KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > iiop > IiopClient


1 /*
2  * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.iiop;
30
31 import com.caucho.config.ConfigException;
32 import com.caucho.ejb.EJBClientInterface;
33 import com.caucho.ejb.cfg.EjbBean;
34 import com.caucho.ejb.cfg.EjbConfig;
35 import com.caucho.vfs.JarPath;
36 import com.caucho.vfs.Path;
37
38 public class IiopClient implements EJBClientInterface {
39   private EjbConfig _ejbConfig = new EjbConfig(null);
40   private IiopStubLoader _loader;
41   
42   /**
43    * Adds a jar
44    */

45   public void addEJBJar(Path jar)
46     throws ConfigException
47   {
48     Path path = JarPath.create(jar).lookup("META-INF/ejb-jar.xml");
49
50     if (path.canRead())
51       _ejbConfig.addEJBPath(jar, path);
52   }
53
54   /**
55    * Returns the home interface.
56    */

57   public Class JavaDoc getEJBHome(String JavaDoc ejbName)
58     throws ConfigException
59   {
60     EjbBean bean = _ejbConfig.getBeanConfig(ejbName);
61     System.out.println("B: " + bean);
62
63     if (bean == null)
64       return null;
65     else
66       return bean.getRemoteHomeClass();
67   }
68   
69   /**
70    * Initialize the client.
71    */

72   public void initEJBs()
73     throws Exception JavaDoc
74   {
75     /*
76     Iterator<EjbBean> iter = _ejbConfig.getBeanConfigIter();
77
78     while (iter.hasNext()) {
79       EjbBean bean = iter.next();
80
81       Class remoteHome = bean.getRemoteHome();
82       Class remoteView = bean.getRemote();
83
84       if (remoteHome == null || remoteView == null)
85     continue;
86
87       if (_loader == null) {
88     _loader = new IiopStubLoader();
89
90     _loader.setPath(WorkDir.getLocalWorkDir());
91       }
92
93       if (remoteHome != null)
94     _loader.addStubClass(remoteHome.getName());
95
96       if (remoteView != null)
97     _loader.addStubClass(remoteView.getName());
98     }
99
100     if (_loader != null) {
101       Thread thread = Thread.currentThread();
102       DynamicClassLoader classLoader =
103     (DynamicClassLoader) thread.getContextClassLoader();
104
105       classLoader.addLoader(_loader);
106     }
107     */

108   }
109 }
110
Popular Tags