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

Java InjectionException类代码示例

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

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



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

示例1: mockEndpointFromUri

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Uri("")
@Produces
@Typed(MockEndpoint.class)
// Qualifiers are dynamically added in CdiCamelExtension
private static MockEndpoint mockEndpointFromUri(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension) {
    Uri uri = getQualifierByType(ip, Uri.class).get();
    try {
        CamelContext context = uri.context().isEmpty()
            ? selectContext(ip, instance, extension)
            : selectContext(uri.context(), instance);
        return context.getEndpoint(uri.value(), MockEndpoint.class);
    } catch (Exception cause) {
        throw new InjectionException("Error injecting mock endpoint annotated with " + uri
            + " into " + ip, cause);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CdiCamelFactory.java


示例2: produceBooleanProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Boolean produceBooleanProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Boolean.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(boolean.class) ? Boolean.FALSE : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java


示例3: produceIntegerProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Integer produceIntegerProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Integer.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(int.class) ? Integer.valueOf(0) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java


示例4: produceLongProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Long produceLongProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Long.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(long.class) ? Long.valueOf(0L) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java


示例5: produceFloatProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Float produceFloatProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Float.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(float.class) ? Float.valueOf(0f) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java


示例6: produceDoubleProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Double produceDoubleProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Double.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(double.class) ? Double.valueOf(0d) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java


示例7: produceBigIntegerProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public BigInteger produceBigIntegerProperty(InjectionPoint injectionPoint) {
    try {
        final BigDecimal value = produceBigDecimalProperty(injectionPoint);

        if (value != null) {
            return value.toBigInteger();
        }
    } catch (Exception e) {
        throw new InjectionException(e);
    }

    return null;
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:17,代码来源:PropertyProducerBean.java


示例8: produceDateProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Date produceDateProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);
        final Date date;

        if (value != null) {
            final Property annotation = injectionPoint.getAnnotated().getAnnotation(Property.class);
            final String pattern = annotation.pattern();
            DateFormat format = new SimpleDateFormat(pattern.isEmpty() ? "yyyy-MM-dd'T'HH:mm:ss.SSSZ" : pattern);
            date = format.parse(value);
        } else {
            date = null;
        }
        return date;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:22,代码来源:PropertyProducerBean.java


示例9: produce

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Override
public T produce(CreationalContext<T> ctx) {
    T context = super.produce(ctx);

    // Register the context in the OSGi registry
    BundleContext bundle = BundleContextUtils.getBundleContext(getClass());
    context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle));

    if (!(context instanceof DefaultCamelContext)) {
        // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface
        throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
    }

    DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
    adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle));
    CamelContextNameStrategy strategy = context.getNameStrategy();
    OsgiCamelContextHelper.osgiUpdate(adapted, bundle);
    // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely
    if (!(strategy instanceof DefaultCamelContextNameStrategy)) {
        context.setNameStrategy(strategy);
    }

    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CamelContextOsgiProducer.java


