Package org.apache.ws.resource.properties

Source Code of org.apache.ws.resource.properties.SushiResource

/*=============================================================================*
*  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.resource.properties;

import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.resource.PropertiesResource;
import org.apache.ws.resource.Resource;
import org.apache.ws.resource.lifetime.ResourceTerminationEvent;
import org.apache.ws.resource.lifetime.ResourceTerminationListener;
import org.apache.ws.resource.lifetime.impl.ResourceTerminationEventImpl;

import java.util.ArrayList;
import java.util.List;

/**
* @author Sal Campana
*/
public class SushiResource
   implements Resource, PropertiesResource
{
   /**
    * The resource ID of the instance.
    */
   public String m_id;

   /**
    * The ResourceProperty Set containing the resource props.
    */
   ResourcePropertySet m_propSet;

   /**
    * A list of termination listeners to be notified when the resource is terminated.
    */
   private List m_terminationListeners = new ArrayList();

    /** The EndpointReference for this resource **/
    protected EndpointReference m_endpointReference;   

   /**
    * DOCUMENT_ME
    *
    * @param id DOCUMENT_ME
    */
   public void setID( Object id )
   {
      if ( m_id != null )
      {
         throw new IllegalStateException( "This resource's ID has already been set." );
      }

      try
      {
         m_id = (String) id;
      }
      catch ( ClassCastException cce )
      {
         throw new IllegalArgumentException( "Specified ID is not a String." );
      }
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public Object getID(  )
   {
      return m_id;
   }

    public void destroy()
    {
         ResourceTerminationEvent rte = new ResourceTerminationEventImpl(getID(),"Job Destroyed");
      for (int i = 0; i < m_terminationListeners.size(); i++)
      {
          ResourceTerminationListener resourceTerminationListener = (ResourceTerminationListener) m_terminationListeners.get(i);
          resourceTerminationListener.terminationOccurred(rte);
      }
    }

    public void init()
    {

    }



    /**
     * Adds a listener to be invoked when the resource has been terminated.
     *
     * @param listener
     */
    public void addTerminationListener(ResourceTerminationListener listener)
    {
       m_terminationListeners.add(listener);
    }

    /**
    * DOCUMENT_ME
    *
    * @param propSet DOCUMENT_ME
    */
   public void setResourcePropertySet( ResourcePropertySet propSet )
   {
      m_propSet = propSet;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public ResourcePropertySet getResourcePropertySet(  )
   {
      return m_propSet;
   }

    /**
     * Returns the EndpointReference associated with this Resource.
     *
     * @return The Resource's EndpointReference or null if the EndpointReference has not been set.
     *
     * Note: It is the responsibility of the Resource creator to set the EndpointReference (i.e. ResourceHome impl)
     */
    public org.apache.ws.addressing.EndpointReference getEndpointReference()
    {
        return m_endpointReference;
    }

}
TOP

Related Classes of org.apache.ws.resource.properties.SushiResource

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.