org.ws4d.java.service
Class ServiceCommons

java.lang.Object
  extended by org.ws4d.java.service.ServiceCommons
All Implemented Interfaces:
Service
Direct Known Subclasses:
DefaultService, ProxyService

public abstract class ServiceCommons
extends java.lang.Object
implements Service

Class represents the common part of a proxy/local DPWS device.


Nested Class Summary
static class ServiceCommons.OperationSignature
           
static class ServiceCommons.PortType
           
 
Method Summary
 EventSource getAnyEventSource(QName portType, java.lang.String eventName)
          Returns the first (or last, or ANY other) event source with the specified portType and eventName.
 Operation getAnyOperation(QName portType, java.lang.String operationName)
          Returns the first (or last, or ANY other) operation with the specified portType and operationName.
 java.lang.Object getCertificate()
          This certificate is used to validate signatures.
 Iterator getDescriptions()
          Returns an iterator over all WSDLs directly attached to this service.
 EventSource getEventSource(QName portType, java.lang.String eventName, java.lang.String inputName, java.lang.String outputName)
          Gets event source of specified portType with given eventName.
 EventSource getEventSource(java.lang.String outputAction)
          Gets event source with specified unique outputAction.
 Iterator getEventSources()
          Gets all events sources.
 Iterator getEventSources(QName portType)
          Gets all event sources of the specified service port type.
 Operation getOperation(QName portType, java.lang.String opName, java.lang.String inputName, java.lang.String outputName)
          Gets an operation of specified portType with given opName.
 Operation getOperation(java.lang.String inputAction)
          Gets operation with specified unique inputAction.
 Iterator getOperations()
          Gets all operations.
 Iterator getOperations(QName portType)
          Gets all operations of the specified service port type.
 CustomAttributeValue getPortTypeAttribute(QName portTypeName, QName attributeName)
          Returns the value of the port type attribute with the given name for the port type with the specified unique portTypeName or with null if this attribute is not available (or if its value is explicitly set to null).
 HashMap getPortTypeAttributes(QName portTypeName)
          Returns all port type attributes explicitly set on this service instance for the port type with the given unique portTypeName.
 java.lang.Object getPrivateKey()
           
 boolean hasPortTypeAttributes(QName portTypeName)
          Returns true only if this service instance has at least one port type attribute set for the port type with the specified unique portTypeName.
 boolean isSecure()
          Sends using WS-Security techniques.
 void setCertificate(java.lang.Object certificate)
          Sets the certificate of this service.
 void setPortTypeAttribute(QName portTypeName, QName attributeName, CustomAttributeValue value)
          Sets the value of the port type attribute with the specified name of the port type with the given unique portTypeName.
 void setPortTypeAttributes(QName portTypeName, HashMap attributes)
          Sets all port type attributes of the port type with unique portTypeName at once to those contained within argument attributes.
 void setPrivateKey(java.lang.Object privKey)
           
 void setSecure(boolean sec)
           
 void setSecureService()
          Sets the service to use security techniques.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ws4d.java.service.Service
getDescription, getEprInfos, getParentDeviceReference, getPortTypes, getServiceId, getServiceReference, getStatus, isRemote, renew, subscribe, unsubscribe
 

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOperations

public Iterator getOperations()
Description copied from interface: Service
Gets all operations.

Specified by:
getOperations in interface Service
Returns:
all operations

getOperations

public Iterator getOperations(QName portType)
Description copied from interface: Service
Gets all operations of the specified service port type.

Specified by:
getOperations in interface Service
Parameters:
portType - specific port type
Returns:
the operations belonging to the specified port type

getOperation

public Operation getOperation(QName portType,
                              java.lang.String opName,
                              java.lang.String inputName,
                              java.lang.String outputName)
Description copied from interface: Service
Gets an operation of specified portType with given opName. The inputName and/or outputName may be null only if the requested operation doesn't have any input/output. Otherwise, this method won't get any results.

When an operation is added to a service, and it doesn't provide an explicit name for either its input or output elements (see OperationCommons.setInputName(String) and OperationCommons.setOutputName(String)), a default name is generated according to the WSDL 1.1 Specification. As long as there are other operations with the same input/output name which have already been added to this service, an incremental index is appended to the default generated name.

If you are certain that the operation of the specified portType and with the given opName is NOT overloaded (i.e. there is no other operation within the same port type with the same operation name), then you can use method Service.getAnyOperation(QName, String) instead of this one.

