1 10 package org.mmbase.bridge; 11 12 18 public class ContextProvider { 19 25 26 public final static String DEFAULT_CLOUD_CONTEXT_NAME = "local"; 27 private static String defaultCloudContextName ; 28 29 43 public static CloudContext getCloudContext(String uri) { 44 if (uri == null || (uri != null && uri.trim().length() == 0)){ 45 uri = getDefaultCloudContextName(); 46 } 47 48 if (uri.startsWith("rmi")){ 49 return RemoteContext.getCloudContext(uri); 50 } else if (uri.startsWith("local")){ 51 return LocalContext.getCloudContext(); 52 } 53 throw new BridgeException("cloudcontext with name {" + uri + "} is not known to MMBase"); 54 } 55 56 60 public static String getDefaultCloudContextName() { 61 if (defaultCloudContextName == null) { 63 defaultCloudContextName = System.getProperty("mmbase.defaultcloudcontext"); 64 } 65 if (defaultCloudContextName == null) { 66 defaultCloudContextName = DEFAULT_CLOUD_CONTEXT_NAME; 67 } 68 return defaultCloudContextName; 69 } 70 71 76 public static CloudContext getDefaultCloudContext() { 77 String uri = System.getProperty("mmbase.defaultcloudcontext"); 78 if (uri != null) { 79 return getCloudContext(uri); 80 } 81 82 try { 83 return getCloudContext(getDefaultCloudContextName()); 84 } catch (NotFoundException nfe) { 85 return getCloudContext("rmi://127.0.0.1:1111/remotecontext"); 86 } catch (BridgeException be) { 87 throw new BridgeException(be.getMessage() + " You may want to specify -Dmmbase.defaultcloudcontext=<URI>", be); 88 } 89 } 90 91 } 92 | Popular Tags |