org.ws4d.java.dispatch
Class DefaultServiceReference

java.lang.Object
  extended by org.ws4d.java.dispatch.DefaultServiceReference
All Implemented Interfaces:
ServiceReferenceInternal, Reference, ServiceReference

public class DefaultServiceReference
extends java.lang.Object
implements ServiceReferenceInternal

Class holds service reference.


Field Summary
 
Fields inherited from interface org.ws4d.java.service.reference.Reference
LOCATION_LOCAL, LOCATION_REMOTE, LOCATION_UNKNOWN
 
Method Summary
 void buildUpService()
          Instructs this service reference to asynchronously send a GetMetadata message to the service and create a new proxy, if required.
 boolean containsAllPortTypes(QNameSet newTypes)
          Returns true only in case this service reference provides all port types listed within argumentportTypes.
 void disconnectFromDevice()
          Removes the parent device reference from this service reference.
 Iterator getEprInfos()
          Gets endpoint references.
 int getLocation()
          Returns the location of the device or service, which may be - LOCATION_UNKNOWN, - LOCATION_REMOTE, - LOCATION_LOCAL.
 Iterator getMetadataLocations()
          Returns an iterator over the set of URI instances pointing at the addresses of the target service's metadata description locations (i.e.
 Iterator getMetadataReferences()
          Returns an iterator over the set of EndpointReference instances pointing at the locations of the target service's metadata descriptions (i.e. usually its WSDL files).
 XAddressInfo getNextXAddressInfoAfterFailure(URI transportAddress)
           
 DeviceReference getParentDeviceRef()
          Returns the parent device reference of the device which hosts the service, if the device is known.
 int getPortTypeCount()
          Returns the number of port types for this service reference.
 Iterator getPortTypes()
          Gets service port types.
 java.lang.String getPreferredCommunicationManagerID()
          Returns the ID of the communication protocol to use when communicating with this reference's target over the current preferred transport address.
 URI getPreferredXAddress()
          Returns the preferred transport address for communication with this reference.
 XAddressInfo getPreferredXAddressInfo()
           
 Service getService()
          Gets present service of reference.
 Service getService(boolean doBuildUp)
          Gets present service of reference.
 URI getServiceId()
          Returns the service ID (unique within the scope of its parent device).
 Iterator getWSDLs()
          Returns an iterator over the set of WSDL instances describing the target service.
 boolean isSecureService()
          Returns whether or not the service is secured
 boolean isServiceObjectExisting()
          Returns whether the service is build up or not.
 Service rebuildService()
           
 void reset()
          Resets this service reference, i.e. makes it loose all internal state information but the endpoint references of the service.
 void setHostedFromService(HostedMData newHosted, java.lang.String comManId, ProtocolData protocolData)
           
 void setLocation(int location)
          Location of service, which this reference is linked to.
 void setMetaDataLocations(URISet metaLocs)
           
 void setMetadataReferences(EndpointReferenceSet metaRefs)
          Updates metadata references.
 void setParentDeviceReference(DeviceReference devRef)
           
 Service setService(LocalService service, HostedMData hosted)
          Sets local service, replaces present service.
 void setWSDLs(DataStructure wsdls)
          Updates WSDLs linked to this service
 java.lang.String toString()
           
 void update(HostedMData newHostedBlock, DeviceReference devRef, ProtocolData protocolData)
          Update service references with hosted metadata.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

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

getService

public Service getService()
                   throws TimeoutException
Description copied from interface: ServiceReference
Gets present service of reference. If the service is remote and its proxy not built up, the proxy may be built by an existing WSDL within the WSDLRepository or by sending a get metadata message.

Specified by:
getService in interface ServiceReference
Returns:
service The present service of this reference. The returned service may change.
Throws:
TimeoutException - This exception is thrown if the remote service doesn't answer to the get metadata message, which tries to receive the necessary data to build up the service. The timeout value can be configured in the DispatchingProperties via the method DispatchingProperties.setResponseWaitTime(int).

getService

public Service getService(boolean doBuildUp)
                   throws TimeoutException
Description copied from interface: ServiceReferenceInternal
Gets present service of reference. If the service is remote and its proxy not built up, the proxy may be built by an existing WSDL within the WSDLRepository or by sending a get metadata message.

