Package org.apache.ws.eventing

Source Code of org.apache.ws.eventing.ForwardEndConsumer

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.pubsub.wsaSOAPConnection;
import org.xmlsoap.schemas.ws.x2004.x08.eventing.LanguageSpecificStringType;
import org.xmlsoap.schemas.ws.x2004.x08.eventing.SubscriptionEndDocument;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;

/**
* DOCUMENT_ME
*
* @version $Revision: 1.8 $
* @author $author$
*/
public class ForwardEndConsumer
   implements org.apache.ws.pubsub.SubscriptionEndConsumer
{
   private static final Log LOG = LogFactory.getLog( ForwardEndConsumer.class.getName(  ) );

   /** DOCUMENT_ME */
   public EndpointReference epr;

   /**
    * Creates a new {@link ForwardEndConsumer} object.
    *
    * @param epr DOCUMENT_ME
    */
   public ForwardEndConsumer( EndpointReference epr )
   {
      this.epr = epr;
   }

   /**
    * DOCUMENT_ME
    *
    * @param epr DOCUMENT_ME
    */
   public void setEPR( EndpointReference epr )
   {
      this.epr = epr;
   }

   /**
    * DOCUMENT_ME
    *
    * @return DOCUMENT_ME
    */
   public EndpointReference getEPR(  )
   {
      return this.epr;
   }

   /**
    * DOCUMENT_ME
    *
    * @param subscription DOCUMENT_ME
    * @param reason DOCUMENT_ME
    */
   public void end( org.apache.ws.pubsub.Subscription subscription,
                    String                            reason )
   {
      //TODO maybe unsubscribe myself
      if ( epr == null )
      {
         LOG.info( "SubscriptionEnd without notification" );
         return;
      }

      //send SubscriptionEnd Notification
      SubscriptionEndDocument                 sedom   = SubscriptionEndDocument.Factory.newInstance(  );
      SubscriptionEndDocument.SubscriptionEnd se      = sedom.addNewSubscriptionEnd(  );
      LanguageSpecificStringType              reasont = se.addNewReason(  );
      reasont.setStringValue( reason );
      try
      {
         //now call
         wsaSOAPConnection sconn = wsaSOAPConnection.newInstance(  );
         MessageFactory    mf    = MessageFactory.newInstance(  );
         SOAPMessage       soapm = mf.createMessage(  );

         //put XMLbean into SOAPBody
         soapm.getSOAPBody(  ).addDocument( (org.w3c.dom.Document) sedom.newDomNode(  ) );

         sconn.call( soapm, epr );
      }
      catch ( Exception e )
      {
         e.printStackTrace(  );
      }
   }
}
TOP

Related Classes of org.apache.ws.eventing.ForwardEndConsumer

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.