Enhance at buildtime.

Enhancing at runtime might be OK to start learning as it quicker to start 
coding but it comes with lots of problems and limitations.

I would say enhancing at build time is not an option for any serious 
developments.
Finally, enhancing at build time is only a matter of one simple ant task, so 
there are no excuse :-)

You can use that macrodef I setup for my project :
macrodef is really (really really) powerfull ant concept.

    <macrodef name="enhance"
              description="This will enhance annotated Java entity classes.">

        <attribute name="class-dir"
                   description="The class folder where to find .class file 
annotated and enhanced using OpenJPA"/>
        <attribute name="persistence-xml-file" description="The full path to 
the persistence.xml file"/>
        <attribute name="lib-dir"
                   description="Folder where to find /openjpa and /jpa folders 
that contains all the .jar"/>

        <sequential>
            <taskdef name="openjpac" 
classname="org.apache.openjpa.ant.PCEnhancerTask">
                <classpath>
                    <fileset dir="@{lib-dir}">
                        <include name="**/*.jar"/>
                    </fileset>
                    <pathelement location="@{class-dir}"/>
                </classpath>
            </taskdef>
            <openjpac>
                <config propertiesFile="@{persistence-xml-file}"/>
                <classpath>
                    <fileset dir="@{lib-dir}">
                        <include name="**/*.jar"/>
                    </fileset>
                    <pathelement location="@{class-dir}"/>
                </classpath>
            </openjpac>
            <mkdir dir="@{class-dir}/META-INF"/>
            <copy todir="@{class-dir}/META-INF" description="Copy 
persistence.xml to META-INF" overwrite="yes">
                <fileset file="@{persistence-xml-file}"/>
            </copy>
        </sequential>
    </macrodef>



To use that macro :

    <target name="enhance-build">
        <echo message="Enhancing build ..."/>
        <enhance class-dir="${build-class-dir}" 
persistence-xml-file="${persistence-xml-file}" lib-dir="../lib"/>
        <echo message="Enhancing build complete."/>
    </target>


Hope this helps.

On Apr 27, 2010, at 06:14 , SreeAsh wrote:

> 
> Hi Ravi,
> 
>        thanks for reply...
> 
>      At runtime, i am not done any enhance my application, by default it's
> enhancing at run time.Please suggest the is its right or we need to do any
> enhancer before deploy.
> 
> regards
> Srini
> 
> 
> -- 
> View this message in context: 
> http://openjpa.208410.n2.nabble.com/After-statting-the-server-login-time-taking-2-minutes-tp4962106p4966520.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to