some trciks needed to reduce labour
i have made couple of session bean with some business methods in JAVA perspective in eclipse.
now i want to make home and remote interfaces for those classes.
i need the help of eclipse so that i can write the home and remote interfaces as quick as possible .
can you tell some tricks ?
yea, i know its copy paste of methods ...still looking for some smart and faster way to do it as i have made many beans in eclipse.
unfortunately i dont have any J2EE ide which could do the autogenerate.....its plain old eclipse java perspective.
i believe , eclipse might have some optimum usability using which i can downsize the labour .
do you think ..it can ?
Can't you use EJB 3.0?
kajbja at 2007-7-12 11:44:24 >

the existing system doesnot use ejb 3.0 .
[url=http://xdoclet.sourceforge.net/xdoclet/index.html]Xdoclet[/url] is exactly what you're looking for. From your EJB class, it will generate the local, remote, home, remote home interfaces, deployment descriptors (ejb-jar.xml, web.xml, proprietary descriptors) for all common containers, JNDI lookup helper classes and all sorts of other goodies. All from just a few javadoc-style comments
I am not so sure whether Xdoclet could really do it .....so please confirm me the following ...
Hey , Xdoclet i am giving you a SessionBean class as input , please provide me the Home Interface and Remote Interface for this bean class as output.
can i really do it using Xdoclet ? i just need to do it ....this will reduce my labour a lot.
> I am not so sure whether Xdoclet could really do it
> .....so please confirm me the following ...
>
>
> Hey , Xdoclet i am giving you a SessionBean class as
> input , please provide me the Home Interface
> and Remote Interface for this bean class as
> output.
>
>
> can i really do it using Xdoclet ? i just need to do
> it ....this will reduce my labour a lot.
Yes, that is exactly what it was designed to do. It provides you with a bunch of ant tasks that will parse your source code for special comments, and generate new code, descriptors etc. for you. It was written by one of the developers of Jboss ( I think ) to avoid all the hassle of coding those boring bits like the home/remote interfaces, descriptors and such-like. Get it, it's a godsend
Whenever you hit a particularly boring, repetitive bit of work, have a think about how you'd describe it in very general terms (like "automatically generate EJB home interfaces") and google it - someone else has almost certainly hit the same boring, repetitive bit of work in the past, and written a tool to do it for you. This is how we got from coding hex codes directly on a drive cylinder to IDEs - laziness and a dislike of boring work
Here is what i have so far ...its not working
build.xml
<?xml version="1.0"?>
<project name="xdoclet" basedir=".">
<property environment="env"/>
<property file="build.properties"/>
<target name="ejbdoclet" >
<taskdef name="ejbdoclet"
classname="xdoclet.ejb.EjbDocletTask" classpath="${java.class.path};${xdoclet.jar.path};
${log4j.jar.path};${ant.jar.path}"/>
<ejbdoclet
sourcepath="${java.dir}"
destdir="${generated.java.dir}"
ejbspec="2.0">
<fileset dir="${java.dir}">
<include name="SampleBean.java" />
</fileset>
<remoteinterface/>
<homeinterface/>
</ejbdoclet>
</target>
</project>
build.properties
java.class.path=C:/j2sdk1.4.2_10/bin
xdoclet.jar.path=C:/xdoclet/xdoclet-1.2.3.jar
log4j.jar.path=C:/xdoclet/log4j.jar
ant.jar.path=C:/xdoclet/ant.jar
generated.java.dir=C:/xdoclet/
java.dir=C:/xdoclet/
SessionBean class
/**
* @ejb.bean type="Stateful"
* view-type="both"
*/
public class SampleBean implements SessionBean {
private String name = null;
public void setSessionContext(SessionContext context) {}
/**
* @ejb.create-method
*/
public void create() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbLoad() {}
public void ejbStore() {}
public void ejbActivate() {}
public void ejbPassivate() {}
/**
* @ejb.interface-method
*/
public void setName(String value) {
this.name = value;
}
/**
* @ejb.interface-method
*/
public String getName() {
return name;
}
}
All these are in the same folder i.e c:\xdoclet
I run the Ant
C:\xdoclet>ant
Buildfile: build.xml
BUILD SUCCESSFUL
Total time: 0 seconds
checked the c:\xdoclet folder and did not find the generated home and remote interfaces classes :-(
whats the problem ?
I support the use of Xdoclet to save time, but it seems like you are approaching your coding in a backwards way.
I write the Remote or Local interface first because I usually already have the design diagrammed out.
I then use the IDE to create a new class that implements the interface and instruct it to automagically generate method stubs for every EJB method defined in the interface.
After my session bean is laid out for me I just remove the code that says 'implements [Remote Interface]' and then fill in the business logic.
Budda bing budda boom, I got myself some EJB's.
> I support the use of Xdoclet to save time, but it
> seems like you are approaching your coding in a
> backwards way.
>
> I write the Remote or Local interface first because I
> usually already have the design diagrammed out.
>
> I then use the IDE to create a new class that
> implements the interface and instruct it to
> automagically generate method stubs for every EJB
> method defined in the interface.
>
> After my session bean is laid out for me I just
> remove the code that says 'implements [Remote
> Interface]' and then fill in the business logic.
>
> Budda bing budda boom, I got myself some EJB's.
Hmmmm interesting way around. The idea of Xdoclet is, you write your business code, the actual EJB class, and that's it. Xdoclet sits as part of your build process, and generates the interfaces, descriptors etc. at build-time. You've actually created more work for yourself by starting with the interface. Surely since you've got the interface designed already, it's entirely arbitrary whether you first express that as a java interface or the actual class?
geo,do you see any mistake there ? the interfaces are not getting generated.i am not that much proficient in xdoclet .any kind of input for this effort is appreciated.thank you
Is your java source inside the Xdoclet folder? I hope not!
> Is your java source inside the Xdoclet folder? I hope
> not!
yea,,,,its there .
N.B : do you think , i need to add j2ee.jar in the classpath ....i dont see it in the example given in a site.....but i doubt it .
however , i dont have jboss's j2ee.jar .......i think weblogic.jar will a replacement for it .
but before that i am not sure whether its required or not ....as i am not getting any exception in the console
Message was edited by:
Unknown_Citizen
Message was edited by:
Unknown_Citizen
I guess I'll get a lot of opposition for saying this, since it's the other way around of what you'd normally do. It can helpfull to comprend what you're supposed to do.
you are using eclipse. If you have the eclipse WTP version, support for XDoclet is built in. The only thing you need to do is link eclipse to your xdoclet installation. Whenever you create a new EJB, eclipse asks you wether it should be an XDoclet annotated EJB or not. In the project properties you can specify what parts you need (home interface, remote interface, client stub...) A fast way to learn what exactly you have to put in the build.xml file is adding XDoclet to your project and check out the build.xml that Eclipse generates. You'll also get a better idea of what you have to put in your code in order to generate the desired classes.