Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2949 - in development/main: metro/central/src/main/net/dpml/metro/central metro/composition/builder/src/main/net/dpml/composition/builder metro/composition/builder/src/main/net/dpml/composition/builder/datatypes metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/data metro/part/src/main/net/dpml/part/control transit/core/handler/src/main/net/dpml/transit/artifact

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2949 - in development/main: metro/central/src/main/net/dpml/metro/central metro/composition/builder/src/main/net/dpml/composition/builder metro/composition/builder/src/main/net/dpml/composition/builder/datatypes metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/data metro/part/src/main/net/dpml/part/control transit/core/handler/src/main/net/dpml/transit/artifact
  • Date: Sat, 02 Jul 2005 01:16:49 -0400

Author: mcconnell AT dpml.net
Date: Sat Jul 2 01:16:49 2005
New Revision: 2949

Removed:

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
Modified:

development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java

development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
development/main/metro/part/src/main/net/dpml/part/control/PartHandler.java

development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
Log:
removal of the DependenciesDirective (now included as an part of
ContextDirective)

Modified:
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
==============================================================================
---
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
(original)
+++
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
Sat Jul 2 01:16:49 2005
@@ -28,6 +28,7 @@
import java.util.Date;

import net.dpml.composition.control.CompositionController;
+import net.dpml.composition.control.CompositionControllerContext;

import net.dpml.part.control.Controller;
import net.dpml.part.control.ControllerContext;
@@ -82,7 +83,8 @@
}
Logger logger = new LoggingAdapter( "metro" );
DefaultContentModel model = new DefaultContentModel( logger, null,
type, title, properties );
- m_controller = new CompositionController( model );
+ ControllerContext context = new CompositionControllerContext( model
);
+ m_controller = new CompositionController( context );
}

public MetroHelper( ContentModel model ) throws Exception
@@ -91,7 +93,8 @@
{
throw new NullPointerException( "model" );
}
- m_controller = new CompositionController( model );
+ ControllerContext context = new CompositionControllerContext( model
);
+ m_controller = new CompositionController( context );
}

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

Modified:
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
==============================================================================
---
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
(original)
+++
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
Sat Jul 2 01:16:49 2005
@@ -32,6 +32,7 @@
import java.util.Map;

import net.dpml.composition.control.CompositionController;
+import net.dpml.composition.control.CompositionControllerContext;

import net.dpml.transit.repository.Repository;

@@ -68,7 +69,8 @@
{
throw new NullPointerException( "model" );
}
- m_controller = new CompositionController( model );
+ ControllerContext context = new CompositionControllerContext( model
);
+ m_controller = new CompositionController( context );
}

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

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
Sat Jul 2 01:16:49 2005
@@ -36,7 +36,7 @@
import net.dpml.composition.builder.datatypes.CategoriesDataType;
import net.dpml.composition.builder.datatypes.ConfigurationDataType;
import net.dpml.composition.builder.datatypes.ContextDataType;
-import net.dpml.composition.builder.datatypes.DependenciesDataType;
+//import net.dpml.composition.builder.datatypes.DependenciesDataType;
import net.dpml.composition.builder.datatypes.ParametersDataType;
import net.dpml.composition.builder.datatypes.PartsDataType;
import net.dpml.composition.data.ClassLoaderDirective;
@@ -88,7 +88,6 @@
private ContextDataType m_context;
private ParametersDataType m_parameters;
private ConfigurationDataType m_configuration;
- private DependenciesDataType m_dependencies;
private PartsDataType m_parts;

private File m_output;
@@ -219,26 +218,6 @@
}
}

