javax.enterprise.inject.Default Java Examples

The following examples show how to use javax.enterprise.inject.Default. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandLineArgsExtension.java    From thorntail with Apache License 2.0 6 votes vote down vote up
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) {
    CommonBean<String[]> stringBean = CommonBeanBuilder.newBuilder(String[].class)
            .beanClass(CommandLineArgsExtension.class)
            .scope(Dependent.class)
            .createSupplier(() -> args)
            .addQualifier(CommandLineArgs.Literal.INSTANCE)
            .addType(String[].class)
            .addType(Object.class).build();
    abd.addBean(stringBean);
    CommonBean<List> listBean = CommonBeanBuilder.newBuilder(List.class)
            .beanClass(CommandLineArgsExtension.class)
            .scope(Dependent.class)
            .createSupplier(() -> argsList)
            .addQualifier(Default.Literal.INSTANCE)
            .addType(List.class)
            .addType(Object.class).build();
    abd.addBean(listBean);
}
 
Example #2
Source File: BeanArchives.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static IndexView buildAdditionalIndex() {
    Indexer indexer = new Indexer();
    // CDI API
    index(indexer, ActivateRequestContext.class.getName());
    index(indexer, Default.class.getName());
    index(indexer, Any.class.getName());
    index(indexer, Named.class.getName());
    index(indexer, Initialized.class.getName());
    index(indexer, BeforeDestroyed.class.getName());
    index(indexer, Destroyed.class.getName());
    index(indexer, Intercepted.class.getName());
    index(indexer, Model.class.getName());
    // Arc built-in beans
    index(indexer, ActivateRequestContextInterceptor.class.getName());
    index(indexer, InjectableRequestContextController.class.getName());
    return indexer.complete();
}
 
Example #3
Source File: AnnotatedTypeBuilderTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Test
public void modifyAnnotationsOnConstructorParameter() throws NoSuchMethodException
{
    final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
    builder.readFromType(Cat.class, true);
    builder.removeFromConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, Default.class);
    builder.addToConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, new AnyLiteral());

    final AnnotatedType<Cat> catAnnotatedType = builder.create();
    Set<AnnotatedConstructor<Cat>> catCtors = catAnnotatedType.getConstructors();

    assertThat(catCtors.size(), is(2));

    for (AnnotatedConstructor<Cat> ctor : catCtors)
    {
        if (ctor.getParameters().size() == 2)
        {
            List<AnnotatedParameter<Cat>> ctorParams = ctor.getParameters();

            assertThat(ctorParams.get(1).getAnnotations().size(), is(1));
            assertThat((AnyLiteral) ctorParams.get(1).getAnnotations().toArray()[0], is(new AnyLiteral()));
        }
    }
}
 
Example #4
Source File: ConversationKey.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
public ConversationKey(Class<?> groupKey, Annotation... qualifiers)
{
    this.groupKey = groupKey;

    //TODO maybe we have to add a real qualifier instead
    Class<? extends Annotation> annotationType;
    for (Annotation qualifier : qualifiers)
    {
        annotationType = qualifier.annotationType();

        if (Any.class.isAssignableFrom(annotationType) ||
                Default.class.isAssignableFrom(annotationType) ||
                Named.class.isAssignableFrom(annotationType) ||
                ConversationGroup.class.isAssignableFrom(annotationType))
        {
            //won't be used for this key!
            continue;
        }

        if (this.qualifiers == null)
        {
            this.qualifiers = new HashSet<Annotation>();
        }
        this.qualifiers.add(qualifier);
    }
}
 
