hammant 02/01/13 02:35:17
Modified: apps/demo build.xml
Added: apps/demo/src/conf avalon-altrmidemo-assembly.xml
avalon-altrmidemo-config.xml
avalon-altrmidemo-environment.xml
apps/demo/src/java/org/apache/avalon/cornerstone/demos/altrmihelloworldserver
AltrmiHelloWorldServer.java
AltrmiHelloWorldServerImpl.java
AltrmiHelloWorldServerImpl.xinfo
AltrmiHelloWorldServerTester.java
apps/demo/src/manifest altrmihelloworld-demo.mf
Log:
AltRMI demo block that uses helloworld
Revision Changes Path
1.34 +92 -1 jakarta-avalon-cornerstone/apps/demo/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/demo/build.xml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- build.xml 11 Jan 2002 17:25:33 -0000 1.33
+++ build.xml 13 Jan 2002 10:35:16 -0000 1.34
@@ -69,6 +69,14 @@
<taskdef name="sar" classname="org.apache.avalon.phoenix.tools.tasks.Sar">
<classpath refid="project.class.path" />
</taskdef>
+
+ <taskdef name="altrmiinterfaces"
classname="org.apache.commons.altrmi.generator.ant.AltrmiInterfaceTask">
+ <classpath refid="project.class.path" />
+ </taskdef>
+
+ <taskdef name="altrmiclassintern"
classname="org.apache.commons.altrmi.generator.ant.AltrmiClassInternTask">
+ <classpath refid="project.class.path" />
+ </taskdef>
<!-- Setup the filters -->
@@ -107,6 +115,10 @@
property="glue.present"/>
<mkdir dir="${build.classes}"/>
+ <mkdir dir="build/genjava"/>
+ <mkdir dir="build/genclasses"/>
+ <mkdir dir="build/genjava2"/>
+ <mkdir dir="build/genclasses2"/>
<javac srcdir="${java.dir}"
destdir="${build.classes}"
@@ -117,6 +129,7 @@
<exclude
name="org/apache/avalon/cornerstone/demos/soaphelloworldserver/**.java"
unless="glue.present" />
+
</javac>
<rmic base="${build.classes}"
@@ -124,6 +137,35 @@
stubVersion="1.2">
<classpath refid="project.class.path"/>
</rmic>
+
+ <altrmiinterfaces genname="helloworld" gendir="apps/demo/build/genjava"
+
classesorinterfaces="org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServer">
+ <classpath>
+ <pathelement location="../../lib/commons-altrmi-common.jar"/>
+ <pathelement location="../../lib/commons-altrmi-generator.jar"/>
+ <pathelement path="build/classes"/>
+ </classpath>
+ </altrmiinterfaces>
+
+ <javac srcdir="build/genjava"
+ destdir="build/genclasses"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="project.class.path" />
+ </javac>
+
+ <altrmiclassintern gendir="apps/demo/build/genjava2"
+ sourceclassdir="apps/demo/build/genclasses/"
+ publishedname="helloworld" />
+
+ <javac srcdir="build/genjava2"
+ destdir="build/genclasses2"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="project.class.path"/>
+ </javac>
<copy todir="${build.classes}">
<fileset dir="${java.dir}">
@@ -157,12 +199,22 @@
<include
name="org/apache/avalon/cornerstone/demos/rmihelloworldserver/*"/>
</jar>
+ <jar jarfile="${build.lib}/demo-altrmihelloworld.jar"
+ manifest="${manifest.dir}/altrmihelloworld-demo.mf">
+ <fileset dir="${build.classes}">
+ <include
name="org/apache/avalon/cornerstone/demos/altrmihelloworldserver/*"/>
+ </fileset>
+ <fileset dir="build/genclasses2">
+ <include name="**"/>
+ </fileset>
+ </jar>
+
</target>
<target name="main" depends="sars" description="Default target to generate
build products minus docs"/>
<target name="all" depends="main,docs" description="Generate build
products including docs"/>
- <target name="sars" depends="jars,soapdemo-sar,rmidemo-sar">
+ <target name="sars" depends="jars, soapdemo-sar, rmidemo-sar,
altrmidemo-sar">
<sar sarfile="${build.lib}/avalon-demo.sar"
config="${conf.dir}/avalon-demo-config.xml"
@@ -237,6 +289,32 @@
</target>
+ <target name="altrmidemo-sar" depends="jars">
+
+ <sar sarfile="${build.lib}/avalon-altrmidemo.sar"
+ config="${conf.dir}/avalon-altrmidemo-config.xml"
+ environment="${conf.dir}/avalon-altrmidemo-environment.xml"
+ assembly="${conf.dir}/avalon-altrmidemo-assembly.xml" >
+
+ <lib dir="${build.lib}/">
+ <include name="demo-helloworld.jar"/>
+ <include name="demo-altrmihelloworld.jar"/>
+ </lib>
+
+ <lib dir="../../build/lib">
+ <include name="cornerstone.jar"/>
+ </lib>
+
+ <lib dir="../../lib">
+ <include name="commons-altrmi-common.jar"/>
+ <include name="commons-altrmi-server-interfaces.jar"/>
+ <include name="commons-altrmi-server-impl.jar"/>
+ </lib>
+ </sar>
+
+ </target>
+
+
<!-- Performs unit tests -->
<target name="check" depends="compile" description="Perform any built in
tests">
</target>
@@ -260,6 +338,19 @@
<arg value="RMIfication Tester" />
</java>
</target>
+
+ <!-- Performs Altrmi related unit tests -->
+ <target name="check-altrmi" depends="compile">
+ <java
classname="org.apache.avalon.cornerstone.demos.altrmihelloworldserver.AltrmiHelloWorldServerTester">
+ <classpath>
+ <pathelement location="../../lib/commons-altrmi-common.jar"/>
+ <pathelement
location="../../lib/commons-altrmi-client-interfaces.jar"/>
+ <pathelement location="../../lib/commons-altrmi-client-impl.jar"/>
+ <pathelement path="build/classes"/>
+ </classpath>
+ </java>
+ </target>
+
<!-- Performs unit tests -->
<target name="rmi-demo-test" depends="check-rmi" description="Change the
HelloWorld message via the RMI API (a test aid)"/>
1.1
jakarta-avalon-cornerstone/apps/demo/src/conf/avalon-altrmidemo-assembly.xml
Index: avalon-altrmidemo-assembly.xml
===================================================================
<?xml version="1.0"?>
<assembly>
<!-- The Connection Manager block -->
<block
class="org.apache.avalon.cornerstone.blocks.connection.DefaultConnectionManager"
name="connections">
<provide name="thread-manager"
role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
</block>
<!-- The ThreadManager block -->
<block
class="org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager"
name="thread-manager" />
<!-- The Socket Manager block -->
<block
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketManager"
name="sockets" />
<!-- -->
<!-- Below this section are the demo blocks -->
<!-- -->
<block
class="org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServerImpl"
name="helloworldserver" >
<provide name="sockets"
role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
<provide name="connections"
role="org.apache.avalon.cornerstone.services.connection.ConnectionManager" />
</block>
<block
class="org.apache.avalon.cornerstone.blocks.transport.publishing.SocketObjectStreamPublisher"
name="altrmi-publisher" >
<provide name="sockets"
role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
<provide name="connections"
role="org.apache.avalon.cornerstone.services.connection.ConnectionManager" />
</block>
<block
class="org.apache.avalon.cornerstone.demos.altrmihelloworldserver.AltrmiHelloWorldServerImpl"
name="altrmihelloworldserver" >
<provide name="helloworldserver"
role="org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServer"/>
<provide name="altrmi-publisher"
role="org.apache.commons.altrmi.server.AltrmiPublisher" />
</block>
</assembly>
1.1
jakarta-avalon-cornerstone/apps/demo/src/conf/avalon-altrmidemo-config.xml
Index: avalon-altrmidemo-config.xml
===================================================================
<?xml version="1.0"?>
<!--
README!
All blocks have full defaults so nothing is needed to make them run.
-->
<config>
<thread-manager>
<thread-group>
<name>default</name>
<!-- normal priority == 5, max-priority = 10 -->
<priority>5</priority>
<!-- are threads deamon threads ? -->
<is-daemon>false</is-daemon>
<max-threads>40</max-threads>
<!-- these are ignored at the moment but will be fixed in later
revisions -->
<min-threads>20</min-threads>
<min-spare-threads>20</min-spare-threads>
</thread-group>
</thread-manager>
<sockets>
<server-sockets>
<factory name="plain"
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultServerSocketFactory"
/>
</server-sockets>
<client-sockets>
<factory name="plain"
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketFactory" />
</client-sockets>
</sockets>
<helloworldserver>
<port>7666</port>
<bind>127.0.0.1</bind>
<helloworldhandler>
<connectiontimeout>360000</connectiontimeout>
</helloworldhandler>
</helloworldserver>
<altrmi-publisher>
<port>8666</port>
<bind>127.0.0.1</bind>
<socketObjectStreamHandler>
<connectiontimeout>360000</connectiontimeout>
</socketObjectStreamHandler>
<classRetrieverType>baseMobileClass</classRetrieverType>
</altrmi-publisher>
<altrmihelloworldserver>
<pub-name>helloworld</pub-name>
</altrmihelloworldserver>
</config>
1.1
jakarta-avalon-cornerstone/apps/demo/src/conf/avalon-altrmidemo-environment.xml
Index: avalon-altrmidemo-environment.xml
===================================================================
<?xml version="1.0"?>
<!--
README!
Basic config file that sets up context for server application.
-->
<environment>
<logs>
<category name="" target="default" priority="DEBUG" />
<category name="objectstorage" target="objectstorage-target"
priority="DEBUG" />
<log-target name="default" location="/logs/avalon-demo.log" />
<log-target name="objectstorage-target"
location="/logs/objectstorage.log" />
</logs>
<policy>
<grant code-base="file:${app.home}${/}SAR-INF${/}lib${/}*">
<permission class="java.security.AllPermission" />
</grant>
</policy>
</environment>
1.1
jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/altrmihelloworldserver/AltrmiHelloWorldServer.java
Index: AltrmiHelloWorldServer.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 file.
*/
package org.apache.avalon.cornerstone.demos.altrmihelloworldserver;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Hammant</a>
* @version 1.0
*/
public interface AltrmiHelloWorldServer
{
String ROLE =
"org.apache.avalon.cornerstone.demos.altrmihelloworldserver.AltrmiHelloWorldServer";
}
1.1
jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/altrmihelloworldserver/AltrmiHelloWorldServerImpl.java
Index: AltrmiHelloWorldServerImpl.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 file.
*/
package org.apache.avalon.cornerstone.demos.altrmihelloworldserver;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.phoenix.Block;
import org.apache.avalon.phoenix.BlockContext;
import org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServer;
import org.apache.commons.altrmi.server.AltrmiPublisher;
/**
* This demo Server applications shows the use of Altrmi to publish the
* HelloWorld block's API to clients over TCP/IP.
*
* HelloWorld would normally mount as just a HTTP hack showing a HTML
* HelloWorld message to suitably forgiving Browsers. With the
* addition of this block and suitably assembled, the HelloWorld
* application is given more life.
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Hammant</a>
* @version 1.0
*/
public class AltrmiHelloWorldServerImpl
extends AbstractLogEnabled
implements Block, AltrmiHelloWorldServer,
Composable, Configurable, Initializable
{
protected HelloWorldServer mHelloWorldServer;
protected AltrmiPublisher mAltrmiPublisher;
protected BlockContext m_context;
protected String publicationName;
public void initialize() throws Exception {
mAltrmiPublisher.publish(mHelloWorldServer, publicationName,
HelloWorldServer.class);
getLogger().info("HelloWorldServer published as " + publicationName);
// This is only to help newbies.....
System.out.println("AltrmiHelloWorld server running. Use
AltrmiHelloWorldTester to connect to it to test it");
}
public void contextualize( final Context context )
{
m_context = (BlockContext)context;
}
public void configure( final Configuration configuration )
throws ConfigurationException
{
publicationName = configuration.getChild("pub-name").getValue();
}
public void compose( final ComponentManager componentManager )
throws ComponentException
{
getLogger().info("SOAPHelloWorldServer.compose()");
mHelloWorldServer = (HelloWorldServer)componentManager.lookup(
HelloWorldServer.ROLE );
mAltrmiPublisher = (AltrmiPublisher)componentManager.lookup(
AltrmiPublisher.class.getName() );
}
}
1.1
jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/altrmihelloworldserver/AltrmiHelloWorldServerImpl.xinfo
Index: AltrmiHelloWorldServerImpl.xinfo
===================================================================
<?xml version="1.0"?>
<blockinfo>
<!-- section to describe block -->
<block>
<version>1.0</version>
</block>
<!-- services that are offered by this block -->
<services>
<service
name="org.apache.avalon.cornerstone.demos.altrmihelloworldserver.AltrmiHelloWorldServer"
version="1.0" />
</services>
<dependencies>
<dependency>
<service name="org.apache.commons.altrmi.server.AltrmiPublisher"
version="1.0"/>
</dependency>
<dependency>
<service
name="org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServer"
version="1.0"/>
</dependency>
</dependencies>
</blockinfo>
1.1
jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/altrmihelloworldserver/AltrmiHelloWorldServerTester.java
Index: AltrmiHelloWorldServerTester.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 file.
*/
package org.apache.avalon.cornerstone.demos.altrmihelloworldserver;
import org.apache.avalon.cornerstone.demos.helloworldserver.HelloWorldServer;
import org.apache.commons.altrmi.client.AltrmiHostContext;
import org.apache.commons.altrmi.client.AltrmiFactory;
import
org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
import org.apache.commons.altrmi.client.impl.ServerClassAltrmiFactory;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Hammant</a>
* @version 1.0
*/
public class AltrmiHelloWorldServerTester
{
protected HelloWorldServer mHelloWorldServer;
public static void main(String[] args) throws Exception
{
System.out.println("helloooo");
try {
System.out.println("1");
AltrmiHostContext arhc = new
SocketObjectStreamHostContext("127.0.0.1", 8666);
System.out.println("2");
ServerClassAltrmiFactory af = new ServerClassAltrmiFactory();
System.out.println("3");
af.setHostContext(arhc);
System.out.println("4");
HelloWorldServer hws = (HelloWorldServer) af.lookup("helloworld",
false);
System.out.println("5");
hws.setGreeting("Howdie Partner");
System.out.println("6");
System.out.println( "The greeting on the HelloWorldServer block
has been changed. Point your browser to http://localhost:7666 to see it." );
} catch (Throwable t) {
t.printStackTrace();
}
}
}
1.1
jakarta-avalon-cornerstone/apps/demo/src/manifest/altrmihelloworld-demo.mf
Index: altrmihelloworld-demo.mf
===================================================================
Manifest-Version: 1.0
Created-By: Apache Avalon Project
Name:
org/apache/avalon/cornerstone/demos/altrmihelloworldserver/AltrmiHelloWorldServerImpl.class
Avalon-Block: true
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>