javax.enterprise.inject.spi.Producer.produce()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中javax.enterprise.inject.spi.Producer.produce()方法的一些代码示例,展示了Producer.produce()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Producer.produce()方法的具体详情如下:
包路径:javax.enterprise.inject.spi.Producer
类名称:Producer
方法名:produce

Producer.produce介绍

[英]Causes an instance to be produced via the Producer.

If the Producer represents a class, this will invoke the constructor annotated javax.inject.Inject if it exists, or the constructor with no parameters otherwise. If the class has interceptors, produce() is responsible for building the interceptors and decorators of the instance.

If the Producer represents a producer field or method, this will invoke the producer method on, or access the producer field of, a contextual instance of the bean that declares the producer.
[中]通过生产者生成实例。
如果生产者代表一个类,这将调用带注释的javax构造函数。注射如果存在,则注入,否则不使用参数的构造函数。如果类有拦截器,product()负责构建实例的拦截器和装饰器。
如果Producer表示Producer字段或方法,则会在声明Producer的bean的上下文实例上调用Producer方法,或访问其Producer字段。

代码示例

代码示例来源:origin: org.infinispan/infinispan-cdi-remote

@Override
public RemoteCache<?, ?> create(Bean<RemoteCache<?, ?>> bean, CreationalContext<RemoteCache<?, ?>> ctx) {
  return remoteCacheProducer.produce(ctx);
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

public Cow produce(CreationalContext<Cow> ctx) {
    overriddenCowProducerCalled = true;
    return producer.produce(ctx);
  }
});

代码示例来源:origin: thorntail/thorntail

@Override
public T produce(CreationalContext<T> ctx) {
  T instance = delegate.produce(ctx);
  applyConfiguration(instance);
  return instance;
}

代码示例来源:origin: weld/core

@Override
public T create(CreationalContext<T> creationalContext) {
  return getProducer().produce(creationalContext);
}

代码示例来源:origin: com.caucho/resin

@Override
public T create(CreationalContext<T> createEnv)
{
 T value = _producer.produce(createEnv);
 
 createEnv.push(value);
 
 return value;
}

代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded

/**
 * Creates an instance of the bean
 *
 * @returns The instance
 */
public T create(final CreationalContext<T> creationalContext) {
  T instance = getProducer().produce(creationalContext);
  instance = checkReturnValue(instance);
  return instance;
}

代码示例来源:origin: org.jboss.weld.se/weld-se

/**
 * Creates an instance of the bean
 *
 * @returns The instance
 */
public T create(final CreationalContext<T> creationalContext) {
  T instance = getProducer().produce(creationalContext);
  instance = checkReturnValue(instance);
  return instance;
}

代码示例来源:origin: weld/core

/**
 *
 * @param producer
 */
public ProducerConfiguratorImpl(Producer<T> producer) {
  this.produceCallback = (c) -> producer.produce(c);
  this.disposeCallback = (i) -> producer.dispose(i);
  this.injectionPoints = producer.getInjectionPoints();
}

代码示例来源:origin: weld/core

/**
 * Creates an instance of the bean
 *
 * @returns The instance
 */
public T create(final CreationalContext<T> creationalContext) {
  T instance = getProducer().produce(creationalContext);
  instance = checkReturnValue(instance);
  return instance;
}

代码示例来源:origin: weld/core

/**
 *
 * @param producer
 */
public ProducerConfiguratorImpl(Producer<T> producer) {
  this.produceCallback = (c) -> producer.produce(c);
  this.disposeCallback = (i) -> producer.dispose(i);
  this.injectionPoints = producer.getInjectionPoints();
}

代码示例来源:origin: weld/core

/**
 * Creates an instance of the bean
 *
 * @returns The instance
 */
public T create(final CreationalContext<T> creationalContext) {
  T instance = getProducer().produce(creationalContext);
  instance = checkReturnValue(instance);
  return instance;
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

/**
 * Creates an instance of the bean
 *
 * @returns The instance
 */
public T create(final CreationalContext<T> creationalContext) {
  T instance = getProducer().produce(creationalContext);
  instance = checkReturnValue(instance);
  return instance;
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

/**
 *
 * @param producer
 */
public ProducerConfiguratorImpl(Producer<T> producer) {
  this.produceCallback = (c) -> producer.produce(c);
  this.disposeCallback = (i) -> producer.dispose(i);
  this.injectionPoints = producer.getInjectionPoints();
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test
@SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_PRODUCER, id = "b") })
public void testStaticProducerField() {
  AnnotatedField<? super Factory> field = this.<Factory, AnnotatedField<Factory>> getAnnotatedMember(Factory.class,
      "WOODY");
  Producer<Toy> producer = cast(getCurrentManager().getProducerFactory(field, null).createProducer(null));
  assertNotNull(producer);
  assertTrue(producer.getInjectionPoints().isEmpty());
  Toy woody = producer.produce(getCurrentManager().<Toy> createCreationalContext(null));
  assertEquals("Woody", woody.getName());
}