Example #5
Source File: InjectionPointMetadataTest.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "serial" })
@Test
public void testObserverInjectionPointMetadata() {
    AtomicReference<InjectionPoint> ip = new AtomicReference<>();
    Arc.container().beanManager().getEvent().select(new TypeLiteral<AtomicReference<InjectionPoint>>() {
    }).fire(ip);
    InjectionPoint injectionPoint = ip.get();
    assertNotNull(injectionPoint);
    assertEquals(Controlled.class, injectionPoint.getType());
    Set<Annotation> qualifiers = injectionPoint.getQualifiers();
    assertEquals(1, qualifiers.size());
    assertEquals(Default.class, qualifiers.iterator().next().annotationType());
    Assertions.assertNull(injectionPoint.getBean());
    assertNotNull(injectionPoint.getAnnotated());
    assertTrue(injectionPoint.getAnnotated() instanceof AnnotatedParameter);
    AnnotatedParameter<Controller> annotatedParam = (AnnotatedParameter<Controller>) injectionPoint.getAnnotated();
    assertEquals(Controlled.class, annotatedParam.getBaseType());
    assertEquals(1, annotatedParam.getAnnotations().size());
    assertFalse(annotatedParam.isAnnotationPresent(Inject.class));
    assertTrue(annotatedParam.isAnnotationPresent(FooAnnotation.class));
    assertTrue(annotatedParam.getAnnotation(Singleton.class) == null);
    assertTrue(annotatedParam.getAnnotations(Singleton.class).isEmpty());
}
 
Example #6
Source File: TransactionStrategyHelper.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
/**
 * <p>This method uses the InvocationContext to scan the &#064;Transactional
 * interceptor for a manually specified Qualifier.</p>
 *
 * <p>If none is given (defaults to &#04;Any.class) then we scan the intercepted
 * instance and resolve the Qualifiers of all it's injected EntityManagers.</p>
 *
 * <p>Please note that we will only pickup the first Qualifier on the
 * injected EntityManager. We also do <b>not</b> parse for binding or
 * &h#064;NonBinding values. A &#064;Qualifier should not have any parameter at all.</p>
 * @param entityManagerMetadata the metadata to locate the entity manager
 * @param interceptedTargetClass the Class of the intercepted target
 */
public Set<Class<? extends Annotation>> resolveEntityManagerQualifiers(EntityManagerMetadata entityManagerMetadata,
                                                                       Class interceptedTargetClass)
{
    Set<Class<? extends Annotation>> emQualifiers = new HashSet<>();
    Class<? extends Annotation>[] qualifierClasses = entityManagerMetadata.getQualifiers();

    if (qualifierClasses == null || qualifierClasses.length == 1 && Any.class.equals(qualifierClasses[0]) )
    {
        // this means we have no special EntityManager configured in the interceptor
        // thus we should scan all the EntityManagers ourselfs from the intercepted class
        collectEntityManagerQualifiersOnClass(emQualifiers, interceptedTargetClass);
    }
    else
    {
        // take the qualifierKeys from the qualifierClasses
        Collections.addAll(emQualifiers, qualifierClasses);
    }

    //see DELTASPIKE-320
    if (emQualifiers.isEmpty())
    {
        emQualifiers.add(Default.class);
    }
    return emQualifiers;
}
 
Example #7
Source File: InterfaceConfigPropertiesUtil.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Add a method like this:
 * 
 * <pre>
 *  &#64;Produces
 *  public SomeConfig produceSomeClass(Config config) {
 *      return new SomeConfigQuarkusImpl(config)
 *  }
 * </pre>
 */
static void addProducerMethodForInterfaceConfigProperties(ClassCreator classCreator, DotName interfaceName,
        String prefix, boolean needsQualifier, String generatedClassName) {
    String methodName = "produce" + interfaceName.withoutPackagePrefix();
    if (needsQualifier) {
        // we need to differentiate the different producers of the same class
        methodName = methodName + "WithPrefix" + HashUtil.sha1(prefix);
    }
    try (MethodCreator method = classCreator.getMethodCreator(methodName, interfaceName.toString(),
            Config.class.getName())) {

        method.addAnnotation(Produces.class);
        if (needsQualifier) {
            method.addAnnotation(AnnotationInstance.create(DotNames.CONFIG_PREFIX, null,
                    new AnnotationValue[] { AnnotationValue.createStringValue("value", prefix) }));
        } else {
            method.addAnnotation(Default.class);
        }
        method.returnValue(method.newInstance(MethodDescriptor.ofConstructor(generatedClassName, Config.class),
                method.getMethodParam(0)));
    }
}
 
