Changeset 30068

Show
Ignore:
Timestamp:
02/12/08 14:52:01 (9 months ago)
Author:
bstefanescu
Message:

aligned branch to trunk - merged autoncf and http evolutions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/AbstractRuntimeService.java

    r28508 r30068  
    6565    } 
    6666 
     67    // warnings during the deployment. Here are collected all errors occured during the startup 
     68    protected final List<String> warnings = new ArrayList<String>(); 
     69 
     70 
    6771    protected AbstractRuntimeService(DefaultRuntimeContext context, 
    6872            Map<String, String> properties) { 
     
    7276            this.properties.putAll(properties); 
    7377        } 
     78    } 
     79 
     80    /** 
     81     * @return the warnings. 
     82     */ 
     83    public List<String> getWarnings() { 
     84        return warnings; 
    7485    } 
    7586 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/RuntimeService.java

    r25241 r30068  
    2121 
    2222import java.io.File; 
     23import java.util.List; 
    2324import java.util.Properties; 
    2425 
     
    191192    <T> T getService(Class<T> serviceClass); 
    192193 
     194    /** 
     195     * Get a list of startup warnings. 
     196     * Can be modified to add new warnings 
     197     * @return the warning list 
     198     */ 
     199    List<String> getWarnings(); 
     200 
    193201} 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/Version.java

    r23049 r30068  
    2828 * @author  <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 
    2929 */ 
    30 public class Version implements Serializable
     30public class Version implements Serializable, Comparable<Version>
    3131 
    3232    public static final Version ZERO = new Version(0, 0, 0); 
     33    public static final Version MIN = ZERO; 
     34    public static final Version MAX = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); 
    3335 
    3436    private static final long serialVersionUID = 4287621413157054503L; 
     
    127129     * @return if the current version is equal to the given one, false otherwise 
    128130     */ 
    129     private boolean isEqualTo(Version version) { 
     131    public boolean isEqualTo(Version version) { 
    130132        return major == version.major 
    131133            && minor == version.minor 
     
    189191    } 
    190192 
     193    public int compareTo(Version v) { 
     194        if (v == null) return -1; 
     195        if (isEqualTo(v)) { 
     196            return 0; 
     197        } else { 
     198            return isGreaterThan(v) ? 1 : 0; 
     199        } 
     200    } 
     201 
    191202} 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/JBossServiceLocator.java

    r28980 r30068  
    2222import java.util.Properties; 
    2323 
     24import javax.naming.Context; 
    2425import javax.naming.InitialContext; 
    2526 
     
    3031public class JBossServiceLocator extends JndiServiceLocator { 
    3132 
    32     private String prefix
     33    private static final long serialVersionUID = -5691359964790311122L
    3334 
    34     private String suffix; 
     35    private String prefix = ""; 
     36 
     37    private String suffix = ""; 
    3538 
    3639    @Override 
    3740    public void initialize(String host, int port, Properties properties) 
    3841            throws Exception { 
     42        if (port == 0) port = 1099; 
    3943        if (properties != null) { 
    4044            prefix = properties.getProperty("prefix", "nuxeo/"); 
    4145            suffix = properties.getProperty("suffix", "/remote"); 
    42         } else { 
    43             properties = new Properties(); 
    44             properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 
    45             properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); 
    46         } 
    47         if (host != null) { // overwrite default values (or those specified through properties) 
    48             String uri = "jnp://" + host + ':' + (port == 0 ? 1099 : port); 
    49             properties.put("java.naming.provider.url", uri); 
     46            // these properties are set only by the client autonficonguration system if needed 
     47            String value = properties.getProperty(Context.PROVIDER_URL); 
     48            if (value != null) { 
     49                value = String.format(value, host, port); 
     50                properties.put(Context.PROVIDER_URL, value); 
     51            } 
    5052        } 
    5153        context = new InitialContext(properties); 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/JndiServiceLocator.java

    r28349 r30068  
    3030public abstract class JndiServiceLocator implements ServiceLocator { 
    3131 
    32     protected InitialContext context; 
     32    protected transient InitialContext context; 
    3333 
    3434    /** 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/RuntimeServiceLocator.java

    r28583 r30068  
    3131public class RuntimeServiceLocator implements ServiceLocator { 
    3232 
     33    private static final long serialVersionUID = -3550824536420353831L; 
     34 
    3335    public void initialize(String host, int port, Properties properties) 
    3436            throws Exception { 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/ServiceAdapter.java

    r19772 r30068  
    2020package org.nuxeo.runtime.api; 
    2121 
     22import java.io.Serializable; 
     23 
    2224/** 
    2325 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 
    2426 * 
    2527 */ 
    26 public interface ServiceAdapter
     28public interface ServiceAdapter extends Serializable
    2729 
    2830    Object adapt(ServiceDescriptor svc, Object service) throws Exception; 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/ServiceDescriptor.java

    r28169 r30068  
    2020package org.nuxeo.runtime.api; 
    2121 
     22import java.io.Serializable; 
     23 
    2224import org.nuxeo.common.xmap.annotation.XNode; 
    2325import org.nuxeo.common.xmap.annotation.XObject; 
     
    2830 */ 
    2931@XObject(value = "service", order = { "serviceClass", "name" }) 
    30 public class ServiceDescriptor { 
     32public class ServiceDescriptor implements Serializable{ 
     33 
     34 
     35    private static final long serialVersionUID = 5490362136607217161L; 
    3136 
    3237    @XNode("@name") 
     
    3540    private String serviceClassName; 
    3641 
    37     private Class<?> serviceClass; 
     42    // this should not be loaded when sending service descriptors to a client because 
     43    // the class may not exists on the client. the class should be loaded only if the client explicitelly 
     44    // lookup the service 
     45    private transient Class<?> serviceClass; 
     46 
    3847 
    3948    @XNode("@class") 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/ServiceGroup.java

    r28515 r30068  
    2020package org.nuxeo.runtime.api; 
    2121 
     22import java.io.Serializable; 
     23 
    2224/** 
    2325 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 
    2426 * 
    2527 */ 
    26 public class ServiceGroup { 
     28public class ServiceGroup implements Serializable { 
     29 
     30    private static final long serialVersionUID = -206692130381710767L; 
    2731 
    2832    private final String name; 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/ServiceHost.java

    r28349 r30068  
    2020package org.nuxeo.runtime.api; 
    2121 
     22import java.io.IOException; 
     23import java.io.ObjectInputStream; 
     24import java.io.ObjectOutputStream; 
     25import java.io.Serializable; 
    2226import java.util.Map; 
    2327import java.util.Properties; 
     
    3337 */ 
    3438@XObject("server") 
    35 public class ServiceHost { 
     39public class ServiceHost implements Serializable { 
     40 
     41    private static final long serialVersionUID = 632838284857927463L; 
    3642 
    3743    public static final ServiceHost LOCAL_SERVER = new ServiceHost(RuntimeServiceLocator.class); 
     
    4955 
    5056 
    51     private ServiceGroup[] groups; 
    52  
    53     private ServiceLocator serviceLocator; 
     57    private transient ServiceGroup[] groups; 
     58 
     59    private transient ServiceLocator serviceLocator; 
    5460 
    5561 
     
    196202    } 
    197203 
     204 
     205    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 
     206        in.defaultReadObject(); 
     207        int len = in.readInt(); 
     208        String[] ar = new String[len]; 
     209        for (int i=0; i<len; i++) { 
     210            ar[i] = (String)in.readObject(); 
     211        } 
     212        setGroups(ar); 
     213    } 
     214 
     215    private void writeObject(ObjectOutputStream out) throws IOException { 
     216        out.defaultWriteObject(); 
     217        if (groups != null) { 
     218            out.writeInt(groups.length); 
     219            for (ServiceGroup group : groups) { 
     220                out.writeObject(group.getName()); 
     221            } 
     222        } else { 
     223            out.writeInt(0); 
     224        } 
     225    } 
     226 
    198227} 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/ServiceLocator.java

    r24983 r30068  
    3030 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 
    3131 */ 
    32 public interface ServiceLocator
     32public interface ServiceLocator extends java.io.Serializable
    3333 
    3434    /** 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/config/Configuration.java

    r28349 r30068  
    214214    } 
    215215 
    216     private void load(Server server, String host, String serverLocator) 
     216    void load(Server server, String host, String serverLocator) 
    217217            throws Exception { 
    218218 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/osgi/OSGiRuntimeService.java

    r28169 r30068  
    7070    private final Map<Bundle, RuntimeContext> contexts; 
    7171 
    72     // warnings during the deployment. Here are collected all errors occured during the startup 
    73     private final List<String> warnings = new ArrayList<String>(); 
    7472 
    7573 
     
    116114    public synchronized RuntimeContext getContext(Bundle bundle) { 
    117115        return contexts.get(bundle); 
    118     } 
    119  
    120     /** 
    121      * @return the warnings. 
    122      */ 
    123     public List<String> getWarnings() { 
    124         return warnings; 
    125116    } 
    126117 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/remoting/RemotingService.java

    r28349 r30068  
    2020package org.nuxeo.runtime.remoting; 
    2121 
     22import java.util.Properties; 
     23 
     24import javax.management.MBeanServer; 
     25import javax.management.MBeanServerFactory; 
     26import javax.management.ObjectName; 
     27 
    2228import org.jboss.remoting.InvokerLocator; 
    2329import org.jboss.remoting.marshal.MarshalFactory; 
    2430import org.jboss.remoting.marshal.serializable.SerializableMarshaller; 
    2531import org.nuxeo.runtime.api.Framework; 
     32import org.nuxeo.runtime.config.AutoConfigurationService; 
     33import org.nuxeo.runtime.config.ConfigurationFactory; 
     34import org.nuxeo.runtime.config.v1.ConfigurationFactory1; 
    2635import org.nuxeo.runtime.model.ComponentContext; 
    2736import org.nuxeo.runtime.model.ComponentName; 
     
    3746public class RemotingService extends DefaultComponent { 
    3847 
     48    public final static String INVOKER_NAME = "nx:service=invoker,name=remoting"; 
     49 
    3950    public static final ComponentName NAME = new ComponentName( 
    4051            "org.nuxeo.runtime.remoting.RemotingService"); 
    4152 
    42     public static final String DEFAULT_LOCATOR = "socket://0.0.0.0:62474/";//?datatype=nuxeo"; 
     53    public static final String DEFAULT_LOCATOR = "socket://0.0.0.0:62474/?datatype=nuxeo"; 
    4354 
    4455    private TransporterServer transporterServer; 
     
    5061    private InvokerLocator serverLocator; 
    5162 
    52     public static Server connect(String locatorURI) throws Exception { 
    53         return (Server) TransporterClient.createTransporterClient( 
    54                 new InvokerLocator(locatorURI), Server.class); 
     63    public static final Server connect(String locatorURI) throws Exception { 
     64        return (Server) TransporterClient.createTransporterClient(new InvokerLocator(locatorURI), Server.class); 
    5565    } 
    5666 
     
    6272     * @return the server object 
    6373     */ 
    64     public static Server connect(String host, int port) throws Exception { 
     74    public static final Server connect(String host, int port) throws Exception { 
    6575        return connect(getServerURI(host, port)); 
    6676    } 
     
    7181     * @param server 
    7282     */ 
    73     public static void disconnect(Server server) { 
     83    public static final void disconnect(Server server) { 
    7484        TransporterClient.destroyTransporterClient(server); 
    7585    } 
    7686 
    77     public static String getServerURI(String host, int port) { 
    78         return "socket://" + host + ':' + port + '/';//?datatype=nuxeo"; 
     87    /** 
     88     * 
     89     * @param host 
     90     * @param port 
     91     * @return 
     92     * 
     93     * @deprecated must be removed since from runtime 1.5.1 the invoker protocol may be configurable 
     94     */ 
     95    public static final String getServerURI(String host, int port) { 
     96        return "socket://" + host + ":" + port+"/?datatype=nuxeo"; 
    7997    } 
    8098 
     
    83101     * 
    84102     * @return the product info if successful, null otherwise 
     103     * @deprecated should no more be used - use instead {@link AutoConfigurationService} 
    85104     */ 
    86105    public static String ping(String host, int port) { 
     
    99118    @Override 
    100119    public void activate(ComponentContext context) throws Exception { 
     120        // register the configuration handlers 
     121        ConfigurationFactory.registerFactory(new ConfigurationFactory1()); 
     122        // register the marshaller 
     123        MarshalFactory.addMarshaller("nuxeo", new SerializableMarshaller(), new NuxeoUnMarshaller()); 
     124        // startup server if needed 
    101125        String val = Framework.getProperty("org.nuxeo.runtime.server.enabled", "true"); 
    102126        isServer = val.equalsIgnoreCase("true"); 
    103127        if (isServer) { 
    104             String locator = Framework.getProperty( 
    105                     "org.nuxeo.runtime.server.locator", DEFAULT_LOCATOR); 
     128            String locator = Framework.getProperty("org.nuxeo.runtime.server.locator", DEFAULT_LOCATOR); 
    106129            serverLocator = new InvokerLocator(locator); 
    107             MarshalFactory.addMarshaller( 
    108                     "nuxeo", new SerializableMarshaller(), new NuxeoUnMarshaller()); 
    109130            server = new ServerImpl(this, context.getRuntimeContext().getRuntime()); 
    110131            transporterServer = TransporterServer.createTransporterServer( 
    111132                    serverLocator, server, Server.class.getName()); 
     133 
     134            //TODO: the current version of jboss remoting doesn't support 
     135            // locatorUrl on the servlet impl. - see docs 
     136            // when this will be supported ignore regitsering the mbean and use locatorUrl to retrieve the invoker 
     137            // (this aproach is more portable) 
     138            MBeanServer mb = (MBeanServer)MBeanServerFactory.findMBeanServer(null).iterator().next(); 
     139            if (mb != null) { 
     140                mb.registerMBean(transporterServer.getConnector().getServerInvoker(), 
     141                        new ObjectName(INVOKER_NAME)); 
     142            } 
    112143        } 
    113144    } 
     
    140171    } 
    141172 
     173 
     174 
     175    public static void main(String[] args) { 
     176        try { 
     177            Server server = connect("servlet://localhost:8080/nuxeo/ServerInvokerServlet"); 
     178            Properties props = server.getProperties(); 
     179            System.out.println(props); 
     180        } catch (Exception e) { 
     181 
     182        } 
     183    } 
     184 
    142185} 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/remoting/Server.java

    r27183 r30068  
    2626import javax.security.auth.login.AppConfigurationEntry; 
    2727 
     28import org.jboss.remoting.InvokerLocator; 
     29import org.nuxeo.runtime.Version; 
    2830import org.nuxeo.runtime.api.login.SecurityDomain; 
     31import org.nuxeo.runtime.config.ConfigurationException; 
     32import org.nuxeo.runtime.config.ServerConfiguration; 
    2933import org.nuxeo.runtime.model.ComponentInstance; 
    3034import org.nuxeo.runtime.model.ComponentName; 
     
    3741public interface  Server { 
    3842 
     43    ServerConfiguration  getConfiguration(InvokerLocator locator, Version version) throws ConfigurationException, UnsupportedServerVersion; 
    3944 
    4045    String getName(); 
    41  
    4246 
    4347    String getDescription(); 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/remoting/ServerImpl.java

    r28172 r30068  
    3333import org.apache.commons.logging.Log; 
    3434import org.apache.commons.logging.LogFactory; 
     35import org.jboss.remoting.InvokerLocator; 
    3536import org.jboss.remoting.loading.ClassUtil; 
    3637import org.nuxeo.common.utils.FileUtils; 
    3738import org.nuxeo.runtime.RuntimeService; 
     39import org.nuxeo.runtime.Version; 
    3840import org.nuxeo.runtime.api.Framework; 
    3941import org.nuxeo.runtime.api.ServiceDescriptor; 
     
    4345import org.nuxeo.runtime.api.login.LoginService; 
    4446import org.nuxeo.runtime.api.login.SecurityDomain; 
     47import org.nuxeo.runtime.config.ConfigurationException; 
     48import org.nuxeo.runtime.config.ConfigurationFactory; 
     49import org.nuxeo.runtime.config.ServerConfiguration; 
    4550import org.nuxeo.runtime.model.ComponentInstance; 
    4651import org.nuxeo.runtime.model.ComponentName; 
     
    199204    } 
    200205 
     206    public ServerConfiguration getConfiguration(InvokerLocator locator, Version version) throws ConfigurationException, UnsupportedServerVersion { 
     207        ConfigurationFactory factory = ConfigurationFactory.getFactory(version); 
     208        return factory.createConfiguration(locator, version); 
     209    } 
     210 
    201211    public void contributeExtension(Extension extension, String xmlContent) throws Exception { 
    202212//        ComponentManagerImpl mgr = (ComponentManagerImpl)runtime.getComponentManager(); 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/remoting/transporter/TransporterServer.java

    r24983 r30068  
    6363        ServerInvocationHandler handler = new TransporterHandler(target); 
    6464        connector.addInvocationHandler(subsystem, handler); 
     65    } 
     66 
     67    /** 
     68     * @return the connector. 
     69     */ 
     70    public Connector getConnector() { 
     71        return connector; 
    6572    } 
    6673 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/java/org/nuxeo/runtime/services/streaming/StreamingService.java

    r28012 r30068  
    2222import java.io.File; 
    2323 
     24import org.apache.commons.logging.Log; 
     25import org.apache.commons.logging.LogFactory; 
    2426import org.nuxeo.runtime.api.Framework; 
    2527import org.nuxeo.runtime.model.ComponentContext; 
     
    3537 */ 
    3638public class StreamingService extends DefaultComponent{ 
     39 
     40    private final static Log log = LogFactory.getLog(StreamingService.class); 
    3741 
    3842    public static final ComponentName NAME = new ComponentName("org.nuxeo.runtime.streaming"); 
     
    115119            throw new IllegalStateException("StreamingManager is already started"); 
    116120        } 
    117         if (serverLocator == null) { 
    118             throw new IllegalArgumentException( 
    119                     "serverLocator must not be null when defining a StreamingService"); 
    120         } 
    121121 
    122122        if (isServer) { 
     
    131131            manager = new StreamManagerServer(transporterServer, tmpDir); 
    132132            serverLocator = transporterServer.getLocatorURI(); 
     133        } else if (serverLocator == null) { 
     134            String msg = "Streaming Server Locator is not defined. Streaming will not work."; 
     135            log.warn(msg); 
     136            Framework.getRuntime().getWarnings().add(msg); 
    133137        } else { 
    134138            int minBufSize = (Integer) context.getPropertyValue("minBufferSize", 1024*8); 
     
    136140            manager = new StreamManagerClient(serverLocator, minBufSize, maxBufSize); 
    137141        } 
    138         manager.start(); 
     142        if (manager != null) { 
     143            manager.start(); 
     144        } 
    139145    } 
    140146 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/resources/META-INF/MANIFEST.MF

    r29592 r30068  
    1010 org.nuxeo.runtime.api, 
    1111 org.nuxeo.runtime.api.login, 
     12 org.nuxeo.runtime.config, 
     13 org.nuxeo.runtime.config.v1, 
     14 org.nuxeo.runtime.detection, 
    1215 org.nuxeo.runtime.expression, 
    1316 org.nuxeo.runtime.model, 
     
    2528 org.nuxeo.runtime.services.streaming, 
    2629 org.nuxeo.runtime.streaming, 
    27  org.nuxeo.runtime.config, 
    2830 org.nuxeo.runtime.util 
    2931Bundle-ClassPath: ., 
  • org.nuxeo.runtime/branches/1.4/nuxeo-runtime/src/main/resources/OSGI-INF/RemotingService.xml

    r27975 r30068  
    99  <implementation class="org.nuxeo.runtime.remoting.RemotingService"/> 
    1010 
     11  <service> 
     12    <provide interface="org.nuxeo.runtime.remoting.RemotingService" /> 
     13  </service> 
     14 
    1115</component> 
    1216