示例10: addRouteToContext

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
private boolean addRouteToContext(Bean<?> routeBean, Bean<?> contextBean, BeanManager manager, AfterDeploymentValidation adv) {
    try {
        CamelContext context = getReference(manager, CamelContext.class, contextBean);
        try {
            Object route = getReference(manager, Object.class, routeBean);
            if (route instanceof RoutesBuilder) {
                context.addRoutes((RoutesBuilder) route);
            } else if (route instanceof RouteContainer) {
                context.addRouteDefinitions(((RouteContainer) route).getRoutes());
            } else {
                throw new IllegalArgumentException(
                    "Invalid routes type [" + routeBean.getBeanClass().getName() + "], "
                        + "must be either of type RoutesBuilder or RouteContainer!");
            }
            return true;
        } catch (Exception cause) {
            adv.addDeploymentProblem(
                new InjectionException(
                    "Error adding routes of type [" + routeBean.getBeanClass().getName() + "] "
                        + "to Camel context [" + context.getName() + "]", cause));
        }
    } catch (Exception exception) {
        adv.addDeploymentProblem(exception);
    }
    return false;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:CdiCamelExtension.java


示例11: setFieldValueOrAddDefinitionError

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
private void setFieldValueOrAddDefinitionError(T instance, Field field, Object value, ValueConverter acceptingConverter) {
	if (acceptingConverter == null) {
		pit.addDefinitionError(new InjectionException(String.format(MESSAGE_NO_CONVERTER_FOUND, field.getName(), field.getType(), pit.getAnnotatedType().getJavaClass().getName())));
	} else if (value == null) {
		pit.addDefinitionError(new InjectionException(String.format(MESSAGE_NO_VALUE_FOUND, field.getName(), field.getType(), pit.getAnnotatedType().getJavaClass().getName())));
	} else {
		try {
			Object convert = acceptingConverter.convert(value);
			boolean accessible = field.isAccessible();
			field.setAccessible(true);
			field.set(instance, convert);
			field.setAccessible(accessible);
		} catch (IllegalAccessException e) {
			pit.addDefinitionError(e);
		}
	}
}
 
开发者ID:coders-kitchen,项目名称:CDIProperties,代码行数:18,代码来源:PropertyInjectionTarget.java


示例12: inject

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Override
public void inject(X instance, CreationalContext<X> ctx) {
    wrapped.inject(instance, ctx);

    final Class<? extends Creature> klass = instance.getClass();
    for (Field field : klass.getDeclaredFields()) {
        field.setAccessible(true);
        final String fieldValueFromXml = xmlBacking.getAttribute(field.getName());
        try {
            if (field.getType().isAssignableFrom(Integer.TYPE)) {
                field.set(instance, Integer.parseInt(fieldValueFromXml));
            } else if (field.getType().isAssignableFrom(String.class)) {
                field.set(instance, fieldValueFromXml);
            } else {
                // TODO: left up for the reader
                throw new InjectionException("Cannot convert to type " + field.getType());
            }
        } catch (IllegalAccessException e) {
            throw new InjectionException("Cannot access field " + field);
        }
    }
}
 
开发者ID:red-fox-mulder,项目名称:eap-6.1-quickstarts,代码行数:23,代码来源:XmlBackedWrappedInjectionTarget.java


示例13: resolve

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
private Neo4jUplink resolve(String connection) {
    if (uplinks.isUnsatisfied()) {
        throw new InjectionException(
                "no neo4j uplinks found. please provide implementation for connection: "
                + connection);
    } else if (uplinks.isAmbiguous()) {
        if ("".equals(connection) || "default"
                .equals(connection)) {
            return uplinks.select(new DefaultLiteral()).get();
        } else {
            for (Neo4jUplink uplink : uplinks) {
                System.out.println("found: " + uplink.getClass().getName());
            }
            return uplinks.select(new NamedLiteral(connection)).get();
        }
    } else if ("".equals(connection) || "default".equals(connection)) {
        return uplinks.get();
    } else {
        throw new InjectionException(
                "cannot find a neo4j-uplink for connection: " + connection);
    }
}
 
开发者ID:etecture,项目名称:dynamic-repositories,代码行数:23,代码来源:Neo4jQueryExecutor.java


示例14: produceProperties

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@PropertyResource
public Properties produceProperties(InjectionPoint point) {
    final Annotated annotated = point.getAnnotated();

    if (point.getType() != Properties.class) {
        throw new InjectionException(Properties.class + " can not be injected to type " + point.getType());
    }

    final Class<?> beanType = point.getBean().getBeanClass();
    final ClassLoader loader = beanType.getClassLoader();
    final PropertyResource annotation = annotated.getAnnotation(PropertyResource.class);
    final PropertyResourceFormat format = annotation.format();

    String locator = annotation.url();

    if (locator.isEmpty()) {
        locator = beanType.getName().replace('.', '/') + ".properties";
    }

    try {
        return factory.getProperties(loader, locator, format);
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:28,代码来源:PropertyResourceProducerBean.java


示例15: produceProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public String produceProperty(InjectionPoint injectionPoint) {
    try {
        return getProperty(injectionPoint);
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:11,代码来源:PropertyProducerBean.java


示例16: produceBigDecimalProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public BigDecimal produceBigDecimalProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);
        final BigDecimal number;

        if (value != null) {
            final Property annotation = injectionPoint.getAnnotated().getAnnotation(Property.class);
            final String pattern = annotation.pattern();

            if (pattern.isEmpty()) {
                number = new BigDecimal(value);
            } else {
                if (logger.isLoggable(Level.FINER)) {
                    logger.log(Level.FINER, "Parsing number with using pattern [" + pattern + ']');
                }

                DecimalFormat format = new DecimalFormat(pattern);
                format.setParseBigDecimal(true);
                number = (BigDecimal) format.parse(value);
            }
        } else {
            number = null;
        }
        return number;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:32,代码来源:PropertyProducerBean.java


示例17: produceJsonArrayProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public JsonArray produceJsonArrayProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);
        return value != null ? Json.createReader(new StringReader(value)).readArray() : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:12,代码来源:PropertyProducerBean.java


示例18: produceJsonObjectProperty

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Produces
@Dependent
@Property
public JsonObject produceJsonObjectProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);
        return value != null ? Json.createReader(new StringReader(value)).readObject() : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:12,代码来源:PropertyProducerBean.java


示例19: testProducePropertyStringInvalid

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Test(expected = InjectionException.class)
public void testProducePropertyStringInvalid() {
    Property property = this.mockProperty("testProducePropertyStringInvalid",
                                          "io/xlate/inject/Invalid.properties",
                                          PropertyResourceFormat.PROPERTIES,
                                          "",
                                          Property.DEFAULT_NULL);
    InjectionPoint point = this.mockInjectionPoint(property, Member.class, "testProducePropertyStringInvalid", -1);
    bean.produceProperty(point);
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:11,代码来源:PropertyProducerBeanTest.java


示例20: testProducePropertyBooleanInvalid

import javax.enterprise.inject.InjectionException; //导入依赖的package包/类
@Test(expected = InjectionException.class)
public void testProducePropertyBooleanInvalid() {
    Property property = this.mockProperty("testProducePropertyBooleanInvalid",
                                          "io/xlate/inject/Invalid.properties",
                                          PropertyResourceFormat.PROPERTIES,
                                          "",
                                          Property.DEFAULT_NULL);
    InjectionPoint point = this.mockInjectionPoint(property, Member.class, "testProducePropertyBooleanInvalid", -1);
    bean.produceBooleanProperty(point);
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:11,代码来源:PropertyProducerBeanTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java TransferState类代码示例发布时间:2022-05-22
下一篇:
Java Dataset类代码示例发布时间: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