Home » openejb-3.1.2-src » org.apache » openejb » server » [javadoc | source]

    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.openejb.server;
   18   
   19   import java.io.File;
   20   import java.io.IOException;
   21   import java.net.URI;
   22   import java.util.Properties;
   23   
   24   import org.apache.openejb.OpenEJB;
   25   import org.apache.openejb.core.ServerFederation;
   26   import org.apache.openejb.loader.SystemInstance;
   27   import org.apache.openejb.spi.Service;
   28   import org.apache.openejb.util.PropertiesService;
   29   
   30   /**
   31    * @org.apache.xbean.XBean element="server"
   32    *   description="OpenEJB Server"
   33    *
   34    * @version $Rev: 576056 $ $Date: 2007-09-16 00:14:42 -0700 (Sun, 16 Sep 2007) $
   35    */
   36   public class Server implements Service {
   37       // FIXME: Remove it completely once we ensure PropertiesService (below) works well
   38       Properties props;
   39       
   40       private PropertiesService propertiesService;
   41   
   42       static Server server;
   43       private ServiceManager manager;
   44   
   45       public static Server getServer() {
   46           if (server == null) {
   47               server = new Server();
   48           }
   49   
   50           return server;
   51       }
   52   
   53       // TODO: Remove it once init() suits our (initialisation) needs 
   54       public void init(Properties props) throws Exception {
   55           this.props = props;
   56   
   57           SystemInstance system = SystemInstance.get();
   58           File home = system.getHome().getDirectory();
   59           system.setProperty("openejb.deployments.classpath.include", ".*/"+home.getName()+"/lib/.*");
   60           system.setProperty("openejb.deployments.classpath.require.descriptor", "true");
   61           system.setProperty("openejb.deployments.classpath.filter.systemapps", "false");
   62   
   63           OpenEJB.init(props, new ServerFederation());
   64   
   65           if (System.getProperty("openejb.nobanner") == null) {
   66               System.out.println("[init] OpenEJB Remote Server");
   67           }
   68   
   69           if (manager == null){
   70               manager = ServiceManager.getManager();
   71           }
   72           manager.init();
   73       }
   74   
   75       /**
   76        * Copy of {@link #init(Properties)} to XBean-ize it
   77        * 
   78        * @throws Exception
   79        */
   80       public void init() throws Exception {
   81   
   82           OpenEJB.init(propertiesService.getProperties(), new ServerFederation());
   83   
   84           if (!propertiesService.isSet("openejb.nobanner")) {
   85               System.out.println("[init] OpenEJB Remote Server");
   86           }
   87   
   88           manager.init();
   89       }
   90   
   91       public void start() throws Exception {
   92           manager.start();
   93       }
   94   
   95       public void stop() throws Exception {
   96           manager.stop();
   97       }
   98   
   99       public void addService(URI uri) {
  100   
  101       }
  102   
  103       public static class ServerServiceFactory {
  104           public ServerService createService(URI location) throws IOException {
  105               return null;
  106           }
  107       }
  108   
  109       public void setServiceManager(ServiceManager serviceManager) {
  110           this.manager = serviceManager;
  111       }
  112       
  113       public void setPropertiesService(PropertiesService propertiesService) {
  114           this.propertiesService = propertiesService;
  115       }
  116   }
  117   

Home » openejb-3.1.2-src » org.apache » openejb » server » [javadoc | source]