01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 2010 2007-10-26 13:19:08Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.proxy.reference;
25:
26: import javax.naming.NamingException;
27: import javax.naming.Reference;
28: import javax.naming.StringRefAddr;
29:
30: import org.ow2.easybeans.proxy.factory.LocalCallFactory;
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 EMBEDDED_ID = "embeddedID";
43:
44: /**
45: * Embedded server ID.
46: */
47: private Integer embeddedID = null;
48:
49: /**
50: * Constructor : build a reference.
51: * @param itfClassName the name of the interface.
52: * @param embeddedID the ID of the embedded server.
53: * @param containerId the ID of the container.
54: * @param factoryName the name of the factory
55: * @param useID true if all instance build with this ref are unique
56: * (stateful), false if it references the same object (stateless)
57: */
58: public LocalCallRef(final String itfClassName,
59: final Integer embeddedID, final String containerId,
60: final String 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
72: public Reference getReference() throws NamingException {
73:
74: // Build the reference to the factory
75: Reference reference = new Reference(getItfClassName(),
76: getFactoryClassName(), null);
77: reference.add(new StringRefAddr(EMBEDDED_ID, embeddedID
78: .toString()));
79: updateRefAddr(reference);
80: return reference;
81: }
82:
83: /**
84: * Gets the name of the factory (can be used by subclasses to change the name).
85: * @return the name of the factory used by this reference.
86: */
87: protected String getFactoryClassName() {
88: return LocalCallFactory.class.getName();
89: }
90: }
|