javax.persistence.Cache#javax.enterprise.inject.spi.InjectionPoint源码实例Demo

下面列出了javax.persistence.Cache#javax.enterprise.inject.spi.InjectionPoint 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public static SubscriptionPublisherInjectionWrapper createInvocationHandler(Bean<?> bean, BeanManager beanManager) {
    SubscriptionPublisherProducer subscriptionPublisherProducer = getSubscriptionPublisherProducerReference(beanManager);
    Class proxiedInterface = SubscriptionPublisherInjection.class;
    Class subscriptionPublisherClass = null;
    Class beanClass = bean.getBeanClass();
    for (InjectionPoint injectionPoint : bean.getInjectionPoints()) {
        if (!injectionPoint.getQualifiers().contains(SUBSCRIPTION_PUBLISHER_ANNOTATION_LITERAL)) {
            continue;
        }
        Type baseType = injectionPoint.getAnnotated().getBaseType();
        if (baseType instanceof Class && SubscriptionPublisher.class.isAssignableFrom((Class) baseType)) {
            subscriptionPublisherClass = (Class) baseType;
            break;
        }
    }
    logger.debug("Found injector {} and publisher {} classes.", proxiedInterface, subscriptionPublisherClass);
    if (subscriptionPublisherClass == null || proxiedInterface == null) {
        throw new JoynrIllegalStateException("Cannot create subscription publisher injection wrapper proxy for bean which doesn't inject a concrete SubscriptionPublisher.");
    }
    return new SubscriptionPublisherInjectionWrapper(proxiedInterface,
                                                     subscriptionPublisherClass,
                                                     subscriptionPublisherProducer,
                                                     beanClass);
}
 
源代码2 项目: thorntail   文件: ConfigurationValueProducer.java
@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));
}
 
源代码3 项目: smallrye-jwt   文件: RawClaimTypeProducer.java
@Produces
@Claim("")
Long getClaimAsLong(InjectionPoint ip) {
    CDILogging.log.getClaimAsLong(ip);
    if (currentToken == null) {
        return null;
    }

    String name = getName(ip);
    Optional<Object> optValue = currentToken.claim(name);
    Long returnValue = null;
    if (optValue.isPresent()) {
        Object value = optValue.get();
        if (value instanceof JsonNumber) {
            JsonNumber jsonValue = (JsonNumber) value;
            returnValue = jsonValue.longValue();
        } else {
            returnValue = Long.parseLong(value.toString());
        }
    }
    return returnValue;
}
 
源代码4 项目: tomee   文件: CheckInjectionPointUsage.java
@Override
public void validate(final EjbModule ejbModule) {
    if (ejbModule.getBeans() == null) {
        return;
    }

    try {
        for (final Field field : ejbModule.getFinder().findAnnotatedFields(Inject.class)) {
            if (!field.getType().equals(InjectionPoint.class) || !HttpServlet.class.isAssignableFrom(field.getDeclaringClass())) {
                continue;
            }

            final Annotation[] annotations = field.getAnnotations();
            if (annotations.length == 1 || (annotations.length == 2 && field.getAnnotation(Default.class) != null)) {
                throw new DefinitionException("Can't inject InjectionPoint in " + field.getDeclaringClass());
            } // else we should check is there is no other qualifier than @Default but too early
        }
    } catch (final NoClassDefFoundError noClassDefFoundError) {
        // ignored: can't check but maybe it is because of an optional dep so ignore it
        // not important to skip it since the failure will be reported elsewhere
        // this validator doesn't check it
    }
}
 
源代码5 项目: deltaspike   文件: CustomConfigPropertyProducer.java
@Produces
@Dependent
@Location
public LocationId produceLocationId(InjectionPoint injectionPoint)
{
    String configuredValue = getStringPropertyValue(injectionPoint);

    /*
    //alternative to @ConfigProperty#defaultValue
    if (configuredValue == null)
    {
        return LocationId.LOCATION_X;
    }
    */
    return LocationId.valueOf(configuredValue.trim().toUpperCase());
}
 
源代码6 项目: datawave   文件: DatawaveConfigPropertyProducer.java
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public List<Double> produceDoubleListConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    
    ArrayList<Double> list = new ArrayList<>();
    if (values != null) {
        for (String value : values) {
            try {
                list.add(Double.parseDouble(value));
            } catch (NumberFormatException nfe) {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Double property '" + configProperty.name() + "' value: " + value + " of "
                                + propertyValue + " happening in bean " + injectionPoint.getBean(), nfe);
            }
            
        }
    }
    return list;
}
 