Example #8
Source File: MakeJCacheCDIInterceptorFriendly.java    From commons-jcs with Apache License 2.0 6 votes vote down vote up
public HelperBean(final AnnotatedType<CDIJCacheHelper> annotatedType,
                  final InjectionTarget<CDIJCacheHelper> injectionTarget,
                  final String id) {
    this.at = annotatedType;
    this.it = injectionTarget;
    this.id =  "JCS#CDIHelper#" + id;

    this.qualifiers = new HashSet<>();
    this.qualifiers.add(new AnnotationLiteral<Default>() {

        /**
         * 
         */
        private static final long serialVersionUID = 3314657767813459983L;});
    this.qualifiers.add(new AnnotationLiteral<Any>() {

        /**
         * 
         */
        private static final long serialVersionUID = 7419841275942488170L;});
}
 
Example #9
Source File: CheckInjectionPointUsage.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void validate(final EjbModule ejbModule) {
    if (ejbModule.getBeans() == null) {
        return;
    }

    try {
        for (final Field field : ejbModule.getFinder().findAnnotatedFields(Inject.class)) {
            if (!field.getType().equals(InjectionPoint.class) || !HttpServlet.class.isAssignableFrom(field.getDeclaringClass())) {
                continue;
            }

            final Annotation[] annotations = field.getAnnotations();
            if (annotations.length == 1 || (annotations.length == 2 && field.getAnnotation(Default.class) != null)) {
                throw new DefinitionException("Can't inject InjectionPoint in " + field.getDeclaringClass());
            } // else we should check is there is no other qualifier than @Default but too early
        }
    } catch (final NoClassDefFoundError noClassDefFoundError) {
        // ignored: can't check but maybe it is because of an optional dep so ignore it
        // not important to skip it since the failure will be reported elsewhere
        // this validator doesn't check it
    }
}
 
Example #10
Source File: RepositoryMetadataInitializer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public RepositoryMetadata init(Class<?> repositoryClass, BeanManager beanManager)
{
    RepositoryMetadata repositoryMetadata = new RepositoryMetadata(repositoryClass);
    // read from looks for JPA Transactional and EntityManagerConfig to determine attributes
    // if those are set, don't process old annotations
    if (!repositoryMetadata.readFrom(repositoryClass, beanManager))
    {
        repositoryMetadata.setEntityManagerResolverClass(extractEntityManagerResolver(repositoryClass));
        repositoryMetadata.setEntityManagerFlushMode(extractEntityManagerFlushMode(repositoryClass));

        if (repositoryMetadata.getEntityManagerResolverClass() != null)
        {
            Set<Bean<?>> beans = beanManager.getBeans(repositoryMetadata.getEntityManagerResolverClass());
            Class<? extends Annotation> scope = beanManager.resolve(beans).getScope();
            repositoryMetadata.setEntityManagerResolverIsNormalScope(beanManager.isNormalScope(scope));
        }
        else
        {
            EntityManagerResolver resolver;
            if (repositoryMetadata.getQualifiers() != null)
            {
                resolver = new QualifierBackedEntityManagerResolver(beanManager,
                        repositoryMetadata.getQualifiers());
            }
            else
            {
                resolver = new QualifierBackedEntityManagerResolver(beanManager, Default.class);
            }
            repositoryMetadata.setUnmanagedResolver(resolver);
            repositoryMetadata.setEntityManagerResolverIsNormalScope(false);
        }
    }
    repositoryMetadata.setEntityMetadata(entityMetadataInitializer.init(repositoryMetadata));
    initializeMethodsMetadata(repositoryMetadata, beanManager);
    
    return repositoryMetadata;
}
 
