1 9 package org.jboss.remoting; 10 11 import java.util.HashMap ; 12 import java.util.Map ; 13 import org.jboss.logging.Logger; 14 import org.jboss.remoting.loading.ClassByteClassLoader; 15 import org.jboss.remoting.marshal.MarshallLoaderFactory; 16 17 25 public abstract class AbstractInvoker implements Invoker 26 { 27 protected final Logger log = Logger.getLogger(getClass()); 28 protected ClassByteClassLoader classbyteloader; 29 protected InvokerLocator locator; 30 protected Map localServerLocators = new HashMap (); 31 32 public AbstractInvoker(InvokerLocator locator) 33 { 34 this.classbyteloader = new ClassByteClassLoader(this.getClass().getClassLoader()); 35 this.locator = locator; 36 37 try 38 { 39 InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator); 40 if(loaderLocator != null) 41 { 42 classbyteloader.setClientInvoker(new Client(loaderLocator)); 43 } 44 } 45 catch(Exception e) 46 { 47 log.error("Could not create remote class loading for invoker.", e); 48 } 49 } 50 51 56 public InvokerLocator getLocator() 57 { 58 return locator; 59 } 60 61 66 public void addClientLocator(String listenerId, InvokerLocator locator) 67 { 68 Object obj = localServerLocators.put(listenerId, locator); 69 if(obj != null) 70 { 71 throw new RuntimeException ("InvokerLocator already exists for listener id " + listenerId + ". " + 72 "Remove this listener before adding again."); 73 } 74 } 75 76 82 public InvokerLocator getClientLocator(String listenerId) 83 { 84 return (InvokerLocator) localServerLocators.get(listenerId); 85 } 86 87 92 public synchronized void setClassLoader(ClassLoader classloader) 93 { 94 this.classbyteloader = new ClassByteClassLoader(classloader); 95 } 96 97 public synchronized ClassLoader getClassLoader() 98 { 99 return classbyteloader; 100 } 101 102 } 103 | Popular Tags |