1 22 package org.jboss.aspects.remoting; 23 24 import org.jboss.aop.Dispatcher; 25 import org.jboss.aop.InstanceAdvised; 26 import org.jboss.aop.InstanceAdvisor; 27 import org.jboss.aop.advice.Interceptor; 28 import org.jboss.aop.proxy.ClassProxy; 29 import org.jboss.aop.proxy.ClassProxyFactory; 30 import org.jboss.aop.util.PayloadKey; 31 import org.jboss.aspects.security.SecurityClientInterceptor; 32 import org.jboss.aspects.tx.ClientTxPropagationInterceptor; 33 import org.jboss.remoting.InvokerLocator; 34 35 import java.lang.reflect.Proxy ; 36 37 41 42 public class Remoting 43 { 44 public static ClassProxy createRemoteProxy(Object objectId, Class clazz, String uri) 45 throws Exception ![JavaDoc](../../../../../cmn/javadoc.gif) 46 { 47 return createRemoteProxy(objectId, clazz, new InvokerLocator(uri)); 48 } 49 50 public static ClassProxy createRemoteProxy(Object objectId, Class clazz, InvokerLocator locator) 51 throws Exception ![JavaDoc](../../../../../cmn/javadoc.gif) 52 { 53 ClassProxy proxy = ClassProxyFactory.newInstance(clazz); 54 makeRemotable(proxy, locator, objectId); 55 56 return proxy; 57 } 58 59 60 68 public static Object createPojiProxy(Object oid, Class [] interfaces, String uri) throws Exception ![JavaDoc](../../../../../cmn/javadoc.gif) 69 { 70 InvokerLocator locator = new InvokerLocator(uri); 71 Interceptor[] interceptors = {IsLocalInterceptor.singleton, InvokeRemoteInterceptor.singleton}; 72 PojiProxy proxy = new PojiProxy(oid, locator, interceptors); 73 return Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, proxy); 74 75 } 76 77 public static void makeRemotable(InstanceAdvised proxy, InvokerLocator locator, Object objectId) 78 { 79 InstanceAdvisor advisor = proxy._getInstanceAdvisor(); 80 advisor.insertInterceptor(IsLocalInterceptor.singleton); 81 advisor.insertInterceptor(SecurityClientInterceptor.singleton); 82 advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton); 83 advisor.insertInterceptor(MergeMetaDataInterceptor.singleton); 84 advisor.insertInterceptor(InvokeRemoteInterceptor.singleton); 85 advisor.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, 86 InvokeRemoteInterceptor.INVOKER_LOCATOR, 87 locator, 88 PayloadKey.AS_IS); 89 advisor.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, 90 InvokeRemoteInterceptor.SUBSYSTEM, 91 "AOP", 92 PayloadKey.AS_IS); 93 94 advisor.getMetaData().addMetaData(Dispatcher.DISPATCHER, 95 Dispatcher.OID, 96 objectId, 97 PayloadKey.AS_IS); 98 } 99 100 101 } 102 | Popular Tags |