hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r468311 - in /hivemind/branches/branch-2-0-annot: framework/src/java/org/apache/hivemind/definition/construction/ framework/src/java/org/apache/hivemind/impl/ framework/src/test/org/apache/hivemind/ xml/src/test/hivemind/test/config/ xml/sr...
Date Fri, 27 Oct 2006 08:05:24 GMT
Author: ahuegen
Date: Fri Oct 27 01:05:23 2006
New Revision: 468311

URL: http://svn.apache.org/viewvc?view=rev&rev=468311
Log:
improved documentation and error handling

Added:
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestToString.java
Modified:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/InterceptorConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.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/java/org/apache/hivemind/impl/RegistryBuilder.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestConfigurationPoint.java
    hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/ConfigurationConstructor.java
Fri Oct 27 01:05:23 2006
@@ -26,6 +26,8 @@
 {
     /**
      * Creates a new configuration container.
+     * The type of the returned object must be compatible to the type of the
+     * configuration this constructor belongs to.
      */
     public Object constructConfigurationContainer(ConfigurationConstructionContext context);
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/InterceptorConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/InterceptorConstructor.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/InterceptorConstructor.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/construction/InterceptorConstructor.java
Fri Oct 27 01:05:23 2006
@@ -28,7 +28,6 @@
 {
     /**
      * Creates a new core service implementation.
-     * @param interceptedMethods TODO
      */
     public void constructServiceInterceptor(InterceptorStack interceptorStack, Module contributingModule);
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ConfigurationPointImpl.java
Fri Oct 27 01:05:23 2006
@@ -60,8 +60,6 @@
 
     private Occurances _expectedCount;
 
-    private List _contributions;
-
     private boolean _building;
 
     private ShutdownCoordinator _shutdownCoordinator;
@@ -78,8 +76,8 @@
     
     protected void extendDescription(ToStringBuilder builder)
     {
+        builder.append("type", getContainerClassName());
         builder.append("expectedCount", _expectedCount);
-        builder.append("contributions", _contributions);
     }
     
     public List getContributions()
@@ -106,6 +104,9 @@
         return getConfigurationPointDefinition().getExpectedContributions();
     }
 
+    /**
+     * @return true if configuration should be create lazy, that means a proxy must be created.
+     */
     public boolean isLazy()
     {
         // TODO annotations: make configurable
@@ -185,17 +186,17 @@
         if (LOG.isDebugEnabled())
             LOG.debug("Constructing extension point " + getExtensionPointId());
 
-        List _contributions = getContributions();
+        List contributions = getContributions();
         
         int count = 0;
-        if (_contributions != null)
-            count = _contributions.size();
+        if (contributions != null)
+            count = contributions.size();
 
         try
         {
             for (int i = 0; i < count; i++)
             {
-                ContributionDefinition cd = (ContributionDefinition) _contributions.get(i);
+                ContributionDefinition cd = (ContributionDefinition) contributions.get(i);
                 Module definingModule = getModule().getRegistry().getModule(cd.getModuleId());
                 ContributionConstructionContext context = new ConfigurationConstructionContextImpl(definingModule,
this);
                 cd.getContributionConstructor().contribute(context, _container);
@@ -208,12 +209,6 @@
                     ex), ex);
         }
 
-        // After constructing the result, if the result
-        // will be cached, then there's no need to keep
-        // the extensions (used to build the
-        // result); it can all be released to the GC.
-
-        _contributions = null;
     }
     
     private Class lookupContainerClass()

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=468311&r1=468310&r2=468311
==============================================================================
--- 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
Fri Oct 27 01:05:23 2006
@@ -22,6 +22,7 @@
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Resource;
 import org.apache.hivemind.definition.ServiceInterceptorDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
 import org.apache.hivemind.events.RegistryShutdownListener;
 import org.apache.hivemind.internal.ConfigurationPoint;
 import org.apache.hivemind.internal.Module;
@@ -265,5 +266,10 @@
     public static String providerWrongType(String providerClassName, Class requiredInterface)
     {
         return _formatter.format("provider-wrong-type", providerClassName, requiredInterface.getName());
+    }
+
+    public static String servicePointDefinitionWithoutImplementation(ServicePointDefinition
sd)
+    {
+        return _formatter.format("servicepointdefinition-without-implementation", sd.getFullyQualifiedId());
     }
 }

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=468311&r1=468310&r2=468311
==============================================================================
--- 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
Fri Oct 27 01:05:23 2006
@@ -58,3 +58,5 @@
 unable-to-read-manifest=Unable to read manifest file {0}: {1}
 unable-to-create-provider=Unable to create provider of type {0}: {1}
 provider-wrong-type=Registry provider class {0} must implement interface {1}
+
+servicepointdefinition-without-implementation=Definition of service point {0} contains no
implementation definition

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
Fri Oct 27 01:05:23 2006
@@ -85,6 +85,7 @@
     public RegistryBuilder()
     {
         this(new DefaultErrorHandler());
+        _registryDefinition = new RegistryDefinition();
     }
     
     public RegistryBuilder(RegistryDefinition registryDefinition)
