You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Conor MacNeill <co...@cortexebusiness.com.au> on 2000/05/07 14:56:07 UTC

Tasks for ejbc compile of weblogic EJBs

Hi,

Attached are two task definitions and a small set of patches to allow you to
use ant to build weblogic EJBs. I developed these tasks for building EJBs
here at Cortex and Cortex have agreed to let me give them to the ant
project.

The new code consists of two optional ant tasks: ddcreator and ejbc.
ddcreator takes a set of deployment descriptor definitions according to the
weblogic definition language and generates the serialised deployment
descriptors, while ejbc takes the serialised deployment descriptor and
generates the various EJB support files required by Weblogic, including the
RMI stubs and skeletons. Both tasks only generate a result if it is out of
date with respect to the source.

Example usage of the ddcreator task would be

    <ddcreator descriptors="${dd.dir}" dest="${gen.classes}"
               classpath="${descriptorbuild.classpath}">
        <include name="*.txt" />
    </ddcreator>

where

descriptors is the directory where the text descriptor defintions are
located
dest is the directory where the serialised deployment descriptors are
written
classpath should include the  weblogic tools and the classes containing the
home and remote interfaces for the various EJBs

The ejbc task is a little more complicated.

    <ejbc descriptors="${gen.classes}" src="${src.dir}"
dest="${gen.classes}"
          manifest="${build.manifest}"
          classpath="${descriptorbuild.classpath}">
        <include name="*.ser" />
    </ejbc>

where

descriptors in this case is the directory where the serialised deployment
descriptors are located
src is the directory containing the source defining the home and remote
interfaces
dest is the directory where the generated support classes are written
manifest is a generated jar manifest file defining all of the EJBs to be
included
classpath should again contains the weblogic tools plus the home, remote and
bean classes.

Both tasks are MatchingTasks and the include element is generally used to
select the appropriate files.

The implementation of these tasks supports the way we have been building
EJBs at Cortex. In particular I set the ejbc options to those we currently
use. If it doesn't fit with other organisations, let me know. Also this is
geared to WebLogic 4.5. I have not yet looked at 5.1.

The implementation details of the two tasks are worth looking at a little
bit more closely. Both tasks are implemented as an ant task with a separate
helper class which is executed in a separate JVM. This is done because I
wanted to control the classpath under which the weblogic tools were
executed. The weblogic tools generally require the classpath to include the
class files for the home and remote interfaces of the beans you are
developing. I did not want to have to startup ant with its classpath
including the project it is compiling. Thus the ant tasks simply delegate
all the work to the helper in a separate JVM.

To create that JVM and have its output pumped into the project log, I used a
Java task object. I needed to modify the ant Task object, however, to make
the setProject method public so I could connect the project to the Java
task. I also added a validateDirectory method which allows any task to
validate that a given File object represents a directory and that the
directory exists. This could probably be used by a few other tasks.

Let me know what you think, especially if you are using WebLogic.

Cheers
Conor

--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex ebusiness Pty Limited

Re: Tasks for ejbc compile of weblogic EJBs

Posted by Roger Vaughn <rv...@seaconinc.com>.
Conor MacNeill wrote:
> 
> >
> > Just in time - I was about to write my own tasks for this.
> >
> > These classes will not compile with the current public version of Ant,
> > however.
> > The method "validateDirectory" is not found, and method "setProject" is
> > available
> > in Task, but is package-scope only.  I also notice that your usage
> > examples show
> > a different syntax for includes than is supported by the public version.
> >
> > What am I missing here?  Should I be using a development version of Ant
> > instead?
> >
> Robert,
> 
> I included a file (diffs.txt) which has some diffs to the core ant classes
> which I added to support these tasks. To build these tasks you will need to
> apply these diffs. If you read the last paragraph of my original email, you
> will see why I made these changes. I am hoping one of the committers will
> apply them.
> 
> The include support is provided by the MatchingTask superclass. The includes
> can be defined in two ways, either as an includes attribute or by nested
> <include> elements. Is that what you mean by a different syntax?
> 
> Good Luck, let me know if you can't get them going.
> 
> Conor

Conor,

Gee, I somehow missed that attachment.  Time to check the ol' seat to
keyboard
connection I think.  I'll apply that patch and see how things go.

Yes, the nested include elements were what I meant.  I wasn't aware that
syntax was allowed, but I like it better!  Thanks for the unintentional
tip.

BTW, I slapped together a "cab" task similar to the "zip" and "jar"
tasks in case anyone is interested.  It only runs on WinDoze and
requires the external cabarc util.  I hate the necessity, but cab files
are the only way I know of to deliver signed applets to IE.

Roger

Re: Tasks for ejbc compile of weblogic EJBs

Posted by Roger Vaughn <rv...@seaconinc.com>.
Conor MacNeill wrote:
> 
> Robert,
> 
> I included a file (diffs.txt) which has some diffs to the core ant classes
> which I added to support these tasks. To build these tasks you will need to
> apply these diffs. If you read the last paragraph of my original email, you
> will see why I made these changes. I am hoping one of the committers will
> apply them.
> 
> The include support is provided by the MatchingTask superclass. The includes
> can be defined in two ways, either as an includes attribute or by nested
> <include> elements. Is that what you mean by a different syntax?
> 
> Good Luck, let me know if you can't get them going.
> 
> Conor

Conor,

I got your EJBC tasks going in my project.  We're using WebLogic 4.0
(don't ask - not my decision...) so I had to make a few minor tweaks.  I
had to take out the "-noexit" options which apparently aren't present in
4.0, and also to my preference, removed the "-keepgenerated" option. 
This latter one would make a good optional tag attribute.  I also found
that the bean stub name has apparently changed between versions - my ejb
compiler is producing *_ServiceStub where you have *_WLStub.  An easy
change, anyway.

Thanks for the good work!

Roger

RE: Tasks for ejbc compile of weblogic EJBs

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
>
> Just in time - I was about to write my own tasks for this.
>
> These classes will not compile with the current public version of Ant,
> however.
> The method "validateDirectory" is not found, and method "setProject" is
> available
> in Task, but is package-scope only.  I also notice that your usage
> examples show
> a different syntax for includes than is supported by the public version.
>
> What am I missing here?  Should I be using a development version of Ant
> instead?
>
Robert,

I included a file (diffs.txt) which has some diffs to the core ant classes
which I added to support these tasks. To build these tasks you will need to
apply these diffs. If you read the last paragraph of my original email, you
will see why I made these changes. I am hoping one of the committers will
apply them.

The include support is provided by the MatchingTask superclass. The includes
can be defined in two ways, either as an includes attribute or by nested
<include> elements. Is that what you mean by a different syntax?

Good Luck, let me know if you can't get them going.

Conor



Re: Tasks for ejbc compile of weblogic EJBs

Posted by Roger Vaughn <rv...@seaconinc.com>.
Conor MacNeill wrote:
> 
> Hi,
> 
> Attached are two task definitions and a small set of patches to allow you to
> use ant to build weblogic EJBs. I developed these tasks for building EJBs
> here at Cortex and Cortex have agreed to let me give them to the ant
> project.
> 
...
> --
> Conor MacNeill
> conor@cortexebusiness.com.au
> Cortex ebusiness Pty Limited

Just in time - I was about to write my own tasks for this.

These classes will not compile with the current public version of Ant,
however.
The method "validateDirectory" is not found, and method "setProject" is
available
in Task, but is package-scope only.  I also notice that your usage
examples show
a different syntax for includes than is supported by the public version.

What am I missing here?  Should I be using a development version of Ant
instead?

Thanks,

Roger Vaughn