KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > proxy > ejb > IIOPHomeFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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 JavaDoc;
25 import javax.ejb.EJBHome JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.Name JavaDoc;
28 import javax.naming.Reference JavaDoc;
29 import javax.naming.spi.ObjectFactory JavaDoc;
30 import javax.rmi.PortableRemoteObject JavaDoc;
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: 37459 $
42  */

43 public class IIOPHomeFactory implements ObjectFactory JavaDoc
44 {
45
46    public IIOPHomeFactory()
47    {
48    }
49    
50    // Implementation of the interface ObjectFactory ------------------------
51

52    /** Lookup the IOR from the Reference and convert into the CORBA
53     * object value using the ORB.string_to_object method.
54     *
55     * @param obj a javax.naming.Reference with a string IOR under the
56     * address type IOR.
57     * @param name not used
58     * @param nameCtx not used
59     * @param environment not used
60     * @return The EJBHome proxy for the IOR
61     * @throws Exception
62     */

63    public Object JavaDoc getObjectInstance(Object JavaDoc obj, Name JavaDoc name,
64                                    Context JavaDoc nameCtx, Hashtable JavaDoc environment)
65       throws Exception JavaDoc
66    {
67       Reference JavaDoc ref = (Reference JavaDoc) obj;
68       String JavaDoc ior = (String JavaDoc) ref.get("IOR").getContent();
69       org.omg.CORBA.Object JavaDoc corbaObj = CorbaORB.getInstance().string_to_object(ior);
70       return (EJBHome JavaDoc) PortableRemoteObject.narrow(corbaObj, EJBHome JavaDoc.class);
71    }
72 }
73
74
Popular Tags