tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r628927 - in /openejb/trunk/openejb3/server: openejb-http/src/main/java/org/apache/openejb/server/httpd/ openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/ openejb-server/src/main/java/org/apache/openejb/server/
Date Mon, 18 Feb 2008 23:58:01 GMT
Author: dblevins
Date: Mon Feb 18 15:57:54 2008
New Revision: 628927

URL: http://svn.apache.org/viewvc?rev=628927&view=rev
Log:
Implemented feature to allow ServerServices to have factory methods

Added:
    openejb/trunk/openejb3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpServerFactory.java
Modified:
    openejb/trunk/openejb3/server/openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/httpejbd
    openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java

Added: openejb/trunk/openejb3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpServerFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpServerFactory.java?rev=628927&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpServerFactory.java
(added)
+++ openejb/trunk/openejb3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpServerFactory.java
Mon Feb 18 15:57:54 2008
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.server.httpd;
+
+import org.apache.openejb.server.ServerService;
+
+public class HttpServerFactory {
+
+    public static ServerService createServerService() {
+        return new OpenEJBHttpEjbServer();
+    }
+}

Modified: openejb/trunk/openejb3/server/openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/httpejbd
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/httpejbd?rev=628927&r1=628926&r2=628927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/httpejbd
(original)
+++ openejb/trunk/openejb3/server/openejb-http/src/main/resources/META-INF/org.apache.openejb.server.ServerService/httpejbd
Mon Feb 18 15:57:54 2008
@@ -18,7 +18,7 @@
 # $Rev$ $Date$
 #
 
-server      = org.apache.openejb.server.httpd.OpenEJBHttpEjbServer
+server      = org.apache.openejb.server.httpd.HttpServerFactory
 bind        = 127.0.0.1
 port        = 4204
 disabled    = false

Modified: openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java?rev=628927&r1=628926&r2=628927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
(original)
+++ openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
Mon Feb 18 15:57:54 2008
@@ -25,6 +25,9 @@
 import org.apache.openejb.assembler.classic.ServiceInfo;
 import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
 import org.apache.xbean.finder.ResourceFinder;
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+import org.apache.xbean.recipe.MissingFactoryMethodException;
 
 import javax.naming.NamingException;
 import javax.naming.Binding;
@@ -40,6 +43,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -67,7 +71,7 @@
         return manager;
     }
 
-    // Have properties files (like xinet.d) that specifies what daemons to 
+    // Have properties files (like xinet.d) that specifies what daemons to
     // Look into the xinet.d file structure again
     // conf/server.d/
     //    admin.properties
@@ -116,11 +120,6 @@
 
                 Class impl = classLoader.loadClass(className);
 
-                if (!interfase.isAssignableFrom(impl)) {
-                    services.remove(name);
-                    continue;
-                }
-
                 properties.put(interfase, impl);
                 String rawProperties = resourceFinder.findString(interfase.getName() + "/"
+ name);
                 properties.put(Properties.class, rawProperties);
@@ -149,6 +148,8 @@
             String serviceName = (String) entry.getKey();
             Properties serviceProperties = (Properties) entry.getValue();
 
+            logger.debug("Processing ServerService(id="+serviceName+")");
+
             overrideProperties(serviceName, serviceProperties);
             serviceProperties.setProperty("name", serviceName);
 
@@ -162,28 +163,46 @@
             }
 
 
-            if (isEnabled(serviceProperties)) {
 
-                // Create Service
-                ServerService service = null;
+            boolean enabled = isEnabled(serviceProperties);
+
+            logger.debug("Found ServerService(id=" + serviceName + ", disabled=" + (!enabled)
+ ")");
+
+            if (enabled) {
 
                 Class serviceClass = (Class) serviceProperties.get(ServerService.class);
 
+                logger.debug("Creating ServerService(id=" + serviceName + ")");
+
                 try {
-                    service = (ServerService) serviceClass.newInstance();
-                } catch (Throwable t) {
-                    String msg1 = messages.format("service.instantiation.err", serviceClass.getName(),
t.getClass().getName(), t.getMessage());
-                    throw new ServiceException(msg1, t);
-                }
+                    // Create Service
+                    ServerService service = null;
 
-                if (!(service instanceof SelfManaging)) {
-                    service = new ServiceLogger(service);
-                    service = new ServiceAccessController(service);
-                    service = new ServiceDaemon(service);
-                }
 
-                service.init(serviceProperties);
-                enabledServers.add(service);
+                    ObjectRecipe recipe = new ObjectRecipe(serviceClass);
+                    try {
+                        if (recipe.findFactoryMethod(serviceClass, "createServerService")
!= null){
+                            recipe = new ObjectRecipe(serviceClass, "createServerService");
+                        }
+                    } catch (MissingFactoryMethodException e) {
+                    }
+
+                    recipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
+                    recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+
+                    service = (ServerService) recipe.create(serviceClass.getClassLoader());
+
+                    if (!(service instanceof SelfManaging)) {
+                        service = new ServiceLogger(service);
+                        service = new ServiceAccessController(service);
+                        service = new ServiceDaemon(service);
+                    }
+
+                    service.init(serviceProperties);
+                    enabledServers.add(service);
+                } catch (Throwable t) {
+                    logger.error("service.instantiation.err", t, serviceClass.getName(),
t.getClass().getName(), t.getMessage());
+                }
             }
 
         }
@@ -274,7 +293,7 @@
             System.out.println("Ready!");
         }
         if (!block) return;
-        
+
         /*
         * This will cause the user thread (the thread that keeps the
         *  vm alive) to go into a state of constant waiting.



Mime
View raw message