Specified by:
getOperation in interface Service
Parameters:
portType - specific port type of operation
opName - name of operation
inputName - the name of the input element which belongs to this operation according to its WSDL; must be null, if operation has no input
outputName - the name of the output element which belongs to this operation according to its WSDL; must be null, if operation has no output
Returns:
requested operation or null, if not found
See Also:
Service.getAnyOperation(QName, String)

getOperation

public Operation getOperation(java.lang.String inputAction)
Description copied from interface: Service
Gets operation with specified unique inputAction.

Specified by:
getOperation in interface Service
Parameters:
inputAction - the WS-Addressing action URI of the requested operation according to its WSDL
Returns:
requested operation or null, if not found

getAnyOperation

public Operation getAnyOperation(QName portType,
                                 java.lang.String operationName)
Description copied from interface: Service
Returns the first (or last, or ANY other) operation with the specified portType and operationName. Note that there might be more than one operation with the same name and port type in the case of overloading. In such situations, it is the user's responsibility to determine which of the overloaded versions was returned by this method. This method returns null, if there are no operations matching the portType and operationName arguments.

This method is useful in case it is known that there is only one operation with a given name within a port type.

Specified by:
getAnyOperation in interface Service
Parameters:
portType - the port type to which the desired operation
operationName - the name of the operation
Returns:
any (maybe randomly determined) operation with the given port type and name
See Also:
Service.getOperation(QName, String, String, String)

getEventSources

public Iterator getEventSources()
Description copied from interface: Service
Gets all events sources.

Specified by:
getEventSources in interface Service
Returns:
all event sources

getEventSources

public Iterator getEventSources(QName portType)
Description copied from interface: Service
Gets all event sources of the specified service port type.

Specified by:
getEventSources in interface Service
Parameters:
portType - specific port type
Returns:
all event sources belonging to the specified service port type

getEventSource

public EventSource getEventSource(QName portType,
                                  java.lang.String eventName,
                                  java.lang.String inputName,
                                  java.lang.String outputName)
Description copied from interface: Service
Gets event source of specified portType with given eventName. The inputName and/or outputName may be null only if the requested event source doesn't have any input/output. Otherwise, this method won't find any results. *

When an event source is added to a service, and it doesn't provide an explicit name for either its input or output elements (see OperationCommons.setInputName(String) and OperationCommons.setOutputName(String)), a default name is therefore generated according to the WSDL 1.1 Specification. If there are other event sources with the same input/output name already added to this service, an incremental index is appended to the default generated name.

If you are certain that the event source of the specified portType and with the given eventName is NOT overloaded (i.e. there is no other event source within the same port type with the same event name), then you can use method Service.getAnyEventSource(QName, String) instead of this one.

Specified by:
getEventSource in interface Service
Parameters:
portType - specific port type of operation
eventName - name of event source
inputName - the name of the input element that belongs to this event source according to its WSDL; must be null, if event source has no input
outputName - the name of the output element that belongs to this event source according to its WSDL; must be null, if event source has no output
Returns:
requested event source or null, if not found
See Also:
Service.getAnyEventSource(QName, String)

getEventSource

public EventSource getEventSource(java.lang.String outputAction)
Description copied from interface: Service
Gets event source with specified unique outputAction.

Specified by:
getEventSource in interface Service
Parameters:
outputAction - the WS-Addressing action URI of the requested event source according to its WSDL
Returns:
requested event or null if not found

getAnyEventSource

public EventSource getAnyEventSource(QName portType,
                                     java.lang.String eventName)
Description copied from interface: Service
Returns the first (or last, or ANY other) event source with the specified portType and eventName. Note that there might be more than one event source with the same name and port type in the case of overloading. In such situations, it is the user's responsibility to determine which of the overloaded versions was returned by this method. This method returns null, if there are no event source matching the portType and eventName arguments.

This method is useful in case it is known that there is only one event source with a given name within a port type.

Specified by:
getAnyEventSource in interface Service
Parameters:
portType - the port type the desired event source belongs to
eventName - the name of the event source
Returns:
any (maybe randomly determined) event source with the given port type and name
See Also:
Service.getEventSource(QName, String, String, String)

getPortTypeAttribute

public CustomAttributeValue getPortTypeAttribute(QName portTypeName,
                                                 QName attributeName)
