hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r447576 - in /hivemind/branches/branch-2-0-annot: framework/src/java/org/apache/hivemind/definition/ framework/src/java/org/apache/hivemind/impl/ framework/src/test/hivemind/test/ xml/src/java/org/apache/hivemind/impl/ xml/src/java/org/apac...
Date Mon, 18 Sep 2006 21:35:14 GMT
Author: ahuegen
Date: Mon Sep 18 14:35:13 2006
New Revision: 447576

URL: http://svn.apache.org/viewvc?view=rev&rev=447576
Log:
Smaller changes to the definition api (consistency checks etc.)

Modified:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionMessages.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionStrings.properties
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/natures/XmlRegistryNature.java

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionMessages.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionMessages.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionMessages.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionMessages.java
Mon Sep 18 14:35:13 2006
@@ -14,7 +14,6 @@
 
 package org.apache.hivemind.definition;
 
-import org.apache.hivemind.Location;
 import org.apache.hivemind.Occurances;
 import org.apache.hivemind.impl.MessageFormatter;
 import org.apache.hivemind.util.IdUtils;
@@ -29,14 +28,11 @@
     private static final MessageFormatter _formatter = new MessageFormatter(DefinitionMessages.class,
             "DefinitionStrings");
     
-    static String duplicateModuleId(String moduleId, Location locationOfExisting,
-            Location locationOfDuplicate)
+    static String duplicateModuleId(String moduleId)
     {
         return _formatter.format(
                 "duplicate-module-id",
-                moduleId,
-                locationOfExisting.getResource(),
-                locationOfDuplicate.getResource());
+                moduleId);
     }
 
     static String wrongNumberOfContributions(ModuleDefinition definingModule, ConfigurationPointDefinition
point, int actualCount,
@@ -48,6 +44,16 @@
                 fullyQualifiedId,
                 contributionCount(actualCount),
                 occurances(expectation));
+    }
+
+    static String duplicateServicePointId(String pointId, String moduleId)
+    {
+        return _formatter.format("duplicate-service-point", pointId, moduleId);
+    }
+
+    static String duplicateConfigurationPointId(String pointId, String moduleId)
+    {
+        return _formatter.format("duplicate-configuration-point", pointId, moduleId);
     }
 
     static String contributionCount(int count)

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionStrings.properties?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionStrings.properties
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/DefinitionStrings.properties
Mon Sep 18 14:35:13 2006
@@ -12,7 +12,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-duplicate-module-id=Module {0} is duplicated!  Definition in {2} has been ignored in favor
of existing definition from {1}.
+duplicate-module-id=A module with id {0} has already been defined.
+duplicate-service-point=A service point with id {0} has already been defined in module {1}.
+duplicate-configuration-point=A configuration point with id {0} has already been defined
in module {1}.
+
 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.
 configuration-point-not-visible=Configuration point {0} is not visible to module {1}.

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
Mon Sep 18 14:35:13 2006
@@ -6,6 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ClassResolver;
 import org.apache.hivemind.Location;
 
@@ -95,8 +96,17 @@
         _packageName = packageName;
     }
     
-    public void addServicePoint(ServicePointDefinition servicePoint) 
+    /**
+     * Adds a service point definition to the module.
+     * @param servicePoint  the service point
+     * @throws ApplicationRuntimeException  if another service point with the same id has
already been defined
+     */
+    public void addServicePoint(ServicePointDefinition servicePoint) throws ApplicationRuntimeException
     {
+        if (_servicePoints.containsKey(servicePoint.getId())) {
+            throw new ApplicationRuntimeException(DefinitionMessages.duplicateServicePointId(servicePoint.getId(),

+                    getId()));
+        }
         _servicePoints.put(servicePoint.getId(), servicePoint);
     }
 
@@ -110,8 +120,17 @@
         return _servicePoints.values();
     }
  
