bloritsch 2002/09/18 10:52:49
Modified: fortress/src/java/org/apache/excalibur/fortress
ContainerManagerConstants.java
fortress/src/java/org/apache/excalibur/fortress/util
ContextBuilder.java ContextManager.java
ContextManagerConstants.java
Added: fortress/src/java/org/apache/excalibur/fortress/container
MetaDataContainer.java
Log:
add some initial scratchings for the MetaDataContainer--nowhere near functional, but
I am working from two machines and I need to synchronize my work
Revision Changes Path
1.12 +6 -1
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ContainerManagerConstants.java
Index: ContainerManagerConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ContainerManagerConstants.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ContainerManagerConstants.java 13 Aug 2002 07:57:26 -0000 1.11
+++ ContainerManagerConstants.java 18 Sep 2002 17:52:49 -0000 1.12
@@ -75,6 +75,11 @@
String CONFIGURATION = "container.configuration";
/**
+ * Assembly Configuration: The assembly info to give to the container.
+ */
+ String ASSEMBLY_CONFIGURATION = "container.assembly.config";
+
+ /**
* Parameters: The Parameters object to give to the container.
*/
String PARAMETERS = "container.parameters";
1.1
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/container/MetaDataContainer.java
Index: MetaDataContainer.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.excalibur.fortress.container;
import org.apache.avalon.framework.activity.*;
import org.apache.avalon.framework.context.*;
import org.apache.avalon.framework.configuration.*;
import org.apache.avalon.framework.service.*;
import org.apache.avalon.framework.logger.*;
import org.apache.excalibur.fortress.*;
import org.apache.excalibur.container.classloader.*;
/**
* The MetaDataContainer is the wave of the future. While the
* @link{DefaultContainer} provides a way to upgrade your legacy systems to
* the Fortress containers, Avalon is moving towards Meta Data. In order to
* describe which services the MetaDataContainer will instantiate, that
* information will be placed in an Assembly XML file. Usually the Assembly
* file is located within the JAR that holds your application.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/09/18 17:52:49 $
*/
public class MetaDataContainer
extends AbstractLogEnabled
implements Configurable, Contextualizable, Initializable, Serviceable
{
protected final JarEntries m_jarEntries;
protected Context m_context;
protected Configuration m_config;
protected Configuration m_assemblyInfo;
protected ServiceManager m_parentManager;
protected ClassLoader m_loader;
public MetaDataContainer()
{
m_jarEntries = JarScanner.getSystemJarEntries();
}
public void contextualize( Context context ) throws ContextException
{
m_context = context;
m_assemblyInfo = (Configuration)
context.get( ContainerManagerConstants.ASSEMBLY_CONFIGURATION );
m_loader = (ClassLoader)
context.get( ContainerConstants.CONTEXT_CLASSLOADER );
if ( m_loader instanceof ComponentClassLoader )
{
m_jarEntries.merge( ((ComponentClassLoader) m_loader).getEntries() );
}
}
public void service( ServiceManager manager ) throws ServiceException
{
m_parentManager = manager;
}
public void configure( Configuration config ) throws ConfigurationException
{
m_config = config;
}
public void initialize() throws Exception
{
}
}
1.23 +14 -0
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextBuilder.java
Index: ContextBuilder.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextBuilder.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ContextBuilder.java 9 Aug 2002 05:31:23 -0000 1.22
+++ ContextBuilder.java 18 Sep 2002 17:52:49 -0000 1.23
@@ -131,6 +131,7 @@
defaultContext.put( CONFIGURATION_URI, "conf/system.xconf" );
defaultContext.put( LOGGER_MANAGER_CONFIGURATION_URI, "conf/logkit.xconf" );
defaultContext.put( ROLE_MANAGER_CONFIGURATION_URI,
"resource://ext/system.roles" );
+ defaultContext.put( ASSEMBLY_CONFIGURATION_URI,
"resource://ext/assembly.xml" );
defaultContext.makeReadOnly();
@@ -197,6 +198,19 @@
public ContextBuilder setContainerConfiguration( String location )
{
context.put( CONFIGURATION_URI, location );
+ return this;
+ }
+
+ public ContextBuilder setAssemblyConfiguration( Configuration config )
+ {
+ context.put( ASSEMBLY_CONFIGURATION, config );
+ context.put( ASSEMBLY_CONFIGURATION_URI, null );
+ return this;
+ }
+
+ public ContextBuilder setAssemblyConfiguration( String location )
+ {
+ context.put( ASSEMBLY_CONFIGURATION_URI, location );
return this;
}
1.39 +44 -2
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java
Index: ContextManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextManager.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- ContextManager.java 6 Sep 2002 15:41:17 -0000 1.38
+++ ContextManager.java 18 Sep 2002 17:52:49 -0000 1.39
@@ -484,7 +484,7 @@
catch( ContextException e )
{
}
-
+
try
{
threadsPerProcessor = (Integer) rootContext.get( THREADS_CPU );
@@ -868,6 +868,48 @@
assumeOwnership( instrumentManager );
childContext.put( INSTRUMENT_MANAGER, instrumentManager );
+ }
+ }
+
+ /**
+ * Will set up a Assembly Descriptor if none is supplied.
+ *
+ * <p>The postcondition is that
+ * <code>childContext.get( Container.LOGGER_MANAGER )</code> should
+ * return a valid logger manager.</p>
+ *
+ * @throws Exception if it cannot instantiate the LoggerManager
+ */
+ protected void initializeAssemblyConfig() throws Exception
+ {
+ try
+ {
+ containerManagerContext.put( ASSEMBLY_CONFIGURATION, rootContext.get(
ASSEMBLY_CONFIGURATION ) );
+ }
+ catch( ContextException ce )
+ {
+ Configuration containerConfig = getConfiguration(
ASSEMBLY_CONFIGURATION, ASSEMBLY_CONFIGURATION_URI );
+ if( containerConfig == null )
+ {
+ // No config.
+ // Does the parent supply a logger manager?
+ try
+ {
+ containerManagerContext.get( ASSEMBLY_CONFIGURATION );
+
+ // OK, done.
+ return;
+ }
+ catch( ContextException cex )
+ {
+ // Guess there is none.
+ return;
+ }
+ }
+ else
+ {
+ containerManagerContext.put( ASSEMBLY_CONFIGURATION,
containerConfig );
+ }
}
}
}
1.13 +2 -2
jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextManagerConstants.java
Index: ContextManagerConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/util/ContextManagerConstants.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ContextManagerConstants.java 13 Aug 2002 07:57:27 -0000 1.12
+++ ContextManagerConstants.java 18 Sep 2002 17:52:49 -0000 1.13
@@ -70,8 +70,8 @@
String ROLE_MANAGER_CONFIGURATION = "container.roleManager.config";
String ROLE_MANAGER_CONFIGURATION_URI = "container.roleManager.config.uri";
+ String ASSEMBLY_CONFIGURATION_URI = "container.assembly.config.uri";
String CONFIGURATION_URI = "container.configuration.uri";
String SERVICE_MANAGER_PARENT = "container.serviceManager.parent";
- String SERVICE_MANAGER_CONFIGURATION_URI =
"container.componentManager.config.uri";
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>