dblevins 2005/02/02 19:07:59
Modified: modules/core/src/test/org/openejb/slsb MockEJBContainer.java
Added: modules/core/src/test/org/openejb/slsb
MockEJBContainerGBean.java
Log:
Revising the WSContainer to better support rpc/encoded strictly against a
lightweight WSDL->Java mapping.
Added validation for lightweigth mappings.
Added ability to download the WSDL via http://foobar.com/someservice?wsdl
Revision Changes Path
1.3 +13 -1
openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainer.java
Index: MockEJBContainer.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MockEJBContainer.java 22 Dec 2004 05:42:39 -0000 1.2
+++ MockEJBContainer.java 3 Feb 2005 00:07:59 -0000 1.3
@@ -45,6 +45,8 @@
package org.openejb.slsb;
import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
import javax.ejb.EJBHome;
import javax.ejb.EJBLocalHome;
import javax.ejb.EJBLocalObject;
@@ -75,6 +77,16 @@
public MockEJBContainer() {
this.proxyInfo = new ProxyInfo(EJBComponentType.STATELESS, "foo",
MockHome.class, MockRemote.class, MockLocalHome.class, MockLocal.class,
MockServiceEndpoint.class, null);
ejbClass = MockEJB.class;
+ }
+
+ public MockEJBContainer(URL ejbJarURL, String ejbName, String ejbClass,
String home, String remote, String localHome, String local, String
serviceEndpoint) {
+ ClassLoader cl = new URLClassLoader(new URL[]{ejbJarURL},
MockEJBContainer.class.getClassLoader());
+ try {
+ this.proxyInfo = new ProxyInfo(EJBComponentType.STATELESS,
ejbName, cl.loadClass(home), cl.loadClass(remote), cl.loadClass(localHome),
cl.loadClass(local), cl.loadClass(serviceEndpoint), null);
+ this.ejbClass = cl.loadClass(ejbClass);
+ } catch (ClassNotFoundException e) {
+ throw (IllegalStateException) new IllegalStateException("Could
not initialize the MockEJBContainer").initCause(e);
+ }
}
public Object getContainerID() {
1.1
openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainerGBean.java
Index: MockEJBContainerGBean.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
*
* $Id: MockEJBContainerGBean.java,v 1.1 2005/02/03 00:07:59 dblevins Exp $
*/
package org.openejb.slsb;
import java.net.URL;
import java.lang.reflect.Method;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.*;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.core.service.Invocation;
import org.openejb.proxy.ProxyInfo;
public class MockEJBContainerGBean {
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = new
GBeanInfoBuilder(MockEJBContainer.class);
infoFactory.addAttribute("ejbJarURL", URL.class, true);
infoFactory.addAttribute("ejbName", String.class, true);
infoFactory.addAttribute("ejbClass", String.class, true);
infoFactory.addAttribute("home", String.class, true);
infoFactory.addAttribute("remote", String.class, true);
infoFactory.addAttribute("localHome", String.class, true);
infoFactory.addAttribute("local", String.class, true);
infoFactory.addAttribute("serviceEndpoint", String.class, true);
infoFactory.addOperation("invoke", new Class[]{Invocation.class});
infoFactory.addOperation("invoke", new Class[]{Method.class,
Object[].class, Object.class});
infoFactory.addAttribute("EJBName", String.class, true);
infoFactory.addAttribute("ProxyInfo", ProxyInfo.class, true);
infoFactory.setConstructor(new String[]{
"ejbJarURL",
"ejbName",
"ejbClass",
"home",
"remote",
"localHome",
"local",
"serviceEndpoint"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
public static ObjectName addGBean(Kernel kernel, URL ejbJarURL, String
ejbName, String ejbClass, String home, String remote, String localHome, String
local, String serviceEndpoint) throws GBeanAlreadyExistsException,
GBeanNotFoundException {
GBeanData gbean = createGBean(ejbJarURL, ejbName, ejbClass, home,
remote, localHome, local, serviceEndpoint);
kernel.loadGBean(gbean, MockEJBContainer.class.getClassLoader());
kernel.startGBean(gbean.getName());
return gbean.getName();
}
public static GBeanData createGBean(URL ejbJarURL, String ejbName, String
ejbClass, String home, String remote, String localHome, String local, String
serviceEndpoint) {
ObjectName gbeanName =
JMXUtil.getObjectName("openejb:j2eeType=StatelessSessionBean,name=" + ejbName);
GBeanData gbean = new GBeanData(gbeanName,
MockEJBContainerGBean.GBEAN_INFO);
gbean.setAttribute("ejbJarURL", ejbJarURL);
gbean.setAttribute("ejbName", ejbName);
gbean.setAttribute("ejbClass", ejbClass);
gbean.setAttribute("home", home);
gbean.setAttribute("remote", remote);
gbean.setAttribute("localHome", localHome);
gbean.setAttribute("local", local);
gbean.setAttribute("serviceEndpoint", serviceEndpoint);
return gbean;
}
}