public static Object newProxyInstance(final ClassLoader classLoader, final InvocationHandler handler, final Class classToSubclass, final Class... interfaces) throws IllegalArgumentException { try { final Class proxyClass = createProxy(classToSubclass, classLoader, interfaces); return constructProxy(proxyClass, handler); } catch (final Throwable e) { throw new InternalError("LocalBeanProxyFactory.newProxyInstance: " + Debug.printStackTrace(e)); } }
public static Object newProxyInstance(final ClassLoader classLoader, final InvocationHandler handler, final Class classToSubclass, final Class... interfaces) throws IllegalArgumentException { try { final Class proxyClass = createProxy(classToSubclass, classLoader, interfaces); return constructProxy(proxyClass, handler); } catch (final Throwable e) { throw new InternalError("LocalBeanProxyFactory.newProxyInstance: " + Debug.printStackTrace(e)); } }
@Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { if (xaResource != null && xaResourceWrapper != null) { xaResource = xaResourceWrapper.wrap(xaResource, container.getContainerID().toString()); } final EndpointHandler endpointHandler = new EndpointHandler(container, beanContext, instanceFactory, xaResource); try { return (MessageEndpoint) LocalBeanProxyFactory.constructProxy(proxy, endpointHandler); } catch (final InternalError e) { // should be useless //try to create the proxy with tccl once again. try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(Thread.currentThread().getContextClassLoader(), endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie) { try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(classLoader, endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie2) { // no-op } } throw e; } }
@Override public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException { if (xaResource != null && xaResourceWrapper != null) { xaResource = xaResourceWrapper.wrap(xaResource, container.getContainerID().toString()); } InvocationHandler endpointHandler = null; if (usePool) { endpointHandler = new PoolEndpointHandler(container, beanContext, instanceManager, xaResource); } else { endpointHandler = new EndpointHandler(container, beanContext, instanceFactory, xaResource); } try { return (MessageEndpoint) LocalBeanProxyFactory.constructProxy(proxy, endpointHandler); } catch (final InternalError e) { // should be useless //try to create the proxy with tccl once again. try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(Thread.currentThread().getContextClassLoader(), endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie) { try { return MessageEndpoint.class.cast(LocalBeanProxyFactory.newProxyInstance(classLoader, endpointHandler, beanContext.getBeanClass(), interfaces)); } catch (final InternalError ie2) { // no-op } } throw e; } }
return LocalBeanProxyFactory.constructProxy(di.get(BeanContext.ProxyClass.class).getProxy(), handler); } else { final List<Class> interfaces = new ArrayList<Class>();
return LocalBeanProxyFactory.constructProxy(di.get(BeanContext.ProxyClass.class).getProxy(), handler); } else { final List<Class> interfaces = new ArrayList<Class>();
public Object createProxy(final Object primaryKey, final Class mainInterface) { try { final InterfaceType objectInterfaceType = this.interfaceType.getCounterpart(); final BeanType type = getBeanContext().getComponentType(); final EjbObjectProxyHandler handler = newEjbObjectHandler(getBeanContext(), primaryKey, objectInterfaceType, getInterfaces(), mainInterface); // TODO Is it correct for ManagedBean injection via managed bean class? if ((InterfaceType.LOCALBEAN.equals(objectInterfaceType) || getBeanContext().getComponentType().equals(BeanType.MANAGED)) && !getBeanContext().isDynamicallyImplemented()) { return LocalBeanProxyFactory.constructProxy(handler.getBeanContext().get(BeanContext.ProxyClass.class).getProxy(), handler); } else { final List<Class> proxyInterfaces = new ArrayList<Class>(handler.getInterfaces().size() + 2); proxyInterfaces.addAll(handler.getInterfaces()); proxyInterfaces.add(Serializable.class); proxyInterfaces.add(IntraVmProxy.class); if (BeanType.STATEFUL.equals(type) || BeanType.MANAGED.equals(type)) { proxyInterfaces.add(BeanContext.Removable.class); } return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[proxyInterfaces.size()]), handler); } } catch (final IllegalAccessException iae) { throw new OpenEJBRuntimeException("Could not create IVM proxy for " + getInterfaces().get(0), iae); } }
public Object createProxy(final Object primaryKey, final Class mainInterface) { try { final InterfaceType objectInterfaceType = this.interfaceType.getCounterpart(); final BeanType type = getBeanContext().getComponentType(); final EjbObjectProxyHandler handler = newEjbObjectHandler(getBeanContext(), primaryKey, objectInterfaceType, getInterfaces(), mainInterface); // TODO Is it correct for ManagedBean injection via managed bean class? if ((InterfaceType.LOCALBEAN.equals(objectInterfaceType) || getBeanContext().getComponentType().equals(BeanType.MANAGED)) && !getBeanContext().isDynamicallyImplemented()) { return LocalBeanProxyFactory.constructProxy(handler.getBeanContext().get(BeanContext.ProxyClass.class).getProxy(), handler); } else { final List<Class> proxyInterfaces = new ArrayList<Class>(handler.getInterfaces().size() + 2); proxyInterfaces.addAll(handler.getInterfaces()); proxyInterfaces.add(Serializable.class); proxyInterfaces.add(IntraVmProxy.class); if (BeanType.STATEFUL.equals(type) || BeanType.MANAGED.equals(type)) { proxyInterfaces.add(BeanContext.Removable.class); } return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[proxyInterfaces.size()]), handler); } } catch (final IllegalAccessException iae) { throw new OpenEJBRuntimeException("Could not create IVM proxy for " + getInterfaces().get(0), iae); } }