當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。