当前位置: 首页>>代码示例>>Java>>正文


Java ProxyHelper类代码示例

本文整理汇总了Java中org.apache.camel.component.bean.ProxyHelper的典型用法代码示例。如果您正苦于以下问题:Java ProxyHelper类的具体用法?Java ProxyHelper怎么用?Java ProxyHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProxyHelper类属于org.apache.camel.component.bean包,在下文中一共展示了ProxyHelper类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPojoRoutes

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:20,代码来源:RmiIntegrationTest.java

示例2: getInjectionValue

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
/**
 * Creates the object to be injected for an {@link org.apache.camel.EndpointInject} or {@link org.apache.camel.Produce} injection point
 */
public Object getInjectionValue(Class<?> type, String endpointUri, String endpointRef, String endpointProperty,
                                String injectionPointName, Object bean, String beanName) {
    if (type.isAssignableFrom(ProducerTemplate.class)) {
        return createInjectionProducerTemplate(endpointUri, endpointRef, endpointProperty, injectionPointName, bean);
    } else if (type.isAssignableFrom(ConsumerTemplate.class)) {
        return createInjectionConsumerTemplate(endpointUri, endpointRef, endpointProperty, injectionPointName);
    } else {
        Endpoint endpoint = getEndpointInjection(bean, endpointUri, endpointRef, endpointProperty, injectionPointName, true);
        if (endpoint != null) {
            if (type.isInstance(endpoint)) {
                return endpoint;
            } else if (type.isAssignableFrom(Producer.class)) {
                return createInjectionProducer(endpoint, bean, beanName);
            } else if (type.isAssignableFrom(PollingConsumer.class)) {
                return createInjectionPollingConsumer(endpoint, bean, beanName);
            } else if (type.isInterface()) {
                // lets create a proxy
                try {
                    return ProxyHelper.createProxy(endpoint, type);
                } catch (Exception e) {
                    throw createProxyInstantiationRuntimeException(type, endpoint, e);
                }
            } else {
                throw new IllegalArgumentException("Invalid type: " + type.getName()
                        + " which cannot be injected via @EndpointInject/@Produce for: " + endpoint);
            }
        }
        return null;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:CamelPostProcessorHelper.java

示例3: testJavaSpaceRequestReply

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
@Test
public void testJavaSpaceRequestReply() throws Exception {
    Endpoint endpoint = context.getEndpoint("direct:input");
    ITestPojo proxy = ProxyHelper.createProxy(endpoint, ITestPojo.class);
    Request req = new Request();
    long start = System.currentTimeMillis();
    for (int i = 0; i < 100; ++i) {
        req.setPayload("REQUEST " + i);
        Reply reply = proxy.method(req);
        assertTrue(reply.getPayload().equals("REPLY for REQUEST " + i));
    }
    long stop = System.currentTimeMillis();
    log.info("{} took {} milliseconds", getTestMethodName(), stop - start);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:JavaSpaceRequestReplyTest.java

示例4: afterPropertiesSet

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    if (endpoint == null) {
        getCamelContext();
        if (getServiceUrl() == null && getServiceRef() == null) {
            throw new IllegalArgumentException("serviceUrl or serviceRef must be specified.");
        }
        if (getServiceInterface() == null) {
            throw new IllegalArgumentException("serviceInterface must be specified.");
        }

        // lookup endpoint or we have the url for it
        if (getServiceRef() != null) {
            endpoint = getCamelContext().getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class);
        } else {
            endpoint = getCamelContext().getEndpoint(getServiceUrl());
        }

        if (endpoint == null) {
            throw new IllegalArgumentException("Could not resolve endpoint: " + getServiceUrl());
        }
    }

    // binding is enabled by default
    boolean bind = getBinding() != null ? getBinding() : true;

    try {
        // need to start endpoint before we create producer
        ServiceHelper.startService(endpoint);
        producer = endpoint.createProducer();
        // add and start producer
        getCamelContext().addService(producer, true, true);
        Class<?> clazz = blueprintContainer.loadClass(getServiceInterface());
        serviceProxy = ProxyHelper.createProxy(endpoint, bind, producer, clazz);
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:38,代码来源:CamelProxyFactoryBean.java

示例5: afterPropertiesSet

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
    if (endpoint == null) {
        if (ObjectHelper.isNotEmpty(camelContextId)) {
            camelContext = CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId);
        }
        if (camelContext == null) {
            throw new IllegalArgumentException("camelContext or camelContextId must be specified");
        }
        
        if (getServiceUrl() == null && getServiceRef() == null) {
            throw new IllegalArgumentException("serviceUrl or serviceRef must be specified.");
        }

        // lookup endpoint or we have the url for it
        if (getServiceRef() != null) {
            endpoint = camelContext.getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class);
        } else {
            endpoint = camelContext.getEndpoint(getServiceUrl());
        }

        if (endpoint == null) {
            throw new IllegalArgumentException("Could not resolve endpoint: " + getServiceUrl());
        }
    }

    // binding is enabled by default
    boolean bind = getBinding() != null ? getBinding() : true;

    try {
        // need to start endpoint before we create producer
        ServiceHelper.startService(endpoint);
        producer = endpoint.createProducer();
        // add and start producer
        camelContext.addService(producer, true, true);
        serviceProxy = ProxyHelper.createProxy(endpoint, bind, producer, getServiceInterface());
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:CamelProxyFactoryBean.java

示例6: testPojoRoutes

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
@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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:RmiRouteTest.java

示例7: calculator

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
@Produces
@Named("calculatorProxy")
public Calculator calculator(CamelContext context) throws Exception {
    Endpoint endpoint = context.getEndpoint("direct:calculatorProxy");
    Calculator proxy = ProxyHelper.createProxy(endpoint, Calculator.class);
    return proxy;
}
 
开发者ID:hwellmann,项目名称:camel-sjms-demo,代码行数:8,代码来源:CamelContextProducer.java

示例8: testEcho

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
public void testEcho() throws Exception {
    Echo service = ProxyHelper.createProxy(context.getEndpoint("direct:echo"), Echo.class);
    assertEquals("Hello World", service.echo("Hello World"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:ProxyReturnNullIssueTest.java

示例9: testEchoNull

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
public void testEchoNull() throws Exception {
    Echo service = ProxyHelper.createProxy(context.getEndpoint("direct:echo"), Echo.class);
    assertEquals(null, service.echo(null));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:ProxyReturnNullIssueTest.java

示例10: build

import org.apache.camel.component.bean.ProxyHelper; //导入依赖的package包/类
/**
 * Builds the proxy.
 *
 * @param interfaceClasses  the service interface(s)
 * @return the proxied bean
 * @throws Exception is thrown if error creating the proxy
 */
public <T> T build(Class<T>... interfaceClasses) throws Exception {
    ObjectHelper.notNull(endpoint, "endpoint");
    return ProxyHelper.createProxy(endpoint, binding, interfaceClasses);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:ProxyBuilder.java


注:本文中的org.apache.camel.component.bean.ProxyHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。