Package org.apache.muse.ws.notification.impl

Source Code of org.apache.muse.ws.notification.impl.SubscribeHandler

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you 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.muse.ws.notification.impl;

import java.util.Date;

import org.w3c.dom.Element;

import org.apache.muse.core.routing.AbstractMessageHandler;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.notification.WsnConstants;
import org.apache.muse.ws.resource.WsResource;
import org.apache.muse.ws.resource.lifetime.ScheduledTermination;
import org.apache.muse.ws.resource.lifetime.WsrlConstants;

/**
*
* SubscribeHandler is the parser for the WS-Notification Subscribe operation.
*
* @author Dan Jemiolo (danj)
*
* @see org.apache.muse.ws.notification.impl.SimpleNotificationProducer
*
*/

public class SubscribeHandler extends AbstractMessageHandler
{
    public SubscribeHandler()
    {
        super(WsnConstants.SUBSCRIBE_URI, WsnConstants.SUBSCRIBE_QNAME);
    }
   
    public Object[] fromXML(Element xml)
        throws SoapFault
    {
        Subscribe sub = new Subscribe(xml);
        return sub.toArray();
    }
   
    public Element toXML(Object result)
        throws SoapFault
    {
        WsResource sub = (WsResource)result;
       
        //
        // add termination time to the response, if it exists
        //
        ScheduledTermination wsrl = (ScheduledTermination)sub.getCapability(WsrlConstants.SCHEDULED_TERMINATION_URI);
        Date time = null;
       
        if (wsrl != null)
            time = wsrl.getTerminationTime();
       
        SubscribeResponse response = new SubscribeResponse(sub, time);
        return response.toXML();
    }
}
TOP

Related Classes of org.apache.muse.ws.notification.impl.SubscribeHandler

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.