com.sun.ws.management.client
Class ResourceFactory

java.lang.Object
  extended by com.sun.ws.management.client.ResourceFactory

public class ResourceFactory
extends java.lang.Object

Factory to create and configure Resource objects for use by a client. Provides additional support methods to obtain the ServerIdentity metadata.

Author:
spinder
See Also:
Resource, EnumerableResource, TransferableResource, ServerIdentity

Field Summary
static java.lang.String LATEST
           
 
Method Summary
static Resource create(java.lang.String destination, java.lang.String resourceURI, long timeoutInMilliseconds, org.w3c.dom.Document content, java.lang.String specVersion)
          Creates a new resource instance on the server.
static Resource create(java.lang.String destination, java.lang.String resourceURI, long timeoutInMilliseconds, org.w3c.dom.Document content, java.lang.String specVersion, java.util.HashSet<org.dmtf.schemas.wbem.wsman._1.wsman.OptionType> optionSet)
          Creates a new resource instance on the server.
static Resource create(java.lang.String destination, java.lang.String resourceURI, org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType existingResourceId, long timeoutInMilliseconds, java.lang.Object content, java.lang.String specVersion, java.util.HashSet<org.dmtf.schemas.wbem.wsman._1.wsman.OptionType> optionSet, java.lang.Object expression, java.util.Map<java.lang.String,java.lang.String> namespaces, java.lang.String dialect)
          Create a new resource on the server.
static Resource createFragment(java.lang.String destination, java.lang.String resourceURI, org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType existingResourceId, long timeoutInMilliseconds, org.w3c.dom.Document content, java.lang.String specVersion, java.lang.String fragmentExp, java.lang.String dialect)
          Create a fragment resource on the server.
static JAXBResource createJAXB(java.lang.String destination, java.lang.String resourceURI, long timeoutInMilliseconds, java.lang.Object content, java.lang.String specVersion, java.lang.String... packageNames)
          Creates a new resource instance on the server.
static JAXBResource createJAXB(java.lang.String destination, java.lang.String resourceURI, long timeoutInMilliseconds, java.lang.Object content, java.lang.String specVersion, com.sun.ws.management.xml.XmlBinding binding)
          Creates a new resource instance on the server.
static void delete(Resource res)
          Delete the specified resource on the server.
static Resource[] find(java.lang.String destination, java.lang.String resourceURI, long timeout, java.util.Map<java.lang.String,java.lang.String> selectors)
          Static method for locating existing exposed resource(s).
static Resource[] find(java.lang.String destination, java.lang.String resourceURI, long timeout, org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType selectors)
          Static method for locating existing exposed resource(s).
static com.sun.ws.management.xml.XmlBinding getBinding()
          Gets the XmlBinding that is used for marshaling and unmarshaling.
static ServerIdentity getIdentity(java.lang.String destination)
          Gets the server identity.
static ServerIdentity getIdentity(java.lang.String destination, int timeout)
          Gets the server identity.
static ServerIdentity getIdentity(java.lang.String destination, int timeout, java.util.Map.Entry<java.lang.String,java.lang.String>... headers)
          Gets the server identity.
static void setBinding(com.sun.ws.management.xml.XmlBinding binding)
          Sets the XmlBinding that will be used for marshalling and unmarshalling.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LATEST

public static final java.lang.String LATEST
See Also:
Constant Field Values
Method Detail

create

public static Resource create(java.lang.String destination,
                              java.lang.String resourceURI,
                              long timeoutInMilliseconds,
                              org.w3c.dom.Document content,
                              java.lang.String specVersion)
                       throws javax.xml.soap.SOAPException,
                              javax.xml.bind.JAXBException,
                              java.io.IOException,
                              FaultException,
                              javax.xml.datatype.DatatypeConfigurationException
Creates a new resource instance on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
timeoutInMilliseconds - Time to wait before giving up on creation
content - a w3c document representing the inital resource state
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
Returns:
A Resource class representing the new resource created on the server.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

create

public static Resource create(java.lang.String destination,
                              java.lang.String resourceURI,
                              long timeoutInMilliseconds,
                              org.w3c.dom.Document content,
                              java.lang.String specVersion,
                              java.util.HashSet<org.dmtf.schemas.wbem.wsman._1.wsman.OptionType> optionSet)
                       throws javax.xml.soap.SOAPException,
                              javax.xml.bind.JAXBException,
                              java.io.IOException,
                              FaultException,
                              javax.xml.datatype.DatatypeConfigurationException