- /**
- * Add a dependencies directive to this component.
- * @return the depedencies directive
- */
- public DependenciesDataType createDependencies()
- {
- if( null == m_dependencies )
- {
- System.out.println( "# Creating dependencies datatype." );
- m_dependencies = new DependenciesDataType();
- return m_dependencies;
- }
- else
- {
- final String error =
- "Illegal attempt to create a duplicate dependencies set.";
- throw new BuildException( error, getLocation() );
- }
- }
-
public void execute()
{
Project t_project = getProject();
@@ -259,6 +238,8 @@
ClassLoaderDirective cld = constructClassLoaderDirective();
ComponentProfile profile = buildComponentProfile( classloader,
cld );

+ // ?? ASSEMBLY ??
+
URI uri = getDefinition().getArtifactURI( Part.ARTIFACT_TYPE );
if( null == m_output )
{
@@ -462,7 +443,6 @@
Mode mode = Mode.EXPLICIT;
CategoriesDirective categories = getCategoriesDirective();
ContextDirective context = getContextDirective( classloader, type );
- DependencyDirective[] dependencies = getDependencyDirectives(
classloader, type );
PartReference[] parts = getParts( classloader, type );
Parameters parameters = getParameters();
Configuration configuration = getConfiguration();
@@ -473,7 +453,7 @@

return new ComponentProfile(
id, activation, collection, lifestyle, classname, categories,
context,
- dependencies, parts, parameters, configuration, cld, mode );
+ parts, parameters, configuration, cld, mode );
}

/**
@@ -489,33 +469,16 @@
{
throw new NullPointerException( "classname" );
}
- String path = classname.replace( '.', '/' ) + ".type";
- URL url = classloader.getResource( path );
- if( null == url )
- {
- final String error =
- "Unable to locate a component type definition for the class ["
- + classname
- + "] under the resource path ["
- + path
- + "].";
- throw new ConstructionException( error );
- }
try
{
- InputStream input = url.openStream();
- ObjectInputStream stream = new ObjectInputStream( input );
- TypeHolder holder = (TypeHolder) stream.readObject();
- byte[] bytes = holder.getByteArray();
- ByteArrayInputStream byteinput = new ByteArrayInputStream( bytes
);
- ObjectInputStream bytestream = new ObjectInputStream( byteinput
);
- return (Type) bytestream.readObject();
+ Class c = classloader.loadClass( classname );
+ return Type.loadType( c );
}
- catch( Exception e )
+ catch( Throwable e )
{
final String error =
- "Unexpected error occured while attempting to load the type
from the path ["
- + path
+ "Unexpected error occured while attempting to load type ["
+ + classname
+ "]";
throw new BuildException( error, e, getLocation() );
}
@@ -698,18 +661,6 @@
}
}

- private DependencyDirective[] getDependencyDirectives( ClassLoader
classloader, Type type )
- {
- if( null == m_dependencies )
- {
- return new DependencyDirective[0];
- }
- else
- {
- return m_dependencies.getDependencyDirectives( classloader, type
);
- }
- }
-
private CategoriesDirective getCategoriesDirective()
{
if( null == m_categories )

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
Sat Jul 2 01:16:49 2005
@@ -23,9 +23,10 @@
import java.net.URISyntaxException;

import net.dpml.composition.builder.PartReferenceBuilder;
-import net.dpml.composition.control.CompositionPartHandler;
+import net.dpml.composition.control.CompositionController;
import net.dpml.composition.info.Type;

+import net.dpml.part.control.ControllerContext;
import net.dpml.part.control.DelegationException;
import net.dpml.part.control.PartNotFoundException;
import net.dpml.part.part.Part;
@@ -127,7 +128,7 @@
URI uri = getURI();
try
{
- CompositionPartHandler handler = new CompositionPartHandler();
+ CompositionController handler = new CompositionController();
return handler.loadPart( uri );
}
catch( PartNotFoundException pnfe )
@@ -158,6 +159,15 @@
+ ioe.getMessage();
throw new BuildException( error, ioe );
}
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while attempting to load part ["
+ + m_uri
+ + "] due to: "
+ + e.getMessage();
+ throw new BuildException( error, e );
+ }
}

private static URI PART_HANDLER_URI = setupURI( "@PART-HANDLER-URI@" );

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Sat Jul 2 01:16:49 2005
@@ -28,6 +28,7 @@
import java.net.URLClassLoader;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Properties;

import net.dpml.logging.Logger;

@@ -58,7 +59,9 @@
import net.dpml.part.manager.Container;
import net.dpml.part.part.Part;

+import net.dpml.transit.adapter.LoggingAdapter;
import net.dpml.transit.model.ContentModel;
+import net.dpml.transit.model.DefaultContentModel;

/**
* A initial test controller.
@@ -89,22 +92,18 @@
// constructor
//--------------------------------------------------------------------

- public CompositionController( ContentModel context )
+ public CompositionController()
throws ControlException
{
- super();
+ this( createDefaultContext() );
+ }

- try
- {
- m_context = new CompositionControllerContext( context );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while attempting to construct the compositon
context.";
- throw new ControlException( CONTROLLER_URI, error, e );
- }
+ public CompositionController( ControllerContext context )
+ throws ControlException
+ {
+ super( context );

+ m_context = context;
m_logger = m_context.getLogger();
m_valueController = new ValueController( this );
m_componentController = new ComponentController( m_logger, this );
@@ -142,19 +141,6 @@
}

//--------------------------------------------------------------------
- // PartHandler
- //--------------------------------------------------------------------
-
- /**
- * Load the model controller.
- * @return the controller
- */
- public Controller getController()
- {
- return this;
- }
-
- //--------------------------------------------------------------------
// Controller
//--------------------------------------------------------------------

