ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/manifest core-services.xml
Date Sat, 26 Jan 2002 04:17:06 GMT
donaldp     02/01/25 20:17:06

  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/services
                        ServiceFactory.java ServiceException.java
               proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys
                        Resources.properties ExecManagerFactory.java
               proposal/myrmidon/src/manifest core-services.xml
  Log:
  Add in a basic example of the interface via which Service *could* be loaded into the runtime.
  
  Added in a sample config file and a sample factory aswell.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/services/ServiceFactory.java
  
  Index: ServiceFactory.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.services;
  
  /**
   * A ServiceFactory is used to create a service for use in the
   * Myrmidon runtime. The factory is responsible for creating and
   * preparing the service for use.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/01/26 04:17:06 $
   */
  public interface ServiceFactory
  {
      /**
       * Create a service that coresponds to this factory.
       * This method is usually called after the factory has been
       * prepared and configured as appropriate.
       */
      Object createService()
          throws ServiceException;
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/services/ServiceException.java
  
  Index: ServiceException.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.services;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * ServiceException thrown when a service can not be created for
   * some reason.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public class ServiceException
      extends CascadingException
  {
      /**
       * Basic constructor for exception that does not specify a message
       */
      public ServiceException()
      {
          this( "", null );
      }
  
      /**
       * Basic constructor with a message
       *
       * @param message the message
       */
      public ServiceException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Constructor that builds cascade so that other exception information can be retained.
       *
       * @param message the message
       * @param throwable the throwable
       */
      public ServiceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  missing-home-dir.error=Cannot locate antRun scripts: Property 'myrmidon.home' not specified
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/factorys/ExecManagerFactory.java
  
  Index: ExecManagerFactory.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.framework.factorys;
  
  import java.io.File;
  import org.apache.aut.nativelib.ExecException;
  import org.apache.aut.nativelib.impl.DefaultExecManager;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.services.ServiceException;
  import org.apache.myrmidon.services.ServiceFactory;
  
  /**
   * A Factory responsible for creating the ExecManager service.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/01/26 04:17:06 $
   */
  public class ExecManagerFactory
      implements ServiceFactory
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( ExecManagerFactory.class );
  
      /**
       * Create the ExecManager Service.
       */
      public Object createService()
          throws ServiceException
      {
          final File home = getHomeDirectory();
          try
          {
              return new DefaultExecManager( home );
          }
          catch( final ExecException ee )
          {
              throw new ServiceException( ee.getMessage(), ee );
          }
      }
  
      /**
       * Utility method to retrieve home directory.
       */
      private static File getHomeDirectory()
          throws ServiceException
      {
          final String home = System.getProperty( "myrmidon.home" );
          if( null == home )
          {
              final String message = REZ.getString( "missing-home-dir.error" );
              throw new ServiceException( message );
          }
  
          return new File( home );
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/manifest/core-services.xml
  
  Index: core-services.xml
  ===================================================================
  <services>
    <service role="org.apache.aut.nativelib.ExecManager"
             factory="org.apache.myrmidon.framework.factorys.ExecManagerFactory"/>
  </services>
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message