private void addInterceptorInstance(Interceptor<Object> interceptor, BeanManagerImpl beanManager, Map<String, SerializableContextualInstance<Interceptor<Object>, Object>> instances, final CreationalContext<Object> creationalContext) { Object instance = beanManager.getReference(interceptor, interceptor.getBeanClass(), creationalContext, true); SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance = beanManager.getServices().get(ContextualStore.class).<Interceptor<Object>, Object>getSerializableContextualInstance(interceptor, instance, creationalContext); instances.put(interceptor.getBeanClass().getName(), serializableContextualInstance); }
public BeanHolder(String contextId, Bean<T> bean) { super(bean); this.contextId = contextId; if (bean == null) { beanId = null; } else { beanId = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); } }
public Bean<?> getBean() { if (bean == null) { if (beanId == null) { throw BeanLogger.LOG.proxyHandlerSerializedForNonSerializableBean(); } bean = Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(beanId); } return bean; }
/** * Always returns the original proxy object that was serialized. * * @return the proxy object * @throws java.io.ObjectStreamException */ Object readResolve() throws ObjectStreamException { Bean<?> bean = Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(beanId); if (bean == null) { throw BeanLogger.LOG.proxyDeserializationFailure(beanId); } return Container.instance(contextId).deploymentManager().getClientProxyProvider().getClientProxy(bean); }
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) { BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); if (id == null) { throw BeanLogger.LOG.beanIdCreationFailed(bean); } BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId); TypeInfo typeInfo = TypeInfo.of(types); T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance); BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id); return proxy; }
@Override public <T> T get(Contextual<T> contextual) { contextual = store.getSerializableContextual(contextual); return context.get(contextual); }
public void addDecorator(Decorator<?> bean) { decorators.add(bean); getServices().get(ContextualStore.class).putIfAbsent(bean); decoratorResolver.clear(); }
public T call() throws Exception { if (instance == null) { Contextual<T> contextual = getBeanManager().getServices().get(ContextualStore.class).<Contextual<T>, T>getContextual(beanId); if (contextual instanceof EEResourceProducerField<?, ?>) { this.instance = Reflections.<EEResourceProducerField<?, T>>cast(contextual).createUnderlying(creationalContext); } else { throw BeanLogger.LOG.beanNotEeResourceProducer(contextual); } } return instance; }
@SuppressWarnings("unchecked") private void addInterceptorInstance(Interceptor<Object> interceptor, InvocationContext invocationContext) { CreationalContext<Object> creationalContext = (CreationalContext<Object>) invocationContext.getContextData().get(SessionBeanInterceptor.CREATIONAL_CONTEXT); Object instance = beanManager.getContext(interceptor.getScope()).get(interceptor, creationalContext); SerializableContextualInstance<Interceptor<Object>,Object> serializableContextualInstance = beanManager.getServices().get(ContextualStore.class).getSerializableContextualInstance(interceptor, instance, creationalContext); interceptorInstances.put(interceptor.getBeanClass().getName(), serializableContextualInstance); }
@SuppressWarnings("unchecked") private void addInterceptorInstance(Interceptor<Object> interceptor, BeanManagerImpl beanManager, Map<String, SerializableContextualInstance<Interceptor<Object>, Object>> instances) { Object instance = beanManager.getContext(interceptor.getScope()).get(interceptor, creationalContext); SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance = beanManager.getServices().get(ContextualStore.class).<Interceptor<Object>, Object>getSerializableContextualInstance(interceptor, instance, creationalContext); instances.put(interceptor.getBeanClass().getName(), serializableContextualInstance); }
@Override public Bean<?> getPassivationCapableBean(String id) { return getServices().get(ContextualStore.class).<Bean<Object>, Object> getContextual(id); }
public SerializableContextualInstanceImpl(C contextual, I instance, CreationalContext<I> creationalContext, ContextualStore contextualStore) { this.contextual = contextualStore.getSerializableContextual(contextual); this.instance = instance; this.creationalContext = creationalContext; }
private void loadContextual() { if (serializable != null) { cached = serializable; } else if (identifierIndex != null) { cached = getContextualStore().<C, I> getContextual(getBeanIdentifierIndex().getIdentifier(identifierIndex)); } else if (identifier != null) { cached = getContextualStore().<C, I> getContextual(identifier); } if (cached == null) { throw new IllegalStateException("Error restoring serialized contextual with id " + identifier); } }
public BeanHolder(String contextId, Bean<T> bean) { super(bean); this.contextId = contextId; if (bean == null) { beanId = null; } else { beanId = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); } }
public Bean<?> getBean() { if (bean == null) { if (beanId == null) { throw BeanLogger.LOG.proxyHandlerSerializedForNonSerializableBean(); } bean = Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(beanId); } return bean; }
/** * Always returns the original proxy object that was serialized. * * @return the proxy object * @throws java.io.ObjectStreamException */ Object readResolve() throws ObjectStreamException { Bean<?> bean = Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(beanId); if (bean == null) { throw BeanLogger.LOG.proxyDeserializationFailure(beanId); } return Container.instance(contextId).deploymentManager().getClientProxyProvider().getClientProxy(bean); }
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) { BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean); if (id == null) { throw BeanLogger.LOG.beanIdCreationFailed(bean); } BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId); TypeInfo typeInfo = TypeInfo.of(types); T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance); BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id); return proxy; }
@Override public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { contextual = store.getSerializableContextual(contextual); return context.get(contextual, creationalContext); }
public void addDecorator(Decorator<?> bean) { decorators.add(bean); getServices().get(ContextualStore.class).putIfAbsent(bean); decoratorResolver.clear(); }
public T call() throws Exception { if (instance == null) { Contextual<T> contextual = getBeanManager().getServices().get(ContextualStore.class).<Contextual<T>, T>getContextual(beanId); if (contextual instanceof EEResourceProducerField<?, ?>) { this.instance = Reflections.<EEResourceProducerField<?, T>>cast(contextual).createUnderlying(creationalContext); } else { throw BeanLogger.LOG.beanNotEeResourceProducer(contextual); } } return instance; }