-    public void addConfigurationPoint(ConfigurationPointDefinition configurationPoint) 
+    /**
+     * Adds a configuration point definition to the module.
+     * @param configurationPoint  the configuration point
+     * @throws ApplicationRuntimeException  if another configuration point with the same
id has already been defined
+     */
+    public void addConfigurationPoint(ConfigurationPointDefinition configurationPoint) throws
ApplicationRuntimeException
     {
+        if (_configurationPoints.containsKey(configurationPoint.getId())) {
+            throw new ApplicationRuntimeException(DefinitionMessages.duplicateConfigurationPointId(configurationPoint.getId(),

+                    getId()));
+        }
         _configurationPoints.put(configurationPoint.getId(), configurationPoint);
     }
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/RegistryDefinition.java
Mon Sep 18 14:35:13 2006
@@ -9,6 +9,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.Occurances;
 import org.apache.hivemind.impl.DefaultErrorHandler;
@@ -46,15 +47,16 @@
         _errorHandler = errorHandler;
     }
 
-    public void addModule(ModuleDefinition module)
+    /**
+     * Adds a module definition.
+     * @param module  the module 
+     * @throws ApplicationRuntimeException  if another module with the same id already exists.
+     */
+    public void addModule(ModuleDefinition module) throws ApplicationRuntimeException
     {
         if (_modules.containsKey(module.getId()))
         {
-            ModuleDefinition existing = (ModuleDefinition) _modules.get(module.getId());
-
-            _errorHandler.error(LOG, DefinitionMessages.duplicateModuleId(module.getId(),
existing
-                    .getLocation(), module.getLocation()), null, null);
-
+            throw new ApplicationRuntimeException(DefinitionMessages.duplicateModuleId(module.getId()));
         }
         else
         {
@@ -144,7 +146,7 @@
         }
     }
 
-    public void resolveImplementations(ModuleDefinition module)
+    private void resolveImplementations(ModuleDefinition module)
     {
         for (Iterator iter = module.getImplementations().iterator(); iter.hasNext();)
         {
@@ -167,7 +169,7 @@
         }
     }
     
-    public void resolveInterceptors(ModuleDefinition module)
+    private void resolveInterceptors(ModuleDefinition module)
     {
         for (Iterator iter = module.getInterceptors().iterator(); iter.hasNext();)
         {
@@ -190,7 +192,7 @@
         }
     }
     
