01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.proxy.ejb;
23:
24: import java.util.Hashtable;
25: import javax.ejb.EJBHome;
26: import javax.naming.Context;
27: import javax.naming.Name;
28: import javax.naming.Reference;
29: import javax.naming.spi.ObjectFactory;
30: import javax.rmi.PortableRemoteObject;
31:
32: import org.jboss.iiop.CorbaORB;
33:
34: /**
35: * An <code>ObjectFactory</code> implementation that translates
36: * <code>Reference</code>s to <code>EJBHome</code>s back into CORBA
37: * object references. The IIOP proxy factory (IORFactory) binds these
38: * <code>Reference</code>s in the JRMP/JNDI namespace.
39: *
40: * @author <a href="mailto:reverbel@ime.usp.br">Francisco Reverbel</a>
41: * @version $Revision: 57194 $
42: */
43: public class IIOPHomeFactory implements ObjectFactory {
44:
45: public IIOPHomeFactory() {
46: }
47:
48: // Implementation of the interface ObjectFactory ------------------------
49:
50: /** Lookup the IOR from the Reference and convert into the CORBA
51: * object value using the ORB.string_to_object method.
52: *
53: * @param obj a javax.naming.Reference with a string IOR under the
54: * address type IOR.
55: * @param name not used
56: * @param nameCtx not used
57: * @param environment not used
58: * @return The EJBHome proxy for the IOR
59: * @throws Exception
60: */
61: public Object getObjectInstance(Object obj, Name name,
62: Context nameCtx, Hashtable environment) throws Exception {
63: Reference ref = (Reference) obj;
64: String ior = (String) ref.get("IOR").getContent();
65: org.omg.CORBA.Object corbaObj = CorbaORB.getInstance()
66: .string_to_object(ior);
67: return (EJBHome) PortableRemoteObject.narrow(corbaObj,
68: EJBHome.class);
69: }
70: }
|