Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2924 - in development/laboratory/users/niclas/osgi/metro: . activation/impl/src/main/net/dpml/activation/impl 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/impl/src/test/net/dpml/composition/model/builder main main/src/main/net/dpml/metro main/src/main/net/dpml/metro/commands meta/api/src/main/net/dpml/meta/info osgi/src/main/net/dpml/osgi system system/api/src/main/net/dpml/system system/impl system/spi system/test unit/src/main/net/dpml/metro/unit util

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: r2924 - in development/laboratory/users/niclas/osgi/metro: . activation/impl/src/main/net/dpml/activation/impl 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/impl/src/test/net/dpml/composition/model/builder main main/src/main/net/dpml/metro main/src/main/net/dpml/metro/commands meta/api/src/main/net/dpml/meta/info osgi/src/main/net/dpml/osgi system system/api/src/main/net/dpml/system system/impl system/spi system/test unit/src/main/net/dpml/metro/unit util
  • Date: Sun, 26 Jun 2005 10:06:52 -0400

Author: niclas AT hedhman.org
Date: Sun Jun 26 10:06:51 2005
New Revision: 2924

Added:

development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/SystemContext.java
(contents, props changed)

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

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

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

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

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

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/CcCommand.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/DeployCommand.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ListCommand.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ShowCommand.java
(contents, props changed)

development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/UndeployCommand.java
(contents, props changed)
development/laboratory/users/niclas/osgi/metro/system/
- copied from r2891,
development/laboratory/users/niclas/osgi/metro/system/
Removed:

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

development/laboratory/users/niclas/osgi/metro/composition/impl/src/test/net/dpml/composition/model/builder/ContentHandlerTestCase.java

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

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

development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/CascadingIOException.java

development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/SystemException.java

development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/SystemRuntimeException.java
development/laboratory/users/niclas/osgi/metro/system/impl/
development/laboratory/users/niclas/osgi/metro/system/spi/
development/laboratory/users/niclas/osgi/metro/system/test/

development/laboratory/users/niclas/osgi/metro/unit/src/main/net/dpml/metro/unit/CompositionTestCase.java
development/laboratory/users/niclas/osgi/metro/util/
Modified:

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

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

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/DefaultRuntimeFactory.java

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

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

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

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

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

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.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/DefaultContainmentModel.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/DefaultServiceRepository.java
development/laboratory/users/niclas/osgi/metro/index.xml
development/laboratory/users/niclas/osgi/metro/main/build.xml

development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/ReferenceDescriptor.java

development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/Service.java

development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/Factory.java
Log:
A lot of work to get Metro to run as a bundle. Added commands into Metro,
which requires the Knopflerfish Console. Removed heaps of unused and/or
unneccessary classes.

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultComponentFactory.java
Sun Jun 26 10:06:51 2005
@@ -68,8 +68,7 @@
private final ComponentModel m_model;

private final Logger m_logger;
-
- private final BundleContext m_OsgiContext;
+ private BundleContext m_OsgiContext;

//-------------------------------------------------------------------
// constructor
@@ -130,7 +129,7 @@
public void etherialize( final Object instance )
{
getLogger().debug( "etherialization" );
-
+
if( instance instanceof Startable )
{
getLogger().debug( "applying shutdown" );

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultLifestyleFactory.java
Sun Jun 26 10:06:51 2005
@@ -1,17 +1,17 @@
-/*
+/*
* 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
- *
+ * 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.
*/
@@ -38,7 +38,6 @@
{

private BundleContext m_OsgiContext;
-
//-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
@@ -63,9 +62,9 @@
*/
public LifestyleManager createLifestyleManager( ComponentModel model )
{
- ComponentFactory factory = createComponentFactory( model,
m_OsgiContext );
+ ComponentFactory factory = createComponentFactory( model );

- final String lifestyle =
+ final String lifestyle =
model.getType().getInfo().getLifestyle();

if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
@@ -82,14 +81,14 @@
}
else
{
- final String error =
+ final String error =
"Unsupported lifestyle [" + lifestyle + "].";
throw new IllegalArgumentException( error );
}
}

- private ComponentFactory createComponentFactory( ComponentModel model,
BundleContext osgi )
+ private ComponentFactory createComponentFactory( ComponentModel model )
{
- return new DefaultComponentFactory( model, osgi );
+ return new DefaultComponentFactory( model, m_OsgiContext );
}
}

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
Sun Jun 26 10:06:51 2005
@@ -28,7 +28,6 @@
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;
import java.net.URISyntaxException;
@@ -54,7 +53,6 @@
//--------------------------------------------------------------

private final BlockFactory m_factory;
- private final BundleContext m_OsgiContext;

//--------------------------------------------------------------
// mutable state
@@ -71,14 +69,9 @@
*
* @exception NullArgumentException if the system argument is null.
*/
- public DefaultRuntime( BundleContext osgi )
+ public DefaultRuntime()
throws NullArgumentException
{
- if( osgi == null )
- {
- throw new NullArgumentException( "osgi" );
- }
- m_OsgiContext = osgi;
m_factory = new BlockFactory();
}

@@ -175,7 +168,7 @@
{
ClassLoader classloader = Appliance.class.getClassLoader();
URI uri = getMetroRuntimeArtifact();
- Object[] params = new Object[]{ m_OsgiContext };
+ Object[] params = new Object[]{};

Repository repository = new StandardLoader();
m_metro = (RuntimeFactory) repository.getPlugin(
classloader, uri, params );

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntimeFactory.java
Sun Jun 26 10:06:51 2005
@@ -1,17 +1,17 @@
-/*
+/*
* 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
- *
+ * 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.
*/

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultServiceManager.java
Sun Jun 26 10:06:51 2005
@@ -28,8 +28,8 @@
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 net.dpml.meta.info.DependencyDescriptor;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

@@ -55,8 +55,6 @@
// immutable state
//-------------------------------------------------------------------

- private final BundleContext m_OsgiContext;
-
private final Logger m_logger;

/**
@@ -71,6 +69,7 @@
* A table of dependency models keyed by lookup key.
*/
private final Map m_map;
+ private BundleContext m_OsgiContext;

//-------------------------------------------------------------------
// constructor
@@ -88,15 +87,13 @@
{
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++ )
@@ -165,10 +162,10 @@
return instance;
}

- Object service = establishOsgiProvider( dependency );
- if( service != null )
+ instance = establishOsgiProvider( dependency );
+ if( instance != null )
{
- return service;
+ return instance;
}

final String error = REZ.getString( "service.error.null-provider",
key );
@@ -193,7 +190,7 @@
{
return null;
}
-
+
//
// get a proxy to the service from the provider
// (note that it is up to a provider to determine if

Modified:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/StuffNeeded.java
Sun Jun 26 10:06:51 2005
@@ -6,67 +6,38 @@

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();
- }
+ private static SystemContext m_SystemContext;

- public static File getWorkingDirectory()
+ public static void setSystemContext( SystemContext context )
{
- return m_work;
+ m_SystemContext = context;
}

- public static void setWorkingDirectory( File work )
+ public static File getWorkingDirectory()
{
- m_work = work;
+ String dirname = m_SystemContext.getWorkDirectory();
+ return new File( dirname );
}

public static File getTempDirectory()
{
- return m_temp;
- }
-
- public static void setTempDirectory( File temp )
- {
- m_temp = temp;
+ String dirname = m_SystemContext.getTemporaryDirectory();
+ return new File( dirname );
}

public static File getLibDirectory()
{
- return m_lib;
- }
-
- public static void setLibDirectory( File lib )
- {
- m_lib = lib;
+ String dirname = m_SystemContext.getLibraryDirectory();
+ return new File( dirname );
}

public static boolean getInfoMode()
{
- return m_infoMode;
- }
-
- public static void setInfoMode( boolean on )
- {
- m_infoMode = on;
+ return m_SystemContext.getInfoPolicy();
}

public static boolean getDebugMode()
{
- return m_debugMode;
- }
-
- public static void setDebugMode( boolean on )
- {
- m_debugMode = on;
+ return m_SystemContext.getDebugPolicy();
}
}

