You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/10/20 22:50:55 UTC
svn commit: rev 55182 - incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema
Author: akarasulu
Date: Wed Oct 20 13:50:54 2004
New Revision: 55182
Added:
incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
Modified:
incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
Log:
Commit changes ...
o added new template file for top level schema class code generation
o added code to generate top level schema file
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 13:50:54 2004
@@ -18,14 +18,12 @@
import java.io.*;
-import java.util.Properties;
-import java.util.HashMap;
-import java.util.Map;
+
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.VelocityContext;
import org.apache.eve.schema.bootstrap.BootstrapSchema;
import org.apache.eve.schema.bootstrap.ProducerTypeEnum;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
/**
@@ -65,9 +63,10 @@
- public EveSchemaTool() throws IOException
+ public EveSchemaTool() throws Exception
{
parser = new OpenLdapSchemaParser();
+ Velocity.init();
}
@@ -119,11 +118,30 @@
+ schema.getSchemaName() + ".schema" );
parser.parse( in );
+ generateSchema();
generateAttributeTypes();
generateObjectClasses();
}
+ protected void generateSchema() throws Exception
+ {
+ String schemaCapped =
+ Character.toUpperCase( schema.getSchemaName().charAt( 0 ) )
+ + schema.getSchemaName().substring( 1, schema.getSchemaName().length() );
+
+ VelocityContext context = new VelocityContext();
+
+ context.put( "package", schema.getPackageName() );
+ context.put( "classname", schemaCapped + "Schema" );
+ context.put( "schema", schema.getSchemaName() );
+ context.put( "owner", schema.getOwner() ) ;
+ context.put( "deps", schema.getDependencies() ) ;
+
+ runVelocity( context, "Schema.template" );
+ }
+
+
protected void generateAttributeTypes() throws Exception
{
// check to see if the producer exists for this type
@@ -147,14 +165,7 @@
context.put( "schemaDeps", new String[] { "dep1", "dep2" } ) ;
context.put( "attrTypes", attributeTypes );
- FileReader template = getResourceReader( "AttributeTypes.template" );
-
- FileWriter writer = getResourceWriter( schema.getUnqualifiedClassName(
- ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER ) );
- Velocity.init();
- Velocity.evaluate( context, writer, "LOG", template );
- writer.flush();
- writer.close();
+ runVelocity( context, "AttributeTypes.template" );
}
@@ -181,11 +192,17 @@
context.put( "schemaDeps", new String[] { "dep1", "dep2" } ) ;
context.put( "objectClasses", objectClasses );
- FileReader template = getResourceReader( "ObjectClasses.template" );
+ runVelocity( context, "ObjectClasses.template" );
+ }
+
+
+ protected void runVelocity( VelocityContext context, String template )
+ throws Exception
+ {
+ FileReader fileIn = getResourceReader( template );
FileWriter writer = getResourceWriter( schema.getUnqualifiedClassName(
ProducerTypeEnum.OBJECT_CLASS_PRODUCER ) );
- Velocity.init();
- Velocity.evaluate( context, writer, "LOG", template );
+ Velocity.evaluate( context, writer, "LOG", fileIn );
writer.flush();
writer.close();
}
Added: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/Schema.template Wed Oct 20 13:50:54 2004
@@ -0,0 +1,47 @@
+/*
+ * 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 java.util.ArrayList;
+
+
+/**
+ * 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.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class $classname extends AbstractBootstrapSchema
+{
+ public $classname()
+ {
+ super( "$owner", "$schema", "$package" );
+
+ ArrayList list = new ArrayList();
+ #if ( $deps )
+list.clear();
+ #foreach ( $name in $deps ) list.add( "$name" );
+ #end
+ setDependencies( ( String[] ) list.toArray( DEFAULT_DEPS ) );#else
+ setDependencies( DEFAULT_DEPS );#end
+
+ }
+}