Java 类org.apache.camel.util.jndi.JndiContext 实例源码

项目:Camel    文件:XsltReferenceParameterTest.java   
public void setUp() throws Exception {
    JndiRegistry registry = new JndiRegistry(new JndiContext());
    RouteBuilder builder = createRouteBuilder();
    CamelContext context = new DefaultCamelContext(registry);

    testConverter = new TestConverter();
    testTransformerFactory = TransformerFactory.newInstance();

    registry.bind("testConverter", testConverter);
    registry.bind("testTransformerFactory", testTransformerFactory);

    ProcessorEndpoint pep1 = context.getEndpoint(TEST_URI_1, ProcessorEndpoint.class);

    context.addRoutes(builder);
    context.start();

    builder1 = (XsltBuilder)pep1.getProcessor();
}
项目:Camel    文件:BeanLookupUsingJndiRegistryIssueTest.java   
public void testCamelWithJndi() throws Exception {
    JndiContext jndi = new JndiContext();
    jndi.bind("foo", new MyOtherDummyBean());

    CamelContext camel = new DefaultCamelContext(jndi);
    camel.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").bean("foo");
        }
    });
    camel.start();

    String reply = camel.createProducerTemplate().requestBody("direct:start", "Camel", String.class);
    assertEquals("Hello Camel", reply);

    camel.stop();
}
项目:fuse-bxms-integ    文件:JsonQueryTest.java   
/** configures camel-drools integration and defines 3 routes:
 * 1) testing route (connection to drools with JSON command format)
 * 2) unmarshalling route (for unmarshalling command results)
 * 3) marshalling route (enables creating commands through API and converting to JSON) */
private CamelContext configure(KieSession session) throws Exception {
    Context context = new JndiContext();
    context.bind("ksession", session);

    CamelContext camelContext = new DefaultCamelContext(context);
    camelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:test-session").policy(new KiePolicy()).unmarshal("json").to("kie://ksession").marshal("json");
            from("direct:unmarshall").policy(new KiePolicy()).unmarshal("json");
            from("direct:marshall").policy(new KiePolicy()).marshal("json");
        }

    });

    return camelContext;
}
项目:fuse-bxms-integ    文件:JaxbInsertTest.java   
/** configures camel-drools integration and defines 3 routes:
 * 1) testing route (connection to drools with JAXB command format)
 * 2) unmarshalling route (for unmarshalling command results)
 * 3) marshalling route (enables creating commands through API and converting to XML) */