@@ -245,19 +231,8 @@
throws IOException, ComponentException, PartNotFoundException,
HandlerNotFoundException, DelegationException
{
m_logger.debug( "loading component " + uri );
-
- ClassLoader classloader =
net.dpml.part.part.Part.class.getClassLoader();
-
Part part = loadPart( uri );
- if( isRecognizedPart( part ) )
- {
- return newComponent( null, part, null );
- }
- else
- {
- Controller controller = getPartHandler( part );
- return controller.newComponent( uri );
- }
+ return newComponent( null, part, null );
}

/**
@@ -310,7 +285,8 @@
}
else
{
- Controller controller = getPartHandler( part );
+ URI handlerUri = part.getPartHandlerURI();
+ Controller controller = (Controller) getPrimaryController(
handlerUri );
return controller.newComponent( parent, part, name );
}
}
@@ -559,4 +535,23 @@
return null;
}
}
+
+ private static ControllerContext createDefaultContext()
+ {
+ try
+ {
+ String title = "Metro Build Context.";
+ String type = "part";
+ Properties properties = new Properties();
+ net.dpml.transit.model.Logger logger = new LoggingAdapter(
"metro" );
+ DefaultContentModel model =
+ new DefaultContentModel( logger, null, type, title, properties
);
+ return new CompositionControllerContext( model );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
Sat Jul 2 01:16:49 2005
@@ -27,12 +27,15 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
+import java.util.Properties ;
import java.util.WeakHashMap ;

import net.dpml.part.part.Part;
import net.dpml.part.part.PartHolder;
import net.dpml.part.control.PartNotFoundException;
import net.dpml.part.control.Controller;
+import net.dpml.part.control.ControllerContext;
+import net.dpml.part.control.ControlException;
import net.dpml.part.control.PartHandler;
import net.dpml.part.control.PartHandlerRuntimeException;
import net.dpml.part.control.HandlerNotFoundException;
@@ -45,7 +48,7 @@
import net.dpml.composition.runtime.DefaultLogger;

import net.dpml.transit.Transit;
-import net.dpml.transit.artifact.Handler;
+import net.dpml.transit.artifact.Artifact;
import net.dpml.transit.repository.Repository;

/**
@@ -54,7 +57,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
*/
-public class CompositionPartHandler implements PartHandler
+public abstract class CompositionPartHandler implements PartHandler
{
/**
* Map containing the foreign part handlers. The map keys
@@ -68,10 +71,13 @@
*/
private final Repository m_loader;

- public CompositionPartHandler()
+ private final ControllerContext m_context;
+
+ public CompositionPartHandler( ControllerContext context ) throws
ControlException
{
super();

+ m_context = context;
m_loader = Transit.getInstance().getRepository();
}

@@ -85,16 +91,6 @@
}

