hammant 2003/01/19 06:22:45 Modified: altrmi/src/java/org/apache/excalibur/altrmi/blocks/publishing AbstractPublisher.java altrmi/src/java/org/apache/excalibur/altrmi/server ServerException.java altrmi/src/java/org/apache/excalibur/altrmi/server/impl/http CustomHttpServer.java altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket AbstractCompleteSocketStreamServer.java Added: altrmi/src/java/org/apache/excalibur/altrmi/common AltrmiRuntimeException.java Log: Basic client and server dependencies on A-F removed. Revision Changes Path 1.4 +1 -1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/blocks/publishing/AbstractPublisher.java Index: AbstractPublisher.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/blocks/publishing/AbstractPublisher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractPublisher.java 5 Jan 2003 23:24:08 -0000 1.3 +++ AbstractPublisher.java 19 Jan 2003 14:22:45 -0000 1.4 @@ -1 +1 @@ -/*
* 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.excalibur.altrmi.blocks.publishing; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.StringTokenizer; import java.util.Vector; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Startable; 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.context.Context; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.excalibur.altrmi.common.MethodRequest; import org.apache.excalibur.altrmi.server.Authenticator; import org.apache.excalibur.altrmi.server.Publisher; import org.apache.excalibur.altrmi.server.ClassRetriever; import org.apache.excalibur.altrmi.server.MethodInvocationHandler; import org.apache.excalibur.altrmi.server.PublicationDescription; import org.apache.excalibur.altrmi.server.PublicationException; import org.apache.excalibur.altrmi.server.impl.AbstractServer; import org.apache.excalibur.altrmi.server.impl.classretrievers.AbstractDynamicGeneratorClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.BcelDynamicGeneratorClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.NoClassRetriever; import org.apache.avalon.framework.context.ContextException; /** * Abstract Publisher. * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @author Thomas Kiesgen * @version $Revision$ */ public abstract class AbstractPublisher extends AbstractLogEnabled implements Publisher, Startable, Serviceable, Contextualizable, Configurable, Initializable { private AbstractServer m_abstractServer; private ClassRetriever m_classRetriever; private Authenticator m_altrmiAuthenticator; protected File m_baseDirectory; private boolean m_isDynamicPublisher = false; /** * * @param configuration * @throws ConfigurationException */ public void configure( Configuration configuration ) throws ConfigurationException { String classRetrieverType = configuration.getChild( "classRetrieverType" ).getValue(); if( classRetrieverType.equals( "jarFile" ) ) { StringTokenizer st = new StringTokenizer( configuration.getChild( "generatedClassJarURLs" ).getValue(), "," ); Vector vector = new Vector(); while( st.hasMoreTokens() ) { try { String url = st.nextToken(); if( url.startsWith( "./" ) ) { File file = new File( m_baseDirectory, url.substring( 2, url.length() ) ); vector.add( file.toURL() ); } else { vector.add( new URL( url ) ); } } catch( MalformedURLException e ) { getLogger() .debug( "Can't create URL from config element 'generatedClassJarURLs'", e ); } } URL[] urls = new URL[ vector.size() ]; vector.copyInto( urls ); m_classRetriever = new JarFileClassRetriever( urls ); } else if( classRetrieverType.equals( "none" ) ) { m_classRetriever = new NoClassRetriever(); } else if( classRetrieverType.equals( "bcel" ) ) { AbstractDynamicGeneratorClassRetriever generator = new BcelDynamicGeneratorClassRetriever(); File classGenDir = new File( m_baseDirectory, configuration.getChild( "classGenDir" ).getValue( "" ) ); generator.setClassGenDir( classGenDir.getAbsolutePath() ); m_classRetriever = generator; m_isDynamicPublisher = true; getLogger().debug( "setting classgen dir for generator to " + classGenDir.getAbsolutePath() ); getLogger().debug( "setting class retriever to bcel dynamic generator" ); } else { throw new ConfigurationException( "classRetrieverType must be 'bcel', 'jarFile' or 'none'" ); } } /** * contextualize as per Contextualizable interface * @param context */ public void contextualize( final Context context ) throws ContextException { m_baseDirectory = ( File ) context.get("app.home"); } /** * Service as per Serviceable interface * @param manager a service manager * @throws ServiceException if a problem during servicing * @phoenix:dependency name="org.apache.excalibur.altrmi.server.Authenticator" */ public void service( ServiceManager manager ) throws ServiceException { m_altrmiAuthenticator = (Authenticator)manager.lookup( Authenticator.class.getName() ); } /** * initialize as per Initializable interface * @throws Exception */ public void initialize() throws Exception { m_abstractServer.setClassRetriever( m_classRetriever ); m_abstractServer.setAuthenticator( m_altrmiAuthenticator ); } /** * * @param implementation * @param asName * @param interfaceToExpose * @throws PublicationException */ public void publish( Object implementation, String asName, Class interfaceToExpose ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Publishing object [as: " + asName + ", impl: " + implementation + ", interf: "+ interfaceToExpose + "]" ); if( m_isDynamicPublisher ) { ( ( AbstractDynamicGeneratorClassRetriever ) m_classRetriever ).generate( asName, interfaceToExpose, this.getClass().getClassLoader() ); if( getLogger().isDebugEnabled() ) { getLogger().debug( "generated dynamic proxy for published interface " + asName ); } } m_abstractServer.publish( implementation, asName, interfaceToExpose ); } /** * Publish an service * @param implementation * @param asName * @param publicationDescription * @throws PublicationException */ public void publish( Object implementation, String asName, PublicationDescription publicationDescription ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Publishing object [as: " + asName + ", impl: " + implementation + "]" ); if( m_isDynamicPublisher ) { ( ( AbstractDynamicGeneratorClassRetriever ) m_classRetriever ).generate( asName, publicationDescription, this.getClass().getClassLoader() ); if( getLogger().isDebugEnabled() ) { getLogger().debug( "generated dynamic proxy for published interface " + asName ); } } m_abstractServer.publish( implementation, asName, publicationDescription ); } /** * * @param object * @param asName * @throws PublicationException */ public void unPublish( Object object, String asName ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Unpublishing object [nane: " + asName + ", impl: " + object + "]" ); m_abstractServer.unPublish( object, asName ); } /** * * @param object * @param asName * @param o1 * @throws PublicationException */ public void replacePublished( Object object, String asName, Object o1 ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Replacing published object [nane: " + asName + ", existing: " + object + ", new: " + o1 + "]" ); m_abstractServer.replacePublished( object, asName, o1 ); } /** * * @throws Exception */ public void start() throws Exception { m_abstractServer.start(); } /** * * @throws Exception */ public void stop() throws Exception { m_abstractServer.stop(); } /** * * @param request * @param publishedName * @return */ public MethodInvocationHandler getMethodInvocationHandler( MethodRequest request, String publishedName ) { return m_abstractServer.getMethodInvocationHandler( request, publishedName ); } /** * * @param publishedName * @return */ public MethodInvocationHandler getMethodInvocationHandler(String publishedName) { return m_abstractServer.getMethodInvocationHandler( publishedName ); } /** * * @return */ protected AbstractServer getAbstractServer() { return m_abstractServer; } /** * * @param abstractServer */ protected void setAbstractServer( AbstractServer abstractServer ) { m_abstractServer = abstractServer; } } \ No newline at end of file +/* * 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.excalibur.altrmi.blocks.publishing; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.StringTokenizer; import java.util.Vector; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Startable; 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.context.Context; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.excalibur.altrmi.common.MethodRequest; import org.apache.excalibur.altrmi.server.Authenticator; import org.apache.excalibur.altrmi.server.Publisher; import org.apache.excalibur.altrmi.server.ClassRetriever; import org.apache.excalibur.altrmi.server.MethodInvocationHandler; import org.apache.excalibur.altrmi.server.PublicationDescription; import org.apache.excalibur.altrmi.server.PublicationException; import org.apache.excalibur.altrmi.server.impl.AbstractServer; import org.apache.excalibur.altrmi.server.impl.LogEnabledServerMonitor; import org.apache.excalibur.altrmi.server.impl.classretrievers.AbstractDynamicGeneratorClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.BcelDynamicGeneratorClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.JarFileClassRetriever; import org.apache.excalibur.altrmi.server.impl.classretrievers.NoClassRetriever; import org.apache.avalon.framework.context.ContextException; /** * Abstract Publisher. * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @author Thomas Kiesgen * @version $Revision$ */ public abstract class AbstractPublisher extends AbstractLogEnabled implements Publisher, Startable, Serviceable, Contextualizable, Configurable, Initializable { private AbstractServer m_abstractServer; private ClassRetriever m_classRetriever; private Authenticator m_altrmiAuthenticator; protected File m_baseDirectory; private boolean m_isDynamicPublisher = false; /** * * @param configuration * @throws ConfigurationException */ public void configure( Configuration configuration ) throws ConfigurationException { String classRetrieverType = configuration.getChild( "classRetrieverType" ).getValue(); if( classRetrieverType.equals( "jarFile" ) ) { StringTokenizer st = new StringTokenizer( configuration.getChild( "generatedClassJarURLs" ).getValue(), "," ); Vector vector = new Vector(); while( st.hasMoreTokens() ) { try { String url = st.nextToken(); if( url.startsWith( "./" ) ) { File file = new File( m_baseDirectory, url.substring( 2, url.length() ) ); vector.add( file.toURL() ); } else { vector.add( new URL( url ) ); } } catch( MalformedURLException e ) { getLogger() .debug( "Can't create URL from config element 'generatedClassJarURLs'", e ); } } URL[] urls = new URL[ vector.size() ]; vector.copyInto( urls ); m_classRetriever = new JarFileClassRetriever( urls ); } else if( classRetrieverType.equals( "none" ) ) { m_classRetriever = new NoClassRetriever(); } else if( classRetrieverType.equals( "bcel" ) ) { AbstractDynamicGeneratorClassRetriever generator = new BcelDynamicGeneratorClassRetriever(); File classGenDir = new File( m_baseDirectory, configuration.getChild( "classGenDir" ).getValue( "" ) ); generator.setClassGenDir( classGenDir.getAbsolutePath() ); m_classRetriever = generator; m_isDynamicPublisher = true; getLogger().debug( "setting classgen dir for generator to " + classGenDir.getAbsolutePath() ); getLogger().debug( "setting class retriever to bcel dynamic generator" ); } else { throw new ConfigurationException( "classRetrieverType must be 'bcel', 'jarFile' or 'none'" ); } } /** * contextualize as per Contextualizable interface * @param context */ public void contextualize( final Context context ) throws ContextException { m_baseDirectory = ( File ) context.get("app.home"); } /** * Service as per Serviceable interface * @param manager a service manager * @throws ServiceException if a problem during servicing * @phoenix:dependency name="org.apache.excalibur.altrmi.server.Authenticator" */ public void service( ServiceManager manager ) throws ServiceException { m_altrmiAuthenticator = (Authenticator)manager.lookup( Authenticator.class.getName() ); } /** * initialize as per Initializable interface * @throws Exception */ public void initialize() throws Exception { m_abstractServer.setClassRetriever( m_classRetriever ); m_abstractServer.setAuthenticator( m_altrmiAuthenticator ); } /** * * @param implementation * @param asName * @param interfaceToExpose * @throws PublicationException */ public void publish( Object implementation, String asName, Class interfaceToExpose ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Publishing object [as: " + asName + ", impl: " + implementation + ", interf: "+ interfaceToExpose + "]" ); if( m_isDynamicPublisher ) { ( ( AbstractDynamicGeneratorClassRetriever ) m_classRetriever ).generate( asName, interfaceToExpose, this.getClass().getClassLoader() ); if( getLogger().isDebugEnabled() ) { getLogger().debug( "generated dynamic proxy for published interface " + asName ); } } m_abstractServer.publish( implementation, asName, interfaceToExpose ); } /** * Publish an service * @param implementation * @param asName * @param publicationDescription * @throws PublicationException */ public void publish( Object implementation, String asName, PublicationDescription publicationDescription ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Publishing object [as: " + asName + ", impl: " + implementation + "]" ); if( m_isDynamicPublisher ) { ( ( AbstractDynamicGeneratorClassRetriever ) m_classRetriever ).generate( asName, publicationDescription, this.getClass().getClassLoader() ); if( getLogger().isDebugEnabled() ) { getLogger().debug( "generated dynamic proxy for published interface " + asName ); } } m_abstractServer.publish( implementation, asName, publicationDescription ); } /** * * @param object * @param asName * @throws PublicationException */ public void unPublish( Object object, String asName ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Unpublishing object [nane: " + asName + ", impl: " + object + "]" ); m_abstractServer.unPublish( object, asName ); } /** * * @param object * @param asName * @param o1 * @throws PublicationException */ public void replacePublished( Object object, String asName, Object o1 ) throws PublicationException { if( getLogger().isDebugEnabled() ) getLogger().debug( "Replacing published object [nane: " + asName + ", existing: " + object + ", new: " + o1 + "]" ); m_abstractServer.replacePublished( object, asName, o1 ); } /** * * @throws Exception */ public void start() throws Exception { m_abstractServer.start(); } /** * * @throws Exception */ public void stop() throws Exception { m_abstractServer.stop(); } /** * * @param request * @param publishedName * @return */ public MethodInvocationHandler getMethodInvocationHandler( MethodRequest request, String publishedName ) { return m_abstractServer.getMethodInvocationHandler( request, publishedName ); } /** * * @param publishedName * @return */ public MethodInvocationHandler getMethodInvocationHandler(String publishedName) { return m_abstractServer.getMethodInvocationHandler( publishedName ); } /** * * @return */ protected AbstractServer getAbstractServer() { return m_abstractServer; } /** * * @param abstractServer */ protected void setAbstractServer( AbstractServer abstractServer ) { m_abstractServer = abstractServer; LogEnabledServerMonitor sm = new LogEnabledServerMonitor(); sm.enableLogging(getLogger()); m_abstractServer.setServerMonitor(sm); } } \ No newline at end of file 1.3 +15 -4 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/ServerException.java Index: ServerException.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/ServerException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServerException.java 11 Jan 2003 16:10:08 -0000 1.2 +++ ServerException.java 19 Jan 2003 14:22:45 -0000 1.3 @@ -7,7 +7,6 @@ */ package org.apache.excalibur.altrmi.server; -import org.apache.avalon.framework.CascadingException; /** * Class ServerException @@ -16,9 +15,11 @@ * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @version $Revision$ */ -public class ServerException extends CascadingException +public class ServerException extends Exception { + Throwable m_throwable; + /** * Construct an ServerException with a message * @@ -41,8 +42,18 @@ */ public ServerException(String message, Throwable throwable) { - super(message, throwable); + super(message); + m_throwable = throwable; } + /** + * Retrieve root cause of the exception. + * + * @return the root cause + */ + public final Throwable getCause() + { + return m_throwable; + } } 1.5 +1 -2 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/http/CustomHttpServer.java Index: CustomHttpServer.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/http/CustomHttpServer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- CustomHttpServer.java 19 Jan 2003 11:10:01 -0000 1.4 +++ CustomHttpServer.java 19 Jan 2003 14:22:45 -0000 1.5 @@ -7,7 +7,6 @@ */ package org.apache.excalibur.altrmi.server.impl.http; -import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.excalibur.altrmi.server.ServerException; import org.apache.excalibur.altrmi.server.impl.AbstractServer; import org.apache.excalibur.altrmi.server.impl.ServerCustomStreamReadWriter; 1.12 +4 -4 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java Index: AbstractCompleteSocketStreamServer.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- AbstractCompleteSocketStreamServer.java 19 Jan 2003 11:10:01 -0000 1.11 +++ AbstractCompleteSocketStreamServer.java 19 Jan 2003 14:22:45 -0000 1.12 @@ -14,7 +14,7 @@ import org.apache.excalibur.altrmi.server.impl.AbstractServer; import org.apache.excalibur.altrmi.server.impl.ServerStreamReadWriter; import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter; -import org.apache.avalon.framework.CascadingRuntimeException; +import org.apache.excalibur.altrmi.common.AltrmiRuntimeException; /** @@ -150,14 +150,14 @@ { setState(SHUTTINGDOWN); - + try { m_serverSocket.close(); } catch ( IOException ioe ) { - throw new CascadingRuntimeException("Error stopping Complete Socket server", ioe); + throw new AltrmiRuntimeException("Error stopping Complete Socket server", ioe); } killAllConnections(); getThread().interrupt(); 1.1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/AltrmiRuntimeException.java Index: AltrmiRuntimeException.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-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 "Jakarta", "Avalon", and "Apache Software Foundation" * 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", * 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/>. */ package org.apache.excalibur.altrmi.common; /** * RumtimeException with cascade features. * Allows recording of nested exceptions. * * @author <a href="mailto:avalon-dev@jakarta.apache.org">Avalon Development Team</a> */ public class AltrmiRuntimeException extends RuntimeException { private final Throwable m_throwable; /** * Construct a new <code>CascadingRuntimeException</code> instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AltrmiRuntimeException( final String message, final Throwable throwable ) { super( message ); m_throwable = throwable; } /** * Retrieve root cause of the exception. * * @return the root cause */ public final Throwable getCause() { return m_throwable; } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>