代码示例来源:origin: astefanutti/further-cdi

<T extends com.codahale.metrics.Metric> void decorateMetricProducer(@Observes ProcessProducer<?, T> pp, BeanManager manager) {
  if (pp.getAnnotatedMember().isAnnotationPresent(Metric.class)) {
    String name = pp.getAnnotatedMember().getAnnotation(Metric.class).name();
    Producer<T> producer = pp.getProducer();
    pp.configureProducer().produceWith(context -> {
      MetricRegistry registry = manager.createInstance().select(MetricRegistry.class).get();
      if (registry.getMetrics().containsKey(name))
        return (T) registry.getMetrics().get(name);
      return registry.register(name, producer.produce(context));
    });
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test
@SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_PRODUCER, id = "a") })
public void testStaticProducerMethod() {
  AnnotatedMethod<? super Factory> method = this.<Factory, AnnotatedMethod<Factory>> getAnnotatedMember(Factory.class,
      "getBuzz");
  Producer<Toy> producer = cast(getCurrentManager().getProducerFactory(method, null).createProducer(null));
  assertNotNull(producer);
  validateInjectionPoints(producer.getInjectionPoints());
  Toy buzz = producer.produce(getCurrentManager().<Toy> createCreationalContext(null));
  assertEquals("Buzz Lightyear", buzz.getName());
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@Test
@SpecAssertions({ @SpecAssertion(section = INJECTIONTARGET, id = "eba"), @SpecAssertion(section = PROCESS_PRODUCER, id = "ab"),
    @SpecAssertion(section = PROCESS_PRODUCER, id = "bb"), @SpecAssertion(section = PROCESS_PRODUCER, id = "cb"),
    @SpecAssertion(section = PROCESS_PRODUCER, id = "db"), @SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "jb") })
public void testProduceAccessesProducerField() {
  Producer<Dog> producer = ProducerProcessor.getQuietDogProducer();
  Bean<Dog> dogBean = getUniqueBean(Dog.class, new AnnotationLiteral<Quiet>() {
  });
  DogProducer.reset();
  Dog dog = producer.produce(getCurrentManager().createCreationalContext(dogBean));
  assert dog.getColor().equals(DogProducer.QUIET_DOG_COLOR);
}

代码示例来源:origin: weld/core

@Override
public T create(CreationalContext<T> creationalContext) {
  final T beanInstance = getProducer().produce(creationalContext);
  if (Reflections.isFinal(rawType) || Serializable.class.isAssignableFrom(beanInstance.getClass())) {
    return checkReturnValue(beanInstance);
  } else {
    BeanInstance proxyBeanInstance = new EnterpriseTargetBeanInstance(getTypes(), new CallableMethodHandler(new EEResourceCallable<T>(getBeanManager(),
        this, creationalContext, beanInstance)));
    return checkReturnValue(proxyFactory.create(proxyBeanInstance));
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se

@Override
public T create(CreationalContext<T> creationalContext) {
  final T beanInstance = getProducer().produce(creationalContext);
  if (Reflections.isFinal(rawType) || Serializable.class.isAssignableFrom(beanInstance.getClass())) {
    return checkReturnValue(beanInstance);
  } else {
    BeanInstance proxyBeanInstance = new EnterpriseTargetBeanInstance(getTypes(), new CallableMethodHandler(new EEResourceCallable<T>(getBeanManager(),
        this, creationalContext, beanInstance)));
    return checkReturnValue(proxyFactory.create(proxyBeanInstance));
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

@Override
public T create(CreationalContext<T> creationalContext) {
  final T beanInstance = getProducer().produce(creationalContext);
  if (Reflections.isFinal(rawType) || Serializable.class.isAssignableFrom(beanInstance.getClass())) {
    return checkReturnValue(beanInstance);
  } else {
    BeanInstance proxyBeanInstance = new EnterpriseTargetBeanInstance(getTypes(), new CallableMethodHandler(new EEResourceCallable<T>(getBeanManager(),
        this, creationalContext, beanInstance)));
    return checkReturnValue(proxyFactory.create(proxyBeanInstance));
  }
}

相关文章