javax.enterprise.context.spi.Context Java Examples

The following examples show how to use javax.enterprise.context.spi.Context. 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: BeanReloadExecutor.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
private static void doReloadBeanInBeanContexts(BeanManagerImpl beanManager, ManagedBean<?> managedBean) {
    try {
        Map<Class<? extends Annotation>, List<Context>> contexts = getContextMap(beanManager);

        List<Context> ctxList = contexts.get(managedBean.getScope());

        if (ctxList != null) {
            for(Context context: ctxList) {
                doReloadBeanInContext(beanManager, managedBean, context);
            }
        } else {
            LOGGER.debug("No active contexts for bean '{}' in scope '{}'", managedBean.getBeanClass().getName(),  managedBean.getScope());
        }
    } catch (Exception e) {
        if (e.getClass().getSimpleName().equals("ContextNotActiveException")) {
            LOGGER.warning("No active contexts for bean '{}'", e, managedBean.getBeanClass().getName());
        } else {
            LOGGER.warning("Context for '{}' failed to reload", e, managedBean.getBeanClass().getName());
        }
    }
}
 
Example #2
Source File: JoynrJeeMessageContextTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testContextRegistered() {
    JoynrJeeMessageContext.getInstance().activate();

    Context result = beanManager.getContext(JoynrJeeMessageScoped.class);

    assertNotNull(result);
    assertTrue(result instanceof JoynrJeeMessageContext);

    JoynrJeeMessageContext.getInstance().deactivate();
    try {
        result = beanManager.getContext(JoynrJeeMessageScoped.class);
        fail("Shouldn't get it after deactivation.");
    } catch (ContextNotActiveException e) {
        logger.trace("Context not available after deactivation as expected.");
    }
}
 
Example #3
Source File: EnsureRequestScopeThreadLocalIsCleanUpTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Test
public void ensureRequestContextCanBeRestarted() throws Exception {
    final ApplicationComposers composers = new ApplicationComposers(EnsureRequestScopeThreadLocalIsCleanUpTest.class);
    composers.before(this);
    final CdiAppContextsService contextsService = CdiAppContextsService.class.cast(WebBeansContext.currentInstance().getService(ContextsService.class));
    final Context req1 = contextsService.getCurrentContext(RequestScoped.class);
    assertNotNull(req1);
    final Context session1 = contextsService.getCurrentContext(SessionScoped.class);
    assertNotNull(session1);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.startContext(RequestScoped.class, null);
    final Context req2 = contextsService.getCurrentContext(RequestScoped.class);
    assertNotSame(req1, req2);
    final Context session2 = contextsService.getCurrentContext(SessionScoped.class);
    assertSame(session1, session2);
    composers.after();
    assertNull(contextsService.getCurrentContext(RequestScoped.class));
    assertNull(contextsService.getCurrentContext(SessionScoped.class));
}
 
Example #4
Source File: RequestScopedThreadContextListener.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext) {

    final BeanContext beanContext = newContext.getBeanContext();

    final WebBeansContext webBeansContext = beanContext.getModuleContext().getAppContext().getWebBeansContext();
    if (webBeansContext == null) {
        return;
    }

    final ContextsService contextsService = webBeansContext.getContextsService();

    final Context requestContext = CdiAppContextsService.class.cast(contextsService).getRequestContext(false);

    if (requestContext == null) {
        contextsService.startContext(RequestScoped.class, CdiAppContextsService.EJB_REQUEST_EVENT);
        newContext.set(DestroyContext.class, new DestroyContext(contextsService, newContext));
    }
}
 
Example #5
Source File: HaCdiCommons.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static Map<Class<? extends Annotation>, Class<? extends Context>> getCurrentScopeToContextMap() {

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    if (classLoader != null) {
        try {
            Class<?> clazz = classLoader.loadClass(HaCdiCommons.class.getName());
            if (clazz != HaCdiCommons.class) {
                return (Map) ReflectionHelper.get(null, clazz, "scopeToContextMap");
            }
        } catch (Exception e) {
            LOGGER.error("getCurrentScopeToContextMap '{}' failed",  e.getMessage());
        }
    }
    return scopeToContextMap;
}
 