源代码7 项目: smallrye-config   文件: ConfigExtension.java
protected void registerCustomBeans(@Observes AfterBeanDiscovery abd, BeanManager bm) {
    Set<Class<?>> customTypes = new HashSet<>();
    for (InjectionPoint ip : injectionPoints) {
        Type requiredType = ip.getType();
        if (requiredType instanceof ParameterizedType) {
            ParameterizedType type = (ParameterizedType) requiredType;
            // TODO We should probably handle all parameterized types correctly
            if (type.getRawType().equals(Provider.class) || type.getRawType().equals(Instance.class)) {
                // These injection points are satisfied by the built-in Instance bean 
                Type typeArgument = type.getActualTypeArguments()[0];
                if (typeArgument instanceof Class && !isClassHandledByConfigProducer(typeArgument)) {
                    customTypes.add((Class<?>) typeArgument);
                }
            }
        } else if (requiredType instanceof Class
                && !isClassHandledByConfigProducer(requiredType)) {
            // type is not produced by ConfigProducer
            customTypes.add((Class<?>) requiredType);
        }
    }

    for (Class<?> customType : customTypes) {
        abd.addBean(new ConfigInjectionBean(bm, customType));
    }
}
 
源代码8 项目: javamoney-lib   文件: MonetaryProducer.java
@Produces @Dependent
public static MonetaryAmountFactory amountFactory(InjectionPoint ip){
    Amount specAnnot = ip.getAnnotated()!=null?ip.getAnnotated().getAnnotation(Amount.class):null;
    if(specAnnot!=null){
        return Monetary.getAmountFactory(createAmountQuery(specAnnot));
    }
    return Monetary.getDefaultAmountFactory();
}
 
@Produces
@Dependent
public GroupedConversation getGroupedConversation(InjectionPoint injectionPoint, BeanManager beanManager)
{
    ConversationKey conversationKey =
        ConversationUtils.convertToConversationKey(injectionPoint.getBean(), beanManager);
    return new InjectableGroupedConversation(conversationKey, getGroupedConversationManager());
}
 
源代码10 项目: quarkus   文件: ErasedGenericTest.java
@Produces
@Claim("")
public Optional<String> getStringValue(InjectionPoint ip) {
    String name = getName(ip);
    Optional<String> value = Optional.of(name);
    return value;
}
 
源代码11 项目: smallrye-jwt   文件: OptionalClaimTypeProducer.java
/**
 * Produces an Optional claim value wrapping a Boolean.
 *
 * @param ip reference to the injection point
 * @return an optional claim value
 */
@Produces
@Claim("")
public Optional<Boolean> getOptionalBoolean(InjectionPoint ip) {
    CDILogging.log.getOptionalBoolean(ip);
    if (currentToken == null) {
        return Optional.empty();
    }
    return Optional.ofNullable((Boolean) JsonUtils.convert(Boolean.class, currentToken.getClaim(getName(ip))));
}
 
源代码12 项目: deltaspike   文件: HttpParams.java
@Produces
@HttpParam("")
String getParamValue(InjectionPoint ip)
{
    ServletRequest request = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    return request.getParameter(ip.getAnnotated().getAnnotation(HttpParam.class).value());
}
 
源代码13 项目: weld-junit   文件: MockEjbInjectionServices.java
@Override
public ResourceReferenceFactory<Object> registerEjbInjectionPoint(InjectionPoint injectionPoint) {
    return new ResourceReferenceFactory<Object>() {
        @Override
        public ResourceReference<Object> createResource() {
            return new SimpleResourceReference<Object>(ejbFactory.apply(injectionPoint));
        }
    };
}
 
源代码14 项目: deltaspike   文件: DefaultConfigPropertyProducer.java
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Boolean produceBooleanConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Boolean.class);
}
 
源代码15 项目: smallrye-jwt   文件: RawClaimTypeProducer.java
static String getName(InjectionPoint ip) {
    String name = null;
    for (Annotation ann : ip.getQualifiers()) {
        if (ann instanceof Claim) {
            Claim claim = (Claim) ann;
            name = claim.standard() == Claims.UNKNOWN ? claim.value() : claim.standard().name();
        }
    }
    return name;
}
 
