Example usage for org.springframework.messaging Message getPayload

List of usage examples for org.springframework.messaging Message getPayload

Introduction

In this page you can find the example usage for org.springframework.messaging Message getPayload.

Prototype

T getPayload();

Source Link

Document

Return the message payload.

Usage

From source file:apiserver.services.pdf.service.GetPdfInfoCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    PdfGetInfoResult props = (PdfGetInfoResult) message.getPayload();

    try {//from   w  w  w.ja  v  a  2s  .c o  m
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<MapResult> future = exec
                .submit(new GetInfoCallable(props.getFile().getFileBytes(), props.getOptions()));

        MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getData());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.SetPdfInfoCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    PdfSetInfoResult props = (PdfSetInfoResult) message.getPayload();

    try {//from   ww  w . ja v  a 2  s  .  c  om
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<MapResult> future = exec
                .submit(new SetInfoCallable(props.getFile().getFileBytes(), props.getOptions()));

        MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getData());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.images.services.jhlabs.MotionBlurFilterService.java

public Object doFilter(Message<?> message) throws MessageConfigException {
    MotionBlurJob props = (MotionBlurJob) message.getPayload();

    float angle = props.getAngle();
    float distance = props.getDistance();
    float rotation = props.getRotation();
    boolean wrapEdges = props.isWrapEdges();
    float zoom = props.getZoom();

    try {/*from w  w  w .j a v a 2s  .  c o m*/

        //run filter
        MotionBlurFilter filter = new MotionBlurFilter();
        filter.setAngle(angle);
        filter.setDistance(distance);
        filter.setRotation(rotation);
        filter.setWrapEdges(wrapEdges);
        filter.setZoom(zoom);

        BufferedImage bufferedImage = props.getBufferedImage();
        if (bufferedImage == null) {
            throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY);
        }

        BufferedImage outFile = filter.filter(bufferedImage, null);

        props.setBufferedImage(outFile);
        return message;
    } catch (Throwable e) {
        //log.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}

From source file:apiserver.services.pdf.service.OptimizePdfCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    OptimizePdfResult props = (OptimizePdfResult) message.getPayload();

    try {//from   www.  j  ava2s .  c  om
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new OptimizePdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.RemovePdfHeaderFooterCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    OptimizePdfResult props = (OptimizePdfResult) message.getPayload();

    try {/*from w w w.  j ava 2 s.  c  o m*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new RemoveHeaderFooterCallable(props.getFile().getFileBytes(), props.getOptions()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.AddFooterToPdfCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    AddFooterPdfResult props = (AddFooterPdfResult) message.getPayload();

    try {/* www .j av  a 2  s  .  co m*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new AddFooterCallable(props.getFile().getFileBytes(), props.getOptions()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.AddHeaderToPdfCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    AddHeaderPdfResult props = (AddHeaderPdfResult) message.getPayload();

    try {/*ww w .j a  v  a2  s . c  o m*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new AddFooterCallable(props.getFile().getFileBytes(), props.getOptions()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.AddPdfWatermarkCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    WatermarkPdfResult props = (WatermarkPdfResult) message.getPayload();

    try {//from   w  w w  .  j a va 2  s.co  m
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<ByteArrayResult> future = exec
                .submit(new AddWatermarkCallable(props.getFile().getFileBytes(), props.getOptions()));

        ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getBytes());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.ExtractPdfImagesCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    ExtractImageResult props = (ExtractImageResult) message.getPayload();

    try {//from w  ww  . j a va  2 s .  c  om
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<CollectionResult> future = exec
                .submit(new ExtractImageCallable(props.getFile().getFileBytes(), props.getOptions()));

        CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getCollection());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}

From source file:apiserver.services.pdf.service.ExtractPdfTextCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    ExtractTextResult props = (ExtractTextResult) message.getPayload();

    try {/*  w ww .  ja  v  a2s  .c  om*/
        long startTime = System.nanoTime();
        Grid grid = verifyGridConnection();

        // Get grid-enabled executor service for nodes where attribute 'worker' is defined.
        ExecutorService exec = getColdFusionExecutor();

        Future<StringResult> future = exec
                .submit(new ExtractTextCallable(props.getFile().getFileBytes(), props.getOptions()));

        StringResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getResult());

        long endTime = System.nanoTime();
        log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total="
                + (endTime - startTime) + "ms");

        return props;
    } catch (Exception ge) {
        throw new RuntimeException(ge);
    }
}