Hi Andrew,
I had a few days of holiday, so did not got a chance to answer earlier..
On Wed, Jan 16, 2002 at 11:49:00PM +0000, Andrew Stevens wrote:
> A wise old hermit known only as Jozsa Kristof <[EMAIL PROTECTED]> once
> said:
> > ..does not appear in the home interface for me. If I change the bean
> > type to
> > Stateless, the ejbCreate() method gets generated into the home
> > interface, if
> > I change it back to Stateful, it does not.
>
> I assume you mean the home interface's create() method. Do you have an
> ejbCreate() in the bean file?
Yes, I do have it.
> For stateful beans, you don't *have* to have a no-argument create method,
> so long as there's some ejbCreate(...) method(s). For stateless, you must
> have a no-arg create method and no others. (sections 6.3/6.4 and 7.5 of
> the EJB2.0 spec)
The signature is:
public void ejbCreate() throws javax.ejb.CreateException
I think this will do for a stateful bean as well..
> If you're using the <session> subtask,
Yep.
> for stateless beans xdoclet adds an ejbCreate() in the generated Session
> class if there isn't one (so less code required in your bean class), but
> for stateful beans it doesn't (since you might not want it). Perhaps the
> home interface generation is also including a create() when there's no
> ejbCreate, but only for stateless session beans?
Looks like a good guess, but in my case I have an ejbCreate() in the *Bean
code, so it could got generated either way as I see. I was searching for any
example Stateful Session bean around which use XDoclet for help, but
couldn't find any :(
>
> Hope that helps. If not, perhaps you could post some of your code - the
> class level tags and create methods of your bean class in particular, and
> the ejbdoclet task parameters.
I'll attach my stateful bean initiate, upon which the create() function
doesn't get generated by xdoclet, and the ant build script's
ejbdoclet-related part.
tia,
Christopher
--
.Digital.Yearning.for.Networked.Assassination.and.Xenocide
package org.dyn.crocodile.connector;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
/**
* Stateful session bean to authenticate and manage Cocoon sessions on the EJB side
*
* @ejb:bean
* name="CocoonConnector"
* type="Stateful"
* jndi-name="CocoonConnector"
* view-type="remote"
* @ejb:interface remote-class="org.dyn.crocodile.interfaces.CocoonConnector"
*/
public class CocoonConnectorBean implements SessionBean
{
/**
* @ejb:interface-method
*/
public boolean AuthenticateUser (String username, String passwd) {
return true;
}
public void ejbCreate() throws javax.ejb.CreateException {};
public void ejbRemove() {};
public void ejbActivate() {};
public void ejbPassivate() {};
public void setSessionContext (SessionContext sc) {}
}
<target name="ejbdoclet" description="Generating sources using EJB/XDoclet">
<taskdef name="ejbdoclet"
classname="xdoclet.ejb.EjbDocletTask" classpath="lib/xdoclet.jar:lib/log4j.jar"/>
<ejbdoclet
sourcepath="src"
destdir="src"
classpathref="project.class.path"
excludedtags="@version,@author"
ejbspec="2.0">
<fileset dir="src">
<include name="**/*Bean.java"/>
</fileset>
<packageSubstitution
packages="data,agent,connector" substituteWith="interfaces"/>
<dataobject/>
<remoteinterface/>
<localinterface/>
<homeinterface/>
<localhomeinterface/>
<entitypk/>
<entitycmp/>
<session/>
<utilobject/>
<deploymentdescriptor destdir="META-INF"/>
<jboss version="3.0"
xmlencoding="UTF-8"
typemapping="Hypersonic SQL"
datasource="java:/DefaultDS"
destdir="META-INF"
/>
</ejbdoclet>
</target>