@@ -105,50 +106,39 @@
 
     public RegistryDefinition getRegistryDefinition()
     {
-        if (_registryDefinition == null) {
-            _registryDefinition = new RegistryDefinition();
-        }
         return _registryDefinition;
     }
     
     /**
-     * This first loads all modules provided by the ModuleDescriptorProvider, then resolves
all the
-     * contributions, then constructs and returns the Registry.
+     * Constructs the registry from its {@link RegistryDefinition}.
      */
     public Registry constructRegistry(Locale locale)
     {
-        RegistryDefinition definition = getRegistryDefinition();
-        return constructRegistry(definition, _errorHandler, locale);
-    }
-    
-    public Registry constructRegistry(RegistryDefinition definition, ErrorHandler errorHandler,
-            Locale locale)
-    {
         // Add Core HiveMind services like ClassFactory
         CoreServicesProvider coreServicesProvider = new CoreServicesProvider();
-        coreServicesProvider.process(definition, errorHandler);
+        coreServicesProvider.process(_registryDefinition, _errorHandler);
         
         // Try to resolve all so far unresolved extensions
-        ExtensionResolver extensionResolver = new ExtensionResolver(errorHandler, definition);
+        ExtensionResolver extensionResolver = new ExtensionResolver(_errorHandler, _registryDefinition);
         extensionResolver.resolveExtensions();
         
-        checkDependencies(definition);
-        checkContributionCounts(definition);
+        checkDependencies(_registryDefinition);
+        checkContributionCounts(_registryDefinition);
         
         // Notify post processors
-        for (Iterator i = definition.getPostProcessors().iterator(); i.hasNext();)
+        for (Iterator i = _registryDefinition.getPostProcessors().iterator(); i.hasNext();)
         {
             RegistryPostProcessor processor = (RegistryPostProcessor) i.next();
 
-            processor.postprocess(definition, errorHandler);
+            processor.postprocess(_registryDefinition, _errorHandler);
         }
 
-        RegistryInfrastructureConstructor constructor = new RegistryInfrastructureConstructor(errorHandler,
LOG, locale);
+        RegistryInfrastructureConstructor constructor = new RegistryInfrastructureConstructor(_errorHandler,
LOG, locale);
         RegistryInfrastructure infrastructure = constructor
-                .constructRegistryInfrastructure(definition);
+                .constructRegistryInfrastructure(_registryDefinition);
 
         // Notify initialization listeners
-        for (Iterator i = definition.getRegistryInitializationListeners().iterator(); i.hasNext();)
+        for (Iterator i = _registryDefinition.getRegistryInitializationListeners().iterator();
i.hasNext();)
         {
             RegistryInitializationListener listener = (RegistryInitializationListener) i.next();
 
@@ -158,6 +148,16 @@
         infrastructure.startup();
 
         return new RegistryImpl(infrastructure);
+    }
+    
+    /**
+     * Constructs the registry from a specified {@link RegistryDefinition}.
+     */
+    public static Registry constructRegistry(RegistryDefinition definition, ErrorHandler
errorHandler,
+            Locale locale)
+    {
+        RegistryBuilder builder = new RegistryBuilder(definition, errorHandler);
+        return builder.constructRegistry(locale);
     }
 
     private void checkDependencies(RegistryDefinition definition)

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/RegistryInfrastructureConstructor.java
Fri Oct 27 01:05:23 2006
@@ -21,6 +21,7 @@
 import java.util.Map.Entry;
 
 import org.apache.commons.logging.Log;
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.ShutdownCoordinator;
 import org.apache.hivemind.definition.ConfigurationPointDefinition;
@@ -197,7 +198,7 @@
         ServiceImplementationDefinition impl = sd.getDefaultImplementation();
 
         if (impl == null) {
-            // TODO annotations: error ?
+            throw new ApplicationRuntimeException(ImplMessages.servicePointDefinitionWithoutImplementation(sd));
         } else {
             if (_log.isDebugEnabled())
                 _log.debug("Adding implementation to service extension point " + point.getExtensionPointId());

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/ServicePointImpl.java
Fri Oct 27 01:05:23 2006
@@ -72,9 +72,8 @@
             builder.append("service", _service);
 
         builder.append("serviceInterfaceName", getServiceInterfaceClassName());
-        builder.append("serviceConstructor", getServiceConstructor());
-        builder.append("interceptorDefinitions", getInterceptorDefinitions());
         builder.append("serviceModel", getServiceModel());
+        builder.append("interceptorDefinitions", getInterceptorDefinitions());
 
         if (_building)
             builder.append("building", _building);
@@ -96,23 +95,13 @@
         return _declaredInterface;
     }
 
-    /** @since 1.1 */
-
     public String getServiceInterfaceClassName()
     {
-        // TODO: For toString tests. Remove?
-        if (getServicePointDefinition() == null)
-            return null;
-        
         return getServicePointDefinition().getInterfaceClassName();
     }
 
     private Object getInterceptorDefinitions()
     {
-        // TODO: For toString tests. Remove?
-        if (getServicePointDefinition() == null)
-            return null;
-
         return getServicePointDefinition().getInterceptors();
     }
 
@@ -295,10 +284,6 @@
 
     public ImplementationConstructor getServiceConstructor()
     {
-        // TODO: For toString tests. Remove?
-        if (getServicePointDefinition() == null)
-            return null;
-
         return getImplementationDefinition().getServiceConstructor();
     }
 

Added: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestToString.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestToString.java?view=auto&rev=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestToString.java
(added)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestToString.java
Fri Oct 27 01:05:23 2006
@@ -0,0 +1,62 @@
+// Copyright 2004, 2005 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;
+
+import hivemind.test.FrameworkTestCase;
+
+import java.util.Locale;
+
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServiceImplementationDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.impl.InterceptorStackImpl;
+import org.apache.hivemind.impl.ModuleImpl;
+import org.apache.hivemind.impl.RegistryInfrastructureImpl;
+import org.apache.hivemind.impl.ServicePointImpl;
+import org.apache.hivemind.internal.ServiceModel;
+import org.apache.hivemind.internal.ServicePoint;
+import org.apache.hivemind.internal.Visibility;
+import org.easymock.MockControl;
+
+/**
+ * A cheat, for code-coverage reasons.  We check that all the classes have a toString()
+ * method.
+ *
+ * @author Howard Lewis Ship
+ */
+
+public class TestToString extends FrameworkTestCase
+{
+
+    public void testToString()
+    {
+        MockControl control = MockControl.createControl(ServicePoint.class);
+        ServicePoint mockServicePoint = (ServicePoint) control.getMock();
+
+        ModuleImpl module = new ModuleImpl();
+        module.setModuleId("module");
+        module.toString();
+        new RegistryInfrastructureImpl(null, Locale.ENGLISH).toString();
+        new InterceptorStackImpl(null, mockServicePoint, null).toString();
+
+        ModuleDefinition md = new ModuleDefinition("module", null, null, null);
+        ServicePointDefinition spd = new ServicePointDefinition(md, "service", null,
+                Visibility.PUBLIC, Runnable.class.getName());
+        ServiceImplementationDefinition sid = new ServiceImplementationDefinition(md, 
+                null, null, ServiceModel.PRIMITIVE, true);
+        spd.addImplementation(sid);
+        new ServicePointImpl(module, spd).toString();
+    }
+}

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestConfigurationPoint.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestConfigurationPoint.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestConfigurationPoint.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestConfigurationPoint.java
Fri Oct 27 01:05:23 2006
@@ -363,10 +363,9 @@
     {
         Registry r = buildFrameworkRegistry("BadAttributes.xml");
 
+        List l = (List) r.getConfiguration("hivemind.test.config.BadAttributes");
         try
         {
-            // TODO annotations: move before try block when config proxies are established
again
-            List l = (List) r.getConfiguration("hivemind.test.config.BadAttributes");
             l.size();
 
             unreachable();

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java?view=diff&rev=468311&r1=468310&r2=468311
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/parse/TestToString.java
Fri Oct 27 01:05:23 2006
@@ -16,15 +16,9 @@
 
 import hivemind.test.FrameworkTestCase;
 
-import java.util.Locale;
-
 import org.apache.hivemind.impl.AttributeImpl;
 import org.apache.hivemind.impl.DefaultErrorHandler;
 import org.apache.hivemind.impl.ElementImpl;
-import org.apache.hivemind.impl.InterceptorStackImpl;
-import org.apache.hivemind.impl.ModuleImpl;
-import org.apache.hivemind.impl.RegistryInfrastructureImpl;
-import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.parse.ConfigurationPointDescriptor;
 import org.apache.hivemind.parse.ContributionDescriptor;
 import org.apache.hivemind.parse.CreateInstanceDescriptor;
@@ -35,7 +29,6 @@
 import org.apache.hivemind.parse.ModuleDescriptor;
 import org.apache.hivemind.parse.ServicePointDescriptor;
 import org.apache.hivemind.parse.SubModuleDescriptor;
-import org.easymock.MockControl;
 
 /**
  * A cheat, for code-coverage reasons.  We check that all the classes have a toString()
@@ -49,9 +42,6 @@
 
     public void testToString()
     {
-        MockControl control = MockControl.createControl(ServicePoint.class);
-        ServicePoint mockServicePoint = (ServicePoint) control.getMock();
-
         new ConfigurationPointDescriptor().toString();
         new ContributionDescriptor().toString();
         new ImplementationDescriptor().toString();
@@ -62,10 +52,7 @@
         new DependencyDescriptor().toString();
         new ServicePointDescriptor().toString();
         new InterceptorDescriptor().toString();
-        new ModuleImpl().toString();
-        new RegistryInfrastructureImpl(null, Locale.ENGLISH).toString();
         new ElementImpl().toString();
         new AttributeImpl("foo", "bar").toString();
-        new InterceptorStackImpl(null, mockServicePoint, null).toString();
     }
 }



Mime
View raw message