jvanzyl     2003/01/27 16:16:18

  Modified:    src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly
                        PlexusTagLibrary.java
               src/plugins-build/plexus/src/test-data
                        plexus-roles-test.conf
  Added:       src/plugins-build/plexus/src/main/org/apache/maven/plexus
                        PlexusImplementationFinder.java
               src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly
                        PlexusImplementationFinderTag.java
               src/plugins-build/plexus/src/test/org/apache/maven/plexus
                        PlexusImplementationFinderTest.java
  Removed:     src/plugins-build/plexus/src/main/org/apache/maven/plexus
                        PlexusRoleFinder.java
               src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly
                        PlexusRoleFinderTag.java
               src/plugins-build/plexus/src/test/org/apache/maven/plexus
                        PlexusRoleFinderTest.java
  Log:
  o Changing the plexus plugin to search for the implementation classes and
    not the roles. We also changed over in Plexus to using <implementation/>
    to denote the concrete implementation and not <class/>.
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-maven/src/plugins-build/plexus/src/main/org/apache/maven/plexus/PlexusImplementationFinder.java
  
  Index: PlexusImplementationFinder.java
  ===================================================================
  package org.apache.maven.plexus;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  import org.xml.sax.Attributes;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.helpers.DefaultHandler;
  
  import javax.xml.parsers.SAXParser;
  import javax.xml.parsers.SAXParserFactory;
  import java.io.File;
  import java.io.FileInputStream;
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  /**
   */
  public class PlexusImplementationFinder
       extends DefaultHandler
  {
      private List impls = new ArrayList();
      private static SAXParserFactory saxFactory;
      private StringBuffer bodyText = new StringBuffer();
      private Set uniqueImpls = new HashSet();
      private File configuration;
      private static final String IMPL_KEY = "implementation";
      
      public void setConfiguration( File configuration )
      {
          this.configuration = configuration;
      }
      
      public File getConfiguration()
      {
          return configuration;
      }        
  
      /**
       * Gets the dependencies attribute of the Bootstrap object
       */
      public List getImpls()
      {
          return impls;
      }
  
      /**
       */
      public void parse()
      {
          try
          {
              saxFactory = SAXParserFactory.newInstance();
              SAXParser parser = saxFactory.newSAXParser();
              InputSource is = new InputSource(new FileInputStream( getConfiguration() 
));
              parser.parse(is, this);
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
      }
  
      /**
       * Handles opening elements of the xml file.
       */
      public void startElement(String uri, String localName, String rawName, 
Attributes attributes)
      {
          String impl = attributes.getValue( IMPL_KEY );
          
          if ( impl != null )
          {
              if ( uniqueImpls.contains( impl ) == false )
              {
                  impls.add( impl );
                  uniqueImpls.add( impl );
              }                
          }            
      }
  
      /**
       * Description of the Method
       */
      public void characters(char buffer[], int start, int length)
      {
          bodyText.append(buffer, start, length);
      }
  
      private String getBodyText()
      {
          return bodyText.toString().trim();
      }        
  
      /**
       * Handles closing elements of the xml file.
       */
      public void endElement(String uri, String localName, String rawName)
      {
          if (rawName.equals(IMPL_KEY))
          {
              String impl = getBodyText();
              
              if ( uniqueImpls.contains( impl ) == false )
              {
                  impls.add( impl );
                  uniqueImpls.add( impl );
              }
          }
          
          bodyText = new StringBuffer();
      }
  
      /**
       * Warning callback.
       *
       * @param spe The parse exception that caused the callback to be invoked.
       */
      public void warning(SAXParseException spe)
      {
          printParseError("Warning", spe);
      }
  
      /**
       * Error callback.
       *
       * @param spe The parse exception that caused the callback to be invoked.
       */
      public void error(SAXParseException spe)
      {
          printParseError("Error", spe);
      }
  
      /**
       * Fatal error callback.
       *
       * @param spe The parse exception that caused the callback to be invoked.
       */
      public void fatalError(SAXParseException spe)
      {
          printParseError("Fatal Error", spe);
      }
  
      /**
       * Description of the Method
       */
      private final void printParseError(String type, SAXParseException spe)
      {
          System.err.println(type + " [line " + spe.getLineNumber() +
              ", row " + spe.getColumnNumber() + "]: " +
              spe.getMessage());
      }
  }
  
  
  
  1.2       +2 -2      
jakarta-turbine-maven/src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly/PlexusTagLibrary.java
  
  Index: PlexusTagLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly/PlexusTagLibrary.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlexusTagLibrary.java     24 Jan 2003 03:45:48 -0000      1.1
  +++ PlexusTagLibrary.java     28 Jan 2003 00:16:18 -0000      1.2
  @@ -17,6 +17,6 @@
        */
       public PlexusTagLibrary()
       {
  -        registerTag( "find-roles", PlexusRoleFinderTag.class );
  +        registerTag( "find-implementations", PlexusImplementationFinderTag.class );
       }
   }
  
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/plexus/src/main/org/apache/maven/plexus/jelly/PlexusImplementationFinderTag.java
  
  Index: PlexusImplementationFinderTag.java
  ===================================================================
  package org.apache.maven.plexus.jelly;
  
  import java.io.File;
  
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.maven.plexus.PlexusImplementationFinder;
  
  /**
   * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
   * @version: $Id: PlexusImplementationFinderTag.java,v 1.1 2003/01/28 00:16:18 
jvanzyl Exp $
   */
  public class PlexusImplementationFinderTag
      extends TagSupport
  {
      /** Id of this pipeline. */
      private File configuration;
      
      private String var;
      
      public void setConfiguration( File configuration )
      {
          this.configuration = configuration;
      }
      
      public File getConfiguration()
      {
          return configuration;
      }        
  
      public void setVar( String var )
      {
          this.var = var;
      }
      
      public String getVar()
      {
          return var;
      }        
      
  
      /** Execute the tag. */
      public void doTag(XMLOutput output)
          throws Exception
      {
          // Create a new pipeline and set the id.
          PlexusImplementationFinder finder = new PlexusImplementationFinder();
          finder.setConfiguration( getConfiguration() );
          finder.parse();
          
          // Place the pipeline in the context.
          context.setVariable( getVar(), finder.getImpls() );
      }
  }
  
  
  
  1.1                  
