1 10 11 package org.mmbase.bridge; 12 13 import java.rmi.*; 14 import java.lang.reflect.*; 15 import java.net.MalformedURLException ; 16 17 19 25 public class RemoteContext { 26 27 36 public static CloudContext getCloudContext(String uri) { 37 try { 38 39 Object remoteCloudContext= Naming.lookup(uri); 40 try { 41 Class clazz = Class.forName("org.mmbase.bridge.remote.implementation.RemoteCloudContext_Impl"); 42 Constructor constr = clazz.getConstructor(new Class [] { Class.forName("org.mmbase.bridge.remote.RemoteCloudContext") }); 43 return (CloudContext) constr.newInstance(new Object [] { remoteCloudContext } ); 44 } catch (ClassNotFoundException e) { 46 return null; 47 } catch (NoSuchMethodException e) { 48 return null; 49 } 50 } catch (MalformedURLException mue) { 51 String message = mue.getMessage(); 52 if (message != null && message.indexOf("no protocol") > -1) { 53 throw new RuntimeException ("This exception maybe occured, because the servlet container is " + 54 "installed in a directory with spaces.\n" + 55 "The java.rmi.server.RMIClassLoader loads classes from network locations " + 56 "(one or more URLS) for marschalling and unmarschalling parameters and return values. " + 57 "The RMIClassLoader uses a codebase where to load the classes. The codebase is a string " + 58 "with URLs separated by spaces.\n" + 59 "Error message: " + mue.getMessage()); 60 } 61 throw new BridgeException("While connecting to " + uri + ": " + mue.getMessage(), mue); 62 } catch (Exception e){ 63 throw new BridgeException("While connecting to " + uri + ": " + e.getMessage(), e); 64 } 65 } 66 public static void main(String [] argv) { 67 getCloudContext(argv[0]); 68 } 69 } 70 | Popular Tags |