To follow up, which is considered 'less coupled' or a 'better' approach?

Example one from the samples:

public void patrolBank() {
               try {
            CustomerHome home = (CustomerHome) new
InitialContext().lookup("java:comp/env/ejb/bank/Customer");
            Collection customers = home.findAll();
            for (Iterator customersInBank = customers.iterator();
customersInBank.hasNext();) {
                Customer customer = (Customer) customersInBank.next();
                customer.talkTo();
            }
       
2 the approach I was trying, using the util class (I took out the catches
for brevity)

public void hello()
        {
DataSetLocal dataSet = null;
                try
                {
                        dataSet =
DataSetBeanUtil.getLocalHome().findByPrimaryKey(new DataSetPK(new
Integer(44)));
        


thanks again in advance,

craig


-----Original Message-----
From: Craig Hamilton [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 31, 2003 9:17 AM
To: '[EMAIL PROTECTED]'
Subject: Re: [Xdoclet-user] Bean Util problem with getLocalHome

I had put the following in the session bean, but didn't know what it does,
or how to use the references tag. Thus I was trying to use the Util object
to retrieve entity's home interface.

Here is the reference in the session bean:

* @ejb.ejb-ref
 *      view-type="Local"
 *      ejb-name="DataSetBean"
 *      ref-name="DataSetBeanLocal"

My question, how do I get the LocalHome interface or a local reference to a
particular dataset now within the Manager session bean?

Thanks in advance,

Craig



Message: 1
Date: Mon, 31 Mar 2003 18:10:31 +1000
Subject: Re: [Xdoclet-user] Bean Util problem with getLocalHome
From: Stephen Coy <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]

Hi,

You can get the effect that you are looking for by adding the tag:

@ejb.util               generate="physical"

to your EJB class.

However, you probably don't really want to do that.

Instead, your client beans code should have @ejb.ref tags which 
generate corresponding ejb-ref tags in your ejb-jar.xml file.

This has the effect of decoupling your client code from the deployed 
name of the bean that you are looking up.

In other words, this allows you to change the JNDI name of the looked 
up bean at deployment time without having to recompile the client code.

Normally, the only time that you need to look up the physical name is 
when the client code is not in an EJB or web container, such as a 
command line client.

Steve Coy

On Monday, March 31, 2003, at 06:10  AM, Craig Hamilton wrote:

> I am trying to use the Util object for a bean, specifically calling the
> getLocalHome method.
>
> I keep getting the object not bound (or something to that effect) 
> error.
>
> I looked at the getLocalHome code and saw that it was doing the lookup 
> using
> the COMP_NAME constant found in the LocalHome interface.  I changed 
> this to
> use the JNDI_NAME constant and then it works.
>
> Would this be a bug, or am I filling out my Bean xdoclet tags 
> incorrectly.
> I have attached the class descriptor for the Bean in question.
>
> I am using xdoc 1.2b2
>
> Craig
>
>
> /**
>  * This is the Facility entity bean. It is an example of how to use the
>  * EJBDoclet tags.
>  *
>  * @ejb.bean
>  *     name="DataSetBean"
>  *     type="CMP"
>  *     cmp-version="2.x"
>  *     jndi-name="ejb/DataSetBean"
>  *     local-jndi-name="ejb/DataSetBeanLocal"
>  *
>  * @ejb.interface
>  *     remote-class="test.DataSetRemote"
>  *     local-class="test.DataSetLocal"
>  * @ejb.pk
>  *      class="test.DataSetPK"
>  *            generate="true"
>  *
>  * @ejb.persistence
>  *     table-name="DATASETS"
>  * @jboss.create-table "false"
>  * @jboss.remove-table "false"
>  *
>  *
>  * @ejb.transaction
>  *     type="Required"
>  *
>  *  @ejb.finder
>  *     signature="java.util.Collection findAll()"
>  *     unchecked="true"
>
>  * @ejb.value-object
>  *     name="DataSet"
>  *     match="*"
>  *
>  * @version 1.5
>  */
> public abstract class DataSetBean implements EntityBean
>




-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to