jakarta-turbine-maven/src/plugins-build/plexus/src/test/org/apache/maven/plexus/PlexusImplementationFinderTest.java
  
  Index: PlexusImplementationFinderTest.java
  ===================================================================
  package org.apache.maven.plexus;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.TestCase;
  
  import java.io.File;
  
  import java.util.List;
  
  /**
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
   *
   * @version $Id: PlexusImplementationFinderTest.java,v 1.1 2003/01/28 00:16:18 
jvanzyl Exp $
   */
  public class PlexusImplementationFinderTest
      extends TestCase
  {
      private static String TEST_CONF = System.getProperty("basedir")
          + "/src/test-data/plexus-roles-test.conf";
  
        /**
       * Constructor.
       *
       * @param name Name of the test.
       */
      public PlexusImplementationFinderTest( String name )
        {
                super( name );
        }
  
        /**
       * Test the plugin cache builder.
         */
        public void testRoleFinder()
        {
          PlexusImplementationFinder finder = new PlexusImplementationFinder();
          finder.setConfiguration( new File( TEST_CONF ) );
          finder.parse();
  
          List impls = finder.getImpls();
  
          assertEquals( "org.apache.plexus.velocity.DefaultVelocityComponent", 
(String) impls.get(0));
          assertEquals( "org.apache.plexus.xmlrpc.DefaultXmlRpcComponent", (String) 
impls.get(1));
          assertEquals( "org.apache.plexus.scheduler.DefaultScheduler", (String) 
impls.get(2));
          assertEquals( "org.apache.plexus.jetty.JettyServletContainer", (String) 
impls.get(3));
      }
  }
  
  
  
  1.2       +5 -88     
jakarta-turbine-maven/src/plugins-build/plexus/src/test-data/plexus-roles-test.conf
  
  Index: plexus-roles-test.conf
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/plugins-build/plexus/src/test-data/plexus-roles-test.conf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plexus-roles-test.conf    24 Jan 2003 03:45:48 -0000      1.1
  +++ plexus-roles-test.conf    28 Jan 2003 00:16:18 -0000      1.2
  @@ -1,21 +1,11 @@
   <plexus>
     
  -  <load-on-start>
  -    <service role="org.apache.plexus.jetty.ServletContainer" id="jetty"/>
  -    <service role="org.apache.plexus.transactor.Transactor" id="transactor"/>
  -    <service role="com.werken.werkflow.agent.AgentManager" id="agent-manager"/>
  -  </load-on-start>
  -  
  +
     <factories>
       <factory>
         <id>velocity</id>
         <role>org.apache.plexus.velocity.VelocityComponent</role>
  -      <class>org.apache.plexus.velocity.DefaultVelocityComponent</class>
  -    </factory>
  -    <factory>
  -      <id>script-agent-factory</id>
  -      <role>com.werken.werkflow.agent.ScriptAgent</role>
  -      <class>com.werken.werkflow.agent.ScriptAgent</class>
  +      
