01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.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: * Initial developer(s): Guillaume Sauthier
22: * --------------------------------------------------------------------------
23: * $Id: JAXRConnection.java 5199 2004-07-29 11:05:21Z sauthieg $
24: * --------------------------------------------------------------------------
25: */package org.objectweb.jonas.jaxr;
26:
27: import java.io.Serializable;
28: import java.util.Properties;
29:
30: import javax.naming.BinaryRefAddr;
31: import javax.naming.NamingException;
32: import javax.naming.Reference;
33: import javax.naming.Referenceable;
34:
35: import org.objectweb.jonas.common.JNDIUtils;
36: import org.objectweb.jonas.jaxr.factory.JAXRFactory;
37:
38: /**
39: * Represents a JAXR Connectionfactory bound in Registry.
40: * @author Guillaume Sauthier
41: */
42: public class JAXRConnection implements Referenceable, Serializable {
43:
44: /**
45: * Internal properties
46: */
47: private Properties p;
48:
49: /**
50: * Constructs a JAXRConnection instance.
51: * @param p properties used to configure connection
52: */
53: public JAXRConnection(Properties p) {
54: this .p = p;
55: }
56:
57: /**
58: * @see javax.naming.Referenceable#getReference()
59: */
60: public Reference getReference() throws NamingException {
61:
62: // create new Reference using javax.xml.registry.ConnectionFactory Type
63: // and our own Factory
64: Reference ref = new Reference(JAXRFactory.FACTORY_TYPE,
65: JAXRFactory.class.getName(), null);
66:
67: // store configuration properties
68: ref.add(new BinaryRefAddr(JAXRFactory.PROPS_NAME, JNDIUtils
69: .getBytesFromObject(p)));
70:
71: // return the instance
72: return ref;
73: }
74:
75: }
|