Package org.apache.ws.notification.base.impl

Source Code of org.apache.ws.notification.base.impl.UnitExampleHome

/*=============================================================================*
*  Copyright 2004 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.notification.base.impl;

import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.notification.base.WsnNamespaceVersionHolder;
import org.apache.ws.notification.base.v2004_06.impl.WsnNamespaceVersionHolderImpl;
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 javax.xml.namespace.QName;
import java.util.Map;

/**
* @author Sal Campana
*/
public class UnitExampleHome
   extends AbstractResourceHome
{
   /** DOCUMENT_ME */
   public static final String SERVICE_NAME      = "UnitHome";

   /** DOCUMENT_ME */
   public static final String TARGET_NAMESPACE  = "http://unittest";

   /** DOCUMENT_ME */
   public static final QName  SERVICE_QNAME     = new QName( TARGET_NAMESPACE, SERVICE_NAME );

   /** DOCUMENT_ME */
   public static final String TARGET_NSPREFIX   = "unit";

   /** DOCUMENT_ME */
   public static final String RESOURCE_ID       = "123";

   /** DOCUMENT_ME */
   public static final QName  PORT_TYPE         = new QName( TARGET_NAMESPACE, "UnitTestExamples" );

   /** DOCUMENT_ME */
   public static final String SERVICE_PORT_NAME = SERVICE_NAME;

   /** DOCUMENT_ME */
   public static final QName RESOURCE_KEY_NAME =
      new QName( TARGET_NAMESPACE, "ResourceIdentifier", TARGET_NSPREFIX );

   /**
    * Map containing all FilesystemResource instances - this map <em>must</em> be static for
    * compatibility with certain JNDI providers.
    */
   private static Map               s_resources;
   private Resource                 m_resource;

   /** DOCUMENT_ME */
   public WsnNamespaceVersionHolder m_namespaceSet = new WsnNamespaceVersionHolderImpl(  );

   /**
    * Creates a new {@link UnitExampleHome} object.
    */
   public UnitExampleHome(  )
   {
      setResourceIdentifierReferenceParameterName( RESOURCE_KEY_NAME.toString(  ) );
      setResourceClassName( UnitResource.class.getName(  ) );
      try
      {
         init(  );
      }
      catch ( Exception e )
      {
         e.printStackTrace(  );
      }
   }

   /**
    * DOCUMENT_ME
    *
    * @param resourceContext DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    *
    * @throws ResourceException DOCUMENT_ME
    * @throws ResourceContextException DOCUMENT_ME
    * @throws ResourceUnknownException DOCUMENT_ME
    */
   public Resource getInstance( ResourceContext resourceContext )
   throws ResourceException,
          ResourceContextException,
          ResourceUnknownException
   {
      if ( m_resource == null )
      {
         try
         {
            UnitResource myResource = new UnitResource(  ); //this will create the resource IF it is has default constructor
            myResource.setID( RESOURCE_ID );
            m_resource = myResource;
            myResource.init(  );
            EndpointReference epr = getEndpointReference( RESOURCE_ID );
            myResource.setEndpointReference( epr ); //make sure to set the EPR on your new instance
            add( myResource );
         }
         catch ( Exception e )
         {
            throw new ResourceException( e );
         }
      }

      return m_resource;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public org.apache.ws.resource.properties.NamespaceVersionHolder getNamespaceVersionHolder(  )
   {
      return m_namespaceSet;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public QName getPortType(  )
   {
      return PORT_TYPE;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public QName getResourceKeyNameQName(  )
   {
      return RESOURCE_KEY_NAME;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public QName getServiceName(  )
   {
      return SERVICE_QNAME;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public String getServicePortName(  )
   {
      return SERVICE_PORT_NAME;
   }

   /**
    * Returns a map of all FilesystemResource instances. Used by the {@link org.apache.ws.resource.impl.AbstractResourceHome}
    * superclass.
    */
   protected final synchronized Map getResourceMap(  )
   {
      if ( s_resources == null )
      {
         s_resources = AbstractResourceHome.createResourceMap( m_resourceIsPersistent );
      }

      return s_resources;
   }
}
TOP

Related Classes of org.apache.ws.notification.base.impl.UnitExampleHome

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.