001: /*
002: * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.iiop;
030:
031: import com.caucho.config.ConfigException;
032: import com.caucho.ejb.EJBClientInterface;
033: import com.caucho.ejb.cfg.EjbBean;
034: import com.caucho.ejb.cfg.EjbConfig;
035: import com.caucho.vfs.JarPath;
036: import com.caucho.vfs.Path;
037:
038: public class IiopClient implements EJBClientInterface {
039: private EjbConfig _ejbConfig = new EjbConfig(null);
040: private IiopStubLoader _loader;
041:
042: /**
043: * Adds a jar
044: */
045: public void addEJBJar(Path jar) throws ConfigException {
046: Path path = JarPath.create(jar).lookup("META-INF/ejb-jar.xml");
047:
048: if (path.canRead())
049: _ejbConfig.addEjbPath(path);
050: }
051:
052: /**
053: * Returns the home interface.
054: */
055: public Class getEJBHome(String ejbName) throws ConfigException {
056: EjbBean bean = _ejbConfig.getBeanConfig(ejbName);
057: System.out.println("B: " + bean);
058:
059: if (bean == null)
060: return null;
061: else
062: return bean.getRemoteHomeClass();
063: }
064:
065: /**
066: * Initialize the client.
067: */
068: public void initEJBs() throws Exception {
069: /*
070: Iterator<EjbBean> iter = _ejbConfig.getBeanConfigIter();
071:
072: while (iter.hasNext()) {
073: EjbBean bean = iter.next();
074:
075: Class remoteHome = bean.getRemoteHome();
076: Class remoteView = bean.getRemote();
077:
078: if (remoteHome == null || remoteView == null)
079: continue;
080:
081: if (_loader == null) {
082: _loader = new IiopStubLoader();
083:
084: _loader.setPath(WorkDir.getLocalWorkDir());
085: }
086:
087: if (remoteHome != null)
088: _loader.addStubClass(remoteHome.getName());
089:
090: if (remoteView != null)
091: _loader.addStubClass(remoteView.getName());
092: }
093:
094: if (_loader != null) {
095: Thread thread = Thread.currentThread();
096: DynamicClassLoader classLoader =
097: (DynamicClassLoader) thread.getContextClassLoader();
098:
099: classLoader.addLoader(_loader);
100: }
101: */
102: }
103: }
|