本文整理汇总了Java中javax.enterprise.inject.Produces类的典型用法代码示例。如果您正苦于以下问题:Java Produces类的具体用法?Java Produces怎么用?Java Produces使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Produces类属于javax.enterprise.inject包,在下文中一共展示了Produces类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: producePrincipal
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@RequestScoped
@Named("userPrincipal")
public UserPrincipal producePrincipal() {
Object principal = SecurityUtils.getSubject().getPrincipal();
UserPrincipal result = null;
if (principal instanceof UserPrincipal) {
result = (UserPrincipal) principal;
}
/*
FIXME
if (principal instanceof SystemAccountPrincipal) {
SystemAccountPrincipal systemAccountPrincipal = (SystemAccountPrincipal) principal;
String identifier = systemAccountPrincipal.getIdentifier();
result = new UserPrincipal(identifier);
}
*/
if (principal == null) {
result = new UserPrincipal();
}
return result;
}
示例2: getVersionInfo
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public VersionInfo getVersionInfo() {
VersionInfo versionInfo = new VersionInfo();
try {
versionInfo.setVersion(appVersion);
versionInfo.setUserAgent(userAgent);
versionInfo.setBuildDate(new DateTime(buildTimestamp));
} catch (IllegalArgumentException e) {
// In development mode no sources will be filtered yet
versionInfo.setVersion("DEVELOPMENT");
versionInfo.setUserAgent("DEVELOPMENT");
versionInfo.setBuildDate(new DateTime());
}
return versionInfo;
}
示例3: passwordEncoder
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@Crypto
public PasswordEncoder passwordEncoder(InjectionPoint ip) {
Crypto crypto = ip.getAnnotated().getAnnotation(Crypto.class);
Crypto.Type type = crypto.value();
PasswordEncoder encoder;
switch (type) {
case PLAIN:
encoder = new PlainPasswordEncoder();
break;
case BCRYPT:
encoder = new BCryptPasswordEncoder();
break;
default:
encoder = new PlainPasswordEncoder();
break;
}
return encoder;
}
示例4: getUserSetting
import javax.enterprise.inject.Produces; //导入依赖的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;
}
示例5: produceOptionalConfigValue
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Dependent
@Produces @ConfigProperty
<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(getValue(injectionPoint, valueType));
}
示例6: createBank
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@BankProducer
public Bank createBank(@Any Instance<Bank> instance, InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
BankType bankTypeAnnotation = annotated.getAnnotation(BankType.class);
Class<? extends Bank> bankType = bankTypeAnnotation.value().getBankType();
return instance.select(bankType).get();
}
示例7: getDraftBooks
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Draft
@Produces
public List<Book> getDraftBooks() {
Book[] books = new Book[] { new Book("Glassfish", "Luca Stancapiano", DRAFT),
new Book("Maven working", "Luca Stancapiano", DRAFT) };
return asList(books);
}
示例8: getPublishedBooks
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Published
@Produces
public List<Book> getPublishedBooks() {
Book[] books = new Book[] {
new Book("Mastering Java EE Development with WildFly 10", "Luca Stancapiano", PUBLISHED),
new Book("Gatein Cookbook", "Luca Stancapiano", PUBLISHED) };
return asList(books);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:9,代码来源:PublishService.java
示例9: createConfig
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@LiquibaseType
public CDILiquibaseConfig createConfig() {
final CDILiquibaseConfig config = new CDILiquibaseConfig();
config.setChangeLog("liquibase/db.changelog.xml");
return config;
}
示例10: produceSpanContext
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public SpanContext produceSpanContext() {
SpanContext spanContext = (SpanContext) request.getAttribute(TracingFilter.SERVER_SPAN_CONTEXT);
if (null == spanContext) {
log.warning("A SpanContext has been requested, but none could be found on the HTTP request's " +
"attributes. Make sure the Servlet integration is on the classpath!");
}
return spanContext;
}
示例11: produceSpan
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public Span produceSpan(InjectionPoint ip) {
Scope scope = tracer.scopeManager().active();
if (null == scope) {
String spanName = ip.getMember().getName();
return tracer.buildSpan(spanName).startActive().span();
}
return scope.span();
}
示例12: produceScope
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public Scope produceScope(InjectionPoint ip) {
Scope scope = tracer.scopeManager().active();
if (null == scope) {
String spanName = ip.getMember().getName();
return tracer.buildSpan(spanName).startActive();
}
return scope;
}
示例13: getHTMLizer
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public HTMLizer getHTMLizer(){
HTMLizer htmLizer = HTMLizer.getInstance();
htmLizer.setGsonBuilder(appContext.getGsonBuilder());
return htmLizer;
}
示例14: produceUser
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@Named("loggedInUser")
public String produceUser() {
Object principal = SecurityUtils.getSubject().getPrincipal();
if (principal != null) {
return principal.toString();
} else {
return null;
}
}
示例15: produceLabels
import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
@DatasetLabels
public List<String> produceLabels() {
String labelsProperty = System.getProperty(LABELS_PROPERTY);
if (labelsProperty == null) {
throw new Error("Provide comma separated values for the dataset labels using the system property "
+ LABELS_PROPERTY);
}
return Stream.of(labelsProperty.split("\\,")).collect(Collectors.toList());
}