/**
- * Return the model controller.
- * @return the controller
- * @exception UnsupportedOperationException allways thrown
- */
- public Controller getController()
- {
- throw new UnsupportedOperationException( "getController" );
- }
-
- /**
* Load a part from serialized form. The uri is assumed to be a uri that
* can be transformed to a URL from which an input stream to a PartHolder
* can be established. If the uri references a foreign part handler the
@@ -129,35 +125,27 @@
}
}

- public Controller getPartHandler( Part part )
- throws HandlerNotFoundException, DelegationException
- {
- URI uri = part.getPartHandlerURI();
- PartHandler handler = loadPartHandler( uri );
- return (Controller) handler;
- }
-
/**
* Load a part handler giiven a handler uri.
* @return the part handler
*/
- public PartHandler loadPartHandler( URI uri )
+ public Controller getPrimaryController( URI uri )
throws HandlerNotFoundException, DelegationException
{
if( false == getURI().equals( uri ) )
{
- return resolvePartHandler( uri );
+ return (Controller) resolvePartHandler( uri );
}
else
{
- return this;
+ return (Controller) this;
}
}

private Part loadSerializedPart( URI uri )
throws IOException, DelegationException, PartNotFoundException
{
- URL url = resolveURL( uri );
+ URL url = Artifact.toURL( uri );
InputStream input = url.openStream();
if( null == input )
{
@@ -209,18 +197,6 @@
}
}

- private URL resolveURL( URI uri ) throws IOException
- {
- if( "artifact".equals( uri.getScheme() ) )
- {
- return new URL( null, uri.toString(), new Handler() );
- }
- else
- {
- return uri.toURL();
- }
- }
-
protected PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException
{
if( getURI().equals( uri ) )
@@ -230,17 +206,35 @@
String key = uri.toString();
synchronized( m_handlers )
{
- PartHandler handler = (PartHandler) m_handlers.get( key );
- if( null == handler )
+ PartHandler[] handlers = (PartHandler[])
m_handlers.keySet().toArray( new PartHandler[0] );
+ for( int i=0; i<handlers.length; i++ )
+ {
+ try
+ {
+ PartHandler handler = handlers[i];
+ if( handler.getURI().equals( uri ) )
+ {
+ return handler;
+ }
+ }
+ catch( RemoteException e )
+ {
+ // TODO: log but continue
+ }
+ }
+ try
{
- handler = loadHandler( uri );
- m_handlers.put( key, handler );
+ PartHandler handler = loadHandler( uri );
+ m_handlers.put( handler, null );
+ return handler;
+ }
+ finally
+ {
+ // log loading event
}
- return handler;
}
}

-
private PartHandler loadHandler( URI uri ) throws
HandlerNotFoundException
{
ClassLoader classloader = Type.class.getClassLoader();
@@ -268,4 +262,5 @@
return null;
}
}
+
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
Sat Jul 2 01:16:49 2005
@@ -131,11 +131,6 @@
private final ContextDirective m_context;

/**
- * The dependency directives.
- */
- private final DependencyDirective[] m_dependencies;
-
- /**
* The internal parts.
*/
private final PartReference[] m_parts;
@@ -160,7 +155,7 @@
InfoDescriptor.UNDEFINED_COLLECTION,
"request",
classname,
- null, null, null, null, null, null, null,
+ null, null, null, null, null, null,
Mode.IMPLICIT );
}

@@ -180,7 +175,6 @@
template.getClassname(),
template.getCategoriesDirective(),
template.getContextDirective(),
- template.getDependencyDirectives(),
template.getParts(),
template.getParameters(),
template.getConfiguration(),
@@ -196,7 +190,6 @@
final String classname,
final CategoriesDirective categories,
final ContextDirective context,
- final DependencyDirective[] dependencies,
final PartReference[] parts,
final Parameters parameters,
final Configuration config,
@@ -234,14 +227,6 @@
m_parameters = parameters;
m_configuration = config;

