Package org.apache.ws.notification.base

Source Code of org.apache.ws.notification.base.FixedTopicSetResourcePropertyCallback

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

import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
import org.apache.ws.notification.topics.TopicSet;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.ResourcePropertyCallback;
import org.apache.ws.resource.properties.impl.CallbackFailedException;
import org.apache.xmlbeans.XmlBoolean;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.FixedTopicSetDocument;
import javax.xml.namespace.QName;

/**
* A callback for the FixedTopicSet resource property from the WS-BaseNotification NotificationProducer portType.
*/
public class FixedTopicSetResourcePropertyCallback
   implements ResourcePropertyCallback
{
   private TopicSet m_topicSet;

   /**
    * Creates a new {@link TopicResourcePropertyCallback} for the specified topic set.
    *
    * @param topicSet the producer's topic set
    */
   public FixedTopicSetResourcePropertyCallback( TopicSet topicSet )
   {
      m_topicSet = topicSet;
   }

   /**
    * Refreshes the value of the wsnt:FixedTopicSet resource property so that it
    * reflects the fixed flag on the producer resource's topic set.
    *
    * @param prop the wsnt:FixedTopicSet resource property
    *
    * @return the wsnt:FixedTopicSet resource property
    *
    * @throws org.apache.ws.resource.properties.impl.CallbackFailedException
    */
   public ResourceProperty refreshProperty( ResourceProperty prop )
   throws CallbackFailedException
   {
      QName propName = prop.getMetaData(  ).getName(  );
      if ( !propName.equals( NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET ) )
      {
         throw new IllegalArgumentException( "Unsupported property: " + propName );
      }

      if ( prop.isEmpty(  ) )
      {
         FixedTopicSetDocument fixedTopicSetDoc = FixedTopicSetDocument.Factory.newInstance(  );
         fixedTopicSetDoc.setFixedTopicSet( m_topicSet.isFixed(  ) );
         prop.add( fixedTopicSetDoc );
      }
      else
      {
         XmlBoolean fixedTopicSetPropElem = (XmlBoolean) prop.get( 0 );
         fixedTopicSetPropElem.setBooleanValue( m_topicSet.isFixed(  ) );
      }

      return prop;
   }
}
TOP

Related Classes of org.apache.ws.notification.base.FixedTopicSetResourcePropertyCallback

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.