Return-Path: Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 50676 invoked by uid 500); 24 Aug 2003 03:28:49 -0000 Received: (qmail 50670 invoked from network); 24 Aug 2003 03:28:49 -0000 Received: from minotaur.apache.org (209.237.227.194) by daedalus.apache.org with SMTP; 24 Aug 2003 03:28:49 -0000 Received: (qmail 89362 invoked by uid 1616); 24 Aug 2003 03:28:30 -0000 Date: 24 Aug 2003 03:28:30 -0000 Message-ID: <20030824032830.89361.qmail@minotaur.apache.org> From: hlship@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/hivemind/src/xsl hivemind.xsl X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N hlship 2003/08/23 20:28:30 Modified: hivemind/src/java/org/apache/commons/hivemind/parse ServiceDescriptor.java DescriptorParser.java hivemind/src/java/org/apache/commons/hivemind HiveMindMessages.properties hivemind/xdocs descriptor.xml extension-points.xml services.xml hivemind/src/test/hivemind/test/parse TestDescriptorParser.java hivemind/src/java/org/apache/commons/hivemind/impl ServiceExtensionPointImpl.java RegistryBuilder.java hivemind/src/xsl hivemind.xsl Log: Remove the required attribute from the element; all services are now required. Revision Changes Path 1.10 +1 -13 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ServiceDescriptor.java Index: ServiceDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ServiceDescriptor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ServiceDescriptor.java 23 Aug 2003 22:46:03 -0000 1.9 +++ ServiceDescriptor.java 24 Aug 2003 03:28:29 -0000 1.10 @@ -72,7 +72,6 @@ { private String _id; private String _interfaceClassName; - private boolean _required = true; private Schema _parametersSchema; private ServiceModel _model = ServiceModel.DEFERRED; @@ -86,11 +85,6 @@ return _interfaceClassName; } - public boolean isRequired() - { - return _required; - } - public void setId(String string) { _id = string; @@ -101,16 +95,10 @@ _interfaceClassName = string; } - public void setRequired(boolean b) - { - _required = b; - } - protected void extendDescription(ToStringBuilder builder) { builder.append("id", _id); builder.append("interfaceClassName", _interfaceClassName); - builder.append("required", _required); builder.append("model", _model); builder.append("parametersSchema", _parametersSchema); } 1.28 +1 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java Index: DescriptorParser.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- DescriptorParser.java 23 Aug 2003 22:46:03 -0000 1.27 +++ DescriptorParser.java 24 Aug 2003 03:28:29 -0000 1.28 @@ -211,7 +211,6 @@ static { SERVICE_ATTRIBUTES.put("id", Boolean.TRUE); SERVICE_ATTRIBUTES.put("interface", Boolean.TRUE); - SERVICE_ATTRIBUTES.put("required", Boolean.FALSE); SERVICE_ATTRIBUTES.put("model", Boolean.FALSE); } @@ -895,7 +894,6 @@ sd.setId(getAttribute("id")); sd.setInterfaceClassName(getAttribute("interface")); - sd.setRequired(getBooleanAttribute("required", true)); ServiceModel model = (ServiceModel) getEnumAttribute("model", MODEL_MAP); 1.25 +2 -3 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties Index: HiveMindMessages.properties =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- HiveMindMessages.properties 21 Aug 2003 20:07:47 -0000 1.24 +++ HiveMindMessages.properties 24 Aug 2003 03:28:29 -0000 1.25 @@ -28,7 +28,6 @@ ExtensionPointImpl.element-is-null=Module {0} has contributed a null element to configuration extension point {1} (at {2}). The contribution has been ignored. ExtensionPointImpl.recursive-configuration=A recursive call to construct configuration {0} has occured. This indicates a cycle between one or more configurations or services. -ServiceExtensionPoint.request-for-missing-service=Unable to provide required service {0} because no module contributed a factory. ServiceExtensionPoint.unable-to-construct-service=Unable to construct service {0}: {1} ServiceExtensionPoint.factory-returned-null=Instance factory for service {0} returned null. ServiceExtensionPoint.factory-wrong-interface=Instance factory for service {0} returned {1} which does not implement the {2} interface declared by the extension point. @@ -57,7 +56,7 @@ RegistryBuilder.duplicate-module-id=Module {0} is duplicated! Definition in {2} has been ignored in favor of existing definition from {1}. RegistryBuilder.unknown-service-extension-point=Module {0} contributes to unknown service extension point {1} (at {2}). The contribution has been ignored. RegistryBuilder.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. -RegistryBuilder.missing-service=No module has contributed a factory for service extension point {0}. +RegistryBuilder.missing-service=No module has contributed a service constructor for service extension point {0}. RegistryBuilder.unknown-configuration-extension-point=Module {0} has contributed to unknown configuration extension point {1} (at {2}). The contribution has been ignored. RegistryBuilder.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. RegistryBuilder.one-or-more=at least one 1.22 +2 -9 jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml Index: descriptor.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- descriptor.xml 23 Aug 2003 22:46:03 -0000 1.21 +++ descriptor.xml 24 Aug 2003 03:28:29 -0000 1.22 @@ -402,14 +402,7 @@ The fully qualified name of the Java interface supplied by this service extension point. - - required - boolean - no - If true (the default), then a factory contribution must be made to - the extension point. If false, then the service provided by the - extension point is optional. - + model deferred | singleton | threaded 1.6 +4 -2 jakarta-commons-sandbox/hivemind/xdocs/extension-points.xml Index: extension-points.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/extension-points.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- extension-points.xml 20 Aug 2003 20:40:45 -0000 1.5 +++ extension-points.xml 24 Aug 2003 03:28:30 -0000 1.6 @@ -249,8 +249,10 @@
  • Are the any default implementations of SymbolSource?

    - There is now an extension point for setting "factory defaults": + There is now an extension point for setting factory defaults: hivemind.FactoryDefaults. + A second extension point, for application defaults, overrides the factory defaults: + hivemind.ApplicationDefaults.

    1.19 +41 -24 jakarta-commons-sandbox/hivemind/xdocs/services.xml Index: services.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/services.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- services.xml 23 Aug 2003 22:46:03 -0000 1.18 +++ services.xml 24 Aug 2003 03:28:30 -0000 1.19 @@ -15,9 +15,10 @@ interface. You supply the interface (in a module). You supply the core implementation of the interface (in the same module, or in a different module). At runtime, HiveMind puts it all together.

    -

    HiveMind uses two service models: singleton and pooled. In the singleton model, - each service will ultimately be just a single object instance. In the pooled model, - there may be many instances simulataneously.

    +

    HiveMind uses three service models: singleton, deferred and threaded. In the singleton and + deferred models, + each service will ultimately be just a single object instance. In the threaded model, + there may be many instances simultaneously, one for each thread.

    A service definition begins with a Java interface. Any interface will @@ -28,8 +29,7 @@

    Each &_service; establishes an - id for the service, defines the interface for the service, and indicates - whether the service is optional or required (required is the default). + id for the service and defines the interface for the service. An example is provided later in this document.

    @@ -57,7 +57,7 @@ Contributions take three forms:

      -
    • Implementation constructors: +
    • Service constructors:
      • &create-instance; to instantiate an instance of a Java class
      • &invoke-factory; to have another service create the implementation
      • @@ -68,10 +68,10 @@

        - -

        An implementation constructor is used to instantiate a Java class as the + +

        An service constructor is used to instantiate a Java class as the core implementation instance for the service.

        -

        There are two forms of implementation constructors: +

        There are two forms of service constructors: instance creators and implementation factories.

        An instance creator is represented by a &create-instance; element. It @@ -141,8 +141,6 @@ whatever interface is defined by the service extension point it will create an instance for.

        -

        Interceptor factories can be implemented using dynamic proxies (a - feature introduced in JDK 1.3), or by dynamic bytecode enhancement.

        A service extension point may have any number of interceptor contributions. If the order in which interceptors are applied is @@ -265,6 +263,21 @@ knows nor cares about this.

    +
    + +

    + The simplest service model is the singleton service model; in this model + the service is constructed on first reference. This is appropriate for + services such as service factories and interceptor factories, and for + several of the basic services provided in the + hivemind module. +

    + + + +
    + +

    @@ -277,7 +290,7 @@

    - To resolve this, HiveMind defers the actual creation of services by default This + To resolve this, HiveMind defers the actual creation of services by default. This is controled by the model attribute of the &service; element; the default model is deferred.

    @@ -321,7 +334,7 @@

    The service implementation is discarded when notified to cleanup; this is controlled by the hivemind.ThreadEventNotifier service. -If your application has any threaded service, you are responsible for invoking the fireThreadCleanup() +If your application has any threaded services, you are responsible for invoking the fireThreadCleanup() method of the service.

    @@ -329,7 +342,7 @@ For example, a servlet application may want to add the following:

    - + public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { @@ -343,7 +356,13 @@ } } - + + +

    +You'll, of course, have to fill in the details, such as the implementation of +getThreadEventNotifier(). Presumably, your servlet constructs +a HiveMind registry from its init() method. +

    @@ -361,14 +380,12 @@
  • What if no module provides a core implementation of the service? -

    If the service is optional, then getService() will return null. For - optional services, you are required to check for null.

    -

    For required services, HiveMind checks for an implementation constructor - when the registry itself is assembled. If a required service extension - point has no implementation constructor, an error is logged (identifying the - extension point id). In addition, getService() will throw an - ApplicationRuntimeException. So, if a service is required, you don't - have to check for null.

    + +

    HiveMind checks for a service constructor + when the registry itself is assembled. If a service extension + point has no service constructor, an error is logged (identifying the + extension point id). In addition, getService() will throw an + ApplicationRuntimeException.

  • 1.22 +1 -2 jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java Index: TestDescriptorParser.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- TestDescriptorParser.java 21 Aug 2003 20:07:47 -0000 1.21 +++ TestDescriptorParser.java 24 Aug 2003 03:28:30 -0000 1.22 @@ -205,7 +205,6 @@ assertEquals("MyService1", sd.getId()); assertEquals("package.MyService", sd.getInterfaceClassName()); - assertEquals(true, sd.isRequired()); CreateInstanceDescriptor cid = (CreateInstanceDescriptor) sd.getInstanceBuilder(); assertEquals("package.impl.MyServiceImpl", cid.getInstanceClassName()); 1.12 +1 -28 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java Index: ServiceExtensionPointImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ServiceExtensionPointImpl.java 23 Aug 2003 22:46:03 -0000 1.11 +++ ServiceExtensionPointImpl.java 24 Aug 2003 03:28:30 -0000 1.12 @@ -88,7 +88,6 @@ private Class _serviceInterface; private ServiceImplementationConstructor _serviceConstructor; private List _interceptorContributions; - private boolean _required; private boolean _building; private Schema _parametersSchema; private Object _constructedService; @@ -97,7 +96,6 @@ protected void extendDescription(ToStringBuilder builder) { builder.append("serviceInterfaceName", _serviceInterfaceName); - builder.append("required", _required); builder.append("factoryContribution", _serviceConstructor); builder.append("interceptorContributions", _interceptorContributions); builder.append("parametersSchema", _parametersSchema); @@ -163,16 +161,6 @@ _serviceInterfaceName = string; } - public boolean isRequired() - { - return _required; - } - - public void setRequired(boolean b) - { - _required = b; - } - public synchronized void addInterceptorContribution(ServiceInterceptorContribution contribution) { if (_interceptorContributions == null) @@ -236,21 +224,6 @@ */ protected Object constructNewServiceImplementation() { - if (_serviceConstructor == null) - { - // If the service is required but there's no factory, then throw - // an exception. The calling code probably doesn't check for null (since - // the service is required), so better an ARE here than an NPE there. - - if (_required) - throw new ApplicationRuntimeException( - HiveMind.format( - "ServiceExtensionPoint.request-for-missing-service", - getExtensionPointId())); - - return null; - } - try { Class serviceType = getServiceInterface(); 1.25 +5 -15 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java Index: RegistryBuilder.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- RegistryBuilder.java 23 Aug 2003 22:46:03 -0000 1.24 +++ RegistryBuilder.java 24 Aug 2003 03:28:30 -0000 1.25 @@ -138,12 +138,6 @@ private Map _servicePoints = new HashMap(); /** - * List of {@link ServiceExtensionPointImpl} of just the required points. - */ - - private List _requiredServices = new ArrayList(); - - /** * Map of {@link ExtensionPointImpl} keyed on fully qualified id. */ @@ -347,7 +341,6 @@ point.setExtensionPointId(pointId); point.setLocation(sd.getLocation()); point.setModule(module); - point.setRequired(sd.isRequired()); point.setServiceInterfaceName(sd.getInterfaceClassName()); point.setParametersSchema(sd.getParametersSchema()); @@ -359,9 +352,6 @@ _servicePoints.put(pointId, point); - if (point.isRequired()) - _requiredServices.add(point); - addInternalServiceContributions(module, pointId, sd); } } @@ -655,14 +645,14 @@ } /** - * Checks that each required service has at factory contribution. + * Checks that each service has at service constructor. */ private void checkForMissingServices() { - int count = _requiredServices.size(); - for (int i = 0; i < count; i++) + Iterator i = _servicePoints.values().iterator(); + while (i.hasNext()) { - ServiceExtensionPointImpl point = (ServiceExtensionPointImpl) _requiredServices.get(i); + ServiceExtensionPointImpl point = (ServiceExtensionPointImpl) i.next(); if (point.getServiceConstructor() != null) continue; 1.17 +1 -8 jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl Index: hivemind.xsl =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- hivemind.xsl 23 Aug 2003 22:46:04 -0000 1.16 +++ hivemind.xsl 24 Aug 2003 03:28:30 -0000 1.17 @@ -377,13 +377,6 @@ - Required - - true - - - - Service Model singleton