Specified by:
getService in interface ServiceReferenceInternal
Parameters:
doBuildUp - If false and service does not exist, service will not be build up. In this case, returned service is null
Returns:
service The present service of this reference. The returned service may change.
Throws:
TimeoutException - This exception is thrown if the remote service doesn't answer to the get metadata message, which tries to receive the necessary data to build up the service. The timeout value can be configured in the DispatchingProperties via the method DispatchingProperties.setResponseWaitTime(int).

buildUpService

public void buildUpService()
Instructs this service reference to asynchronously send a GetMetadata message to the service and create a new proxy, if required. The new proxy service is than announced asynchronously via ServiceListener.serviceCreated(ServiceReference, Service) method.

Note that in order to reduce network traffic a GetMetadata message will actually be sent only if it is detected that the service within this device reference instance is not up to date anymore.


setService

public Service setService(LocalService service,
                          HostedMData hosted)
Description copied from interface: ServiceReferenceInternal
Sets local service, replaces present service. Used to set local services.

Specified by:
setService in interface ServiceReferenceInternal
Parameters:
service - replacement service.
hosted - the hosted block of the service
Returns:
replaced service.

rebuildService

public Service rebuildService()
                       throws TimeoutException
Throws:
TimeoutException

reset

public void reset()
Description copied from interface: ServiceReference
Resets this service reference, i.e. makes it loose all internal state information but the endpoint references of the service.

Specified by:
reset in interface ServiceReference

update

public void update(HostedMData newHostedBlock,
                   DeviceReference devRef,
                   ProtocolData protocolData)
Update service references with hosted metadata. If new metadata lacks of previous transmitted port types, the associated service is removed. If new metadata includes new port types, service is updated.

Specified by:
update in interface ServiceReferenceInternal
Parameters:
endpoint - Endpoint references to set.

disconnectFromDevice

public void disconnectFromDevice()
Description copied from interface: ServiceReferenceInternal
Removes the parent device reference from this service reference.

Specified by:
disconnectFromDevice in interface ServiceReferenceInternal

getPortTypes

public Iterator getPortTypes()
Description copied from interface: ServiceReference
Gets service port types. The port types defines the operations the service provides.

Specified by:
getPortTypes in interface ServiceReference
Returns:
service port types.

getPortTypeCount

public int getPortTypeCount()
Description copied from interface: ServiceReference
Returns the number of port types for this service reference.

Specified by:
getPortTypeCount in interface ServiceReference
Returns:
the number of port types

containsAllPortTypes

public boolean containsAllPortTypes(QNameSet newTypes)
Description copied from interface: ServiceReference
Returns true only in case this service reference provides all port types listed within argumentportTypes.

Specified by:
containsAllPortTypes in interface ServiceReference
Parameters:
newTypes - the port types to check this service reference for
Returns:
true if all port types are provided by this service reference, false otherwise

getLocation

public int getLocation()
Description copied from interface: Reference
Returns the location of the device or service, which may be - LOCATION_UNKNOWN, - LOCATION_REMOTE, - LOCATION_LOCAL.

Specified by:
getLocation in interface Reference
Returns:
the location of the device or service

setLocation