Example #6
Source File: HaCdiCommons.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all bean instances.
 *
 * @param bean the bean
 * @return the bean instances
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<Object> getBeanInstances(Bean<?> bean) {
    List<Object> result = new ArrayList<>();
    Class<? extends Context> contextClass = getContextClass(bean.getScope());
    if (contextClass != null) {
      Map beanRegistry = (Map) getBeanRegistry(contextClass);
      if (beanRegistry != null) {
          Map m = (Map) beanRegistry.get(bean.getBeanClass().getName());
          if (m != null) {
              result.addAll(m.keySet());
          } else {
              LOGGER.debug("BeanRegistry is empty for bean class '{}'", bean.getBeanClass().getName());
          }
      } else {
          LOGGER.error("BeanRegistry field not found in context class '{}'", contextClass.getName());
      }
    }
    for (HaCdiExtraContext extraContext: extraContexts.keySet()) {
        List<Object> instances = extraContext.getBeanInstances(bean.getBeanClass());
        if (instances != null) {
            result.addAll(instances);
        }
    }
    return result;
}
 
Example #7
Source File: ContextualReloadHelper.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Will re-inject any managed beans in the target. Will not call any other life-cycle methods
 *
 * @param ctx
 * @param managedBean
 */
@SuppressWarnings("unchecked")
static void reinitialize(Context ctx, Contextual<Object> contextual) {
    try {
        ManagedBean<Object> managedBean = ManagedBean.class.cast(contextual);
        LOGGER.debug("Re-Initializing bean '{}' in context '{}'", managedBean, ctx);
        Object get = ctx.get(managedBean);
        if (get != null) {
            LOGGER.debug("Bean injection points are reinitialized '{}'", managedBean);
            CreationalContextImpl<Object> creationalContext = managedBean.getWebBeansContext().getCreationalContextFactory().getCreationalContext(managedBean);
            managedBean.getProducer().inject(get, creationalContext);
        }
    } catch (Exception e) {
        LOGGER.error("Error reinitializing bean '{}' in context '{}'", e, contextual, ctx);
    }
}
 
Example #8
Source File: TransactionBeanWithEvents.java    From quarkus with Apache License 2.0 6 votes vote down vote up
void transactionScopePreDestroy(@Observes @BeforeDestroyed(TransactionScoped.class) final Object event,
        final BeanManager beanManager) throws SystemException {
    Transaction tx = tm.getTransaction();
    if (tx == null) {
        log.error("@BeforeDestroyed expects an active transaction");
        throw new IllegalStateException("@BeforeDestroyed expects an active transaction");
    }
    Context ctx;
    try {
        ctx = beanManager.getContext(TransactionScoped.class);
    } catch (Exception e) {
        log.error("Context on @Initialized is not available");
        throw e;
    }
    if (!ctx.isActive()) {
        log.error("Context on @BeforeDestroyed has to be active");
        throw new IllegalStateException("Context on @BeforeDestroyed has to be active");
    }
    if (!(event instanceof Transaction)) {
        log.error("@Intialized scope expects event payload being the " + Transaction.class.getName());
        throw new IllegalStateException("@Intialized scope expects event payload being the " + Transaction.class.getName());
    }

    beforeDestroyedCount++;
}
 
Example #9
Source File: VertxProducer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Undeploy verticles backed by contextual instances of {@link ApplicationScoped} beans before the application context is
 * destroyed. Otherwise Vertx may attempt to stop the verticles after the CDI container is shut down.
 * 
 * @param event
 * @param beanManager
 */
void undeployVerticles(@Observes @BeforeDestroyed(ApplicationScoped.class) Object event,
        BeanManager beanManager, io.vertx.mutiny.core.Vertx mutiny) {
    // Only beans with the AbstractVerticle in the set of bean types are considered - we need a deployment id 
    Set<Bean<?>> beans = beanManager.getBeans(AbstractVerticle.class, Any.Literal.INSTANCE);
    Context applicationContext = beanManager.getContext(ApplicationScoped.class);
    for (Bean<?> bean : beans) {
        if (ApplicationScoped.class.equals(bean.getScope())) {
            // Only beans with @ApplicationScoped are considered
            Object instance = applicationContext.get(bean);
            if (instance != null) {
                // Only existing instances are considered
                try {
                    AbstractVerticle verticle = (AbstractVerticle) instance;
                    mutiny.undeploy(verticle.deploymentID()).await().indefinitely();
                    LOGGER.debugf("Undeployed verticle: %s", instance.getClass());
                } catch (Exception e) {
                    // In theory, a user can undeploy the verticle manually
                    LOGGER.debugf("Unable to undeploy verticle %s: %s", instance.getClass(), e.toString());
                }
            }
        }
    }
}
 
Example #10
Source File: WebappBeanManager.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Context getContext(final Class<? extends Annotation> scope) {
    try {
        return super.getContext(scope);
    } catch (final RuntimeException e) {
        try {
            return getParentBm().getContext(scope);
        } catch (final RuntimeException ignored) {
            throw e;
        }
    }
}
 