Example #11
Source File: DefaultTestServiceProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Default //optional
@Dependent
public InterceptedTestService createInterceptedTestService(@TestServiceQualifier(DEFAULT) InterceptedTestService interceptedTestService)
{
    return interceptedTestService; //the exposed result is an intercepted instance
}
 
Example #12
Source File: ProjectStageProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * We can only produce @Dependent scopes since an enum is final.
 * @return current ProjectStage
 */
@Produces
@Dependent
@Default
public ProjectStage getProjectStage()
{
    if (projectStage == null)
    {
        //triggers initialization
        getInstance();
    }
    return projectStage;
}
 
Example #13
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeDefaultEntityManager(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountDefaultEntityManager++;
}
 
Example #14
Source File: TestEntityManagerProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
protected void closeDefaultEntityManager(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
    closeEntityManagerCountDefaultEntityManager++;
}
 
Example #15
Source File: Resources.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Default
@RequestScoped
public EntityManager create()
{
    return this.entityManagerFactory.createEntityManager();
}
 
Example #16
Source File: Resources.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public void dispose(@Disposes @Default EntityManager entityManager)
{
    if (entityManager.isOpen())
    {
        entityManager.close();
    }
}
 
Example #17
Source File: Resources.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Default
@RequestScoped
public EntityManager create()
{
    return this.entityManagerFactory.createEntityManager();
}
 
Example #18
Source File: TransactionStrategyHelper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * Scan the given class and return all the injected EntityManager fields.
 * <p>Attention: we do only pick up EntityManagers which use &#064;Inject!</p>
 */
private void collectEntityManagerQualifiersOnClass(Set<Class<? extends Annotation>> emQualifiers,Class target)
{
    // first scan all declared fields
    Field[] fields = target.getDeclaredFields();

    for (Field field : fields)
    {
        if (EntityManager.class.equals(field.getType()))
        {
            // also check if this is an injected EM
            if (field.getAnnotation(Inject.class) != null)
            {
                boolean qualifierFound = false;
                Class<? extends Annotation> qualifier = getFirstQualifierAnnotation(field.getAnnotations());
                if (qualifier != null)
                {
                    emQualifiers.add(qualifier);
                    qualifierFound = true;
                }

                if (!qualifierFound)
                {
                    // according to the CDI injection rules @Default is assumed
                    emQualifiers.add(Default.class);
                }
            }
        }
    }

    // finally recurse into the superclasses
    Class superClass = target.getSuperclass();
    if (!Object.class.equals(superClass))
    {
        collectEntityManagerQualifiersOnClass(emQualifiers, superClass);
    }
}
 
Example #19
Source File: AnnotatedTypeBuilderTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testCtWithMultipleParams()
{
    final AnnotatedTypeBuilder<TypeWithParamsInCt> builder = new AnnotatedTypeBuilder<TypeWithParamsInCt>();
    builder.readFromType(TypeWithParamsInCt.class);
    builder.addToClass(new AnnotationLiteral<Default>() {});

    AnnotatedType<TypeWithParamsInCt> newAt = builder.create();
    assertNotNull(newAt);
}
 
Example #20
Source File: FlywayExtension.java    From tutorials with MIT License 5 votes vote down vote up
void afterBeanDiscovery(@Observes AfterBeanDiscovery abdEvent, BeanManager bm) {
    abdEvent.addBean()
            .types(javax.sql.DataSource.class, DataSource.class)
            .qualifiers(new AnnotationLiteral<Default>() {}, new AnnotationLiteral<Any>() {})
            .scope(ApplicationScoped.class)
            .name(DataSource.class.getName())
            .beanClass(DataSource.class)
            .createWith(creationalContext -> {
                DataSource instance = new DataSource();
                instance.setUrl(dataSourceDefinition.url());
                instance.setDriverClassName(dataSourceDefinition.className());
                return instance;
            });
}
 
