You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/06/12 18:12:21 UTC
svn commit: r413698 [2/7] - in /webservices/muse/trunk/modules/muse-wsrf:
specs/ src/org/apache/muse/ws/resource/
src/org/apache/muse/ws/resource/basefaults/
src/org/apache/muse/ws/resource/ext/
src/org/apache/muse/ws/resource/ext/faults/ src/org/apach...
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/ResourceInitializationFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/ResourceInitializationFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/ResourceInitializationFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/ResourceInitializationFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.ext.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.ext.WsrfExtConstants;
+
+public class ResourceInitializationFault extends BaseFault
+{
+ private static final long serialVersionUID = 4539155047536939584L;
+
+ public ResourceInitializationFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public ResourceInitializationFault(String message)
+ {
+ super(WsrfExtConstants.RESOURCE_INITIALIZATION_QNAME, message);
+ }
+
+ public ResourceInitializationFault(String message, Throwable cause)
+ {
+ super(WsrfExtConstants.RESOURCE_INITIALIZATION_QNAME, message, cause);
+ }
+
+ public ResourceInitializationFault(Throwable cause)
+ {
+ super(WsrfExtConstants.RESOURCE_INITIALIZATION_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/SerializationErrorFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/SerializationErrorFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/SerializationErrorFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/ext/faults/SerializationErrorFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.ext.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.ext.WsrfExtConstants;
+
+public class SerializationErrorFault extends BaseFault
+{
+ private static final long serialVersionUID = 6757289952824788179L;
+
+ public SerializationErrorFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public SerializationErrorFault(String message)
+ {
+ super(WsrfExtConstants.SERIALIZATION_ERROR_QNAME, message);
+ }
+
+ public SerializationErrorFault(String message, Throwable cause)
+ {
+ super(WsrfExtConstants.SERIALIZATION_ERROR_QNAME, message, cause);
+ }
+
+ public SerializationErrorFault(Throwable cause)
+ {
+ super(WsrfExtConstants.SERIALIZATION_ERROR_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnavailableFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnavailableFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnavailableFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnavailableFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.WsrfConstants;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+
+public class ResourceUnavailableFault extends BaseFault
+{
+ private static final long serialVersionUID = -7569634397313256251L;
+
+ public ResourceUnavailableFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public ResourceUnavailableFault(String message)
+ {
+ super(WsrfConstants.RESOURCE_UNAVAILABLE_QNAME, message);
+ }
+
+ public ResourceUnavailableFault(String message, Throwable cause)
+ {
+ super(WsrfConstants.RESOURCE_UNAVAILABLE_QNAME, message, cause);
+ }
+
+ public ResourceUnavailableFault(Throwable cause)
+ {
+ super(WsrfConstants.RESOURCE_UNAVAILABLE_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnknownFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnknownFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnknownFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/faults/ResourceUnknownFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.WsrfConstants;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+
+public class ResourceUnknownFault extends BaseFault
+{
+ private static final long serialVersionUID = 6896678425171432138L;
+
+ public ResourceUnknownFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public ResourceUnknownFault(String message)
+ {
+ super(WsrfConstants.RESOURCE_UNKNOWN_QNAME, message);
+ }
+
+ public ResourceUnknownFault(String message, Throwable cause)
+ {
+ super(WsrfConstants.RESOURCE_UNKNOWN_QNAME, message, cause);
+ }
+
+ public ResourceUnknownFault(Throwable cause)
+ {
+ super(WsrfConstants.RESOURCE_UNKNOWN_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/AbstractWsResourceCapability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/AbstractWsResourceCapability.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/AbstractWsResourceCapability.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/AbstractWsResourceCapability.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,389 @@
+/*=============================================================================*
+ * 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.impl;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.AbstractCapability;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.serializer.Serializer;
+import org.apache.muse.core.serializer.SerializerRegistry;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.resource.WsResource;
+import org.apache.muse.ws.resource.WsResourceCapability;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.basefaults.WsbfUtils;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+
+/**
+ *
+ * AbstractWsResourceCapability is a foundation for user-defined capabilities
+ * for WSRF-based resources. It builds on the utilities of its
+ * {@linkplain AbstractCapability parent class} by providing the plumbing
+ * code needed to map WSRP requests to getter/setter methods in the
+ * concrete capability class. For example, it provides the logic needed to
+ * map a WSRP GetResourceProperty request for property myns:Widget to
+ * the getWidget() method in the concrete class (if getWidget() is not
+ * defined, a fault is thrown at initialization time).
+ * <br><br>
+ * This class allows users to implement their capabilities' properties
+ * using simple getter/setter logic (like a traditional Java bean) or
+ * more complicated APIs, but they do not have to worry about the XML and
+ * spec restrictions that are needed to implement WSRP operations. The
+ * combination of the getter/setter methods and the WSRP document schema
+ * gives this class everything it needs to transform Java beans into the
+ * foundation for WSRP.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+public abstract class AbstractWsResourceCapability
+ extends AbstractCapability implements WsResourceCapability
+{
+ private static final QName[] _NO_PROPERTIES = new QName[0];
+
+ private static final Element[] _NO_VALUES = new Element[0];
+
+ //
+ // the Java getXXX methods for all resource properties
+ //
+ private Map _gettersByQName = new HashMap();
+
+ //
+ // the Java setXXX methods for all resource properties THAT
+ // PROVIDE WRITE ACCESS
+ //
+ private Map _settersByQName = new HashMap();
+
+ protected void createGettersAndSetters(QName propertyName)
+ {
+ Class theClass = getClass();
+
+ //
+ // get the local name of the property - namespace is not
+ // referenced in the Java method name
+ //
+ String name = propertyName.getLocalPart();
+ name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
+
+ String getName = "get" + name;
+ String setName = "set" + name;
+
+ //
+ // find the getXXX method, which must have zero params and
+ // a non-void return type
+ //
+
+ Method getMethod = null;
+
+ try
+ {
+ getMethod = theClass.getMethod(getName, new Class[0]);
+ }
+
+ catch (Exception error)
+ {
+ throw new RuntimeException("No getter named " + getName + " with zero parameters.");
+ }
+
+ //
+ // make sure getter isn't returning void
+ //
+ if (getMethod.getReturnType() == void.class)
+ throw new RuntimeException("Getters cannot have a return type of void.");
+
+ _gettersByQName.put(propertyName, getMethod);
+
+ //
+ // find the setXXX method, which must take on param and
+ // can have any return type (will be ignored by this class)
+ //
+
+ Method setMethod = ReflectUtils.getFirstMethod(theClass, setName);
+
+ if (setMethod != null)
+ {
+ Class[] paramTypes = setMethod.getParameterTypes();
+
+ //
+ // the setXXX method has to have one parameter - for the
+ // parameter value
+ //
+ if (paramTypes.length != 1)
+ throw new RuntimeException("Setters can only have one parameter");
+
+ _settersByQName.put(propertyName, setMethod);
+ }
+ }
+
+ public void deleteProperty(QName propertyQName)
+ throws BaseFault
+ {
+ Method method = getSetter(propertyQName);
+ invokeMethod(method, new Object[]{ null });
+ }
+
+ protected Method getGetter(QName propertyQName)
+ {
+ return (Method)_gettersByQName.get(propertyQName);
+ }
+
+ public Element[] getProperty(QName propertyQName)
+ throws BaseFault
+ {
+ Method method = getGetter(propertyQName);
+ Object result = invokeMethod(method, null);
+ return getPropertyElements(propertyQName, result);
+ }
+
+ /**
+ *
+ * @param name
+ * @param value
+ *
+ * @return The XML representation of the resource property value(s).
+ *
+ */
+ protected Element[] getPropertyElements(QName name, Object value)
+ throws BaseFault
+ {
+ //
+ // in this case, we have to determine if there IS a property
+ // and it's null, or there is no property
+ //
+ if (value == null)
+ {
+ ResourcePropertyCollection props = getWsResource().getPropertyCollection();
+
+ //
+ // property is nillable - we say it exists. not 100% accurate,
+ // but as close as we're going to get
+ //
+ if (props.getSchema().isNillable(name))
+ return new Element[]{ XmlUtils.createElement(name) };
+
+ //
+ // not nillable - must not exist
+ //
+ return _NO_VALUES;
+ }
+
+ //
+ // in all other cases, we determine the type of the property
+ // values and use that to serialize into XML
+ //
+ Object[] values = null;
+ Class type = null;
+
+ if (value.getClass().isArray())
+ {
+ values = (Object[])value;
+ type = ReflectUtils.getClassFromArrayClass(value.getClass());
+ }
+
+ else
+ {
+ values = new Object[]{ value };
+ type = value.getClass();
+ }
+
+ Element[] properties = new Element[values.length];
+
+ SerializerRegistry registry = SerializerRegistry.getInstance();
+ Serializer ser = registry.getSerializer(type);
+
+ for (int n = 0; n < values.length; ++n)
+ properties[n] = serializeValue(ser, values[n], name);
+
+ return properties;
+ }
+
+ /**
+ *
+ * <b>NOTE:</b> All capability authors should remember to override
+ * this method if their capability defines <b>any</b> resource properties.
+ *
+ */
+ public QName[] getPropertyNames()
+ {
+ return _NO_PROPERTIES;
+ }
+
+ protected Method getSetter(QName propertyQName)
+ {
+ return (Method)_settersByQName.get(propertyQName);
+ }
+
+ public WsResource getWsResource()
+ {
+ return (WsResource)getResource();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ * <br><br>
+ * AbstractWsResourceCapability continues the initialization process
+ * by inspecting the concrete class to find all of the getters (and,
+ * if applicable, setters) for its resource properties. It then
+ * registers itself with the resource's WSRP collection so that read
+ * and write requests for its properties are delegated to it.
+ *
+ */
+ public void initialize()
+ throws SoapFault
+ {
+ super.initialize();
+
+ QName[] propertyNames = getPropertyNames();
+
+ //
+ // make sure we have appropriate getter/setter methods
+ //
+ for (int n = 0; n < propertyNames.length; ++n)
+ createGettersAndSetters(propertyNames[n]);
+
+ //
+ // tell WSRP container about us - all read/write requests for
+ // our properties will now be sent to us
+ //
+ ResourcePropertyCollection props = getWsResource().getPropertyCollection();
+ props.addCapability(this);
+ }
+
+ public void insertProperty(QName propertyQName, Element[] values)
+ throws BaseFault
+ {
+ Element[] current = getProperty(propertyQName);
+ Element[] all = new Element[current.length + values.length];
+ System.arraycopy(current, 0, all, 0, current.length);
+ System.arraycopy(values, 0, all, current.length, values.length);
+
+ updateProperty(propertyQName, all);
+ }
+
+ protected Object invokeMethod(Method method, Object[] params)
+ throws BaseFault
+ {
+ Object result = null;
+
+ try
+ {
+ result = method.invoke(this, params);
+ }
+
+ catch (Throwable error)
+ {
+ Throwable cause = error.getCause();
+
+ if (cause != null)
+ error = cause;
+
+ throw WsbfUtils.convertToFault(error);
+ }
+
+ return result;
+ }
+
+ private Object deserializeValue(Serializer ser, Element value)
+ throws BaseFault
+ {
+ try
+ {
+ return ser.fromXML(value);
+ }
+
+ catch (SoapFault error)
+ {
+ throw WsbfUtils.convertToFault(error);
+ }
+ }
+
+ private Element serializeValue(Serializer ser, Object value, QName name)
+ throws BaseFault
+ {
+ try
+ {
+ return ser.toXML(value, name);
+ }
+
+ catch (SoapFault error)
+ {
+ throw WsbfUtils.convertToFault(error);
+ }
+ }
+
+ public void setResource(Resource resource)
+ {
+ Class theClass = resource.getClass();
+
+ //
+ // sanity check - only ws-resources should use ws-rp
+ //
+ if (!WsResource.class.isAssignableFrom(theClass))
+ throw new RuntimeException(theClass + " is not a WsResource");
+
+ super.setResource(resource);
+ }
+
+ public void updateProperty(QName propertyQName, Element[] values)
+ throws BaseFault
+ {
+ Method method = getSetter(propertyQName);
+
+ if (method == null) // FIXME: message
+ throw new RuntimeException("No setter for " + propertyQName);
+
+ Class[] paramTypes = method.getParameterTypes();
+ boolean isArray = paramTypes[0].isArray();
+
+ Object[] params = new Object[1];
+
+ //
+ // convert all values into POJOs before calling the setXXX method
+ //
+ SerializerRegistry registry = SerializerRegistry.getInstance();
+
+ if (isArray)
+ {
+ Class theClass = ReflectUtils.getClassFromArrayClass(paramTypes[0]);
+ Serializer ser = registry.getSerializer(theClass);
+
+ params[0] = Array.newInstance(theClass, values.length);
+
+ for (int n = 0; n < values.length; ++n)
+ Array.set(params[0], n, deserializeValue(ser, values[n]));
+ }
+
+ else
+ {
+ Serializer ser = registry.getSerializer(paramTypes[0]);
+ params[0] = deserializeValue(ser, values[0]);
+ }
+
+ invokeMethod(method, params);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/Messages.properties?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/Messages.properties Mon Jun 12 09:12:15 2006
@@ -0,0 +1,36 @@
+NullResource = The owner resource is null.
+NullEnvironment = The Environment is null. The resource's Environment reference is needed in order to get information about the underlying system in a platform-independent way.
+NoEnvironment = The resource's environment must be set with setEnvironment() before it can be initialized (via initialize()). Make sure that a concrete Environment reference is provided right after the resource is instantiated.
+NullLogger = The Logger is null. A resource must have a log, even if it is printing to the console.
+NoLogger = The resource's log must be set with setLog() before it can be initialized (via initialize()). Make sure that a java.util.Logger reference is provided right after the resource is instantiated.
+NullSoapClient = The SoapClient is null. The touchpoint must have a valid way to make SOAP requests.
+NullResourceManager = The ResourceManager is null.
+NullFactoryCollection = The Collection of ResourceDefinition references is null. A touchpoint must have at least one resource type (factory) to instantiate.
+EmptyFactoryCollection = The Collection of ResourceDefinition references is empty. A touchpoint must have at least one resource type (factory) to instantiate.
+NoConstructionName = The ResourceType capability cannot be initialized until the resource's "construction name" is set with setConstructionName(). This name is the value defined in muse.xml under /touchpoint/resource/instance/name, and it will be used to set the actp:Name property. Make sure your instantiation code includes a call to setConstructionName().
+ConstructionNameExists = The resource's construction name has already been set with setConstructionName().
+NullConstructionName = The construction name is null.
+NullEndpointURL = The endpoint URL string is null. What is the resource type's unique endpoint value?
+NullOperationsMap = The OperationsMap collection is null.
+NoOperationsMap = The resource's operations (OperationsMap) must be set with setOperations() before you can try to lookup or invoke a resource's exposed operations. This collection allows the resource class to determine which of its methods should be exposed to the outside world.
+NullOperationName = The Operation name being searched for is null.
+NoPropertiesDefinition = The WS-RP definition identified in the WSDL portType's wsrp:ResourceProperties attribute could not be found. Check the name/namespace and sure the they map to one of the type definitions in the WSDL.
+MethodNotFound = There is no method 'XXX' in XXX or any of its sub-components (capabilities, delegates, beans, etc.). Make sure the method name is typed correctly in muse.xml, and that the resource class specified is correct.
+EndpointNotFound = No resource definition was found for endpoint 'XXX'. The valid endpoints for this touchpoint (as described in muse.xml) are: XXX
+NoInvoker = The resource's Invoker has not been constructed.
+NullClassLoader = The ClassLoader is null. If you don't want to specify your own ClassLoader, use the default constructor, it will use the class' ClassLoader.
+EndpointExists = There is already a resource type bound to the endpoint 'XXX'. You must provide a unique endpoint identifier for each resource type.
+NoDataResource = The resource 'XXX' does not exist or is not in the classpath.
+CreateDocFailed = The XML document 'XXX' could not be loaded. The original error was: XXX
+NoMetadataFound = The resource's WSDL portType definition does not have a wsrmd:metadataDescriptorLocation attribute, so no RMD file is associated with the resource type. The resource will not apply any restrictions on the WS-RP document other than what is defined in the schema.
+ResourceInitialized = The resource instance was successfully initialized.
+ResourceAlreadyDestroyed = The resource has already been destroyed. Make sure other resources do not hold stale references to it.
+NoFactory = A resource must have its ResourceDefinition set with setResourceDefinition() before it can be initialized.
+NullFactory = The ResourceDefinition is null.
+ActionNotSupported = The resource type at 'XXX' does not define an operation for the wsa:Action 'XXX'. Make sure the operation is described in muse.xml before the touchpoint is deployed.
+NullLogFileName = The log file name is null.
+NullClass = The Class is null.
+ResourceDestroyed = The resource was destroyed successfully.
+ExistingResourceEPR = The unique EPR of this resource instance (object) has already been set - once a resource has an identifying EPR, it cannot be changed over its lifetime.
+NoRemoteCreate = The resource type at this endpoint cannot be instantiated by remote clients - all instances are (or have been) created through internal mechanisms. If this type is deployed with a service group, you can browse the group's wssg:Entry property to see what instances are already available.
+NoRequestContext = There was no context data for the current request. Every request for a touchpoint operation should have access to context data that allows the runtime to find the target EPR (resource). Make sure your service code uses Environment.addContext().
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,148 @@
+/*=============================================================================*
+ * 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.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.SimpleResource;
+import org.apache.muse.ws.resource.WsResource;
+import org.apache.muse.ws.resource.metadata.OpenMetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.impl.SimpleResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.impl.WsrpUtils;
+import org.apache.muse.ws.resource.properties.schema.OpenPropertiesSchema;
+import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
+import org.apache.muse.ws.resource.properties.schema.impl.SimpleResourcePropertiesSchema;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+
+/**
+ *
+ * SimpleResource is Muse's default implementation of a WS-RF-compliant
+ * resource ({@linkplain WsResource WsResource}). It creates a WSRP
+ * state model using Muse's default
+ * {@linkplain SimpleResourcePropertyCollection WSRP implementation};
+ * the WSRP implementation class can be modified by overriding the
+ * createPropertyCollection() method in this class.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleWsResource extends SimpleResource implements WsResource
+{
+ private ResourcePropertyCollection _properties = null;
+
+ /**
+ *
+ * This method returns the concrete WSRP state model - this is not
+ * the implementation of the WSRP capabilities (which map SOAP
+ * requests to WSRP operations), but it does implement the actual
+ * WSRP operations and does the delegation of read/write requests
+ * to the capabilities defining the properties. It is available no
+ * matter how many of the WSRP capabilites are exposed to remote
+ * clients.
+ * <br><br>
+ * You can replace the default implementation by overriding
+ * this method to instantiate a different concrete class. You would
+ * then specify the name of your new SimpleWsResource sub-class in
+ * muse.xml's <java-resource-class> tag.
+ *
+ * @return An instance of SimpleResourcePropertyCollection.
+ *
+ */
+ protected ResourcePropertyCollection createPropertyCollection()
+ {
+ return new SimpleResourcePropertyCollection();
+ }
+
+ public final ResourcePropertyCollection getPropertyCollection()
+ {
+ return _properties;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ * <br><br>
+ * The SimpleWsResource implementation takes the following steps:
+ * <ol>
+ * <li>Create WSRP state model - createPropertyCollection()</li>
+ * <br>
+ * <li>Create WSRP document schema and apply it to the collection.</li>
+ * <br>
+ * <li>Create WSRP metadata and apply it to the collection.</li>
+ * <br>
+ * <li>Call super.initialize() to initialize capabilities. The
+ * WSRP collection is now available to the capabilities during
+ * their startup cycle.</li>
+ * <br>
+ * <li>Apply metadata by creating components needed to enforce it.</li>
+ * <br>
+ * <li>Validate WSRP document according to schema and metadata.</li>
+ * <br>
+ * </ol>
+ *
+ */
+ public void initialize()
+ throws SoapFault
+ {
+ _properties = createPropertyCollection();
+
+ ResourcePropertiesSchema schema = createPropertiesSchema();
+ _properties.setSchema(schema);
+
+ MetadataDescriptor metadata = createMetadataDescriptor();
+ _properties.setMetadata(metadata);
+
+ super.initialize();
+
+ _properties.applyMetadata();
+
+ _properties.validateSchema();
+ _properties.validateMetadata();
+ }
+
+ protected ResourcePropertiesSchema createPropertiesSchema()
+ {
+ //
+ // get the WSDL, which has the WS-RP definition/schema
+ //
+ String path = getWsdlPath();
+ QName portType = getWsdlPortType();
+ Document wsdl = WsdlUtils.createWSDL(getEnvironment(), path, true);
+ Element wsrpDoc = WsrpUtils.getPropertiesDefinition(wsdl, portType);
+
+ if (wsrpDoc == null) // FIXME: log message at WARNING level
+ return OpenPropertiesSchema.getInstance();
+
+ return new SimpleResourcePropertiesSchema(wsrpDoc);
+ }
+
+ protected MetadataDescriptor createMetadataDescriptor()
+ {
+ //
+ // FIXME: re-finish when WS-RMD spec is a) stable, and b) in
+ // public review (July-ish)
+ //
+ return OpenMetadataDescriptor.getInstance();
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ImmediateTermination.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ImmediateTermination.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ImmediateTermination.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ImmediateTermination.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.lifetime;
+
+import org.apache.muse.ws.resource.WsResourceCapability;
+import org.apache.muse.ws.resource.lifetime.faults.ResourceNotDestroyedFault;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public interface ImmediateTermination extends WsResourceCapability
+{
+ /**
+ *
+ * Makes the resource unavailable to external clients. Note that this does
+ * not affect any destruction code in the Resource's destroy() operation;
+ * the WS-RL destroy only pertains to the visibility of the resource instance.
+ * WS-RL resources will need to remove the visibility of the resource and
+ * then invoke any destruction/shutdown code that exists.
+ *
+ * @throws ResourceNotDestroyedFault
+ * <ul>
+ * <li>If the resource cannot be removed, or if a destructor
+ * callback fails.</li>
+ * </ul>
+ *
+ */
+ void destroy()
+ throws ResourceNotDestroyedFault;
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ScheduledTermination.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ScheduledTermination.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ScheduledTermination.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/ScheduledTermination.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,87 @@
+/*=============================================================================*
+ * 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.lifetime;
+
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.ws.resource.WsResourceCapability;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.lifetime.faults.TerminationTimeChangeRejectedFault;
+import org.apache.muse.ws.resource.lifetime.faults.UnableToSetTerminationTimeFault;
+
+public interface ScheduledTermination extends WsResourceCapability
+{
+ QName[] PROPERTIES = new QName[]{
+ WsrlConstants.CURRENT_TIME_QNAME,
+ WsrlConstants.TERMINATION_TIME_QNAME
+ };
+
+ /**
+ *
+ * @return The current time, according to the resource.
+ *
+ * @throws BaseFault
+ * <ul>
+ * <li>If there is a WS-RP-based error.</li>
+ * </ul>
+ *
+ */
+ Date getCurrentTime()
+ throws BaseFault;
+
+ /**
+ *
+ * @return The termination time for this resource. The method returns
+ * null if the resource is not scheduled for termination.
+ *
+ * @throws BaseFault
+ * <ul>
+ * <li>If there is a WS-RP-based error.</li>
+ * </ul>
+ *
+ */
+ Date getTerminationTime()
+ throws BaseFault;
+
+ /**
+ *
+ * @param time
+ * The new termination time. If the time is null, the resource
+ * will not be scheduled for destruction. If the time is in the
+ * past, it will be destroyed immediately.
+ *
+ * @return The previous termination time value (or null, if none existed).
+ *
+ * @throws UnableToSetTerminationTimeFault
+ * <ul>
+ * <li>If the new time is invalid or the current time cannot
+ * be adjusted.</li>
+ * </ul>
+ *
+ * @throws TerminationTimeChangeRejectedFault
+ * <ul>
+ * <li>If the new time is invalid according to a policy of
+ * the WS-RL implementation.</li>
+ * </ul>
+ *
+ */
+ Date setTerminationTime(Date time)
+ throws UnableToSetTerminationTimeFault,
+ TerminationTimeChangeRejectedFault;
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/WsrlConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/WsrlConstants.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/WsrlConstants.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/WsrlConstants.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,121 @@
+/*=============================================================================*
+ * 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.lifetime;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * WsrlConstants is a collection of properties that is useful when programming
+ * against the WS-ResourceLifetime spec. This class uses WS-RL v1.2.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class WsrlConstants
+{
+ public static final String NAMESPACE_URI = "http://docs.oasis-open.org/wsrf/rl-2";
+
+ public static final String WSDL_NAMESPACE_URI = "http://docs.oasis-open.org/wsrf/rlw-2";
+
+ public static final String PREFIX = "wsrf-rl";
+
+ public static final String WSDL_PREFIX = "wsrf-rlw";
+
+ public static final String IMMEDIATE_TERMINATION_URI =
+ WSDL_NAMESPACE_URI + "/ImmediateResourceTermination";
+
+ public static final String SCHEDULED_TERMINATION_URI =
+ WSDL_NAMESPACE_URI + "/ScheduledResourceTermination";
+
+ /**
+ *
+ * The WS-A Action URI of the Destroy operation.
+ *
+ */
+ public static final String DESTROY_URI = WSDL_NAMESPACE_URI + "/DestroyRequest";
+
+ /**
+ *
+ * The WS-A Action URI of the SetTerminationTime operation.
+ *
+ */
+ public static final String SET_TERMINATION_URI = WSDL_NAMESPACE_URI + "/SetTerminationTimeRequest";
+
+ public static final QName DESTROY_QNAME =
+ new QName(NAMESPACE_URI, "Destroy", PREFIX);
+
+ public static final QName DESTROY_RESPONSE_QNAME =
+ new QName(NAMESPACE_URI, "DestroyResponse", PREFIX);
+
+ public static final QName RESOURCE_NOT_DESTROYED_QNAME =
+ new QName(WSDL_NAMESPACE_URI, "ResourceNotDestroyedFault", WSDL_PREFIX);
+
+ public static final QName SET_TERMINATION_QNAME =
+ new QName(NAMESPACE_URI, "SetTerminationTime", PREFIX);
+
+ public static final QName SET_TERMINATION_RESPONSE_QNAME =
+ new QName(NAMESPACE_URI, "SetTerminationTimeResponse", PREFIX);
+
+ public static final QName UNABLE_TO_SET_TERMINATION_TIME_QNAME =
+ new QName(WSDL_NAMESPACE_URI, "UnableToSetTerminationTimeFault", WSDL_PREFIX);
+
+ public static final QName TERMINATION_TIME_CHANGE_REJECTED_QNAME =
+ new QName(WSDL_NAMESPACE_URI, "TerminationTimeChangeRejectedFault", WSDL_PREFIX);
+
+ public static final QName NEW_TIME_QNAME =
+ new QName(NAMESPACE_URI, "NewTerminationTime", PREFIX);
+
+ public static final QName REQUESTED_TIME_QNAME =
+ new QName(NAMESPACE_URI, "RequestedTerminationTime", PREFIX);
+
+ public static final QName REQUESTED_DURATION_QNAME =
+ new QName(NAMESPACE_URI, "RequestedLifetimeDuration", PREFIX);
+
+ /**
+ *
+ * The name of the wsrl:CurrentTime property.
+ *
+ */
+ public static final QName CURRENT_TIME_QNAME =
+ new QName(NAMESPACE_URI, "CurrentTime", PREFIX);
+
+ /**
+ *
+ * The name of the wsrl:TerminationTime property.
+ *
+ */
+ public static final QName TERMINATION_TIME_QNAME =
+ new QName(NAMESPACE_URI, "TerminationTime", PREFIX);
+
+ /**
+ *
+ * The name of the WS-RL resource termination event.
+ *
+ */
+ public static final QName NOTIFICATION_QNAME =
+ new QName(NAMESPACE_URI, "TerminationNotification", PREFIX);
+
+ /**
+ *
+ * The name of the WS-N Topic for WS-RL termination events.
+ *
+ */
+ public static final QName TERMINATION_TOPIC_QNAME =
+ new QName(NAMESPACE_URI, "ResourceTermination", PREFIX);
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/ResourceNotDestroyedFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/ResourceNotDestroyedFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/ResourceNotDestroyedFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/ResourceNotDestroyedFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.lifetime.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+
+public class ResourceNotDestroyedFault extends BaseFault
+{
+ private static final long serialVersionUID = 6866739382979399756L;
+
+ public ResourceNotDestroyedFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public ResourceNotDestroyedFault(String message)
+ {
+ super(WsrlConstants.RESOURCE_NOT_DESTROYED_QNAME, message);
+ }
+
+ public ResourceNotDestroyedFault(String message, Throwable cause)
+ {
+ super(WsrlConstants.RESOURCE_NOT_DESTROYED_QNAME, message, cause);
+ }
+
+ public ResourceNotDestroyedFault(Throwable cause)
+ {
+ super(WsrlConstants.RESOURCE_NOT_DESTROYED_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/TerminationTimeChangeRejectedFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/TerminationTimeChangeRejectedFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/TerminationTimeChangeRejectedFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/TerminationTimeChangeRejectedFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.lifetime.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+
+public class TerminationTimeChangeRejectedFault extends BaseFault
+{
+ private static final long serialVersionUID = 5635627685023367442L;
+
+ public TerminationTimeChangeRejectedFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public TerminationTimeChangeRejectedFault(String message)
+ {
+ super(WsrlConstants.TERMINATION_TIME_CHANGE_REJECTED_QNAME, message);
+ }
+
+ public TerminationTimeChangeRejectedFault(String message, Throwable cause)
+ {
+ super(WsrlConstants.TERMINATION_TIME_CHANGE_REJECTED_QNAME, message, cause);
+ }
+
+ public TerminationTimeChangeRejectedFault(Throwable cause)
+ {
+ super(WsrlConstants.TERMINATION_TIME_CHANGE_REJECTED_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/UnableToSetTerminationTimeFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/UnableToSetTerminationTimeFault.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/UnableToSetTerminationTimeFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/faults/UnableToSetTerminationTimeFault.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,47 @@
+/*=============================================================================*
+ * 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.lifetime.faults;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+
+public class UnableToSetTerminationTimeFault extends BaseFault
+{
+ private static final long serialVersionUID = 7831882443947531527L;
+
+ public UnableToSetTerminationTimeFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public UnableToSetTerminationTimeFault(String message)
+ {
+ super(WsrlConstants.UNABLE_TO_SET_TERMINATION_TIME_QNAME, message);
+ }
+
+ public UnableToSetTerminationTimeFault(String message, Throwable cause)
+ {
+ super(WsrlConstants.UNABLE_TO_SET_TERMINATION_TIME_QNAME, message, cause);
+ }
+
+ public UnableToSetTerminationTimeFault(Throwable cause)
+ {
+ super(WsrlConstants.UNABLE_TO_SET_TERMINATION_TIME_QNAME, cause);
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/Messages.properties?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/Messages.properties Mon Jun 12 09:12:15 2006
@@ -0,0 +1,4 @@
+NullRequestElement = The DOM Element with the request's SOAP body is null.
+NullResponseElement = The DOM Element with the response's SOAP body is null.
+NullDocument = The DOM Document needed to create the XML fragment is null.
+InvalidTimeValue = Could not set the wsrl:TerminationTime because the time value - XXX - was invalid. The original error was: XXX
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTime.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTime.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTime.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTime.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,130 @@
+/*=============================================================================*
+ * 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.lifetime.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+import org.apache.muse.ws.resource.lifetime.faults.UnableToSetTerminationTimeFault;
+
+/**
+ *
+ * SetTerminationTime is a serializer/deserializer for the WS-ImmediateTermination
+ * SetTerminationTime operation's request content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SetTerminationTime implements XmlSerializable
+{
+ //
+ // Used to lookup all exception messages
+ //
+ private Messages _MESSAGES = MessagesFactory.get(SetTerminationTime.class);
+
+ //
+ // The new wsrl:TerminationTime (could be null)
+ //
+ private Date _time = null;
+
+ public SetTerminationTime(Date time)
+ {
+ _time = time;
+ }
+
+ public SetTerminationTime(Element request)
+ throws UnableToSetTerminationTimeFault
+ {
+ if (request == null)
+ throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+
+ boolean isDuration = true;
+ String timeString = XmlUtils.getElementText(request, WsrlConstants.REQUESTED_DURATION_QNAME);
+
+ //
+ // no duration, try dateTime
+ //
+ if (timeString == null)
+ {
+ isDuration = false;
+ timeString = XmlUtils.getElementText(request, WsrlConstants.REQUESTED_TIME_QNAME);
+ }
+
+ //
+ // the time could be null - this means there is no
+ // scheduled termination any more
+ //
+ if (timeString != null)
+ {
+ try
+ {
+ if (isDuration)
+ {
+ Date rightNow = new Date();
+ long duration = XsdUtils.getDuration(timeString);
+ long theFuture = rightNow.getTime() + duration;
+ _time = new Date(theFuture);
+ }
+
+ else
+ _time = XsdUtils.getLocalTime(timeString);
+ }
+
+ catch (ParseException error)
+ {
+ Object[] filler = { timeString, error.getMessage() };
+ throw new UnableToSetTerminationTimeFault(_MESSAGES.get("InvalidTimeValue", filler));
+ }
+ }
+ }
+
+ public Date getTerminationTime()
+ {
+ return _time;
+ }
+
+ public String toString()
+ {
+ return XmlUtils.toString(toXML(), false);
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document doc)
+ {
+ if (doc == null)
+ throw new NullPointerException(_MESSAGES.get("NullDocument"));
+
+ Element root = XmlUtils.createElement(doc, WsrlConstants.SET_TERMINATION_QNAME);
+ XmlUtils.setElement(root, WsrlConstants.REQUESTED_TIME_QNAME, getTerminationTime());
+
+ return root;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeHandler.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeHandler.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeHandler.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,58 @@
+/*=============================================================================*
+ * 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.lifetime.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.resource.lifetime.WsrlConstants;
+
+/**
+ *
+ * SetTerminationTimeHandler is the parser for the WS-ImmediateTermination
+ * SetTerminationTime operation.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ * @see org.apache.muse.ws.resource.lifetime.ImmediateTermination
+ *
+ */
+
+public class SetTerminationTimeHandler extends AbstractMessageHandler
+{
+ public SetTerminationTimeHandler()
+ {
+ super(WsrlConstants.SET_TERMINATION_QNAME);
+ }
+
+ public Object[] fromXML(Element xml)
+ throws SoapFault
+ {
+ SetTerminationTime request = new SetTerminationTime(xml);
+ return new Object[]{ request.getTerminationTime() };
+ }
+
+ public Element toXML(Object result)
+ {
+ SetTerminationTimeResponse response =
+ new SetTerminationTimeResponse((Date)result);
+ return response.toXML();
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeResponse.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeResponse.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SetTerminationTimeResponse.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,124 @@
+/*=============================================================================*
+ * 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.lifetime.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+
+/**
+ *
+ * SetTerminationTimeResponse is a serializer/deserializer for the
+ * WS-ImmediateTermination SetTerminationTime operation's response content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SetTerminationTimeResponse implements XmlSerializable
+{
+ //
+ // Used to lookup all exception messages
+ //
+ private Messages _MESSAGES =
+ MessagesFactory.get(SetTerminationTimeResponse.class);
+
+ //
+ // The wsrl:CurrentTime
+ //
+ private Date _currentTime = null;
+
+ //
+ // The resource's new wsrl:TerminationTime (could be null)
+ //
+ private Date _terminationTime = null;
+
+ public SetTerminationTimeResponse(Date termination)
+ {
+ _currentTime = new Date();
+ _terminationTime = termination;
+ }
+
+ public SetTerminationTimeResponse(Element xml)
+ throws ParseException
+ {
+ if (xml == null)
+ throw new NullPointerException(_MESSAGES.get("NullResponseElement"));
+
+ //
+ // current time on the RESOURCE (DON'T use 'new Date()')
+ //
+ QName qname = WsrlConstants.CURRENT_TIME_QNAME;
+ String timeString = XmlUtils.getElementText(xml, qname);
+ _currentTime = XsdUtils.getLocalTime(timeString);
+
+ //
+ // termination time that was just set
+ //
+ qname = WsrlConstants.NEW_TIME_QNAME;
+ timeString = XmlUtils.getElementText(xml, qname);
+
+ //
+ // if the termination was cancelled, there won't be a value
+ //
+ if (timeString != null)
+ _terminationTime = XsdUtils.getLocalTime(timeString);
+ }
+
+ public Date getCurrentTime()
+ {
+ return _currentTime;
+ }
+
+ public Date getTerminationTime()
+ {
+ return _terminationTime;
+ }
+
+ public String toString()
+ {
+ return XmlUtils.toString(toXML(), false);
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document doc)
+ {
+ if (doc == null)
+ throw new NullPointerException(_MESSAGES.get("NullDocument"));
+
+ Element root = XmlUtils.createElement(doc, WsrlConstants.SET_TERMINATION_RESPONSE_QNAME);
+ XmlUtils.setElement(root, WsrlConstants.NEW_TIME_QNAME, getTerminationTime());
+ XmlUtils.setElement(root, WsrlConstants.CURRENT_TIME_QNAME, getCurrentTime());
+
+ return root;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleImmediateTermination.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleImmediateTermination.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleImmediateTermination.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleImmediateTermination.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,41 @@
+/*=============================================================================*
+ * 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.lifetime.impl;
+
+import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
+import org.apache.muse.ws.resource.lifetime.ImmediateTermination;
+import org.apache.muse.ws.resource.lifetime.faults.ResourceNotDestroyedFault;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+
+
+public class SimpleImmediateTermination
+ extends AbstractWsResourceCapability implements ImmediateTermination
+{
+ public synchronized void destroy()
+ throws ResourceNotDestroyedFault
+ {
+ try
+ {
+ getResource().shutdown();
+ }
+
+ catch (SoapFault fault)
+ {
+ throw new ResourceNotDestroyedFault(fault);
+ }
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleScheduledTermination.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleScheduledTermination.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleScheduledTermination.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/lifetime/impl/SimpleScheduledTermination.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,166 @@
+/*=============================================================================*
+ * 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.lifetime.impl;
+
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.TimerTask;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.routing.MessageHandler;
+import org.apache.muse.util.LoggingUtils;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.Timer;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.resource.WsResource;
+import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
+import org.apache.muse.ws.resource.lifetime.ImmediateTermination;
+import org.apache.muse.ws.resource.lifetime.ScheduledTermination;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+
+/**
+ *
+ * SimpleScheduledTermination is Muse's default implementation of WS-RL for
+ * WS-RF and manageable resources. It uses Java's built in timing mechanism
+ * to manage scheduled terminations. This class does not provide any actual
+ * resource shutdown operations - it only removes the resource's visibility
+ * to internal and external clients. Resource classes that leverage this
+ * implementation should call this class' destroy() before doing their own
+ * shutdown tasks.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleScheduledTermination
+ extends AbstractWsResourceCapability implements ScheduledTermination
+{
+ //
+ // Used to lookup all exception messages
+ //
+ protected static Messages _MESSAGES =
+ MessagesFactory.get(SimpleScheduledTermination.class);
+
+ private Timer _terminationTimer = null;
+
+ protected MessageHandler createSetTerminationTimeHandler()
+ {
+ MessageHandler handler = new SetTerminationTimeHandler();
+
+ Method method = ReflectUtils.getFirstMethod(getClass(), "setTerminationTime");
+ handler.setMethod(method);
+
+ return handler;
+ }
+
+ public QName[] getPropertyNames()
+ {
+ return PROPERTIES;
+ }
+
+ public void initialize()
+ throws SoapFault
+ {
+ super.initialize();
+
+ //
+ // create the timer that can be used for acting on the
+ // termination time, but don't start it
+ //
+ TimerTask scheduledDestruction = new DestroyTimerTask(getWsResource());
+ _terminationTimer = new Timer(scheduledDestruction);
+
+ setMessageHandler(createSetTerminationTimeHandler());
+ }
+
+ public Date getCurrentTime()
+ {
+ return new Date();
+ }
+
+ public Date getTerminationTime()
+ {
+ return _terminationTimer.getScheduledTime();
+ }
+
+ public Date setTerminationTime(Date time)
+ {
+ if (time == null)
+ _terminationTimer.cancel();
+
+ else if (_terminationTimer.getScheduledTime() == null)
+ _terminationTimer.schedule(time);
+
+ else
+ _terminationTimer.reschedule(time);
+
+ return time;
+ }
+
+ public void shutdown()
+ throws SoapFault
+ {
+ _terminationTimer.cancel();
+ super.shutdown();
+ }
+
+ /**
+ *
+ * DestroyTimerTask is a simple {@linkplain TimerTask TimerTask} that invokes
+ * a resource's WS-RL Destroy operation. It does not perform any the actual
+ * destruction or cleanup tasks.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ * @see ImmediateTermination#destroy
+ *
+ */
+ class DestroyTimerTask extends TimerTask
+ {
+ private WsResource _resource = null;
+
+ public DestroyTimerTask(WsResource resource)
+ {
+ _resource = resource;
+ }
+
+ /**
+ *
+ * Invokes the resource's WS-RL Destroy operation.
+ *
+ */
+ public void run()
+ {
+ try
+ {
+ _resource.shutdown();
+ }
+
+ catch (SoapFault fault)
+ {
+ //
+ // If the resource destructor fails, there's not much
+ // we can do - there is no caller to report back to,
+ // so we just log the info
+ //
+ LoggingUtils.logError(_resource.getLog(), fault);
+ }
+ }
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/MetadataDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/MetadataDescriptor.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/MetadataDescriptor.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/MetadataDescriptor.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,261 @@
+/*=============================================================================*
+ * 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.metadata;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.ws.addressing.soap.SoapFault;
+
+/**
+ *
+ * MetadataDescriptor is an interface for a single metadata descriptor.
+ * It defines a lookup service for property metadata; in addition to
+ * actual metadata values, the interface has convenience methods for
+ * answering common questions ("Can I delete this property?", etc.)
+ * rather than requiring the user to calculate the answers based on
+ * metadata values.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public interface MetadataDescriptor
+{
+ /**
+ *
+ * @param property
+ *
+ * @return True if the property can be deleted (it is read-write and
+ * mutable)
+ *
+ */
+ boolean canDelete(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @return True if the property can have new instances inserted (it is
+ * read-write and mutable/appendable).
+ *
+ */
+ boolean canInsert(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @return True if the property generates events to which users can
+ * subscribe.
+ *
+ */
+ boolean canSubscribe(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @return True if the property's instances can be updated (it is
+ * read-write and mutable).
+ *
+ */
+ boolean canUpdate(QName property);
+
+ /**
+ *
+ * This method allows you to extend a wsrmd:Property definition and provide
+ * application-specific metadata for a property. These will be parsed as
+ * simple name-value pairs - you cannot associate complex types or XML
+ * fragments with an extended metadata item.
+ *
+ * @param property
+ *
+ * @param elementName
+ * The name of the extended metadata item.
+ *
+ * @return The value of the extended metadata item, or null if there is no
+ * such item.
+ *
+ */
+ String getExtendedMetadata(QName property, QName elementName);
+
+ /**
+ *
+ * @param property
+ *
+ * @return The lower bound of the property's valid value range, if one
+ * is defined. The user must interpret the string value in the
+ * context of the property's type. The method returns null if
+ * no range is defined.
+ *
+ */
+ String getLowerBound(QName property);
+
+ /**
+ *
+ * @return The name of the metadata descriptor (defined in XML by its
+ * "name" attribute).
+ *
+ */
+ String getName();
+
+ /**
+ *
+ * @return The collection of property names that are defined in this
+ * descriptor.
+ *
+ */
+ Collection getPropertyNames();
+
+ /**
+ *
+ * @param property
+ *
+ * @return The collection of static values defined for this property. If
+ * no static values exist, the collection will be empty.
+ * <br><br>
+ * The actual values are DOM Elements, since that is how they are
+ * described in the RMD. They can be compared to the results of a
+ * WS-RP GetResourceProperty call.
+ *
+ * @see #getStaticValues(QName, Class)
+ *
+ */
+ Collection getStaticValues(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @param javaType
+ * The type whose serializer should be used to convert the
+ * property values (DOM Elements) into POJOs.
+ *
+ * @return The array of getStaticValues(QName) in POJO form.
+ *
+ * @throws SoapFault
+ * <ul>
+ * <li>If there is no Serializer registered for the given type.</li>
+ * <li>If the property value XML can not be translated into an
+ * instance of the given type.</li>
+ * </ul>
+ *
+ * @see #getStaticValues(QName)
+ *
+ */
+ Object getStaticValues(QName property, Class javaType)
+ throws SoapFault;
+
+ /**
+ *
+ * @param property
+ *
+ * @return The upper bound of the property's valid value range, if one
+ * is defined. The user must interpret the string value in the
+ * context of the property's type. The method returns null if
+ * no range is defined.
+ *
+ */
+ String getUpperBound(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @return The collection of valid values defined for this property. If
+ * no valid values exist, the collection will be empty (in this
+ * case, <b>all</b> values are valid).
+ * <br><br>
+ * The actual values are DOM Elements, since that is how they are
+ * described in the RMD (unlike a valid value range, the valid
+ * values are complete property instances). They can be compared
+ * to the results of a WS-RP GetResourceProperty call.
+ *
+ * @see #getValidValues(QName, Class)
+ *
+ */
+ Collection getValidValues(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @param javaType
+ * The type whose serializer should be used to convert the
+ * property values (DOM Elements) into POJOs.
+ *
+ * @return The array of getValidValues(QName) in POJO form.
+ *
+ * @throws SoapFault
+ * <ul>
+ * <li>If there is no Serializer registered for the given type.</li>
+ * <li>If the property value XML can not be translated into an
+ * instance of the given type.</li>
+ * </ul>
+ * @throws SoapFault
+ *
+ * @see #getValidValues(QName)
+ *
+ */
+ Object getValidValues(QName property, Class javaType)
+ throws SoapFault;
+
+ /**
+ *
+ * @param property
+ *
+ * @return True if the descriptor defines a property with the given name.
+ *
+ */
+ boolean hasProperty(QName property);
+
+ /**
+ *
+ * @param property
+ *
+ * @return True if the property cannot be modified by external clients,
+ * but is mutable by internal code (it is read-only but mutable).
+ *
+ */
+ boolean isReadOnlyExternal(QName property);
+
+ /**
+ *
+ * @param property
+ * @param value
+ *
+ * @return True if the given value is found in the property's set of
+ * static values. If the property has no static values defined,
+ * the method returns "false".
+ *
+ */
+ boolean isStaticValue(QName property, Object value);
+
+ /**
+ *
+ * @param property
+ * @param value
+ *
+ * @return True if the given value is found in the property's set of
+ * valid values. If the property has no valid values defined,
+ * the method returns "true".
+ *
+ */
+ boolean isValidValue(QName property, Object value);
+}
Added: webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/OpenMetadataDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/OpenMetadataDescriptor.java?rev=413698&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/OpenMetadataDescriptor.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src/org/apache/muse/ws/resource/metadata/OpenMetadataDescriptor.java Mon Jun 12 09:12:15 2006
@@ -0,0 +1,232 @@
+/*=============================================================================*
+ * 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.metadata;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ *
+ * OpenMetadataDescriptor is a
+ * {@linkplain MetadataDescriptor MetadataDescriptor} that allows free reign
+ * on all properties, since no rules or restrictions have been put in place.
+ * This class is a singleton because an empty RMD is the same no matter what
+ * properties are defined.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class OpenMetadataDescriptor implements MetadataDescriptor
+{
+ //
+ // This descriptor is the same no matter what document it's applied to,
+ // so we only need one instance of it
+ //
+ private static final OpenMetadataDescriptor _SINGLETON = new OpenMetadataDescriptor();
+
+ /**
+ *
+ * @return The singleton instance of this class.
+ *
+ */
+ public static OpenMetadataDescriptor getInstance()
+ {
+ return _SINGLETON;
+ }
+
+ /**
+ *
+ * Private constructor used to prevent instantiation.
+ *
+ */
+ private OpenMetadataDescriptor()
+ {
+ //
+ // this constructor is only explicit so we can make it private
+ //
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean canDelete(QName property)
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean canInsert(QName property)
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean canSubscribe(QName property)
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean canUpdate(QName property)
+ {
+ return true;
+ }
+
+ public String getExtendedMetadata(QName property, QName elementName)
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return null
+ *
+ */
+ public String getLowerBound(QName property)
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return null
+ *
+ */
+ public String getName()
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return An empty collection.
+ *
+ */
+ public Collection getPropertyNames()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @return An empty collection.
+ *
+ */
+ public Collection getStaticValues(QName property)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @return An empty collection.
+ *
+ */
+ public Object getStaticValues(QName property, Class type)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @return null
+ *
+ */
+ public String getUpperBound(QName property)
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return An empty collection.
+ *
+ */
+ public Collection getValidValues(QName property)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @return An empty collection.
+ *
+ */
+ public Object getValidValues(QName property, Class type)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean hasProperty(QName property)
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return false
+ *
+ */
+ public boolean isReadOnlyExternal(QName property)
+ {
+ return false;
+ }
+
+ /**
+ *
+ * @return false
+ *
+ */
+ public boolean isStaticValue(QName property, Object value)
+ {
+ return false;
+ }
+
+ /**
+ *
+ * @return true
+ *
+ */
+ public boolean isValidValue(QName property, Object value)
+ {
+ return true;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org