db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r171351 [16/16] - in /incubator/jdo/trunk/enhancer20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/enhancer/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/enhancer/ src/java/org/apache/jdo/impl/enhancer/classfile/ src/java/org/apache/jdo/impl/enhancer/core/ src/java/org/apache/jdo/impl/enhancer/generator/ src/java/org/apache/jdo/impl/enhancer/meta/ src/java/org/apache/jdo/impl/enhancer/meta/model/ src/java/org/apache/jdo/impl/enhancer/meta/prop/ src/java/org/apache/jdo/impl/enhancer/meta/util/ src/java/org/apache/jdo/impl/enhancer/util/ test/ test/sempdept/ test/sempdept/src/ test/sempdept/src/empdept/
Date Sun, 22 May 2005 17:55:54 GMT
Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorBase.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorBase.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorBase.java
(added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorBase.java
Sun May 22 10:55:51 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2005 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 org.apache.jdo.impl.enhancer.util;
+
+import java.io.PrintWriter;
+
+
+
+/**
+ * Base class for resource locators.
+ */
+abstract class ResourceLocatorBase
+    extends Support
+    implements ResourceLocator
+{
+    // misc
+    protected final PrintWriter out;
+    protected final boolean verbose;
+
+    /**
+     * Creates an instance.
+     */
+    public ResourceLocatorBase(PrintWriter out,
+                               boolean verbose)
+    {
+        affirm(out != null);
+        this.out = out;
+        this.verbose = verbose;
+    }
+
+    /**
+     *  Prints out a verbose message.
+     *
+     *  @param msg the message
+     */
+    public void printMessage(String msg)
+    {
+        if (verbose) {
+            out.println(getI18N("enhancer.message", msg));
+        }
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorTimer.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorTimer.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorTimer.java
(added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/ResourceLocatorTimer.java
Sun May 22 10:55:51 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 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 org.apache.jdo.impl.enhancer.util;
+
+import java.io.InputStream;
+
+
+
+public final class ResourceLocatorTimer
+    extends Support
+    implements ResourceLocator
+{
+    // delegate
+    final protected ResourceLocator delegate;
+
+    /**
+     * Creates an instance.
+     */
+    public ResourceLocatorTimer(ResourceLocator delegate)
+    {
+        affirm(delegate);
+        this.delegate = delegate;
+    }
+
+    public InputStream getInputStreamForResource(String resourceName)
+    {
+        try {
+            timer.push("ResourceLocator.getInputStreamForResource(String)",
+                       "ResourceLocator.getInputStreamForResource(" + resourceName + ")");
+            return delegate.getInputStreamForResource(resourceName);
+        } finally {
+            timer.pop();
+        }
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Support.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Support.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Support.java
(added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Support.java
Sun May 22 10:55:51 2005
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2005 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 org.apache.jdo.impl.enhancer.util;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.util.Hashtable;
+import java.text.MessageFormat;
+
+
+
+class I18NHelper
+{
+    private static Hashtable	bundles = new Hashtable();
+    private static Locale 	locale = Locale.getDefault();
+
+    /**
+     * Constructor
+     */
+    public I18NHelper()
+    {}
+
+    /**
+     * Load ResourceBundle by bundle name
+     */
+    public static ResourceBundle loadBundle(String bundleName)
+    {
+        ResourceBundle messages = (ResourceBundle)bundles.get(bundleName);
+
+        if (messages == null) //not found as loaded - add
+        {
+            messages = ResourceBundle.getBundle(bundleName, locale);
+            bundles.put(bundleName, messages);
+        }
+        return messages;
+    }
+
+  
+    /**
+     * Returns message as String
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey) 
+    {
+        return messages.getString(messageKey);
+    }
+
+    /**
+     * Formats message by adding Array of arguments
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, Object
msgArgs[]) 
+    {
+        for (int i=0; i<msgArgs.length; i++) {
+            if (msgArgs[i] == null) msgArgs[i] = ""; // NOI18N
+        }
+        MessageFormat formatter = new MessageFormat(messages.getString(messageKey));
+        return formatter.format(msgArgs);
+    }
+    /**
+     * Formats message by adding a String argument
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, String
arg) 
+    {
+        Object []args = {arg};
+        return getMessage(messages, messageKey, args);
+    }
+    /**
+     * Formats message by adding two String arguments
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, String
arg1,
+                                          String arg2) 
+    {
+        Object []args = {arg1, arg2};
+        return getMessage(messages, messageKey, args);
+    }
+    /**
+     * Formats message by adding three String arguments
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, String
arg1,
+                                          String arg2, String arg3) 
+    {
+        Object []args = {arg1, arg2, arg3};
+        return getMessage(messages, messageKey, args);
+    }
+    /**
+     *
+     * Formats message by adding an Object as an argument
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, Object
arg) 
+    {
+        Object []args = {arg};
+        return getMessage(messages, messageKey, args);
+    }
+    /**
+     * Formats message by adding an int as an argument
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, int
arg) 
+    {
+        Object []args = {new Integer(arg)};
+        return getMessage(messages, messageKey, args);
+    }
+    /**
+     * Formats message by adding a boolean as an argument
+     */
+    final public static String getMessage(ResourceBundle messages, String messageKey, boolean
arg) 
+    {
+        Object []args = {String.valueOf(arg)};
+        return getMessage(messages, messageKey, args);
+    }
+}
+
+
+/**
+ * Basic support for enhancer implementation.
+ */
+public class Support
+    extends Assertion
+{
+    //^olsen: hack
+    static public Timer timer = new Timer();
+
+    /**
+     * I18N message handler
+     */
+    static private ResourceBundle MESSAGES;
+
+
+    /**
+     *
+     */
+    static
+    {
+        try
+        {
+            MESSAGES = I18NHelper.loadBundle("org.apache.jdo.impl.enhancer.Bundle");
+        }
+        catch (java.util.MissingResourceException ex)
+        {
+            ex.printStackTrace ();
+        }
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key)
+    {
+        return I18NHelper.getMessage(MESSAGES, key);
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key,
+                                          String arg)
+    {
+        return I18NHelper.getMessage(MESSAGES, key, arg);
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key,
+                                          String arg1,
+                                          String arg2)
+    {
+        return I18NHelper.getMessage(MESSAGES, key, arg1, arg2);
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key,
+                                          String arg1,
+                                          String arg2,
+                                          String arg3)
+    {
+        return I18NHelper.getMessage(MESSAGES, key, arg1, arg2, arg3);
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key,
+                                          int arg1,
+                                          String arg2)
+    {
+        return I18NHelper.getMessage(MESSAGES, key,
+                                     new Object[]{new Integer(arg1), arg2});
+    }
+
+    /**
+     * Returns the I18N message.
+     */
+    static protected final String getI18N(String key,
+                                          Object[] args)
+    {
+        return I18NHelper.getMessage(MESSAGES, key, args);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Timer.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Timer.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Timer.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/util/Timer.java Sun
May 22 10:55:51 2005
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2005 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 org.apache.jdo.impl.enhancer.util;
+
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import java.text.DecimalFormat;
+
+import java.io.PrintWriter;
+
+
+/**
+ * Utility class for simple performance analysis.
+ */
+public final class Timer
+{
+    // a method's timing descriptor
+    static private class MethodDescriptor
+    {
+        final String name;
+        int instantiations;
+        int calls;
+        long self;
+        long total;
+
+        MethodDescriptor(String name)
+        {
+            this.name = name;
+        }
+    }
+
+    // a method call's timing descriptor
+    static private class MethodCall
+    {
+        final MethodDescriptor method;
+        final String message;
+        long self;
+        long total;
+
+        MethodCall(MethodDescriptor method,
+                   String message,
+                   long self,
+                   long total)
+        {
+            this.method = method;
+            this.message = message;
+            this.self = self;
+            this.total = total;
+        }
+    }
+
+    // output device
+    PrintWriter out = new PrintWriter(System.out, true);
+
+    // methods
+    HashMap methods = new HashMap();
+
+    // method call stack
+    private final ArrayList calls = new ArrayList(16);
+    
+    public Timer()
+    {
+        this.out = out;
+    }
+
+    public Timer(PrintWriter out)
+    {
+        this.out = out;
+    }
+
+    public final synchronized void push(String name)
+    {
+        push(name, name);
+    }
+    
+    public final synchronized void push(String name, String message)
+    {
+        // get time
+        final long now = System.currentTimeMillis();
+
+        // get a method descriptor
+        MethodDescriptor current = (MethodDescriptor)methods.get(name);
+        if (current == null) {
+            current = new MethodDescriptor(name);
+            methods.put(name, current);
+        }
+
+        // update method descriptor
+        current.calls++;
+        current.instantiations++;
+
+        // update method call stack
+        calls.add(new MethodCall(current, message, now, now));
+    }
+
+    public final synchronized void pop()
+    {
+        // get time
+        final long now = System.currentTimeMillis();
+
+        // update method call stack
+        final MethodCall call = (MethodCall)calls.remove(calls.size()-1);
+
+        // get current call's time
+        final long currentSelf = now - call.self;
+        final long currentTotal = now - call.total;
+
+        // update previous call's self time
+        if (calls.size() > 0) {
+            final MethodCall previous = (MethodCall)calls.get(calls.size()-1);
+            previous.self += currentTotal;
+        }
+
+        // update method descriptor
+        final MethodDescriptor current = call.method;
+        current.self += currentSelf;
+        if (--current.instantiations == 0) {
+            current.total += currentTotal;
+        }
+
+        if (false) {
+            out.println("Timer (n,g): " + call.message + " : ("
+                        + currentSelf + ", " + currentTotal + ")");
+        }
+    }
+
+    static private final String pad(String s, int i)
+    {
+        StringBuffer b = new StringBuffer();
+        for (i -= s.length(); i > 0; i--)
+            b.append((char)' ');
+        b.append(s);
+        return b.toString();
+    }
+    
+    public final synchronized void print()
+    {
+        out.println("Timer : printing accumulated times ...");
+        final Object[] calls = methods.values().toArray();
+
+        Arrays.sort(calls,
+                    new Comparator() {
+                            public int compare(Object o1,
+                                               Object o2) {
+                                return (int)(((MethodDescriptor)o2).total
+                                             - ((MethodDescriptor)o1).total);
+                            }
+                            public boolean equals(Object obj) {
+                                return (compare(this, obj) == 0);
+                            }
+                        });
+        
+        out.println("Timer :  total s    self s  #calls  name");
+        DecimalFormat nf = new DecimalFormat();
+        nf.setMaximumFractionDigits(2);
+        nf.setMinimumFractionDigits(2);
+        //nf.applyPattern("#,##0.00");
+        //out.println("Timer : pattern = " + nf.toPattern());
+        for (int i = 0; i < calls.length; i++) {
+            final MethodDescriptor current = (MethodDescriptor)calls[i];
+
+            out.println("Timer : "
+                        + pad(nf.format(current.total / 1000.0), 8) + "  "
+                        + pad(nf.format(current.self / 1000.0), 8) + "  "
+                        + pad(String.valueOf(current.calls), 6) + "  "
+                        + current.name);
+        }
+    }
+}

Added: incubator/jdo/trunk/enhancer20/test/common.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/common.xml?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/common.xml (added)
+++ incubator/jdo/trunk/enhancer20/test/common.xml Sun May 22 10:55:51 2005
@@ -0,0 +1,257 @@
+<!--
+   Copyright 2005 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.
+-->
+
+  <!-- libs -->
+  <property name="jdoapi" value="${user.home}/.maven/repository/apache-jdo/jars/jdo1-api-SNAPSHOT.jar"/>
+  <property name="jdocore" value="${user.home}/.maven/repository/apache-jdo/jars/jdo2-core-20-SNAPSHOT.jar"/>
+  <property name="jdoenhancer" value="${user.home}/.maven/repository/apache-jdo/jars/jdo2-enhancer-20-SNAPSHOT.jar"/>
+  <property name="logging" value="${user.home}/.maven/repository/commons-logging/jars/commons-logging-1.0.4.jar"/>
+  <property name="xmlparser"  value=""/>
+
+  <!-- subdirectories -->
+  <property name="src"  value="src"/> 
+  <property name="cls"  value="cls"/> 
+  <property name="gen"  value="gen"/> 
+  <property name="enh"  value="enh"/>
+
+  <!-- subdirectories -->
+  <property name="debug"  value="on"/> 
+
+  <!-- classpath -->
+  <path id="tools.class.path">
+    <pathelement location="${jdoapi}"/>
+    <pathelement location="${jdocore}"/>
+    <pathelement location="${jdoenhancer}"/>
+    <pathelement location="${logging}"/>
+    <pathelement location="${xmlparser}"/>
+  </path>
+
+  <target name="clean">
+    <delete dir="${cls}"/>
+    <delete dir="${gen}"/>
+    <delete dir="${enh}"/>
+  </target>
+
+  <target name="mrproper" depends="clean">
+    <delete>
+      <fileset dir="." defaultexcludes="no">
+        <include name="**/*.*~"/>
+      </fileset>
+    </delete>
+  </target>
+
+  <target name="init_compile_common">
+    <mkdir dir="${cls}"/>
+  </target>
+
+  <target name="init_enhance_common">
+    <!-- <delete dir="${enh}"/> -->
+    <mkdir dir="${enh}"/>
+  </target>
+
+  <target name="init_generate_common">
+    <delete dir="${gen}"/>
+    <!-- <mkdir dir="${gen}"/> -->
+  </target>
+
+  <target name="compile_common" depends="init_compile_common">
+    <javac srcdir="${src}" destdir="${cls}" debug="${debug}"
+     classpathref="tools.class.path"/>
+  </target>
+
+  <target name="generate_common" depends="init_generate_common">
+    <java classname="org.apache.jdo.impl.enhancer.generator.Main"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="-d ${gen} --properties ${jdoproperties}"/>
+    </java>
+
+    <javac srcdir="${gen}" destdir="${gen}" debug="${debug}"
+     classpathref="tools.class.path"/>
+  </target>
+
+  <target name="enhance_common" depends="compile_common,init_enhance_common,arg.verbose">
+    <java classname="org.apache.jdo.enhancer.EnhancerMain"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-f -d ${enh}"/>
+<!--  disable calling the enhancer with jdopropeties for now
+      <arg line="- -properties ${jdoproperties}"/> 
+-->
+      <arg line="-j"/>
+      <arg path="${src}:${cls}:${jdoapi}"/>
+      <arg line="-s"/>
+      <arg path="${cls}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="enh0_common" depends="compile_common,init_enhance_common,arg.verbose">
+    <java classname="org.apache.jdo.enhancer.Main"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-f -d ${enh}"/>
+<!--  disable calling the enhancer with jdopropeties for now
+      <arg line="- -properties ${jdoproperties}"/>
+-->
+      <arg line="-s ${cls}:${jdoapi}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="enh1_common" depends="compile_common,init_enhance_common,arg.verbose">
+    <java classname="org.apache.jdo.enhancer.Main"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-f -s ${src} -d ${enh} ${classes0}"/>
+    </java>
+  </target>
+
+  <target name="javap_src_common" depends="compile_common">
+    <exec executable="javap" dir="." output="${cls}/${outjavap}"
+     failonerror="yes">
+      <arg line="-classpath"/>
+      <arg path="${cls}:${jdoapi}"/>
+      <arg line="-c -private"/>
+      <arg line="${classes1}"/>
+    </exec>
+  </target>
+
+  <target name="javap_gen_common">
+    <exec executable="javap" dir="." output="${gen}/${outjavap}"
+     failonerror="yes">
+      <arg line="-classpath"/>
+      <arg path="${gen}:${jdoapi}"/>
+      <arg line="-c -private"/>
+      <arg line="${classes1}"/>
+    </exec>
+  </target>
+
+  <target name="javap_enh_common">
+    <exec executable="javap" dir="." output="${enh}/${outjavap}"
+     failonerror="yes">
+      <arg line="-classpath"/>
+      <arg path="${enh}:${jdoapi}"/>
+      <arg line="-c -private"/>
+      <arg line="${classes1}"/>
+    </exec>
+  </target>
+
+  <target name="dis_gen_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.Disassembler"
+     fork="yes" classpathref="tools.class.path" failonerror="yes"
+     output="${gen}/${outdis}">
+      <arg line="${arg.verbose}"/>
+      <arg line="-s"/>
+      <arg path="${gen}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="dis_enh_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.Disassembler"
+     fork="yes" classpathref="tools.class.path" failonerror="yes"
+      output="${enh}/${outdis}">
+      <arg line="${arg.verbose}"/>
+      <arg line="-s"/>
+      <arg path="${enh}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="test_aug_gen_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.AugmentationTest"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${gen}:${jdoapi}"/>
+      <arg line="-s"/>
+      <arg path="${gen}:${jdoapi}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="test_aug_enh_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.AugmentationTest"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${cls}:${jdoapi}"/>
+      <arg line="-s"/>
+      <arg path="${enh}:${jdoapi}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="test_ann_gen_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.AnnotationTest" fork="yes"
+     classpathref="tools.class.path" failonerror="yes">
+      <arg line="${arg.verbose}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${gen}:${jdoapi}"/>
+      <arg line="-s"/>
+      <arg path="${gen}:${jdoapi}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="test_ann_enh_common" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.AnnotationTest" fork="yes"
+     classpathref="tools.class.path" failonerror="yes">
+      <arg line="${arg.verbose}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${cls}:${jdoapi}"/>
+      <arg line="-s"/>
+      <arg path="${enh}:${jdoapi}"/>
+      <arg line="${classes0}"/>
+    </java>
+  </target>
+
+  <target name="test_aug_diff_common" depends="generate_common,enhance_common,arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.AugmentationDiffTest"
+     fork="yes" classpathref="tools.class.path" failonerror="yes">
+      <arg line="${arg.verbose}"/>
+      <arg line="${gen}/**/*.class"/>
+      <arg line="${enh}/**/*.class"/>
+    </java>
+  </target>
+
+  <target name="compile" depends="compile_common"/>
+  <target name="generate" depends="generate_common"/>
+  <target name="enhance" depends="enhance_common"/>
+  <target name="javap_gen" depends="javap_gen_common"/>
+  <target name="javap_enh" depends="javap_enh_common"/>
+  <target name="dis_gen" depends="dis_gen_common"/>
+  <target name="dis_enh" depends="dis_enh_common"/>
+  <target name="test_aug_gen" depends="test_aug_gen_common"/>
+  <target name="test_aug_enh" depends="test_aug_enh_common"/>
+  <target name="test_ann_gen" depends="test_ann_gen_common"/>
+  <target name="test_ann_enh" depends="test_ann_enh_common"/>
+
+  <target name="all_gen" depends="generate,javap_gen,dis_gen,test_aug_gen,test_ann_gen"/>
+  <target name="all_enh" depends="compile,enhance,javap_enh,dis_enh,test_aug_enh,test_ann_enh"/>
+  <target name="all" depends="all_gen,all_enh"/>
+
+  <target name="arg.verbose">
+    <condition property="arg.verbose" value="-v">
+        <or>
+          <istrue value="${verbose}"/>
+          <not> <isset property="verbose"/> </not>
+        </or>
+    </condition>
+    <condition property="arg.verbose" value="">
+        <isfalse value="${verbose}"/>
+    </condition>
+  </target>

Added: incubator/jdo/trunk/enhancer20/test/sempdept/build.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/build.xml?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/build.xml (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/build.xml Sun May 22 10:55:51 2005
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+
+<!--
+    Copyright 2005 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.
+-->
+
+
+<!DOCTYPE project [ <!ENTITY IncludeCommonFile SYSTEM "../common.xml"> ]>
+
+<project name="SEmpDept" default="all" basedir=".">
+
+  <!-- include common.xml -->
+  &IncludeCommonFile;
+
+  <property name="classes0" value="empdept.Department empdept.Department$$Oid empdept.Employee
empdept.Employee$$Oid empdept.FullTimeEmployee empdept.PartTimeEmployee empdept.PartTimeEmployee$$Oid"/>
+
+  <property name="classes1" value="empdept.Department empdept.Department.Oid empdept.Employee
empdept.Employee.Oid empdept.PartTimeEmployee empdept.PartTimeEmployee.Oid"/>
+
+  <property name="jdoproperties" value="${src}/empdept.jdoproperties"/>
+  <property name="jdo" value="${src}/empdept/package.jdo"/>
+
+  <property name="outjavap" value="output.javap"/>
+  <property name="outdis" value="output.dis"/>
+
+  <target name="enhance_files" depends="compile_common,init_enhance_common,arg.verbose">
+    <java classname="org.apache.jdo.enhancer.EnhancerMain"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-f -d ${enh}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${cls}:${jdo}"/>
+<!-- disable calling the enhancer with jdopropeties for now
+      <arg line="- -properties ${jdoproperties}"/>
+-->
+      <arg line="${cls}/empdept/Department.class ${cls}/empdept/Department$$Oid.class
${cls}/empdept/Employee.class ${cls}/empdept/Employee$$Oid.class"/>
+    </java>
+  </target>
+
+  <target name="dis_enh_files" depends="arg.verbose">
+    <java classname="org.apache.jdo.impl.enhancer.util.Disassembler"
+     fork="yes" classpathref="tools.class.path" failonerror="yes"
+      output="${enh}/${outdis}">
+      <arg line="${arg.verbose}"/>
+      <arg line="${enh}/empdept/Department.class ${enh}/empdept/Department$$Oid.class
${enh}/empdept/Employee.class ${enh}/empdept/Employee$$Oid.class"/>
+    </java>
+  </target>
+
+  <target name="test_ann_enh_files" depends="arg.verbose">
+    <java classname="org.apache.jdo.enhancer.util.AnnotationTest"
+     fork="yes" failonerror="yes" classpathref="tools.class.path">
+      <arg line="${arg.verbose}"/>
+      <arg line="-j"/>
+      <arg path="${src}:${cls}:${jdo}"/>
+      <arg line="${enh}/empdept/Department.class ${enh}/empdept/Department$$Oid.class
${enh}/empdept/Employee.class ${enh}/empdept/Employee$$Oid.class"/>
+    </java>
+  </target>
+
+</project>

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept.jdoproperties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept.jdoproperties?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept.jdoproperties (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept.jdoproperties Sun May 22 10:55:51
2005
@@ -0,0 +1,35 @@
+# Classnames can have the following attributes: 
+#          jdo:{persistent|transactional} 
+#          super: <classname> 
+#          oid: <classname> 
+#          access: {public|protected|package|private} 
+# Fieldnames can have the following attributes: 
+#          type:<type> 
+#          access: {public|protected|package|private} 
+#          jdo:{persistent|transactional|transient} 
+#          annotation:{key|dfg|mediated} 
+
+empdept.Department=jdo:persistent,oid:empdept.Department$Oid,access:public
+empdept.Department#deptid=type:int,jdo:persistent,access:private,annotation:key
+empdept.Department#name=type:String,jdo:persistent,access:private,annotation:dfg
+empdept.Department#employees=type:java.util.Collection,jdo:persistent,access:private,annotation:mediated
+
+empdept.Employee=jdo:persistent,oid:empdept.Employee$Oid,access:public
+empdept.Employee#empid=type:long,jdo:persistent,access:private,annotation:key
+empdept.Employee#name=type:String,jdo:persistent,access:private,annotation:dfg
+empdept.Employee#department=type:empdept.Department,jdo:persistent,access:private,annotation:mediated
+empdept.Employee#birthdate=type:java.util.Date,jdo:persistent,access:private,annotation:mediated
+
+empdept.FullTimeEmployee=jdo:persistent,super:empdept.Employee,access:public
+empdept.FullTimeEmployee#salary=type:double,jdo:persistent,access:private,annotation:dfg
+
+empdept.PartTimeEmployee=jdo:persistent,super:empdept.Employee,oid:empdept.PartTimeEmployee$Oid,access:public
+empdept.PartTimeEmployee#cid=type:int,jdo:persistent,access:private,annotation:key
+empdept.PartTimeEmployee#wage=type:double,jdo:persistent,access:private,annotation:dfg
+
+empdept.Department$Oid=jdo:transient,access:public
+empdept.Department$Oid#deptid=type:int,jdo:transient,access:public
+empdept.Employee$Oid=jdo:transient,access:public
+empdept.Employee$Oid#empid=type:long,jdo:transient,access:public
+empdept.PartTimeEmployee$Oid=jdo:transient,super:empdept.Employee$Oid,access:public
+empdept.PartTimeEmployee$Oid#cid=type:long,jdo:transient,access:public

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Department.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Department.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Department.java (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Department.java Sun May 22 10:55:51
2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2005 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 empdept;
+
+import java.util.Collection;
+
+
+/**
+ * A sample department class.
+ */
+public class Department {
+    private int deptid;
+    private String name;
+    private Collection employees;
+
+    public Department() {
+    }
+
+    public Department(String str) {
+        super();
+    }
+
+    public Object clone() throws java.lang.CloneNotSupportedException {
+        // clone() method for enhancer testing purpose
+        final empdept.Department pc = (empdept.Department)super.clone();
+        pc.deptid = this.deptid;
+        pc.employees = this.employees;
+        pc.name = this.name;
+        return pc;
+    }
+
+    public int getDeptid() {
+        return deptid;
+    }
+    
+    public void setDeptid(int deptid) {
+        this. deptid = deptid;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this. name = name;
+    }
+    
+    public Collection getEmployees() {
+        return employees;
+    }
+    
+    public void setEmployees(Collection employees) {
+        this. employees = employees;
+    }
+    
+    public static class Oid
+        implements java.io.Serializable {
+        public int deptid;
+    
+        public Oid() {
+            super();
+        }
+    
+        public Oid(String str) {
+            // not implemented yet
+            throw new UnsupportedOperationException();
+        }
+    
+        public int hashCode() {
+            int hash = 0;
+            hash += (int)deptid;
+            return hash;
+        }
+    
+        public boolean equals(java.lang.Object pk) {
+            if (pk == null || !this.getClass().equals(pk.getClass())) {
+                return false;
+            }
+            Oid oid = (Oid)pk;
+            if (this.deptid != oid.deptid) return false;
+            return true;
+        }
+    }    
+}
+

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Employee.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Employee.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Employee.java (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/Employee.java Sun May 22 10:55:51
2005
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2005 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 empdept;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * A sample employee class.
+ */
+public class Employee {
+    private long empid;    
+    private String name;
+    private Date birthdate;
+    private Department department;    
+    
+    public Employee() {
+    }
+
+    public Employee(String str) {
+        super();
+    }
+
+    public Object clone() throws java.lang.CloneNotSupportedException {
+        // clone() method for enhancer testing purpose
+        final empdept.Employee pc = (empdept.Employee)super.clone();
+        pc.birthdate = this.birthdate;
+        pc.department = this.department;
+        pc.empid = this.empid;
+        pc.name = this.name;
+        return pc;
+    }
+
+    public long getEmpid() {
+        return empid;
+    }
+    
+    public void setEmpid(long empid) {
+        this.empid = empid;
+    }
+
+    public String setName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public java.util.Date getBirthdate() {
+        return birthdate;
+    }
+    
+    public void setBirthdate(Date birthdate) {
+        this.birthdate = birthdate;
+    }
+    
+    public Department getDepartment() {
+        return department;
+    }
+    
+    public void setDepartment(Department department) {
+        this.department = department;
+    }
+    
+    public static class Oid
+        implements java.io.Serializable {
+        public long empid;
+    
+        public Oid() {
+            super();
+        }
+    
+        public Oid(String str) {
+            // not implemented yet
+            throw new UnsupportedOperationException();
+        }
+    
+        public int hashCode() {
+            int hash = 0;
+            hash += (int)empid;
+            return hash;
+        }
+    
+        public boolean equals(java.lang.Object pk) {
+            if (pk == null || !this.getClass().equals(pk.getClass())) {
+                return false;
+            }
+            Oid oid = (Oid)pk;
+            if (this.empid != oid.empid) return false;
+            return true;
+        }
+    
+    }    
+}
+

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/FullTimeEmployee.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/FullTimeEmployee.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/FullTimeEmployee.java (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/FullTimeEmployee.java Sun May
22 10:55:51 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 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 empdept;
+
+
+/**
+ * A sample employee subclass.
+ */
+public class FullTimeEmployee extends Employee {
+    private double salary;
+    
+    public FullTimeEmployee() {
+    }
+    
+    public FullTimeEmployee(String str) {
+        super();
+    }
+
+    public Object clone() throws java.lang.CloneNotSupportedException {
+        // clone() method for enhancer testing purpose
+        final empdept.FullTimeEmployee pc = (empdept.FullTimeEmployee)super.clone();
+        pc.salary = this.salary;
+        return pc;
+    }
+
+    public double getSalary() {
+        return salary;
+    }
+    
+    public void setSalary(double salary) {
+        this.salary = salary;
+    }
+}

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/PartTimeEmployee.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/PartTimeEmployee.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/PartTimeEmployee.java (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/PartTimeEmployee.java Sun May
22 10:55:51 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2005 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 empdept;
+
+
+/**
+ * A sample employee subclass.
+ */
+public class PartTimeEmployee extends Employee {
+    private int cid;
+    private double wage;
+    
+    public PartTimeEmployee() {
+    }
+    
+    public PartTimeEmployee(String str) {
+        super();
+    }
+
+    public Object clone() throws java.lang.CloneNotSupportedException {
+        // clone() method for enhancer testing purpose
+        final empdept.PartTimeEmployee pc = (empdept.PartTimeEmployee)super.clone();
+        pc.cid = this.cid;
+        pc.wage = this.wage;
+        return pc;
+    }
+
+    public int getCid()
+    {
+        return this.cid;
+    }
+
+    public void setCid(int cid)
+    {
+        this.cid = cid;
+    }
+
+    public double getWage() {
+        return wage;
+    }
+    
+    public void setWage(double wage) {
+        this.wage = wage;
+    }
+
+    public static class Oid
+        extends empdept.Employee.Oid
+        implements java.io.Serializable {
+        public int cid;
+    
+        public Oid() {
+            super();
+        }
+    
+        public Oid(String str) {
+            super(str);
+            // not implemented yet
+            throw new UnsupportedOperationException();
+        }
+    
+        public int hashCode() {
+            int hash = super.hashCode();
+            hash += (int)cid;
+            return hash;
+        }
+    
+        public boolean equals(java.lang.Object pk) {
+            if (!super.equals(pk)) {
+                return false;
+            }
+            Oid oid = (Oid)pk;
+            if (this.cid != oid.cid) return false;
+            return true;
+        }    
+    }    
+}

Added: incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/package.jdo?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/package.jdo (added)
+++ incubator/jdo/trunk/enhancer20/test/sempdept/src/empdept/package.jdo Sun May 22 10:55:51
2005
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN"
"http://java.sun.com/dtd/jdo_1_0.dtd">
+<jdo>
+  <package name="empdept">
+
+    <class name="Department"
+    	   objectid-class="empdept.Department$Oid"
+           identity-type="application">
+      <field name="deptid"
+	     primary-key="true"
+	     default-fetch-group="false"
+	     persistence-modifier="persistent"/>
+      <field name="name"
+	     default-fetch-group="true"
+	     persistence-modifier="persistent"/>
+      <field name="employees"
+	     persistence-modifier="persistent">
+        <collection element-type="Employee"/>
+      </field>
+    </class>
+
+    <class name="Employee"
+    	   objectid-class="empdept.Employee$Oid"
+           identity-type="application">
+      <field name="empid"
+	     primary-key="true"
+	     default-fetch-group="false"
+	     persistence-modifier="persistent"/>
+      <field name="name"
+	     default-fetch-group="true"
+	     persistence-modifier="persistent"/>
+      <field name="birthdate"
+	     default-fetch-group="false"
+	     persistence-modifier="persistent"/>
+      <field name="department"
+	     persistence-modifier="persistent"/>
+    </class>
+
+    <class name="FullTimeEmployee" 
+           identity-type="application" 
+           persistence-capable-superclass="Employee">
+      <field name="salary"
+	     default-fetch-group="true"
+	     persistence-modifier="persistent"/>
+    </class>
+
+    <class name="PartTimeEmployee" 
+           identity-type="application" 
+    	   objectid-class="empdept.PartTimeEmployee$Oid"
+           persistence-capable-superclass="Employee">
+      <field name="cid"
+	     primary-key="true"
+	     default-fetch-group="false"
+	     persistence-modifier="persistent"/>
+      <field name="wage"
+	     default-fetch-group="true"
+	     persistence-modifier="persistent"/>
+    </class>
+
+  </package>
+</jdo>



Mime
View raw message