Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2895 - in development/laboratory/users/niclas/osgi/metro: . activation/impl activation/impl/src/main/net/dpml/activation/impl activation/providers composition/api/src/main/net/dpml/composition composition/api/src/main/net/dpml/composition/model composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/spi/src/main/net/dpml/composition/provider composition/test main main/src/main/net/dpml/metro osgi osgi/src/main/net/dpml/osgi system unit unit/src/main/net/dpml/metro/unit

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT hedhman.org
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2895 - in development/laboratory/users/niclas/osgi/metro: . activation/impl activation/impl/src/main/net/dpml/activation/impl activation/providers composition/api/src/main/net/dpml/composition composition/api/src/main/net/dpml/composition/model composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/spi/src/main/net/dpml/composition/provider composition/test main main/src/main/net/dpml/metro osgi osgi/src/main/net/dpml/osgi system unit unit/src/main/net/dpml/metro/unit
  • Date: Mon, 20 Jun 2005 07:13:40 -0400

Author: niclas AT hedhman.org
Date: Mon Jun 20 07:13:39 2005
New Revision: 2895

Added:

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractLifestyleManager.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ApplianceInvocationHandler.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ContainerUtil.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultApplianceMetro.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/SingletonLifestyleManager.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ThreadLifestyleManager.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/TransientLifestyleManager.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
(contents, props changed)
Removed:
development/laboratory/users/niclas/osgi/metro/activation/providers/
development/laboratory/users/niclas/osgi/metro/system/
Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/build.xml

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractAppliance.java

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/BlockInvocationHandler.java

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultBlock.java

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java

development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java

development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ContainmentModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/ContainmentProfileBuilder.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentContext.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionContext.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionFactory.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentContext.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentContext.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFileSelector.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFilesetModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultImportModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ComponentContext.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionContext.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ContainmentContext.java

development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/DeploymentContext.java
development/laboratory/users/niclas/osgi/metro/composition/test/build.xml
development/laboratory/users/niclas/osgi/metro/index.xml
development/laboratory/users/niclas/osgi/metro/main/build.xml

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/Metro.java
development/laboratory/users/niclas/osgi/metro/osgi/build.xml

development/laboratory/users/niclas/osgi/metro/osgi/src/main/net/dpml/osgi/Metro.java
development/laboratory/users/niclas/osgi/metro/unit/build.xml

development/laboratory/users/niclas/osgi/metro/unit/src/main/net/dpml/metro/unit/CompositionTestCase.java
Log:
Removing the system/ which is a lot of overhead for very little
functionality. Also merged the activation-provider-metro into
activation-impl, since the split is not logical and also no longer relevant.

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/build.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/activation/impl/build.xml
(original)
+++ development/laboratory/users/niclas/osgi/metro/activation/impl/build.xml
Mon Jun 20 07:13:39 2005
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-activation-impl" default="install" basedir="."
+<project name="dpml-activation-impl" default="install" basedir="."
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >

<transit:import uri="artifact:template:dpml/magic/standard"/>