Example #11
Source File: WebBeansListenerHelper.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static void ensureRequestScope(final ContextsService cs, final ServletRequestListener listener) {
    final Context reqCtx = cs.getCurrentContext(RequestScoped.class);
    if (reqCtx == null || !cs.getCurrentContext(RequestScoped.class).isActive()) {
        listener.requestInitialized(null);
        FAKE_REQUEST.set(true);
    }
}
 
Example #12
Source File: BeanManagerImpl.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public Context getContext(Class<? extends Annotation> scopeType) {
    Context context = Arc.container().getActiveContext(scopeType);
    if (context == null) {
        throw new ContextNotActiveException("No active context found for: " + scopeType);
    }
    return context;
}
 
Example #13
Source File: HaCdiCommons.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register context class.
 *
 * @param scope the scope
 * @param contextClass the context class
 */
public static void registerContextClass(Class<? extends Annotation> scope, Class<? extends Context> contextClass) {

    Map<Class<? extends Annotation>, Class<? extends Context>> currentScopeToContextMap = getCurrentScopeToContextMap();

    if (!currentScopeToContextMap.containsKey(scope)) {
        LOGGER.debug("Registering scope '{}' to scopeToContextMap@{}", scope.getName(), System.identityHashCode(currentScopeToContextMap));
        currentScopeToContextMap.put(scope, contextClass);
    }
}
 
Example #14
Source File: BeanLocator.java    From AngularBeans with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Object lookup(String beanName, String sessionID) {

		NGSessionScopeContext.setCurrentContext(sessionID);

		Set<Bean<?>> beans = beanManager.getBeans(beanName);

		Class beanClass = CommonUtils.beanNamesHolder.get(beanName);
		if (beans.isEmpty()) {
			beans = beanManager.getBeans(beanClass, new AnnotationLiteral<Any>() { //
			});
		}

		Bean bean = beanManager.resolve(beans);

		Class scopeAnnotationClass = bean.getScope();
		Context context;

		if (scopeAnnotationClass.equals(RequestScoped.class)) {
			context = beanManager.getContext(scopeAnnotationClass);
			if (context == null)
				return bean.create(beanManager.createCreationalContext(bean));

		} else {

			if (scopeAnnotationClass.equals(NGSessionScopeContext.class)) {
				context = NGSessionScopeContext.getINSTANCE();
			} else {
				context = beanManager.getContext(scopeAnnotationClass);
			}

		}
		CreationalContext creationalContext = beanManager.createCreationalContext(bean);
		Object reference = context.get(bean, creationalContext);

		// if(reference==null && scopeAnnotationClass.equals(RequestScoped.class)){
		// reference= bean.create(beanManager.createCreationalContext(bean));
		// }

		return reference;
	}
 
Example #15
Source File: BeanReloadExecutor.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void doReloadBeanInContext(BeanManagerImpl beanManager, ManagedBean managedBean, Context context) {
    if(ContextualReloadHelper.addToReloadSet(context, managedBean)) {
        LOGGER.debug("Bean {}, added to reload set in context '{}'", managedBean, context.getClass());
    } else {
        // fallback for not patched contexts
        doReinjectBean(beanManager, managedBean);
    }
}
 
Example #16
Source File: BeanReloadExecutor.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static Map<Class<? extends Annotation>, List<Context>> getContextMap(BeanManagerImpl beanManager) {
    try {
        return Map.class.cast(ReflectionHelper.get(beanManager, "contexts"));
    } catch (Exception e) {
        LOGGER.warning("BeanManagerImpl.contexts not accessible", e);
    }
    return Collections.emptyMap();
}
 
Example #17
Source File: TransactionBeanWithEvents.java    From quarkus with Apache License 2.0 5 votes vote down vote up
void transactionScopeActivated(@Observes @Initialized(TransactionScoped.class) final Object event,
        final BeanManager beanManager) throws SystemException {
    Transaction tx = tm.getTransaction();
    if (tx == null) {
        log.error("@Intialized expects an active transaction");
        throw new IllegalStateException("@Intialized expects an active transaction");
    }
    if (tx.getStatus() != Status.STATUS_ACTIVE) {
        log.error("@Initialized expects transaction is Status.STATUS_ACTIVE");
        throw new IllegalStateException("@Initialized expects transaction is Status.STATUS_ACTIVE");
    }
    Context ctx;
    try {
        ctx = beanManager.getContext(TransactionScoped.class);
    } catch (Exception e) {
        log.error("Context on @Initialized is not available");
        throw e;
    }
    if (!ctx.isActive()) {
        log.error("Context on @Initialized has to be active");
        throw new IllegalStateException("Context on @Initialized has to be active");
    }
    if (!(event instanceof Transaction)) {
        log.error("@Intialized scope expects event payload being the " + Transaction.class.getName());
        throw new IllegalStateException("@Intialized scope expects event payload being the " + Transaction.class.getName());
    }

    initializedCount++;
}
 
