Hi Wim,
the advantage of your suggestion is - as you said - that you can deploy each
module of its own.
However there exists at least one disadvantages/problem you have to solve
using your approach:
Imagine you have 4 EJB modules A, B, C and D. B and C depend on A and D
depends on B and C:
B
/ \
A D
\ /
C
If Module B and C contain the EJBs of Module A and you merge them to module
D you would have the EJBs of module A two times in module D.
In our approach module D is configued to have dependencies to module A, B
and C:
A
\
B - D
/
C
A, B and C contain only those EJBs in their DD that are defined within them
(i.e. B and C do not contain those of module A, and D doesn't contain those
of A, B or C). If we want to create for D a deployable jar (or ear) we call
a different goal that creates one jar 'D-ejb.jar' that contains only a
META-INF directory with the merged DDs and a manifest.mf referencing A.jar,
B.jar, C.jar and D.jar. We put all these jars into one deployable EAR.
Note that we distinguish between a product and a module in our approach. A
module is a 'normal' jar whereas a product is an EJB jar or EAR that can be
deployed.
Comments or suggestions are always welcome,
J�rn
> -----Urspr�ngliche Nachricht-----
> Von: Wim Lambrecht [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 25. M�rz 2004 17:01
> An: 'Maven Users List'
> Betreff: RE: EJB Deployment descriptor configuration
>
>
> J�rn,
>
> In a previous reply you mentioned "... normal jar (i.e. has
> no META-INF
> directory) that contains a special configuration directory
> that contains
> the deployment descriptors (ejb-jar, jboss.xml etc.) generated by
> XDoclet. ...".
>
> Say that you don't use the 'normal jar' approach, but the
> real 'ejb-jar'
> one. I guess you could easy adjust your goals to manipulate the
> ejb-jar.xml files.
> The extra advantage would be that each EJB-jar would have a default
> configuration present and one could use it directly in a project. In
> your case you always have to rebuilt al the EJB-jars.
> e.g. the people for the hint below (ivata, Colin MacLeod) use this
> approach.
>
> What do you think ?
> Greetings
> -wil-
>
>
> -----Oorspronkelijk bericht-----
> Van: J�rn Gebhardt [mailto:[EMAIL PROTECTED]
> Verzonden: woensdag 24 maart 2004 15:59
> Aan: Maven Users List
> Onderwerp: AW: EJB Deployment descriptor configuration
>
> Hi Wil,
>
> thanks for the hint you got in the XDoclet mailing list (I
> didn't take a
> closer look at it right now, but I definitely will...).
> As mentioned before do we not use arch4j but XSLT.
> Our plugin contains the following two goals for merging DDs.
> Here's the
> Jelly script part for merging ejb-jar.xml files (jboss.xml and
> jbosscmp-jdbc.xml are very similar).
>
>
> <!--
> ==============================================================
> ==========
> jabba:_collect-dds
>
> ==============================================================
> ==========
> =
> -->
> <goal name="jabba:_collect-dds"
> description="Internal Goal! Retrieves the deployment
> descriptor
> fragments out of
> those jar files that have the 'jabba.dd.merge'
> property
> set to true in the POM.
> It takes these fragments out of the jabba-conf
> directory.">
>
>
> <ant:mkdir dir="${maven.jabba.conf.dir}"/>
> <ant:mkdir dir="${maven.jabba.temp.dir}/dds"/>
> <ant:mkdir dir="${maven.jabba.gen.dds.dir}"/>
>
>
> <!-- unpack jabb-conf dir of marked artifacts -->
> <j:forEach var="lib" items="${pom.artifacts}">
> <j:set var="dep" value="${lib.dependency}"/>
> <j:if test="${dep.getProperty('jabba.dd.merge')=='true'}">
> <ant:unzip
> dest="${maven.jabba.temp.dir}/dds/${lib.file.name}">
> <patternset>
> <include name="jabba-conf/**/*.*"/>
> </patternset>
> <fileset dir="${lib.file.parent}">
> <include name="${lib.file.name}"/>
> </fileset>
> </ant:unzip>
> </j:if>
> </j:forEach>
>
>
> <!-- find all ejb-jar.xml files and write them into
> ejb-jar-files.xml -->
> <ant:fileScanner var="ejbJarFiles">
> <ant:fileset dir="${maven.jabba.temp.dir}/dds">
> <ant:patternset>
> <ant:include name="**/ejb-jar.xml"/>
> </ant:patternset>
> </ant:fileset>
> </ant:fileScanner>
>
> <j:file name="${maven.jabba.temp.dir}/dds/ejb-jar-files.xml"
> outputMode="xml"
> prettyPrint="true"
> encoding="UTF-8">
> <x:element name="files">
> <j:forEach var="file"
> items="${ejbJarFiles.iterator()}">
> <x:element
> name="file">${file.toString()}</x:element>
> </j:forEach>
> </x:element>
> </j:file>
>
> </goal>
>
>
> <!--
> ==============================================================
> ==========
> jabba:_merge-dds
>
> ==============================================================
> ==========
> =
> -->
>
> <goal name="jabba:_merge-dds"
> description="Internal Goal! Merges the deployment descriptor
> fragments of the dependent jars
> that are located in the jabba-conf directory."
> prereqs="jabba:_collect-dds">
>
>
> <!-- set JAXP XSL transformer: -->
> <j:invoke var="${systemScope}" method="setProperty"
> on="${systemScope}">
> <j:arg type="java.lang.String"
> value="javax.xml.transform.TransformerFactory" />
> <j:arg type="java.lang.String"
> value="org.apache.xalan.processor.TransformerFactoryImpl" />
> </j:invoke>
>
> <!-- merge ejb-jar.xml deployment descriptors -->
> <ant:xslt
> in="${maven.jabba.temp.dir}/dds/ejb-jar-files.xml"
> out="${maven.jabba.gen.dds.dir}/ejb-jar.xml"
> style="${plugin.resources}/merge-ejb-jar.xsl">
> <xmlcatalog>
> <dtd publicId="-//Sun Microsystems, Inc.//DTD
> Enterprise
> JavaBeans 2.0//EN"
>
> location="${plugin.resources}/ejb-jar_2_0.dtd"/>
> </xmlcatalog>
> </ant:xslt>
>
> </goal>
>
>
> The following xsl style sheet is used for the merge process
> (very simple
> approach that contains no validations or other merge logic:
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <!-- <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD
> Enterprise
> JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> -->
> <xsl:output method="xml" encoding="UTF-8"
> doctype-system="http://java.sun.com/dtd/ejb-jar_2_0.dtd"
> doctype-public="-//Sun Microsystems, Inc.//DTD Enterprise
> JavaBeans
> 2.0//EN"
> cdata-section-elements="description ejb-ql"/>
> <xsl:template match="/">
>
> <ejb-jar>
> <description><![CDATA[No Description.]]></description>
> <display-name>Generated by XDoclet</display-name>
>
> <!-- List of all EJBs -->
> <xsl:comment>List of all EJBs</xsl:comment>
> <enterprise-beans>
> <!-- Session Beans -->
> <xsl:comment>Session Beans</xsl:comment>
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/enterprise-beans/session"/>
> </xsl:for-each>
>
> <!-- Entity Beans -->
> <xsl:comment>Entity Beans</xsl:comment>
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/enterprise-beans/entity"/>
> </xsl:for-each>
>
> <!-- Message Driven Beans -->
> <xsl:comment>Message Driven Beans</xsl:comment>
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/enterprise-beans/message-driven"/>
> </xsl:for-each>
> </enterprise-beans>
>
>
> <!-- Relationships -->
> <xsl:comment>Relationships</xsl:comment>
> <relationships>
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/relationships/ejb-relation"/>
> </xsl:for-each>
> </relationships>
>
>
> <!-- Assembly Descriptor -->
> <xsl:comment>Assembly Descriptor</xsl:comment>
> <assembly-descriptor>
> <!-- security roles -->
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/assembly-descriptor/security-role"/>
> </xsl:for-each>
>
> <!-- method permissions -->
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/assembly-descriptor/method-permission"/>
> </xsl:for-each>
>
> <!-- container transaction -->
> <xsl:for-each select="files/file">
> <xsl:variable name="file" select="document(text())"/>
> <xsl:copy-of
> select="$file/ejb-jar/assembly-descriptor/container-transaction"/>
> </xsl:for-each>
> </assembly-descriptor>
> </ejb-jar>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Hope this helps,
> J�rn
>
> > -----Urspr�ngliche Nachricht-----
> > Von: Wim Lambrecht [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 24. M�rz 2004 12:19
> > An: 'Maven Users List'
> > Betreff: RE:AW:EJB Deployment descriptor configuration
> >
> >
> > Hi J�rn,
> >
> > Thanks for your fast reply.
> > The ['raw'-jars with seperate DD] (configurable via
> > XSLT) approach
> > could be a satisfying solution. We could split de DD in
> changeable and
> > un-changeble pieces. De end-deployers can access de
> > changeable pieces of
> > the DD OR even better, provide there own overriden version. And then
> > it's easy to assemble then just-in-time (At this point it
> > would be nice
> > to do so verification of the EJBJAR, using a 'verifier'
> (jboss). Maybe
> > we need a plugin for that, or make one ...).
> > How do you handle the XSLtransformation, i mean, the nice
> way would be
> > to have a maven XSLT plugin, but there is none for moment.
> >
> > I've posted the same question on the xdoclet-users mailinglist
> > (since this could be a xdoclet issue too). I've received a reply and
> > like to bounce it to you too:
> >
> > [Hi Wim,
> >
> > > Of course, the latter, involves some unjar/rejar too, but
> > it should be
> >
> > > ideal that configuration takes place in an automated
> manner IN the
> > > current project.
> >
> > I had almost exactly the same situation in ivata op - the
> open source
> > groupware project I'm working on. In my case I had several
> > EJB jar files
> > I wanted to combine into one. Each EJB jar has a separate
> subproject,
> > with a maven build that is combined using the multiproject
> mechanism.
> >
> > My solution was to develop a maven plugin. This takes the
> > ejbs from the
> > repositories and merges them together. Then the XML descriptors are
> > extracted and I use dom4j to combine those and jar them into the
> > combined target.
> >
> > The maven plugin is quite separate to the rest of my project. If you
> > download the source package from http://ivata.org (click on
> > the download
> > link at the top), you should be able to see what I mean.
> >
> > The plugin lives in thirdparty/maven/ejbmerge and it depends
> > on another
> > jar project in thirdparty/maven/merge.
> >
> > If you want an example of how I used it, look in
> > openportal/ejb. You'll
> > see there is a file in openportal/ejb/src/xml/XMLMerger.xml
> > which tells
> > the merge process how to combine the descriptors.
> >
> > Take a look. Hope this can help you out.
> >
> > Cheers,
> > Colin
> > __________________________________________________
> > Colin MacLeod
> > [EMAIL PROTECTED]
> > ivata.org - open source enterprise groupware]
> >
> >
> >
> >
> > -----Oorspronkelijk bericht-----
> > Van: J�rn Gebhardt [mailto:[EMAIL PROTECTED]
> > Verzonden: woensdag 24 maart 2004 11:19
> > Aan: Maven Users List
> > Onderwerp: AW: EJB Deployment descriptor configuration
> >
> > Hi Wim,
> >
> > we have a very similar issue. We have many modules containing
> > EJBs, each
> > in
> > a separate Maven project. We are combining these modules to
> a product
> > and
> > merge the deployment descriptors using XSLT. To achieve this, each
> > module is
> > a normal jar (i.e. has no META-INF directory) that contains
> a special
> > configuration directory that contains the deployment descriptors
> > (ejb-jar,
> > jboss.xml etc.) generated by XDoclet.
> >
> > When creating a product that is composed of some modules we first
> > generate
> > an EJB jar that contains only the merged deployment
> > descriptors and the
> > classpath references in the manifest, and afterwards we
> build the EAR
> > that
> > contains the normal modules jars and the just created EJB jar.
> >
> > However this approach doesn't include your product specific
> changes in
> > the
> > EJB DDs of the modules. Here an additional step would be
> needed (most
> > likely
> > in the merged DD).
> >
> > Best regards,
> > J�rn
> >
> > > -----Urspr�ngliche Nachricht-----
> > > Von: Wim Lambrecht [mailto:[EMAIL PROTECTED]
> > > Gesendet: Mittwoch, 24. M�rz 2004 10:57
> > > An: [EMAIL PROTECTED]
> > > Betreff: EJB Deployment descriptor configuration
> > >
> > >
> > > Hi there,
> > >
> > > This is actually a 'configuration' issue.
> > >
> > > i have the following situation:
> > > I want to assemble an J2EE application (ear) which consist of 2
> > > EJB-JARS.
> > > One of de EJB-JARS contains 'common' stuff (let's say, like
> > > user-management, authentication, authorisation) and is an artifact
> > > created via a seperate maven project (so, is independant of
> > > my project).
> > > Let's call this one the COMMON-EJB.jar. Its contains all the usual
> > > stuff, including the corresponding deployment descriptor "DD"
> > > (which is
> > > the configurable part).
> > >
> > > Now, this COMMON-EJB.jar is used in my current project and will be
> > > packaged in the final production EAR. But, and this is the
> > > issue, i want
> > > to re-configure the deployment descriptor (in my
> > application context)
> > > just before the EAR-packaging. I know that, if done manually,
> > > this is no
> > > problem, but i'm looking for an automated way.
> > > Manually i should take the COMMON-EJB.jar, unjars it,
> > change the DD to
> > > my wishes, jar it again, and then use it in my EAR. 'Automated' is
> > > something like: the desired changes for the DD are described
> > > somewhere,
> > > and some script (plugin, pregoal, whatever) applies those
> > > changes to the
> > > original DD (by the way, DD doesn't support inheritance, like the
> > > properties-cascade in Maven does). Which is then used in the
> > > production
> > > EAR.
> > > Of course, the latter, involves some unjar/rejar too, but
> > it should be
> > > ideal that configuration takes place in an automated manner IN the
> > > current project.
> > > So, in the end (in my project built), type 'maven' in the
> > > command line,
> > > and that's it.
> > >
> > > Any ideas, feelings, ...?
> > >
> > > t i a
> > > -wil-
> > >
> > > P.S.
> > > 1. the EJB-jars in the common and in my project are built
> > > with the maven
> > > xdoclet plugin. No problem in that matter.
> > > 2. what re-configurations do i have in mind ? Well: change
> > > transaction-types on bean-methods ; add resourcerefs - like
> > > DataSources
> > > - on enterprise beans, ... the usual stuff a deployer
> does, ... The
> > > session-bean <> entity bean relations (ejbrefs) for instance
> > > can remain
> > > xdoclet-generated IMHO. but here i don't want to
> > (xdoclet)generate the
> > > common beans things again, they should still be provided
> as a EJBJAR
> > > generated in that other project earlier).
> > > 3. in fact, i guess this is a common issue, no ? Not only EJB
> > > Deployment
> > > Descriptors, but all configurable things linked to
> > (packaged inside) a
> > > deliverable (properties-files, EAR DD's, WAR web-inf, etc.),
> > > will sooner
> > > or later in de deploy-proces needs some re-configuration. But
> > > it should
> > > be nice that this configurations be applied automatically.
> > >
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>