Description copied from interface: Service
Returns the value of the port type attribute with the given name for the port type with the specified unique portTypeName or with null if this attribute is not available (or if its value is explicitly set to null).

This method throws a java.lang.IllegalArgumentException if a port type with the given portTypeName is not found within this service instance.

Specified by:
getPortTypeAttribute in interface Service
Parameters:
portTypeName - the unique name of the port type within the scope of this service instance, see Service.getPortTypes()
attributeName - the name of the port type attribute to query the value of
Returns:
the value for the named port type attribute or null

setPortTypeAttribute

public void setPortTypeAttribute(QName portTypeName,
                                 QName attributeName,
                                 CustomAttributeValue value)
Sets the value of the port type attribute with the specified name of the port type with the given unique portTypeName. Throws a java.lang.IllegalArgumentException in case there is no port type with the given portTypeName within this service instance or if name is null.

Parameters:
portTypeName - the unique name of the port type within the scope of this service instance, see Service.getPortTypes()
attributeName - the name of the port type attribute to set, must not be null
value - the value to set the named port type attribute to (may be null
Throws:
java.lang.IllegalArgumentException - if there is no port type with the given portTypeName within this service instance or if name is null

getPortTypeAttributes

public HashMap getPortTypeAttributes(QName portTypeName)
Description copied from interface: Service
Returns all port type attributes explicitly set on this service instance for the port type with the given unique portTypeName. Note that depending on the actual implementation the returned reference may point at the 'life map', i .e. the actual storage for the port type attributes. Thus, modifications to that map should be performed with care and keeping this in mind.

This method throws a java.lang.IllegalArgumentException if a port type with the given portTypeName is not found within this instance.

Specified by:
getPortTypeAttributes in interface Service
Parameters:
portTypeName - the unique name of the port type within the scope of this instance, see Service.getPortTypes()
Returns:
all already set port type attributes

setPortTypeAttributes

public void setPortTypeAttributes(QName portTypeName,
                                  HashMap attributes)
Sets all port type attributes of the port type with unique portTypeName at once to those contained within argument attributes. Note that depending on the actual implementation, it is possible that the map attributes points at may be used for the actual internal storage of the port type attributes (i.e. without copying it). That is why, after passing it to this method, modifications to this map should be made with care. This method throws a java.lang.IllegalArgumentException in case attributes is null.

Parameters:
portTypeName - the unique name of the port type within the scope of this service instance, see Service.getPortTypes()
attributes - the new port type attributes to set
Throws:
java.lang.IllegalArgumentException - if no port type with the given portTypeName is found or if attributes is null

hasPortTypeAttributes

public boolean hasPortTypeAttributes(QName portTypeName)
Description copied from interface: Service
Returns true only if this service instance has at least one port type attribute set for the port type with the specified unique portTypeName. Returns false in any other case, including when there is no port type with the given portTypeName.

Specified by:
hasPortTypeAttributes in interface Service
Parameters:
portTypeName - the unique name of the port type within the scope of this service instance, see Service.getPortTypes()
Returns:
true only if there is at least one port type attribute set for the named port type within this service instance

setSecureService

public void setSecureService()
                      throws java.lang.Exception
Sets the service to use security techniques. Use this method after setting the services HTTPSBinding

Throws:
java.lang.Exception

isSecure

public boolean isSecure()
Sends using WS-Security techniques.

Specified by:
isSecure in interface Service
Returns:

setSecure

public void setSecure(boolean sec)
Specified by:
setSecure in interface Service

setCertificate

public void setCertificate(java.lang.Object certificate)
Description copied from interface: Service
Sets the certificate of this service. Used only in the security package.

Specified by:
setCertificate in interface Service
Parameters:
certificate - must be the java.security.cert.Certificate of the sender device/service

getCertificate

public java.lang.Object getCertificate()
Description copied from interface: Service
This certificate is used to validate signatures. Used in the security package.

Specified by:
getCertificate in interface Service
Returns:
the java.security.cert.Certificate;

getPrivateKey

public java.lang.Object getPrivateKey()

setPrivateKey

public void setPrivateKey(java.lang.Object privKey)
Parameters:
privKey - must be the java.security.PrivateKey of the sender device/ service

getDescriptions

public Iterator getDescriptions()
Description copied from interface: Service
Returns an iterator over all WSDLs directly attached to this service.

Specified by:
getDescriptions in interface Service
Returns:
an iterator over all WSDLs directly attached to this service