notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2130 - in development/main/metro/meta: api/src/main/net/dpml/meta/info api/src/test/net/dpml/meta/info/test impl/src/main/net/dpml/meta/info/builder/impl impl/src/main/net/dpml/meta/info/writer/impl tools/src/main/net/dpml/meta/info/tags
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2130 - in development/main/metro/meta: api/src/main/net/dpml/meta/info api/src/test/net/dpml/meta/info/test impl/src/main/net/dpml/meta/info/builder/impl impl/src/main/net/dpml/meta/info/writer/impl tools/src/main/net/dpml/meta/info/tags
- Date: Thu, 24 Mar 2005 18:03:54 -0500
Author: mcconnell AT dpml.net
Date: Thu Mar 24 18:03:53 2005
New Revision: 2130
Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/InfoDescriptor.java
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/InfoDescriptorTestCase.java
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/TypeTestCase.java
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/XMLTypeCreator.java
development/main/metro/meta/impl/src/main/net/dpml/meta/info/writer/impl/XMLTypeWriter.java
development/main/metro/meta/tools/src/main/net/dpml/meta/info/tags/TypeTag.java
Log:
Update the meta package to enable the declaration of a threadsafe component
by delcaring the threadsafe="true" attribute on the component tag. Add
support for this into the InfoDescriptor in preparation for dropping type
based lifecycle policy declaration.
Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/InfoDescriptor.java
==============================================================================
---
development/main/metro/meta/api/src/main/net/dpml/meta/info/InfoDescriptor.java
(original)
+++
development/main/metro/meta/api/src/main/net/dpml/meta/info/InfoDescriptor.java
Thu Mar 24 18:03:53 2005
@@ -109,6 +109,12 @@
*/
private final boolean m_native;
+ /**
+ * Flag indicating if the type is threadsafe.
+ */
+ private final boolean m_threadsafe;
+
+
//-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
@@ -123,7 +129,7 @@
public InfoDescriptor( final String name, final String classname )
throws IllegalArgumentException, NullPointerException
{
- this( name, classname, null, null, null, null, true, null );
+ this( name, classname, null, null, null, null, false, true, null );
}
/**
@@ -135,6 +141,7 @@
* @param version the implementation version
* @param lifestyle the component lifestyle (singleton, per-thread, etc.)
* @param collection the garbage collection policy for the component
+ * @param threadsafe if TRUE the type is declaring itself as threadsafe
* @param schema the configuration schema
* @param flag native metro flag
* @param attributes a set of attributes associated with the component
type
@@ -148,6 +155,7 @@
final String lifestyle,
final String collection,
final String schema,
+ final boolean threadsafe,
final boolean flag,
final Properties attributes )
throws IllegalArgumentException, NullPointerException
@@ -155,6 +163,7 @@
super( attributes );
m_native = flag;
+ m_threadsafe = threadsafe;
if ( null == classname )
{
@@ -350,6 +359,16 @@
}
/**
+ * Ruturn TRUE is this type is threadsafe.
+ *
+ * @return the threadsafe status
+ */
+ public boolean isThreadsafe()
+ {
+ return m_threadsafe;
+ }
+
+ /**
* Ruturn TRUE is this is a native descriptor else FALSE.
*
* @return the native status
@@ -380,6 +399,7 @@
{
InfoDescriptor info = (InfoDescriptor)other;
isEqual = isEqual && m_native == info.m_native;
+ isEqual = isEqual && m_threadsafe == info.m_threadsafe;
isEqual = isEqual && m_classname.equals( info.m_classname );
isEqual = isEqual && ( m_collection == info.m_collection );
isEqual = isEqual && m_name.equals( info.m_name );
@@ -414,6 +434,14 @@
{
hash = hash - 293741397;
}
+ if( m_threadsafe )
+ {
+ hash = hash + 383972391;
+ }
+ else
+ {
+ hash = hash - 113741397;
+ }
hash ^= m_classname.hashCode();
if ( null != m_name )
{
Modified:
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/InfoDescriptorTestCase.java
==============================================================================
---
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/InfoDescriptorTestCase.java
(original)
+++
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/InfoDescriptorTestCase.java
Thu Mar 24 18:03:53 2005
@@ -38,6 +38,7 @@
private final String m_collection = InfoDescriptor.WEAK_KEY;
private final String m_schema = "schema";
private final boolean m_native = true;
+ private final boolean m_threadsafe = false;
public InfoDescriptorTestCase ( String name )
{
@@ -47,7 +48,7 @@
protected Descriptor getDescriptor()
{
return new InfoDescriptor(
- m_name, m_classname, m_version, m_lifestyle, m_collection,
m_schema, m_native, getProperties());
+ m_name, m_classname, m_version, m_lifestyle, m_collection,
m_schema, m_threadsafe, m_native, getProperties());
}
protected void checkDescriptor( Descriptor desc )
@@ -58,6 +59,7 @@
assertEquals( m_classname, info.getClassname() );
assertEquals( m_version, info.getVersion() );
assertEquals( m_lifestyle, info.getLifestyle() );
+ assertEquals( m_threadsafe, info.isThreadsafe() );
assertEquals( InfoDescriptor.getCollectionPolicy( m_collection ),
info.getCollectionPolicy() );
assertEquals( m_schema, info.getConfigurationSchema() );
}
@@ -67,7 +69,7 @@
try
{
new InfoDescriptor(
- m_name, null, m_version, m_lifestyle, m_collection, m_schema,
m_native, getProperties() );
+ m_name, null, m_version, m_lifestyle, m_collection, m_schema,
m_threadsafe, m_native, getProperties() );
fail("Did not throw the proper NullPointerException");
}
catch( NullPointerException npe )
@@ -79,7 +81,7 @@
{
new InfoDescriptor(
m_name, "foo/fake/ClassName", m_version, m_lifestyle,
m_collection,
- m_schema, m_native, getProperties());
+ m_schema, m_threadsafe, m_native, getProperties());
fail("Did not throw the proper IllegalArgumentException");
}
catch( IllegalArgumentException iae )
@@ -91,19 +93,19 @@
{
new InfoDescriptor(
m_name, m_classname, m_version, InfoDescriptor.SINGLETON,
m_collection,
- m_schema, m_native, getProperties() );
+ m_schema, m_threadsafe, m_native, getProperties() );
new InfoDescriptor(
m_name, m_classname, m_version, InfoDescriptor.THREAD,
m_collection,
- m_schema, m_native, getProperties() );
+ m_schema, m_threadsafe, m_native, getProperties() );
new InfoDescriptor(
m_name, m_classname, m_version, InfoDescriptor.TRANSIENT,
m_collection,
- m_schema, m_native, getProperties() );
+ m_schema, m_threadsafe, m_native, getProperties() );
// All these should pass.
new InfoDescriptor(
m_name, m_classname, m_version, "Fake Lifestyle", m_collection,
- m_schema, m_native, getProperties() );
+ m_schema, m_threadsafe, m_native, getProperties() );
fail( "Did not throw the proper IllegalArgumentException" );
}
Modified:
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/TypeTestCase.java
==============================================================================
---
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/TypeTestCase.java
(original)
+++
development/main/metro/meta/api/src/test/net/dpml/meta/info/test/TypeTestCase.java
Thu Mar 24 18:03:53 2005
@@ -161,6 +161,6 @@
private static InfoDescriptor createSimpleInfo( String classname )
{
- return new InfoDescriptor( null, classname, null, null, null, null,
true, null );
+ return new InfoDescriptor( null, classname, null, null, null, null,
false, true, null );
}
}
Modified:
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/XMLTypeCreator.java
==============================================================================
---
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/XMLTypeCreator.java
(original)
+++
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/XMLTypeCreator.java
Thu Mar 24 18:03:53 2005
@@ -371,6 +371,7 @@
throws BuildException
{
final boolean isNative = info.getAttributeAsBoolean( "native", false
);
+ final boolean threadsafe = info.getAttributeAsBoolean( "threadsafe",
false );
final String name =
info.getChild( "name" ).getValue( null );
@@ -388,7 +389,7 @@
info.getChild( "collection" ).getValue( collectionLegacy );
return new InfoDescriptor(
- name, classname, version, lifestyle, collection, schema, isNative,
attributes );
+ name, classname, version, lifestyle, collection, schema,
threadsafe, isNative, attributes );
}
/**
Modified:
development/main/metro/meta/impl/src/main/net/dpml/meta/info/writer/impl/XMLTypeWriter.java
==============================================================================
---
development/main/metro/meta/impl/src/main/net/dpml/meta/info/writer/impl/XMLTypeWriter.java
(original)
+++
development/main/metro/meta/impl/src/main/net/dpml/meta/info/writer/impl/XMLTypeWriter.java
Thu Mar 24 18:03:53 2005
@@ -123,7 +123,7 @@
private void writeInfo( final Writer writer, final InfoDescriptor info )
throws IOException
{
- writer.write( "\n <info native=\"" + info.isNative() + "\">" );
+ writer.write( "\n <info native=\"" + info.isNative() + "
threadsafe=\"" + info.isThreadsafe() + "\">" );
writer.write( "\n <name>");
writer.write( info.getName() );
Modified:
development/main/metro/meta/tools/src/main/net/dpml/meta/info/tags/TypeTag.java
==============================================================================
---
development/main/metro/meta/tools/src/main/net/dpml/meta/info/tags/TypeTag.java
(original)
+++
development/main/metro/meta/tools/src/main/net/dpml/meta/info/tags/TypeTag.java
Thu Mar 24 18:03:53 2005
@@ -84,6 +84,11 @@
public static final String LIFESTYLE_PARAM = "lifestyle";
/**
+ * The lifestyle parameter
+ */
+ public static final String THREADSAFE_PARAM = "threadsafe";
+
+ /**
* The lifestyle collection policy parameter
*/
public static final String LIFESTYLE_COLLECTION_PARAM = "collection";
@@ -113,6 +118,7 @@
final String name = getName( tag );
final Version version = getVersion( tag );
final String lifestyle = getLifestyle( tag );
+ final boolean threadsafe = getThreadsafe( tag );
final String collection = getLifestyleCollectionPolicy( tag );
final String type = getJavaClass().getFullyQualifiedName();
final Properties properties = new AttributeTag( getJavaClass(),
isNative() ).getProperties();
@@ -120,7 +126,7 @@
final InfoDescriptor info =
new InfoDescriptor(
- name, type, version, lifestyle, collection, schema, isNative(),
properties );
+ name, type, version, lifestyle, collection, schema, threadsafe,
isNative(), properties );
final ServiceDescriptor[] services = new ServicesTag(
getJavaClass(), isNative() ).getServices();
final CategoryDescriptor[] loggers = new LoggerTag( getJavaClass(),
isNative() ).getCategories();
final DependencyDescriptor[] dependencies =
@@ -148,6 +154,12 @@
return getNamedParameter( tag, LIFESTYLE_PARAM, null );
}
+ private boolean getThreadsafe(DocletTag tag)
+ {
+ String threadsafe = getNamedParameter( tag, THREADSAFE_PARAM,
"false" );
+ return Boolean.valueOf( threadsafe ).booleanValue();
+ }
+
private String getLifestyleCollectionPolicy(DocletTag tag)
{
return getNamedParameter( tag, LIFESTYLE_COLLECTION_PARAM, null );
- svn commit: r2130 - in development/main/metro/meta: api/src/main/net/dpml/meta/info api/src/test/net/dpml/meta/info/test impl/src/main/net/dpml/meta/info/builder/impl impl/src/main/net/dpml/meta/info/writer/impl tools/src/main/net/dpml/meta/info/tags, mcconnell, 03/24/2005
Archive powered by MHonArc 2.6.24.