no.ubicollab.osgi
Class DomainManagerImpl

java.lang.Object
  extended by no.ubicollab.osgi.DomainManagerImpl
All Implemented Interfaces:
DomainManager

public class DomainManagerImpl
extends java.lang.Object
implements DomainManager

The Class DomainManagerImpl implements the DomainManager interface and provides the neccessary functionality for service management on UbiNodes. The public members of this class will be accessible through a SOAP/Web- Service interface.

Since:
0.1
Version:
0.6
Author:
Kim-Steve Johansen

Constructor Summary
DomainManagerImpl(org.osgi.framework.BundleContext bc)
          This Constructor creates a new instance of DomainManagerImpl, and reads the service list from file.
 
Method Summary
 boolean checkIfServiceExist(java.lang.String uri)
          Check if a given service exist.
 java.lang.String getInfoAboutService(java.lang.Long bundleID)
          Gets all registered information about the specified service.
 java.lang.String getLogItems(int logLevel, int numItems)
          Read from the log and return selected log items in a XML-formatted string.
 java.lang.String getServiceList()
          Searches for services installed on this UbiNode and returns handles to theese.
 java.lang.String installService(java.lang.String url, java.lang.String friendlyName)
          Installs a service.
 boolean removeService(java.lang.Long bundleID)
          Removes the service provided by the bunde matching the provided bundleId.
 boolean setActiveSpace(int SpaceID, boolean stopOtherServices)
          Activates all services belonging to the space identified by the provided id.
 boolean startService(java.lang.Long bundleID)
          Method to start a service installed on the UbiNode.
 boolean stopService(java.lang.Long bundleID)
          Method to stop a service installed on the UbiNode
 boolean updateServiceProperties(long bundleID, java.lang.String friendlyName, java.lang.String space, int spaceID, java.lang.String type, java.lang.String description)
          Method to update the properties of the service identified by serviceUri.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainManagerImpl

public DomainManagerImpl(org.osgi.framework.BundleContext bc)
This Constructor creates a new instance of DomainManagerImpl, and reads the service list from file.

Parameters:
bc - the BundleContext in which this bundle runs.
Method Detail

removeService

public boolean removeService(java.lang.Long bundleID)
Removes the service provided by the bunde matching the provided bundleId.

Specified by:
removeService in interface DomainManager
Parameters:
bundleID - the bundle ID of the service to remove
Returns:
true, if service is removed, false othervise
See Also:
DomainManager.removeService(java.lang.Long)

getServiceList

public java.lang.String getServiceList()
Searches for services installed on this UbiNode and returns handles to theese.

The xml-structure used to represent the returned service is described in DomainManager#getServiceList.

Specified by:
getServiceList in interface DomainManager
Returns:
The method returns a list of installed services
See Also:
DomainManager.getServiceList()

installService

public java.lang.String installService(java.lang.String url,
                                       java.lang.String friendlyName)
Installs a service. Use this method if you have the URL to a service bundle

Specified by:
installService in interface DomainManager
Parameters:
friendlyName - the friendly name of the service
url - The Url to the service bundle.
Returns:
True if the service is successfully installed, false otherwise.

updateServiceProperties

public boolean updateServiceProperties(long bundleID,
                                       java.lang.String friendlyName,
                                       java.lang.String space,
                                       int spaceID,
                                       java.lang.String type,
                                       java.lang.String description)
Method to update the properties of the service identified by serviceUri.

Specified by:
updateServiceProperties in interface DomainManager
Parameters:
spaceID - the space ID for the space the service is placed in
friendlyName - The service friendly name
type - the type of service
description - the service description
space - The space this service will be active in
bundleID - The ID for the bundle which hosts the requested service
Returns:
True if URI is found and update is OK, false otherwise.
See Also:
DomainManager.updateServiceProperties(long, String, String, int, String, String)

startService

public boolean startService(java.lang.Long bundleID)
Method to start a service installed on the UbiNode.

Specified by:
startService in interface DomainManager
Parameters:
bundleID - the bundle ID
Returns:
True if the service is sucessfully started

stopService

public boolean stopService(java.lang.Long bundleID)
Method to stop a service installed on the UbiNode

Specified by:
stopService in interface DomainManager
Parameters:
bundleID - the bundle ID
Returns:
True if the service is sucessfully started

getLogItems

public java.lang.String getLogItems(int logLevel,
                                    int numItems)
Read from the log and return selected log items in a XML-formatted string.

The xml-structure used to represent the returned service is described in DomainManager#getLogItems.

Specified by:
getLogItems in interface DomainManager
Parameters:
logLevel - The log level to include in the report.
numItems - The number of log items to include in the report
Returns:
the string containg the resulting XML
See Also:
DomainManager.getLogItems(int, int), DomainManager.getLogItems(int, int)

getInfoAboutService

public java.lang.String getInfoAboutService(java.lang.Long bundleID)
Gets all registered information about the specified service.

The xml-structure used to represent the returned service is described in DomainManager#getInfoAboutService.

Specified by:
getInfoAboutService in interface DomainManager
Parameters:
bundleID - the bundle ID the bundle is registered with.
Returns:
An String containg information about the service.
See Also:
DomainManager.getInfoAboutService(java.lang.Long)

checkIfServiceExist

public boolean checkIfServiceExist(java.lang.String uri)
Check if a given service exist.

Specified by:
checkIfServiceExist in interface DomainManager
Parameters:
uri - the service uri
Returns:
true, if service exists, false otherwise

setActiveSpace

public boolean setActiveSpace(int SpaceID,
                              boolean stopOtherServices)
Activates all services belonging to the space identified by the provided id.

Specified by:
setActiveSpace in interface DomainManager
Parameters:
SpaceID - the ID for the Space to activate
stopOtherServices - true to stop the other service proxies, false othervise
Returns:
true, if all proxies adhering to the space ID is started, false othervise.