public String toString() { String name = null; try { name = getProxyInfo().getInterface().getName(); } catch (final Exception e) { //Ignore } return "proxy=" + name + ";deployment=" + this.deploymentID + ";pk=" + this.primaryKey; }
/** * Method instance on proxies that come from a classloader outside * the bean's classloader need to be swapped out for the identical * method in the bean's classloader. * * @param method Method * @return return's the same method but loaded from the beans classloader */ private Method copyMethod(final Method method) throws Exception { final int parameterCount = method.getParameterTypes().length; Class[] types = new Class[1 + parameterCount]; types[0] = method.getDeclaringClass(); System.arraycopy(method.getParameterTypes(), 0, types, 1, parameterCount); types = (Class[]) copyArgs(types); final Class targetClass = types[0]; final Class[] targetParameters = new Class[parameterCount]; System.arraycopy(types, 1, targetParameters, 0, parameterCount); return targetClass.getMethod(method.getName(), targetParameters); }
protected Object[] copyArgs(final Object[] objects) throws IOException, ClassNotFoundException { if (objects == null) { return objects; } /* while copying the arguments is necessary. Its not necessary to copy the array itself, because they array is created by the Proxy implementation for the sole purpose of packaging the arguments for the InvocationHandler.invoke( ) method. Its ephemeral and their for doesn't need to be copied. */ for (int i = 0; i < objects.length; i++) { objects[i] = copyObj(objects[i]); } return objects; }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { isValidReference(method); if (methodName.equals("toString")) return toString(); else if (methodName.equals("equals")) return equals(args[0]) ? Boolean.TRUE : Boolean.FALSE; else if (methodName.equals("hashCode")) return new Integer(hashCode()); else throw new UnsupportedOperationException("Unkown method: " + method); } else if (method.getDeclaringClass() == IntraVmProxy.class) { final String methodName = method.getName(); if (methodName.equals("writeReplace")) return _writeReplace(proxy); else throw new UnsupportedOperationException("Unkown method: " + method); Class interfce = getInvokedInterface(method); Thread.currentThread().setContextClassLoader(getDeploymentInfo().getClassLoader()); try { args = copyArgs(args); method = copyMethod(method); interfce = copyObj(interfce); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); args = copyArgs(args); } finally { IntraVmCopyMonitor.post(); Object returnValue = _invoke(proxy, interfce, method, args); return copy(strategy, returnValue);
if (e instanceof TransactionRequiredException) { if (!rmiRemote && interfaceType.isBusiness()) { return new EJBTransactionRequiredException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBTransactionRolledbackException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new NoSuchEJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new NoSuchObjectLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new AccessLocalException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new AccessLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new EJBException(e.getMessage()).initCause(getCause(e));
@Override public Object invoke(final Object proxy, Method method, Object[] args) throws Throwable { try { isValidReference(method); } catch (final IllegalStateException ise) { final BeanContext beanContext = beanContextRef.get(); if (beanContext != null) { return _writeReplace(proxy); return toString(); } else if (methodName.equals("equals")) { return equals(args[0]) ? Boolean.TRUE : Boolean.FALSE; } else if (methodName.equals("hashCode")) { return hashCode(); } else { throw new UnsupportedOperationException("Unknown method: " + method); return _writeReplace(proxy); } else { throw new UnsupportedOperationException("Unknown method: " + method); return _invoke(proxy, BeanContext.Removable.class, method, args); Class interfce = getInvokedInterface(method); if (strategy == CLASSLOADER_COPY || getBeanContext().getInterfaceType(interfce) == InterfaceType.BUSINESS_REMOTE) { Thread.currentThread().setContextClassLoader(getBeanContext().getClassLoader()); try {
if (e instanceof TransactionRequiredException) { if (!rmiRemote && interfaceType.isBusiness()) { return new EJBTransactionRequiredException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBTransactionRolledbackException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new NoSuchEJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new NoSuchObjectLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new EJBException(e.getMessage()).initCause(getCause(e)); } else { return e; return new AccessLocalException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new AccessLocalException(e.getMessage()).initCause(getCause(e));
@Override public Object invoke(final Object proxy, Method method, Object[] args) throws Throwable { try { isValidReference(method); } catch (final IllegalStateException ise) { final BeanContext beanContext = beanContextRef.get(); if (beanContext != null) { return _writeReplace(proxy); return toString(); } else if (methodName.equals("equals")) { return equals(args[0]) ? Boolean.TRUE : Boolean.FALSE; } else if (methodName.equals("hashCode")) { return hashCode(); } else { throw new UnsupportedOperationException("Unknown method: " + method); return _writeReplace(proxy); } else { throw new UnsupportedOperationException("Unknown method: " + method); return _invoke(proxy, BeanContext.Removable.class, method, args); Class interfce = getInvokedInterface(method); if (strategy == CLASSLOADER_COPY || getBeanContext().getInterfaceType(interfce) == InterfaceType.BUSINESS_REMOTE) { Thread.currentThread().setContextClassLoader(getBeanContext().getClassLoader()); try {
public String toString() { String name = null; try { name = getProxyInfo().getInterface().getName(); } catch (final Exception e) { //Ignore } return "proxy=" + name + ";deployment=" + this.deploymentID + ";pk=" + this.primaryKey; }
protected Object[] copyArgs(Object[] objects) throws IOException, ClassNotFoundException { if (objects == null) return objects; /* while copying the arguments is necessary. Its not necessary to copy the array itself, because they array is created by the Proxy implementation for the sole purpose of packaging the arguments for the InvocationHandler.invoke( ) method. Its ephemeral and their for doesn't need to be copied. */ for (int i = 0; i < objects.length; i++) { objects[i] = copyObj(objects[i]); } return objects; }
/** * Method instance on proxies that come from a classloader outside * the bean's classloader need to be swapped out for the identical * method in the bean's classloader. * * @param method Method * @return return's the same method but loaded from the beans classloader */ private Method copyMethod(final Method method) throws Exception { final int parameterCount = method.getParameterTypes().length; Class[] types = new Class[1 + parameterCount]; types[0] = method.getDeclaringClass(); System.arraycopy(method.getParameterTypes(), 0, types, 1, parameterCount); types = (Class[]) copyArgs(types); final Class targetClass = types[0]; final Class[] targetParameters = new Class[parameterCount]; System.arraycopy(types, 1, targetParameters, 0, parameterCount); return targetClass.getMethod(method.getName(), targetParameters); }
if (e instanceof TransactionRequiredException) { if (!rmiRemote && interfaceType.isBusiness()) { return new EJBTransactionRequiredException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRequiredLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBTransactionRolledbackException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new TransactionRolledbackLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new NoSuchEJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new NoSuchObjectLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new AccessLocalException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new AccessLocalException(e.getMessage()).initCause(getCause(e)); } else { return e; return new EJBException(e.getMessage()).initCause(getCause(e)); } else if (interfaceType.isLocal()) { return new EJBException(e.getMessage()).initCause(getCause(e));
public String toString() { String name = null; try { name = getProxyInfo().getInterface().getName(); } catch (Exception e) { } return "proxy=" + name + ";deployment=" + this.deploymentID + ";pk=" + this.primaryKey; }
protected Object[] copyArgs(final Object[] objects) throws IOException, ClassNotFoundException { if (objects == null) { return null; } /* while copying the arguments is necessary. Its not necessary to copy the array itself, because they array is created by the Proxy implementation for the sole purpose of packaging the arguments for the InvocationHandler.invoke( ) method. Its ephemeral and their for doesn't need to be copied. */ for (int i = 0; i < objects.length; i++) { objects[i] = copyObj(objects[i]); } return objects; }
/** * Method instance on proxies that come from a classloader outside * the bean's classloader need to be swapped out for the identical * method in the bean's classloader. * * @param method * @return return's the same method but loaded from the beans classloader */ private Method copyMethod(Method method) throws Exception { int parameterCount = method.getParameterTypes().length; Object[] types = new Object[1 + parameterCount]; types[0] = method.getDeclaringClass(); System.arraycopy(method.getParameterTypes(), 0, types, 1, parameterCount); types = copyArgs(types); Class targetClass = (Class) types[0]; Class[] targetParameters = new Class[parameterCount]; System.arraycopy(types, 1, targetParameters, 0, parameterCount); Method targetMethod = targetClass.getMethod(method.getName(), targetParameters); return targetMethod; }
if (theProxy instanceof javax.ejb.EJBObject) { ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHandle(handler.getProxyInfo()); } else if (theProxy instanceof javax.ejb.EJBHome) { ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHomeHandle(handler.getProxyInfo()); } else { throw new RuntimeException("Invalid proxy type. Handles are only supported by EJBObject types in EJB 1.1");
private <T> T copy(final IntraVmCopyMonitor.State strategy, final T object) throws IOException, ClassNotFoundException { if (object == null || !strategy.isCopy()) { return object; } IntraVmCopyMonitor.pre(strategy); try { return copyObj(object); } finally { IntraVmCopyMonitor.post(); } }
if (theProxy instanceof EJBObject) { final ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHandle(handler.getProxyInfo()); } else if (theProxy instanceof EJBHome) { final ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHomeHandle(handler.getProxyInfo()); } else { throw new OpenEJBRuntimeException("Invalid proxy type. Handles are only supported by EJBObject types in EJB 1.1");
private <T> T copy(final IntraVmCopyMonitor.State strategy, final T object) throws IOException, ClassNotFoundException { if (object == null || !strategy.isCopy()) { return object; } IntraVmCopyMonitor.pre(strategy); try { return copyObj(object); } finally { IntraVmCopyMonitor.post(); } }
if (theProxy instanceof EJBObject) { final ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHandle(handler.getProxyInfo()); } else if (theProxy instanceof EJBHome) { final ApplicationServer applicationServer = ServerFederation.getApplicationServer(); return applicationServer.getHomeHandle(handler.getProxyInfo()); } else { throw new OpenEJBRuntimeException("Invalid proxy type. Handles are only supported by EJBObject types in EJB 1.1");