Search in sources :

Example 41 with Produces

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;
}
Also used : JmxBroadcaster(org.apache.deltaspike.core.api.jmx.JmxBroadcaster) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Example 42 with Produces

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;
}
Also used : InjectableResourceProvider(org.apache.deltaspike.core.api.resourceloader.InjectableResourceProvider) InjectableResource(org.apache.deltaspike.core.api.resourceloader.InjectableResource) Properties(java.util.Properties) Produces(javax.enterprise.inject.Produces) InjectableResource(org.apache.deltaspike.core.api.resourceloader.InjectableResource)

Example 43 with Produces

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();
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Example 44 with Produces

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);
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Example 45 with Produces

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;
}
Also used : ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Aggregations

Produces (javax.enterprise.inject.Produces)56 Named (javax.inject.Named)32 ApplicationScoped (javax.enterprise.context.ApplicationScoped)25 Properties (java.util.Properties)12 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)12 ArrayList (java.util.ArrayList)6 Dependent (javax.enterprise.context.Dependent)4 ParameterizedType (java.lang.reflect.ParameterizedType)3 Type (java.lang.reflect.Type)3 RequestScoped (javax.enterprise.context.RequestScoped)3 InjectableResource (org.apache.deltaspike.core.api.resourceloader.InjectableResource)3 InjectableResourceProvider (org.apache.deltaspike.core.api.resourceloader.InjectableResourceProvider)3 OperationsFacade (org.gluu.site.ldap.OperationsFacade)3 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)3 FunctionMapperImpl (com.sun.el.lang.FunctionMapperImpl)2 VariableMapperImpl (com.sun.el.lang.VariableMapperImpl)2 CompositeELResolver (javax.el.CompositeELResolver)2 FieldMetaData (org.fusesource.camel.component.sap.model.rfc.FieldMetaData)2 FunctionTemplate (org.fusesource.camel.component.sap.model.rfc.FunctionTemplate)2 ListFieldMetaData (org.fusesource.camel.component.sap.model.rfc.ListFieldMetaData)2