mcconnell 2002/12/11 16:32:33
Modified: assembly/src/java/org/apache/avalon/assembly/appliance
Appliance.java DefaultAppliance.java
assembly/src/java/org/apache/avalon/assembly/engine
Engine.java EngineClassLoader.java
assembly/src/java/org/apache/avalon/assembly/lifestyle
LifestyleHandler.java PooledLifestyleHandler.java
SingletonLifestyleHandler.java
ThreadLocalLifestyleHandler.java
TransientLifestyleHandler.java
assembly/src/java/org/apache/avalon/assembly/profile
ProfileManager.java
assembly/src/test/config block.xml
assembly/src/test/org/apache/avalon/assembly/engine
EngineTestCase.java
Log:
Updating test case to handle direct type driven assembly.
Revision Changes Path
1.5 +8 -2
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java
Index: Appliance.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Appliance.java 3 Dec 2002 06:57:25 -0000 1.4
+++ Appliance.java 12 Dec 2002 00:32:32 -0000 1.5
@@ -155,8 +155,14 @@
void addExtensionProvider( StageDescriptor stage, Appliance appliance );
/**
+ * Activate of the appliance.
+ * @return the implementation object
+ */
+ Object access() throws LifestyleException;
+
+ /**
* Activate a service provided by the appliance.
- * @param appliance the appliance to deploy
+ * @param dependency the service dependecy decsriptor
*/
Object access( DependencyDescriptor dependency ) throws LifestyleException;
1.7 +9 -1
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
Index: DefaultAppliance.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultAppliance.java 7 Dec 2002 09:34:27 -0000 1.6
+++ DefaultAppliance.java 12 Dec 2002 00:32:32 -0000 1.7
@@ -408,6 +408,14 @@
}
/**
+ * Activate of the appliance.
+ */
+ public Object access() throws LifestyleException
+ {
+ return m_handler.access();
+ }
+
+ /**
* Activate an extension handler provided by the appliance.
* @param appliance the appliance to deploy
*/
1.5 +2 -2
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java
Index: Engine.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Engine.java 9 Dec 2002 03:03:47 -0000 1.4
+++ Engine.java 12 Dec 2002 00:32:32 -0000 1.5
@@ -81,7 +81,7 @@
LifestyleHandler createLifestyleHandler( Appliance appliance, Context context );
/**
- * Register a type and associated profiles with the container.
+ * Dynamic registration of a type and associated profiles with the container.
* @param path the path to the appliance implementation class
* @return the appliance
* @exception EngineRuntimeException if a registration error occurs
1.6 +2 -1
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
Index: EngineClassLoader.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EngineClassLoader.java 11 Dec 2002 08:11:04 -0000 1.5
+++ EngineClassLoader.java 12 Dec 2002 00:32:32 -0000 1.6
@@ -793,6 +793,7 @@
}
}
+
/**
* Resolve an appliance capable of supporting a service
* referenced.
1.2 +7 -1
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java
Index: LifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LifestyleHandler.java 29 Nov 2002 13:04:56 -0000 1.1
+++ LifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.2
@@ -62,6 +62,12 @@
public interface LifestyleHandler
{
/**
+ * Activate of the appliance.
+ * @return the implementation object
+ */
+ Object access() throws LifestyleException;
+
+ /**
* Activate a service provided by the appliance.
* @param appliance the appliance to deploy
*/
1.4 +2 -2
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java
Index: PooledLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/PooledLifestyleHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PooledLifestyleHandler.java 3 Dec 2002 06:57:26 -0000 1.3
+++ PooledLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.4
@@ -205,7 +205,7 @@
* @return an instance of the type defined by the profile
* @exception Exception if an error occurs while aquiring the object
*/
- private Object access() throws LifestyleException
+ public Object access() throws LifestyleException
{
try
{
1.5 +2 -2
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java
Index: SingletonLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/SingletonLifestyleHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SingletonLifestyleHandler.java 30 Nov 2002 21:46:39 -0000 1.4
+++ SingletonLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.5
@@ -104,7 +104,7 @@
* Activate the implementation.
* @param appliance the appliance to deploy
*/
- private Object access() throws LifestyleException
+ public Object access() throws LifestyleException
{
if( getLogger().isDebugEnabled() )
{
1.4 +1 -1
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java
Index: ThreadLocalLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/ThreadLocalLifestyleHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ThreadLocalLifestyleHandler.java 30 Nov 2002 21:46:39 -0000 1.3
+++ ThreadLocalLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.4
@@ -95,7 +95,7 @@
* @return an instance of the type defined by the appliance
* @exception Exception if an access phase error occurs
*/
- private Object access() throws LifestyleException
+ public Object access() throws LifestyleException
{
if( getLogger().isDebugEnabled() )
{
1.3 +2 -2
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java
Index: TransientLifestyleHandler.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/TransientLifestyleHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransientLifestyleHandler.java 29 Nov 2002 17:37:30 -0000 1.2
+++ TransientLifestyleHandler.java 12 Dec 2002 00:32:32 -0000 1.3
@@ -104,7 +104,7 @@
* Activate the implementation.
* @param appliance the appliance to deploy
*/
- private Object access() throws LifestyleException
+ public Object access() throws LifestyleException
{
Object object = newInstance();
super.processAccessStage( object );
1.5 +29 -1
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java
Index: ProfileManager.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/profile/ProfileManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProfileManager.java 7 Dec 2002 09:34:28 -0000 1.4
+++ ProfileManager.java 12 Dec 2002 00:32:32 -0000 1.5
@@ -53,6 +53,7 @@
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.Iterator;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
@@ -295,6 +296,33 @@
return profile;
}
+ /**
+ * Get the preferred profile for a supplied type.
+ * @param type the component type
+ * @return the profile matching the type
+ * @exception UnknownTypeException if the type is unknown to the manager
+ */
+ public Profile getProfile( Type type ) throws UnknownTypeException
+ {
+ Enumeration enum = m_profiles.elements();
+ while( enum.hasMoreElements() )
+ {
+ Profile profile = (Profile) enum.nextElement();
+ if( profile.getType().equals( type ) )
+ {
+ return profile;
+ }
+ }
+ if( m_parent != null )
+ {
+ return m_parent.getProfile( type );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
/**
* Get the set of profiles declared for a particular type.
* @param type the component type
1.2 +0 -4 avalon-sandbox/assembly/src/test/config/block.xml
Index: block.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/assembly/src/test/config/block.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- block.xml 11 Dec 2002 04:57:17 -0000 1.1
+++ block.xml 12 Dec 2002 00:32:32 -0000 1.2
@@ -5,12 +5,9 @@
<block>
- <categories priority="INFO"/>
-
<container>
<component name="basic" class="org.apache.excalibur.playground.BasicComponent"
activation="startup">
- <categories priority="DEBUG"/>
<context class="org.apache.excalibur.playground.BasicContext">
<entry key="location">My Place</entry>
<import name="avalon:home" key="home" />
@@ -18,7 +15,6 @@
</component>
<component name="complex"
class="org.apache.excalibur.playground.ComplexComponent" activation="startup">
- <categories priority="DEBUG"/>
<context>
<entry key="location" value="Paris"/>
</context>
1.6 +23 -1
avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
Index: EngineTestCase.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EngineTestCase.java 9 Dec 2002 03:04:56 -0000 1.5
+++ EngineTestCase.java 12 Dec 2002 00:32:32 -0000 1.6
@@ -9,11 +9,14 @@
package org.apache.avalon.assembly.engine;
import java.io.File;
+import java.util.Map;
+import java.util.Hashtable;
import junit.framework.TestCase;
import org.apache.avalon.framework.Version;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.meta.info.*;
+import org.apache.avalon.meta.model.*;
import org.apache.avalon.assembly.TestCaseBase;
import org.apache.avalon.assembly.engine.Engine;
import org.apache.avalon.assembly.appliance.Appliance;
@@ -197,7 +200,26 @@
getLogger().error( error );
assertTrue( false );
}
-
}
+ public void testDirect()
+ {
+ final String classname = "org.apache.avalon.playground.ComplexComponent";
+
+ try
+ {
+ Type type = m_engine.getRepository().getTypeManager().getType(
classname );
+ Profile profile =
m_engine.getRepository().getProfileManager().getProfile( type );
+ Map map = new Hashtable();
+ Appliance appliance = m_engine.createAppliance( profile, map, false );
+ m_engine.assemble( appliance );
+ assertTrue( appliance.access() != null );
+ }
+ catch( Throwable e )
+ {
+ System.out.println("failure for create type using : " + classname );
+ assertTrue( false );
+ e.printStackTrace();
+ }
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>