openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r934507 - in /openjpa/trunk: openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java openjpa-project/src/doc/manual/jpa_overview_criteria.xml scripts/mmg.bat scripts/mmg.options
Date Thu, 15 Apr 2010 18:25:46 GMT
Author: ppoddar
Date: Thu Apr 15 18:25:46 2010
New Revision: 934507

URL: http://svn.apache.org/viewvc?rev=934507&view=rev
Log:
OPENJPA-1628: Usability changes

Removed:
    openjpa/trunk/scripts/mmg.options
Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
    openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_criteria.xml
    openjpa/trunk/scripts/mmg.bat

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java?rev=934507&r1=934506&r2=934507&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
Thu Apr 15 18:25:46 2010
@@ -58,26 +58,26 @@ import org.apache.openjpa.persistence.ut
  * This tool is invoked during compilation for JDK6 compiler if 
  * <UL>
  * <LI>OpenJPA and JPA libraries are available in the compiler classpath
- * and <LI>Annotation Processor option <code>-Aopenjpa.generate=true</code>
is specified.
+ * and <LI>Annotation Processor option <code>-Aopenjpa.metamodel=true</code>
is specified.
  * </UL>
  * <br>
  * <B>Usage</B><br>
- * <code>$ javac -classpath path/to/openjpa-all.jar -Aopenjpa.generated=true mypackage/MyEntity.java</code><br>
+ * <code>$ javac -classpath path/to/openjpa-all.jar -Aopenjpa.metamodel=true mypackage/MyEntity.java</code><br>
  * will generate source code for canonical meta-model class <code>mypackage.MyEntity_.java</code>.
+ * The source code is generated relative to the directory specified in <code>-s</code>
option
+ * of <code>javac</code> compiler and defaulted to the current directory.
  * <p>
- * The Annotation Processor also recognizes the following options (none of them are mandatory).
- * Each of the following option key can also be prefixed with <code>openjpa.</code>
to distinguish if multiple 
- * annotation processors are active during compilation:<br>
+ * The Annotation Processor also recognizes the following options (none of them are mandatory):<br>
  * <TABLE border="1">
- * <TR><TD>-Alog={log level}<TD>The logging level. Default is <code>WARN</code>.
Permissible values are 
+ * <TR><TD>-Aopenjpa.log={log level}<TD>The logging level. Default is <code>WARN</code>.
Permissible values are 
  *     <code>TRACE</code>, <code>INFO</code>, <code>WARN</code>
or <code> ERROR</code>.
- * <TR><TD>-Asource={n}          <TD>Java source version of the generated
code. Default is <code>6</code>.
- * <TR><TD>-Anaming={class name} <TD>fully-qualified name of a class implementing

+ * <TR><TD>-Aopenjpa.source={n}          <TD>Java source version of the
generated code. Default is <code>6</code>.
+ * <TR><TD>-Aopenjpa.naming={class name} <TD>fully-qualified name of a
class implementing 
  * <code>org.apache.openjpa.meta.MetaDataFactory</code> that determines
  * the name of a meta-class given the name of the original persistent Java entity class.
Defaults to
  * <code>org.apache.openjpa.persistence.PersistenceMetaDataFactory</code> which
appends a underscore character
  * (<code>_</code>) to the original Java class name. 
- * <TR><TD>-Aheader={url}        <TD>
+ * <TR><TD>-Aopenjpa.header={url}        <TD>
  * A url whose content will appear as comment header to the generated file(s). Recognizes
special value
  * <code>ASL</code> for Apache Source License header as comment. By default adds
a OpenJPA proprietary   
  * text.
@@ -93,11 +93,11 @@ import org.apache.openjpa.persistence.ut
     "javax.persistence.Entity",
     "javax.persistence.Embeddable", 
     "javax.persistence.MappedSuperclass" })