Example #18
Source File: BeanReloadExecutor.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void doReinjectBeanInstance(BeanManagerImpl beanManager, AbstractClassBean bean, Context context) {
    Object instance = context.get(bean);
    if (instance != null) {
        doCallInject(beanManager, bean, instance);
    }
}
 
Example #19
Source File: ContextualReloadHelper.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Will re-inject any managed beans in the target. Will not call any other life-cycle methods
 *
 * @param ctx
 * @param managedBean
 */
public static void reinitialize(Context ctx, Contextual<Object> contextual) {
    try {
        ManagedBean<Object> managedBean = ManagedBean.class.cast(contextual);
        LOGGER.debug("Re-Initializing........ {},: {}", managedBean, ctx);
        Object get = ctx.get(managedBean);
        if (get != null) {
            LOGGER.debug("Bean injection points are reinitialized '{}'", managedBean);
            managedBean.getProducer().inject(get, managedBean.getBeanManager().createCreationalContext(managedBean));
        }
    } catch (Exception e) {
        LOGGER.error("Error reinitializing bean {},: {}", e, contextual, ctx);
    }
}
 
Example #20
Source File: BeanClassRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
private static void doReloadBeanInContext(BeanManagerImpl beanManager, InjectionTargetBean bean, Context context) {
    if (ContextualReloadHelper.addToReloadSet(context, bean)) {
        LOGGER.debug("Bean {}, added to reload set in context '{}'", bean, context.getClass());
    } else {
        // fallback: try to reinitialize injection points instead...
        doReinjectBeanInstance(beanManager, bean, context);
    }
}
 
Example #21
Source File: BeanClassRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Map<Class<? extends Annotation>, Context> getSingleContextMap(BeanManagerImpl beanManagerImpl){
    try {
        Field contextsField = BeanManagerImpl.class.getField("singleContextMap");
        contextsField.setAccessible(true);
        return (Map) contextsField.get(beanManagerImpl);
    } catch (IllegalAccessException |IllegalArgumentException | NoSuchFieldException | SecurityException e) {
        LOGGER.warning("Field BeanManagerImpl.singleContextMap is not accessible", e);
    }
    return Collections.emptyMap();
}
 
Example #22
Source File: BeanClassRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Map<Class<? extends Annotation>, List<Context>> getContextMap(BeanManagerImpl beanManagerImpl){
    try {
        Field contextsField = BeanManagerImpl.class.getField("contextMap");
        contextsField.setAccessible(true);
        return (Map) contextsField.get(beanManagerImpl);
    } catch (IllegalAccessException |IllegalArgumentException | NoSuchFieldException | SecurityException e) {
        LOGGER.warning("Field BeanManagerImpl.contextMap is not accessible", e);
    }
    return Collections.emptyMap();
}
 
Example #23
Source File: BeanClassRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void doReinjectBeanInstance(BeanManagerImpl beanManager, InjectionTargetBean bean, Context context) {
    Object instance = context.get(bean);
    if (instance != null) {
        instance = unwrapInstance(beanManager, instance);
        bean.getProducer().inject(instance, beanManager.createCreationalContext(bean));
        LOGGER.info("Bean '{}' injection points was reinjected.", bean.getBeanClass().getName());
    }
}
 
Example #24
Source File: TransactionBeanWithEvents.java    From quarkus with Apache License 2.0 5 votes vote down vote up
void transactionScopeDestroyed(@Observes @Destroyed(TransactionScoped.class) final Object event,
        final BeanManager beanManager) throws SystemException {
    Transaction tx = tm.getTransaction();
    if (tx != null)
        throw new IllegalStateException("@Destroyed expects no transaction");
    try {
        Context ctx = beanManager.getContext(TransactionScoped.class);
        throw new IllegalStateException("No bean in context expected but it's " + ctx);
    } catch (final ContextNotActiveException expected) {
    }

    destroyedCount++;
}
 
