use of javax.enterprise.context.Dependent in project deltaspike by apache.
the class JsfMessageProducer method createJsfMessage.
@Produces
@Dependent
public <M> JsfMessage<M> createJsfMessage(InjectionPoint injectionPoint, MessageBundleInvocationHandler invocationHandler) {
if (!(injectionPoint.getType() instanceof ParameterizedType)) {
throw new IllegalArgumentException("JsfMessage must be used as generic type");
}
ParameterizedType paramType = (ParameterizedType) injectionPoint.getType();
Type[] actualTypes = paramType.getActualTypeArguments();
if (actualTypes.length != 1) {
throw new IllegalArgumentException("JsfMessage must have the MessageBundle as generic type parameter");
}
try {
@SuppressWarnings("unchecked") Class<M> type = (Class<M>) actualTypes[0];
return createJsfMessageFor(injectionPoint, type, invocationHandler);
} catch (ClassCastException e) {
throw new IllegalArgumentException("Incorrect class found when trying to convert to parameterized type", e);
}
}
use of javax.enterprise.context.Dependent in project wildfly-swarm by wildfly-swarm.
the class ConfigurationValueProducer method produceOptionalConfigValue.
@SuppressWarnings("unchecked")
@ConfigurationValue("")
@Dependent
@Produces
<T> Optional<T> produceOptionalConfigValue(InjectionPoint injectionPoint) {
Type type = injectionPoint.getAnnotated().getBaseType();
final Class<T> valueType;
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type[] typeArguments = parameterizedType.getActualTypeArguments();
valueType = unwrapType(typeArguments[0]);
} else {
valueType = (Class<T>) String.class;
}
return Optional.ofNullable(resolve(injectionPoint, valueType));
}
Aggregations