源代码16 项目: smallrye-config   文件: ConfigProducerUtil.java
public static <T> T getValue(InjectionPoint injectionPoint, Config config) {
    String name = getName(injectionPoint);
    if (name == null) {
        return null;
    }
    final SmallRyeConfig src = (SmallRyeConfig) config;
    Converter<T> converter = resolveConverter(injectionPoint, src);
    String rawValue = getRawValue(name, src);
    if (rawValue == null) {
        rawValue = getDefaultValue(injectionPoint);
    }
    T converted;
    if (rawValue == null) {
        // convert an empty value
        try {
            converted = converter.convert("");
        } catch (IllegalArgumentException ignored) {
            throw InjectionMessages.msg.propertyNotFound(name);
        }
    } else {
        converted = converter.convert(rawValue);
    }
    if (converted == null) {
        throw InjectionMessages.msg.propertyNotFound(name);
    }
    return converted;
}
 
源代码17 项目: javamoney-lib   文件: MonetaryProducer.java
@Produces @Dependent
public static CurrencyUnit currencyUnit(InjectionPoint ip){
    AmountCurrency specAnnot = ip.getAnnotated()!=null?
            ip.getAnnotated().getAnnotation(AmountCurrency.class):
            null;
    if(specAnnot==null){
        java.util.Currency jdkDefault = java.util.Currency.getInstance(Locale.getDefault());
        if(jdkDefault!=null) {
            return Monetary.getCurrency(jdkDefault.getCurrencyCode());
        }else{
            throw new MonetaryException("No default currency found.");
        }
    }
    return Monetary.getCurrency(createCurrencyQuery(specAnnot));
}
 
源代码18 项目: deltaspike   文件: DefaultConfigPropertyProducer.java
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Class produceClassConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Class.class);
}
 
源代码19 项目: incubator-batchee   文件: BatchProducerBean.java
@Produces
@BatchProperty
public Pattern producePatternProperty(final InjectionPoint injectionPoint) {
    final String v = produceProperty(injectionPoint);
    if (v != null) {
        return DependencyInjections.convertTo(v, Pattern.class, Pattern.class);
    }
    return null;
}
 
源代码20 项目: smallrye-config   文件: ConfigProducerUtil.java
public static ConfigValue getConfigValue(InjectionPoint injectionPoint, Config config) {
    String name = getName(injectionPoint);
    if (name == null) {
        return null;
    }

    ConfigValue configValue = ((SmallRyeConfig) config).getConfigValue(name);
    if (configValue.getValue() == null) {
        configValue = configValue.withValue(getDefaultValue(injectionPoint));
    }

    return configValue;
}
 
源代码21 项目: smallrye-config   文件: ConfigExtension.java
protected void validate(@Observes AfterDeploymentValidation adv) {
    Config config = ConfigProvider.getConfig(getContextClassLoader());
    Set<String> configNames = StreamSupport.stream(config.getPropertyNames().spliterator(), false).collect(toSet());
    for (InjectionPoint injectionPoint : injectionPoints) {
        Type type = injectionPoint.getType();

        // We don't validate the Optional / Provider / Supplier / ConfigValue for defaultValue.
        if (type instanceof Class && ConfigValue.class.isAssignableFrom((Class<?>) type)
                || type instanceof Class && OptionalInt.class.isAssignableFrom((Class<?>) type)
                || type instanceof Class && OptionalLong.class.isAssignableFrom((Class<?>) type)
                || type instanceof Class && OptionalDouble.class.isAssignableFrom((Class<?>) type)
                || type instanceof ParameterizedType
                        && (Optional.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())
                                || Provider.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())
                                || Supplier.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType()))) {
            return;
        }

        ConfigProperty configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
        String name = ConfigProducerUtil.getConfigKey(injectionPoint, configProperty);

        // Check if the name is part of the properties first. Since properties can be a subset, then search for the actual property for a value.
        if (!configNames.contains(name) && ConfigProducerUtil.getRawValue(name, (SmallRyeConfig) config) == null) {
            if (configProperty.defaultValue().equals(ConfigProperty.UNCONFIGURED_VALUE)) {
                adv.addDeploymentProblem(InjectionMessages.msg.noConfigValue(name));
            }
        }

        try {
            // Check if there is a Converter registed for the injected type
            Converter<?> resolvedConverter = ConfigProducerUtil.resolveConverter(injectionPoint, (SmallRyeConfig) config);

            // Check if the value can be converted. The TCK checks this, but this requires to get the value eagerly.
            // This should not be required!
            SecretKeys.doUnlocked(() -> ((SmallRyeConfig) config).getOptionalValue(name, resolvedConverter));
        } catch (IllegalArgumentException e) {
            adv.addDeploymentProblem(e);
        }
    }
}
 