-    public void resolveContributions(ModuleDefinition module)
+    private void resolveContributions(ModuleDefinition module)
     {
         for (Iterator iter = module.getContributions().iterator(); iter.hasNext();)
         {

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
Mon Sep 18 14:35:13 2006
@@ -93,7 +93,7 @@
 
         addInterfaceSynthesizer(md);
         
-        addServiceModuleConfiguration();
+        addServiceModelConfiguration();
     }
 
     /**
@@ -301,7 +301,7 @@
     /**
      * Defines service models, providing a name and a class for each.
      */
-    private void addServiceModuleConfiguration()
+    private void addServiceModelConfiguration()
     {
 
         ConfigurationPointDefinition cpd = helper.addConfigurationPoint("ServiceModels",


Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
Mon Sep 18 14:35:13 2006
@@ -119,11 +119,6 @@
                 locationOfDuplicate.getResource());
     }
 
-    static String duplicateExtensionPointId(String pointId, ExtensionPoint existingPoint)
-    {
-        return _formatter.format("duplicate-extension-point", pointId, existingPoint.getLocation());
-    }
-
     static String missingService(ServicePoint point)
     {
         return _formatter.format("missing-service", point.getExtensionPointId());

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
Mon Sep 18 14:35:13 2006
@@ -27,7 +27,6 @@
 unable-to-read-messages=Unable to read message properties from {0}.
 unable-to-parse=Unable to parse module deployment descriptor {0}: {1}
 duplicate-module-id=Module {0} is duplicated!  Definition in {2} has been ignored in favor
of existing definition from {1}.
-duplicate-extension-point=Extension point {0} conflicts with definition at {1} and 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.  
 

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
Mon Sep 18 14:35:13 2006
@@ -14,10 +14,10 @@
 
 package hivemind.test;
 
-import java.util.List;
-
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.RegistryDefinition;
 import org.apache.hivemind.impl.RegistryBuilder;
 import org.apache.hivemind.service.ClassFactory;
 
@@ -44,14 +44,16 @@
     {
         String duplicateModuleId = "non.unique.module";
 
-        ModuleDefinition firstModule = createModuleDefinition(duplicateModuleId);
-        ModuleDefinition duplicateModule = createModuleDefinition(duplicateModuleId);
-
-        interceptLogging();
-
-        buildFrameworkRegistry(new ModuleDefinition[] {firstModule, duplicateModule});
-
-        assertLoggedMessagePattern("Module " + duplicateModuleId + " is duplicated!");
+        RegistryDefinition registryDefinition = new RegistryDefinition();
+        registryDefinition.addModule(createModuleDefinition(duplicateModuleId));
+        try
+        {
+            registryDefinition.addModule(createModuleDefinition(duplicateModuleId));
+            fail("Duplicate module id not detected");
+        }
+        catch (RuntimeException expected)
+        {
+        }
     }
 
     public void testDuplicateExtensionPoints() throws Exception
@@ -59,20 +61,23 @@
         ModuleDefinition testModule = createModuleDefinition("hivemind.test");
 
         testModule.addServicePoint(createServicePointDefinition("MyService", Comparable.class));
-        testModule.addServicePoint(createServicePointDefinition("MyService", Comparable.class));
+        try
+        {
+            testModule.addServicePoint(createServicePointDefinition("MyService", Comparable.class));
+            fail("duplicate service point not detected");
+        }
+        catch (ApplicationRuntimeException expected)
+        {
+        }
 
         testModule.addConfigurationPoint(createConfigurationPointDefinition("MyConfig"));
-        testModule.addConfigurationPoint(createConfigurationPointDefinition("MyConfig"));
-
-        interceptLogging();
-
-        buildFrameworkRegistry(new ModuleDefinition[] {testModule});
-
-        List interceptedEvents = getInterceptedLogEvents();
-
-        assertLoggedMessagePattern("Extension point hivemind\\.test\\.MyService "
-                + "conflicts with definition at .* and has been ignored\\.", interceptedEvents);
-        assertLoggedMessagePattern("Extension point hivemind\\.test\\.MyConfig "
-                + "conflicts with definition at .* and has been ignored\\.", interceptedEvents);
+        try
+        {
+            testModule.addConfigurationPoint(createConfigurationPointDefinition("MyConfig"));
+            fail("duplicate configuration point not detected");
+        }
+        catch (ApplicationRuntimeException expected)
+        {
+        }
     }
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
Mon Sep 18 14:35:13 2006
@@ -36,15 +36,10 @@
     {
         XmlModuleReader xmlModuleReader = new XmlModuleReader(registryDefinition, _classResolver,
                 errorHandler);
-        findModules(xmlModuleReader);
-    }
-    
-    private void findModules(XmlModuleReader xmlModuleReader)
-    {
         if (LOG.isDebugEnabled())
             LOG.debug("Processing modules visible to " + _classResolver);
 
         xmlModuleReader.readClassPathModules(_resourcePath);
     }
-
+    
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/natures/XmlRegistryNature.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/natures/XmlRegistryNature.java?view=diff&rev=447576&r1=447575&r2=447576
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/natures/XmlRegistryNature.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/natures/XmlRegistryNature.java
Mon Sep 18 14:35:13 2006
@@ -1,5 +1,6 @@
 package org.apache.hivemind.impl.natures;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -49,6 +50,11 @@
     public Schema getSchema(String qualifiedSchemaId)
     {
         return (Schema) _schemas.get(qualifiedSchemaId);
+    }
+    
+    public Collection getSchemas()
+    {
+        return _schemas.values();
     }
 
     public void setRegistry(RegistryInfrastructure registry)



Mime
View raw message