/*=============================================================================*
* Copyright 2006 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.muse.ws.resource.properties.get.impl;
import java.lang.reflect.Method;
import javax.xml.namespace.QName;
import org.w3c.dom.Element;
import org.apache.muse.core.routing.MessageHandler;
import org.apache.muse.util.ReflectUtils;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.resource.basefaults.BaseFault;
import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
import org.apache.muse.ws.resource.properties.get.GetCapability;
import org.apache.muse.ws.resource.properties.get.faults.InvalidResourcePropertyQNameFault;
/**
*
* SimpleGetCapability is Muse's default implementation of the WS-RP 'get'
* operations - the implementation simply forwards these requests to the
* equivalent methods in {@linkplain ResourcePropertyCollection ResourcePropertyCollection}.
*
* @author Dan Jemiolo (danj)
*
*/
public class SimpleGetCapability
extends AbstractWsResourceCapability implements GetCapability
{
protected MessageHandler createGetDocumentHandler()
{
MessageHandler handler = new GetDocumentHandler();
Method method = ReflectUtils.getFirstMethod(getClass(), "getResourcePropertyDocument");
handler.setMethod(method);
return handler;
}
protected MessageHandler createGetHandler()
{
MessageHandler handler = new GetHandler();
Method method = ReflectUtils.getFirstMethod(getClass(), "getResourceProperty");
handler.setMethod(method);
return handler;
}
protected MessageHandler createGetMultipleHandler()
{
MessageHandler handler = new GetMultipleHandler();
Method method = ReflectUtils.getFirstMethod(getClass(), "getMultipleResourceProperties");
handler.setMethod(method);
return handler;
}
public Element[] getMultipleResourceProperties(QName[] qnames)
throws InvalidResourcePropertyQNameFault, BaseFault
{
ResourcePropertyCollection props = getWsResource().getPropertyCollection();
return props.getMultipleResourceProperties(qnames);
}
public Element[] getResourceProperty(QName qname)
throws InvalidResourcePropertyQNameFault, BaseFault
{
ResourcePropertyCollection props = getWsResource().getPropertyCollection();
return props.getResourceProperty(qname);
}
public Element getResourcePropertyDocument()
throws BaseFault
{
ResourcePropertyCollection props = getWsResource().getPropertyCollection();
return props.getResourcePropertyDocument();
}
public void initialize()
throws SoapFault
{
super.initialize();
setMessageHandler(createGetHandler());
setMessageHandler(createGetDocumentHandler());
setMessageHandler(createGetMultipleHandler());
}
}