Changeset 29693

Show
Ignore:
Timestamp:
01/28/08 08:48:40 (10 months ago)
Author:
bstefanescu
Message:

working on autoconfig

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/JBossServiceLocator.java

    r29016 r29693  
    3333    private static final long serialVersionUID = -5691359964790311122L; 
    3434 
    35     private String prefix
     35    private String prefix = ""
    3636 
    37     private String suffix
     37    private String suffix = ""
    3838 
    3939    @Override 
     
    4545            suffix = properties.getProperty("suffix", "/remote"); 
    4646            // 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); 
    4848            if (value != null) { 
    4949                value = String.format(value, host, port); 
    5050                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); 
    5951            } 
    6052        } 
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/api/ServiceHost.java

    r28365 r29693  
    206206    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 
    207207        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); 
    214214    } 
    215215 
    216216    private void writeObject(ObjectOutputStream out) throws IOException { 
    217217        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        } 
    219226    } 
    220227 
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AbstractServerConfiguration.java

    r29659 r29693  
    3333 */ 
    3434public abstract class AbstractServerConfiguration implements ServerConfiguration { 
    35  
    36     private static final String  JNDI_PREFIX = "nuxeo-client-jndi."; 
    3735 
    3836    private static final long serialVersionUID = 1970555604877434479L; 
     
    138136    public Properties getJndiProperties() { 
    139137        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); 
    148139        } 
    149140        return jndiProperties; 
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/AutoConfigurationService.java

    r29658 r29693  
    2121 
    2222import java.util.HashMap; 
     23import java.util.Map; 
     24import java.util.Properties; 
    2325 
    2426import org.jboss.remoting.InvokerLocator; 
     
    8587                // get the configuration based on the client remoting version and the 
    8688                // locator used to access the server 
     89                clear(); 
    8790                config = server.getConfiguration(locator, version); 
    88                 clear(); 
    8991                config.install(); 
    9092            } catch (Exception e) { // compatibility code - for runtime that doesn't supports ServerConfiguration 
     
    113115 
    114116 
     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 
    115131} 
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ConfigurationFactory1.java

    r29660 r29693  
    3131import org.nuxeo.runtime.api.login.LoginService; 
    3232import org.nuxeo.runtime.api.login.SecurityDomain; 
     33import org.nuxeo.runtime.config.AutoConfigurationService; 
    3334import org.nuxeo.runtime.config.ConfigurationException; 
    3435import org.nuxeo.runtime.config.ConfigurationFactory; 
     
    9899        for (ServiceHost shost : serviceHosts) { 
    99100            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 
    100103            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); 
    118106            } else { 
    119107                String newHost = ConfigurationHelper.getNormalizedHost(h, host); 
    120108                if (newHost != null) { 
    121109                    shost.setAddress(newHost, shost.getPort()); 
     110                    updateLocalHostJndiProps(shost); 
    122111                } 
    123112            } 
     
    125114        return serviceHosts; 
    126115    } 
     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 
    127125 
    128126    public SecurityDomain[]  getSecurityDomains() { 
     
    144142 
    145143    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()); 
    149145    } 
    150146 
  • org.nuxeo.runtime/branches/autoconfig/src/main/java/org/nuxeo/runtime/config/v1/ServerConfiguration1.java

    r28365 r29693  
    7676        } 
    7777 
     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 
    7881        for (ServiceHost sh : hosts) { 
    7982            serviceMgr.registerServer(sh);