Skip to Content.
Sympa Menu

notify-dpml - r1538 - in trunk/main/metro: . model/src/main/net/dpml/metro model/src/main/net/dpml/metro/builder runtime/src/main/net/dpml/metro tools/src/main/net/dpml/metro/tools

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1538 - in trunk/main/metro: . model/src/main/net/dpml/metro model/src/main/net/dpml/metro/builder runtime/src/main/net/dpml/metro tools/src/main/net/dpml/metro/tools
  • Date: Wed, 5 Jul 2006 09:51:48 +0200

Author: mcconnell
Date: 2006-07-05 09:51:40 +0200 (Wed, 05 Jul 2006)
New Revision: 1538

Added:
trunk/main/metro/model/src/main/net/dpml/metro/builder/

trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentDecoder.java

trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentEncoder.java
Removed:

trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentDecoder.java

trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentEncoder.java
trunk/main/metro/runtime/src/main/net/dpml/metro/builder/
Modified:
trunk/main/metro/module.xml

trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
Log:
move deployment builder into the model package

Copied: trunk/main/metro/model/src/main/net/dpml/metro/builder (from rev
1524, trunk/main/metro/runtime/src/main/net/dpml/metro/builder)

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentDecoder.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/builder/ComponentDecoder.java
2006-06-20 07:55:19 UTC (rev 1524)
+++
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentDecoder.java
2006-07-05 07:51:40 UTC (rev 1538)
@@ -1,385 +0,0 @@
-/*
- * Copyright 2006 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.builder;
-
-import java.io.IOException;
-import java.net.URI;
-
-import net.dpml.component.ActivationPolicy;
-
-import net.dpml.metro.data.ContextDirective;
-import net.dpml.metro.data.CategoryDirective;
-import net.dpml.metro.data.CategoriesDirective;
-import net.dpml.metro.data.ComponentDirective;
-import net.dpml.metro.data.ValueDirective;
-import net.dpml.metro.data.LookupDirective;
-import net.dpml.metro.info.LifestylePolicy;
-import net.dpml.metro.info.CollectionPolicy;
-import net.dpml.metro.info.PartReference;
-import net.dpml.metro.info.Priority;
-
-import net.dpml.lang.ValueDecoder;
-import net.dpml.lang.Value;
-
-import net.dpml.util.DOM3DocumentBuilder;
-import net.dpml.util.ElementHelper;
-import net.dpml.util.DecodingException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Construct a state graph.
- */
-public class ComponentDecoder
-{
- private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
-
- private static final String SCHEMA_URN = "@COMPONENT-XSD-URI@";
-
- private static final DOM3DocumentBuilder DOCUMENT_BUILDER = new
DOM3DocumentBuilder();
-
- private static final ComponentTypeDecoder TYPE_DECODER = new
ComponentTypeDecoder();
-
- private static final ValueDecoder VALUE_DECODER = new ValueDecoder();
-
- /**
- * Construct a component directive using the supplied uri.
- * @param uri the part uri
- * @return the component directive
- * @exception IOException if an error occurs during directive creation
- */
- public ComponentDirective loadComponentDirective( URI uri ) throws
IOException
- {
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
- try
- {
- final Document document = DOCUMENT_BUILDER.parse( uri );
- final Element root = document.getDocumentElement();
- return buildComponent( root );
- }
- catch( Throwable e )
- {
- final String error =
- "An error while attempting to load a component directive."
- + "\nURI: " + uri;
- IOException exception = new IOException( error );
- exception.initCause( e );
- throw exception;
- }
- }
-
- /**
- * Construct a component directive using the supplied DOM element.
- * @param root the element representing the component directive definition
- * @return the component directive
- * @exception DecodingException if an error occurs during directive
creation
- */
- public ComponentDirective buildComponent( Element root ) throws
DecodingException
- {
- if( null == root )
- {
- throw new NullPointerException( "root" );
- }
-
- return createComponentDirective( root );
- }
-
- private ComponentDirective createComponentDirective( Element element )
throws DecodingException
- {
- String classname = buildComponentClassname( element );
- String name = buildComponentName( element, classname );
- ActivationPolicy activation = buildActivationPolicy( element );
- CollectionPolicy collection = buildCollectionPolicy( element );
- LifestylePolicy lifestyle = buildLifestylePolicy( element );
- CategoriesDirective categories = getNestedCategoriesDirective(
element );
- ContextDirective context = getNestedContextDirective( element );
- PartReference[] parts = getNestedParts( element );
-
- return new ComponentDirective(
- name, activation, collection, lifestyle, classname,
- categories, context, parts );
- }
-
- private String buildComponentClassname( Element element ) throws
DecodingException
- {
- String classname = ElementHelper.getAttribute( element, "type" );
- if( null == classname )
- {
- final String error =
- "Missing component 'class' attribute.";
- throw new DecodingException( element, error );
- }
- else
- {
- return classname;
- }
- }
-
- private ActivationPolicy buildActivationPolicy( Element element ) throws
DecodingException
- {
- String defaultValue = ActivationPolicy.SYSTEM.getName();
- String policy = ElementHelper.getAttribute( element, "activation",
defaultValue );
- return ActivationPolicy.parse( policy );
- }
-
- private LifestylePolicy buildLifestylePolicy( Element element ) throws
DecodingException
- {
- String policy = ElementHelper.getAttribute( element, "lifestyle",
null );
- if( null != policy )
- {
- return LifestylePolicy.parse( policy );
- }
- else
- {
- return null;
- }
- }
-
- private CollectionPolicy buildCollectionPolicy( Element element ) throws
DecodingException
- {
- String defaultValue = CollectionPolicy.SYSTEM.getName();
- String policy = ElementHelper.getAttribute( element, "collection",
defaultValue );
- return CollectionPolicy.parse( policy );
- }
-
- private String buildComponentName( Element element, String classname )
- {
- String name = ElementHelper.getAttribute( element, "name" );
- if( null != name )
- {
- return name;
- }
- else
- {
- name = ElementHelper.getAttribute( element, "key" );
- if( null != name )
- {
- return name;
- }
- else
- {
- return toName( classname );
- }
- }
- }
-
- private CategoriesDirective getNestedCategoriesDirective( Element root )
- {
- Element element = ElementHelper.getChild( root, "categories" );
- if( null == element )
- {
- return null;
- }
- else
- {
- return createCategoriesDirective( element );
- }
- }
-
- private CategoriesDirective createCategoriesDirective( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- String name = ElementHelper.getAttribute( element, "name" );
- Priority priority = createPriority( element );
- String target = ElementHelper.getAttribute( element, "target" );
- CategoryDirective[] categories = createCategoryDirectiveArray(
element );
- return new CategoriesDirective( name, priority, target,
categories );
- }
- }
-
- private CategoryDirective createCategoryDirective( Element element )
- {
- String name = ElementHelper.getAttribute( element, "name" );
- Priority priority = createPriority( element );
- String target = ElementHelper.getAttribute( element, "target" );
- return new CategoryDirective( name, priority, target );
- }
-
- private CategoryDirective[] createCategoryDirectiveArray( Element
element )
- {
- Element[] children = ElementHelper.getChildren( element );
- CategoryDirective[] categories = new CategoryDirective[
children.length ];
- for( int i=0; i<categories.length; i++ )
- {
- Element elem = children[i];
- if( "category".equals( elem.getTagName() ) )
- {
- categories[i] = createCategoryDirective( elem );
- }
- else
- {
- categories[i] = createCategoriesDirective( elem );
- }
- }
- return categories;
- }
-
- private Priority createPriority( Element element )
- {
- String priority = ElementHelper.getAttribute( element, "priority" );
- if( null == priority )
- {
- return null;
- }
- else
- {
- return Priority.parse( priority );
- }
- }
-
- private ContextDirective getNestedContextDirective( Element root )
throws DecodingException
- {
- Element context = ElementHelper.getChild( root, "context" );
- if( null == context )
- {
- return null;
- }
- else
- {
- return createContextDirective( context );
- }
- }
-
- private ContextDirective createContextDirective( Element element )
throws DecodingException
- {
- String classname = ElementHelper.getAttribute( element, "class" );
- Element[] children = ElementHelper.getChildren( element );
- PartReference[] entries = new PartReference[ children.length ];
- for( int i=0; i<children.length; i++ )
- {
- Element elem = children[i];
- entries[i] = createContextEntryPartReference( elem );
- }
- return new ContextDirective( classname, entries );
- }
-
- private PartReference createContextEntryPartReference( Element element )
throws DecodingException
- {
- String key = ElementHelper.getAttribute( element, "key" );
- String spec = ElementHelper.getAttribute( element, "lookup" );
- if( null != spec )
- {
- LookupDirective directive = new LookupDirective( spec );
- return new PartReference( key, directive );
- }
- else
- {
- String name = element.getTagName();
- if( "entry".equals( name ) )
- {
- ValueDirective directive = buildValueDirective( element );
- return new PartReference( key, directive );
- }
- else if( "component".equals( name ) )
- {
- ComponentDirective directive = createComponentDirective(
element );
- return new PartReference( key, directive );
- }
- else
- {
- final String error =
- "Context entry element is not recognized.";
- throw new DecodingException( element, error );
- }
- }
- }
-
- /**
- * Build a value directive using a supplied DOM element.
- * @param element the DOM element
- * @return the value directive
- */
- protected ValueDirective buildValueDirective( Element element )
- {
- String classname = ElementHelper.getAttribute( element, "class" );
- String method = ElementHelper.getAttribute( element, "method" );
- Element[] elements = ElementHelper.getChildren( element, "param" );
- if( elements.length > 0 )
- {
- Value[] values = VALUE_DECODER.decodeValues( elements );
- return new ValueDirective( classname, method, values );
- }
- else
- {
- String value = ElementHelper.getAttribute( element, "value" );
- return new ValueDirective( classname, method, value );
- }
- }
-
- private PartReference[] getNestedParts( Element root ) throws
DecodingException
- {
- Element parts = ElementHelper.getChild( root, "parts" );
- if( null == parts )
- {
- return null;
- }
- else
- {
- return createParts( parts );
- }
- }
-
- private PartReference[] createParts( Element element ) throws
DecodingException
- {
- Element[] children = ElementHelper.getChildren( element );
- PartReference[] parts = new PartReference[ children.length ];
- for( int i=0; i<children.length; i++ )
- {
- Element elem = children[i];
- parts[i] = createPartReference( elem );
- }
- return parts;
- }
-
- private PartReference createPartReference( Element element ) throws
DecodingException
- {
- String key = ElementHelper.getAttribute( element, "key" );
- ComponentDirective directive = createComponentDirective( element );
- return new PartReference( key, directive );
- }
-
- /**
- * Internal utility to get the name of the class without the package
name. Used
- * when constructing a default component name.
- * @param classname the fully qualified classname
- * @return the short class name without the package name
- */
- private String toName( String classname )
- {
- int i = classname.lastIndexOf( "." );
- if( i == -1 )
- {
- return classname.toLowerCase();
- }
- else
- {
- return classname.substring( i + 1, classname.length()
).toLowerCase();
- }
- }
-
-}

