Examples of GenericFile


Examples of org.apache.camel.component.file.GenericFile

        existsCounter = 0;

        GenericFileEndpoint endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
        Exchange exchange = endpoint.createExchange();

        GenericFile file = new GenericFile();
        file.setAbsoluteFilePath("target/foo/me.txt");

        GenericFileDeleteProcessStrategy strategy = new GenericFileDeleteProcessStrategy();
        strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);

        assertEquals("Should have tried to delete file 2 times", 2, deleteCounter);
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

        existsCounter = 0;

        GenericFileEndpoint endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
        Exchange exchange = endpoint.createExchange();

        GenericFile file = new GenericFile();
        file.setAbsoluteFilePath("target/foo/boom.txt");

        GenericFileDeleteProcessStrategy strategy = new GenericFileDeleteProcessStrategy();
        try {
            strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);
            fail("Should have thrown an exception");
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

        // set response body according to the message body
        Object body = out.getBody();
        if (body instanceof GenericFile) {
            // grab body from generic file holder
            GenericFile gf = (GenericFile) body;
            body = gf.getBody();
        }

        if (body == null) {
            // empty response
            response.setEntity("", MediaType.TEXT_PLAIN);
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

   
    @FallbackConverter
    public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
        // use a fallback type converter so we can convert the embedded body if the value is GenericFile
        if (GenericFile.class.isAssignableFrom(value.getClass())) {
            GenericFile file = (GenericFile) value;
            Class<?> from = file.getBody().getClass();

            // maybe from is already the type we want
            if (from.isAssignableFrom(type)) {
                return file.getBody();
            }
            // no then try to lookup a type converter
            TypeConverter tc = registry.lookup(type, from);
            if (tc != null) {
                Object body = file.getBody();
                return tc.convertTo(type, exchange, body);
            }
        }
       
        return null;
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

   
    @FallbackConverter
    public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
        // use a fallback type converter so we can convert the embedded body if the value is GenericFile
        if (GenericFile.class.isAssignableFrom(value.getClass())) {
            GenericFile file = (GenericFile) value;
            Class from = file.getBody().getClass();

            // maybe from is already the type we want
            if (from.isAssignableFrom(type)) {
                return file.getBody();
            }
            // no then try to lookup a type converter
            TypeConverter tc = registry.lookup(type, from);
            if (tc != null) {
                Object body = file.getBody();
                return tc.convertTo(type, exchange, body);
            }
        }
       
        return null;
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

     * @return the scanner, is newer <tt>null</tt>
     */
    public static Scanner getScanner(Exchange exchange, Object value) {
        if (value instanceof GenericFile) {
            // generic file is just a wrapper for the real file so call again with the real file
            GenericFile gf = (GenericFile) value;
            return getScanner(exchange, gf.getFile());
        }

        String charset = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
        Scanner scanner = null;
        if (value instanceof Readable) {
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

        existsCounter = 0;

        GenericFileEndpoint endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
        Exchange exchange = endpoint.createExchange();

        GenericFile file = new GenericFile();
        file.setAbsoluteFilePath("target/foo/me.txt");

        GenericFileDeleteProcessStrategy strategy = new GenericFileDeleteProcessStrategy();
        strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);

        assertEquals("Should have tried to delete file 2 times", 2, deleteCounter);
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

        existsCounter = 0;

        GenericFileEndpoint endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
        Exchange exchange = endpoint.createExchange();

        GenericFile file = new GenericFile();
        file.setAbsoluteFilePath("target/foo/boom.txt");

        GenericFileDeleteProcessStrategy strategy = new GenericFileDeleteProcessStrategy();
        try {
            strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);
            fail("Should have thrown an exception");
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

   
    @FallbackConverter
    public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
        // use a fallback type converter so we can convert the embedded body if the value is GenericFile
        if (GenericFile.class.isAssignableFrom(value.getClass())) {
            GenericFile file = (GenericFile) value;
            Class from = file.getBody().getClass();

            // maybe from is already the type we want
            if (from.isAssignableFrom(type)) {
                return file.getBody();
            }
            // no then try to lookup a type converter
            TypeConverter tc = registry.lookup(type, from);
            if (tc != null) {
                Object body = file.getBody();
                return tc.convertTo(type, exchange, body);
            }
        }
       
        return null;
View Full Code Here

Examples of org.apache.camel.component.file.GenericFile

        existsCounter = 0;

        GenericFileEndpoint endpoint = context.getEndpoint("file://target/foo", GenericFileEndpoint.class);
        Exchange exchange = endpoint.createExchange();

        GenericFile file = new GenericFile();
        file.setAbsoluteFilePath("target/foo/me.txt");

        GenericFileDeleteProcessStrategy strategy = new GenericFileDeleteProcessStrategy();
        strategy.commit(new MyGenericFileOperations(), endpoint, exchange, file);

        assertEquals("Should have tried to delete file 2 times", 2, deleteCounter);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.