private CamelContext configure(StatefulKnowledgeSession session) throws Exception {
    Context context = new JndiContext();
    context.bind("ksession", session);

    CamelContext camelContext = new DefaultCamelContext(context);
    camelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            JaxbDataFormat jdf = new JaxbDataFormat();
            jdf.setContextPath("org.kie.camel.testdomain");
            jdf.setPrettyPrint(true);

            from("direct:test-session").policy(new KiePolicy()).unmarshal(jdf).to("kie://ksession").marshal(jdf);
            from("direct:unmarshall").policy(new KiePolicy()).unmarshal(jdf);
            from("direct:marshall").policy(new KiePolicy()).marshal(jdf);
        }
    });

    return camelContext;
}
项目:wildfly-camel    文件:RmiIntegrationTest.java   
@Test
public void testPojoRoutes() throws Exception {

    JndiContext jndctx = new JndiContext();
    jndctx.bind("bye", new SayService("Good Bye!"));

    CamelContext camelContext = new DefaultCamelContext(jndctx);
    camelContext.addRoutes(createRouteBuilder(camelContext));

    camelContext.start();
    try {
        Endpoint endpoint = camelContext.getEndpoint("direct:hello");
        ISay proxy = ProxyHelper.createProxy(endpoint, false, ISay.class);
        String rc = proxy.say();
        Assert.assertEquals("Good Bye!", rc);
    } finally {
        camelContext.stop();
    }
}
项目:drinkwater-java    文件:MockJndiContextFactoryRule.java   
public MockJndiContextFactoryRule() {

        try {
            this.context = new JndiContext();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:bitbreeds-webrtc    文件:SimpleSignalingExample.java   
/**
 * Application entry point
 * @param args application arguments
 * @throws Exception
 */
public static void main(String... args) throws Exception {
    JndiRegistry reg = new JndiRegistry(new JndiContext());

    reg.bind("sslContextParameters",sslParameters());

    CamelContext ctx = new DefaultCamelContext(reg);
    ctx.addRoutes(new WebsocketRouteNoSSL());
    ctx.setUseMDCLogging(true);
    ctx.setTracing(true);
    ctx.start();
}
项目:bitbreeds-webrtc    文件:SimpleSignalingExample.java   
/**
 * Application entry point
 * @param args application arguments
 * @throws Exception
 */
public static void main(String... args) throws Exception {

    JndiRegistry reg = new JndiRegistry(new JndiContext());

    reg.bind("sslContextParameters",sslParameters());

    CamelContext ctx = new DefaultCamelContext(reg);
    ctx.addRoutes(new WebsocketRouteNoSSL());
    ctx.setUseMDCLogging(true);
    ctx.setTracing(true);
    ctx.start();
}
项目:drinkwater-java    文件:MockJndiContextFactoryRule.java   
public MockJndiContextFactoryRule() {

        try {
            this.context = new JndiContext();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:Camel    文件:BeanRecipientListTimeoutTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());
    answer.bind("myStrategy", new MyAggregationStrategy());
    return answer;
}
项目:Camel    文件:BeanOgnMethodWithXPathInjectionTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", myBean);
    answer.bind("myOtherBean", myOtherBean);
    return answer;
}
项目:Camel    文件:BeanPipelineTest.java   
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("foo", new FooBean());
    answer.bind("bar", new BarBean());
    answer.bind("baz", new BazBean());
    return answer;
}
项目:Camel    文件:BeanInPipelineTest.java   
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("one", new MyBean("one"));
    answer.bind("two", new MyBean("two"));
    answer.bind("three", new MyBean("three"));
    return answer;
}
项目:Camel    文件:BeanWithAnnotationInheritedTest.java   
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("b", new B());
    answer.bind("p", Proxy.newProxyInstance(I1.class.getClassLoader(), new Class[]{I1.class}, new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (method.getName().equals("m1")) {
                return args[0].toString() + args[1].toString();
            } else {
                return null;
            }
        }
    }));
    return answer;
}
项目:Camel    文件:ExpressionAnnotationToDisambiguateMethodsTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", myBean);
    answer.bind("myOtherBean", myOtherBean);
    return answer;
}
项目:Camel    文件:RemoveEndpointsTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:NettyAsyncRequestReplyTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("activemq", amq);
    return answer;
}
项目:Camel    文件:ShiroOverJmsTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsIntegrationTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", myBean);

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsValidatorTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsHttpPostIssueTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsPollEnrichTest.java   
@Override
protected Context createJndiContext() throws Exception {
    deleteDirectory("activemq-data");

    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker which must be persistent
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createPersistentConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsResequencerTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);
    answer.bind("activemq", amq);

    answer.bind("myBean1", b1);
    answer.bind("myBean2", b2);
    answer.bind("myBean3", b3);
    return answer;
}
项目:Camel    文件:JmsJaxbTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsJettyAsyncTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("activemq", amq);
    return answer;
}
项目:Camel    文件:JmsPerformanceTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("myBean", new MyBean());

    // add AMQ client and make use of connection pooling we depend on because of the (large) number
    // of the JMS messages we do produce
    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("activemq", amq);
    return answer;
}
项目:Camel    文件:DynamicRouteTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);
    answer.bind("jms", amq);
    answer.bind("myBean", new MyBean());
    return answer;
}
项目:Camel    文件:JmsHttpJmsTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);
    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:JmsHttpPostIssueWithMockTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);

    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:HttpJmsAsyncTimeoutTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);
    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:HttpAsyncDslTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // add ActiveMQ with embedded broker
    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
    amq.setCamelContext(context);
    answer.bind("jms", amq);
    return answer;
}
项目:Camel    文件:AtomEntryPollingConsumerTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext jndi = new JndiContext();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
    jndi.bind("myDate", df.parse("2007-11-13 14:35:00 +0100"));
    return jndi;
}
项目:Camel    文件:RssEntryPollingConsumerWithFilterTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();

    // timestamp from the feed to use as base
    // Fri, 31 Oct 2008 12:02:21 -0500
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-5:00"));
    cal.set(2008, Calendar.OCTOBER, 31, 12, 02, 21);

    answer.bind("myBean", new MyBean(cal.getTime()));
    return answer;
}
项目:Camel    文件:MinaFiltersTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    IoFilter myFilter = new TestFilter();
    List<IoFilter> myFilters = new ArrayList<IoFilter>();
    myFilters.add(myFilter);

    answer.bind("myFilters", myFilters);
    answer.bind("myFilter", myFilter);
    return answer;
}
项目:Camel    文件:Mina2FiltersTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    IoFilter myFilter = new TestFilter();
    List<IoFilter> myFilters = new ArrayList<IoFilter>();
    myFilters.add(myFilter);

    answer.bind("myFilters", myFilters);
    answer.bind("myFilter", myFilter);
    return answer;
}
项目:Camel    文件:RmiRouteTest.java   
@Test
public void testPojoRoutes() throws Exception {
    if (classPathHasSpaces()) {
        return;
    }

    // Boot up a local RMI registry
    LocateRegistry.createRegistry(getPort());

    // START SNIPPET: register
    JndiContext context = new JndiContext();
    context.bind("bye", new SayService("Good Bye!"));

    CamelContext camelContext = new DefaultCamelContext(context);
    // END SNIPPET: register

    camelContext.addRoutes(getRouteBuilder(camelContext));

    camelContext.start();

    // START SNIPPET: invoke
    Endpoint endpoint = camelContext.getEndpoint("direct:hello");
    ISay proxy = ProxyHelper.createProxy(endpoint, false, ISay.class);
    String rc = proxy.say();
    assertEquals("Good Bye!", rc);
    // END SNIPPET: invoke

    camelContext.stop();
}
项目:myjavacode    文件:CamelTest.java   
/**
 * Camel简单入门
 * @throws Exception
 */
