當前位置: 首頁>>代碼示例>>Java>>正文


Java Processor類代碼示例

本文整理匯總了Java中org.apache.camel.Processor的典型用法代碼示例。如果您正苦於以下問題:Java Processor類的具體用法?Java Processor怎麽用?Java Processor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Processor類屬於org.apache.camel包,在下文中一共展示了Processor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            from(fromURI).process(new Processor() {
                public void process(final Exchange exchange) throws Exception {
                    QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server");
                    SoapFault fault = new SoapFault("Get the null value of person name", faultCode);
                    Element details = StaxUtils.read(new StringReader(DETAILS)).getDocumentElement();
                    fault.setDetail(details);
                    exchange.setException(fault);
                    
                }
            });
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:CxfConsumerPayloadFaultTest.java

示例2: wrapProcessorInInterceptors

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
	public Processor wrapProcessorInInterceptors(CamelContext context,
			final ProcessorDefinition<?> definition, final Processor target,
			final Processor nextTarget) throws Exception {
		return new DelegateAsyncProcessor(new Processor() {
			@Override
			public void process(Exchange exchange) throws Exception {
//				if(!camelConfig.isRunning()){
//					System.err.println("係統將關閉,不在處理任務");
//					return ;
//				}
				System.out.println("defainition :"+definition);
				System.out.println("nextTarget :"+nextTarget);
				target.process(exchange);
			}
		});
	}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:18,代碼來源:DemoInterceptor.java

