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


Java Dependent类代码示例

本文整理汇总了Java中javax.enterprise.context.Dependent的典型用法代码示例。如果您正苦于以下问题:Java Dependent类的具体用法?Java Dependent怎么用?Java Dependent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Dependent类属于javax.enterprise.context包,在下文中一共展示了Dependent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decorateContext

import javax.enterprise.context.Dependent; //导入依赖的package包/类
private <X> AnnotatedField<X> decorateContext(AnnotatedField<X> field) {
    final PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
    final UniqueIdentifier identifier = UniqueIdentifierLitteral.random();

    Set<Annotation> templateQualifiers = new HashSet<>();
    templateQualifiers.add(ServiceLiteral.SERVICE);
    if (hasUnitName(persistenceContext)) {
        templateQualifiers.add(new FilterLiteral("(osgi.unit.name=" + persistenceContext.unitName() + ")"));
    }
    Bean<JpaTemplate> bean = manager.getExtension(OsgiExtension.class)
            .globalDependency(JpaTemplate.class, templateQualifiers);

    Set<Annotation> qualifiers = new HashSet<>();
    qualifiers.add(identifier);
    Bean<EntityManager> b = new SimpleBean<>(EntityManager.class, Dependent.class, Collections.singleton(EntityManager.class), qualifiers, () -> {
        CreationalContext<JpaTemplate> context = manager.createCreationalContext(bean);
        JpaTemplate template = (JpaTemplate) manager.getReference(bean, JpaTemplate.class, context);
        return EntityManagerProducer.create(template);
    });
    beans.add(b);

    Set<Annotation> fieldAnnotations = new HashSet<>();
    fieldAnnotations.add(InjectLiteral.INJECT);
    fieldAnnotations.add(identifier);
    return new SyntheticAnnotatedField<>(field, fieldAnnotations);
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:27,代码来源:PersistenceAnnotatedType.java

示例2: decorateUnit

import javax.enterprise.context.Dependent; //导入依赖的package包/类
private <X> AnnotatedField<X> decorateUnit(AnnotatedField<X> field) {
    final PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class);
    final UniqueIdentifier identifier = UniqueIdentifierLitteral.random();

    Set<Annotation> templateQualifiers = new HashSet<>();
    templateQualifiers.add(ServiceLiteral.SERVICE);
    if (hasUnitName(persistenceUnit)) {
        templateQualifiers.add(new FilterLiteral("(osgi.unit.name=" + persistenceUnit.unitName() + ")"));
    }
    Bean<EntityManagerFactory> bean = manager.getExtension(OsgiExtension.class)
            .globalDependency(EntityManagerFactory.class, templateQualifiers);

    Set<Annotation> qualifiers = new HashSet<>();
    qualifiers.add(identifier);
    Bean<EntityManagerFactory> b = new SimpleBean<>(EntityManagerFactory.class, Dependent.class, Collections.singleton(EntityManagerFactory.class), qualifiers, () -> {
        CreationalContext<EntityManagerFactory> context = manager.createCreationalContext(bean);
        return (EntityManagerFactory) manager.getReference(bean, EntityManagerFactory.class, context);
    });
    beans.add(b);

    Set<Annotation> fieldAnnotations = new HashSet<>();
    fieldAnnotations.add(InjectLiteral.INJECT);
    fieldAnnotations.add(identifier);
    return new SyntheticAnnotatedField<>(field, fieldAnnotations);
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:26,代码来源:PersistenceAnnotatedType.java

示例3: produceOptionalConfigValue

import javax.enterprise.context.Dependent; //导入依赖的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

示例4: pathParam

import javax.enterprise.context.Dependent; //导入依赖的package包/类
/**
 * 
 * @param ip
 * @param parser
 * @param msg
 * @param dc
 * @return
 */
@Produces @Dependent @PathParam("nonbinding")
public static String pathParam(InjectionPoint ip, PathParser parser, Message msg, DestinationChanged dc) {
	final String destination;
	if (msg != null) {
		destination = msg.frame().destination().get();
	} else if (dc != null) {
		destination = dc.getDestination();
	} else {
		throw new IllegalStateException("Neither MessageEvent or DestinationEvent is resolvable!");
	}

	final PathParam param = ip
			.getAnnotated()
			.getAnnotation(PathParam.class);
	final Result r = parser.parse(destination);
	if (r.isSuccess()) {
		return r.get(param.value());
	}
	return null;
}
 
开发者ID:dansiviter,项目名称:cito,代码行数:29,代码来源:PathParamProducer.java

示例5: createBeanAdapter

import javax.enterprise.context.Dependent; //导入依赖的package包/类
/**
 * 
 * @param ip
 * @param beanManager
 * @return
 */
private <T> Bean<T> createBeanAdapter(InjectionPoint ip, BeanManager beanManager) {
	final Type type = ip.getType();
	final Class<T> rawType = ReflectionUtils.getRawType(type);
	final ContextualLifecycle<T> lifecycleAdapter = new BodyLifecycle<T>(ip, beanManager);
	final BeanBuilder<T> beanBuilder = new BeanBuilder<T>(beanManager)
			.readFromType(new AnnotatedTypeBuilder<T>().readFromType(rawType).create())
			.beanClass(Body.class) // see https://issues.jboss.org/browse/WELD-2165
			.name(ip.getMember().getName())
			.qualifiers(ip.getQualifiers())
			.beanLifecycle(lifecycleAdapter)
			.scope(Dependent.class)
			.passivationCapable(false)
			.alternative(false)
			.nullable(true)
			.id("BodyBean#" + type.toString())
			.addType(type); //java.lang.Object needs to be present (as type) in any case
	return beanBuilder.create();
}
 
开发者ID:dansiviter,项目名称:cito,代码行数:25,代码来源:BodyProducerExtension.java

示例6: lookup

import javax.enterprise.context.Dependent; //导入依赖的package包/类
/**
 * Creates a SnoopEEServiceClient for the named service.
 *
 * @param ip The injection point
 * @return a configured SnoopEE service client
 */
@SnoopEE
@Produces
@Dependent
public SnoopEEServiceClient lookup(InjectionPoint ip) {

    final String applicationName = ip.getAnnotated().getAnnotation(SnoopEE.class).serviceName();

    LOGGER.config(() -> "producing " + applicationName);

    String serviceUrl = "http://" + readProperty("snoopeeService", snoopeeConfig);
    LOGGER.config(() -> "Service URL: " + serviceUrl);

    return new SnoopEEServiceClient.Builder(applicationName)
            .serviceUrl(serviceUrl)
            .build();
}
 
开发者ID:ivargrimstad,项目名称:snoopee,代码行数:23,代码来源:SnoopEEProducer.java

示例7: afterBeanDiscovery

import javax.enterprise.context.Dependent; //导入依赖的package包/类
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager) {

        final CommandContextImpl commandContext = new CommandContextImpl();

        // Register the command context
        event.addContext(commandContext);

        // Register the command context bean using CDI 2 configurators API
        event.addBean()
            .addType(CommandContext.class)
            .createWith(ctx -> new InjectableCommandContext(commandContext, beanManager))
            .addQualifier(Default.Literal.INSTANCE)
            .scope(Dependent.class)
            .beanClass(CommandExtension.class);

        // Register the CommandExecution bean using CDI 2 configurators API
        event.addBean()
            .createWith(ctx -> commandContext.getCurrentCommandExecution())
            .addType(CommandExecution.class)
            .addQualifier(Default.Literal.INSTANCE)
            .scope(CommandScoped.class)
            .beanClass(CommandExtension.class);
    }
 
