javax.enterprise.inject.Typed Java Examples

The following examples show how to use javax.enterprise.inject.Typed. 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: ReactiveSessionFactoryProducer.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Produces
@Singleton
@DefaultBean
@Typed(Stage.SessionFactory.class)
public Stage.SessionFactory reactiveSessionFactory() {
    return emf.unwrap(Stage.SessionFactory.class);
}
 
Example #2
Source File: AnnotatedTypeBuilderTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testAdditionOfAnnotation()
{
    final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
    builder.readFromType(Cat.class, true);
    builder.addToClass(new TypedLiteral());

    final AnnotatedType<Cat> catAnnotatedType = builder.create();
    assertThat(catAnnotatedType.isAnnotationPresent(Typed.class), is(true));
}
 
Example #3
Source File: ServletObjectProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Typed(HttpServletResponse.class)
@DeltaSpike
@RequestScoped
public HttpServletResponse getHttpServletResponse()
{
    ServletResponse response = RequestResponseHolder.RESPONSE.get();
    if (response instanceof HttpServletResponse)
    {
        return (HttpServletResponse) response;
    }
    throw new IllegalStateException("The current response is not a HttpServletResponse");
}
 
Example #4
Source File: ServletObjectProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Typed(HttpServletRequest.class)
@DeltaSpike
@RequestScoped
public HttpServletRequest getHttpServletRequest()
{
    ServletRequest request = RequestResponseHolder.REQUEST.get();
    if (request instanceof HttpServletRequest)
    {
        return (HttpServletRequest) request;
    }
    throw new IllegalStateException("The current request is not a HttpServletRequest");
}
 
Example #5
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed(T3.class)
public TypedBean3 produce3()
{
    return new TypedBean3();
}
 
Example #6
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed({T1.class, T2.class})
public TypedBean1and2 produce1and2()
{
    return new TypedBean1and2();
}
 
Example #7
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed(T3.class)
public TypedBean3 produce3()
{
    return new TypedBean3();
}
 
Example #8
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed({T1.class, T2.class})
public TypedBean1and2 produce1and2()
{
    return new TypedBean1and2();
}
 
Example #9
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed(T3.class)
public TypedBean3 produce3()
{
    return new TypedBean3();
}
 
Example #10
Source File: TypedBeanProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@RequestScoped
@Typed({T1.class, T2.class})
public TypedBean1and2 produce1and2()
{
    return new TypedBean1and2();
}
 
Example #11
Source File: CdiEjbBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static void addApiTypes(final Collection<Type> clazzes, final Class<?> beanClass) {
    final Typed typed = beanClass.getAnnotation(Typed.class);
    if (typed == null || typed.value().length == 0) {
        Type current = beanClass;
        while (current != null && Object.class != current) {
            clazzes.add(current);
            // TODO: better loop
            current = Class.class.isInstance(current) ? Class.class.cast(current).getGenericSuperclass() : null;
        }
    } else {
        Collections.addAll(clazzes, typed.value());
    }
}
 
Example #12
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the resource parameters.
 */
@Produces @PortletRequestScoped @Named("resourceParams") @Typed(ResourceParameters.class)
public static ResourceParameters getResourceParameters() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ResourceParameters obj = null;
   if (pap.req instanceof ResourceRequest) {
      obj = ((ResourceRequest)pap.req).getResourceParameters();
   }
   return obj;
}
 
Example #13
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the action parameters.
 */
@Produces @PortletRequestScoped @Named("actionParams") @Typed(ActionParameters.class)
public static ActionParameters getActionParameters() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ActionParameters obj = null;
   if (pap.req instanceof ActionRequest) {
      obj = ((ActionRequest)pap.req).getActionParameters();
   }
   return obj;
}
 
Example #14
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the mutable render parameters.
 */
@Produces @PortletRequestScoped @Named("mutableRenderParams") @Typed(MutableRenderParameters.class)
public static MutableRenderParameters getMutableRenderParameters() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   MutableRenderParameters obj = null;
   if (pap.resp instanceof StateAwareResponse) {
      obj = ((StateAwareResponse)pap.resp).getRenderParameters();
   }
   return obj;
}
 
Example #15
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the render paramters.
 */
@Produces @PortletRequestScoped @Named("renderParams") @Typed(RenderParameters.class)
public static RenderParameters getRenderParameters() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   return pap.req.getRenderParameters();
}
 
Example #16
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the ResourceResponse. 
 */
@Produces @PortletRequestScoped @Named("resourceResponse") @Typed(ResourceResponse.class)
public static ResourceResponse produceResourceResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ResourceResponse resp = null;
   if (pap.resp instanceof ResourceResponse) {
      resp = (ResourceResponse) pap.resp;
   }
   return resp;
}
 
Example #17
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the EventResponse. 
 * @return
 */
@Produces @PortletRequestScoped @Named("eventResponse") @Typed(EventResponse.class)
public static EventResponse produceEventResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   EventResponse resp = null;
   if (pap.resp instanceof EventResponse) {
      resp = (EventResponse) pap.resp;
   }
   return resp;
}
 
