本文整理汇总了Java中javax.enterprise.inject.spi.DeploymentException类的典型用法代码示例。如果您正苦于以下问题:Java DeploymentException类的具体用法?Java DeploymentException怎么用?Java DeploymentException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeploymentException类属于javax.enterprise.inject.spi包,在下文中一共展示了DeploymentException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
public void validate(@Observes AfterDeploymentValidation add, BeanManager bm) {
List<String> deploymentProblems = new ArrayList<>();
Config config = ConfigProvider.getConfig();
for (InjectionPoint injectionPoint : injectionPoints) {
Type type = injectionPoint.getType();
ConfigProperty configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
if (type instanceof Class) {
String key = getConfigKey(injectionPoint, configProperty);
if (!config.getOptionalValue(key, (Class)type).isPresent()) {
String defaultValue = configProperty.defaultValue();
if (defaultValue == null ||
defaultValue.equals(ConfigProperty.UNCONFIGURED_VALUE)) {
deploymentProblems.add("No Config Value exists for " + key);
}
}
}
}
if (!deploymentProblems.isEmpty()) {
add.addDeploymentProblem(new DeploymentException("Error while validating Configuration\n"
+ String.join("\n", deploymentProblems)));
}
}
开发者ID:wildfly-extras,项目名称:wildfly-microprofile-config,代码行数:27,代码来源:ConfigExtension.java
示例2: getOptionalContextInfo
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@Produces
Optional<JWTAuthContextInfo> getOptionalContextInfo() {
if (!publicKeyPemEnc.isPresent()) {
return Optional.empty();
}
JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
try {
RSAPublicKey pk = (RSAPublicKey) KeyUtils.decodePublicKey(publicKeyPemEnc.get());
contextInfo.setSignerKey(pk);
} catch (Exception e) {
throw new DeploymentException(e);
}
if (issuedBy != null && !issuedBy.equals("NONE")) {
contextInfo.setIssuedBy(issuedBy);
}
if (expGracePeriodSecs.isPresent()) {
contextInfo.setExpGracePeriodSecs(expGracePeriodSecs.get());
}
return Optional.of(contextInfo);
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:21,代码来源:JWTAuthContextInfoProvider.java
示例3: processClaimValueInjections
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
log.debugf("pipRaw: %s", pip.getInjectionPoint());
InjectionPoint ip = pip.getInjectionPoint();
if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
Class rawClass = (Class) ip.getType();
if (Modifier.isFinal(rawClass.getModifiers())) {
Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
rawTypes.add(ip.getType());
rawTypeQualifiers.add(claim);
log.debugf("+++ Added Claim raw type: %s", ip.getType());
Class declaringClass = ip.getMember().getDeclaringClass();
Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
pip.addDefinitionError(new DeploymentException(err));
}
}
}
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:22,代码来源:MPJWTExtension.java
示例4: validate
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
public void validate(@Observes AfterDeploymentValidation add) {
List<String> deploymentProblems = new ArrayList<>();
config = ConfigProvider.getConfig();
for (InjectionPoint injectionPoint : injectionPoints) {
Type type = injectionPoint.getType();
ConfigProperty configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
if (type instanceof Class) {
// a direct injection of a ConfigProperty
// that means a Converter must exist.
String key = ConfigInjectionBean.getConfigKey(injectionPoint, configProperty);
if (!config.getOptionalValue(key, (Class) type).isPresent()) {
deploymentProblems.add("No Config Value exists for " + key);
}
}
}
if (!deploymentProblems.isEmpty()) {
add.addDeploymentProblem(new DeploymentException("Error while validating Configuration\n"
+ String.join("\n", deploymentProblems)));
}
}
开发者ID:struberg,项目名称:javaConfig,代码行数:25,代码来源:ConfigExtension.java
示例5: produce
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@Override
public T produce(CreationalContext<T> cc) {
T context = super.produce(cc);
// 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 DeploymentException("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:astefanutti,项目名称:camel-cdi,代码行数:23,代码来源:CamelContextOsgiProducer.java
示例6: addRouteToContext
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的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 DeploymentException("Error adding routes of type [" + routeBean.getBeanClass().getName() + "] "
+ "to Camel context [" + context.getName() + "]", cause));
}
} catch (Exception exception) {
adv.addDeploymentProblem(exception);
}
return false;
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:25,代码来源:CdiCamelExtension.java
示例7: deploy
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "missingConverterOnInstanceInjectionTest.jar")
.addClass(CustomConverterBean.class)
.addAsManifestResource(new StringAsset("my.customtype.value=xxxxx"), "javaconfig.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);
WebArchive war = ShrinkWrap
.create(WebArchive.class, "missingConverterOnInstanceInjectionTest.war")
.addAsLibrary(testJar);
return war;
}
开发者ID:eclipse,项目名称:ConfigJSR,代码行数:16,代码来源:MissingConverterOnInstanceInjectionTest.java
示例8: deploy
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "missingValueOnInstanceInjectionTest.jar")
.addClass(ConfigOwner.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);
WebArchive war = ShrinkWrap
.create(WebArchive.class, "missingValueOnInstanceInjectionTest.war")
.addAsLibrary(testJar);
return war;
}
开发者ID:eclipse,项目名称:ConfigJSR,代码行数:15,代码来源:MissingValueOnInstanceInjectionTest.java
示例9: deploy
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "wrongConverterOnInstanceInjectionTest.jar")
.addClass(ConfigOwner.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource(new StringAsset("my.long.value=xxxxx"), "javaconfig.properties")
.as(JavaArchive.class);
WebArchive war = ShrinkWrap
.create(WebArchive.class, "wrongConverterOnInstanceInjectionTest.war")
.addAsLibrary(testJar);
return war;
}
开发者ID:eclipse,项目名称:ConfigJSR,代码行数:16,代码来源:WrongConverterOnInstanceInjectionTest.java
示例10: deploy
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "missingConverterOnInstanceInjectionTest.jar")
.addClass(CustomConverterBean.class)
.addAsManifestResource(new StringAsset("my.customtype.value=xxxxx"), "microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);
WebArchive war = ShrinkWrap
.create(WebArchive.class, "missingConverterOnInstanceInjectionTest.war")
.addAsLibrary(testJar);
return war;
}
开发者ID:eclipse,项目名称:microprofile-config,代码行数:16,代码来源:MissingConverterOnInstanceInjectionTest.java
示例11: deploy
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
JavaArchive testJar = ShrinkWrap
.create(JavaArchive.class, "wrongConverterOnInstanceInjectionTest.jar")
.addClass(ConfigOwner.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource(new StringAsset("my.long.value=xxxxx"), "microprofile-config.properties")
.as(JavaArchive.class);
WebArchive war = ShrinkWrap
.create(WebArchive.class, "wrongConverterOnInstanceInjectionTest.war")
.addAsLibrary(testJar);
return war;
}
开发者ID:eclipse,项目名称:microprofile-config,代码行数:16,代码来源:WrongConverterOnInstanceInjectionTest.java
示例12: transform
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
public Throwable transform(Throwable throwable) {
// Arquillian sometimes returns InvocationException with nested
// exception and sometimes exception itself
@SuppressWarnings("unchecked")
List<Throwable> throwableList = ExceptionUtils.getThrowableList(throwable);
if (throwableList.isEmpty())
return throwable;
Throwable root = null;
if (throwableList.size() == 1) {
root = throwable;
} else {
root = ExceptionUtils.getRootCause(throwable);
}
if (root instanceof DeploymentException || root instanceof DefinitionException) {
return root;
}
if (isFragmentFound(DEPLOYMENT_EXCEPTION_FRAGMENTS, root)) {
return new DeploymentException(root.getMessage());
}
if (isFragmentFound(DEFINITION_EXCEPTION_FRAGMENTS, root)) {
return new DefinitionException(root.getMessage());
}
return throwable;
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:29,代码来源:SwarmDeploymentExceptionTransformer.java
示例13: processClaimProviderInjections
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
/**
* Collect the types of all Provider injection points annotated with {@linkplain Claim}.
*
* @param pip - the injection point event information
*/
void processClaimProviderInjections(@Observes ProcessInjectionPoint<?, ? extends Provider> pip) {
log.debugf("pip: %s", pip.getInjectionPoint());
final InjectionPoint ip = pip.getInjectionPoint();
if (ip.getAnnotated().isAnnotationPresent(Claim.class)) {
Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
throw new DeploymentException("@Claim at: " + ip + " has no name or valid standard enum setting");
}
boolean usesEnum = claim.standard() != Claims.UNKNOWN;
final String claimName = usesEnum ? claim.standard().name() : claim.value();
log.debugf("Checking Provider Claim(%s), ip: %s", claimName, ip);
ClaimIP claimIP = claims.get(claimName);
Type matchType = ip.getType();
Type actualType = ((ParameterizedType) matchType).getActualTypeArguments()[0];
// Don't add Optional as this is handled specially
if (!optionalOrJsonValue(actualType)) {
rawTypes.add(actualType);
} else if (!actualType.getTypeName().startsWith("javax.json.Json")) {
// Validate that this is not an Optional<JsonValue>
Type innerType = ((ParameterizedType) actualType).getActualTypeArguments()[0];
if (!innerType.getTypeName().startsWith("javax.json.Json")) {
providerOptionalTypes.add(actualType);
providerQualifiers.add(claim);
}
}
rawTypeQualifiers.add(claim);
ClaimIPType key = new ClaimIPType(claimName, actualType);
if (claimIP == null) {
claimIP = new ClaimIP(actualType, actualType, false, claim);
claimIP.setProviderSite(true);
claims.put(key, claimIP);
}
claimIP.getInjectionPoints().add(ip);
log.debugf("+++ Added Provider Claim(%s) ip: %s", claimName, ip);
}
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:43,代码来源:MPJWTExtension.java
示例14: produce
import javax.enterprise.inject.spi.DeploymentException; //导入依赖的package包/类
@Override
public T produce(CreationalContext<T> cc) {
T context = super.produce(cc);
// Do not override the name if it's been already set (in the bean constructor for example)
if (context.getNameStrategy() instanceof DefaultCamelContextNameStrategy)
context.setNameStrategy(nameStrategy(annotated));
// Add bean registry and Camel injector
if (context instanceof DefaultCamelContext) {
DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
adapted.setRegistry(new CdiCamelRegistry(manager));
adapted.setInjector(new CdiCamelInjector(context.getInjector(), manager));
} else {
// Fail fast for the time being to avoid side effects by the time these two methods get declared on the CamelContext interface
throw new DeploymentException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
}
// Add event notifier if at least one observer is present
Set<Annotation> qualifiers = annotated.getAnnotations().stream()
.filter(isAnnotationType(Named.class).negate()
.and(q -> manager.isQualifier(q.annotationType())))
.collect(toSet());
qualifiers.add(Any.Literal.INSTANCE);
if (qualifiers.size() == 1)
qualifiers.add(Default.Literal.INSTANCE);
qualifiers.retainAll(manager.getExtension(CdiCamelExtension.class).getObserverEvents());
if (!qualifiers.isEmpty())
context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));
return context;
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:33,代码来源:CamelContextProducer.java
注:本文中的javax.enterprise.inject.spi.DeploymentException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论