Copied:
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentDecoder.java
(from rev 1537,
trunk/main/metro/runtime/src/main/net/dpml/metro/builder/ComponentDecoder.java)

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentEncoder.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/builder/ComponentEncoder.java
2006-06-20 07:55:19 UTC (rev 1524)
+++
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentEncoder.java
2006-07-05 07:51:40 UTC (rev 1538)
@@ -1,480 +0,0 @@
-/*
- * Copyright 2006 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.builder;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import javax.xml.XMLConstants;
-
-import net.dpml.component.ActivationPolicy;
-import net.dpml.component.Directive;
-
-import net.dpml.lang.Value;
-import net.dpml.lang.ValueEncoder;
-
-import net.dpml.metro.data.ContextDirective;
-import net.dpml.metro.data.CategoryDirective;
-import net.dpml.metro.data.CategoriesDirective;
-import net.dpml.metro.data.ComponentDirective;
-import net.dpml.metro.data.LookupDirective;
-import net.dpml.metro.data.ValueDirective;
-import net.dpml.metro.info.LifestylePolicy;
-import net.dpml.metro.info.CollectionPolicy;
-import net.dpml.metro.info.PartReference;
-import net.dpml.metro.info.Priority;
-
-import net.dpml.util.Encoder;
-
-/**
- * Component part handler.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ComponentEncoder extends ComponentConstants implements Encoder
-{
- private static final String XML_HEADER = "<?xml version=\"1.0\"?>";
- private static final String TYPE_SCHEMA_URN = "@TYPE-XSD-URI@";
- private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
- private static final String PART_SCHEMA_URN = "@PART-XSD-URI@";
- private static final String COMPONENT_SCHEMA_URN = "@COMPONENT-XSD-URI@";
- private static final String PARTIAL_COMPONENT_HEADER =
- "<component xmlns=\""
- + COMPONENT_SCHEMA_URN
- + "\""
- + "\n xmlns:xsi=\""
- + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
- + "\"\n xmlns:part=\""
- + PART_SCHEMA_URN
- + "\"\n xmlns:type=\""
- + TYPE_SCHEMA_URN
- + "\"\n xmlns:component=\""
- + COMPONENT_SCHEMA_URN
- + "\"";
-
- private static final ValueEncoder VALUE_ENCODER = new ValueEncoder();
-
- /**
- * Export a component directive to an output stream as XML.
- * @param directive the component directive
- * @param output the output stream
- * @exception IOException if an IO error occurs
- */
- public void export( ComponentDirective directive, OutputStream output )
throws IOException
- {
- final Writer writer = new OutputStreamWriter( output );
-
- writer.write( XML_HEADER );
- writer.write( "\n\n" );
- writer.write( PARTIAL_COMPONENT_HEADER );
- writeAttributes( writer, directive, "" );
- writeBody( writer, directive, " " );
- writer.write( "\n" );
- writer.write( "</component>" );
- writer.write( "\n" );
- writer.flush();
- output.close();
- }
-
- /**
- * Export a component directive to an output stream as XML.
- * @param writer the print writer
- * @param object the object to encode
- * @param pad character offset
- * @exception IOException if an IO error occurs
- */
- public void encode( Writer writer, Object object, String pad ) throws
IOException
- {
- if( object instanceof ComponentDirective )
- {
- writeTaggedComponent( writer, (ComponentDirective) object, null,
pad );
- }
- else
- {
- final String error =
- "Encoding subject is not recognized."
- + "\nClass: " + object.getClass().getName();
- throw new IllegalArgumentException( error );
- }
- }
-
- /**
- * Export a component directive to an output stream as XML.
- * @param writer the print writer
- * @param directive the component directive
- * @param pad character offset
- * @exception IOException if an IO error occurs
- */
- public void writeComponent(
- Writer writer, ComponentDirective directive, String pad ) throws
IOException
- {
- writeTaggedComponent( writer, directive, null, pad );
- }
-
- /**
- * Export a tagged component directive to an output stream as XML.
- * @param writer the print writer
- * @param directive the component directive
- * @param key the key identifying the component
- * @param pad character offset
- * @exception IOException if an IO error occurs
- */
- public void writeTaggedComponent(
- Writer writer, ComponentDirective directive, String key, String pad )
throws IOException
- {
- writer.write( "\n" + pad + "<component xmlns=\"" +
COMPONENT_SCHEMA_URN + "\"" );
- if( null != key )
- {
- writer.write( " key=\"" + key + "\"" );
- }
- writer.write( "\n" + pad + " " );
- writeAttributes( writer, directive, pad + " " );
- writeBody( writer, directive, pad + " " );
- writer.write( "\n" + pad + "</component>" );
- }
-
- void writeAttributes(
- Writer writer, ComponentDirective directive, String pad ) throws
IOException
- {
- String classname = directive.getClassname();
- writer.write( " type=\"" + classname + "\"" );
- String name = directive.getName();
- if( null != name )
- {
- writer.write( "\n" + pad + " name=\"" + name + "\"" );
- }
- LifestylePolicy lifestyle = directive.getLifestylePolicy();
- if( null != lifestyle )
- {
- writer.write( "\n" + pad + " lifestyle=\"" + lifestyle.getName()
+ "\"" );
- }
- CollectionPolicy collection = directive.getCollectionPolicy();
- if( null != collection )
- {
- writer.write( "\n" + pad + " collection=\"" +
collection.getName() + "\"" );
- }
- ActivationPolicy activation = directive.getActivationPolicy();
- if( null != activation )
- {
- writer.write( "\n" + pad + " activation=\"" +
activation.getName() + "\"" );
- }
- writer.write( ">" );
- }
-
- void writeBody(
- Writer writer, ComponentDirective directive, String pad ) throws
IOException
- {
- CategoriesDirective categories = directive.getCategoriesDirective();
- ContextDirective context = directive.getContextDirective();
- PartReference[] parts = directive.getPartReferences();
- writeCategoriesDirective( writer, categories, pad );
- writeContextDirective( writer, context, pad );
- writeParts( writer, parts, pad );
- }
-
- private void writeCategoriesDirective(
- Writer writer, CategoriesDirective categories, String pad ) throws
IOException
- {
- String name = categories.getName();
- Priority priority = categories.getPriority();
- String target = categories.getTarget();
- CategoryDirective[] subCategories = categories.getCategories();
-
- if( isaNullValue( name ) && isaNullPriority( priority ) &&
isaNullValue( target )
- && ( subCategories.length == 0 ) )
- {
- return;
- }
-
- writer.write( "\n" + pad + "<categories" );
- if( !isaNullValue( name ) )
- {
- writer.write( " name=\"" + name + "\"" );
- }
- if( !isaNullPriority( priority ) )
- {
- writer.write( " priority=\"" + priority.getName() + "\"" );
- }
- if( !isaNullValue( target ) )
- {
- writer.write( " target=\"" + target + "\"" );
- }
- if( subCategories.length == 0 )
- {
- writer.write( "/>" );
- }
- else
- {
- writer.write( ">" );
- for( int i=0; i<subCategories.length; i++ )
- {
- CategoryDirective directive = subCategories[i];
- if( directive instanceof CategoriesDirective )
- {
- CategoriesDirective c = (CategoriesDirective) directive;
- writeCategoriesDirective( writer, c, pad + " " );
- }
- else
- {
- writeCategoryDirective( writer, directive, pad + " " );
- }
- }
- writer.write( "\n" + pad + "</categories>" );
- }
- }
-
- private boolean isaNullPriority( Priority priority )
- {
- if( null == priority )
- {
- return true;
- }
- else
- {
- return Priority.DEBUG.equals( priority );
- }
- }
-
- private boolean isaNullValue( String value )
- {
- if( null == value )
- {
- return true;
- }
- else
- {
- return "".equals( value );
- }
- }
-
- private void writeCategoryDirective(
- Writer writer, CategoryDirective category, String pad ) throws
IOException
- {
- String name = category.getName();
- Priority priority = category.getPriority();
- String target = category.getTarget();
-
- writer.write( "\n" + pad + "<category" );
- if( null != name )
- {
- writer.write( " name=\"" + name + "\"" );
- }
- if( null != priority )
- {
- writer.write( " priority=\"" + priority.getName() + "\"" );
- }
- if( null != target )
- {
- writer.write( " target=\"" + target + "\"" );
- }
- writer.write( "/>" );
- }
-
- private void writeContextDirective(
- Writer writer, ContextDirective context, String pad ) throws
IOException
- {
- String classname = context.getClassname();
- PartReference[] parts = context.getDirectives();
-
- if( ( null == classname ) && ( parts.length == 0 ) )
- {
- return;
- }
-
- writer.write( "\n" + pad + "<context" );
- if( null != classname )
- {
- writer.write( " class=\"" + classname + "\"" );
- }
- if( parts.length == 0 )
- {
- writer.write( "/>" );
- }
- else
- {
- writer.write( ">" );
- writeContextEntries( writer, parts, pad + " " );
- writer.write( "\n" + pad + "</context>" );
- }
- }
-
- /**
- * Write a collection of part references.
- * @param writer the writer
- * @param parts the part refernece array
- * @param pad the offset
- * @exception IOException if an IO error occurs
- */
- protected void writeParts(
- Writer writer, PartReference[] parts, String pad ) throws IOException
- {
- if( parts.length == 0 )
- {
- return;
- }
- else
- {
- writer.write( "\n" + pad + "<parts>" );
- writePartReferences( writer, parts, pad + " " );
- writer.write( "\n" + pad + "</parts>" );
- }
- }
-
- private void writePartReferences(
- Writer writer, PartReference[] parts, String pad ) throws IOException
- {
- for( int i=0; i<parts.length; i++ )
- {
- PartReference ref = parts[i];
- writePartReference( writer, ref, pad );
- }
- }
-
- private void writeContextEntries(
- Writer writer, PartReference[] parts, String pad ) throws IOException
- {
- for( int i=0; i<parts.length; i++ )
- {
- PartReference ref = parts[i];
- writeContextEntry( writer, ref, pad );
- }
- }
-
- private void writeContextEntry(
- Writer writer, PartReference part, String pad ) throws IOException
- {
- String key = part.getKey();
- if( null == key )
- {
- throw new IllegalStateException( "key" );
- }
- Directive directive = part.getDirective();
- if( null == directive )
- {
- throw new IllegalStateException( "directive" );
- }
- if( directive instanceof ValueDirective )
- {
- ValueDirective value = (ValueDirective) directive;
- writeEntry( writer, key, value, pad );
- }
- else if( directive instanceof LookupDirective )
- {
- LookupDirective value = (LookupDirective) directive;
- writeLookupEntry( writer, key, value, pad );
- }
- else if( directive instanceof ComponentDirective )
- {
- ComponentDirective value = (ComponentDirective) directive;
- writeTaggedComponent( writer, value, key, pad );
- }
- else
- {
- String classname = directive.getClass().getName();
- final String message = "WARNING: UNRECOGNIZED ENTRY: "+
classname;
- System.out.println( "# " + message );
- System.out.println( "# key: " + key );
- System.out.println( "# class: " + classname );
- writer.write( "\n" + pad + "<!-- " + message + " -->" );
- writer.write( "\n" + pad + "<!-- " );
- writer.write( "\n" + pad + "key: " + key );
- writer.write( "\n" + pad + "class: " +
directive.getClass().getName() );
- writer.write( "\n" + pad + "-->" );
- }
- }
-
- private void writeLookupEntry(
- Writer writer, String key, LookupDirective directive, String pad )
throws IOException
- {
- String classname = directive.getServiceClassname();
- writer.write( "\n" + pad + "<entry key=\"" + key + "\" lookup=\"" +
classname + "\"/>" );
- }
-
- private void writePartReference(
- Writer writer, PartReference part, String pad ) throws IOException
- {
- String key = part.getKey();
- if( null == key )
- {
- throw new IllegalStateException( "key" );
- }
-
- Directive directive = part.getDirective();
- if( null == directive )
- {
- throw new IllegalStateException( "directive" );
- }
- if( directive instanceof ComponentDirective )
- {
- ComponentDirective component = (ComponentDirective) directive;
- writeTaggedComponent( writer, component, key, pad );
- }
- else
- {
- String classname = directive.getClass().getName();
- final String error =
- "Part reference class not recognized."
- + "\nClass: " + classname;
- throw new IllegalArgumentException( error );
- }
- }
-
- /**
- * Write a context entry.
- * @param writer the writer
- * @param key the entry key
- * @param value the value directive
- * @param pad the offset
- * @exception IOException if an IO error occurs
- */
- protected void writeEntry( Writer writer, String key, ValueDirective
value, String pad ) throws IOException
- {
- String target = value.getTargetExpression();
- String method = value.getMethodName();
-
- writer.write( "\n" + pad + "<entry key=\"" + key + "\"" );
- if( null != target )
- {
- writer.write( " class=\"" + target + "\"" );
- }
- if( null != method )
- {
- writer.write( " method=\"" + method + "\"" );
- }
- Value[] values = value.getValues();
- if( values.length > 0 )
- {
- writer.write( ">" );
- VALUE_ENCODER.encodeValues( writer, values, pad + " " );
- writer.write( "\n" + pad + "</entry>" );
- }
- else
- {
- String v = value.getBaseValue();
- if( null != v )
- {
- writer.write( " value=\"" + v + "\"" );
- }
- writer.write( "/>" );
- }
- }
-}

