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()); }
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") public boolean equals(Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (!BaseEjbProxyHandler.class.isInstance(obj)) { final Class<?> aClass = obj.getClass(); if (Proxy.isProxyClass(aClass)) { obj = Proxy.getInvocationHandler(obj); } else if (LocalBeanProxyFactory.isProxy(aClass)) { obj = LocalBeanProxyFactory.getInvocationHandler(obj); } else { return false; } } return equalHandler(BaseEjbProxyHandler.class.cast(obj)); }
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") public boolean equals(Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (!BaseEjbProxyHandler.class.isInstance(obj)) { final Class<?> aClass = obj.getClass(); if (Proxy.isProxyClass(aClass)) { obj = Proxy.getInvocationHandler(obj); } else if (LocalBeanProxyFactory.isProxy(aClass)) { obj = LocalBeanProxyFactory.getInvocationHandler(obj); } else { return false; } } final BaseEjbProxyHandler other = (BaseEjbProxyHandler) obj; return equalHandler(other); }
public static InvocationHandler getInvocationHandler(final Object proxy) { if (LocalBeanProxyFactory.isProxy(proxy.getClass())) { return LocalBeanProxyFactory.getInvocationHandler(proxy); } checkDefaultFactory(); return defaultFactory.getInvocationHandler(proxy); }
public static InvocationHandler getInvocationHandler(final Object proxy) { if (LocalBeanProxyFactory.isProxy(proxy.getClass())) { return LocalBeanProxyFactory.getInvocationHandler(proxy); } checkDefaultFactory(); return defaultFactory.getInvocationHandler(proxy); }
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); } }