• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PropertyInject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: shouldDeployDefaultCamelContext

import org.apache.camel.PropertyInject; //导入依赖的package包/类
private boolean shouldDeployDefaultCamelContext(Set<Bean<?>> beans) {
    return beans.stream()
        // Is there a Camel bean with the @Default qualifier?
        // Excluding internal components...
        .filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
        .filter(hasType(CamelContextAware.class).or(hasType(Component.class))
            .or(hasType(RouteContainer.class).or(hasType(RoutesBuilder.class))))
        .map(Bean::getQualifiers)
        .flatMap(Set::stream)
        .filter(isEqual(DEFAULT))
        .findAny()
        .isPresent()
        // Or a bean with Camel annotations?
        || concat(camelBeans.stream().map(AnnotatedType::getFields),
                  camelBeans.stream().map(AnnotatedType::getMethods))
        .flatMap(Set::stream)
        .map(Annotated::getAnnotations)
        .flatMap(Set::stream)
        .filter(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
            .or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
            .or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
            .or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
            .or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
        .findAny()
        .isPresent()
        // Or an injection point for Camel primitives?
        || beans.stream()
        // Excluding internal components...
        .filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
        .map(Bean::getInjectionPoints)
        .flatMap(Set::stream)
        .filter(ip -> getRawType(ip.getType()).getName().startsWith("org.apache.camel"))
        .map(InjectionPoint::getQualifiers)
        .flatMap(Set::stream)
        .filter(isAnnotationType(Uri.class).or(isAnnotationType(Mock.class)).or(isEqual(DEFAULT)))
        .findAny()
        .isPresent();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:CdiCamelExtension.java


示例2: setterInjection

import org.apache.camel.PropertyInject; //导入依赖的package包/类
protected void setterInjection(Method method, Object bean, String beanName) {
    PropertyInject propertyInject = method.getAnnotation(PropertyInject.class);
    if (propertyInject != null && getPostProcessorHelper().matchContext(propertyInject.context())) {
        setterPropertyInjection(method, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
    }

    BeanInject beanInject = method.getAnnotation(BeanInject.class);
    if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
        setterBeanInjection(method, beanInject.value(), bean, beanName);
    }

    EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
    if (endpointInject != null && getPostProcessorHelper().matchContext(endpointInject.context())) {
        setterInjection(method, bean, beanName, endpointInject.uri(), endpointInject.ref(), endpointInject.property());
    }

    Produce produce = method.getAnnotation(Produce.class);
    if (produce != null && getPostProcessorHelper().matchContext(produce.context())) {
        setterInjection(method, bean, beanName, produce.uri(), produce.ref(), produce.property());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:DefaultCamelBeanPostProcessor.java


示例3: testPropertyFieldInject

import org.apache.camel.PropertyInject; //导入依赖的package包/类
public void testPropertyFieldInject() throws Exception {
    myProp.put("myTimeout", "2000");
    myProp.put("myApp", "Camel");

    CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);

    MyPropertyFieldBean bean = new MyPropertyFieldBean();

    Field field = bean.getClass().getField("timeout");
    PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
    Class<?> type = field.getType();
    Object value = helper.getInjectionPropertyValue(type, propertyInject.value(), "", "timeout",  bean, "foo");
    assertEquals(Integer.valueOf("2000"), Integer.valueOf("" + value));

    field = bean.getClass().getField("greeting");
    propertyInject = field.getAnnotation(PropertyInject.class);
    type = field.getType();
    value = helper.getInjectionPropertyValue(type, propertyInject.value(), "", "greeting",  bean, "foo");
    assertEquals("Hello Camel", value);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CamelPostProcessorHelperTest.java


示例4: testPropertyFieldDefaultValueInject

import org.apache.camel.PropertyInject; //导入依赖的package包/类
public void testPropertyFieldDefaultValueInject() throws Exception {
    myProp.put("myApp", "Camel");

    CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);

    MyPropertyFieldBean bean = new MyPropertyFieldBean();

    Field field = bean.getClass().getField("timeout");
    PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
    Class<?> type = field.getType();
    Object value = helper.getInjectionPropertyValue(type, propertyInject.value(), "5000", "timeout",  bean, "foo");
    assertEquals(Integer.valueOf("5000"), Integer.valueOf("" + value));

    field = bean.getClass().getField("greeting");
    propertyInject = field.getAnnotation(PropertyInject.class);
    type = field.getType();
    value = helper.getInjectionPropertyValue(type, propertyInject.value(), "", "greeting",  bean, "foo");
    assertEquals("Hello Camel", value);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CamelPostProcessorHelperTest.java


示例5: testPropertyMethodInject

import org.apache.camel.PropertyInject; //导入依赖的package包/类
public void testPropertyMethodInject() throws Exception {
    myProp.put("myTimeout", "2000");
    myProp.put("myApp", "Camel");

    CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);

    MyPropertyMethodBean bean = new MyPropertyMethodBean();

    Method method = bean.getClass().getMethod("setTimeout", int.class);
    PropertyInject propertyInject = method.getAnnotation(PropertyInject.class);
    Class<?> type = method.getParameterTypes()[0];
    Object value = helper.getInjectionPropertyValue(type, propertyInject.value(), "", "timeout",  bean, "foo");
    assertEquals(Integer.valueOf("2000"), Integer.valueOf("" + value));

    method = bean.getClass().getMethod("setGreeting", String.class);
    propertyInject = method.getAnnotation(PropertyInject.class);
    type = method.getParameterTypes()[0];
    value = helper.getInjectionPropertyValue(type, propertyInject.value(), "", "greeting",  bean, "foo");
    assertEquals("Hello Camel", value);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CamelPostProcessorHelperTest.java


示例6: setterInjection

import org.apache.camel.PropertyInject; //导入依赖的package包/类
protected void setterInjection(Method method, Object bean, String beanName) {
    PropertyInject propertyInject = method.getAnnotation(PropertyInject.class);
    if (propertyInject != null && matchContext(propertyInject.context())) {
        setterPropertyInjection(method, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
    }

    BeanInject beanInject = method.getAnnotation(BeanInject.class);
    if (beanInject != null && matchContext(beanInject.context())) {
        setterBeanInjection(method, beanInject.value(), bean, beanName);
    }

    EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
    if (endpointInject != null && matchContext(endpointInject.context())) {
        setterInjection(method, bean, beanName, endpointInject.uri(), endpointInject.ref(), endpointInject.property());
    }

    Produce produce = method.getAnnotation(Produce.class);
    if (produce != null && matchContext(produce.context())) {
        setterInjection(method, bean, beanName, produce.uri(), produce.ref(), produce.property());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CamelNamespaceHandler.java


示例7: processAnnotatedType

import org.apache.camel.PropertyInject; //导入依赖的package包/类
private void processAnnotatedType(@Observes ProcessAnnotatedType<?> pat) {
    if (pat.getAnnotatedType().isAnnotationPresent(Vetoed.class)) {
        pat.veto();
    }
    if (hasAnnotation(pat.getAnnotatedType(), Converter.class)) {
        converters.add(pat.getAnnotatedType().getJavaClass());
    }
    if (hasAnnotation(pat.getAnnotatedType(), BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class)) {
        camelBeans.add(pat.getAnnotatedType());
    }
    if (hasAnnotation(pat.getAnnotatedType(), Consume.class)) {
        eagerBeans.add(pat.getAnnotatedType());
    }
    if (hasAnnotation(pat.getAnnotatedType(), ImportResource.class)) {
        resources.add(pat.getAnnotatedType().getAnnotation(ImportResource.class));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CdiCamelExtension.java


示例8: injectFields

import org.apache.camel.PropertyInject; //导入依赖的package包/类
/**
 * A strategy method to allow implementations to perform some custom JBI
 * based injection of the POJO
 *
 * @param bean the bean to be injected
 */
protected void injectFields(final Object bean, final String beanName) {
    ReflectionHelper.doWithFields(bean.getClass(), new ReflectionHelper.FieldCallback() {
        public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
            PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
            if (propertyInject != null && getPostProcessorHelper().matchContext(propertyInject.context())) {
                injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
            }

            BeanInject beanInject = field.getAnnotation(BeanInject.class);
            if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
                injectFieldBean(field, beanInject.value(), bean, beanName);
            }

            EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
            if (endpointInject != null && getPostProcessorHelper().matchContext(endpointInject.context())) {
                injectField(field, endpointInject.uri(), endpointInject.ref(), endpointInject.property(), bean, beanName);
            }

            Produce produce = field.getAnnotation(Produce.class);
            if (produce != null && getPostProcessorHelper().matchContext(produce.context())) {
                injectField(field, produce.uri(), produce.ref(), produce.property(), bean, beanName);
            }
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:DefaultCamelBeanPostProcessor.java


示例9: injectFields

import org.apache.camel.PropertyInject; //导入依赖的package包/类
/**
 * A strategy method to allow implementations to perform some custom JBI
 * based injection of the POJO
 *
 * @param bean the bean to be injected
 */
protected void injectFields(final Object bean, final String beanName) {
    Class<?> clazz = bean.getClass();
    do {
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
            if (propertyInject != null && matchContext(propertyInject.context())) {
                injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
            }

            BeanInject beanInject = field.getAnnotation(BeanInject.class);
            if (beanInject != null && matchContext(beanInject.context())) {
                injectFieldBean(field, beanInject.value(), bean, beanName);
            }

            EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
            if (endpointInject != null && matchContext(endpointInject.context())) {
                injectField(field, endpointInject.uri(), endpointInject.ref(), endpointInject.property(), bean, beanName);
            }

            Produce produce = field.getAnnotation(Produce.class);
            if (produce != null && matchContext(produce.context())) {
                injectField(field, produce.uri(), produce.ref(), produce.property(), bean, beanName);
            }
        }
        clazz = clazz.getSuperclass();
    } while (clazz != null && clazz != Object.class);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:CamelNamespaceHandler.java


示例10: shouldDeployDefaultCamelContext

import org.apache.camel.PropertyInject; //导入依赖的package包/类
private boolean shouldDeployDefaultCamelContext(BeanManager manager, Set<SyntheticBean<?>> beans) {
    // TODO: find a way to 'pre-filter' by refining the bean types passed to the bean manager
    return concat(manager.getBeans(Object.class, ANY).stream(), beans.stream())
        // Is there a Camel bean with the @Default qualifier?
        // Excluding internal components...
        .filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
        .filter(hasType(CamelContextAware.class).or(hasType(Component.class))
            .or(hasType(RouteContainer.class).or(hasType(RoutesBuilder.class))))
        .map(Bean::getQualifiers)
        .flatMap(Set::stream)
        .anyMatch(isEqual(DEFAULT))
        // Or a bean with Camel annotations?
        || concat(camelBeans.stream().map(AnnotatedType::getFields),
                  camelBeans.stream().map(AnnotatedType::getMethods))
        .flatMap(Set::stream)
        .map(Annotated::getAnnotations)
        .flatMap(Set::stream)
        .anyMatch(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
            .or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
            .or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
            .or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
            .or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
        // Or an injection point for Camel primitives?
        || concat(manager.getBeans(Object.class, ANY).stream(), beans.stream())
        // Excluding internal components...
        .filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
        .map(Bean::getInjectionPoints)
        .flatMap(Set::stream)
        .filter(ip -> getRawType(ip.getType()).getName().startsWith("org.apache.camel"))
        .map(InjectionPoint::getQualifiers)
        .flatMap(Set::stream)
        .anyMatch(isAnnotationType(Uri.class).or(isEqual(DEFAULT)));
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:34,代码来源:CdiCamelExtension.java


示例11: setTimeout

import org.apache.camel.PropertyInject; //导入依赖的package包/类
@PropertyInject("myTimeout")
public void setTimeout(int timeout) {
    this.timeout = timeout;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:CamelPostProcessorHelperTest.java


示例12: setGreeting

import org.apache.camel.PropertyInject; //导入依赖的package包/类
@PropertyInject("Hello {{myApp}}")
public void setGreeting(String greeting) {
    this.greeting = greeting;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:CamelPostProcessorHelperTest.java


示例13: sayHello

import org.apache.camel.PropertyInject; //导入依赖的package包/类
public String sayHello(@PropertyInject("reply") String msg) throws Exception {
    // create a reply message which includes the hostname
    return msg + " from " + InetAddressUtil.getLocalHostName();
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:5,代码来源:HelloBean.java


示例14: camelAnnotations

import org.apache.camel.PropertyInject; //导入依赖的package包/类
private void camelAnnotations(@Observes @WithAnnotations({BeanInject.class, Consume.class,
    EndpointInject.class, Produce.class, PropertyInject.class}) ProcessAnnotatedType<?> pat) {
    camelBeans.add(pat.getAnnotatedType());
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:5,代码来源:CdiCamelExtension.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Fraction类代码示例发布时间:2022-05-22
下一篇:
Java Index类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap