com.cafesoft.core.service
Class StandardServiceReference

java.lang.Object
  |
  +--com.cafesoft.core.service.StandardServiceReference
All Implemented Interfaces:
ServiceReference

public class StandardServiceReference
extends Object
implements ServiceReference

StandardServiceReference contains parameters that uniquely identify a Service type or an instance within some scope. This is useful for:


Field Summary
protected  String id
          The identifier of the referenced Service
protected  Class type
          The Class indicating the Service type
 
Constructor Summary
StandardServiceReference(String id, Class type)
          Create a new StandardServiceReference.
 
Method Summary
 String getId()
          Get the identifier of the referenced Service.
 Class getType()
          Get the type of the referenced Service.
 int hashCode()
          Get the ServiceReference hashcode.
 boolean matches(Service service)
          Check to see if a Service matches this ServiceReference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected String id
The identifier of the referenced Service


type

protected Class type
The Class indicating the Service type

Constructor Detail

StandardServiceReference

public StandardServiceReference(String id,
                                Class type)
Create a new StandardServiceReference.

Parameters:
id - the service identifier (or null to reference a Service by only it's type).
type - the Class corresponding the the Service type.
Method Detail

getId

public String getId()
Get the identifier of the referenced Service.

Specified by:
getId in interface ServiceReference
Returns:
the identifier of the referenced Service or null if the reference is not for a specific instance.

getType

public Class getType()
Get the type of the referenced Service.

Specified by:
getType in interface ServiceReference
Returns:
the Class that specifies the type of the referenced Service.

matches

public boolean matches(Service service)
Check to see if a Service matches this ServiceReference.

Specified by:
matches in interface ServiceReference
Parameters:
service - the Service instance.
Returns:
true if the Service is not null and:
  1. this ServiceReference DOES NOT specify a Service id and the Service implements the type within this ServiceReference.
  2. this ServiceReference DOES specify a Service id and the Service implements the type in this ServiceReference AND has the same identifier as the one within this ServiceReference.

hashCode

public int hashCode()
Get the ServiceReference hashcode.

Overrides:
hashCode in class Object
Returns:
a hashcode that uniquely identifies a ServiceReference, which is unique by type and/or id.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.