Creates a new resource instance on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
timeoutInMilliseconds - Time to wait before giving up on creation
content - a w3c document representing the inital resource state
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
optionSet - set of user defined options to use during the create operation
Returns:
A Resource class representing the new resource created on the server.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

createFragment

public static Resource createFragment(java.lang.String destination,
                                      java.lang.String resourceURI,
                                      org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType existingResourceId,
                                      long timeoutInMilliseconds,
                                      org.w3c.dom.Document content,
                                      java.lang.String specVersion,
                                      java.lang.String fragmentExp,
                                      java.lang.String dialect)
                               throws javax.xml.soap.SOAPException,
                                      javax.xml.bind.JAXBException,
                                      java.io.IOException,
                                      FaultException,
                                      javax.xml.datatype.DatatypeConfigurationException
Create a fragment resource on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
existingResourceId - selector set identifying the resource
timeoutInMilliseconds - Time to wait before giving up on creation
content - a w3c Document representing the fragment to create
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
fragmentExp - the fragment expression
dialect - the fragment expression dialect
Returns:
TransferableResource referencing the resource created
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

create

public static Resource create(java.lang.String destination,
                              java.lang.String resourceURI,
                              org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType existingResourceId,
                              long timeoutInMilliseconds,
                              java.lang.Object content,
                              java.lang.String specVersion,
                              java.util.HashSet<org.dmtf.schemas.wbem.wsman._1.wsman.OptionType> optionSet,
                              java.lang.Object expression,
                              java.util.Map<java.lang.String,java.lang.String> namespaces,
                              java.lang.String dialect)
                       throws javax.xml.soap.SOAPException,
                              javax.xml.bind.JAXBException,
                              java.io.IOException,
                              FaultException,
                              javax.xml.datatype.DatatypeConfigurationException
Create a new resource on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
existingResourceId - selector set identifying the resource for fragment create
timeoutInMilliseconds - Time to wait before giving up on creation
content - an object to be marshalled into the body of the request. If expression is not null this is expected to be a Document or DocumentFragment containing the XmlFragment to create, otherwise it may be any object representing the resource that can be marshalled into the document.
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
optionSet - set of user defined options to use during the create operation
expression - a filter expression to be applied against the resource. For Resource.XPATH_DIALECT this should be a string containing the XPath expression. For other dialects this must be an object recognized by the marshaller.
namespaces - prefix and namespace map for namespaces used in the filter expression.
dialect - the dialect to be used in filter expressions. Resource.XPATH_DIALECT
Returns:
TransferableResource referencing the resource created
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

delete

public static void delete(Resource res)
                   throws javax.xml.soap.SOAPException,
                          javax.xml.bind.JAXBException,
                          java.io.IOException,
                          FaultException,
                          javax.xml.datatype.DatatypeConfigurationException
Delete the specified resource on the server.

Parameters:
res - resource to delete.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException
See Also:
TransferableResource.delete()

find

public static Resource[] find(java.lang.String destination,
                              java.lang.String resourceURI,
                              long timeout,
                              org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType selectors)
                       throws javax.xml.soap.SOAPException,
                              javax.xml.bind.JAXBException,
                              java.io.IOException,
                              FaultException,
                              javax.xml.datatype.DatatypeConfigurationException
Static method for locating existing exposed resource(s). This method returns a single Resource object in the first element of an array. It may be used as an EnumerableResource or TransferableResource, depending upon the desired operation.

Parameters:
destination - URL of the target service
resourceURI - URI identifying the resource
timeout - the OperationTimeout. This is the maximum amount of time the client is willing to wait for the operation to complete.
selectors - set of selectors used to identify a single or subset of resources at the target service.
Returns:
an array containing a single Resource object. It may be used as an EnumerableResource or TransferableResource, depending upon the desired operation.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

find

public static Resource[] find(java.lang.String destination,
                              java.lang.String resourceURI,
                              long timeout,
                              java.util.Map<java.lang.String,java.lang.String> selectors)
                       throws javax.xml.soap.SOAPException,
                              javax.xml.bind.JAXBException,
                              java.io.IOException,
                              FaultException,
                              javax.xml.datatype.DatatypeConfigurationException
Static method for locating existing exposed resource(s). This method returns a single Resource object in the first element of an array. It may be used as an EnumerableResource or TransferableResource, depending upon the desired operation.

Parameters:
destination - URL of the target service
resourceURI - URI identifying the resource
timeout - the OperationTimeout. This is the maximum amount of time the client is willing to wait for the operation to complete.
selectors - set of selectors used to identify a single or subset of resources at the target service.
Returns:
an array containing a single Resource object. It may be used as an EnumerableResource or TransferableResource, depending upon the desired operation.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