Example #25
Source File: CdiPlugin.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public Object getSessionBeanProxy(final Bean<?> inBean, final Class<?> interfce, final CreationalContext<?> creationalContext) {
    Object instance = cacheProxies.get(inBean);
    if (instance != null) {
        return instance;
    }

    synchronized (inBean) { // singleton for the app so safe to sync on it
        instance = cacheProxies.get(inBean);
        if (instance != null) {
            return instance;
        }

        final Class<? extends Annotation> scopeClass = inBean.getScope();
        final CdiEjbBean<Object> cdiEjbBean = (CdiEjbBean<Object>) inBean;
        final CreationalContext<Object> cc = (CreationalContext<Object>) creationalContext;

        if (scopeClass == null || Dependent.class == scopeClass) { // no need to add any layer, null = @New
            return cdiEjbBean.createEjb(cc);
        }

        // only stateful normally
        final InstanceBean<Object> bean = new InstanceBean<>(cdiEjbBean);
        if (webBeansContext.getBeanManagerImpl().isNormalScope(scopeClass)) {
            final BeanContext beanContext = cdiEjbBean.getBeanContext();
            final Provider provider = webBeansContext.getNormalScopeProxyFactory().getInstanceProvider(beanContext.getClassLoader(), cdiEjbBean);

            if (!beanContext.isLocalbean()) {
                final List<Class> interfaces = new ArrayList<>();
                final InterfaceType type = beanContext.getInterfaceType(interfce);
                if (type != null) {
                    interfaces.addAll(beanContext.getInterfaces(type));
                } else { // can happen when looked up from impl instead of API in OWB -> default to business local
                    interfaces.addAll(beanContext.getInterfaces(InterfaceType.BUSINESS_LOCAL));
                }
                interfaces.add(Serializable.class);
                interfaces.add(IntraVmProxy.class);
                if (BeanType.STATEFUL.equals(beanContext.getComponentType()) || BeanType.MANAGED.equals(beanContext.getComponentType())) {
                    interfaces.add(BeanContext.Removable.class);
                }

                try {
                    instance = ProxyManager.newProxyInstance(interfaces.toArray(new Class<?>[interfaces.size()]), new InvocationHandler() {
                        @Override
                        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
                            try {
                                return method.invoke(provider.get(), args);
                            } catch (final InvocationTargetException ite) {
                                throw ite.getCause();
                            }
                        }
                    });
                } catch (final IllegalAccessException e) {
                    throw new OpenEJBRuntimeException(e);
                }

            } else {
                final NormalScopeProxyFactory normalScopeProxyFactory = webBeansContext.getNormalScopeProxyFactory();
                final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass());
                instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
            }

            cacheProxies.put(inBean, instance);
        } else {
            final Context context = webBeansContext.getBeanManagerImpl().getContext(scopeClass);
            instance = context.get(bean, cc);
        }
        bean.setOwbProxy(instance);
        return instance;
    }
}
 
Example #26
Source File: ScopesTest.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
private Context getContext() {
    return WebBeansContext.currentInstance()
                          .getContextsService()
                          .getCurrentContext(RequestScoped.class, false);
}
 
Example #27
Source File: RepositoryRefreshAgent.java    From HotswapAgent with GNU General Public License v2.0 4 votes vote down vote up
private static <T> T getInstance(BeanManager beanManager, Bean<T> bean) {
    Context context = beanManager.getContext(bean.getScope());
    return context.get(bean);
}
 
Example #28
Source File: NGSessionScopeContext.java    From AngularBeans with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Context getINSTANCE() {
	if (INSTANCE == null)
		INSTANCE = new NGSessionScopeContext();
	return INSTANCE;
}
 
Example #29
Source File: ApplicationScopedTest.java    From tomee with Apache License 2.0 3 votes vote down vote up
@Test
public void test() throws Exception {

    final Context appContext = beanManager.getContext(ApplicationScoped.class);


    final Green green = createAndMutate(appContext, Green.class);

    final Blue blue = createAndMutate(appContext, Blue.class);

    assertEquals(green.getMessage(), blue.getGreen().getMessage());

    final BrownLocal brownLocal = createAndMutate(appContext, BrownLocal.class);

    final Green green2 = brownLocal.getGreen();
    green2.getMessage();

    final Orange orange = createAndMutate(appContext, Orange.class);
    assertNotNull(orange);
    assertNotNull(orange.getBlue());
    assertNotNull(orange.getBlue().getGreen());
    assertNotNull(orange.getGreen());

    final Green greenA = orange.getBlue().getGreen();
    final Green greenB = orange.getGreen();

    assertSame(greenA, greenB);
}
 
Example #30
Source File: HaCdiCommons.java    From HotswapAgent with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Gets the context class for specified scope.
 *
 * @param scope the scope
 * @return the context class
 */
public static Class<? extends Context> getContextClass(Class<? extends Annotation> scope) {
    return getCurrentScopeToContextMap().get(scope);
}