use of javax.enterprise.inject.Produces in project deltaspike by apache.
the class BroadcasterProducer method jmxBroadcaster.
@Produces
@Dependent
public JmxBroadcaster jmxBroadcaster(final InjectionPoint ip) {
final Class<?> declaringClass = ip.getMember().getDeclaringClass();
final JmxBroadcaster broadcaster = extension.getBroadcasterFor(declaringClass);
if (broadcaster == null) {
//TODO discuss validation during bootstrapping
throw new IllegalStateException("Invalid injection of " + JmxBroadcaster.class.getName() + " in " + declaringClass.getName() + " detected. It is required to annotate the class with @" + MBean.class.getName());
}
return broadcaster;
}
use of javax.enterprise.inject.Produces in project deltaspike by apache.
the class InjectableResourceProducer method getProperties.
@Produces
@InjectableResource(resourceProvider = InjectableResourceProvider.class, location = "")
public Properties getProperties(final InjectionPoint injectionPoint) throws IOException {
InjectableResource injectableResource = getAnnotation(injectionPoint);
InjectableResourceProvider provider = BeanProvider.getContextualReference(injectableResource.resourceProvider());
final Properties properties = provider.readProperties(injectableResource);
return properties;
}
use of javax.enterprise.inject.Produces in project deltaspike by apache.
the class NumberConfigPropertyProducer method produceNumberProperty.
@Produces
@Dependent
@NumberConfig(name = "unused")
public Float produceNumberProperty(InjectionPoint injectionPoint) throws ParseException {
// resolve the annotation
NumberConfig metaData = getAnnotation(injectionPoint, NumberConfig.class);
// get the configured value from the underlying configuration system
String configuredValue = getPropertyValue(metaData.name(), metaData.defaultValue());
if (configuredValue == null) {
return null;
}
// format according to the given pattern
DecimalFormat df = new DecimalFormat(metaData.pattern(), new DecimalFormatSymbols(Locale.US));
return df.parse(configuredValue).floatValue();
}
use of javax.enterprise.inject.Produces 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.inject.Produces in project deltaspike by apache.
the class ViewConfigResolverProducer method createViewConfigResolver.
@Produces
@ApplicationScoped
public ViewConfigResolver createViewConfigResolver() {
if (!viewConfigExtension.isActivated()) {
return createEmptyDefaultViewConfigResolver();
}
if (//esp. for easier unit-tests
!viewConfigExtension.isTransformed()) {
viewConfigExtension.transformMetaDataTree();
}
ViewConfigResolver viewConfigResolver = viewConfigExtension.getViewConfigResolver();
if (viewConfigResolver == null) {
LOG.warning("It wasn't possible to create a ViewConfigResolver");
viewConfigResolver = createEmptyDefaultViewConfigResolver();
}
return viewConfigResolver;
}
Aggregations