@Test
public void testCamelForBean() throws Exception {
    JndiContext context = new JndiContext();
    CamelLeaveBean leave = new CamelLeaveBean();
    context.bind("leave", leave);

    CamelContext camelContext = new DefaultCamelContext(context);

    camelContext.addRoutes(new CamelLeaveRoute());
    camelContext.start();
    ProducerTemplate tpl = camelContext.createProducerTemplate();

    // true
    tpl.sendBody("direct:start", Collections.singletonMap("days", 2));
    assertFalse(leave.getResult());

    // false
    tpl.sendBody("direct:start", Collections.singletonMap("days", 5));
    assertTrue(leave.getResult());

    // Set<LeaveBean> byType = camelContext.getRegistry().findByType(LeaveBean.class);
    // System.out.println("aa=" + ((LeaveBean)byType.iterator().next()).getResult());

    /*tpl.sendBody("direct:forProperty", Collections.singletonMap("days", 2));
    String result = System.getProperty("ok");
    assertEquals("false", result);

    tpl.sendBody("direct:forProperty", Collections.singletonMap("days", 5));
    result = System.getProperty("ok");
    assertEquals("true", result);*/

    camelContext.stop();
}
项目:activiti-in-action-codes    文件:CamelTest.java   
/**
 * Camel简单入门
 * @throws Exception
 */
@Test
public void testCamelForBean() throws Exception {
    JndiContext context = new JndiContext();
    CamelLeaveBean leave = new CamelLeaveBean();
    context.bind("leave", leave);

    CamelContext camelContext = new DefaultCamelContext(context);

    camelContext.addRoutes(new CamelLeaveRoute());
    camelContext.start();
    ProducerTemplate tpl = camelContext.createProducerTemplate();

    // true
    tpl.sendBody("direct:start", Collections.singletonMap("days", 2));
    assertFalse(leave.getResult());

    // false
    tpl.sendBody("direct:start", Collections.singletonMap("days", 5));
    assertTrue(leave.getResult());

    // Set<LeaveBean> byType = camelContext.getRegistry().findByType(LeaveBean.class);
    // System.out.println("aa=" + ((LeaveBean)byType.iterator().next()).getResult());

    /*tpl.sendBody("direct:forProperty", Collections.singletonMap("days", 2));
    String result = System.getProperty("ok");
    assertEquals("false", result);

    tpl.sendBody("direct:forProperty", Collections.singletonMap("days", 5));
    result = System.getProperty("ok");
    assertEquals("true", result);*/

    camelContext.stop();
}
项目:syndesis    文件:ThrottleTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("addTime", new TimerBean());
    return answer;
}
项目:syndesis    文件:LogTest.java   
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    answer.bind("addTime", new TimerBean());
    return answer;
}