You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by jc...@apache.org on 2005/04/29 03:51:22 UTC
cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind Registry.java
jcarman 2005/04/28 18:51:22
Modified: framework/src/java/org/apache/hivemind/internal
RegistryInfrastructure.java
framework/src/java/org/apache/hivemind/impl
RegistryInfrastructureImpl.java RegistryImpl.java
framework/src/test/org/apache/hivemind/impl
TestRegistryInfrastructure.java
framework/src/java/org/apache/hivemind Registry.java
Log:
Add getServiceIds() Method to Registry Interface.
PR: HIVEMIND-112
Revision Changes Path
1.13 +5 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java
Index: RegistryInfrastructure.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/RegistryInfrastructure.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RegistryInfrastructure.java 31 Mar 2005 16:07:03 -0000 1.12
+++ RegistryInfrastructure.java 29 Apr 2005 01:51:22 -0000 1.13
@@ -233,4 +233,9 @@
*/
public void cleanupThread();
+
+ /**
+ * @param serviceInterface
+ */
+ public List getServiceIds(Class serviceInterface);
}
\ No newline at end of file
1.13 +19 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java
Index: RegistryInfrastructureImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- RegistryInfrastructureImpl.java 27 Apr 2005 14:19:46 -0000 1.12
+++ RegistryInfrastructureImpl.java 29 Apr 2005 01:51:22 -0000 1.13
@@ -563,4 +563,23 @@
{
ServiceSerializationHelper.setServiceSerializationSupport(this);
}
+
+ /* (non-Javadoc)
+ * @see org.apache.hivemind.internal.RegistryInfrastructure#getServiceIds(java.lang.Class)
+ */
+ public List getServiceIds(Class serviceInterface)
+ {
+ final List serviceIds = new LinkedList();
+ for( Iterator i = _servicePoints.values().iterator(); i.hasNext(); )
+ {
+ final ServicePoint servicePoint = ( ServicePoint )i.next();
+
+ if( servicePoint.getServiceInterface().equals( serviceInterface ) && servicePoint.visibleToModule( null ) )
+ {
+ serviceIds.add( servicePoint.getExtensionPointId() );
+ }
+
+ }
+ return serviceIds;
+ }
}
\ No newline at end of file
1.24 +8 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java
Index: RegistryImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryImpl.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- RegistryImpl.java 31 Mar 2005 16:07:03 -0000 1.23
+++ RegistryImpl.java 29 Apr 2005 01:51:22 -0000 1.24
@@ -96,4 +96,12 @@
{
_infrastructure.setupThread();
}
+
+ /**
+ * @since 1.1
+ */
+ public List getServiceIds( Class serviceInterface )
+ {
+ return _infrastructure.getServiceIds( serviceInterface );
+ }
}
\ No newline at end of file
1.5 +39 -12 jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java
Index: TestRegistryInfrastructure.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructure.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestRegistryInfrastructure.java 27 Apr 2005 14:19:46 -0000 1.4
+++ TestRegistryInfrastructure.java 29 Apr 2005 01:51:22 -0000 1.5
@@ -14,7 +14,11 @@
package org.apache.hivemind.impl;
+import java.sql.ResultSet;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.internal.ConfigurationPoint;
@@ -50,16 +54,11 @@
}
public void testGetUnqualifiedServicePoint()
- {
-
+ {
RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null);
final ModuleImpl module1 = new ModuleImpl();
module1.setModuleId( "module1" );
- final ServicePointImpl servicePoint1 = new ServicePointImpl();
- servicePoint1.setModule( module1 );
- servicePoint1.setExtensionPointId( "module1.foo" );
- servicePoint1.setVisibility( Visibility.PUBLIC );
- r.addServicePoint( servicePoint1 );
+ r.addServicePoint( createServicePoint( module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) );
try
{
r.getServicePoint("foo", null);
@@ -71,11 +70,7 @@
}
final ModuleImpl module2 = new ModuleImpl();
module2.setModuleId( "module2" );
- final ServicePointImpl servicePoint2 = new ServicePointImpl();
- servicePoint2.setModule( module2 );
- servicePoint2.setExtensionPointId( "module2.foo" );
- servicePoint2.setVisibility( Visibility.PUBLIC );
- r.addServicePoint( servicePoint2 );
+ r.addServicePoint( createServicePoint( module2, "module2.foo", ResultSet.class, Visibility.PUBLIC ) );
try
{
r.getServicePoint("foo", null);
@@ -87,6 +82,38 @@
}
}
+
+ public void testGetServiceIdsNoServices()
+ {
+ RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null);
+ final List serviceIds = r.getServiceIds( ResultSet.class );
+ assertNotNull( serviceIds );
+ assertTrue( serviceIds.isEmpty() );
+ }
+
+ public void testGetServiceIds()
+ {
+ RegistryInfrastructureImpl r = new RegistryInfrastructureImpl(null, null);
+ assertTrue( r.getServiceIds( ResultSet.class ).isEmpty() );
+ final ModuleImpl module1 = new ModuleImpl();
+ module1.setClassResolver( new DefaultClassResolver() );
+ module1.setModuleId( "module1" );
+ r.addServicePoint( createServicePoint(module1, "module1.foo", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(module1, "module1.bar", ResultSet.class, Visibility.PUBLIC ) );
+ r.addServicePoint( createServicePoint(module1, "module1.baz", ResultSet.class, Visibility.PRIVATE ) );
+ assertEquals( new HashSet( Arrays.asList( new String[] { "module1.foo", "module1.bar" } ) ), new HashSet( r.getServiceIds( ResultSet.class ) ) );
+ }
+
+ private ServicePointImpl createServicePoint(final ModuleImpl module, String id, Class serviceInterface, Visibility visibility )
+ {
+ final ServicePointImpl servicePoint2 = new ServicePointImpl();
+ servicePoint2.setModule( module );
+ servicePoint2.setExtensionPointId( id );
+ servicePoint2.setVisibility( visibility );
+ servicePoint2.setServiceInterfaceName(serviceInterface.getName());
+ return servicePoint2;
+ }
+
/**
* Ensure that the Registry "locks down" after being started up.
*
1.11 +7 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/Registry.java
Index: Registry.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/Registry.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Registry.java 31 Mar 2005 16:07:03 -0000 1.10
+++ Registry.java 29 Apr 2005 01:51:22 -0000 1.11
@@ -142,4 +142,11 @@
*/
public void cleanupThread();
+
+ /**
+ * Returns a list of service ids for service points which implement
+ * the desired service interface.
+ * @since 1.1
+ */
+ public List getServiceIds( Class serviceInterface );
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org