开发者ID:weld,项目名称:command-context-example,代码行数:24,代码来源:CommandExtension.java

示例8: produceBooleanProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Boolean produceBooleanProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Boolean.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(boolean.class) ? Boolean.FALSE : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java

示例9: produceIntegerProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Integer produceIntegerProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Integer.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(int.class) ? Integer.valueOf(0) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java

示例10: produceLongProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Long produceLongProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Long.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(long.class) ? Long.valueOf(0L) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java

示例11: produceFloatProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Float produceFloatProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Float.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(float.class) ? Float.valueOf(0f) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java

示例12: produceDoubleProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Double produceDoubleProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);

        if (value != null) {
            return Double.valueOf(value);
        }

        final Type type = injectionPoint.getType();
        return type.equals(double.class) ? Double.valueOf(0d) : null;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:18,代码来源:PropertyProducerBean.java

示例13: produceBigIntegerProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public BigInteger produceBigIntegerProperty(InjectionPoint injectionPoint) {
    try {
        final BigDecimal value = produceBigDecimalProperty(injectionPoint);

        if (value != null) {
            return value.toBigInteger();
        }
    } catch (Exception e) {
        throw new InjectionException(e);
    }

    return null;
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:17,代码来源:PropertyProducerBean.java

示例14: produceDateProperty

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@Property
public Date produceDateProperty(InjectionPoint injectionPoint) {
    try {
        final String value = getProperty(injectionPoint);
        final Date date;

        if (value != null) {
            final Property annotation = injectionPoint.getAnnotated().getAnnotation(Property.class);
            final String pattern = annotation.pattern();
            DateFormat format = new SimpleDateFormat(pattern.isEmpty() ? "yyyy-MM-dd'T'HH:mm:ss.SSSZ" : pattern);
            date = format.parse(value);
        } else {
            date = null;
        }
        return date;
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:22,代码来源:PropertyProducerBean.java

示例15: getDatasourceJndiName

import javax.enterprise.context.Dependent; //导入依赖的package包/类
@Produces
@Dependent
@DefaultDatasource
public String getDatasourceJndiName() {
    if (this.defaultDatasourceJndiName == null && this.defaultDatasourceName != null) {
        for (DataSource ds : this.fraction.subresources().dataSources()) {
            if (this.defaultDatasourceName.equals(ds.getKey())) {
                if (ds.jndiName() != null) {
                    return ds.jndiName();
                }
                return "java:jboss/datasources/" + this.defaultDatasourceName;
            }
        }
    }
    return this.defaultDatasourceJndiName;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:17,代码来源:DatasourceAndDriverCustomizer.java


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