Skip to Content.
Sympa Menu

notify-dpml - r996 - in trunk/main/metro: model/src/main/net/dpml/metro/info 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: r996 - in trunk/main/metro: model/src/main/net/dpml/metro/info tools/src/main/net/dpml/metro/tools
  • Date: Tue, 31 Jan 2006 01:48:05 +0100

Author: mcconnell
Date: 2006-01-31 01:47:39 +0100 (Tue, 31 Jan 2006)
New Revision: 996

Added:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServicesDataType.java
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
Log:
Add support for the explicit declaration of the services that a component
provides (implementation relied upon introspection of implemented interfaces
which remains as the default behaviour if no <services> tag is declared).

Implementation now supports the following construct:

<type class="oreg.acme.DefaultWidget">
<services>
<service class="org.acme.Widget"/>
</services>
...
</type>

Modified: trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-01-30 16:04:05 UTC (rev 995)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-01-31 00:47:39 UTC (rev 996)
@@ -215,17 +215,6 @@
{
final ClassLoader loader =
Thread.currentThread().getContextClassLoader();

- //try
- //{
- // Class c = context.loadClass(
"net.dpml.configuration.impl.DefaultConfiguration" );
- //}
- //catch( ClassNotFoundException ce )
- //{
- // final String error =
- // "Context classloader does not include the configuration
implementation in the supplied classloader:\n"
- // + context;
- // throw new IllegalStateException( error );
- //}
try
{
Thread.currentThread().setContextClassLoader( context );

Added:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-01-30 16:04:05 UTC (rev 995)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-01-31 00:47:39 UTC (rev 996)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2005 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.tools;
+
+import net.dpml.metro.info.ServiceDescriptor;
+
+import net.dpml.part.Version;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Declaration of an exported service.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ServiceDataType
+{
+ private String m_classname;
+ private Version m_version;
+
+ /**
+ * Set the service classname.
+ * @param classname the name of the service interface class
+ */
+ public void setClass( final String classname )
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ m_classname = classname;
+ }
+
+ /**
+ * Set the service version.
+ * @param spec the version value
+ */
+ public void setVersion( final String spec )
+ {
+ if( null == spec )
+ {
+ throw new NullPointerException( "spec" );
+ }
+ m_version = Version.getVersion( spec );
+ }
+
+ ServiceDescriptor getServiceDescriptor()
+ {
+ if( null == m_classname )
+ {
+ throw new BuildException( "Missing interface 'class' attribute."
);
+ }
+ else
+ {
+ return new ServiceDescriptor( m_classname, m_version );
+ }
+ }
+}

Added:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServicesDataType.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServicesDataType.java
2006-01-30 16:04:05 UTC (rev 995)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServicesDataType.java
2006-01-31 00:47:39 UTC (rev 996)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2005 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.tools;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import net.dpml.metro.info.ServiceDescriptor;
+
+/**
+ * A datatype that enables custom part builders.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ServicesDataType
+{
+ private List m_services = new LinkedList();
+
+ /**
+ * Create a new component builder task.
+ * @return a new component builder task
+ */
+ public ServiceDataType createService()
+ {
+ ServiceDataType service = new ServiceDataType();
+ m_services.add( service );
+ return service;
+ }
+
+ private ServiceDataType[] getServiceDataTypes()
+ {
+ return (ServiceDataType[]) m_services.toArray( new
ServiceDataType[0] );
+ }
+
+ ServiceDescriptor[] getServiceDescriptors()
+ {
+ ServiceDataType[] builders = getServiceDataTypes();
+ ServiceDescriptor[] parts = new ServiceDescriptor[ builders.length ];
+ for( int i=0; i<builders.length; i++ )
+ {
+ ServiceDataType builder = builders[i];
+ parts[i] = builder.getServiceDescriptor();
+ }
+ return parts;
+ }
+}

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
2006-01-30 16:04:05 UTC (rev 995)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
2006-01-31 00:47:39 UTC (rev 996)
@@ -77,7 +77,8 @@
private boolean m_threadsafe = false;
private PartsDataType m_parts;
private StateDataType m_state;
-
+ private ServicesDataType m_services;
+
//---------------------------------------------------------------
// setters
//---------------------------------------------------------------
@@ -147,6 +148,25 @@
}

/**
+ * Create a new services datatype.
+ * @return a new services datatype
+ */
+ public ServicesDataType createServices()
+ {
+ if( m_services == null )
+ {
+ m_services = new ServicesDataType();
+ return m_services;
+ }
+ else
+ {
+ final String error =
+ "Illegal attempt to create a duplicate services element.";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+
+ /**
* Create a state descriptor for the component.
* @return a state graph descriptor
*/
@@ -393,8 +413,15 @@

private ServiceDescriptor[] createServiceDescriptors( Class subject )
{
- ArrayList list = new ArrayList();
- return createServiceDescriptors( subject, list );
+ if( null == m_services )
+ {
+ ArrayList list = new ArrayList();
+ return createServiceDescriptors( subject, list );
+ }
+ else
+ {
+ return m_services.getServiceDescriptors();
+ }
}

private ServiceDescriptor[] createServiceDescriptors( Class subject,
List list )




  • r996 - in trunk/main/metro: model/src/main/net/dpml/metro/info tools/src/main/net/dpml/metro/tools, mcconnell at BerliOS, 01/30/2006

Archive powered by MHonArc 2.6.24.

Top of Page