<implementation>org.apache.plexus.velocity.DefaultVelocityComponent</implementation>
       </factory>
     </factories>
   
  @@ -24,7 +14,7 @@
       <component>
         <id>xmlrpc</id>
         <role>org.apache.plexus.xmlrpc.XmlRpcComponent</role>
  -      <class>org.apache.plexus.xmlrpc.DefaultXmlRpcComponent</class>
  +      
<implementation>org.apache.plexus.xmlrpc.DefaultXmlRpcComponent</implementation>
         <configuration>    
           <port>9000</port>
           <parser>org.apache.xerces.parsers.SAXParser</parser>
  @@ -55,7 +45,7 @@
       <component>
         <id>scheduler</id>
         <role>org.apache.plexus.scheduler.Scheduler</role>
  -      <class>org.apache.plexus.scheduler.DefaultScheduler</class>
  +      <implementation>org.apache.plexus.scheduler.DefaultScheduler</implementation>
         <configuration>    
           <job-directory>jobs</job-directory>
           <scheduler>
  @@ -85,7 +75,7 @@
         <id>jetty</id>
         <logger>test</logger>
         <role>org.apache.plexus.jetty.ServletContainer</role>
  -      <class>org.apache.plexus.jetty.JettyServletContainer</class>
  +      <implementation>org.apache.plexus.jetty.JettyServletContainer</implementation>
         <configuration>
           <host>localhost</host>
           <port>8080</port>
  @@ -96,79 +86,6 @@
         </configuration>
       </component>
       
  -    <component>
  -      <id>transactor</id>
  -      <role>org.apache.plexus.transactor.Transactor</role>
  -      <class>org.apache.plexus.transactor.DefaultTransactor</class>
  -      <configuration>
  -        <marDirectory>mars</marDirectory>
  -        <transactionDirectory>transactions</transactionDirectory>
  -        <driver>org.postgresql.Driver</driver>
  -        <url>jdbc:postgresql://127.0.0.1:5432/buyer</url>
  -        <userid>tambora</userid>
  -        <password>tambora</password>
  -        
<transporter-role>org.apache.plexus.xmlrpc.XmlRpcComponent</transporter-role>
  -        <transporter-id>xmlrpc</transporter-id>
  -      </configuration>
  -    </component>
  -
  -    <!-- W E R K F L O W -->
  -
  -    <component>
  -
  -      <id>werkflow</id>
  -      <role>com.werken.werkflow.WorkflowEngine</role>
  -      <class>com.werken.werkflow.engine.WorkflowEngineImpl</class>
  -
  -      <configuration>
  -        <engine>
  -          <min-threads>1</min-threads>
  -          <max-threads>10</max-threads>
  -          <keep-alive>60000</keep-alive>
  -        </engine>
  -        <process-repos>
  -          <repo>jelly-repo</repo>
  -        </process-repos>
  -      </configuration>
  -
  -    </component>
  -
  -    <!-- P R O C E S S  R E P O S I T O R Y -->
  -
  -    <component>
  -      <id>jelly-repo</id>
  -      <role>com.werken.werkflow.process.ProcessDefinitionRepository</role>
  -      <class>com.werken.werkflow.jelly.JellyProcessDefinitionRepository</class>
  -
  -      <configuration>
  -        <url>conf/po.werk</url>
  -      </configuration>
  -
  -    </component>
  -
  -    <component>
  -
  -      <id>agent-manager</id>
  -      <role>com.werken.werkflow.agent.AgentManager</role>
  -      <class>com.werken.werkflow.agent.SimpleAgentManager</class>
  -
  -      <configuration>
  -        <engine>werkflow</engine>
  -        <bind>
  -          <process>po</process>
  -          <agent>com.werken.werkflow.agent.ScriptAgent</agent>
  -          <configuration> 
  -          </configuration> 
  -        </bind>
  -        <bind>
  -          <process>oc</process>
  -          <agent>com.werken.werkflow.agent.ScriptAgent</agent>
  -          <configuration> 
  -            <trigger>supplier.accept</trigger>
  -          </configuration> 
  -        </bind>
  -      </configuration>
  -    </component>
     </components>
   
   </plexus>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to