示例3: getAfterProducer

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
public Processor getAfterProducer() {
    @SuppressWarnings("unchecked")
    final Processor processor = exchange -> {
        String jsonBean = "";
        if (exchange.getIn().getBody(List.class) != null) {
            //Only grabbing the first record (map) in the list
            @SuppressWarnings("rawtypes")
            List<Map> maps = exchange.getIn().getBody(List.class);
            jsonBean = JSONBeanUtil.toJSONBean(maps.iterator().next());
        } else {
            jsonBean = JSONBeanUtil.toJSONBean(exchange.getIn().getBody(Map.class));
        }
        exchange.getIn().setBody(jsonBean);
    };
    return processor;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:18,代碼來源:SqlConnectorComponent.java

示例4: createEndpoint

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected final Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters)
    throws Exception {
    final DefaultConnectorEndpoint connectorEndpoint = (DefaultConnectorEndpoint) super.createEndpoint(uri, remaining, parameters);

    final DataType inputDataType = connectorEndpoint.getInputDataType();
    final UnmarshallProcessor unmarshallInputProcessor = new UnmarshallInputProcessor(inputDataType);
    final Processor existingBeforeProducer = connectorEndpoint.getBeforeProducer();
    if (existingBeforeProducer == null) {
        connectorEndpoint.setBeforeProducer(unmarshallInputProcessor);
    } else {
        connectorEndpoint.setBeforeProducer(Pipeline.newInstance(getCamelContext(), unmarshallInputProcessor, existingBeforeProducer));
    }

    final DataType outputDataType = connectorEndpoint.getOutputDataType();
    final UnmarshallProcessor unmarshallOutputProcessor = new UnmarshallOutputProcessor(outputDataType);
    final Processor existingAfterProducer = connectorEndpoint.getAfterProducer();
    if (existingAfterProducer == null) {
        connectorEndpoint.setAfterProducer(unmarshallOutputProcessor);
    } else {
        connectorEndpoint.setAfterProducer(Pipeline.newInstance(getCamelContext(), unmarshallOutputProcessor, existingAfterProducer));
    }

    return connectorEndpoint;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:26,代碼來源:SalesforceConnector.java

示例5: shouldNotRemoveExistingProcessors

import org.apache.camel.Processor; //導入依賴的package包/類
@Test
public void shouldNotRemoveExistingProcessors() throws Exception {
    final DefaultConnectorEndpoint endpoint = (DefaultConnectorEndpoint) connectorWithExistingProcessors
        .createEndpoint("salesforce-connector");

    final Processor createdBeforeProducer = endpoint.getBeforeProducer();
    assertThat(createdBeforeProducer).isInstanceOf(Pipeline.class);
    final Pipeline beforePipeline = (Pipeline) createdBeforeProducer;
    assertThat(beforePipeline.getProcessors()).isInstanceOf(List.class).hasSize(2);
    assertThat(((List<Processor>) beforePipeline.getProcessors()).get(0)).isInstanceOf(UnmarshallInputProcessor.class);
    assertThat(((List<Processor>) beforePipeline.getProcessors()).get(1)).isSameAs(beforeProcessor);

    final Processor createdAfterProducer = endpoint.getAfterProducer();
    assertThat(createdAfterProducer).isInstanceOf(Pipeline.class);
    final Pipeline afterPipeline = (Pipeline) createdAfterProducer;
    assertThat(afterPipeline.getProcessors()).isInstanceOf(List.class).hasSize(2);
    assertThat(((List<Processor>) afterPipeline.getProcessors()).get(0)).isInstanceOf(UnmarshallOutputProcessor.class);
    assertThat(((List<Processor>) afterPipeline.getProcessors()).get(1)).isSameAs(afterProcessor);
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:20,代碼來源:SalesforceConnectorTest.java

示例6: configure

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
public void configure() throws Exception {
    
    String jsonBody = "{\"a\":20,\"b\":30}";
    
    from("timer://myTimer?period=1000")
    .setBody().constant(jsonBody)  
    
    .to("sql-stored-connector:DEMO_ADD( "
            + "INTEGER ${body[a]}, "
            + "INTEGER ${body[b]}, "
            + "OUT INTEGER c)")
    .process(new Processor() {
        
        public void process(Exchange exchange)
                throws Exception {
            System.out.println(exchange.getIn()
                    .getBody().getClass());
            System.out.println(exchange.getIn()
                    .getBody());
        }
    });
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:24,代碼來源:TimerSqlStoredRoute.java

示例7: configure

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
public void configure() throws Exception {

    from("sql-stored-start-connector:DEMO_OUT( "
            + "OUT INTEGER C )?schedulerPeriod=5000")
    .process(new Processor() {
        
        public void process(Exchange exchange)
                throws Exception {
            System.out.println(exchange.getIn()
                    .getBody().getClass());
            System.out.println(exchange.getIn()
                    .getBody());
        }
    });
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:17,代碼來源:SqlStoredStartRoute.java

示例8: testMultipartToString

import org.apache.camel.Processor; //導入依賴的package包/類
@Test
public void testMultipartToString() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);

    template.send("direct:a", new Processor() {
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("Hello World");
            exchange.getIn().setHeader(MailConstants.MAIL_ALTERNATIVE_BODY, "Alternative World");
        }
    });

    assertMockEndpointsSatisfied();

    Message mailMessage = mock.getReceivedExchanges().get(0).getIn().getBody(MailMessage.class).getMessage();
    assertNotNull(mailMessage);

    Object content = mailMessage.getContent();
    Multipart mp = assertIsInstanceOf(Multipart.class, content);

    String s = MailConverters.toString(mp);
    assertEquals("Alternative World", s);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:MailConvertersTest.java

示例9: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // leverage the fact that we can limit to max 50 files per poll
            // this will result in polling again and potentially picking up files
            // that already are in progress
            from("file:target/filestress?maxMessagesPerPoll=50&readLock=fileLock").routeId("foo").noAutoStartup()
                .threads(10)
                .process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        // simulate some work with random time to complete
                        Random ran = new Random();
                        int delay = ran.nextInt(250) + 10;
                        Thread.sleep(delay);
                    }
                }).to("mock:result");
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:FileAsyncStressReadLockLockFileTest.java

示例10: testPutAndGetMultiColumns