源代码22 项目: datawave   文件: DatawaveConfigPropertyProducer.java
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public String produceStringConfiguration(InjectionPoint injectionPoint) {
    return super.produceStringConfiguration(injectionPoint);
}
 
源代码23 项目: datawave   文件: DatawaveConfigPropertyProducer.java
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Long produceLongConfiguration(InjectionPoint injectionPoint) {
    return super.produceLongConfiguration(injectionPoint);
}
 
源代码24 项目: camunda-bpm-platform   文件: ProcessVariables.java
/**
 * @since 7.3
 */
@Produces
@ProcessVariableLocalTyped
protected TypedValue getProcessVariableLocalTyped(InjectionPoint ip) {
  String processVariableName = getVariableLocalTypedName(ip);

  if (logger.isLoggable(Level.FINE)) {
    logger.fine("Getting local typed process variable '" + processVariableName + "' from ProcessInstance[" + businessProcess.getProcessInstanceId() + "].");
  }

  return businessProcess.getVariableLocalTyped(processVariableName);
}
 
源代码25 项目: weld-junit   文件: MockResourceInjectionServices.java
private Resource getResourceAnnotation(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    if (annotated instanceof AnnotatedParameter<?>) {
        annotated = ((AnnotatedParameter<?>) annotated).getDeclaringCallable();
    }
    return annotated.getAnnotation(Resource.class);
}
 
源代码26 项目: smallrye-config   文件: ConfigProducerUtil.java
public static String getName(InjectionPoint injectionPoint) {
    for (Annotation qualifier : injectionPoint.getQualifiers()) {
        if (qualifier.annotationType().equals(ConfigProperty.class)) {
            ConfigProperty configProperty = ((ConfigProperty) qualifier);
            return getConfigKey(injectionPoint, configProperty);
        }
    }
    return null;
}
 
@Produces
@Config("")
public String exposeConfig(InjectionPoint injectionPoint) {
    final Config config = injectionPoint.getAnnotated().getAnnotation(Config.class);
    if (config != null)
        return properties.getProperty(config.value());
    return null;
}
 
源代码28 项目: quarkus   文件: BeanOnlyInTestCase.java
@Test
public void testBeanIsInjected() {
    assertNotNull(unusedBean);
    InjectionPoint injectionPoint = unusedBean.getInjectionPoint();
    assertNotNull(injectionPoint);
    assertEquals(UnusedBean.class, injectionPoint.getType());
    assertEquals(1, injectionPoint.getQualifiers().size());
    assertEquals(Default.class, injectionPoint.getQualifiers().iterator().next().annotationType());
    assertTrue(injectionPoint.getMember() instanceof Field);
    assertTrue(injectionPoint.getAnnotated().isAnnotationPresent(Inject.class));
}
 
源代码29 项目: incubator-batchee   文件: BatchProducerBean.java
@Produces
@BatchProperty
public Date produceDateProperty(final InjectionPoint injectionPoint) {
    final String v = produceProperty(injectionPoint);
    if (v != null) {
        return DependencyInjections.convertTo(v, Date.class, Date.class);
    }
    return null;
}
 
源代码30 项目: portals-pluto   文件: PortletParamProducer.java
@Dependent
@PortletParam
@Produces
public Float getFloatParam(ClientDataRequest clientDataRequest, PortletResponse portletResponse,
	InjectionPoint injectionPoint) {

	String value = getStringParam(clientDataRequest, portletResponse, injectionPoint);

	if (value == null) {
		return null;
	}

	Annotated field = injectionPoint.getAnnotated();

	Annotation[] fieldAnnotations = _getFieldAnnotations(field);

	ParamConverter<Float> paramConverter = _getParamConverter(Float.class, field.getBaseType(), fieldAnnotations);

	if (paramConverter != null) {

		try {
			return paramConverter.fromString(value);
		}
		catch (IllegalArgumentException iae) {
			_addBindingError(fieldAnnotations, iae.getMessage(), value);

			return null;
		}
	}

	if (LOG.isWarnEnabled()) {
		LOG.warn("Unable to find a ParamConverterProvider for type Float");
	}

	return null;
}