genDevs.devsBridge.factory
Class DevsFactoryBroker

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by devsBridge.DevsFactoryPOA
          extended by genDevs.devsBridge.factory.DevsFactoryBroker
All Implemented Interfaces:
devsBridge.DevsFactoryOperations, devsBridge.PingableOperations, java.lang.Runnable, org.omg.CORBA.portable.InvokeHandler

public class DevsFactoryBroker
extends devsBridge.DevsFactoryPOA
implements java.lang.Runnable

Implements and Serves a DevsFactory, which delegates creation-requests and release-requests to other factories. Furthermore it implements the call for releasing objects after a certain period of time. TradingService is discovered by initial reference and on fallback at the naming Service for name "TradingService" Currently supports only DevsInit (no Devs and DevsParam) orbd -ORBInitialPort 2809


Field Summary
protected  java.util.GregorianCalendar cal
          time operations
protected  java.lang.Thread clearupThread
          the Tread for checking time and releasing models
protected  java.util.Map<devsBridge.Devs,devsBridge.DevsFactory> factoryMap
          keep track on models and their factories
protected  CosTrading.Lookup lookup
          interface ot the trading service
protected  ORBHelper.ORBInfo orbInfo
          references to ORB and POA
protected  java.util.SortedMap<java.util.Date,devsBridge.Devs> revTimeOutMap
          keep track on scheduled release date and corresponding models
protected  java.util.Map<devsBridge.Devs,java.util.Date> timeOutMap
          keep track on models and their scheduled release date
 
Constructor Summary
DevsFactoryBroker(ORBHelper.ORBInfo orbInfo)
          Constructor.
 
Method Summary
 devsBridge.Devs constructDevs(java.lang.String modelName, java.lang.String translatorName, int timeoutHours)
           
 devsBridge.DevsInit constructDevsInit(java.lang.String modelName, java.lang.String translatorName, int timeoutHours)
           
 devsBridge.DevsInit constructDevsInitParams(java.lang.String modelName, java.lang.String translatorName, int timeoutHours, java.lang.String params)
           
 devsBridge.DevsPorts constructDevsPorts(java.lang.String modelName, java.lang.String translatorName, int timeoutHours)
           
protected  void finalize()
           
protected  devsBridge.TradingDevsFactory getTradedFactory(java.lang.String modelName, java.lang.String translatorName)
          Returns a model that can create models for given Names of the model and the Translator.
protected  void insertModel(devsBridge.Devs devs, devsBridge.DevsFactory devsFactory, int timeOutHours)
          Keeps track on given model.
static void main(java.lang.String[] args)
           
 java.lang.String ping(java.lang.String testString)
          Test if model is reponding.
 void releaseModel(devsBridge.Devs devs)
           
protected  void removeModel(devsBridge.Devs devs)
          Calls the corresponding factory to release the model and removes the model from Track-Keeping.
 void run()
          wakes up every hour and releases expired models
protected  void stopRun()
          Stops the execution of the class - namely the clearup Thread.
 
Methods inherited from class devsBridge.DevsFactoryPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orbInfo

protected ORBHelper.ORBInfo orbInfo
references to ORB and POA


lookup

protected CosTrading.Lookup lookup
interface ot the trading service


factoryMap

protected java.util.Map<devsBridge.Devs,devsBridge.DevsFactory> factoryMap
keep track on models and their factories


timeOutMap

protected java.util.Map<devsBridge.Devs,java.util.Date> timeOutMap
keep track on models and their scheduled release date


revTimeOutMap

protected java.util.SortedMap<java.util.Date,devsBridge.Devs> revTimeOutMap
keep track on scheduled release date and corresponding models


cal

protected java.util.GregorianCalendar cal
time operations


clearupThread

protected java.lang.Thread clearupThread
the Tread for checking time and releasing models

Constructor Detail

DevsFactoryBroker

public DevsFactoryBroker(ORBHelper.ORBInfo orbInfo)
                  throws org.omg.CORBA.UserException
Constructor.

Parameters:
orbInfo - setup of the ORB.
Throws:
org.omg.CORBA.UserException - on locating trading service.
Method Detail

stopRun

protected void stopRun()
Stops the execution of the class - namely the clearup Thread.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

insertModel

protected void insertModel(devsBridge.Devs devs,
                           devsBridge.DevsFactory devsFactory,
                           int timeOutHours)
                    throws devsBridge.DevsCorbaException
Keeps track on given model.

Parameters:
devs - the model.
devsFactory - the factory that created the model.
timeOutHours - automatically release the model after this time.
Throws:
devsBridge.DevsCorbaException - on any error

removeModel

protected void removeModel(devsBridge.Devs devs)
                    throws devsBridge.DevsCorbaException
Calls the corresponding factory to release the model and removes the model from Track-Keeping.

Parameters:
devs - the model.
Throws:
devsBridge.DevsCorbaException - on any error.

run

public void run()
wakes up every hour and releases expired models

Specified by:
run in interface java.lang.Runnable

getTradedFactory

protected devsBridge.TradingDevsFactory getTradedFactory(java.lang.String modelName,
                                                         java.lang.String translatorName)
                                                  throws devsBridge.DevsCorbaException
Returns a model that can create models for given Names of the model and the Translator.

Parameters:
modelName - name of the model.
translatorName - name of the translator.
Returns:
the Factory.
Throws:
devsBridge.DevsCorbaException - if no corresponding factory was found.

constructDevs

public devsBridge.Devs constructDevs(java.lang.String modelName,
                                     java.lang.String translatorName,
                                     int timeoutHours)
                              throws devsBridge.DevsCorbaException
Specified by:
constructDevs in interface devsBridge.DevsFactoryOperations
Throws:
devsBridge.DevsCorbaException

constructDevsPorts

public devsBridge.DevsPorts constructDevsPorts(java.lang.String modelName,
                                               java.lang.String translatorName,
                                               int timeoutHours)
                                        throws devsBridge.DevsCorbaException
Specified by:
constructDevsPorts in interface devsBridge.DevsFactoryOperations
Throws:
devsBridge.DevsCorbaException

constructDevsInitParams

public devsBridge.DevsInit constructDevsInitParams(java.lang.String modelName,
                                                   java.lang.String translatorName,
                                                   int timeoutHours,
                                                   java.lang.String params)
                                            throws devsBridge.DevsCorbaException
Specified by:
constructDevsInitParams in interface devsBridge.DevsFactoryOperations
Throws:
devsBridge.DevsCorbaException

constructDevsInit

public devsBridge.DevsInit constructDevsInit(java.lang.String modelName,
                                             java.lang.String translatorName,
                                             int timeoutHours)
                                      throws devsBridge.DevsCorbaException
Specified by:
constructDevsInit in interface devsBridge.DevsFactoryOperations
Throws:
devsBridge.DevsCorbaException

releaseModel

public void releaseModel(devsBridge.Devs devs)
                  throws devsBridge.DevsCorbaException
Specified by:
releaseModel in interface devsBridge.DevsFactoryOperations
Throws:
devsBridge.DevsCorbaException

main

public static void main(java.lang.String[] args)
Parameters:
args - arguments to the ORB

ping

public java.lang.String ping(java.lang.String testString)
Test if model is reponding.

Specified by:
ping in interface devsBridge.PingableOperations