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/08/29 05:19:20 UTC
svn commit: r437927 [2/2] - in /webservices/muse/trunk/modules:
muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/
muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/
muse-wsrf-impl/src/org/apache/muse/ws/resource/lifetime/impl/ muse-wsrf-i...
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java Mon Aug 28 20:19:18 2006
@@ -41,14 +41,41 @@
public class InsertRequest extends AbstractSetRequestComponent
{
//
- // The name of this SetResourceProperties operation
+ // Used to lookup all exception messages
//
- public static final String OPERATION = "Insert";
+ private static Messages _MESSAGES = MessagesFactory.get(InsertRequest.class);
//
- // Used to lookup all exception messages
+ // The name of this SetResourceProperties operation
//
- private static Messages _MESSAGES = MessagesFactory.get(InsertRequest.class);
+ public static final String OPERATION = "Insert";
+
+ public InsertRequest(Element request)
+ throws BaseFault
+ {
+ if (request == null)
+ throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+
+ Element[] children = XmlUtils.getAllElements(request);
+
+ if (children.length == 0)
+ throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesFoundInsert"));
+
+ //
+ // the WS-RP spec says that in an Insert request with multiple
+ // elements, all elements MUST have the same qualified name
+ //
+
+ QName firstQName = XmlUtils.getElementQName(children[0]);
+
+ Element[] matches = XmlUtils.getElements(request, firstQName);
+
+ if (matches.length != children.length)
+ throw new InvalidMessageFormatFault(_MESSAGES.get("NamesNotEqualInsert"));
+
+ setPropertyName(firstQName);
+ setValues(children);
+ }
public InsertRequest(QName qname)
{
@@ -78,33 +105,6 @@
setPropertyName(qname);
setValues(values);
- }
-
- public InsertRequest(Element request)
- throws BaseFault
- {
- if (request == null)
- throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
-
- Element[] children = XmlUtils.getAllElements(request);
-
- if (children.length == 0)
- throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesFoundInsert"));
-
- //
- // the WS-RP spec says that in an Insert request with multiple
- // elements, all elements MUST have the same qualified name
- //
-
- QName firstQName = XmlUtils.getElementQName(children[0]);
-
- Element[] matches = XmlUtils.getElements(request, firstQName);
-
- if (matches.length != children.length)
- throw new InvalidMessageFormatFault(_MESSAGES.get("NamesNotEqualInsert"));
-
- setPropertyName(firstQName);
- setValues(children);
}
public void execute(ResourcePropertyCollection properties)
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java Mon Aug 28 20:19:18 2006
@@ -25,8 +25,8 @@
/**
*
- * SetHandler is the parser for the WS-ResourceProperties
- * SetResourceProperties operation.
+ * SetHandler is the parser for the WS-ResourceProperties SetResourceProperties
+ * operation.
*
* @author Dan Jemiolo (danj)
*
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java Mon Aug 28 20:19:18 2006
@@ -19,9 +19,9 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.apache.muse.ws.resource.properties.WsrpConstants;
import org.apache.muse.util.xml.XmlSerializable;
import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
/**
*
@@ -34,12 +34,7 @@
public class SetResponse implements XmlSerializable
{
- private static Element _xml = null;
-
- static
- {
- _xml = XmlUtils.createElement(XmlUtils.EMPTY_DOC, WsrpConstants.SET_RESPONSE_QNAME);
- }
+ private static Element _xml = XmlUtils.createElement(WsrpConstants.SET_RESPONSE_QNAME);
public String toString()
{
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java Mon Aug 28 20:19:18 2006
@@ -25,9 +25,20 @@
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.set.SetCapability;
import org.apache.muse.ws.resource.properties.set.SetRequest;
+/**
+ *
+ * SimpleSetCapability is Muse's default implementation of the WS-RP 'set'
+ * operations - the implementation simply forwards these requests to the
+ * equivalent methods in {@linkplain ResourcePropertyCollection ResourcePropertyCollection}.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
public class SimpleSetCapability
extends AbstractWsResourceCapability implements SetCapability
{
@@ -45,7 +56,6 @@
throws SoapFault
{
super.initialize();
-
setMessageHandler(createSetHandler());
}
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java Mon Aug 28 20:19:18 2006
@@ -33,10 +33,10 @@
/**
*
* SimpleSetOperationFactory provides an API for constructing and parsing WS-RP
- * SetResourceProperties requests, including the Insert, Delete,
- * and Update operations. There are convenience methods for creating
- * outbound requests with each operation type as well as a factory
- * method for parsing inbound XML into executables.
+ * SetResourceProperties requests, including the Insert, Delete, and Update
+ * operations. There are convenience methods for creating outbound requests with
+ * each operation type as well as a factory method for parsing inbound XML into
+ * executables.
*
* @author Dan Jemiolo (danj)
*
@@ -48,36 +48,14 @@
// Used to lookup all exception messages
//
private static Messages _MESSAGES = MessagesFactory.get(SimpleSetOperationFactory.class);
-
- /**
- *
- * This is a convenience method that creates a new SimpleSetRequest object
- * an populates it with a DeleteRequest for the given property.
- *
- * @param qname
- * The name of the property to delete.
- *
- */
+
public SetRequest createDelete(QName qname)
{
SetRequest set = new SimpleSetRequest();
set.addRequestComponent(new DeleteRequest(qname));
return set;
}
-
- /**
- *
- * This is a convenience method that creates a new SimpleSetRequest object
- * an populates it with a InsertRequest for the given property.
- *
- * @param qname
- * The name of the property to insert.
- *
- * @param values
- * The initial values for each instance of the property. This
- * array should not be null, nor empty.
- *
- */
+
public SetRequest createInsert(QName qname, Object[] values)
{
SetRequest set = new SimpleSetRequest();
@@ -85,35 +63,13 @@
return set;
}
- /**
- *
- * Parses the given XML fragment according to the WS-RP spec for
- * SetResourceProperties requests.
- *
- * @param request
- * An XML fragment containing a SetResourceProperties request.
- *
- * @return A SimpleSetRequest that contains one AbstractSetRequestComponent for each
- * operation defined in the request. This object can be used
- * to execute the request against a WS-RP container.
- *
- * @throws BaseFault
- * <ul>
- * <li>If the request is empty (contains no operations).</li>
- * <li>If one of the operation types is invalid (only Insert,
- * Delete, and Update are allowed).</li>
- * <li>If one of the operations is not properly formatted.</li>
- * </ul>
- *
- */
public SetRequest createSet(Element request)
throws BaseFault
{
if (request == null)
throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
- Element[] children =
- XmlUtils.getAllElements(request, WsrpConstants.NAMESPACE_URI);
+ Element[] children = XmlUtils.getAllElements(request, WsrpConstants.NAMESPACE_URI);
if (children.length == 0)
throw new InvalidMessageFormatFault(_MESSAGES.get("EmptySetRequest"));
@@ -121,7 +77,8 @@
SetRequest set = new SimpleSetRequest();
//
- // build the different types of sets from XML
+ // build the different types of sets from XML. don't bother with a
+ // table, we only have three command types
//
for (int n = 0; n < children.length; ++n)
{
@@ -149,19 +106,7 @@
return set;
}
-
- /**
- *
- * This is a convenience method that creates a new SimpleSetRequest object
- * an populates it with a UpdateRequest for the given property.
- *
- * @param qname
- * The name of the property to update.
- *
- * @param values
- * The values that will be copied to each instance of the property.
- *
- */
+
public SetRequest createUpdate(QName qname, Object[] values)
{
SetRequest set = new SimpleSetRequest();
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java Mon Aug 28 20:19:18 2006
@@ -41,28 +41,14 @@
public class UpdateRequest extends AbstractSetRequestComponent
{
//
- // The name of this SetResourceProperties operation
+ // Used to lookup all exception messages
//
- public static final String OPERATION = "Update";
+ private static Messages _MESSAGES = MessagesFactory.get(UpdateRequest.class);
//
- // Used to lookup all exception messages
+ // The name of this SetResourceProperties operation
//
- private static Messages _MESSAGES = MessagesFactory.get(UpdateRequest.class);
-
- public UpdateRequest(QName qname, Object value)
- {
- this(qname, new Object[]{ value });
- }
-
- public UpdateRequest(QName qname, Object[] values)
- {
- if (qname == null)
- throw new NullPointerException(_MESSAGES.get("NullQName"));
-
- setPropertyName(qname);
- setValues(values);
- }
+ public static final String OPERATION = "Update";
public UpdateRequest(Element request)
throws BaseFault
@@ -77,6 +63,20 @@
setPropertyName(XmlUtils.getElementQName(properties[0]));
setValues(properties);
+ }
+
+ public UpdateRequest(QName qname, Object value)
+ {
+ this(qname, new Object[]{ value });
+ }
+
+ public UpdateRequest(QName qname, Object[] values)
+ {
+ if (qname == null)
+ throw new NullPointerException(_MESSAGES.get("NullQName"));
+
+ setPropertyName(qname);
+ setValues(values);
}
public void execute(ResourcePropertyCollection properties)
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/remote/WsResourceClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/remote/WsResourceClient.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/remote/WsResourceClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/remote/WsResourceClient.java Mon Aug 28 20:19:18 2006
@@ -45,15 +45,15 @@
/**
*
- * WsResourceClient is a web service proxy that allows users to invoke standard
+ * WsResourceClient is a web service client that allows users to invoke standard
* WSRF operations without writing any XML plumbing code. This class includes
- * all of the operations from WSRL and WSRP, but this does <b>not</b> mean that
- * all Muse resource types implement all WSRL and WSRP operations. It is more
- * convenient to have one proxy class since all WSRL and WSRP operations are
- * defined as separate capabilities (which would result in one proxy per
- * operation); if users need more detailed information about what operations
- * are supported by a resource, they can use the WS-MetadataExchange client
- * and/or the Muse ResourceInspector tool.
+ * all of the operations from WSRF, but this does <b>not</b> mean that all Muse
+ * resource types implement all WSRF operations; rather, it is more convenient
+ * to have one client class since all WSRF operations are defined as separate
+ * capabilities (which would result in one client per operation); if users need
+ * more detailed information about what operations are supported by a resource,
+ * they can use the WS-MetadataExchange client in combination with the Muse
+ * ResourceInspector tool.
*
* @author Dan Jemiolo (danj)
*
@@ -61,6 +61,9 @@
public class WsResourceClient extends AbstractResourceClient
{
+ //
+ // used to parse WSRP SetResourceProperties requests
+ //
private static final SetOperationFactory _SET_FACTORY = new SimpleSetOperationFactory();
public WsResourceClient(EndpointReference destination)
@@ -110,6 +113,13 @@
return XmlUtils.getAllElements(response);
}
+ /**
+ *
+ * This is a convenience method that calls getResourceProperty() and then
+ * parses the XML results into POJOs of the given type using the Muse
+ * serializer framework.
+ *
+ */
public Object getPropertyAsObject(QName qname, Class type)
throws SoapFault
{
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddRequest.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddRequest.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddRequest.java Mon Aug 28 20:19:18 2006
@@ -43,6 +43,9 @@
public class AddRequest implements XmlSerializable
{
+ //
+ // Used to look up all exception messages
+ //
private static Messages _MESSAGES = MessagesFactory.get(AddRequest.class);
private Element _content = null;
@@ -97,14 +100,14 @@
_termination = termination;
}
- public EndpointReference getMemberEPR()
+ public Element getContent()
{
- return _memberEPR;
+ return _content;
}
- public Element getContent()
+ public EndpointReference getMemberEPR()
{
- return _content;
+ return _memberEPR;
}
public Date getTerminationTime()
@@ -130,6 +133,10 @@
WsResourceClient member = new WsResourceClient(epr);
Element content = getContent();
+ //
+ // if no content recorded, retrieve content values at runtime using
+ // remote client
+ //
try
{
if (content == null)
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddResponse.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddResponse.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/AddResponse.java Mon Aug 28 20:19:18 2006
@@ -43,7 +43,10 @@
public class AddResponse implements XmlSerializable
{
- private static Messages _MESSAGES = MessagesFactory.get(AddRequest.class);
+ //
+ // Used to look up all exception messages
+ //
+ private static Messages _MESSAGES = MessagesFactory.get(AddResponse.class);
private Date _currentTime = new Date();
@@ -103,14 +106,14 @@
return _currentTime;
}
- public Date getTerminationTime()
+ public WsResourceClient getEntryClient()
{
- return _terminationTime;
+ return new WsResourceClient(_entryEPR);
}
- public WsResourceClient getEntryClient()
+ public Date getTerminationTime()
{
- return new WsResourceClient(_entryEPR);
+ return _terminationTime;
}
public Element toXML()
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/Messages.properties?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/Messages.properties Mon Aug 28 20:19:18 2006
@@ -11,4 +11,5 @@
IncorrectPersistenceRoot=This implementation of the ServiceGroup capability requires that any persistence implementation have the XXX interface. Your class - XXX - does not implement the methods from this interface.
NullElement=The DOM Element is null.
NullDocument=The DOM Document to be used as an Element factory is null.
-NullEntry=The entry resource is null.
\ No newline at end of file
+NullEntry=The entry resource is null.
+NoServiceGroupCapability=The resource with context path 'XXX' is using the WS-SG ServiceGroupRegistration capability but not the WS-SG ServiceGroup capability. You can't do service group registration without basic service group capabilities, so make sure this capability is added. The capability URI is 'XXX'.
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/ServiceGroupFilePersistence.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/ServiceGroupFilePersistence.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/ServiceGroupFilePersistence.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/ServiceGroupFilePersistence.java Mon Aug 28 20:19:18 2006
@@ -32,16 +32,54 @@
import org.apache.muse.ws.resource.sg.ServiceGroupPersistence;
import org.apache.muse.ws.resource.sg.WssgConstants;
+/**
+ *
+ * ServiceGroupFilePersistence is an implementation of file-based persistence
+ * of service group entry data. It stores data about current service group
+ * entries on disk and then re-loads them after an application restarts. This
+ * allows the service group to continue functioning as it was before the
+ * restart without the application having to somehow re-discover and re-add
+ * all of the members.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
public class ServiceGroupFilePersistence
extends AbstractFilePersistence implements ServiceGroupPersistence
{
private WsResource _serviceGroup = null;
+ protected void createResourceFile(EndpointReference epr, Resource resource, File resourceFile)
+ throws SoapFault
+ {
+ //
+ // write the service group entry XML infoset to file
+ //
+ Entry entry = (Entry)resource.getCapability(WssgConstants.ENTRY_URI);
+ Element entryXML = entry.toXML();
+
+ try
+ {
+ XmlUtils.toFile(entryXML, resourceFile);
+ }
+
+ catch (IOException error)
+ {
+ throw new SoapFault(error);
+ }
+ }
+
protected String getFilePrefix()
{
return "service-group-entry-";
}
-
+
+ public WsResource getServiceGroup()
+ {
+ return _serviceGroup;
+ }
+
protected Resource reloadResource(String contextPath, Element resourceXML)
throws SoapFault
{
@@ -75,33 +113,6 @@
return entryResource;
}
- protected void createResourceFile(EndpointReference epr, Resource resource, File resourceFile)
- throws SoapFault
- {
- Entry entry = (Entry)resource.getCapability(WssgConstants.ENTRY_URI);
- Element entryXML = entry.toXML();
-
- try
- {
- XmlUtils.toFile(entryXML, resourceFile);
- }
-
- catch (IOException error)
- {
- throw new SoapFault(error);
- }
- }
-
- public WsResource getServiceGroup()
- {
- return _serviceGroup;
- }
-
- public void setServiceGroup(WsResource serviceGroup)
- {
- _serviceGroup = serviceGroup;
- }
-
public void resourceAdded(EndpointReference epr, Resource resource)
throws SoapFault
{
@@ -112,5 +123,10 @@
throws SoapFault
{
destroyResourceFile(epr);
+ }
+
+ public void setServiceGroup(WsResource serviceGroup)
+ {
+ _serviceGroup = serviceGroup;
}
}
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleEntry.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleEntry.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleEntry.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleEntry.java Mon Aug 28 20:19:18 2006
@@ -26,7 +26,6 @@
import org.apache.muse.ws.resource.WsResource;
import org.apache.muse.ws.resource.basefaults.BaseFault;
import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
-import org.apache.muse.ws.resource.impl.SimpleWsResource;
import org.apache.muse.ws.resource.remote.WsResourceClient;
import org.apache.muse.ws.resource.sg.Entry;
import org.apache.muse.ws.resource.sg.ServiceGroup;
@@ -38,11 +37,9 @@
/**
*
- * SimpleEntry is Muse's default implementation of the WS-ServiceGroups
- * Entry resource type. This class is exposed as a first-class resource
- * to web service clients. It extends the
- * {@linkplain SimpleWsResource basic resource} defined by Muse
- * and adds support for the Entry-specific properties. Because entries are
+ * SimpleEntry is Muse's default implementation of the WS-RF ServiceGroupEntry
+ * capability. This capability provides all of the Entry-specific properties
+ * needed to quality the resource as a service group entry. Because entries are
* also serialized as properties in the service group itself, this class
* also provides XML serialization.
*
@@ -57,28 +54,20 @@
// Used to look up all exception messages
//
protected static Messages _MESSAGES = MessagesFactory.get(SimpleEntry.class);
-
+
private static final Element[] _EMPTY_CONTENT = new Element[0];
private WsResourceClient _member = null;
private WsResource _serviceGroup = null;
- public QName[] getPropertyNames()
- {
- return PROPERTIES;
- }
-
- public void shutdown()
- throws SoapFault
- {
- ServiceGroup sg =
- (ServiceGroup)getServiceGroup().getCapability(WssgConstants.SERVICE_GROUP_URI);
- sg.removeEntry(getWsResource());
-
- super.shutdown();
- }
-
+ /**
+ *
+ * This implementation reads the content values on-the-fly, creating a
+ * client to the member resource and using the WSRP GetMultipleResourceProperties
+ * operation to discover the property values.
+ *
+ */
public Element getContent()
throws BaseFault
{
@@ -113,29 +102,34 @@
return root;
}
-
+
protected WsResourceClient getMemberClient()
{
return _member;
}
-
- protected WsResource getServiceGroup()
- {
- return _serviceGroup;
- }
-
+
public EndpointReference getMemberEPR()
{
WsResourceClient client = getMemberClient();
return client == null ? null : client.getEndpointReference();
}
+
+ public QName[] getPropertyNames()
+ {
+ return PROPERTIES;
+ }
+
+ protected WsResource getServiceGroup()
+ {
+ return _serviceGroup;
+ }
public EndpointReference getServiceGroupEPR()
{
WsResource sg = getServiceGroup();
return sg == null ? null : sg.getEndpointReference();
}
-
+
public void setMemberEPR(EndpointReference memberEPR)
{
if (memberEPR == null)
@@ -143,13 +137,25 @@
_member = new WsResourceClient(memberEPR, getServiceGroupEPR(), getEnvironment());
}
-
+
public void setServiceGroup(WsResource serviceGroup)
{
if (serviceGroup == null)
throw new NullPointerException(_MESSAGES.get("NullServiceGroup"));
_serviceGroup = serviceGroup;
+ }
+
+ public void shutdown()
+ throws SoapFault
+ {
+ //
+ // tell the sg that owns us to remove us from its collection
+ //
+ ServiceGroup sg = (ServiceGroup)getServiceGroup().getCapability(WssgConstants.SERVICE_GROUP_URI);
+ sg.removeEntry(getWsResource());
+
+ super.shutdown();
}
public Element toXML()
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleMembershipContentRule.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleMembershipContentRule.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleMembershipContentRule.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleMembershipContentRule.java Mon Aug 28 20:19:18 2006
@@ -48,7 +48,7 @@
private static Messages _MESSAGES =
MessagesFactory.get(SimpleMembershipContentRule.class);
- private QName[] _EMPTY_CONTENT = new QName[0];
+ private static final QName[] _EMPTY_CONTENT = new QName[0];
private QName[] _content = _EMPTY_CONTENT;
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroup.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroup.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroup.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroup.java Mon Aug 28 20:19:18 2006
@@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.xml.namespace.QName;
@@ -51,10 +52,11 @@
/**
*
- * SimpleServiceGroup is Muse's default implementation of the
- * WS-ServiceGroup ServiceGroup resource type. It provides SOAP-level
- * access to the entries it contains and lifecycle management for the
- * Entry resources.
+ * SimpleServiceGroup is Muse's default implementation of the WS-RF ServiceGroup
+ * capability. It provides SOAP-level access to the entries it contains and
+ * lifecycle management for the Entry resources. Users that wish to make entry
+ * creation available to remote clients should combine this capability with
+ * the {@linkplain SimpleServiceGroupRegistration ServiceGroupRegistration capability}.
*
* @author Dan Jemiolo (danj)
*
@@ -75,11 +77,6 @@
private String _entryPath = null;
- public QName[] getPropertyNames()
- {
- return PROPERTIES;
- }
-
public WsResource addEntry(EndpointReference memberEPR,
Element content,
Date termination)
@@ -114,6 +111,9 @@
WsResource sg = getWsResource();
+ //
+ // make sure this is a valid member of the group
+ //
if (!isMatch(epr))
throw new AddRefusedFault(_MESSAGES.get("ContentCreationFailed"));
@@ -131,6 +131,10 @@
throw new ResourceInitializationFault(error);
}
+ //
+ // set the sg entry fields before initializing the entry resource
+ //
+
Entry entry = (Entry)resource.getCapability(WssgConstants.ENTRY_URI);
entry.setServiceGroup(sg);
@@ -163,20 +167,25 @@
return resource;
}
- protected MembershipContentRule[] createMembershipContentRules()
+ protected MembershipContentRule createMembershipContentRule()
{
- return new MembershipContentRule[0];
+ return new SimpleMembershipContentRule(getResource().getEndpointReference());
}
- public void shutdown()
- throws SoapFault
+ protected MembershipContentRule createMembershipContentRule(Element xml)
{
- WsResource[] entries = getEntry();
-
- for (int n = 0; n < entries.length; ++n)
- entries[n].shutdown();
-
- super.shutdown();
+ return new SimpleMembershipContentRule(getResource().getEndpointReference(), xml);
+ }
+
+ /**
+ *
+ * This implementation returns an empty array (no content rules, no
+ * restrictions on membership).
+ *
+ */
+ protected MembershipContentRule[] createMembershipContentRules()
+ {
+ return new MembershipContentRule[0];
}
public QName[] getContentElements()
@@ -206,24 +215,48 @@
return (WsResource)_entriesByMemberEPR.get(memberEPR);
}
- public MembershipContentRule[] getMembershipContentRule()
+ protected String getEntryContextPath()
{
- return _contentRules;
+ return _entryPath;
}
- protected MembershipContentRule createMembershipContentRule()
+ protected Element[] getEntryElements()
{
- return new SimpleMembershipContentRule(getResource().getEndpointReference());
+ //
+ // convert resource -> entry capability -> entry XML
+ //
+ WsResource[] entries = getEntry();
+ Element[] entryXML = new Element[entries.length];
+
+ for (int n = 0; n < entries.length; ++n)
+ {
+ Entry entryCap = (Entry)entries[n].getCapability(WssgConstants.ENTRY_URI);
+ entryXML[n] = entryCap.toXML();
+ }
+
+ return entryXML;
}
- protected MembershipContentRule createMembershipContentRule(Element xml)
+ public MembershipContentRule[] getMembershipContentRule()
{
- return new SimpleMembershipContentRule(getResource().getEndpointReference(), xml);
+ return _contentRules;
}
- protected String getEntryContextPath()
+ public Element[] getProperty(QName property)
+ throws BaseFault
{
- return _entryPath;
+ //
+ // special case to convert entry resources into entry XML
+ //
+ if (property.equals(WssgConstants.ENTRY_QNAME))
+ return getEntryElements();
+
+ return super.getProperty(property);
+ }
+
+ public QName[] getPropertyNames()
+ {
+ return PROPERTIES;
}
public void initialize()
@@ -245,6 +278,9 @@
if (_entryPath == null)
throw new RuntimeException(_MESSAGES.get("NoEntryEndpoint"));
+ //
+ // set up persistence, if it's used
+ //
Persistence persistence = getPersistence();
if (persistence != null)
@@ -265,7 +301,7 @@
//
manager.addListener(this);
}
-
+
public boolean isMatch(EndpointReference epr)
{
MembershipContentRule[] rules = getMembershipContentRule();
@@ -276,17 +312,36 @@
return true;
}
-
+
public void removeEntry(WsResource entry)
{
if (entry == null)
throw new NullPointerException(_MESSAGES.get("NullEntry"));
- EndpointReference epr = entry.getEndpointReference();
+ //
+ // this is hack-ish - we have to loop through a hash table to find
+ // the right resource. don't have time to go back and refactor the
+ // way we store entries and make this more efficient - besides, it's
+ // more important the additions and lookups be fast
+ //
+ Iterator i = _entriesByMemberEPR.keySet().iterator();
+ EndpointReference memberEPR = null;
- if (_entriesByMemberEPR.remove(epr) == null)
+ while (i.hasNext() && memberEPR == null)
+ {
+ EndpointReference nextEPR = (EndpointReference)i.next();
+ WsResource nextEntry = (WsResource)_entriesByMemberEPR.get(memberEPR);
+
+ if (entry == nextEntry)
+ memberEPR = nextEPR;
+ }
+
+ if (_entriesByMemberEPR.remove(memberEPR) == null)
throw new RuntimeException(_MESSAGES.get("EntryNotFound"));
-
+
+ //
+ // if we're using persistence, remove the record of the entry
+ //
ServiceGroupPersistence persistence = (ServiceGroupPersistence)getPersistence();
try
@@ -339,6 +394,9 @@
WsResource entry = addEntry(epr, null, termination);
+ //
+ // if we're using persistence, create a record of the entry
+ //
ServiceGroupPersistence persistence = (ServiceGroupPersistence)getPersistence();
try
@@ -378,26 +436,18 @@
}
}
- protected Element[] getEntryElements()
+ public void shutdown()
+ throws SoapFault
{
+ //
+ // if we're being shutdown, we have to shutdown our entry
+ // resources or they'll be orphaned
+ //
WsResource[] entries = getEntry();
- Element[] entryXML = new Element[entries.length];
for (int n = 0; n < entries.length; ++n)
- {
- Entry entryCap = (Entry)entries[n].getCapability(WssgConstants.ENTRY_URI);
- entryXML[n] = entryCap.toXML();
- }
-
- return entryXML;
- }
-
- public Element[] getProperty(QName property)
- throws BaseFault
- {
- if (property.equals(WssgConstants.ENTRY_QNAME))
- return getEntryElements();
+ entries[n].shutdown();
- return super.getProperty(property);
+ super.shutdown();
}
}
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroupRegistration.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroupRegistration.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroupRegistration.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/impl/SimpleServiceGroupRegistration.java Mon Aug 28 20:19:18 2006
@@ -23,6 +23,8 @@
import org.apache.muse.core.routing.MessageHandler;
import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.resource.WsResource;
@@ -35,11 +37,40 @@
import org.apache.muse.ws.resource.sg.faults.ContentCreationFailedFault;
import org.apache.muse.ws.resource.sg.faults.UnsupportedMemberInterfaceFault;
-public class SimpleServiceGroupRegistration extends
- AbstractWsResourceCapability implements ServiceGroupRegistration
+/**
+ *
+ * SimpleServiceGroupRegistration is Muse's default implementation of the
+ * WS-RF ServiceGroupRegistration capability - it simply forwards all
+ * wsrf-sg:Add requests to the ServiceGroup.addEntry() method.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+public class SimpleServiceGroupRegistration
+ extends AbstractWsResourceCapability implements ServiceGroupRegistration
{
+ //
+ // Used to look up all exception messages
+ //
+ private static Messages _MESSAGES = MessagesFactory.get(SimpleServiceGroupRegistration.class);
+
+ //
+ // the WS-SG capability we're forwarding to
+ //
private ServiceGroup _sg = null;
+ public EndpointReference add(EndpointReference memberEPR,
+ Element content,
+ Date terminationTime)
+ throws AddRefusedFault,
+ ContentCreationFailedFault,
+ UnsupportedMemberInterfaceFault,
+ BaseFault
+ {
+ WsResource entry = getServiceGroup().addEntry(memberEPR, content, terminationTime);
+ return entry.getEndpointReference();
+ }
+
protected MessageHandler createAddHandler()
{
MessageHandler handler = new AddHandler();
@@ -62,21 +93,16 @@
_sg = (ServiceGroup)getWsResource().getCapability(WssgConstants.SERVICE_GROUP_URI);
- if (_sg == null) // FIXME: message
- throw new IllegalStateException("No WS-SG capability.");
+ //
+ // make sure the SG capability is used - otherwise we have no one
+ // to handle the add operation!
+ //
+ if (_sg == null)
+ {
+ Object[] filler = { getWsResource().getContextPath(), WssgConstants.SERVICE_GROUP_URI };
+ throw new IllegalStateException(_MESSAGES.get("NoServiceGroupCapability", filler));
+ }
setMessageHandler(createAddHandler());
- }
-
- public EndpointReference add(EndpointReference memberEPR,
- Element content,
- Date terminationTime)
- throws AddRefusedFault,
- ContentCreationFailedFault,
- UnsupportedMemberInterfaceFault,
- BaseFault
- {
- WsResource entry = getServiceGroup().addEntry(memberEPR, content, terminationTime);
- return entry.getEndpointReference();
}
}
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/remote/ServiceGroupClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/remote/ServiceGroupClient.java?rev=437927&r1=437926&r2=437927&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/remote/ServiceGroupClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/sg/remote/ServiceGroupClient.java Mon Aug 28 20:19:18 2006
@@ -34,6 +34,10 @@
/**
*
+ * ServiceGroupClient is a WSRF-based web services client that provides an
+ * implementation of the (optional) wsrf-sg:Add operation as well as a few
+ * convenience methods that make reading through service groups easier.
+ *
* @author Dan Jemiolo (danj)
*
*/
@@ -64,7 +68,12 @@
{
super(destination, source, soapClient);
}
-
+
+ /**
+ *
+ * Invokes the wsrf-sg:Add operation with an empty wsrf-sg:Content parameter.
+ *
+ */
public WsResourceClient add(EndpointReference memberEPR, Date termination)
throws SoapFault
{
@@ -74,32 +83,62 @@
return response.getEntryClient();
}
+ /**
+ *
+ * @return An array of clients pointing to the member EPRs that are
+ * currently in the service group. The array may be empty.
+ * The clients in the array can be used immediately in order
+ * to communicate with the resources in the service group.
+ *
+ */
public WsResourceClient[] getMembers()
throws SoapFault
{
Element[] entries = getResourceProperty(WssgConstants.ENTRY_QNAME);
- WsResourceClient[] proxies = new WsResourceClient[entries.length];
+ WsResourceClient[] clients = new WsResourceClient[entries.length];
EndpointReference src = getSource();
EndpointReference dest = null;
for (int n = 0; n < entries.length; ++n)
{
+ //
+ // convert ws-sg entry XML -> EPRs -> clients
+ //
Element eprXML = XmlUtils.getElement(entries[n], WssgConstants.MEMBER_SERVICE_EPR_QNAME);
dest = new EndpointReference(eprXML);
- proxies[n] = new WsResourceClient(dest, src);
+ clients[n] = new WsResourceClient(dest, src);
}
- return proxies;
+ return clients;
}
-
+
+ /**
+ *
+ * @param epr
+ * The EPR of a resource that may or may not fit the content rules
+ * of the service group.
+ *
+ * @return True if the resource at the given EPR meets the restrictions of
+ * this service group's membership content rules.
+ *
+ */
public boolean isMatch(EndpointReference epr)
throws SoapFault
{
+ //
+ // get content rules from service group
+ //
Element[] results = getResourceProperty(WssgConstants.CONTENT_RULE_QNAME);
+ //
+ // have to do this in a loop since we have to parse the MCRs
+ //
for (int n = 0; n < results.length; ++n)
{
+ //
+ // convert XML -> MCR and then use its isMatch() to do the work
+ //
MembershipContentRule mcr = new SimpleMembershipContentRule(getEndpointReference(), results[n]);
if (!mcr.isMatch(epr))
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org