KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > rpc > LocalCallRef


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: LocalCallRef.java 882 2006-07-18 09:15:39Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.rpc;
27
28 import javax.naming.NamingException JavaDoc;
29 import javax.naming.Reference JavaDoc;
30 import javax.naming.StringRefAddr JavaDoc;
31
32 /**
33  * Define the Referenceable objectd used by local EJB.
34  * This is the object that is bind in the registry.
35  * @author Florent Benoit
36  */

37 public class LocalCallRef extends AbsCallRef {
38
39     /**
40      * Property referencing the embedded server's ID.
41      */

42     public static final String JavaDoc EMBEDDED_ID = "embeddedID";
43
44     /**
45      * Embedded server ID.
46      */

47     private Integer JavaDoc embeddedID = null;
48
49
50     /**
51      * Constructor : build a reference.
52      * @param itfClassName the name of the interface.
53      * @param embeddedID the ID of the embedded server.
54      * @param containerId the ID of the container.
55      * @param factoryName the name of the factory
56      * @param useID true if all instance build with this ref are unique
57      * (stateful), false if it references the same object (stateless)
58      */

59     public LocalCallRef(final String JavaDoc itfClassName, final Integer JavaDoc embeddedID, final String JavaDoc containerId,
60             final String JavaDoc factoryName, final boolean useID) {
61         super(itfClassName, containerId, factoryName, useID);
62         this.embeddedID = embeddedID;
63     }
64
65     /**
66      * Retrieves the Reference of this object.
67      * @return The non-null Reference of this object.
68      * @exception NamingException If a naming exception was encountered while
69      * retrieving the reference.
70      */

71     @Override JavaDoc
72     public Reference JavaDoc getReference() throws NamingException JavaDoc {
73
74         // Build the reference to the factory
75
Reference JavaDoc reference = new Reference JavaDoc(getItfClassName(), LocalCallFactory.class.getName(), null);
76         reference.add(new StringRefAddr JavaDoc(EMBEDDED_ID, embeddedID.toString()));
77         return updateRefAddr(reference);
78
79     }
80
81 }
82
Popular Tags