<target name="init" depends="standard.init">
- <x:filter key="dpml-activation-metro-provider" feature="plugin"
+ <x:filter key="dpml-activation-impl" feature="plugin"
token="METRO-RUNTIME-PROVIDER-SPEC"/>
</target>


Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractAppliance.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractAppliance.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractAppliance.java
Mon Jun 20 07:13:39 2005
@@ -31,7 +31,8 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id$
*/
-public abstract class AbstractAppliance implements Appliance
+public abstract class AbstractAppliance
+ implements Appliance
{
//-------------------------------------------------------------------
// immutable state

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractLifestyleManager.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/AbstractLifestyleManager.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.logging.Logger;
+import net.dpml.meta.info.InfoDescriptor;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+
+/**
+ * Abstract implentation class for a lifestyle handler.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: AbstractLifestyleManager.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+ */
+public abstract class AbstractLifestyleManager implements LifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final ComponentFactory m_factory;
+
+ private final Logger m_logger;
+
+ private final ReferenceQueue m_liberals = new ReferenceQueue();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance.
+ * @param model the component model
+ * @param factory the component factory
+ */
+ public AbstractLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ m_factory = factory;
+ m_model = model;
+ m_logger = model.getLogger();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public abstract void commission() throws Exception;
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public abstract void decommission();
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ return handleResolve();
+ }
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ return resolve();
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ handleRelease( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ public void finalize( Object instance )
+ {
+ synchronized( m_factory )
+ {
+ if( instance != null )
+ {
+ m_factory.etherialize( instance );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected abstract Object handleResolve() throws Exception;
+
+ protected abstract void handleRelease( Object instance );
+
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ protected ComponentFactory getComponentFactory()
+ {
+ return m_factory;
+ }
+
+ /**
+ * Return the liberal queue.
+ */
+ ReferenceQueue getLiberalQueue()
+ {
+ return m_liberals;
+ }
+
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.WEAK )
+ {
+ return new WeakReference( instance, m_liberals );
+ }
+ else if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new StrongReference( instance );
+ }
+ }
+
+ private class StrongReference extends WeakReference
+ {
+ private final Object m_instance;
+
+ public StrongReference( Object instance )
+ {
+ super( instance );
+ m_instance = instance;
+ }
+
+ public Object get()
+ {
+ return m_instance;
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ protected void finalize()
+ throws Throwable
+ {
+ decommission();
+ super.finalize();
+ }
+
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ApplianceInvocationHandler.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ApplianceInvocationHandler.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ApplianceException;
+import net.dpml.activation.TransientApplianceException;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.Reclaimer;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.lang.NullArgumentException;
+import net.dpml.logging.Logger;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * This makes a dynamic proxy for an object. The object can be represented
+ * by one, some or all of it's interfaces.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: ApplianceInvocationHandler.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+ */
+public final class ApplianceInvocationHandler
+ implements InvocationHandler, Reclaimer
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final DefaultApplianceMetro m_appliance;
+ private final Logger m_logger;
+ private final ComponentModel m_model;
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Object m_instance;
+ private boolean m_destroyed = false;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Create a proxy invocation handler.
+ *
+ * @param appliance the runtime appliance
+ * @param logger the assigned logging channel
+ */
+ ApplianceInvocationHandler( DefaultApplianceMetro appliance, Logger
logger )
+ throws NullArgumentException
+ {
+ assertNotNull( appliance, "appliance" );
+ assertNotNull( logger, "logger" );
+
+ m_appliance = appliance;
+ m_logger = logger;
+ m_model = m_appliance.getComponentModel();
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Invoke the specified method on underlying object.
+ * This is called by the proxy object.
+ *
+ * @param proxy the proxy object
+ * @param method the method invoked on proxy object
+ * @param args the arguments supplied to method
+ * @return the return value of method
+ * @throws Throwable if an error occurs
+ * @exception NullArgumentException if any one of the proxy or method
arguments
+ * is null, or if the object instance has been destroyed
earlier.
+ */
+ public Object invoke( final Object proxy, final Method method, final
Object[] args )
+ throws Throwable, NullArgumentException
+ {
+ if( proxy == null )
+ throw new NullArgumentException( "proxy" );
+ if( method == null )
+ throw new NullArgumentException( "method" );
+ if( m_destroyed )
+ throw new NullArgumentException( "destroyed" );
+
+ try
+ {
+ final Object instance = getInstance();
+ return method.invoke( instance, args );
+ }
+ catch( Throwable e )
+ {
+ throw handleInvocationThrowable( e );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Reclaimer
+ //-------------------------------------------------------------------
+
+ public void release()
+ {
+ if( !m_destroyed )
+ {
+ m_destroyed = true;
+ final String message =
+ "Releasing component ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ m_appliance.release( m_instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected void finalize()
+ throws Throwable
+ {
+ if( !m_destroyed && ( null != m_instance ) )
+ {
+ final String message =
+ "Finalizing proxy ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ release();
+ }
+ super.finalize();
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private Object getInstance() throws Exception
+ {
+ if( m_instance == null )
+ m_instance = m_appliance.resolve( false );
+ return m_instance;
+ }
+
+ private Throwable handleInvocationThrowable( Throwable e )
+ {
+ final String error =
+ "Delegation error raised by component: " +
m_appliance.toString();
+ while( true )
+ {
+ if( e instanceof TransientApplianceException )
+ {
+ TransientApplianceException t =
+ (TransientApplianceException) e;
+ return new TransientRuntimeException(
+ t.getMessage(), t.getDelay() );
+ }
+ else if( e instanceof UndeclaredThrowableException )
+ {
+ Throwable cause =
+ ((UndeclaredThrowableException)
e).getUndeclaredThrowable();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else if( e instanceof InvocationTargetException )
+ {
+ Throwable cause =
+ ((InvocationTargetException) e).getTargetException();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return e;
+ }
+
+ private void assertNotNull( Object object, String key )
+ throws NullArgumentException
+ {
+ if( null == object )
+ {
+ throw new NullArgumentException( key );
+ }
+ }
+}

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/BlockInvocationHandler.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/BlockInvocationHandler.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/BlockInvocationHandler.java
Mon Jun 20 07:13:39 2005
@@ -18,6 +18,13 @@

package net.dpml.activation.impl;

+import net.dpml.activation.ApplianceException;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.Reclaimer;
+import net.dpml.composition.model.ServiceModel;
+import net.dpml.lang.NullArgumentException;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -26,20 +33,12 @@
import java.util.Hashtable;
import java.util.Map;

-import net.dpml.activation.ApplianceException;
-
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.model.ServiceModel;
-import net.dpml.composition.model.Reclaimer;
-
-import net.dpml.lang.NullArgumentException;
-
/**
* This makes a dynamic proxy for an object. The object can be represented
* by one, some or all of it's interfaces.
*/
-final class BlockInvocationHandler implements InvocationHandler
+final class BlockInvocationHandler
+ implements InvocationHandler
{
private final DefaultBlock m_block;
private final Map m_providers = new Hashtable();
@@ -111,7 +110,10 @@
catch( UndeclaredThrowableException e )
{
Throwable cause = e.getUndeclaredThrowable();
- if( cause != null ) throw cause;
+ if( cause != null )
+ {
+ throw cause;
+ }
final String error =
"Delegation error raised by: " + m_block;
throw new ApplianceException( error, e );
@@ -119,7 +121,10 @@
catch( InvocationTargetException e )
{
Throwable cause = e.getTargetException();
- if( cause != null ) throw cause;
+ if( cause != null )
+ {
+ throw cause;
+ }
final String error =
"Delegation error raised by: " + m_block;
throw new ApplianceException( error, e );
@@ -176,5 +181,6 @@
}
}
m_providers.clear();
+ super.finalize();
}
}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ContainerUtil.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ContainerUtil.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,260 @@
+/*
+ * Copyright 1997-2003 The Apache Software Foundation
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.dpml.activation.impl;
+
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Initializable;
+import net.dpml.activity.Startable;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.ConfigurationException;
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+import net.dpml.context.Contextualizable;
+import net.dpml.logging.LogEnabled;
+import net.dpml.logging.Logger;
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameterizable;
+import net.dpml.parameters.Parameters;
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.Serviceable;
+
+/**
+ * Utility class that makes it easier to transfer
+ * a component through its lifecycle.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: ContainerUtil.java 2893 2005-06-19 14:24:04Z
niclas AT hedhman.org $
+ */
+public final class ContainerUtil
+{
+ /**
+ * Private constructor to block instantiation.
+ */
+ private ContainerUtil()
+ {
+ }
+
+ /**
+ * Run specified object through shutdown lifecycle.
+ * (Stop and Dispose).
+ *
+ * @param object the object to shutdown
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void shutdown( final Object object )
+ throws Exception
+ {
+ stop( object );
+ dispose( object );
+ }
+
+ /**
+ * Supply specified object with Logger if it implements the
+ * {@link LogEnabled} interface.
+ *
+ * @param object the object to Start
+ * @param logger the logger to enable component with. May be null
+ * in which case the specified object must not implement
LogEnabled.
+ * @throws IllegalArgumentException if the object is LogEnabled but
Logger is null
+ */
+ public static void enableLogging( final Object object, final Logger
logger )
+ {
+ if( object instanceof LogEnabled )
+ {
+ if( null == logger )
+ {
+ final String message = "logger is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (LogEnabled)object ).enableLogging( logger );
+ }
+ }
+
+ /**
+ * Supply specified object with a Context object if it implements the
+ * {@link Contextualizable} interface.
+ *
+ * @param object the object to contextualize
+ * @param context the context object to use for object.
+ * May be null in which case the specified object must not
+ * implement Contextualizable.
+ * @throws ContextException if there is a problem contextualizing object
+ * @throws IllegalArgumentException if the object is Contextualizable but
+ * context is null
+ */
+ public static void contextualize( final Object object,
+ final Context context )
+ throws ContextException
+ {
+ if( object instanceof Contextualizable )
+ {
+ if( null == context )
+ {
+ final String message = "context is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Contextualizable)object ).contextualize( context );
+ }
+ }
+
+ /**
+ * Supply specified object with ServiceManager if it implements the
+ * {@link Serviceable} interface.
+ *
+ * @param object the object to service
+ * @param serviceManager the serviceManager object to use for object.
+ * May be null in which case the specified object must not
+ * implement Serviceable.
+ * @throws ServiceException if there is a problem servicing object
+ * @throws IllegalArgumentException if the object is Servicable but
+ * ServiceManager is null
+ */
+ public static void service( final Object object,
+ final ServiceManager serviceManager )
+ throws ServiceException
+ {
+ if( object instanceof Serviceable )
+ {
+ if( null == serviceManager )
+ {
+ final String message = "ServiceManager is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Serviceable)object ).service( serviceManager );
+ }
+ }
+
+ /**
+ * Configure specified object if it implements the
+ * {@link Configurable} interface.
+ *
+ * @param object the object to Start
+ * @param configuration the configuration object to use during
+ * configuration. May be null in which case the specified object
+ * must not implement Configurable
+ * @throws ConfigurationException if there is a problem Configuring
object,
+ * or the object is Configurable but Configuration is null
+ * @throws IllegalArgumentException if the object is Configurable but
+ * Configuration is null
+ */
+ public static void configure( final Object object,
+ final Configuration configuration )
+ throws ConfigurationException
+ {
+ if( object instanceof Configurable )
+ {
+ if( null == configuration )
+ {
+ final String message = "configuration is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Configurable)object ).configure( configuration );
+ }
+ }
+
+ /**
+ * Parameterize specified object if it implements the
+ * {@link Parameterizable} interface.
+ *
+ * @param object the object to Parameterize.
+ * @param parameters the parameters object to use during
Parameterization.
+ * May be null in which case the specified object must not
+ * implement Parameterizable.
+ * @throws ParameterException if there is a problem Parameterizing object
+ * @throws IllegalArgumentException if the object is Parameterizable but
+ * parameters is null
+ */
+ public static void parameterize( final Object object,
+ final Parameters parameters )
+ throws ParameterException
+ {
+ if( object instanceof Parameterizable )
+ {
+ if( null == parameters )
+ {
+ final String message = "parameters is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Parameterizable)object ).parameterize( parameters );
+ }
+ }
+
+ /**
+ * Initialize specified object if it implements the
+ * {@link Initializable} interface.
+ *
+ * @param object the object to Initialize
+ * @throws Exception if there is a problem Initializing object
+ */
+ public static void initialize( final Object object )
+ throws Exception
+ {
+ if( object instanceof Initializable )
+ {
+ ( (Initializable) object ).initialize();
+ }
+ }
+
+ /**
+ * Start specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to Start
+ * @throws Exception if there is a problem Starting object
+ */
+ public static void start( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).start();
+ }
+ }
+
+ /**
+ * Stop specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to stop
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void stop( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).stop();
+ }
+ }
+
+ /**
+ * Dispose specified object if it implements the
+ * {@link Disposable} interface.
+ *
+ * @param object the object to dispose
+ */
+ public static void dispose( final Object object )
+ {
+ if( object instanceof Disposable )
+ {
+ ( (Disposable)object ).dispose();
+ }
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultApplianceMetro.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultApplianceMetro.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ApplianceException;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.composition.util.DefaultState;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.logging.Logger;
+
+import java.lang.reflect.Proxy;
+
+/**
+ * Abstract appliance.
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: DefaultApplianceMetro.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+ */
+public class DefaultApplianceMetro extends AbstractAppliance
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultApplianceMetro.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final LifestyleManager m_lifestyle;
+
+ private final DefaultState m_commissioned = new DefaultState();
+
+ private long m_delay = 0;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultApplianceMetro( ComponentModel model, LifestyleManager
lifestyle )
+ {
+ super( model );
+ m_model = model;
+ m_lifestyle = lifestyle;
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ synchronized( m_commissioned )
+ {
+ if( m_commissioned.isEnabled() ) return;
+
+ try
+ {
+ m_delay = m_model.getDeploymentTimeout();
+ m_lifestyle.commission();
+ m_delay = 0;
+ m_commissioned.setEnabled( true );
+ }
+ finally
+ {
+ m_delay = 0;
+ }
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ synchronized( m_commissioned )
+ {
+ if( !m_commissioned.isEnabled() ) return;
+ m_lifestyle.decommission();
+ m_commissioned.setEnabled( false );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ return resolve( getComponentModel().getProxyPolicy() );
+ }
+
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ if( !proxy )
+ {
+ if( m_delay > 0 )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.transient",
+ this.toString(),
+ "" + m_delay );
+ throw new TransientRuntimeException( error, m_delay );
+ }
+ else if( !m_commissioned.isEnabled() )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.non-commission-state",
+ this.toString() );
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ return m_lifestyle.resolve();
+ }
+ }
+ else
+ {
+ ComponentModel model = getComponentModel();
+ Logger logger = model.getLogger().getChildLogger( "proxy" );
+ ApplianceInvocationHandler handler = new
ApplianceInvocationHandler( this, logger );
+
+ try
+ {
+ return Proxy.newProxyInstance(
+ model.getDeploymentClass().getClassLoader(),
+ model.getInterfaces(),
+ handler );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Proxy establishment failure in appliance: " + this;
+ throw new ApplianceException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ if( null == instance ) return;
+ if( !m_commissioned.isEnabled() ) return;
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ ApplianceInvocationHandler handler =
+ (ApplianceInvocationHandler) Proxy.getInvocationHandler(
instance );
+ handler.release();
+ }
+ else
+ {
+ m_lifestyle.release( instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Return the model backing the handler.
+ * @return the type that the appliance is managing
+ */
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "appliance:" + getComponentModel().getQualifiedName();
+ }
+}

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultBlock.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultBlock.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultBlock.java
Mon Jun 20 07:13:39 2005
@@ -18,17 +18,15 @@

package net.dpml.activation.impl;

-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-
import net.dpml.activation.ApplianceRuntimeException;
-
import net.dpml.composition.model.ContainmentModel;
import net.dpml.composition.model.ServiceModel;
-
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;

+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+
/**
* Composite appliance.
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,520 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.activation.LifecycleException;
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Initializable;
+import net.dpml.activity.Startable;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContextModel;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.Configuration;
+import net.dpml.context.Context;
+import net.dpml.context.Contextualizable;
+import net.dpml.context.impl.DefaultContext;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.lang.NullArgumentException;
+import net.dpml.logging.LogEnabled;
+import net.dpml.logging.Logger;
+import net.dpml.parameters.Parameterizable;
+import net.dpml.parameters.Parameters;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.Serviceable;
+import org.osgi.framework.BundleContext;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+
+
+/**
+ * A factory enabling the establishment of component instances.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: DefaultComponentFactory.java 2893 2005-06-19 14:24:04Z
niclas AT hedhman.org $
+ */
+public class DefaultComponentFactory
+ implements ComponentFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
ResourceManager.getPackageResources( DefaultComponentFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final Logger m_logger;
+
+ private final BundleContext m_OsgiContext;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new component factory.
+ * @param model the component model
+ */
+ public DefaultComponentFactory( ComponentModel model, BundleContext osgi
)
+ {
+ m_model = model;
+ m_OsgiContext = osgi;
+ m_logger = model.getLogger().getChildLogger( "lifecycle" );
+ }
+
+ //-------------------------------------------------------------------
+ // ComponentFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new incarnated instance
+ */
+ public Object incarnate() throws LifecycleException
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "incarnation";
+ getLogger().debug( message );
+ }
+
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ ClassLoader classloader =
m_model.getDeploymentClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader( classloader );
+
+ try
+ {
+ Object instance = incarnation();
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = "incarnation complete";
+ getLogger().debug( message );
+ }
+ return instance;
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( current );
+ }
+ }
+
+ /**
+ * Termination of the instance including all end-of-life processing.
+ * @param instance the component instance to etherialize
+ */
+ public void etherialize( final Object instance )
+ {
+ getLogger().debug( "etherialization" );
+
+ if( instance instanceof Startable )
+ {
+ getLogger().debug( "applying shutdown" );
+ try
+ {
+ ContainerUtil.stop( instance );
+ }
+ catch( Throwable e )
+ {
+ final String warning = "Ignoring component source shutdown
error.";
+ getLogger().warn( warning, e );
+ }
+ }
+
+ if( instance instanceof Disposable )
+ {
+ getLogger().debug( "applying disposal" );
+ try
+ {
+ ContainerUtil.dispose( instance );
+ }
+ catch( Throwable e )
+ {
+ final String warning = "Ignoring component source disposal
error.";
+ getLogger().warn( warning, e );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // protected implementation
+ //-------------------------------------------------------------------
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new instance
+ */
+ private Object incarnation() throws LifecycleException
+ {
+ Class clazz = m_model.getDeploymentClass();
+ final Logger logger = m_model.getLogger();
+ final Configuration config = m_model.getConfiguration();
+ final Parameters params = m_model.getParameters();
+ final ServiceManager manager = new DefaultServiceManager( m_model,
m_OsgiContext );
+ final Object context = getTargetContext();
+ final Class contextClass = getContextCastingClass();
+
+ final Object instance =
+ instantiate(
+ clazz, logger, config, params, context, contextClass, manager );
+
+ try
+ {
+ if( instance instanceof LogEnabled )
+ {
+ getLogger().debug( "applying logger" );
+ ContainerUtil.enableLogging( instance, logger );
+ }
+
+ if( instance instanceof Contextualizable )
+ {
+ getLogger().debug( "applying context" );
+ ContainerUtil.contextualize( instance, (Context) context );
+ }
+
+ if( instance instanceof Serviceable )
+ {
+ getLogger().debug( "applying service manager" );
+ ContainerUtil.service( instance, manager );
+ }
+
+ if( instance instanceof Configurable )
+ {
+ getLogger().debug( "applying configuration" );
+ ContainerUtil.configure( instance, config );
+ }
+
+ if( instance instanceof Parameterizable )
+ {
+ getLogger().debug( "applying parameters" );
+ ContainerUtil.parameterize( instance, params );
+ }
+
+ //
+ // complete intialization
+ //
+
+ if( instance instanceof Initializable )
+ {
+ getLogger().debug( "applying initialization" );
+ ContainerUtil.initialize( instance );
+ }
+
+ if( Startable.class.isAssignableFrom( clazz ) )
+ {
+ getLogger().debug( "applying startup" );
+ ContainerUtil.start( instance );
+ getLogger().debug( "component startup completed" );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifestyle.error.new",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+
+ return instance;
+ }
+
+ private Class getContextCastingClass()
+ throws LifecycleException
+ {
+ String casting = m_model.getContextModel().getCastingClassname();
+
+ if( null == casting )
+ {
+ return Context.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( casting );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context casting class ["
+ + casting
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+ }
+
+ private Object getTargetContext()
+ throws LifecycleException
+ {
+ ContextModel model = m_model.getContextModel();
+ Class impl = getContextImplementationClass( model );
+ return createComponentContext( impl, model.getContextMap() );
+ }
+
+ private Class getContextImplementationClass( ContextModel model ) throws
LifecycleException
+ {
+ String classname = model.getImplementationClassname();
+
+ if( null == classname )
+ {
+ return DefaultContext.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( classname );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context implementation class ["
+ + classname
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Creates a component context instance.
+ *
+ * @return the context object compliant with the context casting
+ * constraints declared by the component type
+ * @exception LifecycleException if an error occurs while attempting to
+ * construct the context instance
+ */
+ private Object createComponentContext( Class clazz, Map map )
+ throws LifecycleException
+ {
+ //
+ // its a custom context object so we need to create it
+ // using the classic context object as the constructor
+ // argument
+ //
+
+ try
+ {
+ Constructor constructor = clazz.getConstructor(
+ new Class[]{ Map.class } );
+ return constructor.newInstance( new Object[]{ map } );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+
+ private Object instantiate(
+ Class clazz, Logger logger, Configuration config, Parameters
params,
+ Object context, Class contextClass, ServiceManager manager )
+ throws LifecycleException, NullArgumentException
+ {
+ Constructor constructor = getConstructor( clazz );
+
+ Class[] classes = constructor.getParameterTypes();
+ Object[] args = new Object[ classes.length ];
+ for( int i=0; i<classes.length; i++ )
+ {
+ Class c = classes[i];
+ if( Logger.class.isAssignableFrom( c ) )
+ {
+ if( null == logger )
+ {
+ throw new NullArgumentException( "logger" );
+ }
+ args[i] = logger;
+ }
+ else if( ( null != contextClass ) &&
contextClass.isAssignableFrom( c ) )
+ {
+ if( null == context )
+ {
+ throw new NullArgumentException( "context" );
+ }
+ args[i] = context;
+ }
+ else if( Configuration.class.isAssignableFrom( c ) )
+ {
+ if( null == config )
+ {
+ throw new NullArgumentException( "config" );
+ }
+ args[i] = config;
+ }
+ else if( Parameters.class.isAssignableFrom( c ) )
+ {
+ if( null == params )
+ {
+ throw new NullArgumentException( "params" );
+ }
+ args[i] = params;
+ }
+ else if( ServiceManager.class.isAssignableFrom( c ) )
+ {
+ if( null == manager )
+ {
+ throw new NullArgumentException( "manager" );
+ }
+ args[i] = manager;
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.unrecognized-parameter",
+ c.getName(),
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+ }
+
+ //
+ // instantiate the factory
+ //
+
+ return instantiateComponent( constructor, args );
+ }
+
+ private Constructor getConstructor( Class clazz ) throws
LifecycleException
+ {
+ Constructor[] constructors = clazz.getConstructors();
+ if( constructors.length < 1 )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.no-constructor",
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+
+ if( constructors.length > 1 )
+ {
+ final String error =
+ "Multiple constructor ambiguity in the component model "
+ + m_model
+ + ". The component class [" + clazz.getName()
+ + "] declares "
+ + constructors.length
+ + " public constructors.";
+ throw new LifecycleException( error );
+ }
+ else
+ {
+ return constructors[0];
+ }
+ }
+
+ /**
+ * Instantiation of a component instance using a supplied constructor
+ * and arguments.
+ *
+ * @param constructor the component constructor
+ * @param args the constructor arguments
+ * @return the component instance
+ * @exception LifecycleException if an instantiation error occurs
+ */
+ private Object instantiateComponent(
+ final Constructor constructor, final Object[] args )
+ throws LifecycleException
+ {
+ try
+ {
+ if( args.length == 0 )
+ {
+ getLogger().debug(
+ "instantiating component with a null constructor" );
+ }
+ else
+ {
+ int n = args.length;
+ getLogger().debug(
+ "instantiating component with "
+ + n + " arguments." );
+ }
+
+ return constructor.newInstance( args );
+ }
+ catch( Throwable e )
+ {
+ Class clazz = constructor.getDeclaringClass();
+ final String error =
+ REZ.getString(
+ "lifecycle.error.instantiation",
+ clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private void applyContext( final Object instance, final Object context )
+ throws LifecycleException
+ {
+ if( null == context ) return;
+
+ final ContextModel model = m_model.getContextModel();
+ getLogger().debug( "applying context" );
+ if( context instanceof Context )
+ {
+ try
+ {
+ ContainerUtil.contextualize( instance, (Context) context );
+ }
+ catch( Throwable e )
+ {
+ final String error = REZ.getString(
"lifecycle.error.metro-contextualization", m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Supplied context class ["
+ + context.getClass().getName()
+ + "] does not implement the Context interface.";
+ throw new LifecycleException( error );
+ }
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+
+import net.dpml.meta.info.InfoDescriptor;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * A factory enabling the establishment of runtime handlers.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: DefaultLifestyleFactory.java 2893 2005-06-19 14:24:04Z
niclas AT hedhman.org $
+ */
+public class DefaultLifestyleFactory implements LifestyleFactory
+{
+
+ private BundleContext m_OsgiContext;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new default lifestyle factory.
+ */
+ public DefaultLifestyleFactory( BundleContext osgi )
+ {
+ m_OsgiContext = osgi;
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleFactory
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Create a new lifestyle manager.
+ * @param model the component model
+ * @return the lifestyle manager
+ */
+ public LifestyleManager createLifestyleManager( ComponentModel model )
+ {
+ ComponentFactory factory = createComponentFactory( model,
m_OsgiContext );
+
+ final String lifestyle =
+ model.getType().getInfo().getLifestyle();
+
+ if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
+ {
+ return new SingletonLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.THREAD ) )
+ {
+ return new ThreadLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.TRANSIENT ) )
+ {
+ return new TransientLifestyleManager( model, factory );
+ }
+ else
+ {
+ final String error =
+ "Unsupported lifestyle [" + lifestyle + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ private ComponentFactory createComponentFactory( ComponentModel model,
BundleContext osgi )
+ {
+ return new DefaultComponentFactory( model, osgi );
+ }
+}

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
Mon Jun 20 07:13:39 2005
@@ -21,13 +21,13 @@
import net.dpml.activation.Appliance;
import net.dpml.activation.LifestyleRuntimeException;
import net.dpml.activation.RuntimeFactory;
-import net.dpml.composition.model.ComponentModel;
import net.dpml.composition.model.ContainmentModel;
import net.dpml.composition.model.DeploymentModel;
import net.dpml.composition.provider.Runtime;
import net.dpml.lang.NullArgumentException;
-import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
import org.osgi.framework.BundleContext;

import java.net.URI;
@@ -53,7 +53,6 @@
// immutable state
//--------------------------------------------------------------

- private final SystemContext m_system;
private final BlockFactory m_factory;
private final BundleContext m_OsgiContext;

@@ -70,22 +69,16 @@
/**
* Creation of a new system context.
*
- * @param system the system context
* @exception NullArgumentException if the system argument is null.
*/
- public DefaultRuntime( SystemContext system, BundleContext osgi )
+ public DefaultRuntime( BundleContext osgi )
throws NullArgumentException
{
- if( system == null )
- {
- throw new NullArgumentException( "system" );
- }
if( osgi == null )
{
throw new NullArgumentException( "osgi" );
}
m_OsgiContext = osgi;
- m_system = system;
m_factory = new BlockFactory();
}

@@ -166,7 +159,6 @@
}
else
{
- ComponentModel component = (ComponentModel) model;
return getMetroRuntimeFactory();
}
}
@@ -183,14 +175,15 @@
{
ClassLoader classloader = Appliance.class.getClassLoader();
URI uri = getMetroRuntimeArtifact();
- Object[] params = new Object[]{ m_system, m_OsgiContext };
- m_metro = (RuntimeFactory)
m_system.getRepository().getPlugin( classloader, uri, params );
+ Object[] params = new Object[]{ m_OsgiContext };
+
+ Repository repository = new StandardLoader();
+ m_metro = (RuntimeFactory) repository.getPlugin(
classloader, uri, params );
return m_metro;
}
catch( Throwable e )
{
- final String error =
- "Bugger, bugger, bugger";
+ final String error = "Bugger, bugger, bugger";
throw new LifestyleRuntimeException( error, e );
}
}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.Appliance;
+import net.dpml.activation.RuntimeFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ModelRuntimeException;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import org.osgi.framework.BundleContext;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+* A factory enabling the establishment of runtime handlers.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id: DefaultRuntimeFactory.java 2894 2005-06-20 07:59:00Z
niclas AT hedhman.org $
+*/
+public class DefaultRuntimeFactory
+ implements RuntimeFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
ResourceManager.getPackageResources( DefaultRuntimeFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final Map m_map = new Hashtable();
+
+ //-------------------------------------------------------------------
+ // mutable state
+ //-------------------------------------------------------------------
+
+ private LifestyleFactory m_factory;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultRuntimeFactory( BundleContext osgi )
+ {
+ m_factory = new DefaultLifestyleFactory( osgi );
+ }
+
+ //-------------------------------------------------------------------
+ // RuntimeFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a model.
+ * @param model the deployment model
+ * @return the runtime appliance
+ */
+ public Appliance getRuntime( DeploymentModel model )
+ {
+ synchronized( m_map )
+ {
+ Appliance runtime = getRegisteredRuntime( model );
+ if( null != runtime )
+ {
+ return runtime;
+ }
+
+ //
+ // create the runtime
+ //
+
+ if( model instanceof ComponentModel )
+ {
+ ComponentModel component = (ComponentModel) model;
+ LifestyleManager manager = m_factory.createLifestyleManager(
component );
+ runtime = newComponentRuntime( component, manager );
+ }
+ else
+ {
+ String classname = model.getClass().getName();
+ final String error = REZ.getString(
"runtime.error.unknown-model", model.toString(), classname );
+ throw new ModelRuntimeException( error );
+ }
+ registerRuntime( model, runtime );
+ return runtime;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a component model.
+ * @param model the containment model
+ * @return the runtime handler
+ */
+ protected Appliance newComponentRuntime( ComponentModel model,
LifestyleManager manager )
+ {
+ return new DefaultApplianceMetro( model, manager );
+ }
+
+ /**
+ * Lookup a runtime relative to the model name.
+ * @param model the deployment model
+ * @return the matching runtime (possibly null)
+ */
+ private Appliance getRegisteredRuntime( DeploymentModel model )
+ {
+ String name = model.getQualifiedName();
+ return (Appliance) m_map.get( name );
+ }
+
+ private void registerRuntime( DeploymentModel model, Appliance runtime )
+ {
+ String name = model.getQualifiedName();
+ m_map.put( name, runtime );
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,305 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DependencyModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.lang.NullArgumentException;
+import net.dpml.logging.Logger;
+import net.dpml.service.FatalServiceException;
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+import net.dpml.meta.info.DependencyDescriptor;
+import net.dpml.meta.info.ReferenceDescriptor;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * Default implementation of the framework {@link ServiceManager} interface.
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+class DefaultServiceManager
+ implements ServiceManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
ResourceManager.getPackageResources( DefaultServiceManager.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final BundleContext m_OsgiContext;
+
+ private final Logger m_logger;
+
+ /**
+ * A table of identity hashcode integers of established objects
+ * that map to the lookup key that was uased to establish the object.
+ * Used to track which model is providing an object when we
+ * handle release of objects.
+ */
+ private final Hashtable m_table = new Hashtable();
+
+ /**
+ * A table of dependency models keyed by lookup key.
+ */
+ private final Map m_map;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Construct a new ServiceManager.
+ * @param model component model of the component that is
+ * to be serviced.
+ */
+ public DefaultServiceManager( ComponentModel model, BundleContext osgi )
+ throws NullArgumentException
+ {
+ if( model == null )
+ {
+ throw new NullArgumentException( "model" );
+ }
+ if( osgi == null )
+ {
+ throw new NullArgumentException( "osgi" );
+ }
+
+ m_OsgiContext = osgi;
+
+ m_logger = model.getLogger();
+
+ m_map = new Hashtable();
+ DependencyModel[] dependencies = model.getDependencyModels();
+ for( int i=0; i < dependencies.length; i++ )
+ {
+ final DependencyModel dependency = dependencies[i];
+
+ DeploymentModel provider = dependency.getProvider();
+ if( provider != null )
+ {
+ final String key = dependency.getDependency().getKey();
+ m_map.put( key, dependency );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // ServiceManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Returns true if a provider exists for the supplied role.
+ * @param key the service identifier key
+ * @return boolean TRUE if the service is available else FALSE
+ */
+ public boolean hasService( String key )
+ {
+ if( key == null )
+ {
+ return false;
+ }
+ Object provider = m_map.get( key );
+ boolean exists = provider != null;
+ return exists;
+ }
+
+ /**
+ * Retrieve Object by key.
+ * @param key the role
+ * @return the Object or null if the Object doesn't exist
+ * @throws ServiceException if an error occurs
+ * @throws NullPointerException if the supplied key is null
+ */
+ public Object lookup( String key )
+ throws ServiceException, NullArgumentException
+ {
+ if( key == null )
+ {
+ throw new NullArgumentException( "key" );
+ }
+
+ if( hasService( key ) == false )
+ {
+ final String error = "Unknown key: " + key;
+ throw new ServiceException( key, error );
+ }
+
+ //
+ // locate the provider model that is prividing components
+ // for this dependency
+ //
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ Object instance = establishMetroProvider( key, dependency );
+ if( instance != null )
+ {
+ return instance;
+ }
+
+ Object service = establishOsgiProvider( dependency );
+ if( service != null )
+ {
+ return service;
+ }
+
+ final String error = REZ.getString( "service.error.null-provider",
key );
+ throw new IllegalStateException( error );
+ }
+
+ private Object establishOsgiProvider( DependencyModel dependency )
+ {
+ DependencyDescriptor dep = dependency.getDependency();
+ ReferenceDescriptor ref = dep.getReference();
+ String classname = ref.getClassname();
+ ServiceReference reference = m_OsgiContext.getServiceReference(
classname );
+ Object service = m_OsgiContext.getService( reference );
+ return service;
+ }
+
+ private Object establishMetroProvider( String key, DependencyModel
dependency )
+ throws FatalServiceException
+ {
+ final DeploymentModel provider = dependency.getProvider();
+ if( provider == null )
+ {
+ return null;
+ }
+
+ //
+ // get a proxy to the service from the provider
+ // (note that it is up to a provider to determine if
+ // a proxy if generated based on its service export
+ // parameters)
+ //
+
+ try
+ {
+ Object instance = provider.resolve();
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ return instance;
+ }
+
+ //
+ // otherwise we need to hold a reference linking the
+ // object with the source provider
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ m_table.put( id, key );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = "resolved service [" + id + "] for
the key [" + key + "].";
+ getLogger().debug( message );
+ }
+ return instance;
+ }
+ catch( Throwable e )
+ {
+ //
+ // TODO: framework states that ServiceException is thrown
+ // if the service is not found - and in this case that isn't
+ // the issue - in effect we have a good key, but we simply
+ // have not been able to go from key to instance -
+ // should look into some more concrete subtypes of
+ // ServiceException
+
+ final String error = "Unexpected runtime error while attempting
to resolve service for key: " + key;
+ throw new FatalServiceException( key, error, e );
+ }
+ }
+
+ /**
+ * Release a service back to the manager.
+ * @param instance the object to release
+ */
+ public void release( Object instance )
+ {
+ if( instance == null )
+ return;
+
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ InvocationHandler handler = Proxy.getInvocationHandler( instance
);
+ if( handler instanceof ApplianceInvocationHandler )
+ {
+ ApplianceInvocationHandler aic =
(ApplianceInvocationHandler) handler;
+ aic.release();
+ return;
+ }
+ return;
+ }
+
+ //
+ // otherwise we need to locate the source ourselves
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ final String key = (String) m_table.get( id );
+ if( key == null )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning = "Unrecognized object identity [" + id
+ "]. " + "Either this object was not provided by this service manager or it
has already been released.";
+ getLogger().warn( warning );
+ }
+ return;
+ }
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ final DeploymentModel provider = dependency.getProvider();
+ if( provider == null )
+ {
+ if( getLogger().isErrorEnabled() )
+ {
+ final String error = "Unable to release component as no
provider could be found for the key [" + key + "].";
+ getLogger().warn( error );
+ }
+ return;
+ }
+
+ provider.release( instance );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message = "released service [" + id + "] from the
key [" + key + "].";
+ getLogger().debug( message );
+ }
+
+ m_table.remove( id );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}
+

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/SingletonLifestyleManager.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/SingletonLifestyleManager.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.composition.model.ComponentModel;
+
+import java.lang.ref.Reference;
+
+/**
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: SingletonLifestyleManager.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+ */
+public class SingletonLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Reference m_reference;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public SingletonLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a handler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ handleResolve();
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ if( m_reference != null )
+ {
+ finalize( m_reference.get() );
+ m_reference = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected synchronized Object handleResolve() throws Exception
+ {
+ Object instance = null;
+
+ if( m_reference == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ instance = m_reference.get();
+ if( instance == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ return instance;
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected synchronized void handleRelease( Object instance )
+ {
+ // continue with the current singleton reference
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public synchronized void finalize( Object instance )
+ {
+ getComponentFactory().etherialize( instance );
+ m_reference = null;
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ private Object refreshReference() throws Exception
+ {
+ ComponentFactory factory = getComponentFactory();
+ synchronized( factory )
+ {
+ Object instance = factory.incarnate();
+ m_reference = getReference( instance );
+ return instance;
+ }
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ThreadLifestyleManager.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/ThreadLifestyleManager.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.activation.LifestyleRuntimeException;
+import net.dpml.composition.model.ComponentModel;
+
+/**
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: ThreadLifestyleManager.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+ */
+public class ThreadLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ /**
+ * Internal utility class to hold the thread local instance.
+ */
+ private static final class ThreadLocalHolder extends ThreadLocal
+ {
+ private final ComponentFactory m_factory;
+
+ protected ThreadLocalHolder( ComponentFactory factory )
+ {
+ m_factory = factory;
+ }
+
+ //
+ // TODO: the current implementation is hard coded to HARD
+ // collection policy - we need to update the ThreadLocalHolder so
+ // it regenerates the value relative to SOFT or WEAK policies
+ // (but I just need to check docs on thread local state access
+ // semantics)
+ //
+
+ protected Object initialValue()
+ {
+ try
+ {
+ return m_factory.incarnate();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to establish thread local variable.";
+ throw new LifestyleRuntimeException( error, e );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ThreadLocalHolder m_local;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public ThreadLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ if( getComponentModel().getActivationPolicy() )
+ {
+ resolve();
+ }
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public synchronized void decommission()
+ {
+ if( m_local != null )
+ {
+ finalize( m_local.get() );
+ m_local = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ if( m_local == null )
+ {
+ ComponentFactory factory = getComponentFactory();
+ m_local = new ThreadLocalHolder( factory );
+ }
+ return m_local.get();
+ }
+
+ /**
+ * Release an object.
+ *
+ * @param instance the object to be reclaimed
+ */
+ protected void handleRelease( Object instance )
+ {
+ // don't release because this is a shared reference
+ }
+
+}

Added:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/TransientLifestyleManager.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/TransientLifestyleManager.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.activation.impl;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.meta.info.InfoDescriptor;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+
+/**
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id: TransientLifestyleManager.java 2853 2005-06-14 05:43:13Z
niclas AT hedhman.org $
+*/
+public class TransientLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ArrayList m_list = new ArrayList();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public TransientLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ // TODO: setup a background thread to check queues for
+ // released references and remove them from our list, otherwise we
+ // have a memory leak due to accumulation of weak references
+
+ if( getComponentModel().getActivationPolicy() )
+ {
+ handleResolve();
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ Reference[] refs = (Reference[]) m_list.toArray( new Reference[0] );
+ for( int i=0; i<refs.length; i++ )
+ {
+ Reference ref = refs[i];
+ finalize( ref.get() );
+ }
+ m_list.clear();
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ Object instance = getComponentFactory().incarnate();
+ Reference reference = getReference( instance );
+ m_list.add( reference );
+ return instance;
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected void handleRelease( Object instance )
+ {
+ finalize( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Overriding getReference to ensure that we never return a hard
+ * reference for a transient.
+ */
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new WeakReference(
+ instance,
+ getLiberalQueue() );
+ }
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
Mon Jun 20 07:13:39 2005
@@ -0,0 +1,72 @@
+package net.dpml.composition;
+
+import java.io.File;
+
+// This class will soon disappear. Just holding ground while refactoring
away the SystemContext.
+
+public class StuffNeeded
+{
+ static private File m_work;
+ static private File m_lib;
+ static private File m_temp;
+ private static boolean m_infoMode;
+ private static boolean m_debugMode;
+
+ static
+ {
+ m_work = new File( System.getProperty( "dpml.metro.dir" ) );
+ m_work.mkdirs();
+ m_temp = new File( m_work, "temp" );
+ m_temp.mkdirs();
+ }
+
+ public static File getWorkingDirectory()
+ {
+ return m_work;
+ }
+
+ public static void setWorkingDirectory( File work )
+ {
+ m_work = work;
+ }
+
+ public static File getTempDirectory()
+ {
+ return m_temp;
+ }
+
+ public static void setTempDirectory( File temp )
+ {
+ m_temp = temp;
+ }
+
+ public static File getLibDirectory()
+ {
+ return m_lib;
+ }
+
+ public static void setLibDirectory( File lib )
+ {
+ m_lib = lib;
+ }
+
+ public static boolean getInfoMode()
+ {
+ return m_infoMode;
+ }
+
+ public static void setInfoMode( boolean on )
+ {
+ m_infoMode = on;
+ }
+
+ public static boolean getDebugMode()
+ {
+ return m_debugMode;
+ }
+
+ public static void setDebugMode( boolean on )
+ {
+ m_debugMode = on;
+ }
+}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
Mon Jun 20 07:13:39 2005
@@ -33,22 +33,21 @@
*/
public interface ClassLoaderModel
{
-
- /**
+ /**
* Return the classloader model type repository.
*
* @return the repository
*/
TypeRepository getTypeRepository();

- /**
+ /**
* Return the classloader model service repository.
*
* @return the repository
*/
ServiceRepository getServiceRepository();

- /**
+ /**
* Return the fully qualified classpath
* resolved relative to a classpath directives.
*
@@ -57,7 +56,7 @@
*/
CodeSource[] getQualifiedClassPath();

- /**
+ /**
* Return the classloader for a containment context.
* An implementation is required to fulfill the the
* criteria expressed by the associated classloader
@@ -67,7 +66,7 @@
*/
ClassLoader getClassLoader();

- /**
+ /**
* Creation of a classloader model using this model as the
* relative parent.
*
@@ -76,6 +75,6 @@
* @param implied any implied urls
* @return a new classloader context
*/
- ClassLoaderModel createClassLoaderModel(
- Logger logger, ContainmentProfile profile, URL[] implied ) throws
ModelException;
+ ClassLoaderModel createClassLoaderModel( Logger logger,
ContainmentProfile profile, URL[] implied )
+ throws ModelException;
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ContainmentModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ContainmentModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ContainmentModel.java
Mon Jun 20 07:13:39 2005
@@ -28,42 +28,42 @@
import java.util.List;

/**
- * Containment model is an extended deployment model that aggregates
- * a set of models. A containment model describes a logical containment
- * context.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
+* Containment model is an extended deployment model that aggregates
+* a set of models. A containment model describes a logical containment
+* context.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
public interface ContainmentModel extends DeploymentModel
{
String KEY = "urn:composition:containment.model";

/**
- * Get the startup sequence for the model.
- */
+ * Get the startup sequence for the model.
+ */
DeploymentModel[] getStartupGraph();

/**
- * Get the shutdown sequence for the model.
- */
+ * Get the shutdown sequence for the model.
+ */
DeploymentModel[] getShutdownGraph();

- /**
+ /**
* Return the partition established by the containment model.
*
* @return the partition name
*/
String getPartition();

- /**
+ /**
* Return the classloader model.
*
* @return the classloader model
*/
ClassLoaderModel getClassLoaderModel();

- /**
+ /**
* Return the default deployment timeout value declared in the
* kernel configuration. The implementation looks for a value
* assigned under the property key "urn:composition:deployment.timeout"
@@ -71,33 +71,35 @@
*
* @return the default deployment timeout value
*/
- long getDeploymentTimeout();
+ long getDeploymentTimeout();

/**
- * Assemble the containment model.
- * @exception AssemblyException if an error occurs during model assembly
- */
- void assemble() throws AssemblyException;
+ * Assemble the containment model.
+ * @exception AssemblyException if an error occurs during model assembly
+ */
+ void assemble()
+ throws AssemblyException;

/**
- * Assemble the model.
- * @param subjects a list of deployment models that make up the assembly
chain
- * @exception AssemblyException if an error occurs during model assembly
- */
- void assemble( List subjects ) throws AssemblyException;
+ * Assemble the model.
+ * @param subjects a list of deployment models that make up the assembly
chain
+ * @exception AssemblyException if an error occurs during model assembly
+ */
+ void assemble( List subjects )
+ throws AssemblyException;

/**
- * Disassemble the model.
- */
+ * Disassemble the model.
+ */
void disassemble();

- /**
+ /**
* Return the set of models nested within this model.
* @return the classloader model
*/
DeploymentModel[] getModels();

- /**
+ /**
* Return a model relative to a supplied path.
*
* @param path a relative or absolute path
@@ -106,7 +108,7 @@
*/
DeploymentModel getModel( String path );

- /**
+ /**
* Resolve a model capable of supporting the supplied service reference.
*
* @param descriptor a service reference descriptor
@@ -114,9 +116,9 @@
* @exception AssemblyException if an assembly error occurs
*/
DeploymentModel getModel( ReferenceDescriptor descriptor )
- throws AssemblyException;
+ throws AssemblyException;

- /**
+ /**
* Resolve a model capable of supporting the supplied service reference.
*
* @param dependency a service dependency descriptor
@@ -124,9 +126,9 @@
* @exception AssemblyException if an assembly error occurs
*/
DeploymentModel getModel( DependencyDescriptor dependency )
- throws AssemblyException;
+ throws AssemblyException;

- /**
+ /**
* Addition of a new subsidiary containment model
* using a supplied profile url.
*
@@ -134,9 +136,10 @@
* @return the model based on the derived profile
* @exception ModelException if an error occurs during model establishment
*/
- ContainmentModel addContainmentModel( URL url ) throws ModelException;
+ ContainmentModel addContainmentModel( URL url )
+ throws ModelException;

- /**
+ /**
* Addition of a new subsidiary containment model within
* the containment context using a supplied url.
*
@@ -146,9 +149,9 @@
* @exception ModelException if an error occurs during model establishment
*/
ContainmentModel addContainmentModel( URL block, URL config )
- throws ModelException;
+ throws ModelException;

- /**
+ /**
* Addition of a new subsidiary model within
* the containment context using a supplied profile.
*
@@ -156,57 +159,60 @@
* @return the model based on the supplied profile
* @exception ModelException if an error occurs during model establishment
*/
- DeploymentModel addModel( DeploymentProfile profile ) throws
ModelException;
+ DeploymentModel addModel( DeploymentProfile profile )
+ throws ModelException;

- /**
+ /**
* Addition of a new subsidiary model within
* the containment context.
*
* @param model the model to add
* @return the model
*/
- DeploymentModel addModel( DeploymentModel model ) throws ModelException;
+ DeploymentModel addModel( DeploymentModel model )
+ throws ModelException;

- /**
+ /**
* Remove a named model from this model.
* @param name the name of an immediate child model
*/
void removeModel( String name );

- /**
+ /**
* Return the set of service export models.
* @return t he export directives
*/
ServiceModel[] getServiceModels();

- /**
+ /**
* Return a service exoport model matching a supplied class.
* @return the service model
*/
ServiceModel getServiceModel( Class clazz );

- /**
+ /**
* Apply a set of override targets resolvable from a supplied url.
* @param url a url resolvable to a TargetDirective[]
* @exception ModelException if an error occurs
*/
void applyTargets( URL url )
- throws ModelException;
+ throws ModelException;

- /**
+ /**
* Apply a set of override targets.
* @param targets a set of target directives
* @throws ModelException if an error occures
*/
- void applyTargets( TargetDirective[]targets ) throws ModelException;
+ void applyTargets( TargetDirective[]targets )
+ throws ModelException;

- /**
+ /**
* Add a composition listener to the model.
* @param listener the composition listener
*/
void addCompositionListener( CompositionListener listener );

- /**
+ /**
* Remove a composition listener from the model.
* @param listener the composition listener
*/

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/ContainmentProfileBuilder.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/ContainmentProfileBuilder.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/ContainmentProfileBuilder.java
Mon Jun 20 07:13:39 2005
@@ -20,7 +20,6 @@
import net.dpml.composition.data.ContainmentProfile;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.impl.DefaultConfigurationBuilder;
-import net.dpml.system.CascadingIOException;
import org.xml.sax.InputSource;

import java.io.ByteArrayInputStream;
@@ -38,13 +37,12 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id$
*/
-public final class ContainmentProfileBuilder extends ContentHandler
implements ContainmentProfileCreator
+public final class ContainmentProfileBuilder extends ContentHandler
+ implements ContainmentProfileCreator
{
- private XMLContainmentProfileCreator m_xml =
- new XMLContainmentProfileCreator( );
+ private XMLContainmentProfileCreator m_xml = new
XMLContainmentProfileCreator( );

- private final SerializedContainmentProfileCreator m_serial =
- new SerializedContainmentProfileCreator();
+ private final SerializedContainmentProfileCreator m_serial = new
SerializedContainmentProfileCreator();


//------------------------------------------------------------------------
// ContentHandler
@@ -59,14 +57,16 @@
}
catch( Throwable e )
{
- final String error =
- "Error occured while attempting to build a containment
profile.";
- throw new CascadingIOException( error, e );
+ String error = "Error occured while attempting to build a
containment profile.";
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
}

}

- public Object getContent( URLConnection connection, Class[] classes )
throws IOException
+ public Object getContent( URLConnection connection, Class[] classes )
+ throws IOException
{
for( int i=0; i<classes.length; i++ )
{
@@ -82,7 +82,9 @@
{
final String error =
"Error occured while attempting to build a containment
profile.";
- throw new CascadingIOException( error, e );
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
}
}
}
@@ -94,12 +96,12 @@

//------------------------------------------------------------------------

/**
- * Create a {@link ContainmentProfile} from a stream.
- *
- * @param inputStream the stream that the resource is loaded from
- * @return the containment profile
- * @exception Exception if a error occurs during profile creation
- */
+ * Create a {@link ContainmentProfile} from a stream.
+ *
+ * @param inputStream the stream that the resource is loaded from
+ * @return the containment profile
+ * @exception Exception if a error occurs during profile creation
+ */
public ContainmentProfile createContainmentProfile( InputStream
inputStream )
throws Exception
{
@@ -140,10 +142,10 @@
}

/**
- * Build ContainmentProfile from the serialized format.
- *
- * @throws Exception if an error occurs
- */
+ * Build ContainmentProfile from the serialized format.
+ *
+ * @throws Exception if an error occurs
+ */
private ContainmentProfile buildFromSerDescriptor( InputStream
inputStream )
throws Exception
{
@@ -151,10 +153,10 @@
}

/**
- * Build ContainmentProfile from an XML descriptor.
- * @param stream the input stream
- * @throws Exception if an error occurs
- */
+ * Build ContainmentProfile from an XML descriptor.
+ * @param stream the input stream
+ * @throws Exception if an error occurs
+ */
private ContainmentProfile buildFromXMLDescriptor( InputStream stream )
throws Exception
{

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
Mon Jun 20 07:13:39 2005
@@ -22,11 +22,10 @@
import net.dpml.composition.model.ServiceRepository;
import net.dpml.composition.model.TypeRepository;
import net.dpml.composition.provider.ClassLoaderContext;
+import net.dpml.composition.StuffNeeded;
import net.dpml.context.impl.DefaultContext;
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
-import net.dpml.system.SystemContext;
-import net.dpml.transit.repository.Repository;

import java.io.File;
import java.net.URL;
@@ -62,11 +61,6 @@
private final File m_base;

/**
- * The local jar repository.
- */
- private final Repository m_repository;
-
- /**
* The parent type manager.
*/
private final TypeRepository m_types;
@@ -86,11 +80,6 @@
*/
private final URL[] m_implied;

- /**
- * The system context.
- */
- private final SystemContext m_system;
-
//==============================================================
// constructor
//==============================================================
@@ -99,22 +88,18 @@
* Creation of a root classloader context.
*
* @param logger the logging channel to assign to the classloader model
- * @param system the system context
* @param parent the parent classloader
* @param directive the classloader directive
*/
- public DefaultClassLoaderContext(
- Logger logger, SystemContext system,
- ClassLoader parent, ClassLoaderDirective directive )
+ public DefaultClassLoaderContext( Logger logger, ClassLoader parent,
ClassLoaderDirective directive )
{
- this( logger, system, parent, null, null, directive, null );
+ this( logger, parent, null, null, directive, null );
}

/**
* Creation of a new classloader context.
*
* @param logger the logging channel to assign to the classloader model
- * @param system the system context
* @param parent the parent classloader
* @param types the parent type manager
* @param services the parent service manager
@@ -123,13 +108,8 @@
* @exception NullArgumentException if any one of the logger, parent,
packages,
* directive or system arguments is null.
*/
- public DefaultClassLoaderContext(
- Logger logger, SystemContext system,
- ClassLoader parent,
- TypeRepository types,
- ServiceRepository services,
- ClassLoaderDirective directive,
- URL[] implied )
+ public DefaultClassLoaderContext( Logger logger, ClassLoader parent,
TypeRepository types, ServiceRepository services,
+ ClassLoaderDirective directive, URL[]
implied )
throws NullArgumentException
{
super();
@@ -145,19 +125,13 @@
{
throw new NullArgumentException( "directive" );
}
- if( system == null )
- {
- throw new NullArgumentException( "system" );
- }

m_logger = logger;
- m_repository = system.getRepository();
- m_base = system.getAnchorDirectory();
+ m_base = StuffNeeded.getLibDirectory();
m_parent = parent;
m_types = types;
m_services = services;
m_directive = directive;
- m_system = system;

if( implied == null )
{
@@ -189,16 +163,6 @@
}

/**
- * Return the system context.
- *
- * @return the system context
- */
- public Repository getRepository()
- {
- return m_repository;
- }
-
- /**
* Return the base directory from which relative library directives
* and fileset directory paths may be resolved.
*
@@ -251,16 +215,6 @@
}

/**
- * Return the system context.
- *
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_system;
- }
-
- /**
* Return any implied urls to include in the classloader.
*
* @return the implied urls

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
Mon Jun 20 07:13:39 2005
@@ -31,7 +31,6 @@
import net.dpml.composition.provider.ClassLoaderContext;
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
-import net.dpml.system.SystemContext;
import net.dpml.transit.TransitException;
import net.dpml.transit.artifact.Artifact;
import net.dpml.transit.artifact.Handler;
@@ -111,17 +110,13 @@
m_context = context;
m_logger = context.getLogger();
m_local = getLogger().getChildLogger( "classloader" );
+
+ File base = context.getBaseDirectory();
if( getLogger().isDebugEnabled() )
{
- SystemContext systemContext = context.getSystemContext();
- File baseDirectory = context.getBaseDirectory();
- String contextBase = systemContext.toString( baseDirectory );
- getLocalLogger().debug( "base: " + contextBase );
+ getLocalLogger().debug( "base: " + base );
}

- File base =
- context.getBaseDirectory();
-
ClassLoaderDirective directive = context.getClassLoaderDirective();

URL[] implicit = context.getImplicitURLs();
@@ -132,7 +127,7 @@

if( getLocalLogger().isDebugEnabled() )
{
- String str = "classpath: " +
context.getSystemContext().toString( m_classpath );
+ String str = "classpath: " + m_classpath;
getLocalLogger().debug( str );
}

@@ -149,8 +144,7 @@
ArrayList types = new ArrayList();
ArrayList services = new ArrayList();
Logger scannerLogger = getLocalLogger().getChildLogger(
"scanner" );
- SystemContext system = context.getSystemContext();
- Scanner scanner = new Scanner( scannerLogger, system,
m_classLoader );
+ Scanner scanner = new Scanner( scannerLogger, m_classLoader );
scanner.scan( m_urls, types, services );

//
@@ -179,6 +173,10 @@
{
final String error = "Could not create classloader.";
throw new ModelException( error, e );
+ } catch( IOException e )
+ {
+ final String error = "Could not create classloader.";
+ throw new ModelException( error, e );
}
}

@@ -198,8 +196,7 @@
public ClassLoaderModel createClassLoaderModel( Logger logger,
ContainmentProfile profile, URL[] implied )
throws ModelException
{
- ClassLoaderContext context =
- createChildContext( logger, profile, implied );
+ ClassLoaderContext context = createChildContext( logger, profile,
implied );
logger.debug( "creating child classloader for: " + profile );
return new DefaultClassLoaderModel( context );
}
@@ -273,10 +270,9 @@
*/
private ClassLoaderContext createChildContext( Logger logger,
ContainmentProfile profile, URL[] implied )
{
- SystemContext system = m_context.getSystemContext();
ClassLoaderDirective directive = profile.getClassLoaderDirective();

- return new DefaultClassLoaderContext( logger, system, m_classLoader,
m_types, m_services, directive, implied );
+ return new DefaultClassLoaderContext( logger, m_classLoader,
m_types, m_services, directive, implied );
}

private String[] getClassPath()

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentContext.java
Mon Jun 20 07:13:39 2005
@@ -28,7 +28,6 @@
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
import net.dpml.meta.info.Type;
-import net.dpml.system.SystemContext;

import java.io.File;

@@ -77,7 +76,6 @@
*
* @param logger the logging channel to assign
* @param name the deployment context name
- * @param system the system context
* @param classloader the containers classloader
* @param graph the containers dependency graph
* @param model the parent containment model
@@ -93,13 +91,13 @@
* clazz, profile or model argument is null.
*/
public DefaultComponentContext(
- Logger logger, String name, SystemContext system, ClassLoader
classloader,
+ Logger logger, String name, ClassLoader classloader,
DependencyGraph graph, ContainmentModel model, ComponentProfile
profile,
Type type, Class clazz, File dir, File temp,
String partition, Runtime runtime, long timeout )
throws NullArgumentException
{
- super( logger, system, partition, name, profile.getMode(), profile,
graph, runtime, timeout );
+ super( logger, partition, name, profile.getMode(), profile, graph,
runtime, timeout );

if( partition == null )
{

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
Mon Jun 20 07:13:39 2005
@@ -406,23 +406,16 @@
*/
public boolean getProxyPolicy()
{
- if ( m_context.getSystemContext().isProxyEnabled() )
+ Type type = getType();
+ InfoDescriptor info = type.getInfo();
+ String attribute = info.getAttribute( PROXY_KEY, "true" );
+ if ( "false".equals( attribute ) )
{
- Type type = getType();
- InfoDescriptor info = type.getInfo();
- String attribute = info.getAttribute( PROXY_KEY, "true" );
- if ( "false".equals( attribute ) )
- {
- return false;
- }
- else
- {
- return true;
- }
+ return false;
}
else
{
- return false;
+ return true;
}
}

@@ -807,7 +800,9 @@
private boolean isaConstructorArg( Class base )
{
if ( null == base )
+ {
return false;
+ }
Class clazz = getDeploymentClass();
Constructor[] constructors = clazz.getConstructors();
if ( constructors.length == 0 )

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionContext.java
Mon Jun 20 07:13:39 2005
@@ -21,7 +21,6 @@
import net.dpml.composition.provider.CompositionContext;
import net.dpml.context.impl.DefaultContext;
import net.dpml.lang.NullArgumentException;
-import net.dpml.system.SystemContext;

/**
* Implementation of a system context that exposes a system wide set of
parameters.
@@ -36,8 +35,6 @@
// immutable state
//--------------------------------------------------------------

- private final SystemContext m_system;
-
private final ClassLoader m_spi;

private final ClassLoader m_api;
@@ -53,18 +50,14 @@
/**
* Creation of a new top-level system context.
*
- * @param system the system context
* @param timeout a system wide default deployment timeout
*/
- DefaultCompositionContext( SystemContext system, ClassLoader api,
ClassLoader spi, long timeout, boolean audit )
+ DefaultCompositionContext( ClassLoader api, ClassLoader spi, long
timeout, boolean audit )
throws NullArgumentException
{
super();

- assertNotNull( "system", system );
-
m_timeout = timeout;
- m_system = system;
m_audit = audit;

m_api = api;
@@ -76,15 +69,6 @@
//--------------------------------------------------------------

/**
- * Return the system context.
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_system;
- }
-
- /**
* Return true if the audit policy is enabled.
* @return the audit enablement status flag
*/
@@ -121,17 +105,4 @@
{
return m_timeout;
}
-
- //------------------------------------------------------------------
- // runtime operations
- //------------------------------------------------------------------
-
- private void assertNotNull( String name, Object object )
- throws NullArgumentException
- {
- if( null == object )
- {
- throw new NullArgumentException( name );
- }
- }
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
Mon Jun 20 07:13:39 2005
@@ -24,7 +24,6 @@
import net.dpml.criteria.PackedParameter;
import net.dpml.criteria.Parameter;
import net.dpml.lang.NullArgumentException;
-import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Handler;
import net.dpml.transit.TransitException;

@@ -50,9 +49,10 @@
// static
//--------------------------------------------------------------

- private static Parameter[] buildParameters( SystemContext context )
+ private static Parameter[] buildParameters()
{
- Properties properties = context.getProperties();
+ // TODO: What do we put in here???
+ Properties properties = System.getProperties();
return new Parameter[] {
new Parameter( AUDIT_ENABLED_KEY, Boolean.class,
getBooleanDefault( properties, AUDIT_ENABLED_KEY, false ) ),
new Parameter( RUNTIME_ARTIFACT_KEY, String.class,
properties.getProperty( RUNTIME_ARTIFACT_KEY ) ),
@@ -93,9 +93,9 @@
// constructor
//--------------------------------------------------------------

- DefaultCompositionCriteria( SystemContext system )
+ DefaultCompositionCriteria()
{
- super( buildParameters( system ) );
+ super( buildParameters() );
}

//--------------------------------------------------------------

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionFactory.java
Mon Jun 20 07:13:39 2005
@@ -28,12 +28,12 @@
import net.dpml.composition.provider.CompositionFactory;
import net.dpml.composition.provider.CompositionRuntimeException;
import net.dpml.composition.provider.ModelFactory;
+import net.dpml.composition.StuffNeeded;
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
import net.dpml.system.Factory;
-import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Artifact;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -61,6 +61,8 @@
public class DefaultCompositionFactory
implements Factory, CompositionFactory
{
+ private static final String LINE =
"-------------------------------------------\n";
+
//--------------------------------------------------------------
// static
//--------------------------------------------------------------
@@ -73,9 +75,9 @@
// immutable state
//--------------------------------------------------------------

- private final SystemContext m_system;
private final CommandLine m_line;
private BundleContext m_OsgiContext;
+ private Logger m_logger;

//--------------------------------------------------------------
// constructor
@@ -84,15 +86,13 @@
/**
* Creation of a new system context.
*
- * @param system the system context
* @param args the command line arguments
*/
- public DefaultCompositionFactory( SystemContext system, String[] args,
BundleContext osgi )
+ public DefaultCompositionFactory( Logger logger, String[] args,
BundleContext osgi )
throws ParseException
{
- m_system = system;
m_OsgiContext = osgi;
-
+ m_logger = logger;
Options options = buildCommandLineOptions();
CommandLineParser parser = new GnuParser();
m_line = parser.parse( options, args, false );
@@ -111,7 +111,7 @@
*/
public CompositionCriteria createCompositionCriteria()
{
- CompositionCriteria criteria = new DefaultCompositionCriteria(
m_system );
+ CompositionCriteria criteria = new DefaultCompositionCriteria();
if( m_line.hasOption( "audit" ) )
{
criteria.put( CompositionCriteria.AUDIT_ENABLED_KEY, new
Boolean( true ) );
@@ -165,7 +165,8 @@

boolean audit = getAuditMode( criteria );
long timeout = getDefaultDeploymentTimeout( criteria );
- File dir = m_system.getWorkingDirectory();
+
+ File dir = StuffNeeded.getWorkingDirectory();
URL kernel = resolveURL( dir, criteria.getKernelPath(), false );

try
@@ -179,10 +180,10 @@
// prepare the info listing
//

- if( m_system.getInfoMode() || getLogger().isDebugEnabled() )
+ if( StuffNeeded.getInfoMode() || getLogger().isDebugEnabled() )
{
StringBuffer buffer = new StringBuffer( "Composition
Context" );
- buffer.append( SystemContext.LINE );
+ buffer.append( LINE );
pack( buffer, CompositionCriteria.KERNEL_KEY, kernel );
pack( buffer, CompositionCriteria.AUDIT_ENABLED_KEY, audit );
pack( buffer, CompositionCriteria.RUNTIME_ARTIFACT_KEY, uri
);
@@ -201,8 +202,8 @@
}
}
pack( buffer, CompositionCriteria.OVERRIDE_KEY, overrides );
- buffer.append( SystemContext.LINE );
- if( m_system.getInfoMode() )
+ buffer.append( LINE );
+ if( StuffNeeded.getInfoMode() )
{
getLogger().info( buffer.toString() );
}
@@ -219,7 +220,7 @@
ClassLoader api = DeploymentModel.class.getClassLoader();
ClassLoader spi = CompositionContext.class.getClassLoader();

- CompositionContext context = new DefaultCompositionContext(
m_system, api, spi, timeout, audit );
+ CompositionContext context = new DefaultCompositionContext( api,
spi, timeout, audit );
if( getLogger().isDebugEnabled() )
{
getLogger().debug( "composition context established" );
@@ -387,7 +388,7 @@

protected Logger getLogger()
{
- return m_system.getLogger();
+ return m_logger;
}

private Options buildCommandLineOptions()

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentContext.java
Mon Jun 20 07:13:39 2005
@@ -25,22 +25,21 @@
import net.dpml.composition.provider.ContainmentContext;
import net.dpml.composition.provider.ModelFactory;
import net.dpml.composition.provider.Runtime;
+import net.dpml.composition.StuffNeeded;
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
-import net.dpml.system.SystemContext;

import java.io.File;

/**
- * Implementation of a containment supplied to a containment model.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
-public class DefaultContainmentContext
- extends DefaultDeploymentContext
+* Implementation of a containment supplied to a containment model.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
+public class DefaultContainmentContext extends DefaultDeploymentContext
implements ContainmentContext
{

@@ -70,7 +69,6 @@
* Creation of a new root containment context.
*
* @param logger the logging channel to assign
- * @param system the system context
* @param model the classloader model
* @param repository the parent model repository
* @param graph the parent dependency graph
@@ -78,14 +76,12 @@
* @param factory the model factory
* @param runtime the runtime provider
*/
- public DefaultContainmentContext(
- Logger logger, SystemContext system, ClassLoaderModel model,
- ModelRepository repository, DependencyGraph graph,
- ContainmentProfile profile, ModelFactory factory, Runtime runtime,
long timeout )
- {
- this( logger, system, model, repository, graph,
- new File( system.getWorkingDirectory(), "home" ),
- new File( system.getTempDirectory(), "root" ),
+ public DefaultContainmentContext( Logger logger, ClassLoaderModel model,
ModelRepository repository, DependencyGraph graph,
+ ContainmentProfile profile,
ModelFactory factory, Runtime runtime, long timeout )
+ {
+ this( logger, model, repository, graph,
+ new File( StuffNeeded.getWorkingDirectory(), "home" ),
+ new File( StuffNeeded.getTempDirectory(), "root" ),
null, profile, null, "", factory, runtime, timeout
);
}
@@ -94,7 +90,6 @@
* Creation of a new containment context.
*
* @param logger the logging channel to assign
- * @param system the system context
* @param model the classloader model
* @param repository the parent model repository
* @param graph the parent dependency graph
@@ -110,18 +105,13 @@
* null.
*/
public DefaultContainmentContext(
- Logger logger, SystemContext system, ClassLoaderModel model,
- ModelRepository repository, DependencyGraph graph,
- File dir, File temp, ContainmentModel parent,
- ContainmentProfile profile, String partition, String name,
- ModelFactory factory, Runtime runtime, long timeout )
+ Logger logger, ClassLoaderModel model, ModelRepository repository,
DependencyGraph graph,
+ File dir, File temp, ContainmentModel parent, ContainmentProfile
profile, String partition, String name,
+ ModelFactory factory, Runtime runtime, long timeout
+ )
throws NullArgumentException
{
- super( logger, system, partition, name, profile.getMode(), profile,
graph, runtime, timeout );
- if( system == null )
- {
- throw new NullArgumentException( "system" );
- }
+ super( logger, partition, name, profile.getMode(), profile, graph,
runtime, timeout );
if( factory == null )
{
throw new NullArgumentException( "factory" );

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
Mon Jun 20 07:13:39 2005
@@ -60,7 +60,6 @@
import net.dpml.meta.info.ServiceDescriptor;
import net.dpml.meta.info.Type;
import net.dpml.parameters.Parameters;
-import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Artifact;
import org.xml.sax.SAXException;

@@ -132,11 +131,10 @@
* the structural association of this containment model
* within a parent scope
*/
- public DefaultContainmentModel( final ContainmentContext context )
+ public DefaultContainmentModel( ContainmentContext context )
throws ModelException
{
super( context );
-
m_context = context;

if( null == context.getPartitionName() )
@@ -570,7 +568,8 @@
* @return the model based on the supplied profile
* @exception ModelException if an error occurs during model establishment
*/
- public DeploymentModel addModel( DeploymentProfile profile ) throws
ModelException
+ public DeploymentModel addModel( DeploymentProfile profile )
+ throws ModelException
{
final String name = profile.getName();
DeploymentModel model = createDeploymentModel( name, profile );
@@ -586,7 +585,8 @@
* @return the model based on the supplied profile
* @exception ModelException if an error occurs during model establishment
*/
- DeploymentModel createDeploymentModel( DeploymentProfile profile )
throws ModelException
+ DeploymentModel createDeploymentModel( DeploymentProfile profile )
+ throws ModelException
{
final String name = profile.getName();
return createDeploymentModel( name, profile );
@@ -877,7 +877,10 @@
}
ContainmentModel parent = m_context.getParentContainmentModel();
if( parent instanceof DefaultContainmentModel )
- ((DefaultContainmentModel) parent).fireModelRemovedEvent( event
);
+ {
+ DefaultContainmentModel model = (DefaultContainmentModel) parent;
+ model.fireModelRemovedEvent( event );
+ }
}

/**
@@ -888,14 +891,11 @@
* @return the composition model
*/
private ComponentModel createComponentModel( final ComponentProfile
profile )
- throws ModelException
+ throws ModelException
{
- DefaultContainmentModelComponentHelper helper =
- new DefaultContainmentModelComponentHelper( m_context, this );
- ComponentContext context =
- helper.createComponentContext( profile );
- ModelFactory factory =
- m_context.getModelFactory();
+ DefaultContainmentModelComponentHelper helper = new
DefaultContainmentModelComponentHelper( m_context, this );
+ ComponentContext context = helper.createComponentContext( profile );
+ ModelFactory factory = m_context.getModelFactory();
return factory.createComponentModel( context );
}

@@ -906,8 +906,8 @@
* @param profile a containment profile
* @return the composition model
*/
- private ContainmentModel createContainmentModel( final
ContainmentProfile profile )
- throws ModelException
+ private ContainmentModel createContainmentModel( ContainmentProfile
profile )
+ throws ModelException
{
final String name = profile.getName();
return createContainmentModel( name, profile );
@@ -921,9 +921,8 @@
* @param profile a containment profile
* @return the composition model
*/
- private ContainmentModel createContainmentModel(
- final String name, final ContainmentProfile profile )
- throws ModelException
+ private ContainmentModel createContainmentModel( String name,
ContainmentProfile profile )
+ throws ModelException
{
return createContainmentModel( name, profile, new URL[0] );
}
@@ -944,8 +943,7 @@

if( getLogger().isDebugEnabled() )
{
- SystemContext system = m_context.getSystemContext();
- final String message = REZ.getString( "containment.add",
system.toString( name ) );
+ final String message = REZ.getString( "containment.add", name );
getLogger().debug( message );
}

@@ -954,30 +952,22 @@

try
{
- final ClassLoaderModel classLoaderModel =
- m_context.getClassLoaderModel().createClassLoaderModel(
- log, profile, implicit );
+ final ClassLoaderModel classLoaderModel =
m_context.getClassLoaderModel().createClassLoaderModel( log, profile,
implicit );

final File dir = new File( m_context.getWorkingDirectory(), name
);
final File temp = new File( m_context.getTempDirectory(), name );
final Logger logger = getLogger().getChildLogger( name );

- ModelRepository modelRepository =
- m_context.getModelRepository();
+ ModelRepository modelRepository = m_context.getModelRepository();

- DependencyGraph graph =
- m_context.getDependencyGraph();
+ DependencyGraph graph = m_context.getDependencyGraph();

- DefaultContainmentContext context =
- new DefaultContainmentContext(
- logger, m_context.getSystemContext(),
- classLoaderModel, modelRepository, graph,
- dir, temp, this, profile, partition, name,
- m_context.getModelFactory(), m_context.getRuntime(),
- m_context.getDefaultDeploymentTimeout() );
+ DefaultContainmentContext context = new
DefaultContainmentContext( logger, classLoaderModel, modelRepository, graph,
+ dir, temp, this, profile, partition, name,
m_context.getModelFactory(), m_context.getRuntime(),
+ m_context.getDefaultDeploymentTimeout()
+ );

- ModelFactory factory =
- m_context.getModelFactory();
+ ModelFactory factory = m_context.getModelFactory();
return factory.createContainmentModel( context );
}
catch( ModelException e )
@@ -1044,8 +1034,7 @@
{
if( path.indexOf( ":" ) < 0 )
{
- URL anchor =
- m_context.getSystemContext().getWorkingDirectory().toURL();
+ URL anchor = m_context.getWorkingDirectory().toURL();
URL url = new URL( anchor, path );
return createContainmentModel( name, url );
}
@@ -1057,11 +1046,7 @@
}
catch( MalformedURLException e )
{
- final String error =
- "Unable to include block [" + name
- + "] into the containmment model ["
- + getQualifiedName()
- + "] because of a url related error.";
+ final String error = "Unable to include block [" + name + "]
into the containmment model [" + getQualifiedName() + "] because of a url
related error.";
throw new ModelException( error, e );
}
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
Mon Jun 20 07:13:39 2005
@@ -31,7 +31,6 @@
import net.dpml.logging.ConsoleLogger;
import net.dpml.logging.Logger;
import net.dpml.meta.info.Type;
-import net.dpml.system.SystemContext;

import java.io.File;

@@ -101,7 +100,6 @@
throw new NullArgumentException( "profile" );
}

- SystemContext system = m_context.getSystemContext();
final String name = profile.getName();
final String partition = m_model.getPartition();
// TODO: Get hold of the LogService facade.
@@ -117,7 +115,7 @@
Class base = classloader.loadClass( profile.getClassname() );
Type type =
m_model.getClassLoaderModel().getTypeRepository().getType( base );

- return new DefaultComponentContext( logger, name, system,
classloader, graph, m_model,
+ return new DefaultComponentContext( logger, name, classloader,
graph, m_model,
profile, type, base, dir, temp, partition,
m_context.getRuntime(), m_context.getDefaultDeploymentTimeout() );
}
catch( ClassNotFoundException e )

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentContext.java
Mon Jun 20 07:13:39 2005
@@ -32,8 +32,6 @@

import net.dpml.logging.Logger;

-import net.dpml.system.SystemContext;
-
/**
* Default implementation of a deployment context.
*
@@ -52,7 +50,6 @@
private final Logger m_logger;
private final Mode m_mode;
private final DependencyGraph m_graph;
- private final SystemContext m_system;
private final DeploymentProfile m_profile;
private final Runtime m_runtime;
private final long m_timeout;
@@ -74,7 +71,7 @@
* profile or system argument is null.
*/
public DefaultDeploymentContext(
- Logger logger, SystemContext system, String partition, String
name,
+ Logger logger, String partition, String name,
Mode mode, DeploymentProfile profile, DependencyGraph graph,
Runtime runtime, long timeout )
throws NullArgumentException
@@ -100,10 +97,6 @@
{
throw new NullArgumentException( "profile" );
}
- if( system == null )
- {
- throw new NullArgumentException( "system" );
- }

m_profile = profile;
m_graph = new DependencyGraph( graph );
@@ -113,7 +106,6 @@
}

m_logger = logger;
- m_system = system;
m_partition = partition;
m_name = name;
m_mode = mode;
@@ -136,16 +128,6 @@
}

/**
- * Return the system context.
- *
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_system;
- }
-
- /**
* Return the profile name.
* @return the name
*/

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFileSelector.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFileSelector.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFileSelector.java
Mon Jun 20 07:13:39 2005
@@ -23,16 +23,17 @@

public class DefaultFileSelector implements FileSelector
{
- /**
- * This file selector implementation will not filter any file
- * candidates, but instead allow all selections.
- *
- * @param basedir <code>File</code> object for the base directory
- * @param filename the name of the file to check
- * @param file <code>File</code> object for this filename
- * @return whether the file should be selected or not
- */
- public boolean isSelected(File basedir, String filename, File file) {
- return true;
- }
+ /**
+ * This file selector implementation will not filter any file
+ * candidates, but instead allow all selections.
+ *
+ * @param basedir <code>File</code> object for the base directory
+ * @param filename the name of the file to check
+ * @param file <code>File</code> object for this filename
+ * @return whether the file should be selected or not
+ */
+ public boolean isSelected( File basedir, String filename, File file )
+ {
+ return true;
+ }
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFilesetModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFilesetModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultFilesetModel.java
Mon Jun 20 07:13:39 2005
@@ -28,68 +28,74 @@


/**
- * Implementation of a <code>FilesetModel</code> in which a set
- * of <code>IncludeDirective</code> objects, a set of
- * <code>ExcludeDirective</code> objects, a set of default
- * includes and excludes, and a base directory anchor are used
- * to resolve and build a set of files specified by a
- * <code>FilesetDirective</code>.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
+* Implementation of a <code>FilesetModel</code> in which a set
+* of <code>IncludeDirective</code> objects, a set of
+* <code>ExcludeDirective</code> objects, a set of default
+* includes and excludes, and a base directory anchor are used
+* to resolve and build a set of files specified by a
+* <code>FilesetDirective</code>.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
public class DefaultFilesetModel
implements FilesetModel
{
/**
- * Base directory anchor from which to begin filset resolution.
- */
+ * Base directory anchor from which to begin filset resolution.
+ */
private File m_anchor = null;
+
/**
- * Array of <code>IncludeDirective</code> objects to use during
- * fileset resolution.
- */
+ * Array of <code>IncludeDirective</code> objects to use during
+ * fileset resolution.
+ */
private IncludeDirective[] m_includes = null;
+
/**
- * Array of <code>ExcludeDirective</code> objects to use during
- * fileset resolution.
- */
+ * Array of <code>ExcludeDirective</code> objects to use during
+ * fileset resolution.
+ */
private ExcludeDirective[] m_excludes = null;
+
/**
- * Array of <code>String</code> objects to use as a default set
- * of fileset includes.
- */
+ * Array of <code>String</code> objects to use as a default set
+ * of fileset includes.
+ */
private String[] m_defaultIncludes = null;
+
/**
- * Array of <code>String</code> objects to use as a default set
- * of fileset excludes.
- */
+ * Array of <code>String</code> objects to use as a default set
+ * of fileset excludes.
+ */
private String[] m_defaultExcludes = null;
+
/**
- * Array of <code>File</code> objects representing the results
- * of fileset resolution.
- */
+ * Array of <code>File</code> objects representing the results
+ * of fileset resolution.
+ */
private ArrayList m_list = null;
+
/**
- * Container-supplied logger instance.
- */
+ * Container-supplied logger instance.
+ */
private final Logger m_logger;

/**
- * Constructs a new default fileset model.
- *
- * @param anchor base directory anchor from which to begin
- * fileset resolution
- * @param includes array of <code>IncludeDirective</code> objects
- * to use during fileset resolution
- * @param excludes array of <code>ExcludeDirective</code> objects
- * to use during fileset resolution
- * @param defaultIncludes array of <code>String</code> objects
- * to use as a default set of fileset includes
- * @param defaultExcludes array of <code>String</code> objects
- * to use as a default set of fileset excludes
- * @param logger <code>Logger</code> for the fileset model to use
- */
+ * Constructs a new default fileset model.
+ *
+ * @param anchor base directory anchor from which to begin
+ * fileset resolution
+ * @param includes array of <code>IncludeDirective</code> objects
+ * to use during fileset resolution
+ * @param excludes array of <code>ExcludeDirective</code> objects
+ * to use during fileset resolution
+ * @param defaultIncludes array of <code>String</code> objects
+ * to use as a default set of fileset includes
+ * @param defaultExcludes array of <code>String</code> objects
+ * to use as a default set of fileset excludes
+ * @param logger <code>Logger</code> for the fileset model to use
+ */
public DefaultFilesetModel(File anchor, IncludeDirective[] includes,
ExcludeDirective[] excludes, String[] defaultIncludes,
String[] defaultExcludes, Logger logger)
@@ -104,42 +110,42 @@
}

/**
- * Establishes the base directory anchor for the fileset resolution.
- *
- * @param anchor the base directory anchor
- */
+ * Establishes the base directory anchor for the fileset resolution.
+ *
+ * @param anchor the base directory anchor
+ */
private void setBaseDirectory(File anchor) {
m_anchor = anchor;
}

/**
- * Establishes the set of <code>IncludeDirective</code> objects
- * to use during fileset resolution.
- *
- * @param includes array of <code>IncludeDirective</code> objects
- */
+ * Establishes the set of <code>IncludeDirective</code> objects
+ * to use during fileset resolution.
+ *
+ * @param includes array of <code>IncludeDirective</code> objects
+ */
private void setIncludeDirectives(IncludeDirective[] includes) {
m_includes = includes;
}

/**
- * Establishes the set of <code>ExcludeDirective</code> objects
- * to use during fileset resolution.
- *
- * @param excludes array of <code>ExcludeDirectives</code>
- */
+ * Establishes the set of <code>ExcludeDirective</code> objects
+ * to use during fileset resolution.
+ *
+ * @param excludes array of <code>ExcludeDirectives</code>
+ */
private void setExcludeDirectives(ExcludeDirective[] excludes) {
m_excludes = excludes;
}

/**
- * Establishes a set of default includes to use during fileset
- * resolution in lieu of an explicit specification of a set
- * of <code>IncludeDirective</code> objects.
- *
- * @param defaultIncludes array of <code>String</code> objects
- * representing a set of default fileset includes
- */
+ * Establishes a set of default includes to use during fileset
+ * resolution in lieu of an explicit specification of a set
+ * of <code>IncludeDirective</code> objects.
+ *
+ * @param defaultIncludes array of <code>String</code> objects
+ * representing a set of default fileset includes
+ */
private void setDefaultIncludes(String[] defaultIncludes) {
if (defaultIncludes == null) {
//m_defaultIncludes = new String[1];
@@ -151,13 +157,13 @@
}

/**
- * Establishes a set of default excludes to use during fileset
- * resolution in lieu of an explicit specification of a set
- * of <code>ExcludeDirective</code> objects.
- *
- * @param defaultExcludes array of <code>String</code> objects
- * representing a set of default fileset excludes
- */
+ * Establishes a set of default excludes to use during fileset
+ * resolution in lieu of an explicit specification of a set
+ * of <code>ExcludeDirective</code> objects.
+ *
+ * @param defaultExcludes array of <code>String</code> objects
+ * representing a set of default fileset excludes
+ */
private void setDefaultExcludes(String[] defaultExcludes) {
if (defaultExcludes == null) {
m_defaultExcludes = new String[0];
@@ -167,21 +173,21 @@
}

/**
- * Returns a set of <code>File</code> objects representing the
- * results of the fileset resolution. This array will contain
- * fully qualified filenames based on the base directory anchor.
- *
- * @return an array of files to include in the classpath
- */
+ * Returns a set of <code>File</code> objects representing the
+ * results of the fileset resolution. This array will contain
+ * fully qualified filenames based on the base directory anchor.
+ *
+ * @return an array of files to include in the classpath
+ */
public ArrayList getIncludes() {
return m_list;
}

/**
- * Resolves the specified include and exclude directives from
- * the base directory anchor and produces an array of files
- * to include in the classpath.
- */
+ * Resolves the specified include and exclude directives from
+ * the base directory anchor and produces an array of files
+ * to include in the classpath.
+ */
public void resolveFileset() throws IOException, IllegalStateException {
// sanity check...
if (m_anchor == null) {

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultImportModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultImportModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultImportModel.java
Mon Jun 20 07:13:39 2005
@@ -170,7 +170,7 @@
{
try
{
- return m_context.getSystemContext().get( key );
+ return m_context.get( key );
}
catch( ContextException e )
{

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
Mon Jun 20 07:13:39 2005
@@ -39,17 +39,17 @@
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
import net.dpml.lang.NullArgumentException;
-import net.dpml.logging.Logger;
import net.dpml.logging.ConsoleLogger;
+import net.dpml.logging.Logger;
import net.dpml.system.Factory;
-import net.dpml.system.SystemContext;
import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
import org.osgi.framework.BundleContext;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.net.URL;

@@ -114,9 +114,9 @@
throw new NullArgumentException( "deployment" );
}
m_context = context;
- m_logger = context.getSystemContext().getLogger();
+ m_logger = new ConsoleLogger();
Configuration config = getKernelConfiguration( kernel );
- m_runtime = createRuntime( context.getSystemContext(), uri, osgi );
+ m_runtime = createRuntime( uri, osgi );

//
// create the root container
@@ -137,9 +137,7 @@
URL url = deployment[ i ];
if( getLogger().isInfoEnabled() )
{
- getLogger().debug( "installing: "
- + m_context.getSystemContext().toString( url )
- );
+ getLogger().debug( "installing: "+ url );
}
try
{
@@ -312,20 +310,11 @@
ClassLoader root = m_context.getAPIClassLoader();
try
{
- ClassLoaderDirective classLoaderDirective =
- profile.getClassLoaderDirective();
- ClassLoaderContext classLoaderContext = new
DefaultClassLoaderContext( logger,
- m_context.getSystemContext(), root, classLoaderDirective
- );
+ ClassLoaderDirective classLoaderDirective =
profile.getClassLoaderDirective();
+ ClassLoaderContext classLoaderContext = new
DefaultClassLoaderContext( logger, root, classLoaderDirective );
ClassLoaderModel classLoaderModel = new DefaultClassLoaderModel(
classLoaderContext );
- return new DefaultContainmentContext( logger,
- m_context.getSystemContext(),
- classLoaderModel,
- null, null,
- profile,
- this,
- m_runtime,
- m_context.getDefaultDeploymentTimeout()
+ return new DefaultContainmentContext( logger, classLoaderModel,
null, null, profile, this,
+ m_runtime,
m_context.getDefaultDeploymentTimeout()
);
} catch( NullArgumentException e )
{
@@ -416,7 +405,7 @@
/**
* Create a runtime using the supplied artifact. The implementation
*/
- private Runtime createRuntime( SystemContext system, URI uri,
BundleContext osgiContext )
+ private Runtime createRuntime( URI uri, BundleContext osgiContext )
throws CompositionException
{
if( null == uri )
@@ -427,9 +416,9 @@
Object object = null;
try
{
- Repository repository = system.getRepository();
+ Repository repository = new StandardLoader();
ClassLoader classloader =
CompositionContext.class.getClassLoader();
- Object plugin = repository.getPlugin( classloader, uri, new
Object[]{system, osgiContext} );
+ Object plugin = repository.getPlugin( classloader, uri, new
Object[]{ osgiContext } );
if( plugin instanceof Factory )
{
object = ( (Factory) plugin ).create();

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
Mon Jun 20 07:13:39 2005
@@ -29,7 +29,6 @@
import net.dpml.meta.info.builder.BuildException;
import net.dpml.meta.info.builder.impl.ServiceBuilder;
import net.dpml.meta.info.builder.impl.TypeBuilder;
-import net.dpml.system.SystemContext;

import java.io.File;
import java.io.IOException;
@@ -79,11 +78,6 @@
*/
private ClassLoader m_classloader;

- /**
- * System context.
- */
- private SystemContext m_system;
-
private Logger m_logger;


@@ -101,19 +95,14 @@
* @exception NullArgumentException if the classloader argument or the
system
* argument is null.
*/
- public Scanner( Logger logger, SystemContext system, ClassLoader
classloader )
+ public Scanner( Logger logger, ClassLoader classloader )
throws NullArgumentException
{
if( classloader == null )
{
throw new NullArgumentException( "classloader" );
}
- if( system == null )
- {
- throw new NullArgumentException( "system" );
- }
m_classloader = classloader;
- m_system = system;
m_logger = logger;
}

@@ -157,7 +146,7 @@
{
if( getLogger().isDebugEnabled() )
{
- String message = REZ.getString( "scanner.scanning",
m_system.toString( url.toString() ) );
+ String message = REZ.getString( "scanner.scanning",
url.toString() );
getLogger().debug( message );
}
if( isDirectory( url ) )

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
Mon Jun 20 07:13:39 2005
@@ -18,18 +18,14 @@

package net.dpml.composition.provider;

-import java.io.File;
-import java.net.URL;
-
-import net.dpml.system.SystemContext;
import net.dpml.composition.data.ClassLoaderDirective;
-import net.dpml.composition.model.TypeRepository;
import net.dpml.composition.model.ServiceRepository;
-
+import net.dpml.composition.model.TypeRepository;
import net.dpml.context.Context;
import net.dpml.logging.Logger;

-import net.dpml.transit.repository.Repository;
+import java.io.File;
+import java.net.URL;

/**
* Defintion of a working context.
@@ -48,13 +44,6 @@
Logger getLogger();

/**
- * Return the local repository.
- *
- * @return the repository
- */
- Repository getRepository();
-
- /**
* Return the base directory from which relative library directives
* and fileset directory paths may be resolved.
*
@@ -98,11 +87,4 @@
* @return the implied urls
*/
URL[] getImplicitURLs();
-
- /**
- * Return the system context.
- *
- * @return the system context
- */
- SystemContext getSystemContext();
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ComponentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ComponentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ComponentContext.java
Mon Jun 20 07:13:39 2005
@@ -18,14 +18,13 @@

package net.dpml.composition.provider;

-import java.io.File;
-
-import net.dpml.system.SystemContext;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.model.ContainmentModel;
import net.dpml.meta.info.ContextDescriptor;
import net.dpml.meta.info.Type;

+import java.io.File;
+
/**
* Defintion of a component deployment context.
*
@@ -60,13 +59,6 @@
static final String TEMP_KEY = ContextDescriptor.TEMP_KEY;

/**
- * Return the system context.
- *
- * @return the system context
- */
- SystemContext getSystemContext();
-
- /**
* Return the working directory for the component.
*
* @return the working directory

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionContext.java
Mon Jun 20 07:13:39 2005
@@ -19,7 +19,6 @@
package net.dpml.composition.provider;

import net.dpml.context.Context;
-import net.dpml.system.SystemContext;

/**
* Defintion of a system context that exposes a system wide set of
parameters.
@@ -30,13 +29,6 @@
public interface CompositionContext extends Context
{
/**
- * Return the system context.
- *
- * @return the factory
- */
- SystemContext getSystemContext();
-
- /**
* Return the API classloader.
*
* @return the API classloader

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
Mon Jun 20 07:13:39 2005
@@ -22,8 +22,6 @@
import java.util.Map;
import java.net.URL;

-import net.dpml.system.SystemContext;
-
/**
* CompositionCriteria is convinience interface that extends Map with
* a set of operations that enable easy manipulation of the composition
@@ -39,7 +37,7 @@
// criteria keys
//--------------------------------------------------------------

- String GROUP = SystemContext.DOMAIN + ".composition";
+ String GROUP = "dpml.composition";

String AUDIT_ENABLED_KEY = GROUP + ".audit";

@@ -154,5 +152,4 @@
* @return the block urls
*/
URL[] getDeploymentURLs( File base );
-
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
Mon Jun 20 07:13:39 2005
@@ -18,14 +18,12 @@

package net.dpml.composition.provider;

-import java.net.URL;
-import java.net.URLClassLoader;
-
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.ContainmentModel;
import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;

-import net.dpml.system.SystemContext;
+import java.net.URL;
+import java.net.URLClassLoader;

/**
* Utility class that supports the listing of a composition tree.
@@ -35,6 +33,8 @@
*/
public class CompositionHelper
{
+ private static final String LINE =
"-----------------------------------------\n";
+
private CompositionHelper()
{
}
@@ -42,13 +42,13 @@
public static String toString( DeploymentModel model )
{
StringBuffer buffer = new StringBuffer( "audit report" );
- buffer.append( SystemContext.LINE );
+ buffer.append( LINE );
buffer.append( "\nComposition Model" );
- buffer.append( SystemContext.LINE );
+ buffer.append( LINE );
buffer.append( "\n" );
printModel( buffer, " ", model );
buffer.append( "\n" );
- buffer.append( SystemContext.LINE );
+ buffer.append( LINE );
return buffer.toString();
}


Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ContainmentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ContainmentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/ContainmentContext.java
Mon Jun 20 07:13:39 2005
@@ -18,12 +18,12 @@

package net.dpml.composition.provider;

-import java.io.File;
-
import net.dpml.composition.data.ContainmentProfile;
import net.dpml.composition.model.ClassLoaderModel;
-import net.dpml.composition.model.ModelRepository;
import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.ModelRepository;
+
+import java.io.File;

/**
* Defintion of a working context.

Modified:
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/DeploymentContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/DeploymentContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/spi/src/main/net/dpml/composition/provider/DeploymentContext.java
Mon Jun 20 07:13:39 2005
@@ -19,8 +19,6 @@
package net.dpml.composition.provider;

import net.dpml.composition.model.DependencyGraph;
-
-import net.dpml.system.SystemContext;
import net.dpml.context.Context;
import net.dpml.logging.Logger;
import net.dpml.composition.data.Mode;
@@ -67,13 +65,6 @@
Logger getLogger();

/**
- * Return the composition context.
- *
- * @return the system context
- */
- SystemContext getSystemContext();
-
- /**
* Return the runtime.
*
* @return the runtime

Modified:
development/laboratory/users/niclas/osgi/metro/composition/test/build.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/composition/test/build.xml
(original)
+++ development/laboratory/users/niclas/osgi/metro/composition/test/build.xml
Mon Jun 20 07:13:39 2005
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-composition-test" default="install" basedir="."
+<project name="dpml-composition-test" default="install" basedir="."
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >

<transit:import uri="artifact:template:dpml/magic/standard"/>

<target name="init" depends="standard.init">
<x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION_IMPL_URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="TRANSIT-IMPL-SPEC"/>
<x:filter feature="uri" key="dpml-test-testa" token="TEST-A-SPEC"/>
<x:filter feature="uri" key="dpml-test-testb" token="TEST-B-SPEC"/>
<x:filter feature="uri" key="dpml-test-testc" token="TEST-C-SPEC"/>

Modified: development/laboratory/users/niclas/osgi/metro/index.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/index.xml (original)
+++ development/laboratory/users/niclas/osgi/metro/index.xml Mon Jun 20
07:13:39 2005
@@ -221,12 +221,11 @@
<include key="dpml-activity-api" tag="api"/>
<include key="dpml-context-api" tag="api"/>
<include key="dpml-transit-main" tag="api"/>
- <include key="dpml-system-spi" tag="spi"/>
+ <include key="dpml-system-api"/>
<include key="dpml-util-i18n"/>
<include key="dpml-util-exception"/>
<include key="dpml-util-criteria"/>
<include key="dpml-util-cli"/>
- <include key="dpml-system-impl" build="false"/>
<include key="dpml-composition-impl" build="false"/>
<include key="commons-cli"/>
</dependencies>
@@ -244,7 +243,6 @@
<include key="dpml-composition-api"/>
<include key="dpml-transit-main"/>
<include key="dpml-system-api"/>
- <include key="dpml-system-spi"/>
<include key="osgi" runtime="false" />
</dependencies>
</project>
@@ -260,9 +258,9 @@
</info>
<dependencies>
<include key="dpml-composition-spi"/>
+ <include key="dpml-system-api"/>
<include key="dpml-util-exception"/>
<include key="dpml-composition-impl" build="false"/>
- <include key="dpml-system-impl" build="false"/>
<include key="dpml-configuration-impl"/>
<include key="dpml-parameters-impl"/>
<include key="dpml-context-impl"/>
@@ -309,7 +307,6 @@
</types>
</info>
<dependencies>
- <include key="dpml-system-spi"/>
<include key="dpml-composition-api"/>
</dependencies>
</project>
@@ -335,6 +332,7 @@
<include key="dpml-composition-spi" tag="spi"/>
<include key="dpml-meta-spi" tag="spi"/>
<include key="dpml-configuration-impl"/>
+ <include key="dpml-system-api"/>
<include key="dpml-meta-impl"/>
<include key="dpml-util-exception"/>
<include key="dpml-context-impl"/>
@@ -355,10 +353,8 @@
</types>
</info>
<dependencies>
- <include key="dpml-system-spi"/>
<include key="dpml-composition-spi"/>
<include key="dpml-composition-impl"/>
- <include key="dpml-system-impl" test="false"/>
<include key="dpml-composition-impl" test="false"/>
<include key="dpml-util-exception"/>
<include key="dpml-test-testa" test="false"/>
@@ -367,7 +363,6 @@
<include key="dpml-test-testcyclic" test="false"/>
<include key="dpml-test-includes" test="false"/>
<include key="dpml-test-dynamics" test="false"/>
- <include key="dpml-system-impl" build="false"/>
<include key="dpml-test-testschema"/>

<!-- VERY STRANGE THAT THE BELOW IS REQUIRED!!!!!! -->
@@ -403,56 +398,6 @@
</dependencies>
</project>

- <project basedir="system/spi">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-system-spi</name>
- <types>
- <type>jar</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-context-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-system-api"/>
- <include key="dpml-transit-main"/>
- </dependencies>
- </project>
-
- <project basedir="system/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-system-impl</name>
- <types>
- <type>jar</type>
- <type>plugin</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-system-spi" tag="spi"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-context-impl"/>
- <include key="dpml-util-criteria"/>
- <include key="dpml-util-defaults"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-cli"/>
- </dependencies>
- </project>
-
- <project basedir="system/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-system-test</name>
- <types>
- <type>jar</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-system-spi"/>
- <include key="dpml-system-impl" build="false"/>
- </dependencies>
- </project>
-
<!--
DPML Activation.
-->
@@ -470,28 +415,6 @@
</dependencies>
</project>

- <project basedir="activation/providers/metro">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-activation-metro-provider</name>
- <types>
- <type>jar</type>
- <type>plugin</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-activation-api" tag="api"/>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-composition-api" tag="api"/>
- <include key="dpml-composition-spi" tag="spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-defaults"/>
- <include key="dpml-system-spi"/>
- <include key="osgi" runtime="false" />
- <include key="dpml-context-impl"/>
- </dependencies>
- </project>
-
<project basedir="activation/impl">
<info>
<group>dpml/metro/private</group>
@@ -502,11 +425,11 @@
</types>
</info>
<dependencies>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-context-impl"/>
<include key="dpml-transit-main" tag="api"/>
<include key="dpml-activation-api" tag="api"/>
<include key="dpml-composition-api" tag="api"/>
- <include key="dpml-activation-metro-provider" build="false"/>
- <include key="dpml-system-impl" build="false"/>
<include key="osgi" runtime="false" />
</dependencies>
</project>

Modified: development/laboratory/users/niclas/osgi/metro/main/build.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/main/build.xml
(original)
+++ development/laboratory/users/niclas/osgi/metro/main/build.xml Mon
Jun 20 07:13:39 2005
@@ -7,7 +7,6 @@

<target name="init" depends="standard.init">
<x:filter feature="plugin" token="METRO-PLUGIN-URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
<x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION-IMPL-ARTIFACT-URI"/>
<x:filter feature="plugin" key="dpml-activation-impl"
token="RUNTIME-IMPL-ARTIFACT-URI"/>
<x:filter feature="version" key="dpml-transit-main"
token="TRANSIT_VERSION"/>

Modified:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/Metro.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/Metro.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/Metro.java
Mon Jun 20 07:13:39 2005
@@ -19,31 +19,20 @@
package net.dpml.metro;

import net.dpml.activity.Startable;
-
import net.dpml.cli.ArgumentHandler;
-
+import net.dpml.composition.StuffNeeded;
import net.dpml.exception.ExceptionHelper;
-
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
-
import net.dpml.lang.NullArgumentException;
-
+import net.dpml.logging.ConsoleLogger;
import net.dpml.logging.Logger;
-
import net.dpml.system.Factory;
-
-import net.dpml.system.SystemContext;
-import net.dpml.system.SystemContextFactory;
-import net.dpml.system.SystemException;
-
import net.dpml.transit.Transit;
-
import net.dpml.transit.artifact.Artifact;
-
import net.dpml.transit.repository.Plugin;
import net.dpml.transit.repository.Repository;
-
+import net.dpml.transit.repository.StandardLoader;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
@@ -57,10 +46,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-
import java.net.URI;
import java.net.URISyntaxException;
-
import java.util.Map;
import java.util.Properties;

@@ -77,19 +64,17 @@
*/
public class Metro implements Runnable
{
+ private static final String LINE =
"-----------------------------------\n";
+
//
------------------------------------------------------------------------
// static
//
------------------------------------------------------------------------

private static Resources REZ = ResourceManager.getPackageResources(
Metro.class );

- private static String SYSTEM_IMPL_PLUGIN_DEFAULT = "@SYSTEM-PLUGIN-URI@";
-
- public static String SYSTEM_IMPL_SPEC_KEY = SystemContext.DOMAIN +
".metro.system.artifact";
-
private static String TARGET_DEFAULT_URI =
"@COMPOSITION-IMPL-ARTIFACT-URI@";

- public static String TARGET_URI_KEY = SystemContext.DOMAIN +
".metro.main.artifact";
+ public static String TARGET_URI_KEY = "dpml.metro.main.artifact";

public static String DPML_PROPERTIES = "dpml.properties";

@@ -103,7 +88,6 @@
// mutable state
//
------------------------------------------------------------------------

- private SystemContext m_system;
private Logger m_logger;
private Object m_plugin;
private boolean m_fail = false;
@@ -164,9 +148,8 @@
//

Properties properties = getInitialProperties();
- URI system = getSystemContextURI( properties );
- m_system = loadSystemContext( map, repository, system,
pair.getRemainder() );
- m_logger = m_system.getLogger();
+
+ m_logger = new ConsoleLogger();
getLogger().debug( "system context established" );

//
@@ -179,19 +162,18 @@
getLogger().debug( "loading plugin: [" + target + "]." );

ClassLoader classloader = getRootClassLoader();
- m_plugin = loadPlugin( classloader, m_system, target );
+ m_plugin = loadPlugin( classloader, target );

StringBuffer buffer = new StringBuffer( "Metro Context" );
- buffer.append( SystemContext.LINE );
- pack( buffer, SYSTEM_IMPL_SPEC_KEY, system.toString() );
+ buffer.append( LINE );
pack( buffer, TARGET_URI_KEY, target.toString() );
- buffer.append( SystemContext.LINE );
+ buffer.append( LINE );

- if( m_system.getInfoMode() )
+ if( StuffNeeded.getInfoMode() )
{
getLogger().info( buffer.toString() );
}
- else if( m_system.getDebugMode() )
+ else if( StuffNeeded.getDebugMode() )
{
getLogger().debug( buffer.toString() );
}
@@ -240,7 +222,7 @@

private ClassLoader getRootClassLoader()
{
- return SystemContext.class.getClassLoader();
+ return Metro.class.getClassLoader();
}

private boolean getServerMode( CommandLine line )
@@ -255,11 +237,12 @@
}
}

- private Object loadPlugin( ClassLoader classloader, SystemContext
system, URI uri )
+ private Object loadPlugin( ClassLoader classloader, URI uri )
throws Exception
{
- Object[] params = new Object[]{ system, system.getArgs(),
getLogger() };
- Object object = system.getRepository().getPlugin( classloader, uri,
params );
+ Repository repository = new StandardLoader();
+ Object[] params = new Object[]{ getLogger() };
+ Object object = repository.getPlugin( classloader, uri, params );
if( object instanceof Factory )
{
return ((Factory)object).create();
@@ -284,37 +267,6 @@
}
}

- private SystemContext loadSystemContext( Map map, Repository repository,
URI uri, String[] args )
- throws SystemException, IOException
- {
- ClassLoader classloader = SystemContext.class.getClassLoader();
- Object[] params = new Object[]{ map, args };
- Object object = repository.getPlugin( classloader, uri, params );
- if( object instanceof SystemContextFactory )
- {
- SystemContextFactory factory = (SystemContextFactory) object;
- return factory.createSystemContext();
- }
- else
- {
- final String error = "The declared system context factory [" +
object.getClass().getName() + "] does not implement the " +
SystemContextFactory.class.getName() + " interface.";
- throw new SystemException( error );
- }
- }
-
- private URI getSystemContextURI( Properties properties ) throws
URISyntaxException
- {
- String spec = properties.getProperty( SYSTEM_IMPL_SPEC_KEY );
- if( null != spec )
- {
- return Artifact.createArtifact( spec ).toURI();
- }
- else
- {
- return Artifact.createArtifact( SYSTEM_IMPL_PLUGIN_DEFAULT
).toURI();
- }
- }
-
private void handleHelpMessage()
{
System.out.println("");
@@ -325,12 +277,10 @@
}

private void handleVersionMessage( Plugin descriptor, Map map )
- throws SystemException, URISyntaxException
+ throws IOException
{
System.out.println( " " );
Properties properties = getInitialProperties();
- URI system = getSystemContextURI( properties );
- System.out.println( " Metro System: " + system );
System.out.println( " Metro CLI: " + descriptor.getURI() );
System.out.println( " Transit CLI: " + map.get(
"urn:transit.cli.uri" ) );
System.out.println( " Transit Handler: " + map.get(
"urn:transit.handler.uri" ) );
@@ -458,39 +408,31 @@
* @return the aggregated properties
*/
private static Properties getInitialProperties()
- throws SystemException
+ throws IOException
{
- try
- {
- File home = Transit.DPML_HOME;
- Properties properties = getStaticProperties();
- File homePreferenceFile = new File( home, DPML_PROPERTIES );
- loadFile( properties, homePreferenceFile );
+ File home = Transit.DPML_HOME;
+ Properties properties = getStaticProperties();
+ File homePreferenceFile = new File( home, DPML_PROPERTIES );
+ loadFile( properties, homePreferenceFile );

- //
- // get ${user.home}/[key].properties
- //
+ //
+ // get ${user.home}/[key].properties
+ //

- File user = getUserDirectory();
- File userPreferenceFile = new File( user, DPML_PROPERTIES );
- loadFile( properties, userPreferenceFile );
+ File user = getUserDirectory();
+ File userPreferenceFile = new File( user, DPML_PROPERTIES );
+ loadFile( properties, userPreferenceFile );

- //
- // get ${user.dir}/[key].properties
- //
+ //
+ // get ${user.dir}/[key].properties
+ //

- File dir = getWorkingDirectory();
- File dirPreferenceFile = new File( dir, DPML_PROPERTIES );
- loadFile( properties, dirPreferenceFile );
+ File dir = getWorkingDirectory();
+ File dirPreferenceFile = new File( dir, DPML_PROPERTIES );
+ loadFile( properties, dirPreferenceFile );

- properties.setProperty( Transit.HOME_KEY, home.toString() );
- return properties;
- }
- catch( IOException ioe )
- {
- final String error = "Unexpected error while attempting to
construct initial context.";
- throw new SystemException( error, ioe );
- }
+ properties.setProperty( Transit.HOME_KEY, home.toString() );
+ return properties;
}

/**

Modified: development/laboratory/users/niclas/osgi/metro/osgi/build.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/osgi/build.xml
(original)
+++ development/laboratory/users/niclas/osgi/metro/osgi/build.xml Mon
Jun 20 07:13:39 2005
@@ -7,7 +7,6 @@

<target name="init" depends="standard.init">
<x:filter feature="plugin" token="METRO-PLUGIN-URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
<x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION-IMPL-ARTIFACT-URI"/>
<x:filter feature="plugin" key="dpml-activation-impl"
token="RUNTIME-IMPL-ARTIFACT-URI"/>
<x:filter feature="version" key="dpml-transit-main"
token="TRANSIT_VERSION"/>

Modified:
development/laboratory/users/niclas/osgi/metro/osgi/src/main/net/dpml/osgi/Metro.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/osgi/src/main/net/dpml/osgi/Metro.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/osgi/src/main/net/dpml/osgi/Metro.java
Mon Jun 20 07:13:39 2005
@@ -18,9 +18,9 @@

package net.dpml.osgi;

+import net.dpml.composition.StuffNeeded;
import net.dpml.composition.model.ContainmentModel;
import net.dpml.system.Factory;
-import net.dpml.system.SystemContext;
import net.dpml.transit.artifact.Artifact;
import net.dpml.transit.repository.Repository;
import net.dpml.transit.repository.StandardLoader;
@@ -29,9 +29,8 @@
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;

+import java.io.File;
import java.net.URI;
-import java.util.Hashtable;
-import java.util.Map;

public class Metro
implements BundleActivator
@@ -48,34 +47,31 @@
throws Exception
{
m_LogService = findLogService( bundleContext );
-
m_LogService.log( LogService.LOG_INFO, "Starting the Metro Bundle.");

String systemDir = bundleContext.getProperty( "dpml.system.dir" );
+ String tempDir = bundleContext.getProperty( "dpml.temp.dir" );
+ String libDir = bundleContext.getProperty( "dpml.lib.dir" );
String debugMode = bundleContext.getProperty(
"urn:transit.debug.policy" );
+ String infoMode = bundleContext.getProperty(
"urn:transit.info.policy" );

Repository repo = new StandardLoader();
- //
- // create the system context
- //
-
URI uri = Artifact.createArtifact( "@SYSTEM-PLUGIN-URI@" ).toURI();
ClassLoader classloader = getClass().getClassLoader();

- Map data = new Hashtable();
- data.put( "urn:transit.debug.policy", new Boolean( debugMode ) );
- Factory systemfactory = (Factory) repo.getPlugin( classloader, uri,
new Object[]{ data } );
- Map systemCriteria = systemfactory.createDefaultCriteria();
- systemCriteria.put( "dpml.system.dir", systemDir );
- SystemContext system = (SystemContext) systemfactory.create(
systemCriteria );
+ StuffNeeded.setDebugMode( new Boolean( debugMode ).booleanValue() );
+ StuffNeeded.setInfoMode( new Boolean( infoMode ).booleanValue() );
+ StuffNeeded.setWorkingDirectory( new File( systemDir ) );
+ StuffNeeded.setTempDirectory( new File( tempDir ) );
+ StuffNeeded.setLibDirectory( new File( libDir ) );

//
// create the composition context
//

uri = new URI( "@COMPOSITION-IMPL-ARTIFACT-URI@" );
- Object[] params = new Object[]{ system };
- Factory modelFactory = (Factory) system.getRepository().getPlugin(
classloader, uri, params );
+ Object[] params = new Object[ 0 ];
+ Factory modelFactory = (Factory) repo.getPlugin( classloader, uri,
params );
m_root = (ContainmentModel) modelFactory.create();
m_LogService.log( LogService.LOG_INFO, String.valueOf( m_root ) );
m_LogService.log( LogService.LOG_INFO, "Metro Bundle started.");

Modified: development/laboratory/users/niclas/osgi/metro/unit/build.xml
==============================================================================
--- development/laboratory/users/niclas/osgi/metro/unit/build.xml
(original)
+++ development/laboratory/users/niclas/osgi/metro/unit/build.xml Mon
Jun 20 07:13:39 2005
@@ -7,7 +7,6 @@

<target name="init" depends="standard.init">
<x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION_PLUGIN_URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
</target>

<target name="documentation" depends="install">

Modified:
development/laboratory/users/niclas/osgi/metro/unit/src/main/net/dpml/metro/unit/CompositionTestCase.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/unit/src/main/net/dpml/metro/unit/CompositionTestCase.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/unit/src/main/net/dpml/metro/unit/CompositionTestCase.java
Mon Jun 20 07:13:39 2005
@@ -19,20 +19,18 @@
package net.dpml.metro.unit;

import junit.framework.TestCase;
-import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.StuffNeeded;
import net.dpml.composition.model.CompositionException;
+import net.dpml.composition.model.ContainmentModel;
import net.dpml.exception.ExceptionHelper;
import net.dpml.system.Factory;
-import net.dpml.system.SystemContext;
-import net.dpml.transit.artifact.Artifact;
import net.dpml.transit.repository.Repository;
import net.dpml.transit.repository.StandardLoader;

import java.io.File;
-import java.net.URI;
import java.net.MalformedURLException;
+import java.net.URI;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;


@@ -86,29 +84,17 @@
protected void setupCompositionRoot( Map map )
throws Exception
{
- Repository repo = new StandardLoader();
-
- //
- // create the system context
- //
-
- URI uri = Artifact.createArtifact( "@SYSTEM-PLUGIN-URI@" ).toURI();
+ StuffNeeded.setWorkingDirectory( WORK );
ClassLoader classloader = CompositionTestCase.class.getClassLoader();

- Map data = new Hashtable();
- data.put( "urn:transit.debug.policy", new Boolean( false ) ); //
TODO check in supplied map
- Factory systemfactory = (Factory) repo.getPlugin( classloader, uri,
new Object[]{data} );
- Map systemCriteria = systemfactory.createDefaultCriteria();
- systemCriteria.put( "dpml.system.dir", WORK );
- SystemContext system = (SystemContext) systemfactory.create(
systemCriteria );
-
//
// create the composition context
//

- uri = new URI( "@COMPOSITION_PLUGIN_URI@" );
- Object[] params = new Object[]{ system };
- Factory modelFactory = (Factory) system.getRepository().getPlugin(
classloader, uri, params );
+ Repository repository = new StandardLoader();
+ URI uri2 = new URI( "@COMPOSITION_PLUGIN_URI@" );
+ Object[] params = new Object[ 0 ];
+ Factory modelFactory = (Factory) repository.getPlugin( classloader,
uri2, params );
m_root = (ContainmentModel) modelFactory.create( map );
}




  • svn commit: r2895 - in development/laboratory/users/niclas/osgi/metro: . activation/impl activation/impl/src/main/net/dpml/activation/impl activation/providers composition/api/src/main/net/dpml/composition composition/api/src/main/net/dpml/composition/model composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/spi/src/main/net/dpml/composition/provider composition/test main main/src/main/net/dpml/metro osgi osgi/src/main/net/dpml/osgi system unit unit/src/main/net/dpml/metro/unit, niclas, 06/20/2005

Archive powered by MHonArc 2.6.24.

Top of Page