KickJava   Java API By Example, From Geeks To Geeks.

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


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: AbsCallRef.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.Referenceable JavaDoc;
31 import javax.naming.StringRefAddr JavaDoc;
32
33 /**
34  * Define a common Referenceable objectd used by local or remote EJB.
35  * @author Florent Benoit
36  */

37 public abstract class AbsCallRef implements Referenceable JavaDoc {
38
39     /**
40      * Property used for referencing the container ID.
41      */

42     public static final String JavaDoc CONTAINER_ID = "containerID";
43
44     /**
45      * Property used for referencing the name of the factory.
46      */

47     public static final String JavaDoc FACTORY_NAME = "factoryName";
48
49     /**
50      * Property used for referencing the interface class name.
51      */

52     public static final String JavaDoc INTERFACE_NAME = "interfaceClassName";
53
54     /**
55      * Property used for using an unique ID or not.
56      */

57     public static final String JavaDoc USE_ID = "useID";
58
59     /**
60      * Name of the interface class.
61      */

62     private String JavaDoc itfClassName = null;
63
64     /**
65      * Container id.
66      */

67     private String JavaDoc containerId = null;
68
69     /**
70      * Factory name.
71      */

72     private String JavaDoc factoryName = null;
73
74     /**
75      * useID : true if all instance build with this ref are unique (stateful), false if it references the same object (stateless).
76      */

77     private boolean useID;
78
79     /**
80      * Constructor : build a reference.
81      * @param itfClassName the name of the interface.
82      * @param containerId the ID of the container.
83      * @param factoryName the name of the factory
84      * @param useID true if all instance build with this ref are unique
85      * (stateful), false if it references the same object (stateless)
86      */

87     public AbsCallRef(final String JavaDoc itfClassName, final String JavaDoc containerId, final String JavaDoc factoryName, final boolean useID) {
88         this.itfClassName = itfClassName;
89         this.containerId = containerId;
90         this.factoryName = factoryName;
91         this.useID = useID;
92     }
93
94     /**
95      * Retrieves the Reference of this object.
96      * @return The non-null Reference of this object.
97      * @exception NamingException If a naming exception was encountered while
98      * retrieving the reference.
99      */

100     public abstract Reference JavaDoc getReference() throws NamingException JavaDoc;
101
102
103     /**
104      * Adds some settings to the reference.
105      * @param reference the reference to configure
106      * @return the updated reference.
107      */

108     protected Reference JavaDoc updateRefAddr(final Reference JavaDoc reference) {
109         reference.add(new StringRefAddr JavaDoc(CONTAINER_ID, containerId));
110         reference.add(new StringRefAddr JavaDoc(FACTORY_NAME, factoryName));
111         reference.add(new StringRefAddr JavaDoc(INTERFACE_NAME, itfClassName));
112         reference.add(new StringRefAddr JavaDoc(USE_ID, Boolean.toString(useID)));
113         return reference;
114     }
115
116     /**
117      * Gets the interface class name.
118      * @return the name of the interface.
119      */

120     public String JavaDoc getItfClassName() {
121         return itfClassName;
122     }
123
124
125 }
126
Popular Tags