Added:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/SystemContext.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/SystemContext.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,91 @@
+package net.dpml.composition;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+public class SystemContext
+ implements ManagedService
+{
+ private static final String SYSTEM_DIR_KEY = "system.dir";
+ private static final String WORK_DIR_KEY = "working.dir";
+ private static final String TEMP_DIR_KEY = "temporary.dir";
+ private static final String LIB_DIR_KEY = "library.dir";
+ private static final String DEBUG_POLICY_KEY = "debug.policy";
+ private static final String INFO_POLICY_KEY = "info.policy";
+
+ private Dictionary m_Properties;
+ private ServiceRegistration m_Registration;
+
+ public SystemContext()
+ {
+ }
+
+ public synchronized void start( BundleContext context )
+ throws Exception
+ {
+ m_Properties = new Hashtable();
+ m_Properties.put( Constants.SERVICE_PID, "net.dpml.metro.Metro" );
+ String systemDir = System.getProperty( "user.home" ) +
"/.dpml/osgi/metro";
+ m_Properties.put( SYSTEM_DIR_KEY, systemDir );
+ m_Properties.put( WORK_DIR_KEY, systemDir + "/work" );
+ m_Properties.put( TEMP_DIR_KEY, systemDir + "/temp" );
+ m_Properties.put( LIB_DIR_KEY, systemDir + "/lib" );
+ m_Properties.put( DEBUG_POLICY_KEY, Boolean.FALSE );
+ m_Properties.put( INFO_POLICY_KEY, Boolean.TRUE );
+ m_Registration = context.registerService(
ManagedService.class.getName(), this, m_Properties );
+ getWorkDirectory();
+ }
+
+ public synchronized void updated( Dictionary np )
+ throws ConfigurationException
+ {
+ if( np != null )
+ {
+ m_Properties = np;
+ m_Properties.put( Constants.SERVICE_PID, "net.dpml.metro.Metro"
);
+ }
+ m_Registration.setProperties( m_Properties );
+ }
+
+ public String getSystemDirectory()
+ {
+ String dirname = (String) m_Properties.get( SYSTEM_DIR_KEY );
+ return dirname;
+ }
+
+ public String getWorkDirectory()
+ {
+ String dirname = (String) m_Properties.get( WORK_DIR_KEY );
+ return dirname;
+ }
+
+ public String getTemporaryDirectory()
+ {
+ String dirname = (String) m_Properties.get( TEMP_DIR_KEY );
+ return dirname;
+ }
+
+ public String getLibraryDirectory()
+ {
+ String dirname = (String) m_Properties.get( LIB_DIR_KEY );
+ return dirname;
+ }
+
+ public boolean getDebugPolicy()
+ {
+ Boolean policy = (Boolean) m_Properties.get( DEBUG_POLICY_KEY );
+ return policy.booleanValue();
+ }
+
+ public boolean getInfoPolicy()
+ {
+ Boolean policy = (Boolean) m_Properties.get( INFO_POLICY_KEY );
+ return policy.booleanValue();
+ }
+}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ComponentModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ComponentModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ComponentModel.java
Sun Jun 26 10:06:51 2005
@@ -33,164 +33,164 @@
{
static final String PROXY_KEY = "urn:composition:proxy";

- /**
- * Return the deployment type.
- *
- * @return the type
- */
+ /**
+ * Return the deployment type.
+ *
+ * @return the type
+ */
Type getType();

- /**
- * Return the proxy enabled policy for the model. If the system wide
- * proxy enabled is disabled the operation will return false otherwise
the
- * value returned is true unless overriden by the "urn:composition:proxy"
- * attribute.
- *
- * @return the proxy policy
- */
+ /**
+ * Return the proxy enabled policy for the model. If the system wide
+ * proxy enabled is disabled the operation will return false otherwise
the
+ * value returned is true unless overriden by the "urn:composition:proxy"
+ * attribute.
+ *
+ * @return the proxy policy
+ */
boolean getProxyPolicy();

- /**
- * Return the activation policy for the model.
- * @return the activaltion policy
- */
+ /**
+ * Return the activation policy for the model.
+ * @return the activaltion policy
+ */
boolean getActivationPolicy();

- /**
- * Return the collection policy for the model. If a profile
- * does not declare a collection policy, the collection policy
- * declared by the type will be used.
- *
- * @return the collection policy
- * @see net.dpml.meta.info.InfoDescriptor#WEAK
- * @see net.dpml.meta.info.InfoDescriptor#SOFT
- * @see net.dpml.meta.info.InfoDescriptor#HARD
- */
+ /**
+ * Return the collection policy for the model. If a profile
+ * does not declare a collection policy, the collection policy
+ * declared by the type will be used.
+ *
+ * @return the collection policy
+ * @see net.dpml.meta.info.InfoDescriptor#WEAK
+ * @see net.dpml.meta.info.InfoDescriptor#SOFT
+ * @see net.dpml.meta.info.InfoDescriptor#HARD
+ */
int getCollectionPolicy();

- /**
- * Set the collection policy to a supplied value.
- *
- * @param policy the collection policy
- * @see net.dpml.meta.info.InfoDescriptor#WEAK
- * @see net.dpml.meta.info.InfoDescriptor#SOFT
- * @see net.dpml.meta.info.InfoDescriptor#HARD
- * @see net.dpml.meta.info.InfoDescriptor#UNDEFINED
- */
+ /**
+ * Set the collection policy to a supplied value.
+ *
+ * @param policy the collection policy
+ * @see net.dpml.meta.info.InfoDescriptor#WEAK
+ * @see net.dpml.meta.info.InfoDescriptor#SOFT
+ * @see net.dpml.meta.info.InfoDescriptor#HARD
+ * @see net.dpml.meta.info.InfoDescriptor#UNDEFINED
+ */
void setCollectionPolicy( int policy );

- /**
- * Set the activation policy for the model.
- * @param policy the activaltion policy
- */
+ /**
+ * Set the activation policy for the model.
+ * @param policy the activaltion policy
+ */
void setActivationPolicy( boolean policy );

- /**
- * Return the class for the deployable target.
- * @return the class
- */
+ /**
+ * Return the class for the deployable target.
+ * @return the class
+ */
Class getDeploymentClass();

- /**
- * Set the configuration to the supplied value. The supplied
- * configuration will replace the existing configuration.
- *
- * @param config the supplied configuration
- * @throws ModelException
- * @throws IllegalStateException
- */
- void setConfiguration( Configuration config ) throws
IllegalStateException, ModelException;
-
- /**
- * Set the configuration to the supplied value. The supplied
- * configuration may suppliment or replace the existing configuration.
- *
- * @param config the supplied configuration
- * @param policy if TRUE the supplied configuration replaces the current
- * configuration otherwise the resoved configuration shall be layed
above
- * the configuration supplied with the profile which in turn is layer
above
- * the type default configuration (if any)
- * @throws ModelException if the supplied configuraiton was null, or if
the Configuration
- * should been but could not be validated
- * @throws IllegalStateException
- */
+ /**
+ * Set the configuration to the supplied value. The supplied
+ * configuration will replace the existing configuration.
+ *
+ * @param config the supplied configuration
+ * @throws ModelException
+ * @throws IllegalStateException
+ */
+ void setConfiguration( Configuration config )
+ throws IllegalStateException, ModelException;
+
+ /**
+ * Set the configuration to the supplied value. The supplied
+ * configuration may suppliment or replace the existing configuration.
+ *
+ * @param config the supplied configuration
+ * @param policy if TRUE the supplied configuration replaces the current
+ * configuration otherwise the resoved configuration shall be layed
above
+ * the configuration supplied with the profile which in turn is layer
above
+ * the type default configuration (if any)
+ * @throws ModelException if the supplied configuraiton was null, or if
the Configuration
+ * should been but could not be validated
+ * @throws IllegalStateException
+ */
void setConfiguration( Configuration config, boolean policy ) throws
IllegalStateException, ModelException;

- /**
- * Return the configuration to be applied to the component.
- * The implementation returns the current configuration state.
- * If the the component type does not implementation the
- * Configurable interface, the implementation returns null.
- *
- * @return the qualified configuration
- */
+ /**
+ * Return the configuration to be applied to the component.
+ * The implementation returns the current configuration state.
+ * If the the component type does not implementation the
+ * Configurable interface, the implementation returns null.
+ *
+ * @return the qualified configuration
+ */
Configuration getConfiguration();

- /**
- * Test if the component type backing the model is
- * parameterizable.
- *
- * @return TRUE if the component type is parameterizable
- * otherwise FALSE
- */
+ /**
+ * Test if the component type backing the model is
+ * parameterizable.
+ *
+ * @return TRUE if the component type is parameterizable
+ * otherwise FALSE
+ */
boolean isParameterizable();

- /**
- * Set the parameters to the supplied value. The supplied
- * parameters value will replace the existing parameters value.
- *
- * @param parameters the supplied parameters value
- */
+ /**
+ * Set the parameters to the supplied value. The supplied
+ * parameters value will replace the existing parameters value.
+ *
+ * @param parameters the supplied parameters value
+ */
void setParameters( Parameters parameters );

- /**
- * Set the parameters to the supplied value. The supplied
- * parameters value may suppliment or replace the existing
- * parameters value.
- *
- * @param parameters the supplied parameters
- * @param policy if TRUE the supplied parameters replaces the current
- * parameters value otherwise the existing and supplied values
- * are aggregrated
- */
+ /**
+ * Set the parameters to the supplied value. The supplied
+ * parameters value may suppliment or replace the existing
+ * parameters value.
+ *
+ * @param parameters the supplied parameters
+ * @param policy if TRUE the supplied parameters replaces the current
+ * parameters value otherwise the existing and supplied values
+ * are aggregrated
+ */
void setParameters( Parameters parameters, boolean policy );

- /**
- * Return the parameters to be applied to the component.
- * If the the component type does not implementation the
- * Parameterizable interface, the implementation returns null.
- *
- * @return the assigned parameters
- */
+ /**
+ * Return the parameters to be applied to the component.
+ * If the the component type does not implementation the
+ * Parameterizable interface, the implementation returns null.
+ *
+ * @return the assigned parameters
+ */
Parameters getParameters();

- /**
- * Return the context model for this deployment model.
- *
- * @return the context model
- */
+ /**
+ * Return the context model for this deployment model.
+ *
+ * @return the context model
+ */
ContextModel getContextModel();

- /**
- * Return the dependency models for this deployment model.
- *
- * @return the dependency models
- */
+ /**
+ * Return the dependency models for this deployment model.
+ *
+ * @return the dependency models
+ */
DependencyModel[] getDependencyModels();

- /**
- * Return a dependency model for a supplied descriptor or null
- * if no match found.
- *
- * @return the dependency model
- */
+ /**
+ * Return a dependency model for a supplied descriptor or null
+ * if no match found.
+ *
+ * @return the dependency model
+ */
DependencyModel getDependencyModel( DependencyDescriptor dependency );

- /**
- * Return the set of services produced by the model as a array of classes.
- *
- * @return the service classes
- */
+ /**
+ * Return the set of services produced by the model as a array of
classes.
+ *
+ * @return the service classes
+ */
Class[] getInterfaces();
-
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ServiceRepository.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ServiceRepository.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/api/src/main/net/dpml/composition/model/ServiceRepository.java
Sun Jun 26 10:06:51 2005
@@ -56,5 +56,4 @@
*/
Service getService( ReferenceDescriptor reference )
throws UnknownServiceException ;
-
}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/SerializedContainmentProfileCreator.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/SerializedContainmentProfileCreator.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/data/builder/SerializedContainmentProfileCreator.java
Sun Jun 26 10:06:51 2005
@@ -22,6 +22,7 @@

