Changeset 29693
- Timestamp:
- 01/28/08 08:48:40 (10 months ago)
- Files:
-
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/JBossServiceLocator.java (modified) (2 diffs)
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/ServiceHost.java (modified) (1 diff)
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AbstractServerConfiguration.java (modified) (2 diffs)
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AutoConfigurationService.java (modified) (3 diffs)
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ConfigurationFactory1.java (modified) (4 diffs)
- org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ServerConfiguration1.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/JBossServiceLocator.java
r29016 r29693 33 33 private static final long serialVersionUID = -5691359964790311122L; 34 34 35 private String prefix ;35 private String prefix = ""; 36 36 37 private String suffix ;37 private String suffix = ""; 38 38 39 39 @Override … … 45 45 suffix = properties.getProperty("suffix", "/remote"); 46 46 // these properties are set only by the client autonficonguration system if needed 47 String value = properties.getProperty( "org.nuxeo.autoconfig.jndi.provider.url");47 String value = properties.getProperty(Context.PROVIDER_URL); 48 48 if (value != null) { 49 49 value = String.format(value, host, port); 50 50 properties.put(Context.PROVIDER_URL, value); 51 }52 value = properties.getProperty("org.nuxeo.autoconfig.jndi.factory.initial");53 if (value != null) {54 properties.put(Context.INITIAL_CONTEXT_FACTORY, value);55 }56 value = properties.getProperty("org.nuxeo.autoconfig.jndi.factory.url.pkgs");57 if (value != null) {58 properties.put(Context.URL_PKG_PREFIXES, value);59 51 } 60 52 } org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/ServiceHost.java
r28365 r29693 206 206 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 207 207 in.defaultReadObject(); 208 String[] groups = (String[])in.readObject();209 if (groups != null) {210 setGroups(groups);211 } else {212 this.groups = new ServiceGroup[0];213 }208 int len = in.readInt(); 209 String[] ar = new String[len]; 210 for (int i=0; i<len; i++) { 211 ar[i] = (String)in.readObject(); 212 } 213 setGroups(ar); 214 214 } 215 215 216 216 private void writeObject(ObjectOutputStream out) throws IOException { 217 217 out.defaultWriteObject(); 218 out.writeObject(groups); 218 if (groups != null) { 219 out.writeInt(groups.length); 220 for (ServiceGroup group : groups) { 221 out.writeObject(group.getName()); 222 } 223 } else { 224 out.writeInt(0); 225 } 219 226 } 220 227 org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AbstractServerConfiguration.java
r29659 r29693 33 33 */ 34 34 public abstract class AbstractServerConfiguration implements ServerConfiguration { 35 36 private static final String JNDI_PREFIX = "nuxeo-client-jndi.";37 35 38 36 private static final long serialVersionUID = 1970555604877434479L; … … 138 136 public Properties getJndiProperties() { 139 137 if (jndiProperties == null) { 140 jndiProperties = new Properties(); 141 int prefixLen = JNDI_PREFIX.length(); 142 for (Map.Entry<Object,Object> entry : properties.entrySet()) { 143 String key = entry.getKey().toString(); 144 if (key.startsWith(JNDI_PREFIX)) { 145 jndiProperties.put(key.substring(prefixLen), entry.getValue()); 146 } 147 } 138 jndiProperties = AutoConfigurationService.readJndiProperties(properties); 148 139 } 149 140 return jndiProperties; org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AutoConfigurationService.java
r29658 r29693 21 21 22 22 import java.util.HashMap; 23 import java.util.Map; 24 import java.util.Properties; 23 25 24 26 import org.jboss.remoting.InvokerLocator; … … 85 87 // get the configuration based on the client remoting version and the 86 88 // locator used to access the server 89 clear(); 87 90 config = server.getConfiguration(locator, version); 88 clear();89 91 config.install(); 90 92 } catch (Exception e) { // compatibility code - for runtime that doesn't supports ServerConfiguration … … 113 115 114 116 117 private static final String JNDI_PREFIX = "nuxeo-client-jndi."; 118 119 public static Properties readJndiProperties(Properties properties) { 120 Properties jndiProperties = new Properties(); 121 int prefixLen = JNDI_PREFIX.length(); 122 for (Map.Entry<Object,Object> entry : properties.entrySet()) { 123 String key = entry.getKey().toString(); 124 if (key.startsWith(JNDI_PREFIX)) { 125 jndiProperties.put(key.substring(prefixLen), entry.getValue()); 126 } 127 } 128 return jndiProperties; 129 } 130 115 131 } org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ConfigurationFactory1.java
r29660 r29693 31 31 import org.nuxeo.runtime.api.login.LoginService; 32 32 import org.nuxeo.runtime.api.login.SecurityDomain; 33 import org.nuxeo.runtime.config.AutoConfigurationService; 33 34 import org.nuxeo.runtime.config.ConfigurationException; 34 35 import org.nuxeo.runtime.config.ConfigurationFactory; … … 98 99 for (ServiceHost shost : serviceHosts) { 99 100 String h = shost.getHost(); 101 int p = shost.getPort(); 102 // we need to update jndi props of local server so that the lcient use the right config 100 103 if (h == null) { 101 shost.setAddress(host, 0); // TODO: 1099? 102 // handle automatic config of client JNDI 103 Properties runtimeProps = Framework.getRuntime().getProperties(); 104 Properties props = shost.getProperties(); 105 String value = runtimeProps.getProperty("org.nuxeo.autoconfig.jndi.provider.url"); 106 if (value != null) { 107 props.setProperty("org.nuxeo.autoconfig.jndi.provider.url", value); 108 } 109 value = runtimeProps.getProperty("org.nuxeo.autoconfig.jndi.factory.initial"); 110 if (value != null) { 111 props.setProperty("org.nuxeo.autoconfig.jndi.factory.initial", value); 112 } 113 value = runtimeProps.getProperty("org.nuxeo.autoconfig.jndi.factory.url.pkgs"); 114 if (value != null) { 115 props.setProperty("org.nuxeo.autoconfig.jndi.factory.url.pkgs", value); 116 } 117 // JNDI config ended 104 shost.setAddress(host, p); // TODO: 1099? 105 updateLocalHostJndiProps(shost); 118 106 } else { 119 107 String newHost = ConfigurationHelper.getNormalizedHost(h, host); 120 108 if (newHost != null) { 121 109 shost.setAddress(newHost, shost.getPort()); 110 updateLocalHostJndiProps(shost); 122 111 } 123 112 } … … 125 114 return serviceHosts; 126 115 } 116 117 private void updateLocalHostJndiProps(ServiceHost host) { 118 Properties runtimeProps = Framework.getRuntime().getProperties(); 119 Properties props = AutoConfigurationService.readJndiProperties(runtimeProps); 120 if (!props.isEmpty()) { 121 host.setProperties(props); 122 } 123 } 124 127 125 128 126 public SecurityDomain[] getSecurityDomains() { … … 144 142 145 143 public Properties getJNDIProperties() { 146 // for now JNDI properties are stored in the main properties file using a prefix 147 // of nuxeo-client-jndi. 148 return null; 144 return AutoConfigurationService.readJndiProperties(Framework.getRuntime().getProperties()); 149 145 } 150 146 org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ServerConfiguration1.java
r28365 r29693 76 76 } 77 77 78 // TODO: service/groups management is buggy - when ServiceHost objects are deserialized 79 // the Groups are registered in the current manager!! 80 // service management must be rewriten 78 81 for (ServiceHost sh : hosts) { 79 82 serviceMgr.registerServer(sh);
