You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by hl...@apache.org on 2004/07/18 01:50:39 UTC
cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind Registry.java
hlship 2004/07/17 16:50:39
Modified: framework/src/test/hivemind/test/services
AutowireTarget.java ClassResolverHolder.java
src/documentation/content/xdocs index.xml
framework/src/test/hivemind/test/config
TestConfigurationPoint.java
framework/src/java/org/apache/hivemind/impl
ImplStrings.properties ImplMessages.java
RegistryImpl.java
framework/src/java/org/apache/hivemind/service/impl
BuilderClassResolverFacet.java
ServicePropertyObjectProvider.java
. status.xml
framework/src/test/hivemind/test/services/impl
ClassResolverHolderImpl.java
framework/src/java/org/apache/hivemind Registry.java
Added: framework/src/test/hivemind/test MultipleServiceImpl.java
UniqueServiceImpl.java NonExistentServiceImpl.java
TestServicesByInterface.java IUniqueService.java
INonExistentService.java servicesByInterface.sdl
IMultipleService.java
Log:
HIVEMIND-20: Add a version of Registry.getService() that omits the service id (but requires that exactly one service point implements the service interface).
Revision Changes Path
1.1 jakarta-hivemind/framework/src/test/hivemind/test/MultipleServiceImpl.java
Index: MultipleServiceImpl.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public class MultipleServiceImpl implements IMultipleService
{
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/UniqueServiceImpl.java
Index: UniqueServiceImpl.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public class UniqueServiceImpl implements IUniqueService
{
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/NonExistentServiceImpl.java
Index: NonExistentServiceImpl.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public class NonExistentServiceImpl implements INonExistentService
{
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/TestServicesByInterface.java
Index: TestServicesByInterface.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
import org.apache.hivemind.Registry;
import org.apache.hivemind.ApplicationRuntimeException;
/**
* Tests the Registry.getService(java.lang.Class) functionality.
*
* @author Marcus Brito
*/
public class TestServicesByInterface extends FrameworkTestCase
{
private Registry registry;
protected void setUp() throws Exception
{
registry = buildFrameworkRegistry("servicesByInterface.sdl");
}
protected void tearDown() throws Exception
{
registry.shutdown();
}
public void testUniqueGetServiceByInterface()
{
IUniqueService service = (IUniqueService) registry.getService(IUniqueService.class);
assertNotNull(service);
}
public void testNonExistentGetServiceByInterface()
{
try
{
registry.getService(INonExistentService.class);
unreachable();
}
catch (ApplicationRuntimeException ex)
{
assertExceptionSubstring(
ex,
"There is no service point for interface hivemind.test.INonExistentService.");
}
}
public void testMultipleExistentGetServiceByInterface()
{
try
{
registry.getService(IMultipleService.class);
unreachable();
}
catch (ApplicationRuntimeException ex)
{
assertExceptionSubstring(
ex,
"There are multiple service points for interface hivemind.test.IMultipleService: "
+ "{hivemind.tests.serviceByInterface.multipleServiceOne,"
+ " hivemind.tests.serviceByInterface.multipleServiceTwo}.");
}
}
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/IUniqueService.java
Index: IUniqueService.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public interface IUniqueService
{
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/INonExistentService.java
Index: INonExistentService.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public interface INonExistentService
{
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/servicesByInterface.sdl
Index: servicesByInterface.sdl
===================================================================
module (id=hivemind.tests.serviceByInterface version="1.0.0")
{
service-point (id=uniqueService interface=hivemind.test.IUniqueService)
{
create-instance (class=hivemind.test.UniqueServiceImpl)
}
service-point (id=multipleServiceOne interface=hivemind.test.IMultipleService)
{
create-instance (class=hivemind.test.MultipleServiceImpl)
}
service-point (id=multipleServiceTwo interface=hivemind.test.IMultipleService)
{
create-instance (class=hivemind.test.MultipleServiceImpl)
}
}
1.1 jakarta-hivemind/framework/src/test/hivemind/test/IMultipleService.java
Index: IMultipleService.java
===================================================================
// Copyright 2004 The Apache Software Foundation
//
// 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 hivemind.test;
/**
* Used when testing Registry.getService(java.lang.Class)
*
* @author Marcus Brito
*/
public interface IMultipleService
{
}
1.2 +2 -2 jakarta-hivemind/framework/src/test/hivemind/test/services/AutowireTarget.java
Index: AutowireTarget.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/AutowireTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AutowireTarget.java 18 Jun 2004 21:39:00 -0000 1.1
+++ AutowireTarget.java 17 Jul 2004 23:50:38 -0000 1.2
@@ -1,10 +1,10 @@
-// Copyright 2004 The Apache Software Foundation
+// Copyright 2004 The Apache Software Foundation
//
// 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
+// 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,
1.2 +2 -2 jakarta-hivemind/framework/src/test/hivemind/test/services/ClassResolverHolder.java
Index: ClassResolverHolder.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/ClassResolverHolder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassResolverHolder.java 18 Jun 2004 21:39:00 -0000 1.1
+++ ClassResolverHolder.java 17 Jul 2004 23:50:38 -0000 1.2
@@ -1,10 +1,10 @@
-// Copyright 2004 The Apache Software Foundation
+// Copyright 2004 The Apache Software Foundation
//
// 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
+// 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,
1.13 +7 -0 jakarta-hivemind/src/documentation/content/xdocs/index.xml
Index: index.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/index.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- index.xml 25 Jun 2004 20:20:01 -0000 1.12
+++ index.xml 17 Jul 2004 23:50:38 -0000 1.13
@@ -142,6 +142,13 @@
<li>Operating in a completely thread-safe manner</li>
<li>Reporting any errors in a useful, verbose fashion</li>
</ul>
+
+ <note>
+ In the not-unusual case that only a single service within the entire Registry
+ implements a particular service interface,
+ then you may omit the service id, i.e. <code>getService(MyService.class)</code>.
+ </note>
+
<p>However, a much more common case is for services to collaborate: that's
much simpler, since HiveMind will connect the two services together for
you. You'll just need to provide an instance variable and either a
1.16 +3 -3 jakarta-hivemind/framework/src/test/hivemind/test/config/TestConfigurationPoint.java
Index: TestConfigurationPoint.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/config/TestConfigurationPoint.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TestConfigurationPoint.java 16 Jul 2004 23:15:40 -0000 1.15
+++ TestConfigurationPoint.java 17 Jul 2004 23:50:38 -0000 1.16
@@ -337,7 +337,7 @@
r.getConfiguration("hivemind.test.config.TooFew");
- assertLoggedMessage("Configuration extension point hivemind.test.config.TooFew contains no contributions but expects at least one contribution.");
+ assertLoggedMessage("Configuration point hivemind.test.config.TooFew contains no contributions but expects at least one contribution.");
}
@@ -349,7 +349,7 @@
r.getConfiguration("hivemind.test.config.TooMany");
- assertLoggedMessage("Configuration extension point hivemind.test.config.TooMany contains 2 contributions but expects an optional contribution.");
+ assertLoggedMessage("Configuration point hivemind.test.config.TooMany contains 2 contributions but expects an optional contribution.");
}
public void testBadAttributes() throws Exception
@@ -547,7 +547,7 @@
buildFrameworkRegistry("UnknownContribution.xml");
assertLoggedMessagePattern(
- "Module hivemind\\.test\\.config has contributed to unknown configuration extension point UnresolvedSchema\\. "
+ "Module hivemind\\.test\\.config has contributed to unknown configuration point UnresolvedSchema\\. "
+ "The contribution has been ignored\\.");
}
1.6 +11 -9 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
Index: ImplStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ImplStrings.properties 16 Jul 2004 23:15:40 -0000 1.5
+++ ImplStrings.properties 17 Jul 2004 23:50:38 -0000 1.6
@@ -22,25 +22,27 @@
duplicate-translator-name=Translator ''{0}'' duplicates a previous definition at {1} and has been ignored.
translator-instantiation-failure=Unable to instantiate translator class {0}: {1}
registry-shutdown=The HiveMind Registry has been shutdown.
-no-such-service-point=Service extension point {0} does not exist.
+no-such-service-point=Service point {0} does not exist.
+no-service-point-for-interface=There is no service point for interface {0}.
+multiple-service-points-for-interface=There are multiple service points for interface {0}: {1}.
registry-already-started=The HiveMind Registry has been started.
unable-to-load-class=Could not load class {0} from {1}: {2}
-null-interceptor=Service {0} generated a null interceptor (for service extension point {1}).
-interceptor-does-not-implement-interface=The service interceptor ({0}) generated by service {1} for service extension point {2} does not implement the {3} interface defined by the extension point.
+null-interceptor=Service {0} generated a null interceptor (for service point {1}).
+interceptor-does-not-implement-interface=The service interceptor ({0}) generated by service {1} for service point {2} does not implement the {3} interface defined by the service point.
unable-to-read-messages=Unable to read message properties from {0}.
duplicate-schema=Schema {0} conflicts with existing schema at {1}.
unable-to-parse=Unable to parse module deployment descriptor {0}: {1}
unable-to-find-modules=Unable to locate HiveMind module deployment descriptors in {0}: {1}
duplicate-module-id=Module {0} is duplicated! Definition in {2} has been ignored in favor of existing definition from {1}.
-unknown-configuration-extension-point=Module {0} has contributed to unknown configuration extension point {1}. The contribution has been ignored.
-unknown-service-extension-point=Module {0} contributed to unknown service extension point {1}. The contribution has been ignored.
-missing-service=No module has contributed a service constructor for service extension point {0}.
-duplicate-factory=Module {0} has contributed a instance builder to service extension point {1}, which conflicts with an existing contribution by module {2}. The duplicate contribution has been ignored.
+unknown-configuration-extension-point=Module {0} has contributed to unknown configuration point {1}. The contribution has been ignored.
+unknown-service-extension-point=Module {0} contributed to unknown service point {1}. The contribution has been ignored.
+missing-service=No module has contributed a service constructor for service point {0}.
+duplicate-factory=Module {0} has contributed a instance builder to service point {1}, which conflicts with an existing contribution by module {2}. The duplicate contribution has been ignored.
optional=an optional
required=exactly one
one-or-more=at least one
-wrong-number-of-contributions=Configuration extension point {0} contains {1,choice,0#no contributions|1#one contribution|1<{1,number,integer} contributions} but expects {2} contribution.
+wrong-number-of-contributions=Configuration point {0} contains {1,choice,0#no contributions|1#one contribution|1<{1,number,integer} contributions} but expects {2} contribution.
no-such-configuration=Configuration point {0} does not exist.
no-such-symbol=No value available for symbol ''{0}''.
@@ -50,7 +52,7 @@
element-errors=Element {0} (at {1}) contains errors:
unknown-element=Element {0} is not allowed here.
bad-interface=Unable to find interface {0} (for service {1}).
-interface-required=Service extension points must provide an interface type: {0} is a class (for service {1}).
+interface-required=Service points must provide an interface type: {0} is a class (for service {1}).
service-wrong-interface=Service {0} does not implement the requested interface ({1}). The declared service interface type is {2}.
shutdown-coordinator-failure=Unable to shutdown {0}: {1}
1.12 +36 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
Index: ImplMessages.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ImplMessages.java 16 Jul 2004 23:15:40 -0000 1.11
+++ ImplMessages.java 17 Jul 2004 23:50:38 -0000 1.12
@@ -15,6 +15,8 @@
package org.apache.hivemind.impl;
import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.Element;
@@ -293,6 +295,40 @@
public static String registryAlreadyStarted()
{
return _formatter.getMessage("registry-already-started");
+ }
+
+ public static String noServicePointForInterface(Class interfaceClass)
+ {
+ return _formatter.format("no-service-point-for-interface", interfaceClass.getName());
+ }
+
+ public static String multipleServicePointsForInterface(
+ Class interfaceClass,
+ Collection matchingPoints)
+ {
+ StringBuffer buffer = new StringBuffer("{");
+
+ boolean following = false;
+
+ Iterator i = matchingPoints.iterator();
+ while (i.hasNext())
+ {
+ if (following)
+ buffer.append(", ");
+
+ ServicePoint p = (ServicePoint) i.next();
+
+ buffer.append(p.getExtensionPointId());
+
+ following = true;
+ }
+
+ buffer.append("}");
+
+ return _formatter.format(
+ "multiple-service-points-for-interface",
+ interfaceClass.getName(),
+ buffer);
}
public static String incompleteTranslator(TranslatorContribution c)
1.14 +48 -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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RegistryImpl.java 16 Jul 2004 23:15:40 -0000 1.13
+++ RegistryImpl.java 17 Jul 2004 23:50:38 -0000 1.14
@@ -17,6 +17,7 @@
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -54,7 +55,19 @@
private static final String SYMBOL_SOURCES = "hivemind.SymbolSources";
private static final Log LOG = LogFactory.getLog(RegistryImpl.class);
+ /**
+ * Map of {@link ServicePoint} keyed on fully qualified service id.
+ */
private Map _servicePoints = new HashMap();
+
+ /**
+ * Map of List (of {@link ServicePoint}, keyed on service interface.
+ */
+ private Map _servicePointsByInterface = new HashMap();
+
+ /**
+ * Map of {@link ConfigurationPoint} keyed on fully qualified configuration id.
+ */
private Map _configurationPoints = new HashMap();
private SymbolSource[] _variableSources;
@@ -92,6 +105,23 @@
checkStarted();
_servicePoints.put(point.getExtensionPointId(), point);
+
+ addServicePointByInterface(point);
+ }
+
+ private void addServicePointByInterface(ServicePoint point)
+ {
+ Class key = point.getServiceInterface();
+
+ List l = (List) _servicePointsByInterface.get(key);
+
+ if (l == null)
+ {
+ l = new LinkedList();
+ _servicePointsByInterface.put(key, l);
+ }
+
+ l.add(point);
}
public void addConfigurationPoint(ConfigurationPoint point)
@@ -120,6 +150,23 @@
return point.getService(serviceInterface);
}
+ public Object getService(Class serviceInterface)
+ {
+ List servicePoints = (List) _servicePointsByInterface.get(serviceInterface);
+
+ if (servicePoints == null)
+ throw new ApplicationRuntimeException(
+ ImplMessages.noServicePointForInterface(serviceInterface));
+
+ if (servicePoints.size() > 1)
+ throw new ApplicationRuntimeException(
+ ImplMessages.multipleServicePointsForInterface(serviceInterface, servicePoints));
+
+ ServicePoint sp = (ServicePoint) servicePoints.get(0);
+
+ return sp.getService(serviceInterface);
+ }
+
public ConfigurationPoint getConfigurationPoint(String configurationId)
{
checkShutdown();
@@ -381,6 +428,7 @@
_shutdownCoordinator.shutdown();
_servicePoints = null;
+ _servicePointsByInterface = null;
_configurationPoints = null;
_shutdownCoordinator = null;
_variableSources = null;
1.2 +2 -2 jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderClassResolverFacet.java
Index: BuilderClassResolverFacet.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderClassResolverFacet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BuilderClassResolverFacet.java 18 Jun 2004 21:39:01 -0000 1.1
+++ BuilderClassResolverFacet.java 17 Jul 2004 23:50:39 -0000 1.2
@@ -1,10 +1,10 @@
-// Copyright 2004 The Apache Software Foundation
+// Copyright 2004 The Apache Software Foundation
//
// 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
+// 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,
1.2 +14 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ServicePropertyObjectProvider.java
Index: ServicePropertyObjectProvider.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ServicePropertyObjectProvider.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServicePropertyObjectProvider.java 17 Jul 2004 21:32:16 -0000 1.1
+++ ServicePropertyObjectProvider.java 17 Jul 2004 23:50:39 -0000 1.2
@@ -1,3 +1,17 @@
+// Copyright 2004 The Apache Software Foundation
+//
+// 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 org.apache.hivemind.service.impl;
import org.apache.hivemind.ApplicationRuntimeException;
1.26 +4 -0 jakarta-hivemind/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/status.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- status.xml 17 Jul 2004 21:32:16 -0000 1.25
+++ status.xml 17 Jul 2004 23:50:39 -0000 1.26
@@ -59,6 +59,10 @@
<action type="update" dev="HLS">
Created service-property object translator.
</action>
+ <action type="update" dev="HLS" fixes-bug="HIVEMIND-20" due-to="Marcus Brito">
+ Add a version of <code>Registry.getService()</code> that omits the service id
+ (but requires that exactly one service point implements the service interface).
+ </action>
</release>
<release version="1.0-beta-1" date="Jun 26 2004">
1.2 +2 -2 jakarta-hivemind/framework/src/test/hivemind/test/services/impl/ClassResolverHolderImpl.java
Index: ClassResolverHolderImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/impl/ClassResolverHolderImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassResolverHolderImpl.java 18 Jun 2004 21:39:01 -0000 1.1
+++ ClassResolverHolderImpl.java 17 Jul 2004 23:50:39 -0000 1.2
@@ -1,10 +1,10 @@
-// Copyright 2004 The Apache Software Foundation
+// Copyright 2004 The Apache Software Foundation
//
// 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
+// 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,
1.6 +13 -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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Registry.java 25 Jun 2004 20:20:01 -0000 1.5
+++ Registry.java 17 Jul 2004 23:50:39 -0000 1.6
@@ -72,6 +72,19 @@
public Object getService(String serviceId, Class serviceInterface);
/**
+ * Convenience method to obtain a service with a single implementation from the registry.
+ * Exactly one service point must implement the service.
+ *
+ * @param serviceInterface the class to which the service will be cast.
+ * @return the service implementing the given interface.
+ * @throws ApplicationRuntimeException if there are no service extension points implementing
+ * the given interface, or if there multiple service points implementing it.
+ * @see #getService(String, Class)
+ */
+
+ public Object getService(Class serviceInterface);
+
+ /**
* Returns the locale for which the registry was created.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org