import org.apache.camel.Processor; //導入依賴的package包/類
@Test
public void testPutAndGetMultiColumns() throws Exception {
    testPutMultiColumns();
    if (systemReady) {
        Exchange resp = template.request("direct:start", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(HBaseConstants.OPERATION, HBaseConstants.GET);
                for (int col = 0; col < column[0].length; col++) {
                    exchange.getIn().setHeader(HBaseAttribute.HBASE_ROW_ID.asHeader(col + 1), key[0]);
                    exchange.getIn().setHeader(HBaseAttribute.HBASE_FAMILY.asHeader(col + 1), family[0]);
                    exchange.getIn().setHeader(HBaseAttribute.HBASE_QUALIFIER.asHeader(col + 1), column[0][col]);
                }
            }
        });

        for (int col = 0; col < column[0].length; col++) {
            assertEquals(body[0][col][0], resp.getOut().getHeader(HBaseAttribute.HBASE_VALUE.asHeader(col + 1)));
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:HBaseProducerTest.java

示例11: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws URISyntaxException {
            JettyHttpComponent componentJetty = (JettyHttpComponent) context.getComponent("jetty");
            componentJetty.setSslPassword(pwd);
            componentJetty.setSslKeyPassword(pwd);
            URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
            componentJetty.setKeystore(keyStoreUrl.toURI().getPath());
            
            from("jetty:https://localhost:" + port1 + "/test").to("mock:a");

            Processor proc = new Processor() {
                public void process(Exchange exchange) throws Exception {
                    exchange.getOut().setBody("<b>Hello World</b>");
                }
            };
            from("jetty:https://localhost:" + port1 + "/hello").process(proc);
            
            from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:HttpsRouteTest.java

示例12: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    port = AvailablePortFinder.getNextAvailable(8000);

    return new RouteBuilder() {
        public void configure() {
            from("jetty:http://localhost:" + port + "/test")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        String name = exchange.getIn().getHeader("name", String.class);
                        ObjectHelper.notNull(name, "name");

                        name = "org/apache/camel/itest/jetty/" + name;
                        InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(exchange.getContext().getClassResolver(), name);
                        String xml = exchange.getContext().getTypeConverter().convertTo(String.class, is);

                        exchange.getOut().setBody(xml);
                        exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/xml");
                    }
                });
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:25,代碼來源:JettyXsltTest.java

示例13: divideByValueOf

import org.apache.camel.Processor; //導入依賴的package包/類
private Processor divideByValueOf(final ValueBuilder valueBuilder) {
	return new Processor() {
		@Override
		public void process(Exchange exchange) throws Exception {
			Message in = exchange.getIn();
			BigDecimal sum = new BigDecimal(checkNotNull(
					in.getBody(Number.class), "Body of %s is null", in)
					.toString());
			BigDecimal divisor = new BigDecimal(checkNotNull(
					valueBuilder.evaluate(exchange, Integer.class),
					"No %s set in exchange %s", valueBuilder, exchange)
					.toString());
			in.setBody(sum.divide(divisor, HALF_UP));
		}

	};
}
 
開發者ID:Ardulink,項目名稱:Ardulink-2,代碼行數:18,代碼來源:MqttCamelRouteBuilder.java

示例14: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:a").recipientList(header("slip"));

            from("jetty://http://localhost:{{port}}/myapp").process(new Processor() {
                public void process(Exchange exchange) throws Exception {
                    int foo = exchange.getIn().getHeader("foo", Integer.class);
                    String bar = exchange.getIn().getHeader("bar", String.class);

                    exchange.getOut().setHeader("foo", foo * 2);
                    exchange.getOut().setBody("Bye " + bar);
                }
            });
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:HttpJettyProducerRecipientListCustomThreadPoolTest.java

示例15: createRouteBuilder

import org.apache.camel.Processor; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {                
            from("netty4:udp://localhost:{{port}}?sync=true")
                .process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        Poetry poetry = (Poetry) exchange.getIn().getBody();
                        poetry.setPoet("Dr. Sarojini Naidu");
                        exchange.getOut().setBody(poetry);
                    }
                });
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:NettyUDPObjectSyncTest.java


注:本文中的org.apache.camel.Processor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。