本文整理了Java中javax.enterprise.inject.spi.Annotated
类的一些代码示例,展示了Annotated
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotated
类的具体详情如下:
包路径:javax.enterprise.inject.spi.Annotated
类名称:Annotated
[英]Represents a Java program element that can be annotated.
[中]表示可以注释的Java程序元素。
代码示例来源:origin: oracle/helidon
/**
* Returns the {@link Gauge} matching the criteria from the injection point.
*
* @param <T> type of the {@code Gauge}
* @param registry metric registry
* @param ip injection point being resolved
* @return requested gauge
*/
@Produces
@VendorDefined
@SuppressWarnings("unchecked")
private <T> Gauge<T> produceGauge(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return (Gauge<T>) registry.getGauges().entrySet().stream()
.filter(entry -> entry.getKey().equals(metric.name()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Could not produce Gauge for injection point " + ip.toString()))
.getValue();
}
代码示例来源:origin: wildfly/wildfly
@Override
public ResourceReferenceFactory<Object> registerResourceInjectionPoint(final InjectionPoint injectionPoint) {
final String result = getResourceName(injectionPoint);
if (isKnownNamespace(result) && injectionPoint.getAnnotated().isAnnotationPresent(Produces.class)) {
validateResourceInjectionPointType(getManagedReferenceFactory(getBindInfo(result)), injectionPoint);
}
return new ResourceReferenceFactory<Object>() {
@Override
public ResourceReference<Object> createResource() {
return new SimpleResourceReference<Object>(resolveResource(injectionPoint));
}
};
}
代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-jpa-module-impl
@Produces
@Dependent
@PersistenceUnitName("any") // the value is nonbinding, thus 'any' is just a dummy parameter here
public EntityManagerFactory createEntityManagerFactoryForUnit(InjectionPoint injectionPoint)
{
PersistenceUnitName unitNameAnnotation = injectionPoint.getAnnotated().getAnnotation(PersistenceUnitName.class);
if (unitNameAnnotation == null)
{
LOG.warning("@PersisteneUnitName annotation could not be found at EntityManagerFactory injection point!");
return null;
}
String unitName = unitNameAnnotation.value();
Properties properties = persistenceConfigurationProvider.getEntityManagerFactoryConfiguration(unitName);
EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName, properties);
return emf;
}
}
代码示例来源:origin: oracle/helidon
public void collectConfigProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
if (configProperty != null) {
InjectionPoint ip = pip.getInjectionPoint();
String fullPath = ip.getMember().getDeclaringClass().getName()
+ "." + getFieldName(ip);
Type type = ip.getType();
代码示例来源:origin: thorntail/thorntail
@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));
}
代码示例来源:origin: br.gov.frameworkdemoiselle/demoiselle-jsf
@Inject
public ParameterImpl(InjectionPoint ip) {
if (ip.getAnnotated().isAnnotationPresent(Name.class)) {
this.key = ip.getAnnotated().getAnnotation(Name.class).value();
} else {
this.key = ip.getMember().getName();
}
this.type = Reflections.getGenericTypeArgument(ip.getMember(), 0);
this.viewScoped = ip.getAnnotated().isAnnotationPresent(ViewScoped.class);
this.requestScoped = ip.getAnnotated().isAnnotationPresent(RequestScoped.class);
this.sessionScoped = ip.getAnnotated().isAnnotationPresent(SessionScoped.class);
}
代码示例来源:origin: io.smallrye/smallrye-config
public void collectConfigProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
if (configProperty != null) {
injectionPoints.add(pip.getInjectionPoint());
}
}
代码示例来源:origin: org.apache.myfaces.extensions.cdi.bundles/myfaces-extcdi-bundle-jsf12
@Produces
@Dependent
protected ResourceBundle injectableResourceBundle(InjectionPoint injectionPoint)
{
Bundle bundle = getBundleClass(injectionPoint.getAnnotated().getAnnotations());
if(bundle != null)
{
Class bundleClass = bundle.value();
if(bundleClass != null && !Class.class.getName().equals(bundleClass.getName()))
{
return createDefaultResourceBundle().useBundle(bundleClass);
}
if(!"".equals(bundle.name()))
{
return createDefaultResourceBundle().useBundle(bundle.name());
}
}
return createDefaultResourceBundle();
}
代码示例来源:origin: org.jboss.weld.se/weld-se
if (ij.getAnnotated().getAnnotation(New.class) != null && ij.getQualifiers().size() > 1) {
throw ValidatorLogger.LOG.newWithQualifiers(ij, Formats.formatAsStackTraceElement(ij));
if (ij.getType() instanceof TypeVariable<?>) {
throw ValidatorLogger.LOG.injectionPointWithTypeVariable(ij, Formats.formatAsStackTraceElement(ij));
if (!(ij.getMember() instanceof Field) && ij.getAnnotated().isAnnotationPresent(Named.class) && ij.getAnnotated().getAnnotation(Named.class).value().equals("")) {
throw ValidatorLogger.LOG.nonFieldInjectionPointCannotUseNamed(ij, Formats.formatAsStackTraceElement(ij));
if (ij.getAnnotated().isAnnotationPresent(Produces.class)) {
if (bean != null) {
throw BeanLogger.LOG.injectedFieldCannotBeProducer(ij.getAnnotated(), bean);
checkScopeAnnotations(ij, beanManager.getServices().get(MetaAnnotationStore.class));
checkFacadeInjectionPoint(ij, Instance.class);
checkFacadeInjectionPoint(ij, Event.class);
代码示例来源:origin: com.sun.faces/jsf-impl
/**
* Processing bean.
*
* @param event the event.
*/
public void processBean(@Observes ProcessBean<?> event) {
ViewScoped viewScoped = event.getAnnotated().getAnnotation(ViewScoped.class);
if (viewScoped != null && LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Processing occurrence of @ViewScoped");
}
}
代码示例来源:origin: org.jboss.seam.servlet/seam-servlet
@Produces
@TypedMessageBundle
Object produceTypedMessageBundle(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
if (annotated.isAnnotationPresent(Locale.class)) {
return getBundle(getRawType(injectionPoint.getType()), toLocale(annotated.getAnnotation(Locale.class).value()));
} else {
return getBundle(getRawType(injectionPoint.getType()));
}
}
代码示例来源:origin: org.apache.geronimo/geronimo-openapi-impl
<T> void findEndpointsAndApplication(@Observes final ProcessBean<T> event) {
final String typeName = event.getAnnotated().getBaseType().getTypeName();
if (classes == null && !skipScan && event.getAnnotated().isAnnotationPresent(Path.class) &&
!typeName.startsWith("org.apache.geronimo.microprofile.openapi.") &&
(packages == null || packages.stream().anyMatch(typeName::startsWith))) {
endpoints.add(event.getBean());
}
}
代码示例来源:origin: weld/core
private boolean isInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager) {
if (!Beans.isPassivationCapableDependency(resolvedBean)) {
if (((ij.getMember() instanceof Field) && ij.isTransient())) {
return true;
}
if (ij.getAnnotated() instanceof AnnotatedParameter<?> && ij.getAnnotated().isAnnotationPresent(TransientReference.class)) {
return true;
}
return false;
}
return true;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected String getVariableTypedName(InjectionPoint ip) {
String variableName = ip.getAnnotated().getAnnotation(ProcessVariableTyped.class).value();
if (variableName.length() == 0) {
variableName = ip.getMember().getName();
}
return variableName;
}
代码示例来源:origin: org.jboss.weld.se/weld-se
private void checkScopeAnnotations(InjectionPoint ij, MetaAnnotationStore metaAnnotationStore) {
Annotated annotated = ij.getAnnotated();
if (annotated instanceof EnhancedAnnotated<?, ?>) {
EnhancedAnnotated<?, ?> weldAnnotated = (EnhancedAnnotated<?, ?>) annotated;
Set<Annotation> scopes = weldAnnotated.getMetaAnnotations(Scope.class);
Set<Annotation> normalScopes = weldAnnotated.getMetaAnnotations(NormalScope.class);
for (Annotation annotation : scopes) {
logScopeOnInjectionPointWarning(ij, annotation);
}
for (Annotation annotation : normalScopes) {
logScopeOnInjectionPointWarning(ij, annotation);
}
} else {
for (Annotation annotation : annotated.getAnnotations()) {
if (hasScopeMetaAnnotation(annotation)) {
logScopeOnInjectionPointWarning(ij, annotation);
}
}
}
}
代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl
private void validateStatefulSessionBean(Annotated type)
{
assert type.getBaseType().equals(Cow.class);
assert rawTypeSetMatches(type.getTypeClosure(), Cow.class, CowLocal.class, Object.class);
assert type.getAnnotations().size() == 0;
}
代码示例来源:origin: wildfly/wildfly
public static String getResourceName(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class);
String mappedName = resource.mappedName();
if (!mappedName.equals("")) {
if (injectionPoint.getMember() instanceof Field) {
propertyName = injectionPoint.getMember().getName();
} else if (injectionPoint.getMember() instanceof Method) {
propertyName = getPropertyName((Method) injectionPoint.getMember());
if (propertyName == null) {
代码示例来源:origin: io.smallrye/smallrye-config
public static <T> Optional<T> optionalConfigValue(InjectionPoint injectionPoint, Config config) {
Type type = injectionPoint.getAnnotated().getBaseType();
final Class<T> valueType;
valueType = resolveValueType(type);
return Optional.ofNullable(getValue(injectionPoint, valueType, config));
}
代码示例来源:origin: org.apache.myfaces.core/myfaces-impl
private void addAnnotatedTypeIfNecessary(Annotated annotated)
{
if (annotated.isAnnotationPresent(ManagedProperty.class))
{
Type type = annotated.getBaseType();
types.add(new ManagedPropertyInfo(type, annotated.getAnnotation(ManagedProperty.class).value()));
}
}
代码示例来源:origin: org.jboss.weld.se/weld-se
protected void postSpecialize() {
// Override qualifiers and the bean name
Set<Annotation> qualifiers = new HashSet<Annotation>();
for (Annotation qualifier : attributes().getQualifiers()) {
// Don't include implicit javax.enterprise.inject.Default qualifier
if (!qualifier.equals(DefaultLiteral.INSTANCE) || getAnnotated().isAnnotationPresent(Default.class)) {
qualifiers.add(qualifier);
}
}
String name = attributes().getName();
for (AbstractBean<?, ?> specializedBean : getSpecializedBeans()) {
qualifiers.addAll(specializedBean.getQualifiers());
if (specializedBean.getName() != null) {
name = specializedBean.getName();
}
}
setAttributes(new ImmutableBeanAttributes<T>(qualifiers, name, attributes()));
}
内容来源于网络,如有侵权,请联系作者删除!