Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Static Weaving through Eclipse Plug-in
Static Weaving through Eclipse Plug-in [message #536189] Thu, 27 May 2010 10:57 Go to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
Hi,

I am wondering whether it is planned to include static weaving as a feature in the Dali/EclipseLink Support plug-in in the future.

I think this would fundamentally ease static weaving, since current methods (e.g., ant task) are quite cumbersome to install - especially in a distributed development environment.

A similar feature exists for example in the Google Eclipse plug-in for App Engine, where the DataNucleus Enhancer is automatically run after each build.

Best regards,
marco
Re: Static Weaving through Eclipse Plug-in [message #537742 is a reply to message #536189] Thu, 03 June 2010 14:11 Go to previous messageGo to next message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
Hi Marco,

This is a feature that's been identified but has not been captured in a bug or scheduled. Most people do use dynamic weaving as there are only a few instances where it's problematic which is why it hasn't gotten much attention. That said, I think it's a good feature to provide. Can you file a bug against Dali for this?

BTW, EclipseLink provides an ant task for static weaving and it should be straightforward to add a small ant build that is run as part of building. The static weaving task supports in place weaving so .class files aren't moved. This feature was added specifically for IDE integration.

--Shaun
Re: Static Weaving through Eclipse Plug-in [message #538313 is a reply to message #536189] Mon, 07 June 2010 10:22 Go to previous messageGo to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
Hi Shaun,

first of all thanks for your answer. Indeed, dynamic weaving is the preferable option - however, not applicable for JUnit Testing as well as deployments to Tomcat (which is our current deployment target).

I played around with integrating the ant task in our Eclipse build, but with limited success. This may be due to our "special" dev config. We use Maven (and the Maven Eclipsep plug-in) for dependency management as well as for packaging the application. Regular builds during development are done in Eclipse. However, due to using Maven our dependencies are kept outside from the application path during development (in the maven user repo). Using the ant task I experienced that these dependencies cannot be accessed without setting an absolute classpath for every developer (or duplicating the jars within the application path). Therefore, I stopped investigating a solution relying on the Ant task. If there is an option to do so, I would appreciate any hints.

In the meantime I will file an RFE for Dali as you proposed.

Thanks, marco
Re: Static Weaving through Eclipse Plug-in [message #538564 is a reply to message #538313] Tue, 08 June 2010 00:57 Go to previous messageGo to next message
Ari Meyer is currently offline Ari MeyerFriend
Messages: 136
Registered: July 2009
Senior Member
Hi Marco,

I use Maven and Eclipse (and the Maven Eclipse plugin) as well. I set
up a launch config in Eclipse to execute static weaving on demand, and
here it is as exported:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/***PROJECT***"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.eclipse.persistence.tools.weaving.jpa.StaticWeave "/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-loglevel FINEST -persistenceinfo src/main/resources
target/classes target/classes"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="***PROJECT***"/>
</launchConfiguration>

You can replace the "***PROJECT***" placeholders with your Eclipse
project name and then import that launch config, if you'd like. Notice
the MAIN_TYPE and PROGRAM_ARGUMENTS. As long as the eclipselink JAR is
in your Build Path, this should work for you.

Also, here's the relevant part of my Maven config (including an
alternate, commented-out version):

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>JPA Enhancement</id>
<phase>process-classes</phase>
<configuration>
<tasks>
<taskdef
name="weave"

classname=" org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask "
classpathref="maven.test.classpath"/>
<weave
loglevel="FINEST"
source="${basedir}/target/classes"
target="${basedir}/target/classes"
persistenceinfo="${basedir}/src/main/resources">
<classpath refid="maven.test.classpath"/>
</weave>

<!--
<java
classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave "
classpathref="maven.test.classpath"
fork="true">
<arg
line="-loglevel FINEST -persistenceinfo
src/main/resources target/classes target/classes"/>
</java>
-->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>


and here's where I originally got it from:
http://www.tzavellas.com/techblog/2008/10/17/statically-weav ing-jpa-entities-for-eclipselink-using-maven/

Best regards,
Ari


marco wrote:
> Hi Shaun,
>
> first of all thanks for your answer. Indeed, dynamic weaving is the
> preferable option - however, not applicable for JUnit Testing as well as
> deployments to Tomcat (which is our current deployment target).
> I played around with integrating the ant task in our Eclipse build, but
> with limited success. This may be due to our "special" dev config. We
> use Maven (and the Maven Eclipsep plug-in) for dependency management as
> well as for packaging the application. Regular builds during development
> are done in Eclipse. However, due to using Maven our dependencies are
> kept outside from the application path during development (in the maven
> user repo). Using the ant task I experienced that these dependencies
> cannot be accessed without setting an absolute classpath for every
> developer (or duplicating the jars within the application path).
> Therefore, I stopped investigating a solution relying on the Ant task.
> If there is an option to do so, I would appreciate any hints.
> In the meantime I will file an RFE for Dali as you proposed.
>
> Thanks, marco
Re: Static Weaving through Eclipse Plug-in [message #538579 is a reply to message #537742] Tue, 08 June 2010 04:59 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
> Most people do use dynamic weaving as there are only a
> few instances where it's problematic which is why it hasn't gotten much
> attention.

The fact that most people use dynamic binding amazes me a bit. Setting up dynamic weaving requires an, ah, annoying configuration setting where the standard startup scripts of whatever is responsible for starting Java need to be altered. To me the feels like technical aspects of a certain library are "leaking" outside of it's development container or the application's configuration context.

I really prefer static weaving; you then build an artifact that is capable of running without any out-of-its-box stuff, just configuration of a JDBC connection. And by using programmatic configuration (through helper methods) it can easily integrate with whatever configuration mechanism is being used. I only use dynamic weaving during development, because there is no Eclipse plugin that static weaves on demand.

This black-box approach kinda is the basis for a good business model IMHO by encapsulating as much as possible. (Now if only the events were good enough to allow the same level of capsulation, I'd be in separation-of-responsibilities heaven :-)

Tom
Re: Static Weaving through Eclipse Plug-in [message #538800 is a reply to message #536189] Tue, 08 June 2010 16:39 Go to previous messageGo to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
Ari,

thanks for sharing your launch configuration. However, as you wrote this initiates weaving only on demand - I am seeking a solution which integrates seamlessly into the Eclipse build process and is portable across various dev machines.

Anyway, it is a good starting point until the RFE for including static weaving into Dali may (hopefully) be picked up.

regards,
marco
Re: Static Weaving through Eclipse Plug-in [message #538898 is a reply to message #538800] Wed, 09 June 2010 01:47 Go to previous messageGo to next message
Ari Meyer is currently offline Ari MeyerFriend
Messages: 136
Registered: July 2009
Senior Member
Sure Marco. One other option may be M2Eclipse, as it's supposed to
enable incremental builds -- perhaps there's a hook whereby you could
invoke the enhancer only when an Entity has been (re)compiled. It's in
alpha and I've had issues with it, though, so I'm putting up with
on-demand enhancement for now. :-)
Ari

marco wrote:
> Ari,
>
> thanks for sharing your launch configuration. However, as you wrote this
> initiates weaving only on demand - I am seeking a solution which
> integrates seamlessly into the Eclipse build process and is portable
> across various dev machines.
>
> Anyway, it is a good starting point until the RFE for including static
> weaving into Dali may (hopefully) be picked up.
>
> regards,
> marco
Re: Static Weaving through Eclipse Plug-in [message #538957 is a reply to message #536189] Wed, 09 June 2010 07:57 Go to previous messageGo to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
I tried out m2eclipse once, but I experienced too many issues - so we are using the Eclipse Maven Plug-In from command line.

Regarding weaving, I will stick to your approach for the moment.

regards,
marco
Re: Static Weaving through Eclipse Plug-in [message #539240 is a reply to message #536189] Thu, 10 June 2010 07:11 Go to previous messageGo to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
btw: this is the link to the RFE in the Dali Bugzilla

https://bugs.eclipse.org/bugs/show_bug.cgi?id=315949

regards,
marco
Re: Static Weaving through Eclipse Plug-in [message #541292 is a reply to message #536189] Sat, 19 June 2010 15:34 Go to previous messageGo to next message
marco is currently offline marcoFriend
Messages: 21
Registered: May 2010
Junior Member
The Dali team wants to identify the community interest in this feature. So please comment/vote the bug if you are interested (https://bugs.eclipse.org/bugs/show_bug.cgi?id=315949)
Re: Static Weaving through Eclipse Plug-in [message #542146 is a reply to message #541292] Thu, 24 June 2010 04:52 Go to previous message
Fericit Bostan is currently offline Fericit BostanFriend
Messages: 68
Registered: June 2010
Member
I've been doing static weaving from within Eclipse for my JPA projects by simply defining an ant script to perform the weaving and adding it to the build process in the project properties. I really don't think anyone needs to write a plugin when this can be incorporated into the build process so easily. I never use dynamic weaving.

Here is the script. Simply edit it accordingly.

<?xml version="1.0"?>
<project name="jpa-weaving" default="weaving" basedir="./../..">
    <property environment="env"/>
    <property name="glassfish.home" value="${env.GLASSFISH_HOME}"/>
    <path id="weavingclasspath">
        <pathelement location="${glassfish.home}/lib/javaee.jar"/>
        <pathelement location="${glassfish.home}/modules/org.eclipse.persistence.core.jar"/>
        <pathelement location="${glassfish.home}/modules/org.eclipse.persistence.jpa.jar"/>
    </path>
	
    <target name="define.task" description="New task definition for EclipseLink static weaving"	>
        <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
            <classpath refid="weavingclasspath"/>
        </taskdef>
    </target>

    <target name="weaving" description="perform weaving" depends="define.task">
        <weave source="${basedir}/target/classes" target="${basedir}/target/classes">
            <classpath refid="weavingclasspath"/>
        </weave>
    </target>
</project>

Previous Topic:IN_OUT Parameters not working for NamedStoredProcedureQuery
Next Topic:managing in-memory references held on the owning side
Goto Forum:
  


Current Time: Thu Nov 27 21:02:49 GMT 2014

Powered by FUDForum. Page generated in 0.02863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software