/** * Wraps all JAR-RS components by Jersey-specific injection target. * * @param pit process injection target. * @param <T> type of the processed injection target. */ public <T> void observeInjectionTarget(@Observes ProcessInjectionTarget<T> pit) { BasicInjectionTarget<T> it = (BasicInjectionTarget<T>) pit.getInjectionTarget(); JerseyInjectionTarget<T> jerseyInjectionTarget = new JerseyInjectionTarget<>(it, pit.getAnnotatedType().getJavaClass()); jerseyInjectionTargets.add(jerseyInjectionTarget); pit.setInjectionTarget(jerseyInjectionTarget); }
/** * Gather Application or resource classes to start. * * @param pit injection target * @param <T> any type */ @SuppressWarnings("unchecked") public <T> void gatherApplications(@Observes ProcessInjectionTarget<T> pit) { AnnotatedType<T> at = pit.getAnnotatedType(); if (!at.isAnnotationPresent(ApplicationScoped.class)) { return; } // class is annotated, let's make sure it is an application Class<?> theClass = at.getJavaClass(); if (Application.class.isAssignableFrom(theClass)) { this.applications.add((Class<? extends Application>) theClass); } else { // still may be a jax-rs resource (with no application attached) if (at.isAnnotationPresent(Path.class)) { this.resourceClasses.add(theClass); } } }
@SuppressWarnings("unused") private void processInjectionTarget(@Observes final ProcessInjectionTarget event) { final InjectionTarget it = event.getInjectionTarget(); final Class<?> componentClass = event.getAnnotatedType().getJavaClass(); || jaxrsInjectableTypes.contains(event.getAnnotatedType().getBaseType())) { target = new InjectionManagerInjectedCdiTarget(it) {
protected <T> InjectionTarget<T> wrapInjectionTarget(ProcessInjectionTarget<T> event) { return new JaxrsInjectionTarget<T>(event.getInjectionTarget(), event.getAnnotatedType().getJavaClass()); }
/** * Wrap InjectionTarget of JAX-RS components within JaxrsInjectionTarget * which takes care of JAX-RS property injection. * * @param <T> type * @param event event */ public <T> void observeInjectionTarget(@Observes ProcessInjectionTarget<T> event) { if (event.getAnnotatedType() == null) { // check for resin's bug http://bugs.caucho.com/view.php?id=3967 LogMessages.LOGGER.warn(Messages.MESSAGES.annotatedTypeNull()); return; } if (Utils.isJaxrsComponent(event.getAnnotatedType().getJavaClass())) { event.setInjectionTarget(wrapInjectionTarget(event)); } }
public void processDogInjectionTarget(@Observes ProcessInjectionTarget<Dog> injectionTargetEvent) { // There a couple, but it does not matter which one is used for the tests dogInjectionTarget = injectionTargetEvent.getInjectionTarget(); dogAnnotatedType = injectionTargetEvent.getAnnotatedType(); }
public void processDogInjectionTarget(@Observes ProcessInjectionTarget<Dog> injectionTargetEvent) { // There a couple, but it does not matter which one is used for the tests dogInjectionTarget = injectionTargetEvent.getInjectionTarget(); dogAnnotatedType = injectionTargetEvent.getAnnotatedType(); }
<X> void registerGenericBeanInjectionTarget(@Observes ProcessInjectionTarget<X> event) { AnnotatedType<X> type = event.getAnnotatedType(); if (type.isAnnotationPresent(GenericConfiguration.class)) { genericInjectionTargets.put(type, event.getInjectionTarget()); } }
@SuppressWarnings("unused") <T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit, BeanManager beanManager) throws Exception { try (AutoCloseable handle = Performance.accumulate("ConfigurationExtension.processInjectionTarget")) { if (isApplicable(pit.getAnnotatedType())) { pit.setInjectionTarget(new ConfigurableInjectionTarget<T>(pit.getInjectionTarget(), this.configurableManager)); } } }
public void processInjectionTargets(@Observes ProcessInjectionTarget<?> event, BeanManager beanManager) { probe.getBootstrapStats().increment(EventType.PIT); if (eventMonitorContainerLifecycleEvents) { addContainerLifecycleEvent(event, Formats.formatType(event.getAnnotatedType().getBaseType(), false), beanManager); } }
public void processInjectionTargets(@Observes ProcessInjectionTarget<?> event, BeanManager beanManager) { probe.getBootstrapStats().increment(EventType.PIT); if (eventMonitorContainerLifecycleEvents) { addContainerLifecycleEvent(event, Formats.formatType(event.getAnnotatedType().getBaseType(), false), beanManager); } }
public void processInjectionTargets(@Observes ProcessInjectionTarget<?> event, BeanManager beanManager) { probe.getBootstrapStats().increment(EventType.PIT); if (eventMonitorContainerLifecycleEvents) { addContainerLifecycleEvent(event, Formats.formatType(event.getAnnotatedType().getBaseType(), false), beanManager); } }
public void processInjectionTargets(@Observes ProcessInjectionTarget<?> event, BeanManager beanManager) { probe.getBootstrapStats().increment(EventType.PIT); if (eventMonitorContainerLifecycleEvents) { addContainerLifecycleEvent(event, Formats.formatType(event.getAnnotatedType().getBaseType(), false), beanManager); } }
public void processInjectionTargets(@Observes ProcessInjectionTarget<?> event, BeanManager beanManager) { probe.getBootstrapStats().increment(EventType.PIT); if (eventMonitorContainerLifecycleEvents) { addContainerLifecycleEvent(event, Formats.formatType(event.getAnnotatedType().getBaseType(), false), beanManager); } }
@Test @SpecAssertions( { @SpecAssertion(section = "11.5.6", id = "aab"), @SpecAssertion(section = "11.5.6", id = "abb"), @SpecAssertion(section = "12.3", id = "db") }) public void testProcessInjectionTargetFiredForSessionBean() { assert ProcessInjectionTargetObserver.getStatelessSessionBeanEvent() != null; assert ProcessInjectionTargetObserver.getStatefulSessionBeanEvent() != null; validateStatelessSessionBean(ProcessInjectionTargetObserver.getStatelessSessionBeanEvent().getAnnotatedType()); validateStatefulSessionBean(ProcessInjectionTargetObserver.getStatefulSessionBeanEvent().getAnnotatedType()); }
@Test @SpecAssertions( { @SpecAssertion(section = "12.3", id = "ba"), @SpecAssertion(section = "11.5.6", id = "aaa") }) public void testProcessInjectionTargetFiredForManagedBean() { assert ProcessInjectionTargetObserver.getManagedBeanEvent() != null; validateManagedBean(ProcessInjectionTargetObserver.getManagedBeanEvent().getAnnotatedType()); }
@Test @SpecAssertions({ @SpecAssertion(section = "11.5.6", id = "aac"), @SpecAssertion(section = "11.5.6", id = "abc"), @SpecAssertion(section = "12.3", id = "de")}) public void testProcessInjectionTargetEventFiredForServletListener() { assert ProcessInjectionTargetObserver.getListenerEvent() != null; validateServletListenerAnnotatedType(ProcessInjectionTargetObserver.getListenerEvent().getAnnotatedType()); }
@Test @SpecAssertions({ @SpecAssertion(section = "11.5.6", id = "aai"), @SpecAssertion(section = "11.5.6", id = "abi"), @SpecAssertion(section = "12.3", id = "dk")}) public void testProcessInjectionTargetEventFiredForFilter() { assert ProcessInjectionTargetObserver.getFilterEvent() != null; validateFilterAnnotatedType(ProcessInjectionTargetObserver.getFilterEvent().getAnnotatedType()); }
@Test @SpecAssertions({ @SpecAssertion(section = "11.5.6", id = "aad"), @SpecAssertion(section = "11.5.6", id = "abd"), @SpecAssertion(section = "12.3", id = "df")}) public void testProcessInjectionTargetEventFiredForTagHandler() { assert ProcessInjectionTargetObserver.getTagHandlerEvent() != null; validateTagHandlerAnnotatedType(ProcessInjectionTargetObserver.getTagHandlerEvent().getAnnotatedType()); }
@Test @SpecAssertions({ @SpecAssertion(section = "11.5.6", id = "aae"), @SpecAssertion(section = "11.5.6", id = "abe"), @SpecAssertion(section = "12.3", id = "dg")}) public void testProcessInjectionTargetEventFiredForTagLibraryListener() { assert ProcessInjectionTargetObserver.getTagLibraryListenerEvent() != null; validateTagLibraryListenerAnnotatedType(ProcessInjectionTargetObserver.getTagLibraryListenerEvent().getAnnotatedType()); }