You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/03/08 05:22:07 UTC
cvs commit: avalon-sandbox/merlin-jndi/src/java/org/apache/avalon/merlin/jndi ExceptionHelper.java Service.java ServiceFactory.java
mcconnell 2003/03/07 20:22:07
Added: merlin-jndi .cvsignore build.xml default.properties
merlin-jndi/src/etc project.mf
merlin-jndi/src/java/org/apache/avalon/merlin/jndi
ExceptionHelper.java Service.java
ServiceFactory.java
Log:
Initial commit of a Merlin to JNDI connector.
Revision Changes Path
1.1 avalon-sandbox/merlin-jndi/.cvsignore
Index: .cvsignore
===================================================================
build
dist
distributions
merlin
ant.properties
checkstyle.cache
velocity.log
project.xml
project.properties
maven.log
maven.xml
target
xdocs
1.1 avalon-sandbox/merlin-jndi/build.xml
Index: build.xml
===================================================================
<?xml version="1.0"?>
<!--
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.
@author Avalon Development Team
@version 1.0 12/03/2001
-->
<project name="merlin-jndi" default="install" basedir=".">
<property file="${basedir}/../ant.properties"/>
<property file="${basedir}/ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<property file="${basedir}/../default.properties"/>
<property file="${basedir}/default.properties"/>
<!-- Classpath for product -->
<path id="project.class.path">
<pathelement path="${java.class.path}"/>
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="main" depends="jar" description="Build the JNDI connector."/>
<target name="rebuild" depends="clean,main" description="Rebuild the project."/>
<target name="context" depends="dependencies">
<mkdir dir="${lib.dir}"/>
<uptodate property="uptodate" targetfile="${build.lib}/${jar.name}">
<srcfiles dir="${src.dir}">
<include name="**/*.*"/>
</srcfiles>
<srcfiles dir="${lib.dir}">
<include name="**/*.*"/>
</srcfiles>
</uptodate>
</target>
<target name="dependencies" depends="check-jndi"/>
<target name="flags">
<available property="jndi.present"
classname="javax.naming.spi.ObjectFactory"
classpathref="project.class.path" />
</target>
<target name="check-jndi" depends="flags" unless="jndi.present">
<echo>You must download the JNDI package and place it in the local ./lib directory. </echo>
</target>
<!-- Compiles the bootstrap source code -->
<target name="compile" depends="context"
description="Compiles the bootstrap source code" unless="uptodate" if="jndi.present" >
<echo message="compiling jndi connector"/>
<mkdir dir="${build.classes}"/>
<javac srcdir="${java.dir}"
destdir="${build.classes}"
debug="${build.debug}"
optimize="${build.optimize}"
deprecation="${build.deprecation}"
target="1.2">
<src path="${java.dir}" />
<classpath refid="project.class.path" />
</javac>
</target>
<!--
Creation of the jndi connector jar file.
-->
<target name="jar" depends="compile"
description="Generates the jar files" unless="uptodate">
<mkdir dir="${build.lib}"/>
<copy todir="${build.classes}">
<fileset dir="${java.dir}">
<include name="*.properties"/>
</fileset>
</copy>
<jar jarfile="${build.lib}/${jar.name}"
basedir="${build.classes}"
compress="${build.compress}" manifest="${src.dir}/etc/project.mf">
</jar>
</target>
<target name="install" depends="jar">
<mkdir dir="${local.repository}"/>
<copy toDir="${local.repository}" file="${build.lib}/${jar.name}"/>
</target>
<!-- Creates all the Javadocs -->
<target name="javadocs" depends="compile"
description="Generates the javadocs" unless="skip.javadocs">
<mkdir dir="${build.javadocs}"/>
<javadoc sourcepath="${java.dir}" packagenames="*,*.*"
destdir="${build.javadocs}" overview="${java.dir}/package.html">
<classpath refid="project.class.path" />
<doclet name="com.sun.tools.doclets.standard.Standard">
<param name="-author"/>
<param name="-version"/>
<param name="-doctitle" value="${Name}"/>
<param name="-windowtitle" value="${Name} API"/>
<param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
<param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
<param name="-bottom"
value=""Copyright © ${year} Apache Avalon Project. All Rights Reserved.""/>
</doclet>
</javadoc>
</target>
<!-- Cleans up build and distribution directories -->
<target name="clean" description="Cleans up the project">
<delete dir="${build.dir}" />
</target>
</project>
1.1 avalon-sandbox/merlin-jndi/default.properties
Index: default.properties
===================================================================
# -------------------------------------------------------------------
# B U I L D P R O P E R T I E S
# -------------------------------------------------------------------
# Specifies default property values
# Overridden by ../default.properties and all ant.properties
# Not user-editable; use ant.properties files instead
family=merlin
codename=merlin-jndi
name=${codename}
Name=Merlin JNDI COnnector
dir-name=merlin-jndi
version=1.0
package-version=1.0
year=2003
local.repository = ../lib
remote.repository = http://www.osm.net/repository
# --------------------------------------------------
# directory structure
# --------------------------------------------------
src.dir = src
java.dir = ${src.dir}/java
etc.dir = ${src.dir}/etc
lib.dir = lib
dist.dir = dist
# --------------------------------------------------
# Settings used to configure compile environment
build.debug = off
build.optimize = on
build.deprecation = on
build.compress = true
# location of intermediate products
build.dir = build
build.lib = ${build.dir}/lib
build.classes = ${build.dir}/classes
build.docs = ${build.dir}/docs
build.javadocs = ${build.docs}/api
# name of jar file
jar.name = ${name}-${package-version}.jar
1.1 avalon-sandbox/merlin-jndi/src/etc/project.mf
Index: project.mf
===================================================================
Manifest-Version: 1.0
Created-By: Apache Avalon
Extension-Name: merlin-jndi
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: ASF
Implementation-Version: 1.0
1.1 avalon-sandbox/merlin-jndi/src/java/org/apache/avalon/merlin/jndi/ExceptionHelper.java
Index: ExceptionHelper.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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", "Apache Avalon", "Avalon Framework" 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 apache@apache.org.
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 (INCLU-
DING, 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.avalon.merlin.jndi;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.StringTokenizer;
/**
* General utilities supporting the packaging of exception messages.
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
class ExceptionHelper
{
static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
/**
* Prints the exception to the standard error out together with
* cause statements.
* @param e the exception to print
*/
public static void printException( Throwable e )
{
printException( null, e );
}
/**
* Prints the exception to the standard error out together with
* cause statements.
* @param label label identifying the error
* @param e the exception to print
*/
public static void printException( String label, Throwable e )
{
printException( label, e, null );
}
/**
* Prints the exception to the standard error out together with
* source and cause statements.
* @param label label identifying the error
* @param e the exception to print
* @param source the source of the request
*/
public static void printException( String label, Throwable e, Object source )
{
printException( label, e, source, false );
}
/**
* Prints the exception to the standard error out together with
* source and cause statements.
* @param label label identifying the error
* @param e the exception to print
* @param source the source of the request
* @param trace boolean value inidication if a stack trace though be included
*/
public static void printException( String label, Throwable e, Object source, boolean trace )
{
if( e == null )
{
throw new NullPointerException( "throwable" );
}
java.io.PrintStream out = System.err;
synchronized( out )
{
out.println( "===================================================================" );
if( label != null )
{
out.println( "Message: " + label );
}
if( source != null )
{
out.println( "Source: " + source );
}
out.println( "Exception: " + e.toString() );
if( getCause( e ) != null )
{
printCause( out, e );
}
out.println( "===================================================================" );
if( trace )
{
Throwable root = getLastThrowable( e );
root.printStackTrace();
out.println( "===================================================================" );
}
}
}
/**
* Returns the exception and causal exceptions as a formatted string.
* @param message the header message
* @param e the exception
* @return String the formatting string
*/
public static String packException( final String message, final Throwable e )
{
return packException( message, e, true );
}
/**
* Returns the exception and causal exceptions as a formatted string.
* @param message the header message
* @param e the exception
* @return String the formatting string
*/
public static String packException( final String message, final Throwable e, boolean stack )
{
StringBuffer buffer = new StringBuffer();
buffer.append( "Message: " + message );
buffer.append( "\n===================================================================" );
if( e == null )
{
return buffer.toString();
}
else
{
buffer.append( "\n\nException: " + e.getClass().getName() );
buffer.append( "\n" + e.getMessage() );
packCause( buffer, getCause( e ) ).toString();
buffer.append( "\n\n===================================================================" );
}
Throwable root = getLastThrowable( e );
if(( root != null ) && stack )
{
String[] trace = captureStackTrace( root );
for( int i = 0; i < trace.length; i++ )
{
buffer.append( "\n" + trace[ i ] );
}
}
buffer.append( "\n===================================================================" );
return buffer.toString();
}
private static StringBuffer packCause( StringBuffer buffer, Throwable cause )
{
if( cause == null )
{
return buffer;
}
buffer.append( "\n\nCause: " + cause.getClass().getName() );
buffer.append( "\n" + cause.getMessage() );
return packCause( buffer, getCause( cause ) );
}
private static Throwable getLastThrowable( Throwable exception )
{
Throwable cause = getCause( exception );
if( cause != null )
{
return getLastThrowable( cause );
}
return exception;
}
private static Throwable getCause( Throwable exception )
{
if( exception == null )
{
throw new NullPointerException( "exception" );
}
try
{
Method method = exception.getClass().getMethod( "getCause", new Class[ 0 ] );
return (Throwable)method.invoke( exception, new Object[ 0 ] );
}
catch( Throwable e )
{
return null;
}
}
/**
* Captures the stack trace associated with this exception.
*
* @param throwable a <code>Throwable</code>
* @return an array of Strings describing stack frames.
*/
private static String[] captureStackTrace( final Throwable throwable )
{
final StringWriter sw = new StringWriter();
throwable.printStackTrace( new PrintWriter( sw, true ) );
return splitString( sw.toString(), LINE_SEPARATOR );
}
/**
* Splits the string on every token into an array of stack frames.
*
* @param string the string to split
* @param onToken the token to split on
* @return the resultant array
*/
private static String[] splitString( final String string, final String onToken )
{
final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
final String[] result = new String[ tokenizer.countTokens() ];
for( int i = 0; i < result.length; i++ )
{
result[ i ] = tokenizer.nextToken();
}
return result;
}
private static void printCause( java.io.PrintStream out, Throwable e )
{
Throwable cause = getCause( e );
out.println( "Cause: " + cause.toString() );
if( getCause( cause ) != null )
{
printCause( out, cause );
}
}
}
1.1 avalon-sandbox/merlin-jndi/src/java/org/apache/avalon/merlin/jndi/Service.java
Index: Service.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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", "Apache Avalon", "Avalon Framework" 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 apache@apache.org.
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 (INCLU-
DING, 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.avalon.merlin.jndi;
import javax.naming.*;
/**
* A referenceable service.
*/
public class Service implements Referenceable
{
String m_service;
public Service( String service )
{
m_service = service;
}
public Reference getReference() throws NamingException
{
return new Reference(
Service.class.getName(),
new StringRefAddr("service", m_service ),
ServiceFactory.class.getName(),
null );
}
public String toString() {
return m_service;
}
}
1.1 avalon-sandbox/merlin-jndi/src/java/org/apache/avalon/merlin/jndi/ServiceFactory.java
Index: ServiceFactory.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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", "Apache Avalon", "Avalon Framework" 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 apache@apache.org.
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 (INCLU-
DING, 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.avalon.merlin.jndi;
import javax.naming.*;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Hashtable;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* This is an object factory that when given a reference for a service
* object, will create an instance of the corresponding service.
*/
public class ServiceFactory implements ObjectFactory
{
private static final String MERLIN_KERNEL_LOADER_CLASSNAME =
"org.apache.avalon.merlin.kernel.impl.DefaultKernelLoader";
private Object m_kernel;
/**
* Return a service instance if the supplied object is a reference
* with the classname corresponding to the Service class, else null.
*
*/
public Object getObjectInstance(
Object object, final Name name, Context context, final Hashtable environment ) throws Exception
{
System.out.println("object: " + object );
System.out.println("name: " + name );
System.out.println("context: " + context );
System.out.println("environment: " + environment );
if( m_kernel == null )
{
m_kernel = bootstrapKernel( object );
}
return m_kernel;
}
private Object bootstrapKernel( Object object ) throws Exception
{
try
{
if( object == null )
{
throw new Exception( "object");
}
if( !( object instanceof Reference ) )
{
throw new Exception( "Cannot resolve JNDI bootstrap properties.");
}
Reference reference = (Reference) object;
File home = getFile( "home", reference );
File system = getFile( "system", reference );
File kernel = getFile( "kernel", reference );
URL block = getURL( "block", reference );
System.out.println("HOME: " + home );
System.out.println("SYSTEM: " + system );
System.out.println("BLOCK: " + block );
System.out.println("KERNEL: " + kernel );
File config = null;
try
{
config = getFile( "config", reference );
System.out.println("CONFIG: " + config );
}
catch( Throwable e )
{
// optional
}
String debug = "INFO";
try
{
debug = getString( "debug", reference );
System.out.println("DEBUG: " + debug );
}
catch( Throwable e )
{
// optional
}
File lib = new File( system, "lib" );
File shared = new File( lib, "shared" );
File sys = new File( lib, "system" );
URL[] targets = getJarFiles( shared );
URL[] libs = getJarFiles( sys, targets );
ClassLoader current = Thread.currentThread().getContextClassLoader();
ClassLoader common = new URLClassLoader( targets, current );
ClassLoader internal = new URLClassLoader( libs, current );
Map map = new Hashtable();
//
// build the kernel loader context
//
map.put( "urn:merlin:classloader.common", common );
map.put( "urn:merlin:classloader.system", internal);
map.put( "urn:merlin:home", home );
map.put( "urn:merlin:system", system );
map.put( "urn:merlin:kernel.profile", kernel );
map.put( "urn:merlin:block.url", block );
map.put( "urn:merlin:debug", debug );
if( config != null )
{
map.put( "urn:merlin:block.config", config.toURL() );
}
return loadKernel( internal, map );
}
catch( Throwable e )
{
final String error =
"Unexpected error while bootstrapping the kernel.";
final String message = ExceptionHelper.packException( error, e );
throw new Exception( message );
}
}
private Object loadKernel( ClassLoader loader, Map map )
{
Thread.currentThread().setContextClassLoader( loader );
Object kernelLoader = null;
Class clazz;
//
// load the kernel loader class from the supplied classloader
//
try
{
clazz = loader.loadClass( MERLIN_KERNEL_LOADER_CLASSNAME );
}
catch( Throwable e )
{
final String error =
"Internal error during loader class creation.";
throw new RuntimeException( error, e );
}
//
// instantiate the loader
//
try
{
Constructor constructor = clazz.getConstructor( new Class[0] );
kernelLoader = constructor.newInstance( new Object[0] );
}
catch( Throwable e )
{
final String error =
"Internal error during loader instantiation.";
throw new RuntimeException( error, e );
}
//
// create the kernel instance
//
try
{
Method method = kernelLoader.getClass().getMethod( "build", new Class[]{ Map.class } );
return method.invoke( kernelLoader, new Object[]{ map } );
}
catch( Throwable e )
{
final String error =
"Internal error during kernel resolution.";
throw new RuntimeException( error, e );
}
}
private static URL[] getJarFiles( File base )
{
if( base == null )
{
throw new NullPointerException( "base" );
}
return getJarFiles( base, new URL[0] );
}
private static URL[] getJarFiles( File base, URL[] urls )
{
if( base == null )
{
throw new NullPointerException( "base" );
}
List list = new ArrayList();
for( int i=0; i<urls.length; i++ )
{
list.add( urls[i] );
}
populateJars( list, base );
return (URL[]) list.toArray( new URL[0] );
}
private static void populateJars( List list, File base )
{
if( list == null )
{
throw new NullPointerException( "list" );
}
if( base == null )
{
throw new NullPointerException( "base" );
}
try
{
File[] files = base.listFiles();
for( int i=0; i<files.length; i++ )
{
File file = files[i];
if( file.getName().endsWith( ".jar" ) )
{
list.add( file.toURL() );
}
}
}
catch( Throwable e )
{
final String error =
"Unexpected error while scanning files in shared directory: " + base;
throw new RuntimeException( error, e );
}
}
private File getFile( String key, Reference reference ) throws Exception
{
RefAddr ref = reference.get( key );
if( ref == null )
{
throw new Exception( "Missing resolve " + key + " ref.");
}
String value = (String) ref.getContent();
if( value == null )
{
throw new Exception( "Null " + key + " ref value.");
}
return new File( value );
}
private URL getURL( String key, Reference reference ) throws Exception
{
RefAddr ref = reference.get( key );
if( ref == null )
{
throw new Exception( "Missing resolve " + key + " ref.");
}
String value = (String) ref.getContent();
if( value == null )
{
throw new Exception( "Null " + key + " ref value.");
}
return new URL( value );
}
private String getString( String key, Reference reference ) throws Exception
{
RefAddr ref = reference.get( key );
if( ref == null )
{
throw new Exception( "Missing resolve " + key + " ref.");
}
String value = (String) ref.getContent();
if( value == null )
{
throw new Exception( "Null " + key + " ref value.");
}
return value;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org
Re: restructuring Merlin
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-03-08 at 11:35, Leo Simons wrote:
>
> can we congratulate on going top-level yet?
Not just yet. But I think the issue will be resolved in the next couple
of days.
> cheers!
>
> - Leo
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: restructuring Merlin
Posted by Leo Simons <le...@apache.org>.
Jason van Zyl wrote:
> On Sat, 2003-03-08 at 09:37, Leo Simons wrote:
>
>>Stephen McConnell wrote:
>>
>>> if its also
>>>acceptable that I move these projects to Maven.
>>>
>>>Any opinions?
>>
>>+1
>
>
> I would be glad to help if you're having any troubles. Most of nasty
> problems will go away in beta-9 as I finally have ClassWorlds integrated
> so that each plugin gets it's own separate classloader which makes life
> much easier. A road map for Maven will be released on Monday part of
can we congratulate on going top-level yet?
cheers!
- Leo
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: restructuring Merlin
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Jason van Zyl wrote, On 08/03/2003 17.30:
> On Sat, 2003-03-08 at 09:37, Leo Simons wrote:
>
>>Stephen McConnell wrote:
>>
>>> if its also
>>>acceptable that I move these projects to Maven.
>>>
>>>Any opinions?
>>
>>+1
These projects are sandbox projects.
The issues I had with using Maven for Avalon *now* are not applicable
IMO in the sandbox; on the contrary I welcome any experimentation there
that can make us understand more things.
NOTE: Centipede has now been proposed to Ant, and we are in the process
of friutfully discussing on how to better serve Ant.
...
> A road map for Maven will be released on Monday part of
> which will be an outline Maven being turned into an Avalon component.
Avalon should use as much things that relate to its codebase as
possible. This is one of the reasons why I strongly favor using Cocoon
(Forrest) for the doc generation. And the reason why I personally
encourage Stephen to make Merlin use Maven.
Add to this that I am a Forrest developer, and that I can't wait to have
Forrest work nicely with Maven (yes, I do want to get to a single HTML2
DTD), you have my
+1
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: restructuring Merlin
Posted by Jason van Zyl <ja...@zenplex.com>.
On Sat, 2003-03-08 at 09:37, Leo Simons wrote:
> Stephen McConnell wrote:
> > if its also
> > acceptable that I move these projects to Maven.
> >
> > Any opinions?
>
> +1
I would be glad to help if you're having any troubles. Most of nasty
problems will go away in beta-9 as I finally have ClassWorlds integrated
so that each plugin gets it's own separate classloader which makes life
much easier. A road map for Maven will be released on Monday part of
which will be an outline Maven being turned into an Avalon component.
Soon after I hope that beta-9 will be released and with the classloader
isolation Maven should be _much_ easier to live with.
> - Leo
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: restructuring Merlin
Posted by Leo Simons <le...@apache.org>.
Stephen McConnell wrote:
> if its also
> acceptable that I move these projects to Maven.
>
> Any opinions?
+1
- Leo
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
restructuring Merlin
Posted by Stephen McConnell <mc...@apache.org>.
Taking into account the amount of work implied by the following two
emails (avalon jar repository + Merlin restructuring), I'm would like to
put forward a proposal which would set the groundwork for justifying this.
http://marc.theaimsgroup.com/?l=avalon-dev&m=104712140011322&w=2
http://marc.theaimsgroup.com/?l=avalon-dev&m=104712113711184&w=2
I'm currently spending too much time maintaining two build environments
- Ant and Maven. The Ant environment is maintained only to support the
content over on Avalon. On my local machine I'm using Maven builds for
everything (and as a result my internal processes are much more reliable
and better structured). I'm willing to migrate the current Merlin,
Assembly, Meta content under an umbrella Merlin project if its also
acceptable that I move these projects to Maven.
Any opinions?
Cheers, Steve.
--
Stephen J. McConnell
mailto:mcconnell@apache.org
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: cvs commit: avalon-sandbox/merlin-jndi/
Posted by Leo Simons <le...@apache.org>.
Stephen McConnell wrote:
>> what does this do?
>
> It a JNDI ObjectFactory that lets you access a new instance of the
> Merlin Kernel from a JNDI context.
so IIUC it is of no real use outside merlin?
>> I would like to change (or set up) informal sandbox policy: before
>> you put a new subproject in sandbox, write up a short proposal for
>> the subproject, so everyone knows the project is there and what it
>> does. And you'll have to lobby against a -1 of course.
>
> I agree that new projects should be discussed before launching of on
> a sandbox commit. However, I do think that the notion of "project"
> should be qualified.
you have a suggestion? :D
> If the structural breakout is problematic it could be repackage but
> this would be nothing more that moving deck-chairs.
yes please :D
Makes things clearer.
it'd be my preference to keep all code used by one container inside a
single base directory until it actually becomes used in another
container. Like moving the phoenix dependencies into avalon-phoenix,
merlin-jndi classes into avalon-sandbox/merlin, assembly classes into
avalon-sandbox/merlin and container/lifecycle out of avalon-fortress
(because it is in use in merlin).
This makes it clearer at a glance what the actual organisation of a
project is. Another way to put it: consider the (hypothetical) case
where we decide we're going to base "spearhead" on merlin/assembly. We
might want an avalon-spearhead repository. Content of that as it stands
now would be sandbox/assembly, sandbox/merlin-*, and I believe also
sandbox/meta or sandbox/info.
All those packages are in fact a single "project". The fact they could
be used independently of each other in theory doesn't change that. I can
point at many packages in phoenix that are completely independent of
everything else, for example.
The single thing that looks to be an exception (besides the merlin stuff
in sandbox), instrument-*, is not! Just look at the gump dependency tree
to see why :D
cheers!
- Leo
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: cvs commit: avalon-sandbox/merlin-jndi/
Posted by Stephen McConnell <mc...@apache.org>.
Noel J. Bergman wrote:
>Stephen,
>
>
>
>>It a JNDI ObjectFactory that lets you access a new instance of the
>>Merlin Kernel from a JNDI context.
>>
>>
>
>
>
>> Context initCtx = new InitialContext();
>> Context envCtx = (Context) initCtx.lookup("java:comp/env");
>> Kenel kernel = envCtx.lookup("merlin/ServiceFactory");
>>
>>
>
>
>
>>Naturally this needs to be backed by a JNDI resource declaration as
>>per the Servlet 2.3 spec (or alternative JNDI configuration). That's
>>where parameters such as the Merlin system and block definition URLs
>>are declared.
>>
>>
>
>Do you have any interest in seeing org.apache.naming moved out of Tomcat
>into a common project for others, e.g., Avalon, James, and others, to use?
>
>
Yes.
I spend some time going over the Tomcat code partly to get a validation
of the Merlin/JNDI connection up and running inside tomcat but also
because of the related discussions on this topic over on the James list.
While I don't have a real deep grip on the content of the
org.apche.naming package - I do have the impression that this may be a
starting point for the addition of handlers support service URLs.
Cheers, Steve.
> --- Noel
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
>For additional commands, e-mail: dev-help@avalon.apache.org
>
>
>
>
>
--
Stephen J. McConnell
mailto:mcconnell@apache.org
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
RE: cvs commit: avalon-sandbox/merlin-jndi/
Posted by "Noel J. Bergman" <no...@devtech.com>.
Stephen,
> It a JNDI ObjectFactory that lets you access a new instance of the
> Merlin Kernel from a JNDI context.
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> Kenel kernel = envCtx.lookup("merlin/ServiceFactory");
> Naturally this needs to be backed by a JNDI resource declaration as
> per the Servlet 2.3 spec (or alternative JNDI configuration). That's
> where parameters such as the Merlin system and block definition URLs
> are declared.
Do you have any interest in seeing org.apache.naming moved out of Tomcat
into a common project for others, e.g., Avalon, James, and others, to use?
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: cvs commit: avalon-sandbox/merlin-jndi/
Posted by Stephen McConnell <mc...@apache.org>.
Leo Simons wrote:
> what does this do?
It a JNDI ObjectFactory that lets you access a new instance of the
Merlin Kernel from a JNDI context.
For example, a servlet could do the following:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Kenel kernel = envCtx.lookup("merlin/ServiceFactory");
Naturally this needs to be backed by a JNDI resource declaration as
per the Servlet 2.3 spec (or alternative JNDI configuration). That's
where parameters such as the Merlin system and block definition URLs
are declared.
>
> I would like to change (or set up) informal sandbox policy: before
> you put a new subproject in sandbox, write up a short proposal for
> the subproject, so everyone knows the project is there and what it
> does. And you'll have to lobby against a -1 of course.
I agree that new projects should be discussed before launching of on
a sandbox commit. However, I do think that the notion of "project"
should be qualified. For example, the merlin-jndi package reflects
good structuring and separation of concerns within and across the
Merlin system. It's all part of the Merlin "project" (from a
functional perspective).
If the structural breakout is problematic it could be repackage but
this would be nothing more that moving deck-chairs. The current
Merlin suite presently includes:
merlin core merlin implementation
merlin-spi Merlin Service Provider Interface API
merlin-jndi Merlin JNDI Connector
merlin-bootstrap Merlin CLI loader
Cheers, Steve.
--
Stephen J. McConnell
mailto:mcconnell@apache.orghttp://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: cvs commit: avalon-sandbox/merlin-jndi/
Posted by Leo Simons <le...@apache.org>.
what does this do?
I would like to change (or set up) informal sandbox policy: before you
put a new subproject in sandbox, write up a short proposal for the
subproject, so everyone knows the project is there and what it does. And
you'll have to lobby against a -1 of course.
cheers,
- Leo
mcconnell@apache.org wrote:
> Log:
> Initial commit of a Merlin to JNDI connector.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org