dblevins 2004/12/22 00:42:39
Added: modules/core/src/java/org/openejb/server/soap
SoapHttpListener.java SoapHttpListenerGBean.java
WSContainer.java WSContainerGBean.java
WSContainerIndex.java WSContainerIndexGBean.java
Log:
Basic soap rpc/encoded deployment and container support along with a general
revamping of the networkservice stacks.
Revision Changes Path
1.1
openejb/modules/core/src/java/org/openejb/server/soap/SoapHttpListener.java
Index: SoapHttpListener.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: SoapHttpListener.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import java.io.IOException;
import org.codehaus.xfire.MessageContext;
import org.openejb.server.httpd.HttpListener;
import org.openejb.server.httpd.HttpRequest;
import org.openejb.server.httpd.HttpResponse;
public class SoapHttpListener implements HttpListener {
private final WSContainerIndex containerIndex;
public SoapHttpListener(WSContainerIndex containerIndex) {
this.containerIndex = containerIndex;
}
public void onMessage(HttpRequest req, HttpResponse res) throws
IOException {
MessageContext context = new MessageContext("not-used", null,
res.getOutputStream(), null, req.getURI().toString());
context.setRequestStream(req.getInputStream());
String path = req.getURI().getPath();
WSContainer container = containerIndex.getContainer(path);
if (container == null) {
res.setCode(404);
res.setResponseString("No such web service");
}
res.setContentType("text/xml");
container.invoke(context);
}
}
1.1
openejb/modules/core/src/java/org/openejb/server/soap/SoapHttpListenerGBean.java
Index: SoapHttpListenerGBean.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: SoapHttpListenerGBean.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.openejb.server.httpd.HttpRequest;
import org.openejb.server.httpd.HttpResponse;
public class SoapHttpListenerGBean {
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = new
GBeanInfoBuilder(SoapHttpListener.class);
infoFactory.addOperation("onMessage", new Class[]{HttpRequest.class,
HttpResponse.class});
infoFactory.addReference("WSContainerIndex", WSContainerIndex.class);
infoFactory.setConstructor(new String[]{"WSContainerIndex"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
public static ObjectName addGBean(Kernel kernel, String name, ObjectName
containerIndex) throws GBeanAlreadyExistsException, GBeanNotFoundException {
GBeanData gbean = createGBean(name, containerIndex);
kernel.loadGBean(gbean, SoapHttpListener.class.getClassLoader());
kernel.startGBean(gbean.getName());
return gbean.getName();
}
public static GBeanData createGBean(String name, ObjectName
containerIndex) {
ObjectName gbeanName =
JMXUtil.getObjectName("openejb:type=SoapHttpListener,name=" + name);
GBeanData gbean = new GBeanData(gbeanName,
SoapHttpListenerGBean.GBEAN_INFO);
gbean.setReferencePattern("WSContainerIndex", containerIndex);
return gbean;
}
}
1.1
openejb/modules/core/src/java/org/openejb/server/soap/WSContainer.java
Index: WSContainer.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: WSContainer.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.fault.Soap11FaultHandler;
import org.codehaus.xfire.fault.XFireFault;
import org.codehaus.xfire.handler.SoapHandler;
import org.codehaus.xfire.java.DefaultJavaService;
import org.codehaus.xfire.java.Invoker;
import org.codehaus.xfire.java.JavaServiceHandler;
import org.codehaus.xfire.java.mapping.DefaultTypeMappingRegistry;
import org.codehaus.xfire.soap.Soap11;
import org.openejb.EJBContainer;
import org.openejb.proxy.ProxyInfo;
public class WSContainer implements Invoker {
private final EJBContainer ejbContainer;
private final URI location;
private final URL wsdlURL;
private final DefaultJavaService service;
protected WSContainer() {
this.ejbContainer = null;
this.location = null;
this.wsdlURL = null;
this.service = null;
}
public WSContainer(EJBContainer ejbContainer, URI location, URL wsdlURL,
String namespace, String encoding, String style) {
this.ejbContainer = ejbContainer;
this.location = location;
this.wsdlURL = wsdlURL;
ProxyInfo proxyInfo = ejbContainer.getProxyInfo();
Class serviceEndpointInterface =
proxyInfo.getServiceEndpointInterface();
service = new DefaultJavaService();
service.setName(ejbContainer.getEJBName());
service.setDefaultNamespace(namespace);
service.setServiceClass(serviceEndpointInterface);
service.setSoapVersion(Soap11.getInstance());
service.setStyle(style);
service.setUse(encoding);
service.setWSDLURL(wsdlURL);
service.setServiceHandler(new SoapHandler(new
JavaServiceHandler(this)));
service.setFaultHandler(new Soap11FaultHandler());
service.setAutoTyped(true);
// Setup Type Mapping
DefaultTypeMappingRegistry registry = new
DefaultTypeMappingRegistry();
registry.registerDefault(registry.createDefaultMappings());
service.setTypeMappingRegistry(registry);
service.initializeTypeMapping();
service.initializeOperations();
}
public void invoke(MessageContext context) {
SoapHandler handler = null;
try {
context.setService(service);
handler = (SoapHandler) service.getServiceHandler();
handler.invoke(context);
} catch (Exception e) {
if (e instanceof XFireRuntimeException) {
throw (XFireRuntimeException) e;
} else if (handler != null) {
//log.error("Fault occurred.", e);
handler.handleFault(e, context);
} else {
throw new XFireRuntimeException("Couldn't process message.",
e);
}
}
}
public Object invoke(Method m, Object[] params, MessageContext context)
throws XFireFault {
try {
return ejbContainer.invoke(m, params, null);
} catch (Throwable throwable) {
throwable.printStackTrace();
throw new XFireFault("Error invoking EJB", throwable,
XFireFault.RECEIVER);
}
}
public URI getLocation() {
return location;
}
public URL getWsdlURL() {
return wsdlURL;
}
}
1.1
openejb/modules/core/src/java/org/openejb/server/soap/WSContainerGBean.java
Index: WSContainerGBean.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: WSContainerGBean.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import java.net.URI;
import java.net.URL;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.codehaus.xfire.MessageContext;
import org.openejb.EJBContainer;
public class WSContainerGBean {
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = new
GBeanInfoBuilder(WSContainer.class);
infoFactory.addOperation("invoke", new Class[]{MessageContext.class});
infoFactory.addReference("EJBContainer", EJBContainer.class);
infoFactory.addAttribute("location", URI.class, true);
infoFactory.addAttribute("wsdlURL", URL.class, true);
infoFactory.addAttribute("namespace", String.class, true);
infoFactory.addAttribute("encoding", String.class, true);
infoFactory.addAttribute("style", String.class, true);
infoFactory.setConstructor(new String[]{
"EJBContainer",
"location",
"wsdlURL",
"namespace",
"encoding",
"style"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
public static ObjectName addGBean(Kernel kernel, String name, ObjectName
ejbContainer, URI location, URL wsdlURL, String namespace, String encoding,
String style) throws GBeanAlreadyExistsException, GBeanNotFoundException {
GBeanData gbean = createGBean(name, ejbContainer, location, wsdlURL,
namespace, encoding, style);
kernel.loadGBean(gbean, WSContainer.class.getClassLoader());
kernel.startGBean(gbean.getName());
return gbean.getName();
}
public static GBeanData createGBean(String name, ObjectName ejbContainer,
URI location, URL wsdlURL, String namespace, String encoding, String style) {
assert ejbContainer != null : "EJBContainer objectname is null";
ObjectName gbeanName =
JMXUtil.getObjectName("openejb:type=WSContainer,name=" + name);
GBeanData gbean = new GBeanData(gbeanName,
WSContainerGBean.GBEAN_INFO);
gbean.setReferencePattern("EJBContainer", ejbContainer);
gbean.setAttribute("location", location);
gbean.setAttribute("wsdlURL", wsdlURL);
gbean.setAttribute("namespace", namespace);
gbean.setAttribute("encoding", encoding);
gbean.setAttribute("style", style);
return gbean;
}
}
1.1
openejb/modules/core/src/java/org/openejb/server/soap/WSContainerIndex.java
Index: WSContainerIndex.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: WSContainerIndex.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.geronimo.gbean.*;
/**
* This class is a bit crufty. Need something like this, but not static
* and more along the lines of a collection of containers registered as gbeans
*/
public class WSContainerIndex implements ReferenceCollectionListener,
GBeanLifecycle {
// todo delete me
private static WSContainerIndex containerIndex = new WSContainerIndex();
public static WSContainerIndex getInstance() {
return containerIndex;
}
/**
* Index from jndi name to the index (Integer) number in the containers
lookup table
*/
private final HashMap urlToContainerMap = new HashMap();
/**
* GBean reference collection that we watch for new containers to register
*/
private ReferenceCollection wsContainers;
protected WSContainerIndex() {
}
public WSContainerIndex(Collection wsContainers) {
WSContainerIndex.containerIndex = this;
this.wsContainers = (ReferenceCollection) wsContainers;
this.wsContainers.addReferenceCollectionListener(this);
}
public void doStart() throws WaitingException, Exception {
for (Iterator iterator = wsContainers.iterator();
iterator.hasNext();) {
WSContainer container = (WSContainer) iterator.next();
urlToContainerMap.put(container.getLocation().getPath(),
container);
}
}
public void doStop() throws WaitingException, Exception {
urlToContainerMap.clear();
}
public void doFail() {
urlToContainerMap.clear();
}
public synchronized void addContainer(WSContainer container) {
urlToContainerMap.put(container.getLocation().getPath(), container);
}
public synchronized void removeContainer(WSContainer container) {
urlToContainerMap.remove(container.getLocation().getPath());
}
public void memberAdded(ReferenceCollectionEvent event) {
addContainer((WSContainer) event.getMember());
}
public void memberRemoved(ReferenceCollectionEvent event) {
removeContainer((WSContainer) event.getMember());
}
public synchronized WSContainer getContainer(String urlPath) {
return (WSContainer) urlToContainerMap.get(urlPath);
}
}
1.1
openejb/modules/core/src/java/org/openejb/server/soap/WSContainerIndexGBean.java
Index: WSContainerIndexGBean.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: WSContainerIndexGBean.java,v 1.1 2004/12/22 05:42:39 dblevins Exp $
*/
package org.openejb.server.soap;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.JMXUtil;
public class WSContainerIndexGBean {
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = new
GBeanInfoBuilder(WSContainerIndex.class);
infoFactory.addOperation("getContainer", new Class[]{String.class});
infoFactory.addReference("WSContainers", WSContainer.class);
infoFactory.setConstructor(new String[]{"WSContainers"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
public static ObjectName addGBean(Kernel kernel, String name, ObjectName
wsContainers) throws GBeanAlreadyExistsException, GBeanNotFoundException {
GBeanData gbean = createGBean(name, wsContainers);
kernel.loadGBean(gbean, WSContainerIndex.class.getClassLoader());
kernel.startGBean(gbean.getName());
return gbean.getName();
}
public static GBeanData createGBean(String name, ObjectName wsContainers)
{
ObjectName gbeanName =
JMXUtil.getObjectName("openejb:type=WSContainerIndex,name=" + name);
GBeanData gbean = new GBeanData(gbeanName,
WSContainerIndexGBean.GBEAN_INFO);
gbean.setReferencePattern("WSContainers", wsContainers);
return gbean;
}
}