Copied:
trunk/main/metro/model/src/main/net/dpml/metro/builder/ComponentEncoder.java
(from rev 1537,
trunk/main/metro/runtime/src/main/net/dpml/metro/builder/ComponentEncoder.java)

Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-07-05 07:25:28 UTC (rev 1537)
+++ trunk/main/metro/module.xml 2006-07-05 07:51:40 UTC (rev 1538)
@@ -60,6 +60,10 @@
<feature token="VERSION" id="version"/>
<feature token="GROUP" id="group"/>
<feature token="PART-HANDLER-URI" id="uri"
ref="dpml/metro/dpml-metro-runtime" type="part"/>
+ <feature token="STATE-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-state" alias="true"/>
+ <feature token="PART-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-part" alias="true"/>
+ <feature token="TYPE-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-type" alias="true"/>
+ <feature token="COMPONENT-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-component" alias="true"/>
</filters>
</project>

@@ -86,6 +90,8 @@
</test>
</dependencies>
<filters>
+ <!--
+ -->
<feature token="PART-HANDLER-URI" id="uri" type="part"/>
<feature token="STATE-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-state" alias="true"/>
<feature token="PART-XSD-URI" id="uri" type="xsd"
ref="dpml/lang/dpml-part" alias="true"/>

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-07-05 07:25:28 UTC (rev 1537)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-07-05 07:51:40 UTC (rev 1538)
@@ -83,7 +83,7 @@
private PartsDataType m_parts;
private File m_output;
private Type m_type;
- //private ComponentDirective m_profile;
+ private URI m_extends;
private boolean m_alias = false;

/**
@@ -108,10 +108,10 @@
* Set the extends uri feature.
* @param uri the uri from which the component extends
*/
- //public void setExtends( URI uri )
- //{
- // m_extends = uri;
- //}
+ public void setExtends( URI uri )
+ {
+ m_extends = uri;
+ }

/**
* Set the embedded component flag.
@@ -372,14 +372,21 @@
CategoriesDirective categories = getCategoriesDirective();
ContextDirective context = getContextDirective( classloader, type );
PartReference[] parts = getParts( classloader );
+ URI base = getBaseURI();

//
// return the component profile
//

return new ComponentDirective(
- id, activation, collection, lifestyle, classname, categories,
context, parts );
+ id, activation, collection, lifestyle, classname, categories,
+ context, parts, base );
}
+
+ private URI getBaseURI()
+ {
+ return m_extends;
+ }

private Type loadType( ClassLoader classloader, String classname )
{




  • r1538 - in trunk/main/metro: . model/src/main/net/dpml/metro model/src/main/net/dpml/metro/builder runtime/src/main/net/dpml/metro tools/src/main/net/dpml/metro/tools, mcconnell at BerliOS, 07/05/2006

Archive powered by MHonArc 2.6.24.

Top of Page