hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/parse ParseStrings.properties ParseMessages.java DescriptorParser.java
Date Mon, 25 Oct 2004 09:02:31 GMT
knut        2004/10/25 02:02:31

  Modified:    framework/src/test/hivemind/test/parse
                        TestDescriptorParser.java
               framework/src/java/org/apache/hivemind/parse
                        ParseStrings.properties ParseMessages.java
                        DescriptorParser.java
  Added:       framework/src/test/hivemind/test/parse DuplicateSchemas.xml
  Removed:     framework/src/test/hivemind/test/parse
                        DuplicateParametersSchema.xml
  Log:
  added check and handling for multiple schemas on configurations
  
  Revision  Changes    Path
  1.25      +19 -1     jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java
  
  Index: TestDescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TestDescriptorParser.java	27 Sep 2004 15:50:47 -0000	1.24
  +++ TestDescriptorParser.java	25 Oct 2004 09:02:31 -0000	1.25
  @@ -312,11 +312,29 @@
           assertEquals("myParameter", em.getElementName());
       }
   
  +    public void testDuplicateContributionsSchema() throws Exception
  +    {
  +        interceptLogging();
  +
  +        ModuleDescriptor md = parse("DuplicateSchemas.xml");
  +
  +        assertLoggedMessagePattern("Multiple contributions schemas specified for configuration
MyConfiguration. Using locally defined schema \\(at ");
  +
  +        ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor) md.getConfigurationPoints().get(0);
  +        Schema nestedSchema = cpd.getContributionsSchema();
  +
  +        assertNotNull(nestedSchema);
  +
  +        ElementModel em = (ElementModel) nestedSchema.getElementModel().get(0);
  +
  +        assertEquals("myParameter", em.getElementName());
  +    }
  +
       public void testDuplicateParametersSchema() throws Exception
       {
           interceptLogging();
   
  -        ModuleDescriptor md = parse("DuplicateParametersSchema.xml");
  +        ModuleDescriptor md = parse("DuplicateSchemas.xml");
   
           assertLoggedMessagePattern("Multiple parameters schemas specified for service MyServiceFactory.
Using locally defined schema \\(at ");
   
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/hivemind/test/parse/DuplicateSchemas.xml
  
  Index: DuplicateSchemas.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     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.
  -->
  
  <module id="hivemind.test.parse" version="1.0.0">
  
  	<schema id="Parameters">
  		<element name="aParameter"/>
  	</schema>
  
  	<service-point id="MyServiceFactory"
  		interface="org.apache.hivemind.ServiceImplementationFactory"
  		parameters-schema-id="Parameters">
  		<parameters-schema>
  			<element name="myParameter"/>
  		</parameters-schema>
  	</service-point>
  
  	<configuration-point id="MyConfiguration"
  		schema-id="Parameters">
  		<schema>
  			<element name="myParameter"/>
  		</schema>
  	</configuration-point>
  		
  </module>
  
  
  
  1.11      +1 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties
  
  Index: ParseStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ParseStrings.properties	27 Sep 2004 15:50:47 -0000	1.10
  +++ ParseStrings.properties	25 Oct 2004 09:02:31 -0000	1.11
  @@ -16,6 +16,7 @@
   dupe-attribute-mapping=Mapping for attribute {0} conflicts with a previous mapping (at
{1}) and has been ignored.
   extra-mappings=Mappings for unknown attribute(s) {0} (for element {1}) have been ignored.
   unable-to-resolve-schema=Unable to resolve reference to schema ''{0}''.
  +multiple-contributions-schemas=Multiple contributions schemas specified for configuration
{0}. Using locally defined schema (at {1}).
   multiple-parameters-schemas=Multiple parameters schemas specified for service {0}. Using
locally defined schema (at {1}).
   not-module=Document element should be module not {0} (at {1}).
   required-attribute=Missing required attribute ''{0}'' in element {1} (at {2}).
  
  
  
  1.12      +5 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java
  
  Index: ParseMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ParseMessages.java	27 Sep 2004 14:36:35 -0000	1.11
  +++ ParseMessages.java	25 Oct 2004 09:02:31 -0000	1.12
  @@ -51,6 +51,11 @@
           return _formatter.format("unable-to-resolve-schema", schemaId);
       }
   
  +    public static String multipleContributionsSchemas(String configurationId, Location
location)
  +    {
  +        return _formatter.format("multiple-contributions-schemas", configurationId, location);
  +    }
  +
       public static String multipleParametersSchemas(String serviceId, Location location)
       {
           return _formatter.format("multiple-parameters-schemas", serviceId, location);
  
  
  
  1.39      +9 -6      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
  
  Index: DescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- DescriptorParser.java	14 Oct 2004 14:31:31 -0000	1.38
  +++ DescriptorParser.java	25 Oct 2004 09:02:31 -0000	1.39
  @@ -168,8 +168,8 @@
       /**
        * Used to resolve and link schema references during the parse.
        */
  -    private RegistryAssembly _registryAssembly;
   
  +    private RegistryAssembly _registryAssembly;
       private ClassResolver _resolver;
   
       private Perl5Compiler _compiler;
  @@ -862,9 +862,14 @@
   
           push(elementName, schema, STATE_SCHEMA);
   
  -        // TODO: Check if already has cpd / already specified schema-id
  -
  -        cpd.setContributionsSchema(schema);
  +        if (cpd.getContributionsSchema() != null)
  +        {
  +            cpd.setContributionsSchema(schema);
  +            _errorHandler.error(LOG, ParseMessages.multipleContributionsSchemas(cpd.getId(),
schema
  +                    .getLocation()), schema.getLocation(), null);
  +        }
  +        else
  +            cpd.setContributionsSchema(schema);
   
           checkAttributes("schema{embedded}");
       }
  @@ -1016,8 +1021,6 @@
   
           if (visibility != null)
               schema.setVisibility(visibility);
  -
  -        // TODO: check for duplicate name!
   
           _registryAssembly.addSchema(qualify(id), schema);
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message