@Override protected FastEvent<String> computeValue() { return FastEvent.of(String.class, manager, manager.getGlobalLenientObserverNotifier(), BeforeDestroyed.Literal.CONVERSATION); } };
@AroundInvoke Object invoke(InvocationContext ctx) throws Exception { if (isRequestContextActive()) { return ctx.proceed(); } else { Object dummyPayload = new Object(); try { requestContext.activate(); fastEventInit.fire(dummyPayload); return ctx.proceed(); } finally { requestContext.invalidate(); fastEventBeforeDestroyed.fire(dummyPayload); requestContext.deactivate(); fastEventDestroyed.fire(dummyPayload); } } }
public Object aroundInvoke(InvocationContext invocation) throws Exception { if (isRequestContextActive()) { return invocation.proceed(); } else { EjbRequestContext requestContext = getEjbRequestContext(); try { requestContext.associate(invocation); requestContext.activate(); try { // An event with qualifier @Initialized(RequestScoped.class) is fired when the request context is initialized requestInitializedEvent.get().fire(ContextEvent.REQUEST_INITIALIZED_EJB); return invocation.proceed(); } finally { requestBeforeDestroyedEvent.get().fire(ContextEvent.REQUEST_BEFORE_DESTROYED_EJB); requestContext.invalidate(); requestContext.deactivate(); } } finally { requestContext.dissociate(invocation); // An event with qualifier @Destroyed(RequestScoped.class) when the request context is destroyed requestDestroyedEvent.get().fire(ContextEvent.REQUEST_DESTROYED_EJB); } } }
this.beanResolver = new TypeSafeBeanResolver(this, createDynamicAccessibleIterable(beanTransform)); this.decoratorResolver = new TypeSafeDecoratorResolver(this, createDynamicGlobalIterable(BeanManagerImpl::getDecorators)); this.interceptorResolver = new TypeSafeInterceptorResolver(this, createDynamicGlobalIterable(BeanManagerImpl::getInterceptors)); this.nameBasedResolver = new NameBasedResolver(this, createDynamicAccessibleIterable(beanTransform)); this.weldELResolver = services.getOptional(ExpressionLanguageSupport.class).map(el -> el.createElResolver(this)).orElse(null); this.currentInjectionPoint = getServices().get(CurrentInjectionPoint.class); this.clientProxyOptimization = getServices().get(WeldConfiguration.class).getBooleanProperty(ConfigurationKey.INJECTABLE_REFERENCE_OPTIMIZATION); this.requestInitializedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, Initialized.Literal.REQUEST)); this.requestBeforeDestroyedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, BeforeDestroyed.Literal.REQUEST)); this.requestDestroyedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, Destroyed.Literal.REQUEST));
@Override public void deactivate() throws ContextNotActiveException { if (!isRequestContextActive()) { throw BeanManagerLogger.LOG.contextNotActive(RequestScoped.class); } if (isActivator.compareAndSet(true, false)) { try { requestBeforeDestroyedEvent.fire(toString()); requestContext.invalidate(); requestContext.deactivate(); } finally { requestDestroyedEvent.fire(toString()); } } }
/** * Constructs a new FastEvent instance * @param type the event type * @param manager the bean manager * @param notifier the notifier to be used for observer method resolution * @param qualifiers the event qualifiers * @return */ public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers) { ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(type, qualifiers); if (resolvedObserverMethods.isMetadataRequired()) { EventMetadata metadata = new EventMetadataImpl(type, null, qualifiers); CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class); return new FastEventWithMetadataPropagation<T>(resolvedObserverMethods, metadata, metadataService); } else { return new FastEvent<T>(resolvedObserverMethods); } }
public HttpContextLifecycle(BeanManagerImpl beanManager, HttpContextActivationFilter contextActivationFilter, boolean ignoreForwards, boolean ignoreIncludes, boolean lazyConversationContext, boolean nestedInvocationGuardEnabled) { this.beanManager = beanManager; this.conversationContextActivator = new ConversationContextActivator(beanManager, lazyConversationContext); this.conversationActivationEnabled = null; this.ignoreForwards = ignoreForwards; this.ignoreIncludes = ignoreIncludes; this.contextActivationFilter = contextActivationFilter; this.requestInitializedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Initialized.Literal.REQUEST); this.requestBeforeDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, BeforeDestroyed.Literal.REQUEST); this.requestDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Destroyed.Literal.REQUEST); this.sessionInitializedEvent = FastEvent.of(HttpSession.class, beanManager, Initialized.Literal.SESSION); this.sessionBeforeDestroyedEvent = FastEvent.of(HttpSession.class, beanManager, BeforeDestroyed.Literal.SESSION); this.sessionDestroyedEvent = FastEvent.of(HttpSession.class, beanManager, Destroyed.Literal.SESSION); this.servletApi = beanManager.getServices().get(ServletApiAbstraction.class); this.servletContextService = beanManager.getServices().get(ServletContextService.class); this.nestedInvocationGuardEnabled = nestedInvocationGuardEnabled; this.container = Container.instance(beanManager); BeanDeploymentModules beanDeploymentModules = beanManager.getServices().get(BeanDeploymentModules.class); this.module = beanDeploymentModules != null ? beanDeploymentModules.getModule(beanManager) : null; }
/** * Same as {@link #of(Class, BeanManagerImpl, Annotation...)}, just the accessible lenient observer notifier is used for observer method resolution */ public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, Annotation... qualifiers) { return of(type, manager, manager.getAccessibleLenientObserverNotifier(), qualifiers); }
protected ConversationContextActivator(BeanManagerImpl beanManager, boolean lazy) { this.beanManager = beanManager; conversationInitializedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Initialized.Literal.CONVERSATION); conversationBeforeDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, BeforeDestroyed.Literal.CONVERSATION); conversationDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Destroyed.Literal.CONVERSATION); lazyInitializationCallback = lazy ? conversationInitializedEvent::fire : null; this.lazy = lazy; }
@Override public void accept(HttpServletRequest input) { conversationInitializedEvent.fire(input); } } : null;
@AroundInvoke Object invoke(InvocationContext ctx) throws Exception { if (isRequestContextActive()) { return ctx.proceed(); } else { Object dummyPayload = new Object(); try { requestContext.activate(); fastEventInit.fire(dummyPayload); return ctx.proceed(); } finally { requestContext.invalidate(); fastEventBeforeDestroyed.fire(dummyPayload); requestContext.deactivate(); fastEventDestroyed.fire(dummyPayload); } } }
public Object aroundInvoke(InvocationContext invocation) throws Exception { if (isRequestContextActive()) { return invocation.proceed(); } else { EjbRequestContext requestContext = getEjbRequestContext(); try { requestContext.associate(invocation); requestContext.activate(); try { // An event with qualifier @Initialized(RequestScoped.class) is fired when the request context is initialized requestInitializedEvent.get().fire(ContextEvent.REQUEST_INITIALIZED_EJB); return invocation.proceed(); } finally { requestContext.invalidate(); requestContext.deactivate(); } } finally { requestContext.dissociate(invocation); // An event with qualifier @Destroyed(RequestScoped.class) when the request context is destroyed requestDestroyedEvent.get().fire(ContextEvent.REQUEST_DESTROYED_EJB); } } }
this.beanResolver = new TypeSafeBeanResolver(this, createDynamicAccessibleIterable(beanTransform)); this.decoratorResolver = new TypeSafeDecoratorResolver(this, createDynamicGlobalIterable(BeanManagerImpl::getDecorators)); this.interceptorResolver = new TypeSafeInterceptorResolver(this, createDynamicGlobalIterable(BeanManagerImpl::getInterceptors)); this.nameBasedResolver = new NameBasedResolver(this, createDynamicAccessibleIterable(beanTransform)); this.weldELResolver = services.getOptional(ExpressionLanguageSupport.class).map(el -> el.createElResolver(this)).orElse(null); this.currentInjectionPoint = getServices().get(CurrentInjectionPoint.class); this.clientProxyOptimization = getServices().get(WeldConfiguration.class).getBooleanProperty(ConfigurationKey.INJECTABLE_REFERENCE_OPTIMIZATION); this.requestInitializedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, Initialized.Literal.REQUEST)); this.requestBeforeDestroyedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, BeforeDestroyed.Literal.REQUEST)); this.requestDestroyedEvent = LazyValueHolder.forSupplier(() -> FastEvent.of(Object.class, this, Destroyed.Literal.REQUEST));
@Override public void deactivate() throws ContextNotActiveException { if (!isRequestContextActive()) { throw BeanManagerLogger.LOG.contextNotActive(RequestScoped.class); } if (isActivator.compareAndSet(true, false)) { try { requestBeforeDestroyedEvent.fire(toString()); requestContext.invalidate(); requestContext.deactivate(); } finally { requestDestroyedEvent.fire(toString()); } } }
/** * Constructs a new FastEvent instance * @param type the event type * @param manager the bean manager * @param notifier the notifier to be used for observer method resolution * @param qualifiers the event qualifiers * @return */ public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers) { ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(type, qualifiers); if (resolvedObserverMethods.isMetadataRequired()) { EventMetadata metadata = new EventMetadataImpl(type, null, qualifiers); CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class); return new FastEventWithMetadataPropagation<T>(resolvedObserverMethods, metadata, metadataService); } else { return new FastEvent<T>(resolvedObserverMethods); } }
public HttpContextLifecycle(BeanManagerImpl beanManager, HttpContextActivationFilter contextActivationFilter, boolean ignoreForwards, boolean ignoreIncludes, boolean lazyConversationContext, boolean nestedInvocationGuardEnabled) { this.beanManager = beanManager; this.conversationContextActivator = new ConversationContextActivator(beanManager, lazyConversationContext); this.conversationActivationEnabled = null; this.ignoreForwards = ignoreForwards; this.ignoreIncludes = ignoreIncludes; this.contextActivationFilter = contextActivationFilter; this.requestInitializedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Initialized.Literal.REQUEST); this.requestBeforeDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, BeforeDestroyed.Literal.REQUEST); this.requestDestroyedEvent = FastEvent.of(HttpServletRequest.class, beanManager, Destroyed.Literal.REQUEST); this.sessionInitializedEvent = FastEvent.of(HttpSession.class, beanManager, Initialized.Literal.SESSION); this.sessionBeforeDestroyedEvent = FastEvent.of(HttpSession.class, beanManager, BeforeDestroyed.Literal.SESSION); this.sessionDestroyedEvent = FastEvent.of(HttpSession.class, beanManager, Destroyed.Literal.SESSION); this.servletApi = beanManager.getServices().get(ServletApiAbstraction.class); this.servletContextService = beanManager.getServices().get(ServletContextService.class); this.nestedInvocationGuardEnabled = nestedInvocationGuardEnabled; this.container = Container.instance(beanManager); BeanDeploymentModules beanDeploymentModules = beanManager.getServices().get(BeanDeploymentModules.class); this.module = beanDeploymentModules != null ? beanDeploymentModules.getModule(beanManager) : null; }
/** * Same as {@link #of(Class, BeanManagerImpl, Annotation...)}, just the accessible lenient observer notifier is used for observer method resolution */ public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, Annotation... qualifiers) { return of(type, manager, manager.getAccessibleLenientObserverNotifier(), qualifiers); }