Example #21
Source File: AnnotatedTypeBuilderTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testEnumWithParam()
{
    final AnnotatedTypeBuilder<EnumWithParams> builder = new AnnotatedTypeBuilder<EnumWithParams>();
    builder.readFromType(EnumWithParams.class);
    builder.addToClass(new AnnotationLiteral<Default>() {});

    AnnotatedType<EnumWithParams> newAt = builder.create();
    assertNotNull(newAt);
}
 
Example #22
Source File: MPJWTCDIExtension.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void registerClaimProducer(@Observes final AfterBeanDiscovery abd, final BeanManager bm) {

        final Set<Type> types = injectionPoints.stream()
                .filter(NOT_PROVIDERS)
                .filter(NOT_INSTANCES)
                .map(ip -> REPLACED_TYPES.getOrDefault(ip.getType(), ip.getType()))
                .collect(Collectors.<Type>toSet());

        final Set<Type> providerTypes = injectionPoints.stream()
                .filter(NOT_PROVIDERS.negate())
                .map(ip -> ((ParameterizedType) ip.getType()).getActualTypeArguments()[0])
                .collect(Collectors.<Type>toSet());

        final Set<Type> instanceTypes = injectionPoints.stream()
                .filter(NOT_INSTANCES.negate())
                .map(ip -> ((ParameterizedType) ip.getType()).getActualTypeArguments()[0])
                .collect(Collectors.<Type>toSet());

        types.addAll(providerTypes);
        types.addAll(instanceTypes);

        types.stream()
                .map(type -> new ClaimBean<>(bm, type))
                .forEach((Consumer<ClaimBean>) abd::addBean);

        abd.addBean()
                .id(MPJWTCDIExtension.class.getName() + "#" + JsonWebToken.class.getName())
                .beanClass(JsonWebToken.class)
                .types(JsonWebToken.class, Object.class)
                .qualifiers(Default.Literal.INSTANCE, Any.Literal.INSTANCE)
                .scope(Dependent.class)
                .createWith(ctx -> {
                    final Principal principal = getContextualReference(Principal.class, bm);
                    if (JsonWebToken.class.isInstance(principal)) {
                        return JsonWebToken.class.cast(principal);
                    }

                    return null;
                });
    }
 
Example #23
Source File: VertxExtension.java    From weld-vertx with Apache License 2.0 5 votes vote down vote up
public void registerBeansAfterBeanDiscovery(@Observes AfterBeanDiscovery event) {
    if (vertx == null) {
        // Do no register beans - no Vertx instance available during bootstrap
        return;
    }
    // Allow to inject Vertx used to deploy the WeldVerticle
    event.addBean().types(getBeanTypes(vertx.getClass(), Vertx.class)).addQualifiers(Any.Literal.INSTANCE, Default.Literal.INSTANCE)
            .scope(ApplicationScoped.class).createWith(c -> vertx);
    // Allow to inject Context of the WeldVerticle
    event.addBean().types(getBeanTypes(context.getClass(), Context.class)).addQualifiers(Any.Literal.INSTANCE, Default.Literal.INSTANCE)
            .scope(ApplicationScoped.class).createWith(c -> context);
}
 
Example #24
Source File: ConfigurableFractionBean.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Annotation> getQualifiers() {
    Set<Annotation> qualifiers = new HashSet<>();
    qualifiers.add(Default.Literal.INSTANCE);
    qualifiers.add(Any.Literal.INSTANCE);
    return qualifiers;
}
 
Example #25
Source File: ConfigurableExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unused"})
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd) throws Exception {
    try (AutoCloseable handle = Performance.time("ConfigurationExtension.afterBeanDiscovery")) {
        CommonBean<ConfigurableManager> configurableManagerBean = CommonBeanBuilder.newBuilder(ConfigurableManager.class)
                .beanClass(ConfigurableManager.class)
                .scope(Singleton.class)
                .addQualifier(Default.Literal.INSTANCE)
                .createSupplier(() -> configurableManager)
                .addType(ConfigurableManager.class)
                .addType(Object.class).build();
        abd.addBean(configurableManagerBean);
    }
}
 
