private Collection<Class<?>> getContextTypes(final Object resourceObject) { if (!ProxyManager.isProxyClass(resourceObject.getClass()) && !LocalBeanProxyFactory.isProxy(resourceObject.getClass())) { return Collections.emptySet(); } final InvocationHandler handler = ProxyManager.getInvocationHandler(resourceObject); if (!(handler instanceof BeanContextInvocationHandler)) { return Collections.emptySet(); } final BeanContext beanContext = ((BeanContextInvocationHandler) handler).getBeanContext(); if (beanContext == null) { return Collections.emptySet(); } return contextTypes.get(beanContext.getBeanClass()); }
private void destroyScopedStateful(final T instance, final CreationalContext<T> cc) { try { instance.hashCode(); // force the instance to be created - otherwise we'll miss @PreDestroy for instance } catch (final NoSuchEJBException e) { InvocationHandler handler = null; if (LocalBeanProxyFactory.isProxy(instance.getClass())) { handler = LocalBeanProxyFactory.getInvocationHandler(instance); } else if (ProxyManager.isProxyClass(instance.getClass())) { handler = ProxyManager.getInvocationHandler(instance); } if (BaseEjbProxyHandler.class.isInstance(handler) && !BaseEjbProxyHandler.class.cast(handler).isValid()) { return; // already destroyed } // else log error logger.log(Level.FINE, "The stateful instance " + instance + " can't be removed since it was invalidated", e); return; } final Object ejbInstance = dependentSFSBToBeRemoved.remove(System.identityHashCode(instance)); if (ejbInstance != null) { destroyStatefulSessionBeanInstance((T) ejbInstance, cc); } else { destroyStatefulSessionBeanInstance(instance, cc); } }
private void destroyScopedStateful(final T instance, final CreationalContext<T> cc) { try { instance.hashCode(); // force the instance to be created - otherwise we'll miss @PreDestroy for instance } catch (final NoSuchEJBException e) { InvocationHandler handler = null; if (LocalBeanProxyFactory.isProxy(instance.getClass())) { handler = LocalBeanProxyFactory.getInvocationHandler(instance); } else if (ProxyManager.isProxyClass(instance.getClass())) { handler = ProxyManager.getInvocationHandler(instance); } if (BaseEjbProxyHandler.class.isInstance(handler) && !BaseEjbProxyHandler.class.cast(handler).isValid()) { return; // already destroyed } // else log error logger.log(Level.FINE, "The stateful instance " + instance + " can't be removed since it was invalidated", e); return; } final Object ejbInstance = dependentSFSBToBeRemoved.remove(System.identityHashCode(instance)); if (ejbInstance != null) { destroyStatefulSessionBeanInstance((T) ejbInstance, cc); } else { destroyStatefulSessionBeanInstance(instance, cc); } }