getIdentity

public static ServerIdentity getIdentity(java.lang.String destination)
                                  throws javax.xml.soap.SOAPException,
                                         java.io.IOException,
                                         javax.xml.bind.JAXBException
Gets the server identity.

Parameters:
destination - URL of the target service
Returns:
ServerIdentity
Throws:
javax.xml.soap.SOAPException
java.io.IOException
javax.xml.bind.JAXBException
See Also:
ServerIdentity

getIdentity

public static ServerIdentity getIdentity(java.lang.String destination,
                                         int timeout)
                                  throws javax.xml.soap.SOAPException,
                                         java.io.IOException,
                                         javax.xml.bind.JAXBException,
                                         java.lang.InterruptedException,
                                         java.util.concurrent.TimeoutException
Gets the server identity.

Parameters:
destination - URL of the target service
timeout - the OperationTimeout. This is the maximum amount of time the client is willing to wait for the operation to complete.
Returns:
ServerIdentity
Throws:
javax.xml.soap.SOAPException
java.io.IOException
javax.xml.bind.JAXBException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
See Also:
ServerIdentity

getIdentity

public static ServerIdentity getIdentity(java.lang.String destination,
                                         int timeout,
                                         java.util.Map.Entry<java.lang.String,java.lang.String>... headers)
                                  throws javax.xml.soap.SOAPException,
                                         java.io.IOException,
                                         javax.xml.bind.JAXBException,
                                         java.lang.InterruptedException,
                                         java.util.concurrent.TimeoutException
Gets the server identity.

Parameters:
destination - URL of the target service
timeout - the OperationTimeout. This is the maximum amount of time the client is willing to wait for the operation to complete.
headers - additional SOAP headers to set on the request
Returns:
ServerIdentity
Throws:
javax.xml.soap.SOAPException
java.io.IOException
javax.xml.bind.JAXBException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
See Also:
ServerIdentity

setBinding

public static void setBinding(com.sun.ws.management.xml.XmlBinding binding)
Sets the XmlBinding that will be used for marshalling and unmarshalling.

Parameters:
binding -

getBinding

public static com.sun.ws.management.xml.XmlBinding getBinding()
Gets the XmlBinding that is used for marshaling and unmarshaling.

Returns:
the XmlBinding.

createJAXB

public static JAXBResource createJAXB(java.lang.String destination,
                                      java.lang.String resourceURI,
                                      long timeoutInMilliseconds,
                                      java.lang.Object content,
                                      java.lang.String specVersion,
                                      com.sun.ws.management.xml.XmlBinding binding)
                               throws javax.xml.soap.SOAPException,
                                      javax.xml.bind.JAXBException,
                                      java.io.IOException,
                                      FaultException,
                                      javax.xml.datatype.DatatypeConfigurationException
Creates a new resource instance on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
timeoutInMilliseconds - Time to wait before giving up on creation
content - object to be marshaled into the SOAP document that represents the resource to be created.
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
binding - XmlBinding to use to marshal and unmarshal the SOAP documents sent over the wire.
Returns:
A Resource class representing the new resource created on the server.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException

createJAXB

public static JAXBResource createJAXB(java.lang.String destination,
                                      java.lang.String resourceURI,
                                      long timeoutInMilliseconds,
                                      java.lang.Object content,
                                      java.lang.String specVersion,
                                      java.lang.String... packageNames)
                               throws javax.xml.soap.SOAPException,
                                      javax.xml.bind.JAXBException,
                                      java.io.IOException,
                                      FaultException,
                                      javax.xml.datatype.DatatypeConfigurationException
Creates a new resource instance on the server.

Parameters:
destination - A URL for the destination port of this service.
resourceURI - A resource URI indicating the type of resource to create
timeoutInMilliseconds - Time to wait before giving up on creation
content - object to be marshaled into the SOAP document that represents the resource to be created.
specVersion - The wsman spec version of the client to create. You can use null or the constant #LATEST.
packageNames - names of packages to be used to construct an XmlBinding object that will be used to marshal the resource into the SOAP document. NOTE: For performance reasons it is highly recommended to use createJAXB(String, String, long, Object, String, XmlBinding) instead of this method and reuse the XmlBinding object.
Returns:
A Resource class representing the new resource created on the server.
Throws:
javax.xml.soap.SOAPException
javax.xml.bind.JAXBException
java.io.IOException
FaultException
javax.xml.datatype.DatatypeConfigurationException