Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2151 - in development/main/metro: composition/builder/src/main/net/dpml/composition/builder composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info meta/api/src/test/net/dpml/meta/info/test

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: r2151 - in development/main/metro: composition/builder/src/main/net/dpml/composition/builder composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info meta/api/src/test/net/dpml/meta/info/test
  • Date: Sat, 26 Mar 2005 15:35:15 -0500

Author: mcconnell AT dpml.net
Date: Sat Mar 26 15:35:14 2005
New Revision: 2151

Modified:

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

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java

development/main/metro/meta/api/src/main/net/dpml/meta/info/InfoDescriptor.java
development/main/metro/meta/api/src/main/net/dpml/meta/info/Type.java

development/main/metro/meta/api/src/test/net/dpml/meta/info/test/InfoDescriptorTestCase.java
Log:
Correction to the determination of a static field value in the type builder
task. Updates to the static fields to use strings in preference to int as
strings are self documenting.

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
Sat Mar 26 15:35:14 2005
@@ -225,10 +225,8 @@
String name = getName();
String classname = subject.getName();
boolean threadsafe = getThreadSafeCapability( subject );
- int lifestylePreference = getLifestylePreference( subject );
- String lifestyle = InfoDescriptor.getLifestylePreferenceKey(
lifestylePreference );
- int collectionPolicy = getCollectionPolicyPreference( subject );
- String collection = InfoDescriptor.getCollectionPolicyKey(
collectionPolicy );
+ String lifestyle = getLifestylePreference( subject, threadsafe );
+ String collection = getCollectionPolicyPreference( subject );
String schema = getConfigurationSchema( subject );
Properties properties = getTypeProperties( subject );
return new InfoDescriptor(
@@ -240,7 +238,7 @@
try
{
Field field = subject.getDeclaredField(
"TYPE_THREADSAFE_CAPABLE" );
- if( field.getModifiers() == Modifier.STATIC )
+ if( Modifier.isStatic( field.getModifiers() ) )
{
return field.getBoolean( null );
}
@@ -273,23 +271,37 @@

}

- private int getLifestylePreference( Class subject ) throws
IntrospectionException
+ private String getLifestylePreference( Class subject, boolean threadsafe
) throws IntrospectionException
{
try
{
Field field = subject.getDeclaredField(
"TYPE_LIFESTYLE_PREFERENCE" );
- if( field.getModifiers() == Modifier.STATIC )
+ if( Modifier.isStatic( field.getModifiers() ) )
{
- return field.getInt( null );
+ return (String) field.get( null );
}
else
{
- return InfoDescriptor.TRANSIENT_LIFESTYLE;
+ if( threadsafe )
+ {
+ return InfoDescriptor.SINGLETON;
+ }
+ else
+ {
+ return InfoDescriptor.TRANSIENT;
+ }
}
}
catch( NoSuchFieldException e )
{
- return InfoDescriptor.TRANSIENT_LIFESTYLE;
+ if( threadsafe )
+ {
+ return InfoDescriptor.SINGLETON;
+ }
+ else
+ {
+ return InfoDescriptor.TRANSIENT;
+ }
}
catch( IllegalArgumentException e )
{
@@ -297,7 +309,7 @@
"The component type ["
+ subject.getName()
+ "] declares an invalid static field
TYPE_LIFESTYLE_PREFERENCE declaration. "
- + "Could not convert the value to an int.";
+ + "Could not convert the value to an string.";
throw new IntrospectionException( error );
}
catch( Exception e )
@@ -310,23 +322,23 @@
}
}