- if( null == dependencies )
- {
- m_dependencies = new DependencyDirective[0];
- }
- else
- {
- m_dependencies = dependencies;
- }
if( null == parts )
{
m_parts = new PartReference[0];
@@ -298,16 +283,6 @@
}

/**
- * Return the dependency directives.
- *
- * @return the set of DependencyDirective statements for the profile.
- */
- public DependencyDirective[] getDependencyDirectives()
- {
- return m_dependencies;
- }
-
- /**
* Return the internal parts.
*
* @return the array of internal parts.
@@ -318,26 +293,6 @@
}

/**
- * Return the dependency directive for a supplied key.
- *
- * @return the matching DependencyDirective (possibly null if
- * no directive is declared for the given key)
- */
- public DependencyDirective getDependencyDirective( final String key )
- {
- DependencyDirective[] directives = getDependencyDirectives();
- for( int i=0; i<directives.length; i++ )
- {
- DependencyDirective directive = directives[i];
- if( directive.getKey().equals( key ) )
- {
- return directive;
- }
- }
- return null;
- }
-
- /**
* Return the Parameters for the profile.
*
* @return the Parameters for Component (if any).
@@ -407,24 +362,6 @@
{
return false;
}
- if( getDependencyDirectives().length !=
profile.getDependencyDirectives().length )
- {
- return false;
- }
- else
- {
- DependencyDirective[] mine = getDependencyDirectives();
- DependencyDirective[] yours = profile.getDependencyDirectives();
- for( int i=0; i<mine.length; i++ )
- {
- DependencyDirective a = mine[i];
- DependencyDirective b = yours[i];
- if( false == a.equals( b ) )
- {
- return false;
- }
- }
- }
if( getParts().length != profile.getParts().length )
{
return false;
@@ -476,10 +413,6 @@
{
hash ^= m_configuration.hashCode();
}
- for( int i=0; i<m_dependencies.length; i++ )
- {
- hash ^= m_dependencies[i].hashCode();
- }
for( int i=0; i<m_parts.length; i++ )
{
hash ^= m_parts[i].hashCode();

Modified:
development/main/metro/part/src/main/net/dpml/part/control/PartHandler.java
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/PartHandler.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/control/PartHandler.java
Sat Jul 2 01:16:49 2005
@@ -40,10 +40,10 @@
URI getURI() throws RemoteException;

/**
- * Load a part handler giiven a handler uri.
+ * Load a controller given a part handler uri.
* @return the part handler
*/
- PartHandler loadPartHandler( URI uri )
+ Controller getPrimaryController( URI uri )
throws HandlerNotFoundException, IOException, DelegationException,
RemoteException;

/**
@@ -62,4 +62,5 @@
* @return the part
*/
Part loadPart( byte[] bytes ) throws IOException, RemoteException;
+
}

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/artifact/Artifact.java
Sat Jul 2 01:16:49 2005
@@ -176,6 +176,19 @@
}
}

+ public static URL toURL( URI uri ) throws MalformedURLException
+ {
+ try
+ {
+ Artifact artifact = Artifact.createArtifact( uri );
+ return artifact.toURL();
+ }
+ catch( UnsupportedSchemeException e )
+ {
+ return uri.toURL();
+ }
+ }
+
//
------------------------------------------------------------------------
// state
//
------------------------------------------------------------------------



  • svn commit: r2949 - in development/main: metro/central/src/main/net/dpml/metro/central metro/composition/builder/src/main/net/dpml/composition/builder metro/composition/builder/src/main/net/dpml/composition/builder/datatypes metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/data metro/part/src/main/net/dpml/part/control transit/core/handler/src/main/net/dpml/transit/artifact, mcconnell, 07/02/2005

Archive powered by MHonArc 2.6.24.

Top of Page