import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.io.IOException;

/**
* Create {@link ContainmentProfile} from stream made up of
@@ -38,13 +39,13 @@
*
* @param inputStream the stream that the resource is loaded from
* @return the containment profile
- * @exception Exception if a error occurs during profile creation
+ * @exception IOException if a error occurs during profile creation
*/
public ContainmentProfile createContainmentProfile( InputStream
inputStream )
- throws Exception
+ throws IOException, ClassNotFoundException
{
final ObjectInputStream ois = new ObjectInputStream( inputStream );
- return (ContainmentProfile)ois.readObject();
+ return (ContainmentProfile) ois.readObject();
}

}

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
Sun Jun 26 10:06:51 2005
@@ -27,6 +27,8 @@
import net.dpml.composition.provider.CompositionRuntimeException;
import net.dpml.composition.provider.ContainmentContext;

+import java.io.Serializable;
+
/**
* Containment model implmentation within which composite models are
aggregated
* as a part of a containment deployment model.
@@ -35,9 +37,11 @@
* @version $Id$
*/
public class DefaultCompositionController extends DefaultContainmentModel
- implements Startable
+ implements Startable, Serializable
{
- static private final String[] STATE_NAMES =
+ static final long serialVersionUID = 1L;
+
+ static private final String[] STATE_NAMES =
{
"state: initializing",
"state: initialized",

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
Sun Jun 26 10:06:51 2005
@@ -18,7 +18,7 @@

package net.dpml.composition.model.impl;

-import net.dpml.composition.data.builder.CompositionContentHandlerFactory;
+import net.dpml.composition.StuffNeeded;
import net.dpml.composition.model.ContainmentModel;
import net.dpml.composition.model.DeploymentModel;
import net.dpml.composition.model.ModelException;
@@ -28,7 +28,6 @@
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;
@@ -49,7 +48,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLConnection;
import java.util.Map;

/**
@@ -76,35 +74,33 @@
//--------------------------------------------------------------

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

//--------------------------------------------------------------
// constructor
//--------------------------------------------------------------

- /**
+ /**
* Creation of a new system context.
*
* @param args the command line arguments
*/
- public DefaultCompositionFactory( Logger logger, String[] args,
BundleContext osgi )
+ public DefaultCompositionFactory( Logger logger, BundleContext osgi,
String[] args )
throws ParseException
{
- m_OsgiContext = osgi;
m_logger = logger;
+ m_OsgiContext = osgi;
Options options = buildCommandLineOptions();
CommandLineParser parser = new GnuParser();
m_line = parser.parse( options, args, false );
-
- setupContentHandler();
}

//--------------------------------------------------------------
// CompositionFactory
//--------------------------------------------------------------

- /**
+ /**
* Return the default criteria map.
*
* @return a new instance of the default factory criteria
@@ -144,22 +140,24 @@
return criteria;
}

- /**
- * Creation of a new root containment model.
- * @return the root container
- */
- public ContainmentModel createContainmentModel() throws
CompositionException
+ /**
+ * Creation of a new root containment model.
+ * @return the root container
+ */
+ public ContainmentModel createContainmentModel()
+ throws CompositionException
{
CompositionCriteria criteria = createCompositionCriteria();
return createContainmentModel( criteria );
}

- /**
- * Creation of a new root containment model.
- * @param map the composition criteria
- * @return the root container
- */
- public ContainmentModel createContainmentModel( Map map ) throws
CompositionException
+ /**
+ * Creation of a new root containment model.
+ * @param map the composition criteria
+ * @return the root container
+ */
+ public ContainmentModel createContainmentModel( Map map )
+ throws CompositionException
{
CompositionCriteria criteria = buildCompositionCriteria( map );

@@ -230,7 +228,7 @@
// create the model factory and return the root model
//

- ModelFactory modelFactory = new DefaultModelFactory( context,
uri, kernel, deployment, overrides, m_OsgiContext );
+ ModelFactory modelFactory = new DefaultModelFactory( context,
uri, kernel, deployment, overrides );
return modelFactory.getRootModel();
}
catch( CompositionException ce )
@@ -267,31 +265,31 @@
// Factory
//--------------------------------------------------------------

- /**
- * Return the default criteria map. The implementation returns a map
- * preloaded with defaults based on declared properties and command line
- * arguments declared to the factory.
- *
- * @return a new instance of the default factory criteria
- */
+ /**
+ * Return the default criteria map. The implementation returns a map
+ * preloaded with defaults based on declared properties and command line
+ * arguments declared to the factory.
+ *
+ * @return a new instance of the default factory criteria
+ */
public Map createDefaultCriteria()
{
return createCompositionCriteria();
}

- /**
- * Creation of a new composition context.
- * @return the composition context instance
- */
+ /**
+ * Creation of a new composition context.
+ * @return the composition context instance
+ */
public Object create() throws Exception
{
return createContainmentModel();
}

- /**
- * Creation of a new composition context.
- * @return the composition context instance
- */
+ /**
+ * Creation of a new composition context.
+ * @return the composition context instance
+ */
public Object create( Map map ) throws Exception
{
return createContainmentModel( map );
@@ -559,10 +557,4 @@
{
buffer.append( "\n" + message );
}
-
- private void setupContentHandler()
- {
- CompositionContentHandlerFactory factory = new
CompositionContentHandlerFactory();
- URLConnection.setContentHandlerFactory( 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
Sun Jun 26 10:06:51 2005
@@ -89,18 +89,13 @@
// static
//--------------------------------------------------------------

- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultContainmentModel.class );
+ private static final Resources REZ =
ResourceManager.getPackageResources( DefaultContainmentModel.class );

- private static final ContainmentProfileBuilder BUILDER =
- new ContainmentProfileBuilder();
+ private static final ContainmentProfileBuilder BUILDER = new
ContainmentProfileBuilder();

- private static final XMLContainmentProfileCreator CREATOR =
- new XMLContainmentProfileCreator();
+ private static final XMLContainmentProfileCreator CREATOR = new
XMLContainmentProfileCreator();

- private static final XMLTargetsCreator TARGETS =
- new XMLTargetsCreator();
+ private static final XMLTargetsCreator TARGETS = new XMLTargetsCreator();

//--------------------------------------------------------------
// immutable state
@@ -143,9 +138,7 @@
}
else
{
- m_partition = context.getPartitionName()
- + context.getName()
- + DeploymentModel.SEPARATOR;
+ m_partition = context.getPartitionName() + context.getName() +
DeploymentModel.SEPARATOR;
}

//
@@ -164,8 +157,7 @@
// setup the service export parameters
//

- DefaultContainmentModelExportHelper helper =
- new DefaultContainmentModelExportHelper( m_context, this );
+ DefaultContainmentModelExportHelper helper = new
DefaultContainmentModelExportHelper( m_context, this );
m_services = helper.createServiceExport();
}

@@ -1204,6 +1196,8 @@
{
URL jarURL = convertToJarURL( url );
blockURL = new URL( jarURL, "/BLOCK-INF/block.xml" );
+
+ // TODO: Remove the usage of the BUILDER and instead retrieve
the Content from the URL.
InputStream stream = blockURL.openStream();
ContainmentProfile profile = BUILDER.createContainmentProfile(
stream );
String message = "including composite block: " +
blockURL.toString();
@@ -1240,6 +1234,7 @@
{
URL blockURL = new URL( url, "/BLOCK-INF/block.xml" );
InputStream stream = blockURL.openStream();
+ // TODO: Remove the usage of the BUILDER and instead retrieve
the Content from the URL.
ContainmentProfile profile = BUILDER.createContainmentProfile(
stream );
String message = "including composite block: " +
blockURL.toString();
getLogger().debug( message );
@@ -1412,8 +1407,7 @@
{
try
{
- DefaultConfigurationBuilder builder =
- new DefaultConfigurationBuilder();
+ DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder();
Configuration config = builder.build( url.toString() );
return TARGETS.createTargets( config ).getTargets();
}

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
Sun Jun 26 10:06:51 2005
@@ -44,7 +44,6 @@
import net.dpml.system.Factory;
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;

@@ -100,9 +99,7 @@
* @param context the composition context
* @param uri the URI to the runtime artifact
*/
- DefaultModelFactory(
- final CompositionContext context, URI uri,
- URL kernel, URL[] deployment, URL overrides, BundleContext osgi )
+ DefaultModelFactory( CompositionContext context, URI uri, URL kernel,
URL[] deployment, URL overrides )
throws ModelException, NullArgumentException
{
if( context == null )
@@ -116,7 +113,7 @@
m_context = context;
m_logger = new ConsoleLogger();
Configuration config = getKernelConfiguration( kernel );
- m_runtime = createRuntime( uri, osgi );
+ m_runtime = createRuntime( uri );

//
// create the root container
@@ -405,7 +402,7 @@
/**
* Create a runtime using the supplied artifact. The implementation
*/
- private Runtime createRuntime( URI uri, BundleContext osgiContext )
+ private Runtime createRuntime( URI uri )
throws CompositionException
{
if( null == uri )
@@ -418,7 +415,7 @@
{
Repository repository = new StandardLoader();
ClassLoader classloader =
CompositionContext.class.getClassLoader();
- Object plugin = repository.getPlugin( classloader, uri, new
Object[]{ osgiContext } );
+ Object plugin = repository.getPlugin( classloader, uri, new
Object[]{ } );
if( plugin instanceof Factory )
{
object = ( (Factory) plugin ).create();

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultServiceRepository.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultServiceRepository.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultServiceRepository.java
Sun Jun 26 10:06:51 2005
@@ -36,7 +36,8 @@
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id$
*/
-public class DefaultServiceRepository implements ServiceRepository
+public class DefaultServiceRepository
+ implements ServiceRepository
{
//==============================================================
// immutable state
@@ -50,7 +51,7 @@
/**
* The parent service manager (may be null)
*/
- private final ServiceRepository m_parent;
+ private ServiceRepository m_parent;

/**
* List of service entries.
@@ -67,8 +68,8 @@
* @param services the list of available services
* @exception NullPointerException if the services list is null
*/
- DefaultServiceRepository(
- final Logger logger, final List services ) throws NullPointerException
+ DefaultServiceRepository( Logger logger, List services )
+ throws NullPointerException
{
this( logger, null, services );
}
@@ -80,8 +81,7 @@
* @param services the list of available services
* @exception NullArgumentException if the services list is null
*/
- DefaultServiceRepository( final Logger logger, final ServiceRepository
parent,
- final List services )
+ DefaultServiceRepository( Logger logger, ServiceRepository parent, List
services )
throws NullArgumentException
{
if( services == null )
@@ -108,8 +108,8 @@
* @return the service matching the supplied classname and version.
* @exception UnknownServiceException if a matching service cannot be
found
*/
- public Service getService( final String classname, final Version version
)
- throws UnknownServiceException
+ public Service getService( String classname, Version version )
+ throws UnknownServiceException
{
return getService( new ReferenceDescriptor( classname, version ) );
}
@@ -124,8 +124,8 @@
* @return the service matching the supplied descriptor.
* @exception UnknownServiceException if a matching service cannot be
found
*/
- public Service getService( final ReferenceDescriptor reference )
- throws UnknownServiceException
+ public Service getService( ReferenceDescriptor reference )
+ throws UnknownServiceException
{
Service service = getLocalService( reference );
if( service == null )
@@ -143,7 +143,7 @@
return service;
}

- private Service getLocalService( final ReferenceDescriptor reference )
+ private Service getLocalService( ReferenceDescriptor reference )
{
Iterator iterator = m_services.iterator();
while( iterator.hasNext() )

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 Sun Jun 26
10:06:51 2005
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1"?>

<index key="dpml-metro">
+ <import uri="artifact:module:dpml/transit/dpml-transit#2912"/>

- <import uri="artifact:module:dpml/transit/dpml-transit#2798"/>
-
- <!--
- Metro Modules
- -->
+ <!-- Metro Modules -->

<project file="module.xml">
<info>
@@ -216,34 +213,22 @@
</types>
</info>
<dependencies>
- <include key="dpml-composition-api" tag="spi"/>
- <include key="dpml-logging-api" tag="api"/>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-context-api" tag="api"/>
- <include key="dpml-transit-main" tag="api"/>
+ <include key="dpml-composition-api"/>
+ <include key="dpml-composition-impl"/>
+ <include key="dpml-composition-spi"/>
+ <include key="dpml-configuration-impl" />
+ <include key="dpml-logging-api"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-transit-main"/>
<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-composition-impl" build="false"/>
<include key="commons-cli"/>
- </dependencies>
- </project>
-
- <project basedir="osgi">
- <info>
- <group>dpml/metro/osgi</group>
- <name>dpml-metro-osgi</name>
- <types>
- <type>jar</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-composition-api"/>
- <include key="dpml-transit-main"/>
- <include key="dpml-system-api"/>
<include key="osgi" runtime="false" />
+ <include key="console_all" runtime="false" />
</dependencies>
</project>

@@ -293,6 +278,7 @@
<include key="dpml-logging-api"/>
<include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
<include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
+ <include key="osgi" runtime="false" />
</dependencies>
</project>

@@ -340,7 +326,7 @@
<include key="dpml-util-cli"/>
<include key="dpml-activation-impl" build="false"/>
<include key="dpml-test-playground" build="false"/>
- <include key="osgi"/>
+ <include key="osgi" runtime="false" />
</dependencies>
</project>

@@ -370,19 +356,6 @@
</dependencies>
</project>

- <!-- Utitlities -->
-
- <project basedir="util/defaults">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-util-defaults</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-transit-main"/>
- </dependencies>
- </project>
-
<!-- System -->

<project basedir="system/api">
@@ -398,9 +371,7 @@
</dependencies>
</project>

- <!--
- DPML Activation.
- -->
+ <!-- DPML Activation. -->

<project basedir="activation/api">
<info>
@@ -449,9 +420,7 @@
</dependencies>
</project>

- <!--
- Metro Test.
- -->
+ <!-- Metro Test. -->

<project basedir="testing/dynamics">
<info>
@@ -695,4 +664,12 @@
</info>
</resource>

+ <resource>
+ <info>
+ <name>console_all</name>
+ <version>1.0.0</version>
+ <group>osgi/knopflerfish/console</group>
+ </info>
+ </resource>
+
</index>

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 Sun
Jun 26 10:06:51 2005
@@ -17,8 +17,59 @@

</target>

+ <target name="build" depends="standard.build">
+ <mkdir dir="target/manifest/" />
+ <x:property name="version" feature="version" />
+ <tstamp/>
+ <x:path mode="runtime" id="runtime-path" />
+ <pathconvert
+ dirsep="/"
+ pathsep=","
+ property="classpath"
+ refid="runtime-path"
+ >
+ <mapper type="flatten"/>
+ </pathconvert>
+ <manifest file="target/manifest/MANIFEST.MF" >
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Specification-Title" value=""/>
+ <attribute name="Specification-Version" value="1.0"/>
+ <attribute name="Specification-Vendor" value="Digital Product Meta
Library"/>
+ <attribute name="Implementation-Title" value="Metro OSGi Bundle"/>
+ <attribute name="Implementation-Version" value="${version} ${DSTAMP}"/>
+ <attribute name="Implementation-Vendor" value="Digital Product Meta
Library"/>
+
+ <attribute name="Bundle-Activator"
value="net.dpml.metro.MetroBundleActivator" />
+ <attribute name="Bundle-Category" value="container, platform"/>
+ <attribute name="Bundle-ClassPath" value=".,${classpath}"/>
+ <attribute name="Bundle-ContactAddress"
value="http://www.dpml.net/about"/>
+ <attribute name="Bundle-Copyright" value="Copyright 2005 Digital
Product Meta Library"/>
+ <attribute name="Bundle-Description" value="Metro Runtime Platform"/>
+ <attribute name="Bundle-DocURL"
value="http://www.dpml.net/metro/latest/index.html"/>
+ <attribute name="Bundle-Name" value="Metro"/>
+<!--
+ <attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE"/>
+-->
+ <attribute name="Bundle-UpdateLocation"
value="http://repository.dpml.net/classic/dpml/metro/tools/jars/dpml-metro-main.jar"/>
+ <attribute name="Bundle-Vendor" value="DPML"/>
+ <attribute name="Bundle-Version" value="${version}"/>
+ <attribute name="Import-Package" value="org.osgi.service.log,
org.osgi.service.cm"/>
+ </manifest>
+ </target>
+
<target name="package" depends="standard.package">
- <x:export class="net.dpml.metro.Metro"/>
+ <x:replicate todir="target/bundle-content/" flatten="true"/>
+ <x:property name="jarfilename" feature="filename" />
+ <x:property name="transitdir" feature="spec" key="dpml-transit-main" />
+ <jar destfile="target/deliverables/jars/${jarfilename}"
+ manifest="target/manifest/MANIFEST.MF" >
+ <fileset dir="target/classes/" >
+ <include name="**" />
+ </fileset>
+ <fileset dir="target/bundle-content/" >
+ <include name="**/*.jar" />
+ </fileset>
+ </jar>
</target>

<target name="install" depends="update,standard.install"/>

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/ArtifactStreamHandlerService.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/ArtifactStreamHandlerService.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,37 @@
+package net.dpml.metro;
+
+import net.dpml.transit.SecuredTransitContext;
+import net.dpml.transit.artifact.ArtifactURLConnection;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.url.AbstractURLStreamHandlerService;
+import org.osgi.service.url.URLConstants;
+import org.osgi.service.url.URLStreamHandlerService;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Hashtable;
+
+public class ArtifactStreamHandlerService extends
AbstractURLStreamHandlerService
+{
+ private ServiceRegistration m_Registration;
+
+ public ArtifactStreamHandlerService( BundleContext context )
+ {
+ Hashtable properties = new Hashtable();
+ properties.put( URLConstants.URL_HANDLER_PROTOCOL, new String[] {
"artifact" } );
+ m_Registration = context.registerService(
URLStreamHandlerService.class.getName(), this, properties );
+ }
+
+ public URLConnection openConnection( URL url )
+ throws IOException
+ {
+ return new ArtifactURLConnection( url,
SecuredTransitContext.create() );
+ }
+
+ public void dispose()
+ {
+ m_Registration.unregister();
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/ContentHandlerService.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/ContentHandlerService.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,169 @@
+package net.dpml.metro;
+
+import net.dpml.composition.data.ContainmentProfile;
+import net.dpml.composition.data.builder.SerializedContainmentProfileCreator;
+import net.dpml.composition.data.builder.XMLContainmentProfileCreator;
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.impl.DefaultConfigurationBuilder;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.url.URLConstants;
+import org.xml.sax.InputSource;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StreamCorruptedException;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+import java.util.Hashtable;
+
+public class ContentHandlerService extends ContentHandler
+{
+ private ServiceRegistration m_Registration;
+
+ public ContentHandlerService( BundleContext context )
+ {
+ Hashtable properties = new Hashtable();
+ properties.put( URLConstants.URL_CONTENT_MIMETYPE, new String[] {
"text/x-dpml-block" } );
+ m_Registration = context.registerService(
ContentHandler.class.getName(), this, properties );
+ }
+
+ public void dispose()
+ {
+ m_Registration.unregister();
+ }
+
+ public Object getContent( URLConnection connection ) throws IOException
+ {
+ InputStream stream = connection.getInputStream();
+ try
+ {
+ return createContainmentProfile( stream );
+ }
+ catch( RuntimeException e )
+ {
+ String error = "Error occured while attempting to build a
containment profile.";
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
+ }
+ catch( Exception 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
+ {
+ for( int i=0; i<classes.length; i++ )
+ {
+ Class c = classes[i];
+ if( ContainmentProfile.class.isAssignableFrom( c ) )
+ {
+ try
+ {
+ InputStream stream = connection.getInputStream();
+ return createContainmentProfile( stream );
+ }
+ catch( IOException e )
+ {
+ String error = "Error occured while attempting to build
a containment profile.";
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
+ }
+ catch( RuntimeException e )
+ {
+ String error = "Error occured while attempting to build
a containment profile.";
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
+ }
+ catch( Exception e )
+ {
+ String error = "Error occured while attempting to build
a containment profile.";
+ IOException ioException = new IOException( error );
+ ioException.initCause( e );
+ throw ioException;
+ }
+ }
+ }
+ return null;
+ }
+
+
//------------------------------------------------------------------------
+ // ContainmentProfileCreator
+
//------------------------------------------------------------------------
+
+ /**
+ * 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
+ {
+ // we backup the inputstream content in a bytearray
+ byte[] buffer = new byte[1024];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for( int read = 0; read >= 0; )
+ {
+ baos.write( buffer, 0, read );
+ read = inputStream.read( buffer );
+ }
+
+ inputStream = new ByteArrayInputStream( baos.toByteArray() );
+
+ try
+ {
+ ContainmentProfile profile = buildFromSerDescriptor(
inputStream);
+ if( null != profile )
+ {
+ return profile;
+ }
+ }
+ catch( StreamCorruptedException e )
+ {
+ inputStream = new ByteArrayInputStream( baos.toByteArray() );
+ }
+
+ return buildFromXMLDescriptor( inputStream );
+ }
+
+ /**
+ * Build ContainmentProfile from the serialized format.
+ *
+ * @throws IOException if an underlying I/O problem occurred.
+ * @throws ClassNotFoundException if the stream contains references to
classes outside the classloader's reach.
+ */
+ private ContainmentProfile buildFromSerDescriptor( InputStream
inputStream )
+ throws IOException, ClassNotFoundException
+ {
+ SerializedContainmentProfileCreator serial = new
SerializedContainmentProfileCreator();
+ return serial.createContainmentProfile( inputStream );
+ }
+
+ /**
+ * Build ContainmentProfile from an XML descriptor.
+ * @param stream the input stream
+ * @throws Exception if an error occurs
+ */
+ private ContainmentProfile buildFromXMLDescriptor( InputStream stream )
+ throws Exception
+ {
+ XMLContainmentProfileCreator xml = new XMLContainmentProfileCreator(
);
+
+ DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder();
+ final InputSource source = new InputSource( stream );
+ Configuration config = builder.build( source );
+ return xml.createContainmentProfile( config );
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/MetroBundleActivator.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/MetroBundleActivator.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,310 @@
+/*
+ * 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.metro;
+
+import net.dpml.activity.Startable;
+import net.dpml.composition.StuffNeeded;
+import net.dpml.composition.SystemContext;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.lang.NullArgumentException;
+import net.dpml.logging.Logger;
+import net.dpml.system.Factory;
+import net.dpml.transit.Transit;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+import org.knopflerfish.service.console.CommandGroup;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+import java.util.Hashtable;
+
+
+/**
+ * The metro system provides support for the establishment of a composition
+ * model based on a root container defintion, a series of initial container
+ * deployment targets, and configuration override management. This class
+ * deals with the parameterization of a series of stacked plugins based on
+ * supplied command line arguments.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ * @version $Id: MetroBundleActivator.java 2895 2005-06-20 11:13:39Z
niclas AT hedhman.org $
+ */
+public class MetroBundleActivator
+ implements BundleActivator
+{
+ private static String TARGET_URI_KEY = "dpml.metro.main.artifact";
+ private static String DPML_PROPERTIES = "dpml.properties";
+
+ private static final String LINE =
"-----------------------------------\n";
+ private static String TARGET_DEFAULT_URI =
"@COMPOSITION-IMPL-ARTIFACT-URI@";
+
+ private Object m_plugin;
+ private LogService m_LogService;
+ private SystemContext m_SystemContext;
+ private BundleContext m_BundleContext;
+
+ private ArtifactStreamHandlerService m_ArtifactHandlerService;
+ private MetroCommands m_Commands;
+ private ServiceRegistration m_CommandsRegistration;
+
+ //
------------------------------------------------------------------------
+ // constructors
+ //
------------------------------------------------------------------------
+
+ /**
+ * Creation of a new metro instance using a supplied bootstrap repository
+ * plugin descriptor and commandline arguments.
+ *
+ * @exception NullArgumentException if either of the debug, repository,
descriptor
+ * or args argument is null.
+ */
+ public MetroBundleActivator()
+ {
+ }
+
+ private void pack( StringBuffer buffer, String key, Object value )
+ {
+ if( null == value )
+ {
+ pack( buffer, "${" + key + "} : " );
+ }
+ else
+ {
+ pack( buffer, "${" + key + "} : " + value );
+ }
+ }
+
+ private void pack( StringBuffer buffer, String message )
+ {
+ buffer.append( "\n" + message );
+ }
+
+ private ClassLoader getRootClassLoader()
+ {
+ return MetroBundleActivator.class.getClassLoader();
+ }
+
+ private Object loadPlugin( ClassLoader classloader, URI uri, Logger
logger )
+ throws Exception
+ {
+ Repository repository = new StandardLoader();
+ Object[] params = new Object[]{ logger, m_BundleContext };
+ Object object = repository.getPlugin( classloader, uri, params );
+ if( object instanceof Factory )
+ {
+ return ((Factory)object).create();
+ }
+ else
+ {
+ return object;
+ }
+ }
+
+ private URI getMainArtifact( Properties properties )
+ throws URISyntaxException
+ {
+ String spec = properties.getProperty( TARGET_URI_KEY );
+ if( null != spec )
+ {
+ return Artifact.createArtifact( spec ).toURI();
+ }
+ else
+ {
+ return Artifact.createArtifact( TARGET_DEFAULT_URI ).toURI();
+ }
+ }
+
+ /**
+ * Load all properties file from the standard locations. Standard
+ * locations in priority order include:
+ * <ul>
+ * <li>${user.dir}/dpml.properties</li>
+ * <li>${user.home}/dpml.properties</li>
+ * <li>${dpml.home}/dpml.properties</li>
+ * </ul>
+ * @return the aggregated properties
+ */
+ private static Properties getInitialProperties()
+ throws IOException
+ {
+ File home = Transit.DPML_HOME;
+ Properties properties = getStaticProperties();
+ File homePreferenceFile = new File( home, DPML_PROPERTIES );
+ loadFile( properties, homePreferenceFile );
+
+ //
+ // get ${user.home}/[key].properties
+ //
+
+ File user = getUserDirectory();
+ File userPreferenceFile = new File( user, DPML_PROPERTIES );
+ loadFile( properties, userPreferenceFile );
+
+ //
+ // get ${user.dir}/[key].properties
+ //
+
+ File dir = getWorkingDirectory();
+ File dirPreferenceFile = new File( dir, DPML_PROPERTIES );
+ loadFile( properties, dirPreferenceFile );
+
+ properties.setProperty( Transit.HOME_KEY, home.toString() );
+ return properties;
+ }
+
+ /**
+ * Read in a static properties resource relative to a supplied class
+ * and path.
+ *
+ * @return the static properties
+ * @exception IllegalStateException if the path is unresolvable
+ */
+ private static Properties getStaticProperties()
+ throws IOException
+ {
+ Properties bootstrap = new Properties();
+ InputStream input =
+ MetroBundleActivator.class.getClassLoader().getResourceAsStream(
DPML_PROPERTIES );
+ if( input != null )
+ {
+ bootstrap.load( input );
+ }
+ return bootstrap;
+ }
+
+ private static File getUserDirectory()
+ {
+ return new File( System.getProperty( "user.home" ) );
+ }
+
+ private static File getWorkingDirectory()
+ {
+ return new File( System.getProperty( "user.dir" ) );
+ }
+
+ private static void loadFile( Properties properties, File file )
+ throws IOException
+ {
+ if( file.exists() )
+ {
+ InputStream input = new FileInputStream( file );
+ try
+ {
+ properties.load( input );
+ } finally
+ {
+ input.close();
+ }
+ }
+ }
+
+ public void start( BundleContext bundleContext )
+ throws Exception
+ {
+ m_BundleContext = bundleContext;
+ m_SystemContext = new SystemContext();
+ m_SystemContext.start( bundleContext );
+ StuffNeeded.setSystemContext( m_SystemContext );
+ m_ArtifactHandlerService = new ArtifactStreamHandlerService(
bundleContext );
+ m_LogService = findLogService( bundleContext );
+ m_LogService.log( LogService.LOG_INFO, "Starting the
MetroBundleActivator Bundle.");
+
+ Properties properties = getInitialProperties();
+ Logger logger = new OsgiBridgeLogger( m_LogService );
+
+ URI target = getMainArtifact( properties );
+ m_LogService.log( LogService.LOG_DEBUG, "loading plugin: [" + target
+ "]." );
+
+ ClassLoader classloader = getRootClassLoader();
+ m_plugin = loadPlugin( classloader, target, logger );
+
+ StringBuffer buffer = new StringBuffer( "MetroBundleActivator
Context" );
+ buffer.append( LINE );
+ pack( buffer, TARGET_URI_KEY, target.toString() );
+ buffer.append( LINE );
+
+ if( StuffNeeded.getInfoMode() )
+ {
+ m_LogService.log( LogService.LOG_INFO, buffer.toString() );
+ }
+ else if( StuffNeeded.getDebugMode() )
+ {
+ m_LogService.log( LogService.LOG_INFO, buffer.toString() );
+ }
+ if( m_plugin instanceof Startable )
+ {
+ Startable startable = (Startable) m_plugin;
+ startable.start();
+ m_LogService.log( LogService.LOG_DEBUG, "plugin startup
completed" );
+ }
+ else
+ {
+ m_LogService.log( LogService.LOG_DEBUG, "plugin established" );
+ }
+ if( m_plugin instanceof ContainmentModel )
+ {
+ ContainmentModel root = (ContainmentModel) m_plugin;
+ m_Commands = new MetroCommands( root );
+ Hashtable props = new Hashtable();
+ props.put("groupName", m_Commands.getGroupName());
+ m_CommandsRegistration = bundleContext.registerService(
CommandGroup.class.getName(), m_Commands, props);
+ }
+ m_LogService.log( LogService.LOG_INFO, "MetroBundleActivator Bundle
started.");
+ }
+
+ public void stop( BundleContext bundleContext )
+ throws Exception
+ {
+ m_LogService.log( LogService.LOG_INFO, "Stopping the
MetroBundleActivator Bundle.");
+ if( m_plugin instanceof Startable )
+ {
+ m_LogService.log( LogService.LOG_DEBUG, "Stopping the
MetroBundleActivator Bundle.");
+ Startable startable = (Startable) m_plugin;
+ startable.stop();
+ }
+ if( m_Commands != null )
+ {
+ m_Commands.dispose();
+ }
+ if( m_CommandsRegistration != null )
+ {
+ m_CommandsRegistration.unregister();
+ }
+ m_LogService.log( LogService.LOG_INFO, "MetroBundleActivator Bundle
stopped.");
+ m_ArtifactHandlerService.dispose();
+ }
+
+ private LogService findLogService( BundleContext context )
+ {
+ ServiceReference reference = context.getServiceReference(
"org.osgi.service.log.LogService" );
+ LogService logService = (LogService) context.getService( reference );
+ return logService;
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/MetroCommands.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/MetroCommands.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,129 @@
+package net.dpml.metro;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.metro.commands.CcCommand;
+import net.dpml.metro.commands.DeployCommand;
+import net.dpml.metro.commands.ListCommand;
+import net.dpml.metro.commands.ShowCommand;
+import net.dpml.metro.commands.UndeployCommand;
+import org.knopflerfish.service.console.CommandGroupAdapter;
+import org.knopflerfish.service.console.Session;
+
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.Dictionary;
+
+public class MetroCommands extends CommandGroupAdapter
+{
+ private ContainmentModel m_CurrentContainer;
+ private CcCommand m_Cc;
+ private ShowCommand m_Show;
+ private DeployCommand m_Deploy;
+ private UndeployCommand m_Undeploy;
+ private ListCommand m_List;
+
+ public MetroCommands( ContainmentModel root )
+ {
+ super( "metro", "MetroBundleActivator Commands" );
+ m_CurrentContainer = root;
+ m_Cc = new CcCommand();
+ m_Show = new ShowCommand();
+ m_Deploy = new DeployCommand();
+ m_Undeploy = new UndeployCommand();
+ m_List = new ListCommand();
+ }
+
+ public final static String USAGE_SHOW = "[<selection>] ...";
+ public final static String [] HELP_SHOW = new String [] {
+ "Prints out the details of one or more <selection> models.",
+ "<selection> One or many deployment models can be given as",
+ " argument(s) and the deployment models inside these",
+ " will be listed."
+ };
+
+ public int cmdShow( Dictionary opts, Reader in, PrintWriter output,
Session session )
+ {
+ return m_Show.execute( m_CurrentContainer, opts, in, output, session
);
+ }
+
+ public final static String USAGE_LIST = "[<selection>] ...";
+ public final static String [] HELP_LIST = new String [] {
+ "List the deployment model(s) in the <selection>.",
+ "<selection> If not specified, current container is used.",
+ " One or many deployment models can be given as",
+ " argument(s) and the deployment models inside these",
+ " will be listed."
+ };
+
+ public int cmdList( Dictionary opts, Reader in, PrintWriter output,
Session session )
+ {
+ return m_List.execute( m_CurrentContainer, opts, in, output, session
);
+ }
+
+ public final static String USAGE_CC = "<path>";
+ public final static String [] HELP_CC = new String [] {
+ "Changes the Current Container to the container in <path>.",
+ "<path> The absolute path, or the path relative to the current",
+ " container, that we should make the Current Container"
+ };
+
+ public int cmdCc( Dictionary opts, Reader in, PrintWriter output,
Session session )
+ {
+ ContainmentModel newContainer = m_Cc.execute( m_CurrentContainer,
opts, in, output, session );
+ if( newContainer == null )
+ {
+ return 1;
+ }
+ m_CurrentContainer = newContainer;
+ return 0;
+ }
+
+ public final static String USAGE_DEPLOY = "<block-url> [<destination>]
[<targets-url>] ";
+ public final static String [] HELP_DEPLOY = new String [] {
+ "Deploys the block located at the <block-url> into the
<destination>,",
+ "with an optional target overrides located at the <targets-url>.",
+ "<block-url> The URL of the block. Typically an artifact: URL.",
+ "<destination> The absolute path, or the path relative to the
current",
+ " container, where the block should be deployed. This
must be a",
+ " ContainmentModel.",
+ "<targets-url> The URL where the targets override should be
retrieved from."
+ };
+
+ public int cmdDeploy( Dictionary opts, Reader in, PrintWriter output,
Session session )
+ {
+ ContainmentModel newContainer = m_Deploy.execute(
m_CurrentContainer, opts, in, output, session );
+ if( newContainer == null )
+ {
+ return 1;
+ }
+ m_CurrentContainer = newContainer;
+ return 0;
+ }
+
+ public final static String USAGE_UNDEPLOY = "<path>";
+ public final static String [] HELP_UNDEPLOY = new String []
+ {
+ "Undeploys the container located at the <path>.",
+ "<path> The absolute path, or the path relative to the current",
+ " container, of the container to be undeployed from the
model.",
+ " The model will first be decommissioned."
+ };
+
+ public int cmdUndeploy( Dictionary opts, Reader in, PrintWriter output,
Session session )
+ {
+ ContainmentModel newContainer = m_Undeploy.execute(
m_CurrentContainer, opts, in, output, session );
+ if( newContainer == null )
+ {
+ return 1;
+ }
+ m_CurrentContainer = newContainer;
+ return 0;
+ }
+
+ /** Called when the Bundle is shutdown, by the MetroBundleActivator
BundleActivator.
+ *
+ */
+ public void dispose()
+ {
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/OsgiBridgeLogger.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/OsgiBridgeLogger.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,96 @@
+package net.dpml.metro;
+
+import net.dpml.logging.Logger;
+import org.osgi.service.log.LogService;
+
+public class OsgiBridgeLogger
+ implements Logger
+{
+
+ private LogService m_Logger;
+
+ public OsgiBridgeLogger( LogService service )
+ {
+ m_Logger = service;
+ }
+
+ public void debug( String message )
+ {
+ m_Logger.log( LogService.LOG_DEBUG, message );
+ }
+
+ public void debug( String message, Throwable throwable )
+ {
+ m_Logger.log( LogService.LOG_DEBUG, message, throwable );
+ }
+
+ public boolean isDebugEnabled()
+ {
+ return true;
+ }
+
+ public void info( String message )
+ {
+ m_Logger.log( LogService.LOG_INFO, message );
+ }
+
+ public void info( String message, Throwable throwable )
+ {
+ m_Logger.log( LogService.LOG_INFO, message, throwable );
+ }
+
+ public boolean isInfoEnabled()
+ {
+ return true;
+ }
+
+ public void warn( String message )
+ {
+ m_Logger.log( LogService.LOG_WARNING, message );
+ }
+
+ public void warn( String message, Throwable throwable )
+ {
+ m_Logger.log( LogService.LOG_WARNING, message, throwable );
+ }
+
+ public boolean isWarnEnabled()
+ {
+ return true;
+ }
+
+ public void error( String message )
+ {
+ m_Logger.log( LogService.LOG_ERROR, message );
+ }
+
+ public void error( String message, Throwable throwable )
+ {
+ m_Logger.log( LogService.LOG_ERROR, message, throwable );
+ }
+
+ public boolean isErrorEnabled()
+ {
+ return true;
+ }
+
+ public void fatalError( String message )
+ {
+ m_Logger.log( LogService.LOG_ERROR, message );
+ }
+
+ public void fatalError( String message, Throwable throwable )
+ {
+ m_Logger.log( LogService.LOG_ERROR, message, throwable );
+ }
+
+ public boolean isFatalErrorEnabled()
+ {
+ return true;
+ }
+
+ public Logger getChildLogger( String name )
+ {
+ return this;
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/CcCommand.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/CcCommand.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,33 @@
+package net.dpml.metro.commands;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import org.knopflerfish.service.console.Session;
+
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.Dictionary;
+
+public class CcCommand
+{
+
+ public ContainmentModel execute( ContainmentModel current, Dictionary
opts, Reader in, PrintWriter output, Session session )
+ {
+ String path = (String) opts.get( "path" );
+ DeploymentModel model = current.getModel( path );
+ if( model instanceof ContainmentModel )
+ {
+ current = (ContainmentModel) model;
+ output.println( current );
+ }
+ else
+ {
+ output.println( "Error: Not a container: " + path );
+ return null; // FAILED
+ }
+ output.println();
+ output.flush();
+ return current; // SUCCESS
+ }
+
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/DeployCommand.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/DeployCommand.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,108 @@
+package net.dpml.metro.commands;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ModelException;
+import org.knopflerfish.service.console.Session;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Dictionary;
+
+public class DeployCommand
+{
+ public ContainmentModel execute( ContainmentModel current, Dictionary
opts, Reader in, PrintWriter output, Session session )
+ {
+ String block = (String) opts.get( "block-url" );
+ String targets = (String) opts.get( "targets-url" );
+ String destination = (String) opts.get( "destination" );
+
+ if( destination == null || "".equals( destination ) )
+ {
+ destination = current.getQualifiedName();
+ }
+
+ DeploymentModel model = current.getModel( destination );
+ if( model == null )
+ {
+ output.println( "Error: <destination> must be an existing
ContainmentModel." );
+ return null;
+ }
+
+ if( model instanceof ContainmentModel == false)
+ {
+ output.println( "Error: <destination> must be a ContainmentModel
and not a " + model.getClass().getName() );
+ return null;
+ }
+
+ ContainmentModel container = (ContainmentModel) model;
+ ContainmentModel newContainer = null;
+ URL targetsUrl = null;
+ URL blockUrl = null;
+ try
+ {
+ blockUrl = resolveURL( block );
+ targetsUrl = resolveURL( targets );
+ newContainer = container.addContainmentModel( blockUrl,
targetsUrl );
+ newContainer.commission();
+ output.println();
+ output.flush();
+ return newContainer;
+ } catch( IOException e )
+ {
+ output.println( "Error: Invalid URL." );
+ e.printStackTrace( output );
+ return null;
+ } catch( ModelException e )
+ {
+ output.println( "Error: Unable to add the block " + blockUrl + "
with the override targets " + targetsUrl + " into " + container );
+ return null;
+ } catch( Exception e )
+ {
+ output.println( "Error: Unable to commission " + newContainer );
+ return null;
+ }
+ }
+
+ private URL resolveURL( String value )
+ throws IOException
+ {
+ if( value.startsWith( "artifact:" ) )
+ {
+ return artifactSpecToURL( value );
+ }
+
+ try
+ {
+ return new URL( value );
+ }
+ catch( MalformedURLException e )
+ {
+ File target = new File( value );
+ if( target.exists() )
+ {
+ return toURL( target );
+ }
+ else
+ {
+ throw new IOException( "Unable to resolve URL: " + value );
+ }
+ }
+ }
+
+ private URL toURL( File file )
+ throws MalformedURLException, IOException
+ {
+ return file.getCanonicalFile().toURL();
+ }
+
+ private URL artifactSpecToURL( String spec )
+ throws IOException
+ {
+ return new URL( spec );
+ }
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ListCommand.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ListCommand.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,43 @@
+package net.dpml.metro.commands;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import org.knopflerfish.service.console.Session;
+
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.Dictionary;
+
+public class ListCommand
+{
+
+ public int execute( ContainmentModel current, Dictionary opts, Reader
in, PrintWriter output, Session session )
+ {
+ output.println();
+ String[] selection = (String[]) opts.get("selection");
+ if( selection.length == 0 )
+ {
+ selection = new String[] { current.getQualifiedName() };
+ }
+ for( int i = 0 ; i < selection.length; i++ )
+ {
+ String path = selection[ i ];
+ DeploymentModel model = current.getModel( path );
+ if( model instanceof ContainmentModel )
+ {
+ DeploymentModel[] models = ((ContainmentModel)
model).getModels();
+ for( int j = 0; i < models.length; i++ )
+ {
+ DeploymentModel m = models[ j ];
+ output.write( m.toString() );
+ output.println();
+ }
+ }
+ output.println();
+ output.flush();
+ }
+ return 0; // SUCCESS
+ }
+
+
+}

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ShowCommand.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/ShowCommand.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2004 Niclas Hedman.
+ *
+ * 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.metro.commands;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import org.knopflerfish.service.console.Session;
+
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.Dictionary;
+
+/**
+ */
+public class ShowCommand
+{
+ String LINE =
"\n-----------------------------------------------------------";
+
+ public int execute( ContainmentModel current, Dictionary opts, Reader
in, PrintWriter output, Session session )
+ {
+ String path = (String) opts.get( "path" );
+ output.println();
+ if( path == null )
+ path = current.getPath();
+ DeploymentModel model = current.getModel( path );
+ printModel( output, model );
+ output.println();
+ output.flush();
+ return 0; // SUCCESS
+ }
+
+ public void printModel( PrintWriter output, DeploymentModel model )
+ {
+ output.println( "audit report" );
+ output.println( LINE );
+ output.println( "\nApplication Model" );
+ output.println( LINE );
+ output.println( "\n" );
+ printModel( output, " ", model );
+ output.println( "\n" );
+ output.println( LINE );
+ }
+
+ public void printModel( PrintWriter output, String lead, DeploymentModel
model )
+ {
+ if( model instanceof ContainmentModel )
+ {
+ printContainmentModel( output, lead, (ContainmentModel) model );
+ }
+ else if( model instanceof ComponentModel )
+ {
+ printComponentModel( output, lead, (ComponentModel) model );
+ }
+ }
+
+ public void printContainmentModel( PrintWriter output, String lead,
ContainmentModel model )
+ {
+ output.println( "\n" + lead + "container:" + model + ")" );
+ printDeploymentModel( output, lead, model );
+ DeploymentModel[] models = model.getModels();
+ if( models.length > 0 )
+ {
+ output.println( "\n" + lead + " children:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ printModel( output, " " + lead, m );
+ }
+ }
+ models = model.getStartupGraph();
+ if( models.length > 0 )
+ {
+ output.println( "\n" + lead + " startup:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ output.println( "\n" + " " + lead + (i+1) + ": " + m );
+ }
+ }
+ models = ((ContainmentModel)model).getShutdownGraph();
+ if( models.length > 0 )
+ {
+ output.println( "\n" + lead + " shutdown:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ output.println( "\n" + " " + lead + (i+1) + ": " + m );
+ }
+ }
+ }
+
+ public void printComponentModel( PrintWriter output, String lead,
ComponentModel model )
+ {
+ output.println( "\n" + lead + "component:" + model + "(" +
model.getDeploymentTimeout() + ")" );
+ printDeploymentModel( output, lead, model );
+ }
+
+ public void printDeploymentModel( PrintWriter output, String lead,
DeploymentModel model )
+ {
+ DeploymentModel[] providers = model.getProviders();
+ DeploymentModel[] consumers = model.getConsumerGraph();
+
+ if(( providers.length == 0 ) && ( consumers.length == 0 ))
+ {
+ return;
+ }
+
+ if( providers.length > 0 ) for( int i=0; i<providers.length; i++ )
+ {
+ DeploymentModel m = providers[i];
+ output.println( "\n" + lead + " <-- consumes: " + m );
+ }
+
+ if( consumers.length > 0 ) for( int i=0; i<consumers.length; i++ )
+ {
+ DeploymentModel m = consumers[i];
+ if( isDirectProvider( m, model ) )
+ {
+ output.println( "\n" + lead + " --> supplies: " + m );
+ }
+ }
+ }
+
+ private boolean isDirectProvider( DeploymentModel consumer,
DeploymentModel model )
+ {
+ String name = model.getQualifiedName();
+ DeploymentModel[] providers = consumer.getProviders();
+ for( int i=0; i<providers.length; i++ )
+ {
+ DeploymentModel m = providers[i];
+ if( m.getQualifiedName().equals( name ) ) return true;
+ }
+ return false;
+ }
+}
+

Added:
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/UndeployCommand.java
==============================================================================
--- (empty file)
+++
development/laboratory/users/niclas/osgi/metro/main/src/main/net/dpml/metro/commands/UndeployCommand.java
Sun Jun 26 10:06:51 2005
@@ -0,0 +1,43 @@
+package net.dpml.metro.commands;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import org.knopflerfish.service.console.Session;
+
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.Dictionary;
+
+public class UndeployCommand
+{
+ public ContainmentModel execute( ContainmentModel current, Dictionary
opts, Reader in, PrintWriter output, Session session )
+ {
+ String target = (String) opts.get( "path" );
+ ContainmentModel root = (ContainmentModel) current.getModel( "/" );
+ DeploymentModel model = current.getModel( target );
+ if( model == null )
+ {
+ output.println( "Error: <path> must be an existing
ContainmentModel." );
+ return null;
+ }
+
+ if( model instanceof ContainmentModel == false)
+ {
+ output.println( "Error: <destination> must be a ContainmentModel
and not a " + model.getClass().getName() );
+ return null;
+ }
+
+ ContainmentModel container = (ContainmentModel) model;
+ String name = container.getName();
+ String path = container.getPath();
+ ContainmentModel parent = (ContainmentModel) root.getModel( path );
+ container.decommission();
+ container.disassemble();
+ parent.removeModel( name );
+
+ output.println();
+ output.flush();
+ return root; //SUCCESS
+ }
+
+}

Modified:
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/ReferenceDescriptor.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/ReferenceDescriptor.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/ReferenceDescriptor.java
Sun Jun 26 10:06:51 2005
@@ -67,8 +67,7 @@
* @exception NullArgumentException if the classname or version is null
* @exception IllegalArgumentException if the classname string is invalid
*/
- public ReferenceDescriptor( final String classname,
- final Version version )
+ public ReferenceDescriptor( String classname, Version version )
throws NullArgumentException
{
if ( null == classname )
@@ -173,7 +172,7 @@
}

/**
- * Returns the cashcode.
+ * Returns the hashcode.
* @return the hascode value
*/
public int hashCode()

Modified:
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/Service.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/Service.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/meta/api/src/main/net/dpml/meta/info/Service.java
Sun Jun 26 10:06:51 2005
@@ -68,9 +68,7 @@
* @param reference the versioned classname
* @param entries the set of attributes to assign to the descriptor
*/
- public Service(
- final ReferenceDescriptor reference,
- final EntryDescriptor[] entries )
+ public Service( ReferenceDescriptor reference, EntryDescriptor[] entries
)
{
this( reference, entries, null );
}
@@ -82,9 +80,7 @@
* @param reference the versioned classname
* @param attributes the set of attributes to assign to the descriptor
*/
- public Service(
- final ReferenceDescriptor reference,
- final Properties attributes )
+ public Service( ReferenceDescriptor reference, Properties attributes )
{
this( reference, null, attributes );
}
@@ -98,10 +94,7 @@
* @param attributes the set of attributes to assign to the descriptor
* @exception NullArgumentException if the reference argument is null.
*/
- public Service(
- final ReferenceDescriptor reference,
- final EntryDescriptor[] entries,
- final Properties attributes )
+ public Service( ReferenceDescriptor reference, EntryDescriptor[]
entries, Properties attributes )
throws NullArgumentException
{
super( attributes );

Modified:
development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/Factory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/Factory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/system/api/src/main/net/dpml/system/Factory.java
Sun Jun 26 10:06:51 2005
@@ -27,23 +27,25 @@
*/
public interface Factory
{
- /**
- * Return a new instance of default criteria for the factory.
- * @return a new criteria instance
- */
+ /**
+ * Return a new instance of default criteria for the factory.
+ * @return a new criteria instance
+ */
Map createDefaultCriteria();

- /**
- * Create a new instance of an application.
- * @return the application instance
- */
- Object create() throws Exception;
+ /**
+ * Create a new instance of an application.
+ * @return the application instance
+ */
+ Object create()
+ throws Exception;

- /**
- * Create a new instance of an application.
- * @param criteria the creation criteria
- * @return the application instance
- */
- Object create( Map criteria ) throws Exception;
+ /**
+ * Create a new instance of an application.
+ * @param criteria the creation criteria
+ * @return the application instance
+ */
+ Object create( Map criteria )
+ throws Exception;

}



  • svn commit: r2924 - in development/laboratory/users/niclas/osgi/metro: . activation/impl/src/main/net/dpml/activation/impl 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/impl/src/test/net/dpml/composition/model/builder main main/src/main/net/dpml/metro main/src/main/net/dpml/metro/commands meta/api/src/main/net/dpml/meta/info osgi/src/main/net/dpml/osgi system system/api/src/main/net/dpml/system system/impl system/spi system/test unit/src/main/net/dpml/metro/unit util, niclas, 06/26/2005

Archive powered by MHonArc 2.6.24.

Top of Page