- private int getCollectionPolicyPreference( Class subject ) throws
IntrospectionException
+ private String getCollectionPolicyPreference( Class subject ) throws
IntrospectionException
{
try
{
Field field = subject.getDeclaredField(
"TYPE_COLLECTION_PREFERENCE" );
- if( field.getModifiers() == Modifier.STATIC )
+ if( Modifier.isStatic( field.getModifiers() ) )
{
- return field.getInt( null );
+ return (String) field.get( null );
}
else
{
- return InfoDescriptor.UNDEFINED;
+ return null;
}
}
catch( NoSuchFieldException e )
{
- return InfoDescriptor.UNDEFINED;
+ return null;
}
catch( IllegalArgumentException e )
{
@@ -334,7 +346,7 @@
"The component type ["
+ subject.getName()
+ "] declares an invalid static field
TYPE_COLLECTION_PREFERENCE declaration. "
- + "Could not convert the value to an int.";
+ + "Could not convert the value to an string.";
throw new IntrospectionException( error );
}
catch( Exception e )
@@ -352,7 +364,7 @@
try
{
Field field = subject.getDeclaredField(
"TYPE_CONFIGURATION_SCHEMA" );
- if( field.getModifiers() == Modifier.STATIC )
+ if( Modifier.isStatic( field.getModifiers() ) )
{
if( String.class.isAssignableFrom( field.getType() ) )
{
@@ -405,7 +417,7 @@
try
{
Field field = subject.getDeclaredField( "TYPE_INFO_PROPERTIES" );
- if( field.getModifiers() == Modifier.STATIC )
+ if( Modifier.isStatic( field.getModifiers() ) )
{
if( Properties.class.isAssignableFrom( field.getType() ) )
{

Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
Sat Mar 26 15:35:14 2005
@@ -28,6 +28,12 @@
public class DefaultGizmo implements Gizmo
{
//------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ //------------------------------------------------------------------
// constructor
//------------------------------------------------------------------

@@ -53,7 +59,7 @@
Widget getWidget();
}

- public interface Parts
+ public interface Parts // not used
{
Widget createWidget();
Widget getWidget();

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
Sat Mar 26 15:35:14 2005
@@ -47,22 +47,22 @@
// static
//-------------------------------------------------------------------

- public static final int TRANSIENT_LIFESTYLE = 0;
- public static final int THREAD_LIFESTYLE = 1;
- public static final int SINGLETON_LIFESTYLE = 2;
-
public static final String TRANSIENT = "transient";
public static final String SINGLETON = "singleton";
public static final String THREAD = "thread";

- public static final String WEAK_KEY = "weak";
- public static final String SOFT_KEY = "soft";
- public static final String HARD_KEY = "hard";
-
- public static final int UNDEFINED = -1;
- public static final int WEAK = 0;
- public static final int SOFT = 1;
- public static final int HARD = 2;
+ public static final String WEAK = "weak";
+ public static final String SOFT = "soft";
+ public static final String HARD = "hard";
+
+ public static final int TRANSIENT_LIFESTYLE = 0;
+ public static final int THREAD_LIFESTYLE = 1;
+ public static final int SINGLETON_LIFESTYLE = 2;
+
+ public static final int UNDEFINED_COLLECTION = -1;
+ public static final int WEAK_COLLECTION = 0;
+ public static final int SOFT_COLLECTION = 1;
+ public static final int HARD_COLLECTION = 2;

//-------------------------------------------------------------------
// immutable state
@@ -97,13 +97,13 @@

/**
* The component garbage collection policy. The value returned is either
- * WEAK, SOFT or HARD. A component implementing a WEAK policy
+ * WEAK_COLLECTION, SOFT_COLLECTION or HARD_COLLECTION. A component
implementing a WEAK_COLLECTION policy
* will be decommissioned if no references exist. A component declaring
a
- * SOFT policy will exist without reference so long as memory contention
- * does not occur. A component implementing HARD policies will be
+ * SOFT_COLLECTION policy will exist without reference so long as memory
contention
+ * does not occur. A component implementing HARD_COLLECTION policies
will be
* maintained irrespective of usage and memory constraints so long as its
* scope exists (the jvm for a "singleton" and Thread for "thread"
lifestyles).
- * The default policy is HARD.
+ * The default policy is HARD_COLLECTION.
*/
private final int m_collection;

@@ -202,11 +202,11 @@
}

int p = getCollectionPolicy( collection );
- if( p > UNDEFINED )
+ if( p > UNDEFINED_COLLECTION )
{
- if(( m_lifestyle == TRANSIENT ) && ( p == HARD ))
+ if(( m_lifestyle == TRANSIENT ) && ( p == HARD_COLLECTION ))
{
- m_collection = SOFT;
+ m_collection = SOFT_COLLECTION;
}
else
{
@@ -217,11 +217,11 @@
{
if( m_lifestyle == TRANSIENT )
{
- m_collection = SOFT;
+ m_collection = SOFT_COLLECTION;
}
else
{
- m_collection = HARD;
+ m_collection = HARD_COLLECTION;
}
}

@@ -299,7 +299,7 @@
*/
public boolean isWeak()
{
- return m_collection == WEAK;
+ return m_collection == WEAK_COLLECTION;
}

/**
@@ -309,7 +309,7 @@
*/
public boolean isSoft()
{
- return m_collection == SOFT;
+ return m_collection == SOFT_COLLECTION;
}

/**
@@ -319,7 +319,7 @@
*/
public boolean isHard()
{
- return m_collection == HARD;
+ return m_collection == HARD_COLLECTION;
}

/**
@@ -502,23 +502,23 @@
*/
public static String getCollectionPolicyKey( int policy )
{
- if ( policy == UNDEFINED )
+ if ( policy == UNDEFINED_COLLECTION )
{
return null;
}
else
{
- if( policy == HARD )
+ if( policy == HARD_COLLECTION )
{
- return HARD_KEY;
+ return HARD;
}
- else if( policy == SOFT )
+ else if( policy == SOFT_COLLECTION )
{
- return SOFT_KEY;
+ return SOFT;
}
- else if( policy == WEAK )
+ else if( policy == WEAK_COLLECTION )
{
- return WEAK_KEY;
+ return WEAK;
}
else
{
@@ -538,21 +538,21 @@
{
if ( policy == null )
{
- return UNDEFINED;
+ return UNDEFINED_COLLECTION;
}
else
{
- if( policy.equalsIgnoreCase( HARD_KEY ) )
+ if( policy.equalsIgnoreCase( HARD ) )
{
- return HARD;
+ return HARD_COLLECTION;
}
- else if( policy.equalsIgnoreCase( SOFT_KEY ))
+ else if( policy.equalsIgnoreCase( SOFT ))
{
- return SOFT;
+ return SOFT_COLLECTION;
}
- else if( policy.equalsIgnoreCase( WEAK_KEY ))
+ else if( policy.equalsIgnoreCase( WEAK ))
{
- return WEAK;
+ return WEAK_COLLECTION;
}
else
{

Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/Type.java
==============================================================================
--- development/main/metro/meta/api/src/main/net/dpml/meta/info/Type.java
(original)
+++ development/main/metro/meta/api/src/main/net/dpml/meta/info/Type.java
Sat Mar 26 15:35:14 2005
@@ -47,6 +47,8 @@
*/
public class Type implements Serializable
{
+ static final long serialVersionUID = 1L;
+
private final InfoDescriptor m_descriptor;
private final ContextDescriptor m_context;
private final Configuration m_configuration;

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
Sat Mar 26 15:35:14 2005
@@ -35,7 +35,7 @@
private final String m_classname =
InfoDescriptorTestCase.class.getName();
private final Version m_version = Version.getVersion("1.2.3");
private final String m_lifestyle = InfoDescriptor.SINGLETON;
- private final String m_collection = InfoDescriptor.WEAK_KEY;
+ private final String m_collection = InfoDescriptor.WEAK;
private final String m_schema = "schema";
private final boolean m_native = true;
private final boolean m_threadsafe = false;



  • svn commit: r2151 - in development/main/metro: composition/builder/src/main/net/dpml/composition/builder composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info meta/api/src/test/net/dpml/meta/info/test, mcconnell, 03/26/2005

Archive powered by MHonArc 2.6.24.

Top of Page