obixserver.core.engine
Class ObjBrokerImpl

java.lang.Object
  extended by obixserver.core.engine.ObjBrokerImpl
All Implemented Interfaces:
ObjBroker, Service

public class ObjBrokerImpl
extends Object
implements ObjBroker

Implements ObjBroker interface as facade for Obj managment. It uses WatchManager to manage watches and feeds and InvocationManager to invoke processing for operations (POST requests). ObjCache is used for caching of Obj's and their mapping and lookup based on Obj hrefs (URIs).


Field Summary
private  AlarmManager alarmManager
          Manages alarm lifecycle: creation, deletion and updates.
private  String baseUri
          Base URL loaded from properties
private  InvocationManager invocationManager
          Manages invocation of operations on Obj's
private  Map invocationTargetMap
          A map of invocation targets registered with the obix server system.
static Logger logger
           
private  ObjCache objCache
          Obix object cache.
private  boolean useRelativeHref
          Use relative hrefs when generating canonical href.
private  WatchManager watchManager
          Watch manager invoked for watch operations and updates from user modules.
 
Constructor Summary
ObjBrokerImpl(ObjCache obixObjCache)
          Constructs an instance, initializing fields with parameters.
 
Method Summary
 void addCondition(Condition condition)
          Adds an alarm to the system.
 void addFeed(obix.Feed feed, List feedSet)
          Adds a set of Obj's to a feed.
 obix.Obj addObj(obix.Obj obj)
          Adds object to object manager and to the service.
 void addObjTree(obix.Obj obj)
          Adds object and children to object manager and service, recursively.
 void addProxy(String uri, ObjProxy proxy)
          Adds a proxy obj.
 void addToFeed(obix.Feed feedObj, obix.Obj obj)
          Adds obj to all feeds associated with given feed obj.
 void clearFeed(obix.Feed feed)
          Clears a feed.
private  void generateHref(obix.Obj obj)
          Generate href for obj.
 String getBaseUri()
          Get base URI for this server.
 List getFeed(obix.Feed feed)
          Returns the set of Obj's that belong to a feed.
 obix.Obj getObj(String uri)
          Returns Obj for given URI in the Obj repository.
 obix.Obj invoke(obix.Obj obj, String xml, String method)
          Invokes processing for operation Obj's (Op Obj's).
 void notifyStatusChange(List objList)
          Notifies about status change via a list of changed Obj's.
 void notifyStatusChange(obix.Obj obj)
          Notifies about status change.
 void notifyStatusChangeRecursive(obix.Obj obj)
          Notifies about status change recursively for passed obj and its children.
 void removeCondition(Condition c)
           
 void removeObjTree(obix.Obj obj)
          Removes obj and its children from object repository.
private  void setCanonicalHref(obix.Obj obj)
          Sets href in a canonical way,.
 void start()
          Starts the service.
 void stop()
          Stops the service.
 void updateObject(obix.Obj obj)
          Updates obj and its children in the obj repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final Logger logger

useRelativeHref

private boolean useRelativeHref
Use relative hrefs when generating canonical href.


objCache

private ObjCache objCache
Obix object cache.


watchManager

private WatchManager watchManager
Watch manager invoked for watch operations and updates from user modules.


baseUri

private String baseUri
Base URL loaded from properties


invocationManager

private InvocationManager invocationManager
Manages invocation of operations on Obj's


alarmManager

private AlarmManager alarmManager
Manages alarm lifecycle: creation, deletion and updates.


invocationTargetMap

private Map invocationTargetMap
A map of invocation targets registered with the obix server system. uri -> instance

Constructor Detail

ObjBrokerImpl

public ObjBrokerImpl(ObjCache obixObjCache)
Constructs an instance, initializing fields with parameters.

Parameters:
obixObjCache -
Method Detail

start

public void start()
           throws ObixserverException
Description copied from interface: Service
Starts the service.

Specified by:
start in interface Service
Throws:
ObixserverException - if an error occurs during start invocation.

stop

public void stop()
          throws ObixserverException
Description copied from interface: Service
Stops the service.

Specified by:
stop in interface Service
Throws:
ObixserverException - if an error occurs during stop invocation.

updateObject

public void updateObject(obix.Obj obj)
Updates obj and its children in the obj repository. Update is needed only for Obj's that have proxies.

