directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 55183 - incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema
Date Wed, 20 Oct 2004 21:24:28 GMT
Author: akarasulu
Date: Wed Oct 20 14:24:27 2004
New Revision: 55183

Added:
   incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/typeless.template
Modified:
   incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
   incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
Log:
Commit changes ...

 o added a template for all other producer types
 o added code to generate the other type producers besides attributeTypes and
   objectClasses



Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
Wed Oct 20 14:24:27 2004
@@ -18,6 +18,8 @@
 
 
 import java.io.*;
+import java.util.List;
+import java.util.ArrayList;
 
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.VelocityContext;
@@ -121,6 +123,7 @@
         generateSchema();
         generateAttributeTypes();
         generateObjectClasses();
+        generateRest();
     }
 
 
@@ -138,14 +141,89 @@
         context.put( "owner", schema.getOwner() ) ;
         context.put( "deps", schema.getDependencies()  ) ;
 
-        runVelocity( context, "Schema.template" );
+        FileReader fileIn = getResourceReader( "Schema.template" );
+        FileWriter writer = getResourceWriter( schema.getUnqualifiedClassName() );
+        Velocity.evaluate( context, writer, "LOG", fileIn );
+        writer.flush();
+        writer.close();
+    }
+
+
+
+    protected void generateRest() throws Exception
+    {
+        List types = new ArrayList();
+        types.addAll( ProducerTypeEnum.list() );
+        types.remove( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER );
+        types.remove( ProducerTypeEnum.OBJECT_CLASS_PRODUCER );
+        ProducerTypeEnum type = null;
+
+        for ( int ii = 0; ii < types.size(); ii++ )
+        {
+            type = ( ProducerTypeEnum ) types.get( ii );
+
+            if ( exists( type ) )
+            {
+                continue;
+            }
+
+
+            VelocityContext context = new VelocityContext();
+            context.put( "package", schema.getPackageName() );
+            context.put( "classname", schema.getUnqualifiedClassName( type ) );
+            context.put( "schema", schema.getSchemaName() );
+            context.put( "owner", schema.getOwner() ) ;
+            context.put( "type", type.getName().substring( 0,
+                    type.getName().length() - 8 ) ) ;
+
+            String typeName = null;
+            switch( type.getValue() )
+            {
+                case( ProducerTypeEnum.COMPARATOR_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.COMPARATOR_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.MATCHING_RULE_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.MATCHING_RULE_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.NAME_FORM_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.NAME_FORM_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.NORMALIZER_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.NORMALIZER_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER";
+                    break;
+                case( ProducerTypeEnum.SYNTAX_PRODUCER_VAL ):
+                    typeName = "ProducerTypeEnum.SYNTAX_PRODUCER";
+                    break;
+                default:
+                    throw new IllegalStateException( "Unexpected producer: "
+                        + type.getName() );
+            }
+
+            context.put( "typeName", typeName ) ;
+            runVelocity( context, "typeless.template", type );
+        }
+
     }
 
 
     protected void generateAttributeTypes() throws Exception
     {
+        final ProducerTypeEnum type = ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER;
+
         // check to see if the producer exists for this type
-        if ( exists( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER ) )
+        if ( exists( type ) )
         {
             return;
         }
@@ -158,21 +236,23 @@
         VelocityContext context = new VelocityContext();
         context.put( "package", schema.getPackageName() );
         context.put( "classname",
-            schema.getUnqualifiedClassName( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER ) );
+            schema.getUnqualifiedClassName( type ) );
         context.put( "schema", schema.getSchemaName() );
         context.put( "owner", schema.getOwner() ) ;
         context.put( "schemaDepCount", new Integer( schema.getDependencies().length ) );
         context.put( "schemaDeps", new String[] { "dep1", "dep2" }  ) ;
         context.put( "attrTypes", attributeTypes );
 
-        runVelocity( context, "AttributeTypes.template" );
+        runVelocity( context, "AttributeTypes.template", type );
     }
 
 
     protected void generateObjectClasses() throws Exception
     {
+        final ProducerTypeEnum type = ProducerTypeEnum.OBJECT_CLASS_PRODUCER;
+
         // check to see if the producer exists for this type
-        if ( exists( ProducerTypeEnum.OBJECT_CLASS_PRODUCER ) )
+        if ( exists( type ) )
         {
             return;
         }
@@ -184,24 +264,23 @@
 
         VelocityContext context = new VelocityContext();
         context.put( "package", schema.getPackageName() );
-        context.put( "classname",
-            schema.getUnqualifiedClassName( ProducerTypeEnum.OBJECT_CLASS_PRODUCER ) );
+        context.put( "classname", schema.getUnqualifiedClassName( type ) );
         context.put( "schema", schema.getSchemaName() );
         context.put( "owner", schema.getOwner() ) ;
         context.put( "schemaDepCount", new Integer( schema.getDependencies().length ) );
         context.put( "schemaDeps", new String[] { "dep1", "dep2" }  ) ;
         context.put( "objectClasses", objectClasses );
 
-        runVelocity( context, "ObjectClasses.template" );
+        runVelocity( context, "ObjectClasses.template", type );
     }
 
 
-    protected void runVelocity( VelocityContext context, String template )
+    protected void runVelocity( VelocityContext context, String template,
+                                ProducerTypeEnum type )
             throws Exception
     {
         FileReader fileIn = getResourceReader( template );
-        FileWriter writer = getResourceWriter( schema.getUnqualifiedClassName(
-                ProducerTypeEnum.OBJECT_CLASS_PRODUCER ) );
+        FileWriter writer = getResourceWriter( schema.getUnqualifiedClassName( type ) );
         Velocity.evaluate( context, writer, "LOG", fileIn );
         writer.flush();
         writer.close();

Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
Wed Oct 20 14:24:27 2004
@@ -21,10 +21,8 @@
 
 
 /**
- * A producer of schema attributeType definations for the $schema schema.  This
- * code has been automatically generated using schema files in the OpenLDAP
- * format along with the eve schema plugin for maven.  This has been done
- * to facilitate Eve<->OpenLDAP schema interoperability.
+ * Top level $schema schema class.  This code has been automatically generated
+ * using the eve schema plugin for maven.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$

Added: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/typeless.template
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/typeless.template
Wed Oct 20 14:24:27 2004
@@ -0,0 +1,52 @@
+/*
+ *   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.
+ *
+ */
+package $package;
+
+
+import javax.naming.NamingException;
+
+
+/**
+ * A producer of $type objects for the $schema schema.  This code has been
+ * automatically generated using schema files in the OpenLDAP format along with
+ * the eve schema plugin for maven.  This has been done to facilitate
+ * Eve<->OpenLDAP schema interoperability.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class $classname extends AbstractBootstrapProducer
+{
+    public $classname()
+    {
+        super( $typeName );
+    }
+
+
+    // ------------------------------------------------------------------------
+    // BootstrapProducer Methods
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * @see BootstrapProducer#produce(BootstrapRegistries, ProducerCallback)
+     */
+    public void produce( BootstrapRegistries registries, ProducerCallback cb )
+        throws NamingException
+    {
+    }
+}

Mime
View raw message