/*=============================================================================*
* Copyright 2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*=============================================================================*/
package org.apache.ws.muse.example.resourceadmin;
import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.muse.example.application.ApplicationHome;
import org.apache.ws.muse.example.businessprocesstype.BusinessprocesstypeHome;
import org.apache.ws.muse.example.host.HostHome;
import org.apache.ws.muse.example.integrationserver.IntegrationserverHome;
import org.apache.ws.resource.ResourceException;
import org.apache.ws.resource.ResourceUnknownException;
import org.apache.ws.resource.impl.AbstractResourceHome;
import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* @author Kinga Dziembowski
*
* Home for Resourceadmin WS-Resources.
*/
public class ResourceadminHome
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/resourceadmin}resourceadmin" );
/** 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/resourceadmin}ResourceAdminPortType" );
/** The WSDL Port name associated with the resource. This is useful for building EPR's. **/
public static final String PORT_NAME = "resourceadmin";
/** 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}" );
/**
* 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;
/** DOCUMENT_ME */
protected static final String[] m_homesNames =
{
IntegrationserverHome.HOME_LOCATION,
BusinessprocesstypeHome.HOME_LOCATION,
ApplicationHome.HOME_LOCATION,
HostHome.HOME_LOCATION
};
/** DOCUMENT_ME */
protected static final QName[] m_resourceIDQNames =
new QName[]
{
HostHome.RESOURCE_ID,
BusinessprocesstypeHome.RESOURCE_ID,
IntegrationserverHome.RESOURCE_ID,
ApplicationHome.RESOURCE_ID
};
private ResourceadminResource m_adminResource = null;
/** DOCUMENT_ME */
protected Map m_allResources = new HashMap( );
/**
* This method is called by the system to initialize Home.
*/
public void init() throws Exception
{
super.init();
try
{
if ( m_adminResource == null )
{
m_adminResource = (ResourceadminResource) createInstance( null );
EndpointReference epr =
getEndpointReference( null );
m_adminResource.setEndpointReference( epr );
add( m_adminResource );
System.out.println("epr is " + epr.toString());
}
}
catch ( ResourceException e )
{
throw new ResourceUnknownException( "ResourceadminResource","ResourceadminResource"
);
}
}
// The list of jndi locations for resource homes
public static String[] getKnownHomes( )
{
return m_homesNames;
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public QName getPortType( )
{
return PORT_TYPE;
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public QName getResourceKeyNameQName( )
{
return RESOURCE_KEY_NAME;
}
// the list of all running resource created and resistered with resourceadmin
public Map getResources( )
{
return m_allResources;
}
// The list of QNames identifying the resource key
public QName[] getResourcesKeyNameQnames( )
{
return m_resourceIDQNames;
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public QName getServiceName( )
{
return SERVICE_NAME;
}
/**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
*/
public String getServicePortName( )
{
return PORT_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 ResourceAdmin 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;
}
}