org.springframework.osgi.mock
Class MockServiceReference

java.lang.Object
  extended by org.springframework.osgi.mock.MockServiceReference
All Implemented Interfaces:
ServiceReference

public class MockServiceReference
extends Object
implements ServiceReference

ServiceReference mock.

This mock tries to adhere to the OSGi spec as much as possible by providing the mandatory serviceId properties such as Constants.SERVICE_ID, Constants.OBJECTCLASS and Constants.SERVICE_RANKING.

Author:
Costin Leau

Constructor Summary
MockServiceReference()
          Constructs a new MockServiceReference instance using defaults.
MockServiceReference(Bundle bundle)
          Constructs a new MockServiceReference instance associated with the given bundle.
MockServiceReference(Bundle bundle, Dictionary properties, ServiceRegistration registration)
          Constructs a new MockServiceReference instance associated with the given bundle, service registration and having the given service properties.
MockServiceReference(Bundle bundle, Dictionary properties, ServiceRegistration registration, String[] classes)
          Constructs a new MockServiceReference instance.
MockServiceReference(Bundle bundle, String[] classes)
          Constructs a new MockServiceReference instance associated with the given bundle and matching the given class names.
MockServiceReference(ServiceRegistration registration)
          Constructs a new MockServiceReference instance associated with the given service registration.
MockServiceReference(String[] classes)
          Constructs a new MockServiceReference instance matching the given class namess.
 
Method Summary
 int compareTo(Object reference)
           
 boolean equals(Object obj)
          Two mock service references are equal if they contain the same service id.
 Bundle getBundle()
           
 Object getProperty(String key)
           
 String[] getPropertyKeys()
           
 Bundle[] getUsingBundles()
           
 int hashCode()
           Returns a hash code based on the class and service id.
 boolean isAssignableTo(Bundle bundle, String className)
           
 void setProperties(Dictionary properties)
          Sets the properties associated with this reference.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MockServiceReference

public MockServiceReference()
Constructs a new MockServiceReference instance using defaults.


MockServiceReference

public MockServiceReference(Bundle bundle)
Constructs a new MockServiceReference instance associated with the given bundle.

Parameters:
bundle - associated reference bundle

MockServiceReference

public MockServiceReference(String[] classes)
Constructs a new MockServiceReference instance matching the given class namess.

Parameters:
classes - associated class names

MockServiceReference

public MockServiceReference(Bundle bundle,
                            String[] classes)
Constructs a new MockServiceReference instance associated with the given bundle and matching the given class names.

Parameters:
bundle - associated bundle
classes - matching class names

MockServiceReference

public MockServiceReference(ServiceRegistration registration)
Constructs a new MockServiceReference instance associated with the given service registration.

Parameters:
registration - service registration

MockServiceReference

public MockServiceReference(Bundle bundle,
                            Dictionary properties,
                            ServiceRegistration registration)
Constructs a new MockServiceReference instance associated with the given bundle, service registration and having the given service properties.

Parameters:
bundle - associated bundle
properties - reference properties
registration - associated service registrations

MockServiceReference

public MockServiceReference(Bundle bundle,
                            Dictionary properties,
                            ServiceRegistration registration,
                            String[] classes)
Constructs a new MockServiceReference instance. This constructor gives access to all the parameters of the mock service reference such as associated bundle, reference properties, service registration and reference class names.

Parameters:
bundle - associated bundle
properties - reference properties
registration - service registration
classes - reference class names
Method Detail

getBundle

public Bundle getBundle()
Specified by:
getBundle in interface ServiceReference

getProperty

public Object getProperty(String key)
Specified by:
getProperty in interface ServiceReference

getPropertyKeys

public String[] getPropertyKeys()
Specified by:
getPropertyKeys in interface ServiceReference

getUsingBundles

public Bundle[] getUsingBundles()
Specified by:
getUsingBundles in interface ServiceReference

isAssignableTo

public boolean isAssignableTo(Bundle bundle,
                              String className)
Specified by:
isAssignableTo in interface ServiceReference

setProperties

public void setProperties(Dictionary properties)
Sets the properties associated with this reference.

Parameters:
properties -

equals

public boolean equals(Object obj)
Two mock service references are equal if they contain the same service id.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code based on the class and service id.

Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Object reference)


Copyright © 2006-2011 Spring Framework. All Rights Reserved.