当前位置: 首页>>代码示例>>Java>>正文


Java Produces类代码示例

本文整理汇总了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;
}
 
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:24,代码来源:ProducerBean.java

示例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;
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:18,代码来源:VersionInfoProducer.java

示例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;
}
 
开发者ID:hantsy,项目名称:javaee8-jaxrs-sample,代码行数:21,代码来源:PasswordEncoderProducer.java

示例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;
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:27,代码来源:UserSettingsProducer.java

示例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));
}
 
开发者ID:wildfly-extras,项目名称:wildfly-microprofile-config,代码行数:17,代码来源:ConfigProducer.java

示例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();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:10,代码来源:BankFactory.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:8,代码来源:BookService.java

示例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;
}
 
开发者ID:fernandomoraes,项目名称:willdfly-swarm-hello-world,代码行数:8,代码来源:LiquibaseProducer.java

示例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;
}
 
开发者ID:opentracing-contrib,项目名称:java-cdi,代码行数:11,代码来源:SpanContextProducer.java

示例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();
}
 
开发者ID:opentracing-contrib,项目名称:java-cdi,代码行数:11,代码来源:SpanContextProducer.java

示例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;
}
 
开发者ID:opentracing-contrib,项目名称:java-cdi,代码行数:11,代码来源:SpanContextProducer.java

示例13: getHTMLizer

import javax.enterprise.inject.Produces; //导入依赖的package包/类
@Produces
public HTMLizer getHTMLizer(){

    HTMLizer htmLizer = HTMLizer.getInstance();
    htmLizer.setGsonBuilder(appContext.getGsonBuilder());
    return htmLizer;

}
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:9,代码来源:MVCReqHandler.java

示例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;
    }
}
 
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:11,代码来源:ProducerBean.java

示例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());
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:11,代码来源:Producers.java


注:本文中的javax.enterprise.inject.Produces类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。