You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/04/13 07:45:11 UTC
cvs commit: avalon-sandbox/merlin/merlin-smp/src/repository/james block.xml
mcconnell 2003/04/12 22:45:11
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/appliance
DefaultApplianceRepository.java
merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
DefaultBlockLoader.java
merlin/merlin-core/src/java/org/apache/avalon/merlin/container/builder
XMLContainerCreator.java
merlin/merlin-smp/src/examples/afs/simple/conf block.xml
merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank
BankTestCase.java
merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/BLOCK-INF
block.xml
merlin/merlin-smp/src/repository/demo block.xml
merlin/merlin-smp/src/repository/james block.xml
Log:
General updates supporting reengineering of the root block model (not totally perfect just yet - but heading in the right direction).
Revision Changes Path
1.7 +7 -0 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java
Index: DefaultApplianceRepository.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultApplianceRepository.java 13 Apr 2003 02:21:15 -0000 1.6
+++ DefaultApplianceRepository.java 13 Apr 2003 05:45:09 -0000 1.7
@@ -122,6 +122,8 @@
"Unexpected error while creating the root repository URL.";
throw new ApplianceRuntimeException( error, e );
}
+
+ System.out.println( "# ROOT: " + m_url + ", " + this );
}
/**
@@ -151,6 +153,8 @@
+ parent.getURL() + " with the name: " + name;
throw new ApplianceRuntimeException( error, e );
}
+
+ System.out.println( "# CHILD: " + m_url + ", " + this );
}
//==================================================================
@@ -359,6 +363,9 @@
{
final String key = appliance.getURL().getPath().substring( local.length() );
m_appliances.put( key, appliance );
+
+ System.out.println( "# REGISTER - key: '" + key + "' appliance: " + appliance + " in " + this );
+
} else
{
final String error =
1.9 +112 -132 avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java
Index: DefaultBlockLoader.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultBlockLoader.java 13 Apr 2003 03:20:32 -0000 1.8
+++ DefaultBlockLoader.java 13 Apr 2003 05:45:09 -0000 1.9
@@ -141,6 +141,8 @@
* <li>error management
* </ul>
*
+ * WARNING: This class is in the process of refactoring.
+ *
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
* @see DefaultBlock
@@ -299,136 +301,7 @@
public Block install( final URL path, final URL overrides )
throws BlockException
{
- return installSource( m_engine, Container.PATH_SEPERATOR, path, overrides );
- }
-
- /**
- * Load a block declared in the supplied block and configuration URL.
- * The path URL may refer to a XML file containing a block directive
- * or a jar file containing a block.xml file.
- *
- * @param path the block defintion URL
- * @param overrides the URL to a configuration containing configuration overrides
- * @return the block
- */
- private Block installSource(
- final EngineClassLoader loader, final String root, final URL path, final URL overrides )
- throws BlockException
- {
-
- Configuration block = getSourceConfiguration( path );
- Configuration config = getTargetsConfiguration( overrides );
- String name = getBlockName( block );
-
- Configuration[] targets = config.getChildren( "target" );
-
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug("target override count: " + targets.length );
- }
-
- for( int j=0; j<targets.length; j++ )
- {
- Configuration target = targets[j];
- try
- {
- String key = root + name + "/" + target.getAttribute( "name" );
- m_library.put( key, target.getChild( "configuration" ) );
- getLogger().debug( "registering configuration for key: " + key );
- }
- catch( Throwable e )
- {
- final String error =
- "A configuration target override does not declare a target."
- + "\nURL: " + overrides
- + ConfigurationUtil.list( target );
- throw new BlockException( error, e );
- }
- }
-
- URL base = getBasePath( path );
- Configuration implementation = block.getChild( "implementation", false );
- if( implementation == null )
- {
- implementation = block.getChild( "container" );
- }
- Configuration engineConfig = implementation.getChild( "engine" );
- EngineClassLoader engine = null;
- try
- {
- engine = createEngine( loader, m_home, engineConfig, name, base, base );
- }
- catch( Throwable e )
- {
- final String error =
- "Could not construct engine for block: " + name;
- throw new BlockException( error, e );
- }
-
- //
- // create the containment profile and extract the list of
- // container profiles
- //
-
- ContainmentProfile descriptor =
- createContainmentProfile( name, engine, implementation );
-
- //
- // create the block dependencies
- //
-
- Configuration depsConfig = block.getChild( "dependencies", false );
- DependencyDescriptor[] dependencies = null;
- if( depsConfig != null )
- {
- try
- {
- dependencies = TYPE_CREATOR.buildDependencies( depsConfig );
- }
- catch( ConfigurationException ce )
- {
- final String error =
- "Invalid dependencies declaration in block specification:\n"
- + ConfigurationUtil.list( depsConfig );
- throw new BlockException( error, ce );
- }
- }
-
- //
- // create the block services
- //
-
- Configuration servicesConfig = block.getChild( "dependencies" , false );
- ServiceDescriptor[] services = null;
- if( servicesConfig != null )
- {
- try
- {
- services = TYPE_CREATOR.buildServices( servicesConfig );
- }
- catch( ConfigurationException ce )
- {
- final String error =
- "Invalid services declaration in block specification:\n"
- + ConfigurationUtil.list( depsConfig );
- throw new BlockException( error, ce );
- }
- }
-
- //
- // create any subsidiary blocks
- //
-
- String partition = root + name + Container.PATH_SEPERATOR;
- List blocks =
- createChildBlocks( engine, partition, implementation, config, base );
-
- //
- // create the block
- //
-
- return createBlock(
- dependencies, services, engine, blocks, descriptor, name, root, config );
+ return createRootBlock( path, overrides );
}
//==============================================================
@@ -746,7 +619,6 @@
"Cannot create a block due to an error during meta info creation.";
throw new BlockException( error, e );
}
-
}
/**
@@ -809,6 +681,114 @@
"Unable to create block: " + partition + name;
throw new BlockException( error, e );
}
+ }
+
+ /**
+ * Load a block declared in the supplied block and configuration URL.
+ * The path URL may refer to a XML file containing a block directive
+ * or a jar file containing a block.xml file.
+ *
+ * @param path the block defintion URL
+ * @param overrides the URL to a configuration containing configuration overrides
+ * @return the block
+ */
+ private Block createRootBlock( final URL path, final URL overrides )
+ throws BlockException
+ {
+
+ Configuration block = getSourceConfiguration( path );
+ Configuration config = getTargetsConfiguration( overrides );
+
+ Configuration[] targets = config.getChildren( "target" );
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug("target override count: " + targets.length );
+ }
+
+ for( int j=0; j<targets.length; j++ )
+ {
+ Configuration target = targets[j];
+ try
+ {
+ String key = Container.PATH_SEPERATOR + target.getAttribute( "name" );
+ m_library.put( key, target.getChild( "configuration" ) );
+ getLogger().debug( "registering configuration for key: " + key );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "A configuration target override does not declare a target."
+ + "\nURL: " + overrides
+ + ConfigurationUtil.list( target );
+ throw new BlockException( error, e );
+ }
+ }
+
+ URL base = getBasePath( path );
+
+ //
+ // create the containment profile and extract the list of
+ // container profiles
+ //
+
+ ContainmentProfile descriptor =
+ createContainmentProfile( "", m_engine, block );
+
+ //
+ // create the block dependencies
+ //
+
+ Configuration depsConfig = block.getChild( "dependencies", false );
+ DependencyDescriptor[] dependencies = null;
+ if( depsConfig != null )
+ {
+ try
+ {
+ dependencies = TYPE_CREATOR.buildDependencies( depsConfig );
+ }
+ catch( ConfigurationException ce )
+ {
+ final String error =
+ "Invalid dependencies declaration in block specification:\n"
+ + ConfigurationUtil.list( depsConfig );
+ throw new BlockException( error, ce );
+ }
+ }
+
+ //
+ // create the block services
+ //
+
+ Configuration servicesConfig = block.getChild( "dependencies" , false );
+ ServiceDescriptor[] services = null;
+ if( servicesConfig != null )
+ {
+ try
+ {
+ services = TYPE_CREATOR.buildServices( servicesConfig );
+ }
+ catch( ConfigurationException ce )
+ {
+ final String error =
+ "Invalid services declaration in block specification:\n"
+ + ConfigurationUtil.list( depsConfig );
+ throw new BlockException( error, ce );
+ }
+ }
+
+ //
+ // create any subsidiary blocks
+ //
+
+ List blocks =
+ createChildBlocks( m_engine, Container.PATH_SEPERATOR, block, config, base );
+
+ //
+ // create the block
+ //
+
+ return createBlock(
+ dependencies, services, m_engine, blocks, descriptor, "", Container.PATH_SEPERATOR, config );
}
private JarFile getJarFile( URL url ) throws MalformedURLException
1.5 +7 -6 avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/container/builder/XMLContainerCreator.java
Index: XMLContainerCreator.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/container/builder/XMLContainerCreator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLContainerCreator.java 13 Apr 2003 03:36:47 -0000 1.4
+++ XMLContainerCreator.java 13 Apr 2003 05:45:10 -0000 1.5
@@ -151,7 +151,8 @@
/**
* Create an explicit {@link ContainmentProfile} instance from a
- * configuration.
+ * configuration. The returned profile does not include subcontainers
+ * or contained component profiles.
* @param type the component type
* @param config the profile description
* @return the profile
@@ -164,10 +165,11 @@
return createContainmentProfile( type, config, "container" );
}
-
/**
* Create an explicit {@link ContainmentProfile} instance from a
- * configuration.
+ * configuration. The returned profile does not include subcontainers
+ * or contained component profiles.
+ *
* @param type the component type
* @param config the profile description
* @return the profile
@@ -204,8 +206,7 @@
//
return (ContainmentProfile) getConstructor().newInstance(
- new Object[]{
- name, params, config, context, categories, type, mode } );
+ new Object[]{ name, params, config, context, categories, type, mode } );
}
/**
1.4 +1 -1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/conf/block.xml
Index: block.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/conf/block.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- block.xml 10 Apr 2003 04:36:14 -0000 1.3
+++ block.xml 13 Apr 2003 05:45:10 -0000 1.4
@@ -1,6 +1,6 @@
<block name="banking">
- <container>
+ <container name="banking">
<component name="bank" class="org.apache.bank.impl.BankProvider" activation="startup">
<configuration>
<name>Apache Financial Services</name>
1.4 +21 -0 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank/BankTestCase.java
Index: BankTestCase.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank/BankTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BankTestCase.java 10 Apr 2003 14:19:49 -0000 1.3
+++ BankTestCase.java 13 Apr 2003 05:45:11 -0000 1.4
@@ -53,9 +53,30 @@
super( name );
}
+ public void testRoot() throws Exception
+ {
+ try
+ {
+ URL root = (URL) super.getRootBlock().getURL();
+ URL url = new URL( root, "/");
+ System.out.println( "URL: " + url );
+ System.out.println( "OBJECT: " + url.getContent() );
+ }
+ catch( Throwable e )
+ {
+ final String msg = "Root test failure.";
+ final String error = ExceptionHelper.packException( msg, e );
+ System.out.println( error );
+ assertTrue( false );
+ return;
+ }
+
+ }
+
public void testBank() throws Exception
{
Bank bank = null;
+
try
{
URL root = (URL) super.getRootBlock().getURL();
1.2 +1 -1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/BLOCK-INF/block.xml
Index: block.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/BLOCK-INF/block.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- block.xml 7 Apr 2003 16:59:28 -0000 1.1
+++ block.xml 13 Apr 2003 05:45:11 -0000 1.2
@@ -1,6 +1,6 @@
<block name="banking">
- <container>
+ <container name="banking">
<component name="bank" class="org.apache.bank.impl.BankProvider" activation="startup">
<configuration>
<name>Apache Financial Services</name>
1.3 +6 -11 avalon-sandbox/merlin/merlin-smp/src/repository/demo/block.xml
Index: block.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/repository/demo/block.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- block.xml 29 Mar 2003 03:25:57 -0000 1.2
+++ block.xml 13 Apr 2003 05:45:11 -0000 1.3
@@ -5,7 +5,7 @@
<block name="demo">
- <implementation>
+ <container name="xxx">
<!--
Setup the classloader.
@@ -16,11 +16,6 @@
<repository>
<resource id="demo:merlin-demo" version="1.0"/>
</repository>
- <!--
- <fileset dir=".">
- <include name="merlin-demo-1.0.jar"/>
- </fileset>
- -->
</classpath>
</engine>
@@ -29,24 +24,24 @@
multiple components and multiple containers
-->
- <appliance name="standard"
+ <component name="standard"
class="org.apache.avalon.playground.StandardComponent" activation="startup">
<context class="org.apache.avalon.playground.StandardContextImp"/>
<configuration>
<message>Message declared in block descriptor.</message>
</configuration>
- </appliance>
+ </component>
<container name="test">
- <appliance name="standard"
+ <component name="standard"
class="org.apache.avalon.playground.StandardComponent" activation="startup">
<context class="org.apache.avalon.playground.StandardContextImp"/>
<configuration>
<message>Standard component inside a nested block.</message>
</configuration>
- </appliance>
+ </component>
</container>
- </implementation>
+ </container>
</block>
1.3 +35 -35 avalon-sandbox/merlin/merlin-smp/src/repository/james/block.xml
Index: block.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/repository/james/block.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- block.xml 29 Mar 2003 03:25:57 -0000 1.2
+++ block.xml 13 Apr 2003 05:45:11 -0000 1.3
@@ -16,9 +16,9 @@
<!--
Block implementation. The implementation element may contain component
and container entities. The block implementation statement is equivalent
- to a root container who's name corresponds to the name of the block.
+ to a root container.
-->
- <implementation>
+ <container name="impl">
<categories priority="INFO"/>
@@ -46,23 +46,23 @@
</classpath>
</engine>
- <appliance name="james" class="org.apache.james.James"
+ <component name="james" class="org.apache.james.James"
activation="true">
<!-- see config.xml for configuration -->
- </appliance>
+ </component>
- <appliance name="dns" class="org.apache.james.dnsserver.DNSServer"
+ <component name="dns" class="org.apache.james.dnsserver.DNSServer"
activation="true">
<!-- see config.xml for configuration -->
- </appliance>
+ </component>
- <appliance name="remote"
+ <component name="remote"
class="org.apache.james.remotemanager.RemoteManager"
activation="true">
<!-- see config.xml for port and handler configuration -->
- </appliance>
+ </component>
- <appliance name="pop3"
+ <component name="pop3"
class="org.apache.james.pop3server.POP3Server"
activation="true">
<configuration enabled="true">
@@ -72,9 +72,9 @@
<connectiontimeout>120000</connectiontimeout>
</handler>
</configuration>
- </appliance>
+ </component>
- <appliance name="smtp"
+ <component name="smtp"
class="org.apache.james.smtpserver.SMTPServer"
activation="true">
<configuration enabled="true">
@@ -85,9 +85,9 @@
<maxmessagesize>0</maxmessagesize>
</handler>
</configuration>
- </appliance>
+ </component>
- <appliance name="threads"
+ <component name="threads"
class="org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager"
activation="true">
<configuration>
@@ -100,9 +100,9 @@
<min-spare-threads>20</min-spare-threads>
</thread-group>
</configuration>
- </appliance>
+ </component>
- <appliance name="store"
+ <component name="store"
class="org.apache.avalon.cornerstone.blocks.masterstore.RepositoryManager"
activation="true">
<configuration>
@@ -137,10 +137,10 @@
</repository>
</repositories>
</configuration>
- </appliance>
+ </component>
<!-- The High Level Storage block -->
- <appliance name="mailstore"
+ <component name="mailstore"
class="org.apache.james.core.AvalonMailStore"
activation="true">
<configuration>
@@ -217,9 +217,9 @@
<repository destinationURL="file://var/mail/spool/" type="SPOOL"/>
</spoolRepository>
</configuration>
- </appliance>
+ </component>
- <appliance name="users-store"
+ <component name="users-store"
class="org.apache.james.core.AvalonUsersStore"
activation="true">
<configuration>
@@ -228,18 +228,18 @@
<destination URL="file://var/users/"/>
</repository>
</configuration>
- </appliance>
+ </component>
- <appliance name="connections"
+ <component name="connections"
class="org.apache.james.util.connection.SimpleConnectionManager"
activation="true">
<configuration>
<idle-timeout>300000</idle-timeout>
<max-connections>30</max-connections>
</configuration>
- </appliance>
+ </component>
- <appliance name="sockets"
+ <component name="sockets"
class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketManager"
activation="true">
<configuration>
@@ -250,17 +250,17 @@
<factory name="plain" class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketFactory"/>
</client-sockets>
</configuration>
- </appliance>
+ </component>
- <appliance name="scheduler"
+ <component name="scheduler"
class="org.apache.avalon.cornerstone.blocks.scheduler.DefaultTimeScheduler"
activation="true"/>
- <appliance name="datasources"
+ <component name="datasources"
class="org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector"
activation="true"/>
- <appliance name="spool"
+ <component name="spool"
class="org.apache.james.transport.JamesSpoolManager"
activation="true">
<configuration>
@@ -336,11 +336,11 @@
</mailet>
</processor>
</configuration>
- </appliance>
+ </component>
<!-- NNTP Repository -->
- <appliance name="nntp-repository"
+ <component name="nntp-repository"
class="org.apache.james.nntpserver.repository.NNTPRepositoryImpl"
activation="false">
<configuration>
@@ -366,9 +366,9 @@
</configuration>
</spool>
</configuration>
- </appliance>
+ </component>
- <appliance name="nntp" class="org.apache.james.nntpserver.NNTPServer"
+ <component name="nntp" class="org.apache.james.nntpserver.NNTPServer"
activation="false">
<configuration enabled="false">
<port>119</port>
@@ -378,9 +378,9 @@
<authRequired>false</authRequired>
</handler>
</configuration>
- </appliance>
+ </component>
- <appliance name="fetchpop" class="org.apache.james.fetchpop.FetchScheduler"
+ <component name="fetchpop" class="org.apache.james.fetchpop.FetchScheduler"
activation="false">
<configuration enabled="false">
<fetch name="mydomain.com">
@@ -392,8 +392,8 @@
<interval>600000</interval>
</fetch>
</configuration>
- </appliance>
+ </component>
- </implementation>
+ </container>
</block>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org