@Override public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext) { if (creationalContext == null) return null; T instance = bean.create(creationalContext); return instance; }
private <T> void destroyContextualInstance(ContextualInstance<T> instance) { instance.getContextual().destroy(instance.getInstance(), instance.getCreationalContext()); ContextLogger.LOG.contextualInstanceRemoved(instance, this); }
@SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { Map<Contextual<?>, ContextualInstance<?>> ctx = currentContext.get(); if (ctx == null) { // Thread local not set - context is not active! throw new ContextNotActiveException(); } ContextualInstance<T> instance = (ContextualInstance<T>) ctx.get(contextual); if (instance == null && creationalContext != null) { // Bean instance does not exist - create one if we have CreationalContext instance = new ContextualInstance<T>(contextual.create(creationalContext), creationalContext, contextual); ctx.put(contextual, instance); } return instance != null ? instance.get() : null; }
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); throw ContextLogger.LOG.contextualIsNull(); return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class));
@SuppressWarnings("unchecked") public void reset(Object instance) { bean.destroy((T)instance, cc); }
@SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { Map<Contextual<?>, ContextualInstance<?>> ctx = currentContext.get(); if (ctx == null) { // Thread local not set - context is not active! throw new ContextNotActiveException(); } ContextualInstance<T> instance = (ContextualInstance<T>) ctx.get(contextual); if (instance == null && creationalContext != null) { // Bean instance does not exist - create one if we have CreationalContext instance = new ContextualInstance<T>(contextual.create(creationalContext), creationalContext, contextual); ctx.put(contextual, instance); } return instance != null ? instance.get() : null; }
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); throw ContextLogger.LOG.contextualIsNull(); return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class));
public void destroy() { contextual.destroy(object, creationalContext); } }
@SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { Map<Contextual<?>, ContextualInstance<?>> ctx = currentContext.get(); if (ctx == null) { // Thread local not set - context is not active! throw new ContextNotActiveException(); } ContextualInstance<T> instance = (ContextualInstance<T>) ctx.get(contextual); if (instance == null && creationalContext != null) { // Bean instance does not exist - create one if we have CreationalContext instance = new ContextualInstance<T>(contextual.create(creationalContext), creationalContext, contextual); ctx.put(contextual, instance); } return instance != null ? instance.get() : null; }
public TransactionScopedBean(Contextual<T> contextual, CreationalContext<T> creationalContext, TransactionScopedContextImpl transactionScopedContext) { this.contextual = contextual; this.creationalContext = creationalContext; this.transactionScopedContext = transactionScopedContext; contextualInstance = contextual.create(creationalContext); }
private <T> void destroyContextualInstance(ContextualInstance<T> instance) { instance.getContextual().destroy(instance.getInstance(), instance.getCreationalContext()); ContextLogger.LOG.contextualInstanceRemoved(instance, this); }
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); throw ContextLogger.LOG.contextualIsNull(); return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class));
@Override @SuppressWarnings("unchecked") public void destroy(Contextual<?> contextual) { Instance instance = storage.remove(contextual); @SuppressWarnings("rawtypes") Contextual rawContextual = contextual; rawContextual.destroy(instance.instance, instance.ctx); } }
@SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { Map<Contextual<?>, ContextualInstance<?>> ctx = currentContext.get(); if (ctx == null) { // Thread local not set - context is not active! throw new ContextNotActiveException(); } ContextualInstance<T> instance = (ContextualInstance<T>) ctx.get(contextual); if (instance == null && creationalContext != null) { // Bean instance does not exist - create one if we have CreationalContext instance = new ContextualInstance<T>(contextual.create(creationalContext), creationalContext, contextual); ctx.put(contextual, instance); } return instance != null ? instance.get() : null; }
@Override public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { return contextual.create(creationalContext); } }
private <T> void destroyContextualInstance(ContextualInstance<T> instance) { instance.getContextual().destroy(instance.getInstance(), instance.getCreationalContext()); ContextLogger.LOG.contextualInstanceRemoved(instance, this); }
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); throw ContextLogger.LOG.contextualIsNull(); return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class));
@Override public void destroy(Contextual<?> contextual) { Instance instance = storage.remove(contextual); Contextual rawContextual = contextual; rawContextual.destroy(instance.instance, instance.ctx); }
@SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { Map<Contextual<?>, ContextualInstance<?>> ctx = currentContext.get(); if (ctx == null) { // Thread local not set - context is not active! throw new ContextNotActiveException(); } ContextualInstance<T> instance = (ContextualInstance<T>) ctx.get(contextual); if (instance == null && creationalContext != null) { // Bean instance does not exist - create one if we have CreationalContext instance = new ContextualInstance<T>(contextual.create(creationalContext), creationalContext, contextual); ctx.put(contextual, instance); } return instance != null ? instance.get() : null; }
public T create(Contextual<T> contextual) { if (beanInstance == null) { beanInstance = contextual.create(beanCreationalContext); } return beanInstance; } }