本文整理汇总了Java中javax.enterprise.inject.spi.Annotated.isAnnotationPresent方法的典型用法代码示例。如果您正苦于以下问题:Java Annotated.isAnnotationPresent方法的具体用法?Java Annotated.isAnnotationPresent怎么用?Java Annotated.isAnnotationPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.enterprise.inject.spi.Annotated
的用法示例。
在下文中一共展示了Annotated.isAnnotationPresent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAppDataValueAsString
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@AppData("PRODUCER")
public String getAppDataValueAsString(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
String key = null;
String value = null;
if (annotated.isAnnotationPresent(AppData.class)) {
AppData annotation = annotated.getAnnotation(AppData.class);
key = annotation.value();
value = properties.getProperty(key);
}
if (value == null) {
throw new IllegalArgumentException("No AppData value found for key " + key);
}
return value;
}
示例2: getUserSetting
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@CoreSetting("PRODUCER")
public String getUserSetting(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
if (annotated.isAnnotationPresent(CoreSetting.class)) {
String settingPath = annotated.getAnnotation(CoreSetting.class).value();
Object object = yamlCoreSettings;
String[] split = settingPath.split("\\.");
int c = 0;
while (c < split.length) {
try {
object = PropertyUtils.getProperty(object, split[c]);
c++;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
LogManager.getLogger(getClass()).error("Failed retrieving setting " + settingPath, e);
return null;
}
}
return String.valueOf(object);
}
return null;
}
示例3: createL10nMap
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
public I18nMap createL10nMap(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
String baseName;
if (annotated.isAnnotationPresent(I18nData.class)) {
baseName = annotated.getAnnotation(I18nData.class).value().getSimpleName();
} else {
baseName = injectionPoint.getBean().getBeanClass().getSimpleName();
}
File langFile = new File(langBase, baseName + ".properties");
I18NMapImpl l10NMap = new I18NMapImpl(commonLang);
try (InputStream stream = new FileInputStream(langFile)) {
l10NMap.load(stream);
} catch (IOException e) {
// I18n data will be injected in all components,
// but a component is not required to have a language definition
// This implementation will return an empty I18nMap containing only able to supply common strings
}
return l10NMap;
}
示例4: nameStrategy
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private static CamelContextNameStrategy nameStrategy(Annotated annotated) {
if (annotated.isAnnotationPresent(ContextName.class)) {
return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value());
} else if (annotated.isAnnotationPresent(Named.class)) {
// TODO: support stereotype with empty @Named annotation
String name = annotated.getAnnotation(Named.class).value();
if (name.isEmpty()) {
if (annotated instanceof AnnotatedField) {
name = ((AnnotatedField) annotated).getJavaMember().getName();
} else if (annotated instanceof AnnotatedMethod) {
name = ((AnnotatedMethod) annotated).getJavaMember().getName();
if (name.startsWith("get")) {
name = decapitalize(name.substring(3));
}
} else {
name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName());
}
}
return new ExplicitCamelContextNameStrategy(name);
} else {
// Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created
return new CdiCamelContextNameStrategy();
}
}
示例5: nameStrategy
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private static CamelContextNameStrategy nameStrategy(Annotated annotated) {
if (annotated.isAnnotationPresent(ContextName.class)) {
return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value());
} else if (annotated.isAnnotationPresent(Named.class)) {
// TODO: support stereotype with empty @Named annotation
String name = annotated.getAnnotation(Named.class).value();
if (name.isEmpty()) {
if (annotated instanceof AnnotatedField) {
name = ((AnnotatedField) annotated).getJavaMember().getName();
} else if (annotated instanceof AnnotatedMethod) {
name = ((AnnotatedMethod) annotated).getJavaMember().getName();
if (name.startsWith("get"))
name = decapitalize(name.substring(3));
} else {
name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName());
}
}
return new ExplicitCamelContextNameStrategy(name);
} else {
// Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created
return new CdiCamelContextNameStrategy();
}
}
示例6: getAnnotation
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
public static <A extends Annotation> Optional<A> getAnnotation(BeanManager beanManager, Annotated annotated, Class<A> annotationType) {
annotated.getAnnotation(annotationType);
if (annotated.getAnnotations().isEmpty()) {
return empty();
}
if (annotated.isAnnotationPresent(annotationType)) {
return Optional.of(annotated.getAnnotation(annotationType));
}
Queue<Annotation> annotations = new LinkedList<>(annotated.getAnnotations());
while (!annotations.isEmpty()) {
Annotation annotation = annotations.remove();
if (annotation.annotationType().equals(annotationType)) {
return Optional.of(annotationType.cast(annotation));
}
if (beanManager.isStereotype(annotation.annotationType())) {
annotations.addAll(
beanManager.getStereotypeDefinition(
annotation.annotationType()
)
);
}
}
return empty();
}
示例7: createCdiFXMLLoader
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
/**
* Create a CDI-aware FXMLLoader.
* If an annotation of type @FXMLLoaderParams can be found, use it's parameters
* to configure the FXMLLoader instance that shall be used to perform the loading
* of the FXML file.
*
* @param injectionPoint
* Injection point.
* @return
* A new FXMLLoader instance.
*/
@Produces
@FXMLLoaderParams
FXMLLoader createCdiFXMLLoader(final InjectionPoint injectionPoint) {
final CdiFXMLLoader fxmlLoader = new CdiFXMLLoader();
final Annotated annotated = injectionPoint.getAnnotated();
final Class<?> declaringClass = injectionPoint.getMember().getDeclaringClass();
if (annotated.isAnnotationPresent(FXMLLoaderParams.class)) {
final FXMLLoaderParams annotation = annotated.getAnnotation(FXMLLoaderParams.class);
initializeFXMLLoader(fxmlLoader, declaringClass, annotation.location(), annotation.resources(), annotation.charset());
}
return fxmlLoader;
}
示例8: isWebRoute
import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private boolean isWebRoute(Annotated annotated) {
return annotated.isAnnotationPresent(WebRoute.class) || annotated.isAnnotationPresent(WebRoutes.class);
}