Package org.wsdmdemo.service.weatherClientConfig

Source Code of org.wsdmdemo.service.weatherClientConfig.WeatherClientConfigHome

package org.wsdmdemo.service.weatherClientConfig;

import org.apache.ws.addressing.EndpointReference;
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.ResourceKey;
import org.apache.ws.resource.ResourceUnknownException;
import org.apache.ws.resource.impl.AbstractResourceHome;

import javax.xml.namespace.QName;
import java.io.Serializable;

/**
* **** NOTE: This file will not be overwritten during generation ****
* <p/>
* Home for WeatherClientConfig WS-Resources.
*/
public class WeatherClientConfigHome
        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://wsdmdemo.org/service/weather-client-config}WeatherClientConfig");

    /**
     * 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://wsdmdemo.org/service/weather-client-config}WeatherClientConfigPortType");

    /**
     * The WSDL Port name associated with the resource. This is useful for building EPR's. *
     */
    public static final String PORT_NAME = "weather-client-config";

    /**
     * The name of the resource key for this resource. *
     */
    public static final QName RESOURCE_KEY_NAME = javax.xml.namespace.QName.valueOf("{http://wsdmdemo.org/service/weather-client-config}ResourceIdentifier");

    /**
     * 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;

    private static Object m_lock = new Object();
    /**
     * @param resourceContext
     * @return A Resource
     * @throws ResourceException
     * @throws ResourceContextException
     * @throws ResourceUnknownException
     */
    public Resource getInstance(ResourceContext resourceContext)
            throws ResourceException,
                   ResourceContextException,
                   ResourceUnknownException
    {
        ResourceKey key = resourceContext.getResourceKey();
        Resource resource = null;
        try
        {
            synchronized (m_lock)
            {
                resource = find(key); //attempt to find from the underlying cache
            }
        }
        catch (ResourceException re)
        {
            Object id = key.getValue();
            //create as many clients as requested...
            try
            {
                WeatherClientConfigResource myresource = (WeatherClientConfigResource) createInstance(key); //this will create the resource IF it is has default constructor. It also calls init() on the resource.
                //the next line will create an EPR
                EndpointReference epr = getEndpointReference(resourceContext.getBaseURL() + "/" + getServiceName().getLocalPart(), key, SPEC_NAMESPACE_SET.getAddressingNamespace());
                myresource.setEndpointReference(epr); //make sure to set the EPR on your new instance
                add(key, myresource); //make sure to add your instance to the underlying cache to be found in future requests using find(..)
            }
            catch (Exception e)
            {
                throw new ResourceException(e);
            }
        }
        return resource;
    }

    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;
    }
}
TOP

Related Classes of org.wsdmdemo.service.weatherClientConfig.WeatherClientConfigHome

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.