package org.apache.ws.muse.example.integrationserver;
import org.apache.ws.muse.example.resourceadmin.properties.CreateParamsType;
import org.apache.ws.resource.Resource;
import org.apache.ws.resource.ResourceContext;
import org.apache.ws.resource.ResourceContextException;
import org.apache.ws.resource.ResourceException;
import org.apache.ws.resource.ResourceUnknownException;
import org.apache.ws.resource.impl.AbstractResourceHome;
import org.apache.ws.addressing.EndpointReference;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.Map;
/**
* Home for Integrationserver WS-Resources.
*/
public class IntegrationserverHome
extends AbstractResourceHome
implements Serializable
{
/** The service endpoint name as registered with the SOAP Platform. This is useful for building EPR's. **/
public static final QName SERVICE_NAME = javax.xml.namespace.QName.valueOf("{http://ws.apache.org/muse/example/integrationserver}integrationserver");
/** The management PortType associated with this resource. This is useful for building EPR's.**/
public static final QName PORT_TYPE = javax.xml.namespace.QName.valueOf("{http://ws.apache.org/muse/example/integrationserver}IntegrationServerPortType");
/** The WSDL Port name associated with the resource. This is useful for building EPR's. **/
public static final String PORT_NAME = "integrationserver";
/** The name of the resource key for this resource. **/
public static final QName RESOURCE_KEY_NAME = javax.xml.namespace.QName.valueOf("{${resourcekey.NamespaceURI}}${resourcekey.LocalPart}");
public static final QName RESOURCE_ID = javax.xml.namespace.QName.valueOf("{http://ws.apache.org/muse/example/integrationserver}ResourceID");
/**
* A NamespaceVerionHolder which maintains the QNames of Spec Wsdls
*/
public static final org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl SPEC_NAMESPACE_SET = new org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl();
/** A constant for the JNDI Lookup name for this home. **/
public static final String HOME_LOCATION =
org.apache.ws.resource.JndiConstants.CONTEXT_NAME_SERVICES + "/" + SERVICE_NAME.getLocalPart() + "/" + org.apache.ws.resource.JndiConstants.ATOMIC_NAME_HOME;
/** A variable to hold the factory resource object */
private IntegrationserverResource m_serverResource = null;
public void init() throws Exception
{
super.init();
}
public Resource create(ResourceContext resourceContext, CreateParamsType createParams) throws ResourceException,
ResourceContextException,
ResourceUnknownException
{
if (m_serverResource == null)
{
Object resourceId = SERVICE_NAME.toString();
System.out.println("integrationsever id= " + resourceId);
try
{
// We create an instance of Integration server with the resourceId, needed for bookkping done by resourceAdmin
// But Integration server is a singleton, we do not want to use ResourceID in the EPR, we will create EPR with null as resouceId
m_serverResource = new IntegrationserverResource( resourceId, createParams );
//The EPRs should be build using "http://schemas.xmlsoap.org/ws/2003/03/addressing" addressing namespace. It introduces spec conflicts
//To work around thes problem the "http://schemas.xmlsoap.org/ws/2004/08/addressing" is used as namespace for addressing
EndpointReference epr = getEndpointReference(null);
((IntegrationserverResource)m_serverResource).setEndpointReference( epr );
m_serverResource.init();
add(m_serverResource);
}
catch (Exception e)
{
throw new ResourceException(e);
}
}
return m_serverResource;
}
public QName getServiceName()
{
return SERVICE_NAME;
}
public QName getPortType()
{
return PORT_TYPE;
}
public String getServicePortName()
{
return PORT_NAME;
}
public QName getResourceKeyNameQName()
{
return RESOURCE_KEY_NAME;
}
/**
* Map containing all FilesystemResource instances - this map <em>must</em> be static for
* compatibility with certain JNDI providers.
*/
private static Map s_resources;
/**
* Returns a map of all IntegrationServer instances. Used by the {@link org.apache.ws.resource.impl.AbstractResourceHome}
* superclass.
*/
protected synchronized final Map getResourceMap()
{
if ( s_resources == null )
{
s_resources = AbstractResourceHome.createResourceMap( m_resourceIsPersistent );
}
return s_resources;
}
public org.apache.ws.resource.properties.NamespaceVersionHolder getNamespaceVersionHolder()
{
return SPEC_NAMESPACE_SET;
}
}