public void setLocation(int location)
Location of service, which this reference is linked to. Allowed values:
  • Reference.LOCATION_LOCAL,
  • Reference.LOCATION_REMOTE or
  • Reference.LOCATION_UNKNOWN

    Specified by:
    setLocation in interface ServiceReferenceInternal
    Parameters:
    location - Reference.LOCATION_LOCAL, Reference.LOCATION_REMOTE or Reference.LOCATION_UNKNOWN.

  • getEprInfos

    public Iterator getEprInfos()
    Description copied from interface: ServiceReference
    Gets endpoint references. In DPWS the address contained in an endpoint reference is a transport address.

    Specified by:
    getEprInfos in interface ServiceReference
    Returns:
    endpoint references.

    getServiceId

    public URI getServiceId()
    Description copied from interface: ServiceReference
    Returns the service ID (unique within the scope of its parent device).

    Specified by:
    getServiceId in interface ServiceReference
    Returns:
    the service ID

    getMetadataReferences

    public Iterator getMetadataReferences()
    Returns an iterator over the set of EndpointReference instances pointing at the locations of the target service's metadata descriptions (i.e. usually its WSDL files).

    Specified by:
    getMetadataReferences in interface ServiceReference
    Returns:
    an iterator over EndpointReferences to the service's metadata

    getMetadataLocations

    public Iterator getMetadataLocations()
    Returns an iterator over the set of URI instances pointing at the addresses of the target service's metadata description locations (i.e. usually its WSDL files).

    Specified by:
    getMetadataLocations in interface ServiceReference
    Returns:
    an iterator over URIs to the service's metadata

    getWSDLs

    public Iterator getWSDLs()
    Returns an iterator over the set of WSDL instances describing the target service.

    Specified by:
    getWSDLs in interface ServiceReference
    Returns:
    an iterator over WSDLs containing the service's metadata

    getPreferredXAddress

    public URI getPreferredXAddress()
                             throws TimeoutException
    Description copied from interface: Reference
    Returns the preferred transport address for communication with this reference.

    Specified by:
    getPreferredXAddress in interface Reference
    Returns:
    the preferred transport address for this reference
    Throws:
    TimeoutException - if no suitable transport address can be detected

    getPreferredCommunicationManagerID

    public java.lang.String getPreferredCommunicationManagerID()
                                                        throws TimeoutException
    Description copied from interface: Reference
    Returns the ID of the communication protocol to use when communicating with this reference's target over the current preferred transport address. Will return the framework-wide default communication ID, if no preferred transport address has been explicitly set.

    Specified by:
    getPreferredCommunicationManagerID in interface Reference
    Returns:
    the ID of the protocol to communicate over with the target of this reference
    Throws:
    TimeoutException - if no suitable transport address can be detected

    getPreferredXAddressInfo

    public XAddressInfo getPreferredXAddressInfo()
                                          throws TimeoutException
    Specified by:
    getPreferredXAddressInfo in interface ServiceReferenceInternal
    Throws:
    TimeoutException

    getNextXAddressInfoAfterFailure

    public XAddressInfo getNextXAddressInfoAfterFailure(URI transportAddress)
                                                 throws TimeoutException
    Specified by:
    getNextXAddressInfoAfterFailure in interface ServiceReferenceInternal
    Throws:
    TimeoutException

    setParentDeviceReference

    public void setParentDeviceReference(DeviceReference devRef)
    Specified by:
    setParentDeviceReference in interface ServiceReferenceInternal
    Parameters:
    devRef -

    getParentDeviceRef

    public DeviceReference getParentDeviceRef()
    Description copied from interface: ServiceReference
    Returns the parent device reference of the device which hosts the service, if the device is known.

    Specified by:
    getParentDeviceRef in interface ServiceReference
    Returns:
    The device reference of the device which hosts the service.

    isServiceObjectExisting

    public boolean isServiceObjectExisting()
    Description copied from interface: ServiceReference
    Returns whether the service is build up or not.

    Specified by:
    isServiceObjectExisting in interface ServiceReference
    Returns:
    true, if service object exists.

    isSecureService

    public boolean isSecureService()
    Description copied from interface: ServiceReference
    Returns whether or not the service is secured

    Specified by:
    isSecureService in interface ServiceReference
    Returns:

    setHostedFromService

    public void setHostedFromService(HostedMData newHosted,
                                     java.lang.String comManId,
                                     ProtocolData protocolData)

    setMetaDataLocations

    public void setMetaDataLocations(URISet metaLocs)
    Specified by:
    setMetaDataLocations in interface ServiceReferenceInternal

    setMetadataReferences

    public void setMetadataReferences(EndpointReferenceSet metaRefs)
    Description copied from interface: ServiceReferenceInternal
    Updates metadata references.

    Specified by:
    setMetadataReferences in interface ServiceReferenceInternal

    setWSDLs

    public void setWSDLs(DataStructure wsdls)
    Description copied from interface: ServiceReferenceInternal
    Updates WSDLs linked to this service

    Specified by:
    setWSDLs in interface ServiceReferenceInternal