ch.ethz.iks.slp
Class ServiceURL

java.lang.Object
  extended by ch.ethz.iks.slp.impl.AuthenticatedURL
      extended by ch.ethz.iks.slp.ServiceURL
All Implemented Interfaces:
java.io.Serializable

public final class ServiceURL
extends ch.ethz.iks.slp.impl.AuthenticatedURL
implements java.io.Serializable

Implementation of the SLP ServiceURL class defined in RFC 2614.

Since:
0.1
Author:
Jan S. Rellermeyer, Systems Group, ETH Zürich
See Also:
Serialized Form

Field Summary
static int LIFETIME_DEFAULT
           
static int LIFETIME_MAXIMUM
           
static int LIFETIME_NONE
           
static int LIFETIME_PERMANENT
           
static int NO_PORT
           
 
Fields inherited from class ch.ethz.iks.slp.impl.AuthenticatedURL
authBlocks
 
Constructor Summary
ServiceURL(java.lang.String serviceURL, int lifeTime)
          create a new ServiceURL instance from a String.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Check if two instances are equal.
static ServiceURL fromBytes(java.io.DataInputStream input)
          Reads a byte stream from a DataInput and constructs a ServiceURL from it, following the RFC 2608 schema: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | Lifetime | URL Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |URL len, contd.| URL (variable length) \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |# of URL auths | Auth. blocks (if any) \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ .
 java.lang.String getHost()
          get the host.
 int getLength()
           
 int getLifetime()
          get the lifetime.
 int getPort()
          get the port.
 java.lang.String getProtocol()
          get the protocol.
 ServiceType getServiceType()
          get the service type.
 java.lang.String getTransport()
          Deprecated.  
 java.lang.String getURLPath()
          get the URL path.
 int hashCode()
          get the hashCode of the ServiceURL instance.
 boolean matches(java.lang.Object obj)
          Check if a ServiceURL matches another ServiceURL or a ServiceType.
 java.lang.String toString()
          get a String representation of the ServiceURL.
 void writeTo(java.io.DataOutputStream out)
          get the byte representation of the ServiceURL instance.
 
Methods inherited from class ch.ethz.iks.slp.impl.AuthenticatedURL
getAuthBlockLength, parseAuthBlock, sign, verify, writeAuthBlock
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_PORT

public static final int NO_PORT
See Also:
Constant Field Values

LIFETIME_NONE

public static final int LIFETIME_NONE
See Also:
Constant Field Values

LIFETIME_DEFAULT

public static final int LIFETIME_DEFAULT
See Also:
Constant Field Values

LIFETIME_MAXIMUM

public static final int LIFETIME_MAXIMUM
See Also:
Constant Field Values

LIFETIME_PERMANENT

public static final int LIFETIME_PERMANENT
See Also:
Constant Field Values
Constructor Detail

ServiceURL

public ServiceURL(java.lang.String serviceURL,
                  int lifeTime)
           throws ServiceLocationException
create a new ServiceURL instance from a String.

Parameters:
serviceURL - the string representation of a ServiceURL like
                 service::"serviceType"://"addrspec"
 
where servicetype should be of the form abstractType:concreteType and addrspec is the hostname or dotted decimal notation of the host's address followed by an optional :portNumber. Example:
                     service:osgi:remote://my.host.ch:9200
 
lifeTime - the lifetime of the ServiceURL in seconds.
Throws:
ServiceLocationException - if the String is not parsable.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Check if two instances are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare to.
Returns:
true if the instances are equal.

matches

public boolean matches(java.lang.Object obj)
Check if a ServiceURL matches another ServiceURL or a ServiceType. In the first case, the method performs an equality check with equals(Object obj), for ServiceTypes, the ServiceType part of the ServiceURL is checked against the given ServiceType.

Parameters:
obj - a ServiceURL or ServiceType. All other objects will return false.
Returns:
true if the match succeeds.

toString

public java.lang.String toString()
get a String representation of the ServiceURL.

Overrides:
toString in class java.lang.Object
Returns:
the String representation.

hashCode

public int hashCode()
get the hashCode of the ServiceURL instance.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode.

getServiceType

public ServiceType getServiceType()
get the service type.

Returns:
the service type.

getTransport

public java.lang.String getTransport()
Deprecated. 

get the transport method.

Returns:
the transport method. IP returns empty string.

getProtocol

public java.lang.String getProtocol()
get the protocol.

Returns:
the protocol, if specified. Otherwise, returns null.

getHost

public java.lang.String getHost()
get the host.

Returns:
the host.

getPort

public int getPort()
get the port.

Returns:
the port.

getURLPath

public java.lang.String getURLPath()
get the URL path.

Returns:
the URL path.

getLifetime

public int getLifetime()
get the lifetime.

Returns:
the lifetime.

writeTo

public void writeTo(java.io.DataOutputStream out)
             throws java.io.IOException
get the byte representation of the ServiceURL instance.

Throws:
java.io.IOException
java.io.IOException - if an internal processing error occurs.

getLength

public int getLength()

fromBytes

public static ServiceURL fromBytes(java.io.DataInputStream input)
                            throws ServiceLocationException,
                                   java.io.IOException
Reads a byte stream from a DataInput and constructs a ServiceURL from it, following the RFC 2608 schema:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |   Reserved    |          Lifetime             |   URL Length  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |URL len, contd.|            URL (variable length)              \
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |# of URL auths |            Auth. blocks (if any)              \
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
.

Parameters:
input - the DataInput streaming the ServiceURL bytes.
Returns:
a ServiceURL instance.
Throws:
ServiceLocationException - in case of IO exceptions.
java.io.IOException


Copyright © 2008 Systems Group, ETH Zurich. All Rights Reserved.