Example #18
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
/**
 * Injects {@code Flowable<Message<X>>} and {@code Flowable<X>}.
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the flowable to be injected
 */
@Produces
@Typed(Flowable.class)
@Channel("") // Stream name is ignored during type-safe resolution
<T> Flowable<T> produceFlowable(InjectionPoint injectionPoint) {
    Type first = getFirstParameter(injectionPoint.getType());
    if (TypeUtils.isAssignable(first, Message.class)) {
        return cast(Flowable.fromPublisher(getPublisher(injectionPoint)));
    } else {
        return cast(Flowable.fromPublisher(getPublisher(injectionPoint))
                .map(Message::getPayload));
    }
}
 
Example #19
Source File: ReactiveSessionFactoryProducer.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Produces
@Singleton
@DefaultBean
@Typed(Mutiny.SessionFactory.class)
public Mutiny.SessionFactory mutinySessionFactory() {
    return emf.unwrap(Mutiny.SessionFactory.class);
}
 
Example #20
Source File: SmallRyeContextPropagationProvider.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Typed(ManagedExecutor.class)
@Produces
@Singleton
@DefaultBean
public ManagedExecutor getAllManagedExecutor() {
    return managedExecutor;
}
 
Example #21
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the ClientDataRequest.
 */
@Produces @PortletRequestScoped @Named("clientDataRequest") @Typed(ClientDataRequest.class)
public static ClientDataRequest produceClientDataRequest() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ClientDataRequest req = null;
   if (pap.req instanceof ClientDataRequest) {
      req = (ClientDataRequest) pap.req;
   }
   return req;
}
 
Example #22
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the MimeResponse. 
 */
@Produces @PortletRequestScoped @Named("mimeResponse") @Typed(MimeResponse.class)
public static MimeResponse produceMimeResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   MimeResponse resp = null;
   if (pap.resp instanceof MimeResponse) {
      resp = (MimeResponse) pap.resp;
   }
   return resp;
}
 
Example #23
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the StateAwareResponse. 
 */
@Produces @PortletRequestScoped @Named("stateAwareResponse") @Typed(StateAwareResponse.class)
public static StateAwareResponse produceStateAwareResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   StateAwareResponse resp = null;
   if (pap.resp instanceof StateAwareResponse) {
      resp = (StateAwareResponse) pap.resp;
   }
   return resp;
}
 
Example #24
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the ActionRequest.
 */
@Produces @PortletRequestScoped @Named("actionRequest") @Typed(ActionRequest.class)
public static ActionRequest produceActionRequest() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ActionRequest req = null;
   if (pap.req instanceof ActionRequest) {
      req = (ActionRequest) pap.req;
   }
   return req;
}
 
Example #25
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the ActionResponse. 
 */
@Produces @PortletRequestScoped @Named("actionResponse") @Typed(ActionResponse.class)
public static ActionResponse produceActionResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   ActionResponse resp = null;
   if (pap.resp instanceof ActionResponse) {
      resp = (ActionResponse) pap.resp;
   }
   return resp;
}
 
Example #26
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the HeaderRequest.
 */
@Produces @PortletRequestScoped @Named("headerRequest") @Typed(HeaderRequest.class)
public static HeaderRequest produceHeaderRequest() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   HeaderRequest req = null;
   if (pap.req instanceof HeaderRequest) {
      req = (HeaderRequest) pap.req;
   }
   return req;
}
 
Example #27
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the HeaderResponse. 
 */
@Produces @PortletRequestScoped @Named("headerResponse") @Typed(HeaderResponse.class)
public static HeaderResponse produceHeaderResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   HeaderResponse resp = null;
   if (pap.resp instanceof HeaderResponse) {
      resp = (HeaderResponse) pap.resp;
   }
   return resp;
}
 
Example #28
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the RenderRequest.
 */
@Produces @PortletRequestScoped @Named("renderRequest") @Typed(RenderRequest.class)
public static RenderRequest produceRenderRequest() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   RenderRequest req = null;
   if ((pap.req instanceof RenderRequest) && !(pap.req instanceof HeaderRequest)) {
      req = (RenderRequest) pap.req;
   }
   return req;
}
 
Example #29
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the RenderResponse. 
 */
@Produces @PortletRequestScoped @Named("renderResponse") @Typed(RenderResponse.class)
public static RenderResponse produceRenderResponse() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   RenderResponse resp = null;
   if (pap.resp instanceof RenderResponse) {
      resp = (RenderResponse) pap.resp;
   }
   return resp;
}
 
Example #30
Source File: PortletArtifactProducer.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
/**
 * Producer method for the EventRequest.
 */
@Produces @PortletRequestScoped @Named("eventRequest") @Typed(EventRequest.class)
public static EventRequest produceEventRequest() {
   PortletArtifactProducer pap = producers.get();
   assert pap != null;
   EventRequest req = null;
   if (pap.req instanceof EventRequest) {
      req = (EventRequest) pap.req;
   }
   return req;
}