commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl NameLookupImpl.java
Date Fri, 05 Sep 2003 15:04:41 GMT
hlship      2003/09/05 08:04:41

  Modified:    hivemind/src/java/org/apache/commons/hivemind/schema/rules
                        ExtensionPointTranslator.java
                        ServiceTranslator.java ClassTranslator.java
                        EnumerationTranslator.java BooleanTranslator.java
                        RuleUtils.java IntTranslator.java
               hivemind/src/java/org/apache/commons/hivemind/impl
                        InterceptorStackImpl.java
                        InvokeFactoryServiceConstructor.java
               hivemind/src/java/org/apache/commons/hivemind
                        HiveMindMessages.properties
               hivemind/src/java/org/apache/commons/hivemind/util
                        LocalizedNameGenerator.java
               hivemind/src/test/hivemind/test/config
                        ToUpperCaseTranslator.java
               hivemind/src/test/hivemind/test/services StringHolder.xml
               hivemind/src/java/org/apache/commons/hivemind/service/impl
                        NameLookupImpl.java
  Log:
  Improve efficiency when a interceptor or instance factory is re-invoked.
  Remove unneeded null service checks.
  Convert from StringUtils.isEmpty() to StringUtils.isBlank() (because of commons-lang 2.0).
  
  Revision  Changes    Path
  1.3       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ExtensionPointTranslator.java
  
  Index: ExtensionPointTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ExtensionPointTranslator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtensionPointTranslator.java	30 Aug 2003 14:29:53 -0000	1.2
  +++ ExtensionPointTranslator.java	5 Sep 2003 15:04:41 -0000	1.3
  @@ -80,7 +80,7 @@
   
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return null;
   
           Module module = processor.getContributingModule();
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ServiceTranslator.java
  
  Index: ServiceTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ServiceTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServiceTranslator.java	30 Aug 2003 14:29:53 -0000	1.3
  +++ ServiceTranslator.java	5 Sep 2003 15:04:41 -0000	1.4
  @@ -83,7 +83,7 @@
        */
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return null;
   
           Module module = processor.getContributingModule();
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ClassTranslator.java
  
  Index: ClassTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/ClassTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassTranslator.java	30 Aug 2003 14:29:53 -0000	1.3
  +++ ClassTranslator.java	5 Sep 2003 15:04:41 -0000	1.4
  @@ -83,7 +83,7 @@
        */
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return null;
   
           try
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/EnumerationTranslator.java
  
  Index: EnumerationTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/EnumerationTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EnumerationTranslator.java	30 Aug 2003 14:29:53 -0000	1.3
  +++ EnumerationTranslator.java	5 Sep 2003 15:04:41 -0000	1.4
  @@ -109,7 +109,7 @@
   
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return null;
   
           Class c = getClass(processor);
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/BooleanTranslator.java
  
  Index: BooleanTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/BooleanTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BooleanTranslator.java	30 Aug 2003 14:29:53 -0000	1.3
  +++ BooleanTranslator.java	5 Sep 2003 15:04:41 -0000	1.4
  @@ -102,7 +102,7 @@
       
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return _defaultValue;
   
           if (inputValue.equals("true"))
  
  
  
  1.5       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/RuleUtils.java
  
  Index: RuleUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/RuleUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RuleUtils.java	30 Aug 2003 14:29:53 -0000	1.4
  +++ RuleUtils.java	5 Sep 2003 15:04:41 -0000	1.5
  @@ -90,7 +90,7 @@
        */
       public static Map convertInitializer(String initializer)
       {
  -        if (StringUtils.isEmpty(initializer))
  +        if (StringUtils.isBlank(initializer))
               return Collections.EMPTY_MAP;
   
           Map result = new HashMap();
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/IntTranslator.java
  
  Index: IntTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/schema/rules/IntTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IntTranslator.java	30 Aug 2003 14:29:53 -0000	1.3
  +++ IntTranslator.java	5 Sep 2003 15:04:41 -0000	1.4
  @@ -124,7 +124,7 @@
        */
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return new Integer(_defaultValue);
   
           int value;
  
  
  
  1.5       +2 -12     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InterceptorStackImpl.java
  
  Index: InterceptorStackImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InterceptorStackImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InterceptorStackImpl.java	30 Aug 2003 14:29:51 -0000	1.4
  +++ InterceptorStackImpl.java	5 Sep 2003 15:04:41 -0000	1.5
  @@ -151,7 +151,7 @@
                       new Object[] {
                           interceptor,
                           _contribution.getFactoryId(),
  -						_sep.getExtensionPointId(),
  +                        _sep.getExtensionPointId(),
                           _interfaceClass.getName()}),
                   _contribution.getLocation(),
                   null);
  @@ -176,16 +176,6 @@
               (ServiceInterceptorFactory) _registry.getService(
                   factoryId,
                   ServiceInterceptorFactory.class);
  -
  -        if (factory == null)
  -        {
  -            LOG.error(
  -                HiveMind.format(
  -                    "InterceptorStack.null-factory",
  -                    factoryId,
  -                    _sep.getExtensionPointId()));
  -            return;
  -        }
   
           // And now we can finally do this!
   
  
  
  
  1.5       +27 -25    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InvokeFactoryServiceConstructor.java
  
  Index: InvokeFactoryServiceConstructor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InvokeFactoryServiceConstructor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InvokeFactoryServiceConstructor.java	30 Aug 2003 14:29:51 -0000	1.4
  +++ InvokeFactoryServiceConstructor.java	5 Sep 2003 15:04:41 -0000	1.5
  @@ -83,39 +83,46 @@
       private String _factoryServiceId;
       private ServiceExtensionPoint _serviceExtensionPoint;
       private Module _contributingModule;
  +
  +    /** List of {@link org.apache.commons.hivemind.Element}, the raw XML parameters. */
       private List _parameters;
   
  +    /** The factory service to be invoked. */
  +    private ServiceImplementationFactory _factory;
  +
  +    /** The parameters converted to objects as per the factory's parameter schema. */
  +    private List _convertedParameters;
  +
       public Object constructCoreServiceImplementation()
       {
  -        Registry registry = _contributingModule.getRegistry();
  +        if (_factory == null)
  +        {
  +            Registry registry = _contributingModule.getRegistry();
   
  -        String qualifiedFactoryId = HiveMind.qualify(_contributingModule, _factoryServiceId);
  +            String qualifiedFactoryId = HiveMind.qualify(_contributingModule, _factoryServiceId);
   
  -        String factoryModuleId = RegistryImpl.split(qualifiedFactoryId);
  -        Module factoryModule = registry.getModule(factoryModuleId);
  -        ServiceExtensionPoint factoryPoint =
  -            factoryModule.getServiceExtensionPoint(qualifiedFactoryId);
  +            String factoryModuleId = RegistryImpl.split(qualifiedFactoryId);
  +            Module factoryModule = registry.getModule(factoryModuleId);
  +            ServiceExtensionPoint factoryPoint =
  +                factoryModule.getServiceExtensionPoint(qualifiedFactoryId);
   
  -        ServiceImplementationFactory factory =
  -            (ServiceImplementationFactory) factoryPoint.getService(
  -                ServiceImplementationFactory.class);
  +            _factory =
  +                (ServiceImplementationFactory) factoryPoint.getService(
  +                    ServiceImplementationFactory.class);
   
  -        if (factory == null)
  -            throw new ApplicationRuntimeException(
  -                HiveMind.format("InvokeFactoryDescriptor.factory-is-null", qualifiedFactoryId),
  -                getLocation(),
  -                null);
  +            Schema schema = factoryPoint.getParametersSchema();
   
  -        Schema schema = factoryPoint.getParametersSchema();
  +            SchemaProcessorImpl processor = new SchemaProcessorImpl(schema);
   
  -        SchemaProcessorImpl processor = new SchemaProcessorImpl(schema);
  +            processor.process(_parameters, _contributingModule);
   
  -        processor.process(_parameters, _contributingModule);
  +            _convertedParameters = processor.getElements();
  +        }
   
  -        return factory.createCoreServiceImplementation(
  +        return _factory.createCoreServiceImplementation(
               _serviceExtensionPoint,
               _contributingModule,
  -            processor.getElements());
  +            _convertedParameters);
       }
   
       public Module getContributingModule()
  @@ -131,11 +138,6 @@
       public List getParameters()
       {
           return _parameters;
  -    }
  -
  -    public String getFactoryServiceId()
  -    {
  -        return _factoryServiceId;
       }
   
       public ServiceExtensionPoint getServiceExtensionPoint()
  
  
  
  1.26      +1 -6      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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- HiveMindMessages.properties	24 Aug 2003 03:28:29 -0000	1.25
  +++ HiveMindMessages.properties	5 Sep 2003 15:04:41 -0000	1.26
  @@ -67,7 +67,6 @@
   
   InterceptorStack.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.
   InterceptorStack.null-interceptor=Service {0} generated a null interceptor (for service
extension point {1}).
  -InterceptorStack.null-factory=Interceptor factory {0} (requested for service extension
point {1}) is null and is being skipped.
   
   MessagesImpl.unable-to-read=Unable to read message properties from {0}.
   
  @@ -92,10 +91,6 @@
   ClassFabImpl.unable-to-add-constructor=Unable to add constructor to class {0}: {1}
   
   MethodFabImpl.unable-to-add-catch=Unable to add catch block for exception {0} to class
{1}: {2}
  -
  -# parse package
  -
  -InvokeFactoryDescriptor.factory-is-null=Factory service {0} is null.
   
   # schema.rules package
   
  
  
  
  1.3       +5 -5      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/util/LocalizedNameGenerator.java
  
  Index: LocalizedNameGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/util/LocalizedNameGenerator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalizedNameGenerator.java	30 Aug 2003 14:29:56 -0000	1.2
  +++ LocalizedNameGenerator.java	5 Sep 2003 15:04:41 -0000	1.3
  @@ -125,14 +125,14 @@
               {
                   case LCV :
   
  -                    if (StringUtils.isEmpty(_variant))
  +                    if (StringUtils.isBlank(_variant))
                           continue;
   
                       return;
   
                   case LC :
   
  -                    if (StringUtils.isEmpty(_country))
  +                    if (StringUtils.isBlank(_country))
                           continue;
   
                       return;
  @@ -142,14 +142,14 @@
                       // If _country is null, then we've already generated this string
                       // as state LCV and we can continue directly to state L
                       
  -                    if (StringUtils.isEmpty(_variant) || StringUtils.isEmpty(_country))
  +                    if (StringUtils.isBlank(_variant) || StringUtils.isBlank(_country))
                           continue;
   
                       return;
   
                   case L :
   
  -                    if (StringUtils.isEmpty(_language))
  +                    if (StringUtils.isBlank(_language))
                           continue;
   
                       return;
  
  
  
  1.3       +2 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/ToUpperCaseTranslator.java
  
  Index: ToUpperCaseTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/ToUpperCaseTranslator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ToUpperCaseTranslator.java	30 Aug 2003 14:29:56 -0000	1.2
  +++ ToUpperCaseTranslator.java	5 Sep 2003 15:04:41 -0000	1.3
  @@ -73,7 +73,7 @@
   
       public Object translate(SchemaProcessor processor, Element element, String inputValue)
       {
  -        if (StringUtils.isEmpty(inputValue))
  +        if (StringUtils.isBlank(inputValue))
               return null;
   
           return inputValue.toUpperCase();
  
  
  
  1.2       +9 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/StringHolder.xml
  
  Index: StringHolder.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/StringHolder.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringHolder.xml	23 Aug 2003 22:46:03 -0000	1.1
  +++ StringHolder.xml	5 Sep 2003 15:04:41 -0000	1.2
  @@ -4,7 +4,14 @@
   	id="hivemind.test.services" 
   	version="0.0.1">
   	<service id="StringHolder" interface="hivemind.test.services.StringHolder" model="threaded">
  -	  <create-instance class="hivemind.test.services.impl.StringHolderImpl"/>
  +	  
  +	  <!-- Could just use create-instance, but looking for some code coverage instead
  +	  	   InvokeFactoryServiceConstructor -->
  +	  	   
  +	  <invoke-factory service-id="hivemind.BuilderFactory">
  +	  	<construct class="hivemind.test.services.impl.StringHolderImpl"/>	
  +	  </invoke-factory>
  +
   	  <interceptor service-id="hivemind.LoggingInterceptor"/>
   	</service>
   </module>
  
  
  
  1.6       +4 -4      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/NameLookupImpl.java
  
  Index: NameLookupImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/NameLookupImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NameLookupImpl.java	30 Aug 2003 14:29:54 -0000	1.5
  +++ NameLookupImpl.java	5 Sep 2003 15:04:41 -0000	1.6
  @@ -130,13 +130,13 @@
       {
           Hashtable properties = new Hashtable();
   
  -        if (!StringUtils.isEmpty(_initialFactory))
  +        if (!StringUtils.isBlank(_initialFactory))
               properties.put(Context.INITIAL_CONTEXT_FACTORY, _initialFactory);
   
  -        if (!StringUtils.isEmpty(_providerURL))
  +        if (!StringUtils.isBlank(_providerURL))
               properties.put(Context.PROVIDER_URL, _providerURL);
   
  -        if (!StringUtils.isEmpty(_URLPackages))
  +        if (!StringUtils.isBlank(_URLPackages))
               properties.put(Context.URL_PKG_PREFIXES, _URLPackages);
   
           return constructContext(properties);
  
  
  

Mime
View raw message