-@SupportedOptions({ "openjpa.log", "log", 
-                    "openjpa.source", "source",
-                    "openjpa.naming", "naming",
-                    "openjpa.header", "header",
-                    "openjpa.generate"
+@SupportedOptions({ "openjpa.log", 
+                    "openjpa.source",
+                    "openjpa.naming",
+                    "openjpa.header",
+                    "openjpa.metamodel"
                   })
 @SupportedSourceVersion(RELEASE_6)
 
@@ -185,11 +185,11 @@ public class AnnotationProcessor6 extend
     @Override
     public synchronized void init(ProcessingEnvironment processingEnv) {
         super.init(processingEnv);
-        active = "true".equalsIgnoreCase(getOptionValue("openjpa.generate"));
+        active = "true".equalsIgnoreCase(getOptionValue("openjpa.metamodel"));
         if (!active)
             return;
         processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, _loc.get("mmg-tool-banner").toString());
-        logger = new CompileTimeLogger(processingEnv, getOptionValue("openjpa.log", "log"));
+        logger = new CompileTimeLogger(processingEnv, getOptionValue("openjpa.log"));
         setSourceVersion();
         setNamingPolicy();
         setHeader();
@@ -304,12 +304,12 @@ public class AnnotationProcessor6 extend
     }
     
     /**
-     * Parse annotation processor option <code>-Asource=n</code> to detect
+     * Parse annotation processor option <code>-Aopenjpa.source=n</code> to detect
      * the source version for the generated classes. 
      * n must be a integer. Default or wrong specification returns 6.
      */
     private void setSourceVersion() {
-        String version = getOptionValue("openjpa.source", "source");
+        String version = getOptionValue("openjpa.source");
         if (version != null) {
             try {
                 generatedSourceVersion = Integer.parseInt(version);
@@ -323,7 +323,7 @@ public class AnnotationProcessor6 extend
     }
     
     private void setNamingPolicy() {
-        String policy = getOptionValue("openjpa.naming","naming");
+        String policy = getOptionValue("openjpa.naming");
         if (policy != null) {
             try {
                 factory = (MetaDataFactory)Class.forName(policy).newInstance();
@@ -337,7 +337,7 @@ public class AnnotationProcessor6 extend
     }
     
     private void setHeader() {
-        String headerOption = getOptionValue("openjpa.header", "header");
+        String headerOption = getOptionValue("openjpa.header");
         if (headerOption == null) {
             return;
         }
@@ -360,7 +360,7 @@ public class AnnotationProcessor6 extend
     private PrintWriter createSourceFile(String originalClass, String metaClass, TypeElement
e) 
         throws IOException {
         JavaFileObject javaFile = processingEnv.getFiler().createSourceFile(metaClass, e);
-        logger.info(_loc.get("mmg-process", javaFile.toUri()));
+        logger.info(_loc.get("mmg-process", javaFile.toUri().normalize()));
         return new PrintWriter(javaFile.openWriter());
     }
     

Modified: openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_criteria.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_criteria.xml?rev=934507&r1=934506&r2=934507&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_criteria.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_criteria.xml Thu Apr 15 18:25:46
2010
@@ -168,9 +168,9 @@ Annotation processing tool generates sou
 the annotated source code of persistent entity. 
 This tool is invoked during compilation for JDK6 compiler if OpenJPA and JPA 
 libraries are specified in the compiler <code>-classpath</code> option <emphasis>and</emphasis>
-Annotation processor option <code>-Aopenjpa.generate=true</code> is specified.
+Annotation processor option <code>-Aopenjpa.metamodel=true</code> is specified.
     <programlisting>
- $ javac -classpath path/to/openjpa-all.jar -Aopenjpa.generate=true mypackage/MyEntity.java
+ $ javac -classpath path/to/openjpa-all.jar -Aopenjpa.metamodel=true mypackage/MyEntity.java
     </programlisting>
 will generate source code for canonical meta-model class <code>mypackage.MyEntity_</code>.
 The source code is generated relative to the directory specified in <code>-s</code>
option
@@ -179,23 +179,22 @@ of <code>javac</code> compiler and defau
       
       <para>
 The Annotation Processor recognizes the following options specified in the command-line with
<code>-A</code> 
-(none of them are mandatory). Each of the following option key can also be prefixed with
<code>openjpa.</code> 
-to distinguish if multiple annotation processors are active during compilation.
+(none of them are mandatory).
     <itemizedlist>
         <listitem>
 			<para>
-              -Alog=TRACE|INFO|WARN|ERROR : The logging level. Default is <code>WARN</code>.
+              -Aopenjpa.log=TRACE|INFO|WARN|ERROR : The logging level. Default is <code>WARN</code>.
             </para>
         </listitem>
         <listitem>
 			<para>
-             -Asource=&lt;n&gt; : where &lt;n&gt; denotes the integral number
for Java source 
+             -Aopenjpa.source=&lt;n&gt; : where &lt;n&gt; denotes the integral
number for Java source 
              version of the generated code. Default is <code>6</code>.
              </para>
         </listitem>
         <listitem>
 			<para>
-               -Anaming=class name : fully-qualified name of a class implementing 
+               -Aopenjpa.naming=class name : fully-qualified name of a class implementing

                <code>org.apache.openjpa.meta.MetaDataFactory</code> that determines
 the name of a meta-class given the name of the original persistent Java entity class. Defaults
to
 <code>org.apache.openjpa.persistence.PersistenceMetaDataFactory</code> which
appends a underscore character
@@ -204,7 +203,7 @@ the name of a meta-class given the name 
         </listitem>
         <listitem>
 			<para>
-               -Aheader=&lt;url&gt; : A url whose content will appear as comment
header to the generated file(s). 
+               -Aopenjpa.header=&lt;url&gt; : A url whose content will appear as
comment header to the generated file(s). 
                Recognizes special value <code>ASL</code> for Apache Source License
header as comment. 
                By default, adds a OpenJPA proprietary text as comment block.
              </para>

Modified: openjpa/trunk/scripts/mmg.bat
URL: http://svn.apache.org/viewvc/openjpa/trunk/scripts/mmg.bat?rev=934507&r1=934506&r2=934507&view=diff
==============================================================================
--- openjpa/trunk/scripts/mmg.bat (original)
+++ openjpa/trunk/scripts/mmg.bat Thu Apr 15 18:25:46 2010
@@ -21,22 +21,24 @@
 @rem Example Batch script to generate canonical meta-model classes
 @rem
 @rem Usage
-@rem   $ mmg.bat <options.file> <class.list>
+@rem   $ mmg.bat <class.list>
 @rem 
 @rem The canonical meta-model classes can be generated during compilation of
 @rem domain classes. This batch file compiles a set of classes (X.java) listed 
-@rem in <class.list> file. The compiler is invoked with an annotation
-@rem processor which generates a meta-model class X_.java for each X.java. 
-@rem The options for annotation processor is specified in <options.file>.
+@rem in <class.list> file. The compiler discoveres the annotation
+@rem processor if openjpa classes are in classpath. The discovered annotation
+@rem processor, however, is active only if -Aopenjpa.metamodel=true is set.  
 @rem 
 @rem See also 
-@rem    mmg.options       : The options to Javac compiler 
 @rem    domain-class.list : The domain classes to be compiled
 @rem ---------------------------------------------------------------------------
 @echo off
 setlocal
 set JAVAC=%JAVA_HOME%\bin\javac
 
+@rem ---------------------------------------------------------------------------
+@rem Compiler classpath shown for a typical OpenJPA development environment in Windows. 
+@rem The essential aspect is openjpa libraries must be in the compiler's classpath.
 set M_REPO="C:\Documents and Settings\Administrator\.m2\repository"
 set SPEC=geronimo-jpa_2.0_spec
 set VERSION=1.0-EA9-SNAPSHOT
@@ -44,10 +46,20 @@ set JPA_LIB=%M_REPO%\org\apache\geronimo
 
 set CLASSPATH=%JPA_LIB%
 set CLASSPATH=%CLASSPATH%;..\openjpa\src\main\resources
-set CLASSPATH=%CLASSPATH%;..\openjpa\target\classes
+set CLASSPATH=%CLASSPATH%;..\openjpa-persistence\target\classes
+set CLASSPATH=%CLASSPATH%;..\openjpa-kernel\target\classes
+set CLASSPATH=%CLASSPATH%;..\openjpa-lib\target\classes
 
+@rem ---------------------------------------------------------------------------
 echo Using Java Compiler %JAVAC%
 %JAVAC% -version
-%JAVAC% -cp %CLASSPATH% @%1 @%2
+
+@rem ---------------------------------------------------------------------------
+@rem Root directory for of the generated source files. Specified as -s option 
+set GEN_DIR=../openjpa-persistence-jdbc/src/test/java
+
+@rem Only one option is shown for logging. Other available options are documented in
+@rem OpenJPA User Manual and JavaDoc
+%JAVAC% -cp %CLASSPATH% -s %GEN_DIR% -Aopenjpa.metamodel=true -Aopenjpa.log=TRACE @%1
 
 endlocal



Mime
View raw message