You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2003/01/25 16:47:19 UTC
cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/assembler Assembler.java AssemblyException.java Resources.properties
hammant 2003/01/25 07:47:18
Modified: . build.xml
src/java/org/apache/avalon/phoenix BlockEvent.java
src/java/org/apache/avalon/phoenix/components
ContainerConstants.java
src/java/org/apache/avalon/phoenix/components/application
BlockEntry.java BlockResourceProvider.java
DefaultApplication.java DefaultBlockContext.java
DependencyGraph.java ExportHelper.java
ListenerResourceProvider.java ListenerSupport.java
src/java/org/apache/avalon/phoenix/components/deployer
DefaultDeployer.java
src/java/org/apache/avalon/phoenix/components/embeddor
DefaultEmbeddor.java EmbeddorEntry.java
src/java/org/apache/avalon/phoenix/components/kernel
DefaultApplicationContext.java DefaultKernel.java
SarEntry.java
src/java/org/apache/avalon/phoenix/components/kernel/beanshell
BeanShellKernelProxy.java
src/java/org/apache/avalon/phoenix/components/util
ComponentInfoConverter.java
src/java/org/apache/avalon/phoenix/containerkit/verifier
package.html
src/java/org/apache/avalon/phoenix/interfaces
ApplicationContext.java Installation.java
Kernel.java
src/java/org/apache/avalon/phoenix/metadata
BlockListenerMetaData.java
src/java/org/apache/avalon/phoenix/tools/metagenerate
MetaGenerateTask.java MxinfoHelper.java
src/java/org/apache/avalon/phoenix/tools/tasks Sar.java
src/java/org/apache/avalon/phoenix/tools/verifier
SarVerifier.java
src/test/org/apache/avalon/phoenix/components/application/test
MockApplicationContext.java
src/test/org/apache/avalon/phoenix/test
AbstractContainerTestCase.java
Added: src/java/org/apache/avalon/phoenix/components/deployer
PhoenixComponentFactory.java
src/java/org/apache/avalon/phoenix/components/util
ComponentMetaDataConverter.java
src/java/org/apache/avalon/phoenix/components/assembler
Assembler.java AssemblyException.java
Resources.properties
Log:
Merging in of autoassembly branch.
Revision Changes Path
1.195 +1 -0 jakarta-avalon-phoenix/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/build.xml,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -r1.194 -r1.195
--- build.xml 18 Jan 2003 16:43:42 -0000 1.194
+++ build.xml 25 Jan 2003 15:47:16 -0000 1.195
@@ -480,6 +480,7 @@
<copy todir="${bin.dist.lib}">
<fileset dir="${lib.dir}">
<include name="excalibur*.jar"/>
+ <include name="sandbox-info-*.jar"/>
</fileset>
<fileset dir="${lib.dir}/jing">
<include name="*.jar"/>
1.11 +4 -6 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/BlockEvent.java
Index: BlockEvent.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/BlockEvent.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BlockEvent.java 11 Sep 2002 12:47:26 -0000 1.10
+++ BlockEvent.java 25 Jan 2003 15:47:16 -0000 1.11
@@ -21,9 +21,7 @@
extends EventObject
{
private final String m_name;
-
private final Object m_block;
-
private final BlockInfo m_blockInfo;
/**
@@ -41,15 +39,15 @@
if( null == name )
{
- throw new NullPointerException( "name property is null" );
+ throw new NullPointerException( "name" );
}
if( null == block )
{
- throw new NullPointerException( "block property is null" );
+ throw new NullPointerException( "block" );
}
if( null == blockInfo )
{
- throw new NullPointerException( "blockInfo property is null" );
+ throw new NullPointerException( "blockInfo" );
}
m_name = name;
@@ -86,7 +84,7 @@
*/
public Block getBlock()
{
- return (Block)m_block;
+ return (Block)getObject();
}
/**
1.2 +5 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/ContainerConstants.java
Index: ContainerConstants.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/ContainerConstants.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContainerConstants.java 27 Nov 2002 07:03:53 -0000 1.1
+++ ContainerConstants.java 25 Jan 2003 15:47:16 -0000 1.2
@@ -20,4 +20,9 @@
String DATE = "@@DATE@@";
String DISABLE_PROXY_ATTR = "phoenix:disable-proxy";
+ String ASSEMBLY_NAME = "phoenix:assembly-name";
+ String ASSEMBLY_CONFIG = "phoenix:config";
+
+ String BLOCK_PARTITION = "block";
+ String LISTENER_PARTITION = "listener";
}
1.23 +31 -14 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockEntry.java
Index: BlockEntry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockEntry.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- BlockEntry.java 11 Oct 2002 05:59:51 -0000 1.22
+++ BlockEntry.java 25 Jan 2003 15:47:17 -0000 1.23
@@ -7,9 +7,11 @@
*/
package org.apache.avalon.phoenix.components.application;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metainfo.BlockInfo;
-import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
+import org.apache.avalon.phoenix.components.ContainerConstants;
+import org.apache.avalon.framework.info.Attribute;
+import org.apache.avalon.framework.info.ComponentInfo;
+import org.apache.avalon.framework.info.ServiceDescriptor;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
/**
* This is the structure describing each block before it is loaded.
@@ -19,23 +21,23 @@
class BlockEntry
{
private Object m_object;
- private BlockMetaData m_blockMetaData;
+ private ComponentProfile m_componentProfile;
private BlockInvocationHandler m_invocationHandler;
- public BlockEntry( final BlockMetaData blockMetaData )
+ public BlockEntry( final ComponentProfile componentProfile )
{
invalidate();
- m_blockMetaData = blockMetaData;
+ m_componentProfile = componentProfile;
}
public String getName()
{
- return getMetaData().getName();
+ return getProfile().getMetaData().getName();
}
- public BlockMetaData getMetaData()
+ public ComponentProfile getProfile()
{
- return m_blockMetaData;
+ return m_componentProfile;
}
public synchronized Object getObject()
@@ -47,9 +49,9 @@
{
invalidate();
- if( null != object && ! getMetaData().isDisableProxy() )
+ if( null != object && ! isDisableProxy() )
{
- final BlockInfo blockInfo = getMetaData().getBlockInfo();
+ final ComponentInfo blockInfo = m_componentProfile.getInfo();
final Class[] interfaces = getServiceClasses( object, blockInfo.getServices() );
m_invocationHandler = new BlockInvocationHandler( object, interfaces );
}
@@ -58,7 +60,7 @@
public synchronized Object getProxy()
{
- if ( getMetaData().isDisableProxy() )
+ if ( isDisableProxy() )
{
return m_object;
}
@@ -75,6 +77,20 @@
}
}
+ private boolean isDisableProxy()
+ {
+ final Attribute[] attributes = getProfile().getMetaData().getAttributes();
+ for( int i = 0; i < attributes.length; i++ )
+ {
+ final Attribute attribute = attributes[ i ];
+ if( attribute.getName().equals( ContainerConstants.DISABLE_PROXY_ATTR ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
protected synchronized void invalidate()
{
if( null != m_invocationHandler )
@@ -85,7 +101,8 @@
m_object = null;
}
- private Class[] getServiceClasses( final Object block, final ServiceDescriptor[] services )
+ private Class[] getServiceClasses( final Object block,
+ final ServiceDescriptor[] services )
{
final Class[] classes = new Class[ services.length + 1 ];
final ClassLoader classLoader = block.getClass().getClassLoader();
@@ -94,7 +111,7 @@
{
try
{
- classes[ i ] = classLoader.loadClass( services[ i ].getName() );
+ classes[ i ] = classLoader.loadClass( services[ i ].getType() );
}
catch( final Throwable throwable )
{
1.14 +26 -31 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockResourceProvider.java
Index: BlockResourceProvider.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockResourceProvider.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BlockResourceProvider.java 18 Jan 2003 16:43:42 -0000 1.13
+++ BlockResourceProvider.java 25 Jan 2003 15:47:17 -0000 1.14
@@ -16,9 +16,7 @@
import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.DefaultComponentManager;
import org.apache.avalon.framework.component.WrapperComponentManager;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -28,13 +26,12 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.info.DependencyDescriptor;
+import org.apache.avalon.phoenix.containerkit.lifecycle.ResourceProvider;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.metadata.DependencyMetaData;
import org.apache.avalon.phoenix.interfaces.Application;
import org.apache.avalon.phoenix.interfaces.ApplicationContext;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metadata.DependencyMetaData;
-import org.apache.avalon.phoenix.metainfo.DependencyDescriptor;
-import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
-import org.apache.avalon.phoenix.containerkit.lifecycle.ResourceProvider;
/**
* The accessor used to access resources for a particular
@@ -88,9 +85,9 @@
public Object createObject( final Object entry )
throws Exception
{
- final BlockMetaData metaData = getMetaDataFor( entry );
+ final ComponentProfile profile = getProfileFor( entry );
final ClassLoader classLoader = m_context.getClassLoader();
- String classname = metaData.getBlockInfo().getBlockDescriptor().getImplementationKey();
+ String classname = profile.getInfo().getDescriptor().getImplementationKey();
final Class clazz = classLoader.loadClass( classname );
return clazz.newInstance();
}
@@ -105,8 +102,8 @@
public Logger createLogger( final Object entry )
throws Exception
{
- final BlockMetaData metaData = getMetaDataFor( entry );
- final String name = metaData.getName();
+ final ComponentProfile profile = getProfileFor( entry );
+ final String name = profile.getMetaData().getName();
return m_context.getLogger( name );
}
@@ -119,8 +116,8 @@
public Context createContext( final Object entry )
throws Exception
{
- final BlockMetaData metaData = getMetaDataFor( entry );
- return new DefaultBlockContext( metaData.getName(),
+ final ComponentProfile profile = getProfileFor( entry );
+ return new DefaultBlockContext( profile.getMetaData().getName(),
m_context );
}
@@ -171,24 +168,23 @@
private Map createServiceMap( final Object entry )
throws Exception
{
- final BlockMetaData metaData = getMetaDataFor( entry );
+ final ComponentProfile metaData = getProfileFor( entry );
final HashMap map = new HashMap();
final HashMap sets = new HashMap();
- final DependencyMetaData[] roles = metaData.getDependencies();
+ final DependencyMetaData[] roles = metaData.getMetaData().getDependencies();
for( int i = 0; i < roles.length; i++ )
{
final DependencyMetaData role = roles[ i ];
- final Object dependency = m_application.getBlock( role.getName() );
+ final Object dependency = m_application.getBlock( role.getProviderName() );
final DependencyDescriptor candidate =
- metaData.getBlockInfo().getDependency( role.getRole() );
+ metaData.getInfo().getDependency( role.getKey() );
- final String key = role.getRole();
+ final String key = role.getKey();
- final ServiceDescriptor service = candidate.getService();
- if( service.isArray() )
+ if( candidate.isArray() )
{
ArrayList list = (ArrayList)sets.get( key );
if( null == list )
@@ -199,7 +195,7 @@
list.add( dependency );
}
- else if( service.isMap() )
+ else if( candidate.isMap() )
{
HashMap smap = (HashMap)sets.get( key );
if( null == smap )
@@ -224,16 +220,15 @@
if( value instanceof List )
{
final List list = (List)value;
- final ServiceDescriptor service =
- metaData.getBlockInfo().getDependency( key ).getService();
+ final DependencyDescriptor dependency = metaData.getInfo().getDependency( key );
- final Object[] result = toArray( list, service.getComponentType() );
+ final Object[] result = toArray( list, dependency.getComponentType() );
map.put( key, result );
- if( key.equals( service.getName() ) )
+ if( key.equals( dependency.getType() ) )
{
final String classname =
- "[L" + service.getComponentType() + ";";
+ "[L" + dependency.getComponentType() + ";";
map.put( classname, result );
}
}
@@ -272,8 +267,8 @@
public Configuration createConfiguration( final Object entry )
throws Exception
{
- final BlockMetaData metaData = getMetaDataFor( entry );
- final String name = metaData.getName();
+ final ComponentProfile metaData = getProfileFor( entry );
+ final String name = metaData.getMetaData().getName();
try
{
return m_context.getConfiguration( name );
@@ -306,8 +301,8 @@
* @param entry the entry
* @return the MetaData for entry
*/
- private BlockMetaData getMetaDataFor( final Object entry )
+ private ComponentProfile getProfileFor( final Object entry )
{
- return ( (BlockEntry)entry ).getMetaData();
+ return ( (BlockEntry)entry ).getProfile();
}
}
1.40 +40 -23 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java
Index: DefaultApplication.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- DefaultApplication.java 18 Jan 2003 16:43:42 -0000 1.39
+++ DefaultApplication.java 25 Jan 2003 15:47:17 -0000 1.40
@@ -7,6 +7,7 @@
*/
package org.apache.avalon.phoenix.components.application;
+import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -19,15 +20,21 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.phoenix.ApplicationListener;
import org.apache.avalon.phoenix.BlockListener;
+import org.apache.avalon.phoenix.components.ContainerConstants;
+import org.apache.avalon.phoenix.components.util.ComponentMetaDataConverter;
import org.apache.avalon.phoenix.interfaces.Application;
import org.apache.avalon.phoenix.interfaces.ApplicationContext;
import org.apache.avalon.phoenix.interfaces.ApplicationException;
import org.apache.avalon.phoenix.interfaces.ApplicationMBean;
-import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
import org.apache.avalon.phoenix.metadata.SarMetaData;
import org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleException;
import org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleHelper;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
+import org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleException;
+import org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleHelper;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
import org.apache.excalibur.threadcontext.ThreadContext;
/**
@@ -127,10 +134,12 @@
{
try
{
- final BlockMetaData[] blocks = m_context.getMetaData().getBlocks();
+ final PartitionProfile partition =
+ m_context.getPartitionProfile().getPartition( ContainerConstants.BLOCK_PARTITION );
+ final ComponentProfile[] blocks = partition.getComponents();
for( int i = 0; i < blocks.length; i++ )
{
- final String blockName = blocks[ i ].getName();
+ final String blockName = blocks[ i ].getMetaData().getName();
final BlockEntry blockEntry = new BlockEntry( blocks[ i ] );
m_entries.put( blockName, blockEntry );
}
@@ -250,7 +259,7 @@
*/
public String getName()
{
- return getMetaData().getName();
+ return m_context.getPartitionProfile().getMetaData().getName();
}
/**
@@ -260,7 +269,7 @@
*/
public String getDisplayName()
{
- return getMetaData().getName();
+ return m_context.getPartitionProfile().getMetaData().getName();
}
/**
@@ -280,7 +289,7 @@
*/
public String getHomeDirectory()
{
- return getMetaData().getHomeDirectory().getPath();
+ return m_context.getHomeDirectory().getPath();
}
/**
@@ -294,11 +303,6 @@
return m_running;
}
- protected final SarMetaData getMetaData()
- {
- return m_context.getMetaData();
- }
-
/////////////////////////////
// Private Utility Methods //
/////////////////////////////
@@ -327,7 +331,8 @@
private void doLoadBlockListeners()
throws Exception
{
- final BlockListenerMetaData[] listeners = m_context.getMetaData().getListeners();
+ final ComponentProfile[] listeners =
+ getComponentsInPartition( ContainerConstants.LISTENER_PARTITION );
for( int i = 0; i < listeners.length; i++ )
{
try
@@ -336,7 +341,7 @@
}
catch( final Exception e )
{
- final String name = listeners[ i ].getName();
+ final String name = listeners[ i ].getMetaData().getName();
final String message =
REZ.getString( "bad-listener", "startup", name, e.getMessage() );
getLogger().error( message, e );
@@ -345,6 +350,13 @@
}
}
+ private ComponentProfile[] getComponentsInPartition( final String key )
+ {
+ final PartitionProfile partition =
+ m_context.getPartitionProfile().getPartition( key );
+ return partition.getComponents();
+ }
+
/**
* Run a phase for application.
* Each phase transitions application into new state and processes
@@ -381,7 +393,8 @@
private final void doRunPhase( final String name )
throws Exception
{
- final BlockMetaData[] blocks = m_context.getMetaData().getBlocks();
+ final ComponentProfile[] blocks =
+ getComponentsInPartition( ContainerConstants.BLOCK_PARTITION );
final String[] order = DependencyGraph.walkGraph( PHASE_STARTUP == name, blocks );
//Log message describing the number of blocks
@@ -400,7 +413,11 @@
if( PHASE_STARTUP == name )
{
//... for startup, so indicate to applicable listeners
- m_listenerSupport.fireApplicationStartingEvent( getMetaData() );
+ final PartitionProfile partition = m_context.getPartitionProfile();
+ final File homeDirectory = m_context.getHomeDirectory();
+ final SarMetaData sarMetaData =
+ ComponentMetaDataConverter.toSarMetaData( partition, homeDirectory );
+ m_listenerSupport.fireApplicationStartingEvent( sarMetaData );
}
else
{
@@ -484,7 +501,7 @@
m_blockAccessor );
m_exportHelper.exportBlock( m_context,
- entry.getMetaData(),
+ entry.getProfile(),
block );
entry.setObject( block );
@@ -511,7 +528,7 @@
{
//Remove block from Management system
m_exportHelper.unexportBlock( m_context,
- entry.getMetaData(),
+ entry.getProfile(),
object );
entry.invalidate();
@@ -529,17 +546,17 @@
* This will involve creation of BlockListener object and configuration of
* object if appropriate.
*
- * @param metaData the BlockListenerMetaData
+ * @param profile the BlockListenerMetaData
* @throws Exception if an error occurs when listener passes
* through a specific lifecycle stage
*/
- public void startupListener( final BlockListenerMetaData metaData )
+ public void startupListener( final ComponentProfile profile )
throws Exception
{
- final String name = metaData.getName();
+ final String name = profile.getMetaData().getName();
final Object listener =
m_lifecycleHelper.startup( name,
- metaData,
+ profile,
m_listenerAccessor );
// However onky ApplicationListners can avail of block events.
@@ -556,7 +573,7 @@
final String message =
REZ.getString( "helper.isa-blocklistener.error",
name,
- metaData.getClassname() );
+ profile.getMetaData().getImplementationKey() );
getLogger().error( message );
System.err.println( message );
}
1.21 +3 -5 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultBlockContext.java
Index: DefaultBlockContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultBlockContext.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DefaultBlockContext.java 1 Nov 2002 08:23:30 -0000 1.20
+++ DefaultBlockContext.java 25 Jan 2003 15:47:17 -0000 1.21
@@ -13,7 +13,6 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.phoenix.BlockContext;
import org.apache.avalon.phoenix.interfaces.ApplicationContext;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
/**
* Context via which Blocks communicate with container.
@@ -36,14 +35,13 @@
public Object get( Object key )
throws ContextException
{
- final SarMetaData metaData = m_applicationContext.getMetaData();
if( BlockContext.APP_NAME.equals( key ) )
{
- return metaData.getName();
+ return m_applicationContext.getPartitionProfile().getMetaData().getName();
}
else if( BlockContext.APP_HOME_DIR.equals( key ) )
{
- return metaData.getHomeDirectory();
+ return m_applicationContext.getHomeDirectory();
}
else if( BlockContext.NAME.equals( key ) )
{
@@ -62,7 +60,7 @@
*/
public File getBaseDirectory()
{
- return m_applicationContext.getMetaData().getHomeDirectory();
+ return m_applicationContext.getHomeDirectory();
}
/**
1.9 +24 -21 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DependencyGraph.java
Index: DependencyGraph.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DependencyGraph.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DependencyGraph.java 6 Aug 2002 11:57:39 -0000 1.8
+++ DependencyGraph.java 25 Jan 2003 15:47:17 -0000 1.9
@@ -8,9 +8,9 @@
package org.apache.avalon.phoenix.components.application;
import java.util.ArrayList;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metadata.DependencyMetaData;
-import org.apache.avalon.phoenix.metainfo.DependencyDescriptor;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.metadata.DependencyMetaData;
+import org.apache.avalon.framework.info.DependencyDescriptor;
/**
*
@@ -33,7 +33,8 @@
* @param blocks the blocks to traverse
* @return the ordered node names
*/
- public static String[] walkGraph( final boolean forward, final BlockMetaData[] blocks )
+ public static String[] walkGraph( final boolean forward,
+ final ComponentProfile[] blocks )
{
final ArrayList result = new ArrayList();
@@ -49,14 +50,14 @@
return (String[])result.toArray( new String[ 0 ] );
}
- private static void visitBlock( final BlockMetaData block,
- final BlockMetaData[] blocks,
+ private static void visitBlock( final ComponentProfile block,
+ final ComponentProfile[] blocks,
final boolean forward,
final ArrayList done,
final ArrayList order )
{
//If already visited this block then bug out early
- final String name = block.getName();
+ final String name = block.getMetaData().getName();
if( done.contains( name ) )
{
return;
@@ -80,16 +81,17 @@
*
* @param block the BlockMetaData
*/
- private static void visitDependencies( final BlockMetaData block,
- final BlockMetaData[] blocks,
+ private static void visitDependencies( final ComponentProfile block,
+ final ComponentProfile[] blocks,
final ArrayList done,
final ArrayList order )
{
- final DependencyDescriptor[] descriptors = block.getBlockInfo().getDependencies();
+ final DependencyDescriptor[] descriptors = block.getInfo().getDependencies();
for( int i = 0; i < descriptors.length; i++ )
{
- final DependencyMetaData dependency = block.getDependency( descriptors[ i ].getRole() );
- final BlockMetaData other = getBlock( dependency.getName(), blocks );
+ final String key = descriptors[ i ].getKey();
+ final DependencyMetaData dependency = block.getMetaData().getDependency( key );
+ final ComponentProfile other = getBlock( dependency.getProviderName(), blocks );
visitBlock( other, blocks, true, done, order );
}
}
@@ -98,23 +100,23 @@
* Traverse all reverse dependencies of specified block.
* A reverse dependency are those that dependend on block.
*
- * @param block the BlockMetaData
+ * @param block the ComponentProfile
*/
- private static void visitReverseDependencies( final BlockMetaData block,
- final BlockMetaData[] blocks,
+ private static void visitReverseDependencies( final ComponentProfile block,
+ final ComponentProfile[] blocks,
final ArrayList done,
final ArrayList order )
{
- final String name = block.getName();
+ final String name = block.getMetaData().getName();
for( int i = 0; i < blocks.length; i++ )
{
- final BlockMetaData other = blocks[ i ];
- final DependencyMetaData[] roles = other.getDependencies();
+ final ComponentProfile other = blocks[ i ];
+ final DependencyMetaData[] roles = other.getMetaData().getDependencies();
for( int j = 0; j < roles.length; j++ )
{
- final String depends = roles[ j ].getName();
+ final String depends = roles[ j ].getProviderName();
if( depends.equals( name ) )
{
visitBlock( other, blocks, false, done, order );
@@ -130,11 +132,12 @@
* @param blocks the Block array
* @return the Block
*/
- private static BlockMetaData getBlock( final String name, final BlockMetaData[] blocks )
+ private static ComponentProfile getBlock( final String name,
+ final ComponentProfile[] blocks )
{
for( int i = 0; i < blocks.length; i++ )
{
- if( blocks[ i ].getName().equals( name ) )
+ if( blocks[ i ].getMetaData().getName().equals( name ) )
{
return blocks[ i ];
}
1.4 +34 -10 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ExportHelper.java
Index: ExportHelper.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ExportHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExportHelper.java 6 Aug 2002 11:57:39 -0000 1.3
+++ ExportHelper.java 25 Jan 2003 15:47:17 -0000 1.4
@@ -10,10 +10,12 @@
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.tools.infobuilder.LegacyUtil;
+import org.apache.avalon.framework.info.ServiceDescriptor;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.phoenix.interfaces.ApplicationContext;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import java.util.ArrayList;
/**
* Utility class to help with exporting Blocks to management subsystem.
@@ -32,12 +34,12 @@
* services, into management system.
*/
void exportBlock( final ApplicationContext context,
- final BlockMetaData metaData,
+ final ComponentProfile profile,
final Object block )
throws CascadingException
{
- final ServiceDescriptor[] services = metaData.getBlockInfo().getManagementAccessPoints();
- final String name = metaData.getName();
+ final ServiceDescriptor[] services = getMxServices( profile );
+ final String name = profile.getMetaData().getName();
final ClassLoader classLoader = block.getClass().getClassLoader();
final Class[] serviceClasses = new Class[ services.length ];
@@ -47,13 +49,13 @@
final ServiceDescriptor service = services[ i ];
try
{
- serviceClasses[ i ] = classLoader.loadClass( service.getName() );
+ serviceClasses[ i ] = classLoader.loadClass( service.getType() );
}
catch( final Exception e )
{
final String reason = e.toString();
final String message =
- REZ.getString( "bad-mx-service.error", name, service.getName(), reason );
+ REZ.getString( "bad-mx-service.error", name, service.getType(), reason );
getLogger().error( message );
throw new CascadingException( message, e );
}
@@ -74,14 +76,36 @@
}
/**
+ * Return an array of all Management services for profile.
+ *
+ * @param profile the component profile
+ * @return the management services.
+ */
+ private ServiceDescriptor[] getMxServices( final ComponentProfile profile )
+ {
+ final ArrayList mxServices = new ArrayList();
+ final ServiceDescriptor[] services = profile.getInfo().getServices();
+ for( int i = 0; i < services.length; i++ )
+ {
+ final ServiceDescriptor service = services[ i ];
+ if( LegacyUtil.isMxService( service ) )
+ {
+ mxServices.add( service );
+ }
+ }
+
+ return (ServiceDescriptor[])mxServices.toArray( new ServiceDescriptor[ mxServices.size() ] );
+ }
+
+ /**
* Unxport the services of block, declared to be management
* services, into management system.
*/
void unexportBlock( final ApplicationContext context,
- final BlockMetaData metaData,
+ final ComponentProfile profile,
final Object block )
{
- final String name = metaData.getName();
+ final String name = profile.getMetaData().getName();
try
{
context.unexportObject( name );
1.5 +2 -2 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ListenerResourceProvider.java
Index: ListenerResourceProvider.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ListenerResourceProvider.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ListenerResourceProvider.java 18 Jan 2003 16:43:42 -0000 1.4
+++ ListenerResourceProvider.java 25 Jan 2003 15:47:17 -0000 1.5
@@ -63,7 +63,7 @@
final BlockListenerMetaData metaData = getMetaData( entry );
final ClassLoader classLoader = m_context.getClassLoader();
final Class clazz =
- classLoader.loadClass( metaData.getClassname() );
+ classLoader.loadClass( metaData.getImplementationKey() );
return clazz.newInstance();
}
1.5 +7 -4 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ListenerSupport.java
Index: ListenerSupport.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/ListenerSupport.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ListenerSupport.java 6 Sep 2002 12:01:07 -0000 1.4
+++ ListenerSupport.java 25 Jan 2003 15:47:17 -0000 1.5
@@ -11,8 +11,10 @@
import org.apache.avalon.phoenix.ApplicationListener;
import org.apache.avalon.phoenix.BlockEvent;
import org.apache.avalon.phoenix.BlockListener;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
+import org.apache.avalon.phoenix.metainfo.BlockInfo;
+import org.apache.avalon.phoenix.components.util.ComponentInfoConverter;
import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
/**
* Manage a set of {@link ApplicationListener} objects and propogate
@@ -75,11 +77,12 @@
*/
private BlockEvent createEvent( final BlockEntry entry )
{
- final BlockMetaData metaData = entry.getMetaData();
+ final ComponentProfile profile = entry.getProfile();
+ final BlockInfo blockInfo = ComponentInfoConverter.toBlockInfo( profile.getInfo() );
final BlockEvent event =
- new BlockEvent( metaData.getName(),
+ new BlockEvent( profile.getMetaData().getName(),
entry.getProxy(),
- metaData.getBlockInfo() );
+ blockInfo );
return event;
}
1.63 +156 -88 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java
Index: DefaultDeployer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/DefaultDeployer.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- DefaultDeployer.java 2 Nov 2002 00:29:27 -0000 1.62
+++ DefaultDeployer.java 25 Jan 2003 15:47:17 -0000 1.63
@@ -10,6 +10,8 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
@@ -19,14 +21,22 @@
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.info.ComponentInfo;
+import org.apache.avalon.framework.info.SchemaDescriptor;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.tools.infobuilder.LegacyUtil;
+import org.apache.avalon.phoenix.BlockContext;
+import org.apache.avalon.phoenix.components.ContainerConstants;
+import org.apache.avalon.phoenix.components.assembler.Assembler;
+import org.apache.avalon.phoenix.components.assembler.AssemblyException;
import org.apache.avalon.phoenix.interfaces.Application;
import org.apache.avalon.phoenix.interfaces.ClassLoaderManager;
+import org.apache.avalon.phoenix.interfaces.ClassLoaderSet;
import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
import org.apache.avalon.phoenix.interfaces.ConfigurationValidator;
import org.apache.avalon.phoenix.interfaces.Deployer;
@@ -37,17 +47,15 @@
import org.apache.avalon.phoenix.interfaces.Installer;
import org.apache.avalon.phoenix.interfaces.Kernel;
import org.apache.avalon.phoenix.interfaces.LogManager;
-import org.apache.avalon.phoenix.interfaces.ClassLoaderSet;
-import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
-import org.apache.avalon.phoenix.metainfo.BlockDescriptor;
-import org.apache.avalon.phoenix.tools.assembler.Assembler;
-import org.apache.avalon.phoenix.tools.assembler.AssemblyException;
import org.apache.avalon.phoenix.tools.configuration.ConfigurationBuilder;
import org.apache.avalon.phoenix.tools.verifier.SarVerifier;
import org.apache.avalon.phoenix.tools.verifier.VerifyException;
-import org.apache.avalon.phoenix.BlockContext;
+import org.apache.avalon.phoenix.containerkit.factory.ComponentBundle;
+import org.apache.avalon.phoenix.containerkit.factory.ComponentFactory;
+import org.apache.avalon.phoenix.containerkit.metadata.ComponentMetaData;
+import org.apache.avalon.phoenix.containerkit.metadata.PartitionMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
/**
* Deploy .sar files into a kernel using this class.
@@ -248,7 +256,7 @@
final Configuration environment = getConfigurationFor( installation.getEnvironment() );
final Configuration assembly = getConfigurationFor( installation.getAssembly() );
- final File directory = installation.getDirectory();
+ final File directory = installation.getHomeDirectory();
final DefaultContext context = new DefaultContext();
context.put( BlockContext.APP_NAME, name );
@@ -256,19 +264,20 @@
final ClassLoaderSet classLoaderSet =
m_classLoaderManager.createClassLoaderSet( environment,
- installation.getDirectory(),
+ installation.getHomeDirectory(),
installation.getWorkDirectory() );
final ClassLoader classLoader = classLoaderSet.getDefaultClassLoader();
context.put( "classloader", classLoader );
- //assemble all the blocks for application
- final SarMetaData metaData =
- m_assembler.assembleSar( name, assembly, directory, classLoader );
+ final PartitionMetaData metaData = assembleSar( name, assembly );
- storeConfigurationSchemas( metaData, classLoader );
+ final ComponentFactory factory = new PhoenixComponentFactory( classLoader );
+ setupLogger( factory, "factory" );
+ final PartitionProfile profile = assembleSarProfile( metaData, factory );
- verify( metaData, classLoader );
+ storeConfigurationSchemas( profile, classLoader );
+ verify( profile, classLoader );
//Setup configuration for all the applications blocks
setupConfiguration( metaData, config.getChildren() );
@@ -278,7 +287,8 @@
m_logManager.createHierarchy( logs, context );
//Finally add application to kernel
- m_kernel.addApplication( metaData,
+ m_kernel.addApplication( profile,
+ installation.getHomeDirectory(),
installation.getWorkDirectory(),
classLoader,
logger,
@@ -321,47 +331,139 @@
}
}
+ private PartitionProfile assembleSarProfile( final PartitionMetaData metaData,
+ final ComponentFactory factory )
+ throws Exception
+ {
+ final PartitionMetaData blockPartition =
+ metaData.getPartition( ContainerConstants.BLOCK_PARTITION );
+ final PartitionMetaData listenerPartition =
+ metaData.getPartition( ContainerConstants.LISTENER_PARTITION );
+
+ final PartitionProfile blockProfile = assembleProfile( blockPartition, factory );
+ final PartitionProfile listenerProfile =
+ assembleListenerProfile( listenerPartition );
+
+ final PartitionProfile[] profiles = new PartitionProfile[]{blockProfile, listenerProfile};
+ return new PartitionProfile( metaData,
+ profiles,
+ new ComponentProfile[ 0 ] );
+ }
+
+ private PartitionProfile assembleListenerProfile( final PartitionMetaData metaData )
+ throws Exception
+ {
+ final ArrayList componentSet = new ArrayList();
+ final ComponentMetaData[] components = metaData.getComponents();
+ for( int i = 0; i < components.length; i++ )
+ {
+ final ComponentMetaData component = components[ i ];
+ final ComponentInfo info =
+ LegacyUtil.createListenerInfo( component.getImplementationKey() );
+ final ComponentProfile profile = new ComponentProfile( info, component );
+ componentSet.add( profile );
+ }
+
+ final ComponentProfile[] profiles =
+ (ComponentProfile[])componentSet.toArray( new ComponentProfile[ componentSet.size() ] );
+ return new PartitionProfile( metaData, PartitionProfile.EMPTY_SET, profiles );
+ }
+
+ private PartitionProfile assembleProfile( final PartitionMetaData metaData,
+ final ComponentFactory factory )
+ throws Exception
+ {
+ final ArrayList partitionSet = new ArrayList();
+ final PartitionMetaData[] partitions = metaData.getPartitions();
+ for( int i = 0; i < partitions.length; i++ )
+ {
+ final PartitionMetaData partition = partitions[ i ];
+ final PartitionProfile profile = assembleProfile( partition, factory );
+ partitionSet.add( profile );
+ }
+
+ final ArrayList componentSet = new ArrayList();
+ final ComponentMetaData[] components = metaData.getComponents();
+ for( int i = 0; i < components.length; i++ )
+ {
+ final ComponentMetaData component = components[ i ];
+ final ComponentBundle bundle =
+ factory.createBundle( component.getImplementationKey() );
+ final ComponentInfo info = bundle.getComponentInfo();
+ final ComponentProfile profile = new ComponentProfile( info, component );
+ componentSet.add( profile );
+ }
+
+ final PartitionProfile[] partitionProfiles =
+ (PartitionProfile[])partitionSet.toArray( new PartitionProfile[ partitionSet.size() ] );
+ final ComponentProfile[] componentProfiles =
+ (ComponentProfile[])componentSet.toArray( new ComponentProfile[ componentSet.size() ] );
+ return new PartitionProfile( metaData, partitionProfiles, componentProfiles );
+ }
+
+ private PartitionMetaData assembleSar( final String name,
+ final Configuration assembly )
+ throws Exception
+ {
+ final Map parameters = new HashMap();
+ parameters.put( ContainerConstants.ASSEMBLY_NAME, name );
+ parameters.put( ContainerConstants.ASSEMBLY_CONFIG, assembly );
+ //assemble all the blocks for application
+ return m_assembler.buildAssembly( parameters );
+ }
+
/**
* Verify that the application conforms to our requirements.
*
- * @param metaData the application metaData
- * @param classLoader the ClassLoader associated with app
+ * @param profile the application profile
* @throws VerifyException on error
*/
- protected void verify( final SarMetaData metaData,
- final ClassLoader classLoader )
+ private void verify( final PartitionProfile profile,
+ final ClassLoader classLoader )
throws VerifyException
{
- m_verifier.verifySar( metaData, classLoader );
+ try
+ {
+ m_verifier.verifySar( profile, classLoader );
+ }
+ catch( org.apache.avalon.framework.tools.verifier.VerifyException e )
+ {
+ throw new VerifyException( e.getMessage(), e.getCause() );
+ }
}
/**
* Store the configuration schemas for this application
*
- * @param metaData the application metaData
+ * @param profile the application profile
* @throws DeploymentException upon invalid schema
*/
- private void storeConfigurationSchemas( final SarMetaData metaData, ClassLoader classLoader )
+ private void storeConfigurationSchemas( final PartitionProfile profile,
+ final ClassLoader classLoader )
throws DeploymentException
{
- final BlockMetaData[] blocks = metaData.getBlocks();
+ final String application = profile.getMetaData().getName();
+ final PartitionProfile partition = profile.getPartition( ContainerConstants.BLOCK_PARTITION );
+ final ComponentProfile[] blocks = partition.getComponents();
int i = 0;
+ final ComponentProfile block = blocks[ i ];
+ final String implementationKey =
+ block.getInfo().getDescriptor().getImplementationKey();
+ final String name = block.getMetaData().getName();
try
{
for( i = 0; i < blocks.length; i++ )
{
- final String name = blocks[ i ].getName();
- final BlockDescriptor descriptor = blocks[ i ].getBlockInfo().getBlockDescriptor();
- final String type = descriptor.getSchemaType();
+ final SchemaDescriptor descriptor = block.getInfo().getConfigurationSchema();
- if( null != type )
+ if( null != descriptor && !descriptor.getType().equals( "" ) )
{
- m_validator.addSchema( metaData.getName(),
+ m_validator.addSchema( application,
name,
- type,
+ descriptor.getType(),
getConfigurationSchemaURL( name,
- descriptor.getImplementationKey(),
+ implementationKey,
classLoader )
);
}
@@ -370,14 +472,15 @@
catch( ConfigurationException e )
{
//uh-oh, bad schema bad bad!
- final String message = REZ.getString( "deploy.error.config.schema.invalid",
- blocks[ i ].getName() );
+ final String message =
+ REZ.getString( "deploy.error.config.schema.invalid",
+ implementationKey );
//back out any schemas that we have already stored for this app
while( --i >= 0 )
{
- m_validator.removeSchema( metaData.getName(),
- blocks[ i ].getName() );
+ m_validator.removeSchema( name,
+ implementationKey );
}
throw new DeploymentException( message, e );
@@ -395,9 +498,11 @@
if( null == resource )
{
- throw new DeploymentException( REZ.getString( "deploy.error.config.schema.missing",
- name,
- resourceName ) );
+ final String message =
+ REZ.getString( "deploy.error.config.schema.missing",
+ name,
+ resourceName );
+ throw new DeploymentException( message );
}
else
{
@@ -434,19 +539,24 @@
* @param configurations the block configurations.
* @throws DeploymentException if an error occurs
*/
- private void setupConfiguration( final SarMetaData metaData,
+ private void setupConfiguration( final PartitionMetaData metaData,
final Configuration[] configurations )
throws DeploymentException
{
final String application = metaData.getName();
-
+ final PartitionMetaData listenerPartition =
+ metaData.getPartition( ContainerConstants.LISTENER_PARTITION );
+ final PartitionMetaData blockPartition =
+ metaData.getPartition( ContainerConstants.BLOCK_PARTITION );
for( int i = 0; i < configurations.length; i++ )
{
final Configuration configuration = configurations[ i ];
final String name = configuration.getName();
- final boolean listener = hasBlockListener( name, metaData.getListeners() );
-
- if( !hasBlock( name, metaData.getBlocks() ) && !listener )
+ final boolean listener =
+ null != listenerPartition.getComponent( name );
+ final boolean block =
+ null != blockPartition.getComponent( name );
+ if( !block && !listener )
{
final String message =
REZ.getString( "deploy.error.extra.config",
@@ -465,8 +575,8 @@
}
else
{
- final String message = REZ.getString( "deploy.error.config.invalid", name );
-
+ final String message =
+ REZ.getString( "deploy.error.config.invalid", name );
throw new DeploymentException( message );
}
}
@@ -475,47 +585,5 @@
throw new DeploymentException( ce.getMessage(), ce );
}
}
- }
-
- /**
- * Return true if specified array contains entry with specified name.
- *
- * @param name the blocks name
- * @param blocks the set of BlockMetaData objects to search
- * @return true if block present, false otherwise
- */
- private boolean hasBlock( final String name, final BlockMetaData[] blocks )
- {
- for( int i = 0; i < blocks.length; i++ )
- {
- final String other = blocks[ i ].getName();
- if( other.equals( name ) )
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Return true if specified array contains entry with specified name.
- *
- * @param name the blocks name
- * @param listeners the set of BlockListenerMetaData objects to search
- * @return true if block present, false otherwise
- */
- private boolean hasBlockListener( final String name,
- final BlockListenerMetaData[] listeners )
- {
- for( int i = 0; i < listeners.length; i++ )
- {
- if( listeners[ i ].getName().equals( name ) )
- {
- return true;
- }
- }
-
- return false;
}
}
1.2 +55 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/deployer/PhoenixComponentFactory.java
1.83 +3 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java
Index: DefaultEmbeddor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/DefaultEmbeddor.java,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- DefaultEmbeddor.java 27 Nov 2002 07:03:53 -0000 1.82
+++ DefaultEmbeddor.java 25 Jan 2003 15:47:17 -0000 1.83
@@ -11,6 +11,7 @@
import java.util.Date;
import java.util.Observable;
import java.util.Observer;
+import java.net.URL;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.ExtensionFileFilter;
@@ -568,6 +569,8 @@
{
try
{
+ final URL url =
+ getClass().getClassLoader().getResource( classname.replace('.','/') + ".class" );
final Object object = Class.forName( classname ).newInstance();
if( !service.isInstance( object ) )
{
1.4 +0 -4 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/EmbeddorEntry.java
Index: EmbeddorEntry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/embeddor/EmbeddorEntry.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EmbeddorEntry.java 26 Jul 2002 09:49:21 -0000 1.3
+++ EmbeddorEntry.java 25 Jan 2003 15:47:17 -0000 1.4
@@ -15,13 +15,9 @@
public class EmbeddorEntry
{
private final String m_role;
-
private final String m_classname;
-
private final String m_loggerName;
-
private final Configuration m_configuration;
-
private Object m_object;
public EmbeddorEntry( final String role,
1.32 +37 -38 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/DefaultApplicationContext.java
Index: DefaultApplicationContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/DefaultApplicationContext.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- DefaultApplicationContext.java 1 Nov 2002 08:23:30 -0000 1.31
+++ DefaultApplicationContext.java 25 Jan 2003 15:47:17 -0000 1.32
@@ -23,6 +23,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.phoenix.components.ContainerConstants;
import org.apache.avalon.phoenix.components.util.ResourceUtil;
import org.apache.avalon.phoenix.interfaces.ApplicationContext;
import org.apache.avalon.phoenix.interfaces.ConfigurationRepository;
@@ -30,8 +31,8 @@
import org.apache.avalon.phoenix.interfaces.Kernel;
import org.apache.avalon.phoenix.interfaces.ManagerException;
import org.apache.avalon.phoenix.interfaces.SystemManager;
-import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.metadata.PartitionMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
import org.apache.excalibur.threadcontext.ThreadContext;
import org.apache.excalibur.threadcontext.impl.DefaultThreadContextPolicy;
@@ -68,8 +69,9 @@
private SystemManager m_blockManager;
- private final SarMetaData m_metaData;
+ private final PartitionProfile m_profile;
private final File m_workDirectory;
+ private final File m_homeDirectory;
/**
* The map containing all the named loaders.
@@ -81,15 +83,16 @@
*/
private Kernel m_kernel;
- protected DefaultApplicationContext( final SarMetaData metaData,
+ protected DefaultApplicationContext( final PartitionProfile profile,
+ final File homeDirectory,
final File workDirectory,
final ClassLoader classLoader,
final Logger hierarchy,
final Map loaders )
{
- if( null == metaData )
+ if( null == profile )
{
- throw new NullPointerException( "metaData" );
+ throw new NullPointerException( "profile" );
}
if( null == classLoader )
{
@@ -103,11 +106,15 @@
{
throw new NullPointerException( "workDirectory" );
}
-
- m_metaData = metaData;
+ if( null == homeDirectory )
+ {
+ throw new NullPointerException( "homeDirectory" );
+ }
+ m_profile = profile;
m_classLoader = classLoader;
m_hierarchy = hierarchy;
m_workDirectory = workDirectory;
+ m_homeDirectory = homeDirectory;
m_loaders = loaders;
final DefaultThreadContextPolicy policy = new DefaultThreadContextPolicy();
@@ -138,7 +145,7 @@
{
final File file =
ResourceUtil.getFileForResource( name,
- m_metaData.getHomeDirectory(),
+ getHomeDirectory(),
m_workDirectory );
if( !file.exists() )
{
@@ -158,9 +165,9 @@
}
}
- public SarMetaData getMetaData()
+ public PartitionProfile getPartitionProfile()
{
- return m_metaData;
+ return m_profile;
}
public ThreadContext getThreadContext()
@@ -189,17 +196,22 @@
//return and do whatever it needs to be
//done
Thread.sleep( 2 );
- m_kernel.removeApplication( m_metaData.getName() );
+ m_kernel.removeApplication( getName() );
}
catch( Exception e )
{
final String message =
REZ.getString( "applicationcontext.error.noremove",
- m_metaData.getName() );
+ getName() );
getLogger().error( message, e );
}
}
+ public File getHomeDirectory()
+ {
+ return m_homeDirectory;
+ }
+
/**
* Get ClassLoader for the current application.
*
@@ -260,15 +272,18 @@
throws ConfigurationException
{
final Configuration configuration =
- m_repository.getConfiguration( m_metaData.getName(),
+ m_repository.getConfiguration( getName(),
component );
//no validation of listeners just yet..
- if( hasBlockListener( component, this.m_metaData.getListeners() ) )
+ final PartitionMetaData partition =
+ m_profile.getMetaData().getPartition( ContainerConstants.LISTENER_PARTITION );
+ final boolean isListener = null != partition.getComponent( component );
+ if( isListener )
{
return configuration;
}
- else if( m_validator.isValid( m_metaData.getName(),
+ else if( m_validator.isValid( getName(),
component,
configuration ) )
{
@@ -299,27 +314,6 @@
}
/**
- * Return true if specified array contains entry with specified name.
- *
- * @param name the blocks name
- * @param listeners the set of BlockListenerMetaData objects to search
- * @return true if block present, false otherwise
- */
- private boolean hasBlockListener( final String name,
- final BlockListenerMetaData[] listeners )
- {
- for( int i = 0; i < listeners.length; i++ )
- {
- if( listeners[ i ].getName().equals( name ) )
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
* Returns the local SystemManager where the blocks should be registered
* for management.
*
@@ -330,6 +324,11 @@
{
final SystemManager appContext =
m_systemManager.getSubContext( null, "application" );
- return appContext.getSubContext( m_metaData.getName(), "block" );
+ return appContext.getSubContext( getName(), "block" );
+ }
+
+ private String getName()
+ {
+ return m_profile.getMetaData().getName();
}
}
1.83 +16 -11 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/DefaultKernel.java
Index: DefaultKernel.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/DefaultKernel.java,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- DefaultKernel.java 1 Nov 2002 08:23:30 -0000 1.82
+++ DefaultKernel.java 25 Jan 2003 15:47:17 -0000 1.83
@@ -34,7 +34,8 @@
import org.apache.avalon.phoenix.interfaces.Kernel;
import org.apache.avalon.phoenix.interfaces.KernelMBean;
import org.apache.avalon.phoenix.interfaces.SystemManager;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.metadata.PartitionMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
/**
* The ServerKernel is the core of the Phoenix system.
@@ -142,7 +143,7 @@
//lock for application startup and shutdown
synchronized( entry )
{
- final String name = entry.getMetaData().getName();
+ final String name = entry.getProfile().getMetaData().getName();
Application application = entry.getApplication();
if( null == application )
@@ -170,7 +171,7 @@
final String message =
REZ.getString( "kernel.error.entry.initialize",
- entry.getMetaData().getName() );
+ entry.getProfile().getMetaData().getName() );
throw new CascadingException( message, t );
}
@@ -181,7 +182,8 @@
catch( final Throwable t )
{
final String message =
- REZ.getString( "kernel.error.entry.start", entry.getMetaData().getName() );
+ REZ.getString( "kernel.error.entry.start",
+ entry.getProfile().getMetaData().getName() );
if( m_addInvalidApplications )
{
@@ -232,22 +234,25 @@
{
final String message =
REZ.getString( "kernel.error.entry.nostop",
- entry.getMetaData().getName() );
+ entry.getProfile().getMetaData().getName() );
getLogger().warn( message );
}
}
}
- public void addApplication( final SarMetaData metaData,
+ public void addApplication( final PartitionProfile profile,
+ final File homeDirectory,
final File workDirectory,
final ClassLoader classLoader,
final Logger logger,
final Map classloaders )
throws Exception
{
- final String name = metaData.getName();
+
+ final String name = profile.getMetaData().getName();
final SarEntry entry =
- new SarEntry( metaData, workDirectory, classLoader,
+ new SarEntry( profile, homeDirectory,
+ workDirectory, classLoader,
logger, classloaders );
m_entries.put( name, entry );
@@ -266,11 +271,11 @@
private ApplicationContext createApplicationContext( final SarEntry entry )
throws Exception
{
- final SarMetaData metaData = entry.getMetaData();
- final String name = metaData.getName();
+ final String name = entry.getProfile().getMetaData().getName();
final DefaultApplicationContext context =
- new DefaultApplicationContext( metaData,
+ new DefaultApplicationContext( entry.getProfile(),
+ entry.getHomeDirectory(),
entry.getWorkDirectory(),
entry.getClassLoader(),
entry.getLogger(),
1.18 +20 -8 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/SarEntry.java
Index: SarEntry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/SarEntry.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- SarEntry.java 1 Nov 2002 08:23:30 -0000 1.17
+++ SarEntry.java 25 Jan 2003 15:47:17 -0000 1.18
@@ -11,7 +11,7 @@
import java.util.Map;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.phoenix.interfaces.Application;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
/**
* This is the structure describing each server application before it is loaded.
@@ -20,22 +20,24 @@
*/
final class SarEntry
{
- private final SarMetaData m_metaData;
+ private final PartitionProfile m_profile;
private final ClassLoader m_classLoader;
private final Logger m_logger;
+ private final File m_homeDirectory;
private final File m_workDirectory;
private final Map m_classLoaders;
private Application m_application;
- protected SarEntry( final SarMetaData metaData,
+ protected SarEntry( final PartitionProfile profile,
+ final File homeDirectory,
final File workDirectory,
final ClassLoader classLoader,
final Logger logger,
final Map classLoaders )
{
- if( null == metaData )
+ if( null == profile )
{
- throw new NullPointerException( "metaData" );
+ throw new NullPointerException( "profile" );
}
if( null == classLoader )
{
@@ -49,18 +51,28 @@
{
throw new NullPointerException( "workDirectory" );
}
+ if( null == homeDirectory )
+ {
+ throw new NullPointerException( "homeDirectory" );
+ }
if( null == classLoaders )
{
throw new NullPointerException( "classLoaders" );
}
- m_metaData = metaData;
+ m_profile = profile;
m_classLoader = classLoader;
m_logger = logger;
+ m_homeDirectory = homeDirectory;
m_workDirectory = workDirectory;
m_classLoaders = classLoaders;
}
+ public File getHomeDirectory()
+ {
+ return m_homeDirectory;
+ }
+
public File getWorkDirectory()
{
return m_workDirectory;
@@ -76,9 +88,9 @@
m_application = application;
}
- public SarMetaData getMetaData()
+ public PartitionProfile getProfile()
{
- return m_metaData;
+ return m_profile;
}
public Logger getLogger()
1.8 +1 -1 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/beanshell/BeanShellKernelProxy.java
Index: BeanShellKernelProxy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/kernel/beanshell/BeanShellKernelProxy.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BeanShellKernelProxy.java 1 Nov 2002 08:23:30 -0000 1.7
+++ BeanShellKernelProxy.java 25 Jan 2003 15:47:17 -0000 1.8
@@ -28,7 +28,7 @@
m_kernel = kernel;
}
- public void addApplication( final SarMetaData metaData,
+ public void addApplication( final PartitionMetaData metaData,
final File workDirectory,
final ClassLoader classLoader,
final Logger logger,
1.9 +19 -42 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/util/ComponentInfoConverter.java
Index: ComponentInfoConverter.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/util/ComponentInfoConverter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ComponentInfoConverter.java 9 Dec 2002 17:09:59 -0000 1.8
+++ ComponentInfoConverter.java 25 Jan 2003 15:47:17 -0000 1.9
@@ -9,10 +9,10 @@
import java.util.ArrayList;
import org.apache.avalon.framework.Version;
-import org.apache.avalon.framework.info.Attribute;
import org.apache.avalon.framework.info.ComponentDescriptor;
import org.apache.avalon.framework.info.ComponentInfo;
-import org.apache.avalon.framework.info.FeatureDescriptor;
+import org.apache.avalon.framework.info.SchemaDescriptor;
+import org.apache.avalon.framework.tools.infobuilder.LegacyUtil;
import org.apache.avalon.phoenix.metainfo.BlockDescriptor;
import org.apache.avalon.phoenix.metainfo.BlockInfo;
import org.apache.avalon.phoenix.metainfo.DependencyDescriptor;
@@ -38,12 +38,9 @@
*/
public static BlockInfo toBlockInfo( final ComponentInfo component )
{
- final BlockDescriptor descriptor =
- toBlockDescriptor( component );
- final ServiceDescriptor[] services =
- toPhoenixServices( component.getServices() );
- final ServiceDescriptor[] mxServices =
- getMXServices( component.getServices() );
+ final BlockDescriptor descriptor = toBlockDescriptor( component );
+ final ServiceDescriptor[] services = toPhoenixServices( component.getServices() );
+ final ServiceDescriptor[] mxServices = getMXServices( component.getServices() );
final DependencyDescriptor[] dependencys =
toPhoenixDependencys( component.getDependencies() );
@@ -65,8 +62,7 @@
final ArrayList serviceSet = new ArrayList();
for( int i = 0; i < services.length; i++ )
{
- final Attribute tag = services[ i ].getAttribute( "mx" );
- if( null != tag )
+ if( LegacyUtil.isMxService( services[ i ] ) )
{
serviceSet.add( toPhoenixService( services[ i ] ) );
}
@@ -86,7 +82,10 @@
final ArrayList serviceSet = new ArrayList();
for( int i = 0; i < services.length; i++ )
{
- serviceSet.add( toPhoenixService( services[ i ] ) );
+ if( !LegacyUtil.isMxService( services[ i ] ) )
+ {
+ serviceSet.add( toPhoenixService( services[ i ] ) );
+ }
}
return (ServiceDescriptor[])serviceSet.toArray( new ServiceDescriptor[ serviceSet.size() ] );
}
@@ -100,9 +99,8 @@
private static ServiceDescriptor toPhoenixService(
final org.apache.avalon.framework.info.ServiceDescriptor service )
{
- final Version version = toVersion( service );
- final String classname = service.getType();
- return new ServiceDescriptor( classname, version );
+ final Version version = LegacyUtil.toVersion( service );
+ return new ServiceDescriptor( service.getType(), version );
}
/**
@@ -131,7 +129,7 @@
private static DependencyDescriptor toPhoenixDependency(
final org.apache.avalon.framework.info.DependencyDescriptor dependency )
{
- final Version version = toVersion( dependency );
+ final Version version = LegacyUtil.toVersion( dependency );
final ServiceDescriptor service =
new ServiceDescriptor( dependency.getType(), version );
return new DependencyDescriptor( dependency.getKey(), service );
@@ -146,39 +144,18 @@
private static BlockDescriptor toBlockDescriptor( final ComponentInfo component )
{
final ComponentDescriptor descriptor = component.getDescriptor();
- final Version version = toVersion( descriptor );
+ final Version version = LegacyUtil.toVersion( descriptor );
- //FIXME: Assuming that getSchema is replaced with getConfigurationSchema. /LS
- String schemaType = component.getConfigurationSchema().getType();
- if( "".equals( schemaType ) )
+ final SchemaDescriptor schema = component.getConfigurationSchema();
+ String schemaType = null;
+ if( null != schema )
{
- schemaType = null;
+ schemaType = schema.getType();
}
return new BlockDescriptor( null,
descriptor.getImplementationKey(),
schemaType,
version );
- }
-
- /**
- * Create a version for a feature. Defaults to 1.0 if not specified.
- *
- * @param feature the feature
- * @return the Version object
- */
- private static Version toVersion( final FeatureDescriptor feature )
- {
- final Attribute tag = feature.getAttribute( "avalon" );
- Version version = new Version( 1, 0, 0 );
- if( null != tag )
- {
- final String versionString = tag.getParameter( "version" );
- if( null != versionString )
- {
- version = Version.getVersion( versionString );
- }
- }
- return version;
}
}
1.2 +157 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/util/ComponentMetaDataConverter.java
1.2 +2 -2 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/containerkit/verifier/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/containerkit/verifier/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 18 Jan 2003 16:43:44 -0000 1.1
+++ package.html 25 Jan 2003 15:47:18 -0000 1.2
@@ -7,11 +7,11 @@
<p>This package includes a set of classes supporting the verification of the
integrity of a component class and the verification of the integrity of a
relationships and inter-dependecies based on supplied meta-data. The
-{@link org.apache.excalibur.containerkit.verifier.ComponentVerifier} provides
+{@link org.apache.avalon.phoenix.containerkit.verifier.ComponentVerifier} provides
support for the validation of a component class. It includes validation
functions that check for structural and best-practice integrity related to
the class, lifecycle patterns and service. The
-{@link org.apache.excalibur.containerkit.verifier.AssemblyVerifier} performs
+{@link org.apache.avalon.phoenix.containerkit.verifier.AssemblyVerifier} performs
validation of the structural integrity of a set component assembly based on
assembly meta-data.
</body>
1.20 +6 -2 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/ApplicationContext.java
Index: ApplicationContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/ApplicationContext.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ApplicationContext.java 1 Nov 2002 08:23:30 -0000 1.19
+++ ApplicationContext.java 25 Jan 2003 15:47:18 -0000 1.20
@@ -7,11 +7,13 @@
*/
package org.apache.avalon.phoenix.interfaces;
+import java.io.File;
import java.io.InputStream;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.metadata.PartitionMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
import org.apache.excalibur.threadcontext.ThreadContext;
/**
@@ -23,7 +25,9 @@
{
String ROLE = ApplicationContext.class.getName();
- SarMetaData getMetaData();
+ File getHomeDirectory();
+
+ PartitionProfile getPartitionProfile();
ThreadContext getThreadContext();
1.3 +5 -5 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Installation.java
Index: Installation.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Installation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Installation.java 1 Nov 2002 01:15:40 -0000 1.2
+++ Installation.java 25 Jan 2003 15:47:18 -0000 1.3
@@ -24,7 +24,7 @@
private final File m_source;
///Directory in which application is installed
- private final File m_directory;
+ private final File m_homeDirectory;
///Directory in which application temporary/work data is stored
private final File m_workDirectory;
@@ -46,7 +46,7 @@
final String environment )
{
m_source = source;
- m_directory = directory;
+ m_homeDirectory = directory;
m_workDirectory = workDirectory;
m_config = config;
m_assembly = assembly;
@@ -69,9 +69,9 @@
*
* @return the applications base directory
*/
- public File getDirectory()
+ public File getHomeDirectory()
{
- return m_directory;
+ return m_homeDirectory;
}
/**
1.18 +3 -3 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Kernel.java
Index: Kernel.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/interfaces/Kernel.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Kernel.java 1 Nov 2002 08:23:31 -0000 1.17
+++ Kernel.java 25 Jan 2003 15:47:18 -0000 1.18
@@ -10,7 +10,7 @@
import java.io.File;
import java.util.Map;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
/**
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -22,8 +22,8 @@
/**
* Adds an application to the container
*/
- void addApplication( SarMetaData metaData,
- File workDirectory,
+ void addApplication( PartitionProfile profile,
+ File homeDirectory, File workDirectory,
ClassLoader classLoader,
Logger logger,
Map classloaders )
1.7 +13 -5 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/metadata/BlockListenerMetaData.java
Index: BlockListenerMetaData.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/metadata/BlockListenerMetaData.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BlockListenerMetaData.java 6 Aug 2002 11:57:41 -0000 1.6
+++ BlockListenerMetaData.java 25 Jan 2003 15:47:18 -0000 1.7
@@ -15,18 +15,26 @@
public final class BlockListenerMetaData
{
private final String m_name;
+ private final String m_implementationKey;
- private final String m_classname;
-
- public BlockListenerMetaData( final String name, final String classname )
+ public BlockListenerMetaData( final String name,
+ final String implementationKey )
{
m_name = name;
- m_classname = classname;
+ m_implementationKey = implementationKey;
+ }
+
+ public String getImplementationKey()
+ {
+ return m_implementationKey;
}
+ /**
+ * @deprecated Use getImplementationKey() instead.
+ */
public String getClassname()
{
- return m_classname;
+ return getImplementationKey();
}
public String getName()
1.4 +39 -48 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MetaGenerateTask.java
Index: MetaGenerateTask.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MetaGenerateTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MetaGenerateTask.java 22 Oct 2002 06:41:12 -0000 1.3
+++ MetaGenerateTask.java 25 Jan 2003 15:47:18 -0000 1.4
@@ -7,81 +7,72 @@
*/
package org.apache.avalon.phoenix.tools.metagenerate;
-import com.thoughtworks.qdox.ant.AbstractQdoxTask;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
-import java.io.File;
import java.io.IOException;
+import java.io.File;
+import org.apache.avalon.framework.tools.ant.FormatEnum;
import org.apache.tools.ant.BuildException;
/**
* MetaInfo Generation Ant Taskdef
- * @author Paul Hammant
+ * @author Paul Hammant
*/
-public class MetaGenerateTask extends AbstractQdoxTask
+public class MetaGenerateTask
+ extends org.apache.avalon.framework.tools.ant.MetaGenerateTask
{
-
- private File m_destDir;
- private boolean m_inheritance = true;
+ //private boolean m_inheritance = true;
/**
- * Execute
+ * Inheritence : should parent classes of blocks be queried too?
+ * @param inheritance
*/
- public void execute()
+ public void setInheritance( boolean inheritance )
{
- super.execute();
- try
- {
- m_destDir.mkdirs();
- outputClasses();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- throw new BuildException("IOException " + e.getMessage());
- }
+ //TODO: Do inheritance based on markup rather than based on task run
+ //m_inheritance = inheritance;
}
- /**
- * Set the desitation
- * @param destinationDir The destination directory
- */
- public void setDest(File destinationDir)
+ public void setDest( File destDir )
{
- m_destDir = destinationDir;
+ super.setDestDir( destDir );
}
- /**
- * Inheritence : should parent classes of blocks be queried too?
- * @param inheritance
- */
- public void setInheritance(boolean inheritance)
+ public void execute()
+ throws BuildException
{
- m_inheritance = inheritance;
+ final FormatEnum format = new FormatEnum();
+ format.setValue( "legacy" );
+ setFormat( format);
+ super.execute();
+ outputClasses();
}
/**
* Output the classes
- * @throws IOException If a problem writing output
+ *
+ * @throws BuildException If a problem writing output
*/
- protected void outputClasses() throws IOException
+ private void outputClasses()
+ throws BuildException
{
-
- for (int i = 0; i < allClasses.size(); i++)
+ final int size = allClasses.size();
+ for( int i = 0; i < size; i++ )
{
- JavaClass javaClass = (JavaClass) allClasses.get(i);
- DocletTag block = javaClass.getTagByName("phoenix:block");
- if (block != null)
- {
- XinfoFactory factory = new XinfoFactory(m_destDir, javaClass,
- allClasses, m_inheritance);
- factory.generate();
- }
- DocletTag topic = javaClass.getTagByName("phoenix:mx-topic");
- if (topic != null)
+ final JavaClass javaClass = (JavaClass)allClasses.get( i );
+ final DocletTag topic = javaClass.getTagByName( "phoenix:mx-topic" );
+ if( topic != null )
{
- MxinfoFactory factory = new MxinfoFactory(m_destDir, javaClass);
- factory.generate();
+ final MxinfoFactory factory =
+ new MxinfoFactory( getDestDir(), javaClass );
+ try
+ {
+ factory.generate();
+ }
+ catch( final IOException ioe )
+ {
+ throw new BuildException( ioe.getMessage(), ioe );
+ }
}
}
}
1.3 +76 -60 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MxinfoHelper.java
Index: MxinfoHelper.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MxinfoHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MxinfoHelper.java 2 Oct 2002 11:11:58 -0000 1.2
+++ MxinfoHelper.java 25 Jan 2003 15:47:18 -0000 1.3
@@ -18,11 +18,8 @@
* A Xinfo Helper.
* @author Paul Hammant
*/
-public class MxinfoHelper extends AbstractHelper
+public class MxinfoHelper
{
-
- private FileWriter m_output;
-
private static final String HEADER[] = new String[]{
"<?xml version=\"1.0\"?>",
"<!DOCTYPE mxinfo PUBLIC \"-//PHOENIX/Mx Info DTD Version 1.0//EN\"",
@@ -48,23 +45,23 @@
private static final String OPERATIONS_HEADER[] = new String[]{
"",
" <!-- operations -->",
- "" };
+ ""};
private static final String OPERATION_HEADER[] = new String[]{
" <operation",
" name=\"@NAME@\"",
" description=\"@DESCRIPTION@\"",
- " type=\"@RETURN@\">" };
+ " type=\"@RETURN@\">"};
private static final String PARAMETER[] = new String[]{
" <param",
" name=\"@NAME@\"",
" description=\"@DESCRIPTION@\"",
" type=\"@TYPE@\"",
- " />" };
+ " />"};
private static final String OPERATION_FOOTER[] = new String[]{
- " </operation>" };
+ " </operation>"};
private static final String FOOTER[] = new String[]{
"",
@@ -72,14 +69,16 @@
"",
"</mxinfo>"};
+ private FileWriter m_output;
+
/**
* Construct
* @param file The File to create
* @throws IOException If a problem writing output
*/
- public MxinfoHelper(File file) throws IOException
+ public MxinfoHelper( final File file ) throws IOException
{
- m_output = new FileWriter(file);
+ m_output = new FileWriter( file );
}
/**
@@ -87,23 +86,23 @@
* @param topic The topic
* @throws IOException If a problem writing output
*/
- public void writeHeader(String topic) throws IOException
+ public void writeHeader( String topic ) throws IOException
{
- for (int i = 0; i < HEADER.length; i++)
+ for( int i = 0; i < HEADER.length; i++ )
{
- m_output.write(HEADER[i] + "\n");
+ m_output.write( HEADER[ i ] + "\n" );
}
- for (int i = 0; i < TOPIC.length; i++)
+ for( int i = 0; i < TOPIC.length; i++ )
{
- String line = TOPIC[i];
- line = replaceString(line, "\"@TOPIC@\"", topic);
- m_output.write(line + "\n");
+ String line = TOPIC[ i ];
+ line = replaceString( line, "\"@TOPIC@\"", topic );
+ m_output.write( line + "\n" );
}
- for (int i = 0; i < ATTR_HEADER.length; i++)
+ for( int i = 0; i < ATTR_HEADER.length; i++ )
{
- m_output.write(ATTR_HEADER[i] + "\n");
+ m_output.write( ATTR_HEADER[ i ] + "\n" );
}
}
@@ -115,19 +114,19 @@
* @param type The type
* @throws IOException If a problem writing output
*/
- public NamedXmlSnippet makeAttrLines(String attrName, String description, String type)
- throws IOException
+ public NamedXmlSnippet makeAttrLines( String attrName, String description, String type )
+ throws IOException
{
String xml = "";
- for (int i = 0; i < ATTRIBUTE.length; i++)
+ for( int i = 0; i < ATTRIBUTE.length; i++ )
{
- String line = ATTRIBUTE[i];
- line = replaceString(line, "@NAME@", attrName);
- line = replaceString(line, "\"@DESCRIPTION@\"", description);
- line = replaceString(line, "@RETURN@", type);
+ String line = ATTRIBUTE[ i ];
+ line = replaceString( line, "@NAME@", attrName );
+ line = replaceString( line, "\"@DESCRIPTION@\"", description );
+ line = replaceString( line, "@RETURN@", type );
xml = xml + line + "\n";
}
- return new NamedXmlSnippet(attrName, xml);
+ return new NamedXmlSnippet( attrName, xml );
}
/**
@@ -135,26 +134,25 @@
* @param attributes A list of attributes
* @throws IOException If a problem writing output
*/
- public void writeAttributes(List attributes) throws IOException
+ public void writeAttributes( List attributes ) throws IOException
{
- Collections.sort(attributes);
- for (Iterator iterator = attributes.iterator(); iterator.hasNext();)
+ Collections.sort( attributes );
+ for( Iterator iterator = attributes.iterator(); iterator.hasNext(); )
{
- NamedXmlSnippet attribute = (NamedXmlSnippet) iterator.next();
- m_output.write(attribute.getXml());
+ NamedXmlSnippet attribute = (NamedXmlSnippet)iterator.next();
+ m_output.write( attribute.getXml() );
}
}
-
/**
* Write the operations headers
* @throws IOException If a problem writing output
*/
public void writeOperationsHeader() throws IOException
{
- for (int i = 0; i < OPERATIONS_HEADER.length; i++)
+ for( int i = 0; i < OPERATIONS_HEADER.length; i++ )
{
- m_output.write(OPERATIONS_HEADER[i] + "\n");
+ m_output.write( OPERATIONS_HEADER[ i ] + "\n" );
}
}
@@ -165,16 +163,16 @@
* @param type The type
* @throws IOException If a problem writing output
*/
- public String makeOperationHeader(String operName, String description, String type)
- throws IOException
+ public String makeOperationHeader( String operName, String description, String type )
+ throws IOException
{
String xml = "";
- for (int i = 0; i < OPERATION_HEADER.length; i++)
+ for( int i = 0; i < OPERATION_HEADER.length; i++ )
{
- String line = OPERATION_HEADER[i];
- line = replaceString(line, "@NAME@", operName);
- line = replaceString(line, "@DESCRIPTION@", description);
- line = replaceString(line, "@RETURN@", type);
+ String line = OPERATION_HEADER[ i ];
+ line = replaceString( line, "@NAME@", operName );
+ line = replaceString( line, "@DESCRIPTION@", description );
+ line = replaceString( line, "@RETURN@", type );
xml = xml + line + "\n";
}
return xml;
@@ -187,9 +185,9 @@
public String makeOperationFooter() throws IOException
{
String xml = "";
- for (int i = 0; i < OPERATION_FOOTER.length; i++)
+ for( int i = 0; i < OPERATION_FOOTER.length; i++ )
{
- xml = xml + OPERATION_FOOTER[i] + "\n";
+ xml = xml + OPERATION_FOOTER[ i ] + "\n";
}
return xml;
}
@@ -201,16 +199,16 @@
* @param type The type
* @throws IOException If a problem writing output
*/
- public String makeOperationParameter(String paramName, String description, String type)
- throws IOException
+ public String makeOperationParameter( String paramName, String description, String type )
+ throws IOException
{
String xml = "";
- for (int i = 0; i < PARAMETER.length; i++)
+ for( int i = 0; i < PARAMETER.length; i++ )
{
- String line = PARAMETER[i];
- line = replaceString(line, "@NAME@", paramName);
- line = replaceString(line, "@DESCRIPTION@", description);
- line = replaceString(line, "@TYPE@", type);
+ String line = PARAMETER[ i ];
+ line = replaceString( line, "@NAME@", paramName );
+ line = replaceString( line, "@DESCRIPTION@", description );
+ line = replaceString( line, "@TYPE@", type );
xml = xml + line + "\n";
}
return xml;
@@ -221,26 +219,25 @@
* @param operations A list of operations
* @throws IOException If a problem writing output
*/
- public void writeOperations(List operations) throws IOException
+ public void writeOperations( List operations ) throws IOException
{
- Collections.sort(operations);
- for (Iterator iterator = operations.iterator(); iterator.hasNext();)
+ Collections.sort( operations );
+ for( Iterator iterator = operations.iterator(); iterator.hasNext(); )
{
- NamedXmlSnippet operation = (NamedXmlSnippet) iterator.next();
- m_output.write(operation.getXml());
+ NamedXmlSnippet operation = (NamedXmlSnippet)iterator.next();
+ m_output.write( operation.getXml() );
}
}
-
/**
* Write footer
* @throws IOException If a problem writing output
*/
public void writeFooter() throws IOException
{
- for (int i = 0; i < FOOTER.length; i++)
+ for( int i = 0; i < FOOTER.length; i++ )
{
- m_output.write(FOOTER[i] + "\n");
+ m_output.write( FOOTER[ i ] + "\n" );
}
}
@@ -253,5 +250,24 @@
m_output.close();
}
-
+ /**
+ * Replace a test with another in a string
+ * @param source The string to be changed.
+ * @param term The term to replace.
+ * @param replacement To replace with.
+ * @return The resulting string.
+ */
+ protected String replaceString( final String source, String term, String replacement )
+ {
+ String retval = source;
+ int ix = retval.indexOf( term );
+ if( ix != -1 )
+ {
+ retval =
+ retval.substring( 0, ix )
+ + replacement
+ + retval.substring( ix + term.length(), retval.length() );
+ }
+ return retval;
+ }
}
1.18 +24 -13 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/tasks/Sar.java
Index: Sar.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/tasks/Sar.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Sar.java 25 Aug 2002 05:36:22 -0000 1.17
+++ Sar.java 25 Jan 2003 15:47:18 -0000 1.18
@@ -42,12 +42,16 @@
if( !m_config.exists() )
{
- throw new BuildException( "Config descriptor: " + m_config + " does not exist." );
+ final String message =
+ "Config descriptor: " + m_config + " does not exist.";
+ throw new BuildException( message, getLocation() );
}
if( !m_config.isFile() )
{
- throw new BuildException( "Config descriptor: " + m_config + " is not a file." );
+ final String message =
+ "Config descriptor: " + m_config + " is not a file.";
+ throw new BuildException( message, getLocation() );
}
}
@@ -57,12 +61,16 @@
if( !m_assembly.exists() )
{
- throw new BuildException( "Assembly descriptor: " + m_assembly + " does not exist." );
+ final String message =
+ "Assembly descriptor: " + m_assembly + " does not exist.";
+ throw new BuildException( message, getLocation() );
}
if( !m_assembly.isFile() )
{
- throw new BuildException( "Assembly descriptor: " + m_assembly + " is not a file." );
+ final String message =
+ "Assembly descriptor: " + m_assembly + " is not a file.";
+ throw new BuildException( message, getLocation() );
}
}
@@ -78,16 +86,16 @@
if( !m_environment.exists() )
{
- final String message = "Environment descriptor: "
- + m_environment + " does not exist.";
- throw new BuildException( message );
+ final String message = "Environment descriptor: " +
+ m_environment + " does not exist.";
+ throw new BuildException( message, getLocation() );
}
if( !m_environment.isFile() )
{
- final String message = "Environment descriptor: "
- + m_environment + " is not a file.";
- throw new BuildException( message );
+ final String message = "Environment descriptor: " +
+ m_environment + " is not a file.";
+ throw new BuildException( message, getLocation() );
}
}
@@ -108,15 +116,18 @@
{
if( null == m_config )
{
- throw new BuildException( "config attribute is required", location );
+ final String message = "config attribute is required";
+ throw new BuildException( message, getLocation() );
}
if( null == m_assembly )
{
- throw new BuildException( "assembly attribute is required", location );
+ final String message = "assembly attribute is required";
+ throw new BuildException( message, getLocation() );
}
if( null == m_environment )
{
- throw new BuildException( "environment attribute is required", location );
+ final String message = "environment attribute is required";
+ throw new BuildException( message, getLocation() );
}
pushFile( "SAR-INF/config.xml", m_config );
1.30 +76 -507 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/SarVerifier.java
Index: SarVerifier.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/SarVerifier.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- SarVerifier.java 15 Sep 2002 02:07:31 -0000 1.29
+++ SarVerifier.java 25 Jan 2003 15:47:18 -0000 1.30
@@ -7,29 +7,18 @@
*/
package org.apache.avalon.phoenix.tools.verifier;
-import java.util.ArrayList;
-import java.util.Stack;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.activity.Startable;
-import org.apache.avalon.framework.component.Composable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.tools.verifier.InfoVerifier;
+import org.apache.avalon.framework.tools.verifier.VerifyException;
import org.apache.avalon.phoenix.Block;
import org.apache.avalon.phoenix.BlockListener;
-import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
-import org.apache.avalon.phoenix.metadata.BlockMetaData;
-import org.apache.avalon.phoenix.metadata.DependencyMetaData;
-import org.apache.avalon.phoenix.metadata.SarMetaData;
-import org.apache.avalon.phoenix.metainfo.BlockInfo;
-import org.apache.avalon.phoenix.metainfo.DependencyDescriptor;
-import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
+import org.apache.avalon.phoenix.components.ContainerConstants;
+import org.apache.avalon.phoenix.containerkit.metadata.ComponentMetaData;
+import org.apache.avalon.phoenix.containerkit.registry.ComponentProfile;
+import org.apache.avalon.phoenix.containerkit.registry.PartitionProfile;
+import org.apache.avalon.phoenix.containerkit.verifier.AssemblyVerifier;
/**
* This Class verifies that Sars are valid. It performs a number
@@ -60,65 +49,49 @@
* @version $Revision$ $Date$
*/
public class SarVerifier
- extends AbstractLogEnabled
+ extends AssemblyVerifier
{
private static final Resources REZ =
ResourceManager.getPackageResources( SarVerifier.class );
- private static final Class[] FRAMEWORK_CLASSES = new Class[]
+ private final InfoVerifier m_infoVerifier = new InfoVerifier();
+
+ public void enableLogging( final Logger logger )
{
- LogEnabled.class,
- Contextualizable.class,
- Composable.class,
- Serviceable.class,
- Configurable.class,
- Parameterizable.class,
- Initializable.class,
- Startable.class,
- Disposable.class
- };
+ super.enableLogging( logger );
+ m_infoVerifier.enableLogging( logger );
+ }
/**
- * Verify the specified {@link SarMetaData} object.
- * The rules used to verify {@link SarMetaData} are specified
+ * Verify the specified {@link PartitionProfile} object.
+ * The rules used to verify {@link PartitionProfile} are specified
* in the Class javadocs.
*
- * @param sar the SarMetaDat object
- * @param classLoader the ClassLoader used to load types. This is used
- * to verify that specified Class objects exist and
- * implement the correct interfaces.
+ * @param profile the Sar profile
* @throws VerifyException if an error occurs
*/
- public void verifySar( final SarMetaData sar, final ClassLoader classLoader )
+ public void verifySar( final PartitionProfile profile,
+ final ClassLoader classLoader )
throws VerifyException
{
- final BlockMetaData[] blocks = sar.getBlocks();
- final BlockListenerMetaData[] listeners = sar.getListeners();
+ final ComponentProfile[] blocks =
+ profile.getPartition( ContainerConstants.BLOCK_PARTITION ).getComponents();
+ final ComponentProfile[] listeners =
+ profile.getPartition( ContainerConstants.LISTENER_PARTITION ).getComponents();
String message = null;
message = REZ.getString( "verify-valid-names" );
getLogger().info( message );
- verifySarName( sar.getName() );
- verifyValidNames( blocks );
+ verifySarName( profile.getMetaData().getName() );
verifyValidNames( listeners );
+ super.verifyAssembly( blocks );
+
message = REZ.getString( "verify-unique-names" );
getLogger().info( message );
checkNamesUnique( blocks, listeners );
- message = REZ.getString( "verify-dependencies-mapping" );
- getLogger().info( message );
- verifyValidDependencies( blocks );
-
- message = REZ.getString( "verify-dependency-references" );
- getLogger().info( message );
- verifyDependencyReferences( blocks );
-
- message = REZ.getString( "verify-nocircular-dependencies" );
- getLogger().info( message );
- verifyNoCircularDependencies( blocks );
-
message = REZ.getString( "verify-block-type" );
getLogger().info( message );
verifyBlocksType( blocks, classLoader );
@@ -129,276 +102,69 @@
}
/**
- * Verfiy that all Blocks have the needed dependencies specified correctly.
- *
- * @param blocks the BlockMetaData objects for the blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyValidDependencies( final BlockMetaData[] blocks )
- throws VerifyException
- {
- for( int i = 0; i < blocks.length; i++ )
- {
- verifyDependenciesMap( blocks[ i ] );
- }
- }
-
- /**
- * Verfiy that there are no circular references between Blocks.
- *
- * @param blocks the BlockMetaData objects for the blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyNoCircularDependencies( final BlockMetaData[] blocks )
- throws VerifyException
- {
- for( int i = 0; i < blocks.length; i++ )
- {
- final BlockMetaData block = blocks[ i ];
-
- final Stack stack = new Stack();
- stack.push( block );
- verifyNoCircularDependencies( block, blocks, stack );
- stack.pop();
- }
- }
-
- /**
- * Verfiy that there are no circular references between Blocks.
- *
- * @param blocks the BlockMetaData objects for the blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyNoCircularDependencies( final BlockMetaData block,
- final BlockMetaData[] blocks,
- final Stack stack )
- throws VerifyException
- {
- final BlockMetaData[] dependencies = getDependencies( block, blocks );
-
- for( int i = 0; i < dependencies.length; i++ )
- {
- final BlockMetaData dependency = dependencies[ i ];
- if( stack.contains( dependency ) )
- {
- final String trace = getDependencyTrace( dependency, stack );
- final String message =
- REZ.getString( "dependency-circular", block.getName(), trace );
- throw new VerifyException( message );
- }
-
- stack.push( dependency );
- verifyNoCircularDependencies( dependency, blocks, stack );
- stack.pop();
- }
- }
-
- /**
- * Get a string defining path from top of stack till it reaches specified block.
- *
- * @param block the block
- * @param stack the Stack
- * @return the path of dependency
- */
- private String getDependencyTrace( final BlockMetaData block,
- final Stack stack )
- {
- final StringBuffer sb = new StringBuffer();
- sb.append( "[ " );
-
- final String name = block.getName();
- final int size = stack.size();
- final int top = size - 1;
- for( int i = top; i >= 0; i-- )
- {
- final BlockMetaData other = (BlockMetaData)stack.get( i );
- if( top != i )
- {
- sb.append( ", " );
- }
- sb.append( other.getName() );
-
- if( other.getName().equals( name ) )
- {
- break;
- }
- }
-
- sb.append( ", " );
- sb.append( name );
-
- sb.append( " ]" );
- return sb.toString();
- }
-
- /**
- * Get array of dependencies for specified Block from specified Block array.
- *
- * @param block the block to get dependencies of
- * @param blocks the total set of blocks in application
- * @return the dependencies of block
- */
- private BlockMetaData[] getDependencies( final BlockMetaData block,
- final BlockMetaData[] blocks )
- {
- final ArrayList dependencies = new ArrayList();
- final DependencyMetaData[] deps = block.getDependencies();
-
- for( int i = 0; i < deps.length; i++ )
- {
- final String name = deps[ i ].getName();
- final BlockMetaData other = getBlock( name, blocks );
- dependencies.add( other );
- }
-
- return (BlockMetaData[])dependencies.toArray( new BlockMetaData[ 0 ] );
- }
-
- /**
- * Verfiy that the inter-Block dependencies are valid.
+ * Verfiy that all Blocks specify classes that implement the
+ * advertised interfaces.
*
- * @param blocks the BlockMetaData objects for the blocks
+ * @param blocks the ComponentProfile objects for the blocks
* @throws VerifyException if an error occurs
*/
- private void verifyDependencyReferences( final BlockMetaData[] blocks )
+ private void verifyBlocksType( final ComponentProfile[] blocks,
+ final ClassLoader classLoader )
throws VerifyException
{
for( int i = 0; i < blocks.length; i++ )
{
- verifyDependencyReferences( blocks[ i ], blocks );
+ verifyBlockType( blocks[ i ], classLoader );
}
}
/**
- * Verfiy that the inter-Block dependencies are valid for specified Block.
+ * Verfiy that specified Block designate classes that implement the
+ * advertised interfaces.
*
- * @param block the BlockMetaData object for the block
- * @param others the BlockMetaData objects for the other blocks
+ * @param block the BlockMetaData object for the blocks
* @throws VerifyException if an error occurs
*/
- private void verifyDependencyReferences( final BlockMetaData block,
- final BlockMetaData[] others )
+ private void verifyBlockType( final ComponentProfile block,
+ final ClassLoader classLoader )
throws VerifyException
{
- final BlockInfo info = block.getBlockInfo();
- final DependencyMetaData[] roles = block.getDependencies();
+ final ComponentMetaData metaData = block.getMetaData();
+ final Class clazz = loadClass( "block", metaData, classLoader );
- for( int i = 0; i < roles.length; i++ )
- {
- final String blockName = roles[ i ].getName();
- final String roleName = roles[ i ].getRole();
- final ServiceDescriptor service =
- info.getDependency( roleName ).getService();
-
- //Get the other block that is providing service
- final BlockMetaData other = getBlock( blockName, others );
- if( null == other )
- {
- final String message =
- REZ.getString( "dependency-noblock", blockName, block.getName() );
- throw new VerifyException( message );
- }
-
- //make sure that the block offers service
- //that user expects it to be providing
- final ServiceDescriptor[] services = other.getBlockInfo().getServices();
- if( !hasMatchingService( service, services ) )
- {
- final String message =
- REZ.getString( "dependency-noservice", blockName, service, block.getName() );
- throw new VerifyException( message );
- }
- }
- }
+ m_infoVerifier.verifyType( metaData.getName(),
+ metaData.getImplementationKey(),
+ block.getInfo(),
+ classLoader );
- /**
- * Get Block with specified name from specified Block array.
- *
- * @param name the name of block to get
- * @param blocks the array of Blocks to search
- * @return the Block if found, else null
- */
- private BlockMetaData getBlock( final String name, final BlockMetaData[] blocks )
- {
- for( int i = 0; i < blocks.length; i++ )
- {
- if( blocks[ i ].getName().equals( name ) )
- {
- return blocks[ i ];
- }
- }
-
- return null;
- }
-
- /**
- * Verfiy that all Blocks specify classes that implement the
- * advertised interfaces.
- *
- * @param blocks the BlockMetaData objects for the blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyBlocksType( final BlockMetaData[] blocks, final ClassLoader classLoader )
- throws VerifyException
- {
- for( int i = 0; i < blocks.length; i++ )
+ if( Block.class.isAssignableFrom( clazz ) )
{
- verifyBlockType( blocks[ i ], classLoader );
+ final String message =
+ REZ.getString( "verifier.implements-block.error",
+ metaData.getName(),
+ metaData.getImplementationKey() );
+ getLogger().error( message );
+ System.err.println( message );
}
}
- /**
- * Verfiy that specified Block designate classes that implement the
- * advertised interfaces.
- *
- * @param block the BlockMetaData object for the blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyBlockType( final BlockMetaData block, final ClassLoader classLoader )
+ private Class loadClass( final String type,
+ final ComponentMetaData metaData,
+ final ClassLoader classLoader )
throws VerifyException
{
- final String name = block.getName();
- final String classname = block.getImplementationKey();
- Class clazz = null;
try
{
- clazz = classLoader.loadClass( classname );
+ return classLoader.loadClass( metaData.getImplementationKey() );
}
catch( final Exception e )
{
- final String message = REZ.getString( "bad-block-class",
- name,
- classname,
+ final String message = REZ.getString( "bad-" + type + "-class",
+ metaData.getName(),
+ metaData.getImplementationKey(),
e.getMessage() );
throw new VerifyException( message );
}
-
- final Class[] interfaces =
- getServiceClasses( name,
- block.getBlockInfo().getServices(),
- classLoader );
-
- for( int i = 0; i < interfaces.length; i++ )
- {
- if( !interfaces[ i ].isAssignableFrom( clazz ) )
- {
- final String message = REZ.getString( "block-noimpl-service",
- name,
- classname,
- interfaces[ i ].getName() );
- throw new VerifyException( message );
- }
- }
-
- if( Block.class.isAssignableFrom( clazz ) )
- {
- final String message =
- REZ.getString( "verifier.implements-block.error",
- name,
- classname );
- getLogger().error( message );
- System.err.println( message );
- }
}
/**
@@ -407,7 +173,7 @@
* @param listeners the BlockListenerMetaData objects for the listeners
* @throws VerifyException if an error occurs
*/
- private void verifyListenersType( final BlockListenerMetaData[] listeners,
+ private void verifyListenersType( final ComponentProfile[] listeners,
final ClassLoader classLoader )
throws VerifyException
{
@@ -423,30 +189,18 @@
* @param listener the BlockListenerMetaData object for the listener
* @throws VerifyException if an error occurs
*/
- private void verifyListenerType( final BlockListenerMetaData listener,
+ private void verifyListenerType( final ComponentProfile listener,
final ClassLoader classLoader )
throws VerifyException
{
- Class clazz = null;
- try
- {
- clazz = classLoader.loadClass( listener.getClassname() );
- }
- catch( final Exception e )
- {
- final String message =
- REZ.getString( "bad-listener-class",
- listener.getName(),
- listener.getClassname(),
- e.getMessage() );
- throw new VerifyException( message, e );
- }
-
+ final ComponentMetaData metaData = listener.getMetaData();
+ final Class clazz = loadClass( "listener", metaData, classLoader );
if( !BlockListener.class.isAssignableFrom( clazz ) )
{
- final String message = REZ.getString( "listener-noimpl-listener",
- listener.getName(),
- listener.getClassname() );
+ final String message =
+ REZ.getString( "listener-noimpl-listener",
+ metaData,
+ metaData );
throw new VerifyException( message );
}
}
@@ -468,53 +222,13 @@
}
/**
- * Verify that the names of the specified blocks are valid.
- *
- * @param blocks the Blocks
- * @throws VerifyException if an error occurs
- */
- private void verifyValidNames( final BlockMetaData[] blocks )
- throws VerifyException
- {
- for( int i = 0; i < blocks.length; i++ )
- {
- final String name = blocks[ i ].getName();
- if( !isValidName( name ) )
- {
- final String message = REZ.getString( "invalid-block-name", name );
- throw new VerifyException( message );
- }
- }
- }
-
- /**
- * Verify that the names of the specified listeners are valid.
- *
- * @param listeners the listeners
- * @throws VerifyException if an error occurs
- */
- private void verifyValidNames( final BlockListenerMetaData[] listeners )
- throws VerifyException
- {
- for( int i = 0; i < listeners.length; i++ )
- {
- final String name = listeners[ i ].getName();
- if( !isValidName( name ) )
- {
- final String message = REZ.getString( "invalid-listener-name", name );
- throw new VerifyException( message );
- }
- }
- }
-
- /**
* Return true if specified name is valid.
* Valid names consist of letters, digits or the '-' & '.' characters.
*
* @param name the name to check
* @return true if valid, false otherwise
*/
- private boolean isValidName( final String name )
+ public boolean isValidName( final String name )
{
final int size = name.length();
for( int i = 0; i < size; i++ )
@@ -539,19 +253,19 @@
* @param listeners the listeners
* @throws VerifyException if an error occurs
*/
- private void checkNamesUnique( final BlockMetaData[] blocks,
- final BlockListenerMetaData[] listeners )
+ private void checkNamesUnique( final ComponentProfile[] blocks,
+ final ComponentProfile[] listeners )
throws VerifyException
{
for( int i = 0; i < blocks.length; i++ )
{
- final String name = blocks[ i ].getName();
+ final String name = blocks[ i ].getMetaData().getName();
checkNameUnique( name, blocks, listeners, i, -1 );
}
for( int i = 0; i < listeners.length; i++ )
{
- final String name = listeners[ i ].getName();
+ final String name = listeners[ i ].getMetaData().getName();
checkNameUnique( name, blocks, listeners, -1, i );
}
}
@@ -570,8 +284,8 @@
* @throws VerifyException if an error occurs
*/
private void checkNameUnique( final String name,
- final BlockMetaData[] blocks,
- final BlockListenerMetaData[] listeners,
+ final ComponentProfile[] blocks,
+ final ComponentProfile[] listeners,
final int blockIndex,
final int listenerIndex )
throws VerifyException
@@ -579,7 +293,7 @@
//Verify no blocks have the same name
for( int i = 0; i < blocks.length; i++ )
{
- final String other = blocks[ i ].getName();
+ final String other = blocks[ i ].getMetaData().getName();
if( blockIndex != i && name.equals( other ) )
{
final String message = REZ.getString( "duplicate-name", name );
@@ -590,157 +304,12 @@
//Verify no listeners have the same name
for( int i = 0; i < listeners.length; i++ )
{
- final String other = listeners[ i ].getName();
+ final String other = listeners[ i ].getMetaData().getName();
if( listenerIndex != i && name.equals( other ) )
{
final String message = REZ.getString( "duplicate-name", name );
throw new VerifyException( message );
}
}
- }
-
- /**
- * Retrieve a list of DependencyMetaData objects for BlockMetaData
- * and verify that there is a 1 to 1 map with dependencies specified
- * in BlockInfo.
- *
- * @param block the BlockMetaData describing the block
- * @throws VerifyException if an error occurs
- */
- private void verifyDependenciesMap( final BlockMetaData block )
- throws VerifyException
- {
- //Make sure all role entries specified in config file are valid
- final DependencyMetaData[] roles = block.getDependencies();
- for( int i = 0; i < roles.length; i++ )
- {
- final String roleName = roles[ i ].getRole();
- final DependencyDescriptor descriptor = block.getBlockInfo().getDependency( roleName );
-
- //If there is no dependency descriptor in BlockInfo then
- //user has specified an uneeded dependency.
- if( null == descriptor )
- {
- final String message = REZ.getString( "unknown-dependency",
- roles[ i ].getName(),
- roleName,
- block.getName() );
- throw new VerifyException( message );
- }
- }
-
- //Make sure all dependencies in BlockInfo file are satisfied
- final DependencyDescriptor[] dependencies = block.getBlockInfo().getDependencies();
- for( int i = 0; i < dependencies.length; i++ )
- {
- final DependencyMetaData role = block.getDependency( dependencies[ i ].getRole() );
-
- //If there is no Role then the user has failed
- //to specify a needed dependency.
- if( null == role )
- {
- final String message = REZ.getString( "unspecified-dependency",
- dependencies[ i ].getRole(),
- block.getName() );
- throw new VerifyException( message );
- }
- }
- }
-
- /**
- * Retrieve an array of Classes for all the services (+ the Block interface)
- * that a Block offers. This method also makes sure all services offered are
- * interfaces.
- *
- * @param name the name of block
- * @param services the services the Block offers
- * @param classLoader the classLoader
- * @return an array of Classes for all the services
- * @throws VerifyException if an error occurs
- */
- private Class[] getServiceClasses( final String name,
- final ServiceDescriptor[] services,
- final ClassLoader classLoader )
- throws VerifyException
- {
- final Class[] classes = new Class[ services.length ];
-
- for( int i = 0; i < services.length; i++ )
- {
- final String classname = services[ i ].getName();
- try
- {
- classes[ i ] = classLoader.loadClass( classname );
- }
- catch( final Throwable t )
- {
- final String message =
- REZ.getString( "bad-service-class", name, classname, t.getMessage() );
- throw new VerifyException( message, t );
- }
-
- if( !classes[ i ].isInterface() )
- {
- final String message =
- REZ.getString( "service-not-interface", name, classname );
- throw new VerifyException( message );
- }
-
- checkNotFrameworkInterface( name, classname, classes[ i ] );
- }
-
- return classes;
- }
-
- /**
- * Warn the user if any of the service interfaces extend
- * a Lifecycle interface (a generally unrecomended approach).
- *
- * @param name the name of block
- * @param classname the classname of block
- * @param clazz the service implemented by block
- */
- private void checkNotFrameworkInterface( final String name,
- final String classname,
- final Class clazz )
- {
- for( int i = 0; i < FRAMEWORK_CLASSES.length; i++ )
- {
- final Class lifecycle = FRAMEWORK_CLASSES[ i ];
- if( lifecycle.isAssignableFrom( clazz ) )
- {
- final String message =
- REZ.getString( "verifier.service-isa-lifecycle.error",
- name,
- classname,
- clazz.getName(),
- lifecycle.getName() );
- getLogger().warn( message );
- System.err.println( message );
- }
- }
- }
-
- /**
- * Return true if specified service matches any of the
- * candidate services.
- *
- * @param candidates an array of candidate services
- * @param service the service
- * @return true if candidate services contains a service that matches
- * specified service, false otherwise
- */
- private boolean hasMatchingService( final ServiceDescriptor service,
- final ServiceDescriptor[] candidates )
- {
- for( int i = 0; i < candidates.length; i++ )
- {
- if( service.matches( candidates[ i ] ) )
- {
- return true;
- }
- }
-
- return false;
}
}
1.4 +2 -2 jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/components/application/test/MockApplicationContext.java
Index: MockApplicationContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/components/application/test/MockApplicationContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MockApplicationContext.java 1 Nov 2002 08:23:31 -0000 1.3
+++ MockApplicationContext.java 25 Jan 2003 15:47:18 -0000 1.4
@@ -36,7 +36,7 @@
m_logger = logger;
}
- public SarMetaData getMetaData()
+ public SarMetaData getPartitionProfile()
{
return m_sarMetaData;
}
1.3 +9 -6 jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/AbstractContainerTestCase.java
Index: AbstractContainerTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/test/AbstractContainerTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractContainerTestCase.java 2 Oct 2002 11:25:56 -0000 1.2
+++ AbstractContainerTestCase.java 25 Jan 2003 15:47:18 -0000 1.3
@@ -7,13 +7,15 @@
*/
package org.apache.avalon.phoenix.test;
-import java.io.File;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.TestCase;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.avalon.phoenix.components.ContainerConstants;
import org.apache.avalon.phoenix.metadata.SarMetaData;
-import org.apache.avalon.phoenix.tools.assembler.Assembler;
+import org.apache.avalon.phoenix.components.assembler.Assembler;
import org.apache.avalon.phoenix.tools.configuration.ConfigurationBuilder;
/**
@@ -35,10 +37,11 @@
{
final Assembler assembler = new Assembler();
assembler.enableLogging( new ConsoleLogger() );
- final ClassLoader classLoader = getClass().getClassLoader();
final Configuration assembly = loadConfig( config );
- return assembler.assembleSar( "test", assembly,
- new File( "." ), classLoader );
+ final Map parameters = new HashMap();
+ parameters.put( ContainerConstants.ASSEMBLY_NAME, "test" );
+ parameters.put( ContainerConstants.ASSEMBLY_CONFIG, assembly );
+ return assembler.buildAssembly( parameters );
}
protected Configuration loadConfig( final String config )
1.2 +235 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/assembler/Assembler.java
1.2 +41 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/assembler/AssemblyException.java
1.2 +6 -0 jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/assembler/Resources.properties
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>