You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by fa...@apache.org on 2003/09/28 04:22:19 UTC

cvs commit: avalon-sandbox/exporter/xdocs index.xml navigation.xml

farra       2003/09/27 19:22:19

  Added:       exporter README.txt maven.xml project.properties project.xml
               exporter/src/conf app.properties block.xml
               exporter/src/java/org/apache/avalon/components/exporter
                        App.java ExportException.java ServiceExporter.java
               exporter/src/java/org/apache/avalon/components/exporter/impl
                        AltRmiExporter.java
               exporter/src/java/org/apache/avalon/components/exporter/test
                        TestClient.java TestComponent.java TestService.java
               exporter/xdocs index.xml navigation.xml
  Log:
  new merlin 3.0 stage extension.
  Exports services using altrmi.
  see readme for build details
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/exporter/README.txt
  
  Index: README.txt
  ===================================================================
                              Avalon Exporter
  SEPT 2003
  
  Avalon exporter is a simple component for exporting services via AltRMI.
  It's designed to be used with Merlin 3.0 and takes advantage of the 
  merlin lifecycle extension API.
  
  To build with maven:
  
    - include http://jadetower.sf.net/dist in your remote repository list
    - make sure you have the avalon meta plugin
    - RUN:
       maven jar:jar
  
  To run in merlin:
  
    - make sure your kernel.xml file includes the host listed above
    - run
  
      merlin.sh target/avalon-exporter-0.1.jar
  
  To run standalone client
  
    - follow maven directions above
    - now run:
  
      maven exporter:run
  
    - You should get a "Hello World" message
  
  To Do:
  
    - remove current tests from source tree and make real junit tests
    - seperate into api/impl
    - add ServiceDiscovery interface 
  
  
  
  1.1                  avalon-sandbox/exporter/maven.xml
  
  Index: maven.xml
  ===================================================================
  <?xml version="1.0"?>
  <project
    xmlns:j="jelly:core"
    xmlns:ant="jelly:ant"
    xmlns:maven="jelly:maven"
    xmlns:deploy="deploy"
    xmlns:m="maven">
  
     <preGoal name="jar:jar">
      <attainGoal name="avalon:meta"/>
    </preGoal>
  
  
     <goal name="exporter:run">
      <attainGoal name="jar:jar"/>
         <java classname="${maven.jar.mainclass}" fork="true" failonerror="true">
           <classpath>
             <pathelement path="${maven.build.dir}/${maven.final.name}.jar"/>
            <j:forEach var="dep" items="${pom.dependencies}">
             <pathelement path="${maven.repo.local}/${dep.artifactDirectory}/jars/${dep.artifact}"/>
            </j:forEach>
           </classpath>
         </java>
      </goal>
  
  </project>
  
  
  
  1.1                  avalon-sandbox/exporter/project.properties
  
  Index: project.properties
  ===================================================================
  maven.xdoc.date=left
  maven.xdoc.version=${pom.currentVersion}
  maven.jar.mainclass=org.apache.avalon.components.exporter.test.TestClient
  
  
  1.1                  avalon-sandbox/exporter/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <project>
  
    <!-- the version of maven's project object model -->
    <pomVersion>3</pomVersion>
  
    <!-- a unique name for this project -->
    <id>avalon-exporter</id>
  
    <!-- a short but descriptive name for the project -->
    <name>Avalon Exporter</name>
  
    <!-- The version of the project under development, e.g.
         1.1, 1.2, 2.0-dev -->
    <currentVersion>0.1</currentVersion>
  
    <!-- details about the organization that 'owns' the project -->
    <organization>
      <name>Apache Avalon Project</name>
      <url>http://avalon.apache.org/</url>
      <logo>http://avalon.apache.org/images/apache-avalon-logo.png</logo>
    </organization>
  
    <!-- the year the project started -->
    <inceptionYear>2003</inceptionYear>
    <package>org.apache.avalon.components.exporter</package>
    <logo>/images/logo.jpg</logo>
    <description>
      Exports avalon components via RMI/JNDI (using AltRMI)
    </description>
    <!-- a short description of what the project does -->
    <shortDescription>
  
    </shortDescription>
  
    <!-- the project home page -->
    <url>http://avalon.apache.org</url>
    <issueTrackingUrl></issueTrackingUrl>
    <siteAddress>cvs.apache.org</siteAddress>
    <siteDirectory></siteDirectory>
    <distributionDirectory></distributionDirectory>
  
    <repository>
      <connection>scm:annoncvs:pserver:cvs@cvs.apache.org:/home/cvs:avalon-sandbox/exporter-api</connection>
      <url>http://cvs.apache.org/viewcvs.cgi/</url>
    </repository>
  
    <!-- any mailing lists for the project -->
    <mailingLists/>
  
    <!-- who the developers are for the project -->
    <developers>
     <developer>
        <name>J Aaron Farr</name>
        <id>farra</id>
        <email>aaron.farr@am.sony.com</email>
        <organization>Sony Electronics</organization>
        <roles>
          <role>Java Developer</role>
        </roles>
      </developer>
    </developers>
  
    <!-- jar files the project is dependent on -->
    <dependencies>
  
     <dependency>
        <groupId>avalon-framework</groupId>
        <artifactId>avalon-framework</artifactId>
        <version>4.1.4</version>
        <url>http://avalon.apache.org/</url>
     </dependency>
  
      <dependency>
        <groupId>avalon-meta</groupId>
        <artifactId>avalon-meta-api</artifactId>
        <version>SNAPSHOT</version>
        <url>http://avalon.apache.org</url>
      </dependency>
  
      <dependency>
        <groupId>avalon-activation</groupId>
        <artifactId>avalon-activation-api</artifactId>
        <version>SNAPSHOT</version>
        <url>http://avalon.apache.org</url>
      </dependency>
  
      <dependency>
        <groupId>avalon-composition</groupId>
        <artifactId>avalon-composition-api</artifactId>
        <version>SNAPSHOT</version>
        <url>http://avalon.apache.org</url>
      </dependency>
  
      <dependency>
        <groupId>altrmi</groupId>
        <artifactId>altrmi-server-interfaces</artifactId>
        <version>0.9.6</version>
      </dependency>
  
      <dependency>
        <groupId>altrmi</groupId>
        <artifactId>altrmi-server-impl</artifactId>
        <version>0.9.6</version>
      </dependency>
  
      <dependency>
        <groupId>altrmi</groupId>
        <artifactId>altrmi-common</artifactId>
        <version>0.9.6</version>
      </dependency>
  
      <!-- runtime dependencies for test -->
      <dependency>
        <groupId>altrmi</groupId>
        <artifactId>altrmi-client-impl</artifactId>
        <version>0.9.6</version>
      </dependency>
  
      <dependency>
        <groupId>altrmi</groupId>
        <artifactId>altrmi-client-interfaces</artifactId>
        <version>0.9.6</version>
      </dependency>
  
      <dependency>
        <groupId>sun</groupId>
        <artifactId>jndi</artifactId>
        <version>1.2.1</version>
      </dependency>
    </dependencies>
  
    <!-- build information for the project -->
    <build>
      <nagEmailAddress>aaron.farr@am.sony.com</nagEmailAddress>
      <sourceDirectory>${basedir}/src/java</sourceDirectory>
      <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
  
      <unitTest/>
  
      <resources>
        <resource>
         <directory>${basedir}/src/conf</directory>
         <targetPath>BLOCK-INF</targetPath>
          <includes>
           <include>block.xml</include>
         </includes>
        </resource>
      </resources>
    </build>
  
  
  </project>
  
  
  
  
  1.1                  avalon-sandbox/exporter/src/conf/app.properties
  
  Index: app.properties
  ===================================================================
  # Sample app properties.
  foo=bar
  
  
  
  1.1                  avalon-sandbox/exporter/src/conf/block.xml
  
  Index: block.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <container name="exporter">
  
     <classloader>
       <classpath>
         <repository>
             <resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
             <resource id="altrmi:altrmi-common" version="0.9.6"/>
             <resource id="altrmi:altrmi-generator" version="0.9.6"/>
             <resource id="altrmi:altrmi-registry" version="0.9.6"/>
             <resource id="altrmi:altrmi-server-impl" version="0.9.6"/>
             <resource id="altrmi:altrmi-server-interfaces" version="0.9.6"/>
             <resource id="bcel:bcel" version="5.1"/>
         </repository>
       </classpath>
     </classloader>
  
  
    <services>
       <service type="org.apache.avalon.components.exporter.ServiceExporter">
         <source>altrmi-exporter</source>
       </service>
    </services>
  
  
     <component name="altrmi-exporter" class="org.apache.avalon.components.exporter.impl.AltRmiExporter" activation="startup">
       <configuration>
          <port>7124</port>
       </configuration>
     </component>
  
  
     <component name="test" class="org.apache.avalon.components.exporter.test.TestComponent" activation="startup"/>
  
  
  </container>
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/App.java
  
  Index: App.java
  ===================================================================
  package org.apache.avalon.components.exporter;
  
  /**
   * Hello world!
   *
   * @author <a href="jason@zenplex.com">Jason van Zyl</a>
   *
   */
  public class App 
  {
      public static void main( String[] args )
      {
          System.out.println( "Hello World!" );
      }
  }
  
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/ExportException.java
  
  Index: ExportException.java
  ===================================================================
  package org.apache.avalon.components.exporter;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * @version $Id: ExportException.java,v 1.1 2003/09/28 02:22:19 farra Exp $
   */
  
  public class ExportException
      extends CascadingException
  {
    public ExportException(String message) {
      super(message);
    }
  
    public ExportException(String message, Exception cause){
      super(message,cause);
    }
  
  }
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/ServiceExporter.java
  
  Index: ServiceExporter.java
  ===================================================================
  package org.apache.avalon.components.exporter;
  
  /**
   * Marker service for exporters
   * @version $Id: ServiceExporter.java,v 1.1 2003/09/28 02:22:19 farra Exp $
   * @avalon.service version="1.0"
   */
  public interface ServiceExporter {
  
    public static final String ROLE = ServiceExporter.class.getName();
  
    /**
     * export the service
     * @param name the service bind name
     * @param obj the service implementation
     * @param services the service classes implemented
     * @param additionalFacades additional facades to publish
     * @throws ExportException
     */
    public void export(String name, Object obj,
                       Class[] services, Class[] additionalFacades)
        throws ExportException;
  
  
  }
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/impl/AltRmiExporter.java
  
  Index: AltRmiExporter.java
  ===================================================================
  package org.apache.avalon.components.exporter.impl;
  
  import org.apache.avalon.activation.lifecycle.LifecycleCreateExtension;
  import org.apache.avalon.activation.lifecycle.LifecycleDestroyExtension;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.composition.model.DeploymentModel;
  import org.apache.avalon.meta.info.StageDescriptor;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.meta.info.Type;
  import org.apache.avalon.meta.info.ServiceDescriptor;
  import org.apache.altrmi.server.impl.AbstractServer;
  import org.apache.altrmi.server.PublicationDescription;
  import org.apache.altrmi.server.PublicationException;
  import org.apache.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
  import org.apache.altrmi.server.impl.classretrievers.BcelDynamicGeneratorClassRetriever;
  import org.apache.altrmi.server.impl.classretrievers.AbstractDynamicGeneratorClassRetriever;
  import org.apache.altrmi.server.impl.AbstractServerStreamReadWriter;
  import org.apache.altrmi.server.impl.DefaultServerSideClientContextFactory;
  import org.apache.altrmi.server.impl.NullServerMonitor;
  import org.apache.altrmi.server.impl.ServerCustomStreamReadWriter;
  import org.apache.altrmi.server.impl.DefaultAuthenticator;
  import org.apache.altrmi.server.impl.adapters.InvocationHandlerAdapter;
  import org.apache.altrmi.server.impl.classretrievers.NoClassRetriever;
  import org.apache.altrmi.common.DefaultThreadPool;
  import java.util.StringTokenizer;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.components.exporter.ServiceExporter;
  import org.apache.avalon.components.exporter.ExportException;
  
  
  /**
   * @author Avalon Development Team
   * @version $Id: AltRmiExporter.java,v 1.1 2003/09/28 02:22:19 farra Exp $
   * @avalon.component name="altrmi-exporter" lifestyle="singleton"
   * @avalon.service type="org.apache.avalon.components.exporter.ServiceExporter"
   * @avalon.extension id="urn:exporter:altrmi"
   */
  public class AltRmiExporter
      extends AbstractLogEnabled
      implements LifecycleCreateExtension, LifecycleDestroyExtension,
                 ServiceExporter, Configurable, Initializable, Startable
  {
  
    protected AbstractServer m_server = null;
    protected AbstractDynamicGeneratorClassRetriever m_generator = null;
    protected int m_port = 7124;
  
    public AltRmiExporter() {
    }
  
  
    public void export(String name, Object obj, Class[] services,
                       Class[] additionalFacades) throws ExportException {
      try {
        PublicationDescription pub = new PublicationDescription(services,
            additionalFacades);
  
        if(getLogger().isDebugEnabled()) getLogger().debug("Generating Proxy...");
  
        m_generator.generate(name, pub,
                             Thread.currentThread().getContextClassLoader());
  
        if (getLogger().isDebugEnabled()) getLogger().debug("Exported: " + name);
  
        m_server.publish(obj, name, pub);
  
      }
      catch (PublicationException ex) {
        throw new ExportException("Error exporting the service",ex);
      }
    }
  
    public void create(DeploymentModel deploymentModel,
                       StageDescriptor stageDescriptor, Object object) {
      try {
  
        Type type = deploymentModel.getType();
        String name = type.getInfo().getName();
        if(getLogger().isDebugEnabled())
          getLogger().debug("Preparing export: "+name);
  
        // get service list
        ServiceDescriptor[] services = type.getServices();
        Class[] serviceClasses = new Class[services.length];
        for (int i = 0; i < services.length; i++) {
          ServiceDescriptor desc = services[i];
          serviceClasses[i] = Class.forName(desc.getReference().getClassname());
        }
  
        String facades = stageDescriptor.getAttribute("urn:altrmi:add-facades",null);
        Class facadeClasses[] = new Class[0];
        if(facades != null){
          StringTokenizer st = new StringTokenizer(facades,",");
          facadeClasses = new Class[st.countTokens()];
          int i = 0;
          while(st.hasMoreTokens()){
            facadeClasses[i] = Class.forName(st.nextToken());
            i++;
          }
        }
  
        export(name,object,serviceClasses,facadeClasses);
  
      }
      catch (Exception ex) {
        getLogger().error("Error publishing component",ex);
      }
    }
  
    public void destroy(DeploymentModel deploymentModel,
                        StageDescriptor stageDescriptor, Object object) {
      /** @todo hmm... how to destroy with altrmi? */
    }
  
    public void configure(Configuration configuration) {
      m_port = configuration.getChild("port",true).getValueAsInteger(7124);
      /** @todo add more configuration for the server... */
    }
  
    public void initialize() {
      m_generator = new BcelDynamicGeneratorClassRetriever();
      m_server = new CompleteSocketCustomStreamServer(m_generator,
          new DefaultAuthenticator(), new NullServerMonitor(),
          new DefaultThreadPool(),new DefaultServerSideClientContextFactory(),m_port);
    }
  
  
    public void start() throws Exception {
      m_server.start();
    }
  
    public void stop() {
      m_server.stop();
    }
  
  }
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/test/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  package org.apache.avalon.components.exporter.test;
  
  import javax.naming.InitialContext;
  import java.util.Hashtable;
  import javax.naming.Context;
  import javax.naming.*;
  
  /**
   * <p>Title:  Avalon Exporter</p>
   * <p>Description:  Exports avalon components via RMI/JNDI (using AltRMI)</p>
   * <p>Copyright:  Copyright (c) 2003 Apache Avalon Project - All Rights Reserved.</p>
   * <p>Company:  Apache Avalon Project</p>
   * @author cimadmin
   * @version $Id: TestClient.java,v 1.1 2003/09/28 02:22:19 farra Exp $
   */
  
  public class TestClient {
    public TestClient() {
    }
  
  
    public static void main(String[] args) {
  
      try {
        Hashtable env = new Hashtable();
        env.put(
            Context.INITIAL_CONTEXT_FACTORY,
            "org.apache.altrmi.client.impl.naming.DefaultInitialContextFactory");
        env.put(Context.PROVIDER_URL, "altrmi://localhost:7124/SocketCustomStream");
        Context ctx = new InitialContext(env);
  
        TestService test = (TestService) ctx.lookup("test");
        System.out.println(test.getValue());
      }
      catch (NamingException ex) {
        ex.printStackTrace();
      }
      System.exit(0);
    }
  
  }
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/test/TestComponent.java
  
  Index: TestComponent.java
  ===================================================================
  package org.apache.avalon.components.exporter.test;
  
  
  /**
   * @avalon.component name="test"
   * @avalon.service type="org.apache.avalon.components.exporter.test.TestService"
   * @avalon.stage id="urn:exporter:altrmi"
   */
  public class TestComponent
      implements TestService
  {
    public TestComponent() {
    }
  
    public String getValue() {
      return "Hello World!";
    }
  }
  
  
  1.1                  avalon-sandbox/exporter/src/java/org/apache/avalon/components/exporter/test/TestService.java
  
  Index: TestService.java
  ===================================================================
  package org.apache.avalon.components.exporter.test;
  
  /**
   * @avalon.service version="1.0"
   */
  public interface TestService {
  
    public String getValue();
  
  }
  
  
  1.1                  avalon-sandbox/exporter/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
       For more information on xdocs, see
       http://maven.apache.org/reference/plugins/xdoc/
  
       to render, run:
          maven site:generate
  
       Note, most all normal XHTML tags will work here
       (like anchor for links, etc.) just LEAVE OUT style info!
  
       don't forget to update the navigation.xml file too
       (and delete this).
  	
  -->
  
  <?xml version="1.0"?>
  <document>
  
    <properties>
      <author email="nospam@foo.com">Jon S. Stevens</author>
      <author email="mrsmith@foo.com">Mr. Smith</author>
      <title></title>
    </properties>
  
    <meta name="keyword" content="jakarta, java"/>
  
    
  <body>
  
  <section name="Section 1">
  <p>
  This is section 1.
  </p>
  
  <table>
  <tr>
      <td>This is a table</td>
  </tr>
  </table>
  
  <ul>
  
      <li>This is an unordered list.</li>
  </ul>
  
  </section>
  
  <section name="Section 2">
  <p>
  This is section 2.
  </p>
  
  <ol>
      <li>This is an ordered list.</li>
  </ol>
  
  </section>
  
  <section name="Section 3">
  <p>
  This is section 3.
  </p>
  
  <source>
      Anything within this tag is rendered as a "box"
      with lines and &lt;pre&gt;&lt;/pre&gt; tags around it.
  </source>
  
      <subsection name="Subsection of Section 3">
      <p>
          This is the subsection 3.
      </p>
      </subsection>
  
  </section>
  
  </body>
  </document>
  
  
  
  
  
  
  1.1                  avalon-sandbox/exporter/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!--
     This file modifies your sidebar menu. 
      EVERY subdirectory should have one.
       (however, links are from the document root, not relative)
  -->
  
  <project name="My Project">
  
    <title>My Project</title>
  
    <body>
      <!-- links end up in the upper right hand corner -->
      <links>
         <item name="Sony Inside" href="http://intranet.ptg.sel.sony.com"/>
         <item name="CIM" href="http://uspbcim2.ptg.sel.sony.com/"/>
         <item name="Projects" href="http://uspbcim2.ptg.sel.sony.com/CIM/projects"/>
      </links>
  
      <!-- left sidebar items -->
      <menu name="My Project">
        <item name="Overview" href="/index.html"/>
        <!-- add as necessary 
        <item name="Installation" href="/install.html"/>
        <item name="Configuration" href="/conf.html"/>
        <item name="Development" href="/dev.html"/>
        -->
      </menu>
      
    </body>
    
  </project>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org