Specified by:
updateObject in interface ObjBroker
Parameters:
obj - Obj or Obj tree with children that should be updated in cache and proxy,

notifyStatusChangeRecursive

public void notifyStatusChangeRecursive(obix.Obj obj)
Notifies about status change recursively for passed obj and its children.

Specified by:
notifyStatusChangeRecursive in interface ObjBroker
Parameters:
obj - obj whiose status has changed.

notifyStatusChange

public void notifyStatusChange(obix.Obj obj)
Notifies about status change.

Specified by:
notifyStatusChange in interface ObjBroker
Parameters:
obj - obj whose status has changed.

notifyStatusChange

public void notifyStatusChange(List objList)
Description copied from interface: ObjBroker
Notifies about status change via a list of changed Obj's.

Specified by:
notifyStatusChange in interface ObjBroker
Parameters:
objList - list of Obj's whose status has changed

addObj

public obix.Obj addObj(obix.Obj obj)
Adds object to object manager and to the service.

Specified by:
addObj in interface ObjBroker
Parameters:
obj -
Returns:
the obj added, which may be different from the one requested to be added

addObjTree

public void addObjTree(obix.Obj obj)
Adds object and children to object manager and service, recursively. This assumes that there is no loop in the tree, i.e. child can't have a pre-decessor as a child. a child can have only one parent.

Specified by:
addObjTree in interface ObjBroker
Parameters:
obj -

invoke

public obix.Obj invoke(obix.Obj obj,
                       String xml,
                       String method)
                throws ObixserverException,
                       obix.xml.XException
Description copied from interface: ObjBroker
Invokes processing for operation Obj's (Op Obj's).

Specified by:
invoke in interface ObjBroker
Parameters:
obj - target obj of this invocation: obj that is being read/GET, write/PUT into, or POSTed into.
xml - request payload
method - REST method
Returns:
obj that invocatoin produce. This obj may be later encoding into REST response: in that case a recursive encoding will be done if invocation is op/POST, otherwise it will be non-recursive.
Throws:
obix.xml.XException - if request of incorrect xml syntax
ObixserverException - if error occured during processing

removeObjTree

public void removeObjTree(obix.Obj obj)
Description copied from interface: ObjBroker
Removes obj and its children from object repository.

Specified by:
removeObjTree in interface ObjBroker
Parameters:
obj - obj to remove

addFeed

public void addFeed(obix.Feed feed,
                    List feedSet)
Description copied from interface: ObjBroker
Adds a set of Obj's to a feed.

Specified by:
addFeed in interface ObjBroker

addToFeed

public void addToFeed(obix.Feed feedObj,
                      obix.Obj obj)
Description copied from interface: ObjBroker
Adds obj to all feeds associated with given feed obj.

Specified by:
addToFeed in interface ObjBroker

clearFeed

public void clearFeed(obix.Feed feed)
Description copied from interface: ObjBroker
Clears a feed.

Specified by:
clearFeed in interface ObjBroker

getFeed

public List getFeed(obix.Feed feed)
Description copied from interface: ObjBroker
Returns the set of Obj's that belong to a feed.

Specified by:
getFeed in interface ObjBroker

addProxy

public void addProxy(String uri,
                     ObjProxy proxy)
Description copied from interface: ObjBroker
Adds a proxy obj.

Specified by:
addProxy in interface ObjBroker

getObj

public obix.Obj getObj(String uri)
Description copied from interface: ObjBroker
Returns Obj for given URI in the Obj repository.

Specified by:
getObj in interface ObjBroker
Returns:
Obj or null if no Obj found for given URI

setCanonicalHref

private void setCanonicalHref(obix.Obj obj)
Sets href in a canonical way,. using the object name property.

Parameters:
obj -

generateHref

private void generateHref(obix.Obj obj)
Generate href for obj. If object resolver set, it is invoked to see if it wants to resolve the URI.

Parameters:
obj -

addCondition

public void addCondition(Condition condition)
Description copied from interface: ObjBroker
Adds an alarm to the system.

Specified by:
addCondition in interface ObjBroker

removeCondition

public void removeCondition(Condition c)

getBaseUri

public String getBaseUri()
Description copied from interface: ObjBroker
Get base URI for this server. Example: http://obixserver:1225

Specified by:
getBaseUri in interface ObjBroker
Returns:
the base URI


Copyright © 2006-2008 Peter Michalek All Rights Reserved.