Example #26
Source File: ConfigViewProducingExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception {
    try (AutoCloseable handle = Performance.time("ConfigViewProducingExtension.afterBeanDiscovery")) {
        CommonBean<ConfigView> configViewBean = CommonBeanBuilder.newBuilder(ConfigView.class)
                .beanClass(ConfigViewProducingExtension.class)
                .scope(Singleton.class)
                .addQualifier(Default.Literal.INSTANCE)
                .createSupplier(() -> configView)
                .addType(ConfigView.class)
                .addType(Object.class).build();
        abd.addBean(configViewBean);
    }
}
 
Example #27
Source File: TracerProducer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves tracer instance to be used. It is using {@link TracerResolver} service loader to find
 * the tracer. It tracer is not resolved it will use {@link io.opentracing.noop.NoopTracer}.
 *
 * @return tracer instance
 */
@Default
@Produces
@Singleton
public Tracer produceTracer() {
  // TCK casts to MockTracer so we cannot use GlobalTracer as a bean!
  Tracer tracer = TracerResolver.resolveTracer();
  if (tracer == null) {
    tracer = GlobalTracer.get();
  }
  logger.info(String.format("Registering %s to GlobalTracer and providing it as CDI bean.", tracer));
  GlobalTracer.register(tracer);
  return tracer;
}
 
Example #28
Source File: CdiConfig.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
public void addABean(@Observes AfterBeanDiscovery event) {
    // get an instance of BeanConfigurator
    event.addBean()
            // set the desired data
            .types(Greeter.class)
            .scope(ApplicationScoped.class)
            .addQualifier(Default.Literal.INSTANCE)
            //.addQualifier(Custom.CustomLiteral.INSTANCE);
            //finally, add a callback to tell CDI how to instantiate this bean
            .produceWith(obj -> new Greeter());
}
 
Example #29
Source File: MockBean.java    From weld-junit with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @return a new {@link MockBean} instance
 * @throws IllegalStateException If a create callback is not set
 */
public MockBean<T> build() {
    if (createCallback == null) {
        throw new IllegalStateException("Create callback must not be null");
    }
    Set<Annotation> normalizedQualfiers = new HashSet<Annotation>(qualifiers);
    normalizedQualfiers.remove(Any.Literal.INSTANCE);
    normalizedQualfiers.remove(Default.Literal.INSTANCE);
    if (normalizedQualfiers.isEmpty()) {
        normalizedQualfiers.add(Default.Literal.INSTANCE);
        normalizedQualfiers.add(Any.Literal.INSTANCE);
    } else {
        ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder();
        if (normalizedQualfiers.size() == 1
                && normalizedQualfiers.iterator().next().annotationType().equals(Named.class)) {
            builder.add(Default.Literal.INSTANCE);
        }
        builder.add(Any.Literal.INSTANCE);
        builder.addAll(qualifiers);
        normalizedQualfiers = builder.build();
    }
    // if given any priority, we will instead initialize MockBeanWithPriority
    if (priority != null) {
        return new MockBeanWithPriority<>(beanClass, stereotypes, alternative, selectForSyntheticBeanArchive, priority, name, normalizedQualfiers, types, scope, createCallback,
                destroyCallback);
    } else {
        return new MockBean<>(beanClass, stereotypes, alternative, selectForSyntheticBeanArchive, name, normalizedQualfiers, types, scope, createCallback,
                destroyCallback);
    }
}
 
Example #30
Source File: LabeledTestServiceProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Default //optional
@Dependent
public InterceptedTestService createInterceptedTestService(@TestServiceQualifier(LABELED) InterceptedTestService interceptedTestService)
{
    return interceptedTestService; //the exposed result is an intercepted instance
}