genDevs.devsBridge.factory
Class DevsFactoryServer

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by devsBridge.TradingDevsFactoryPOA
          extended by genDevs.devsBridge.factory.DevsFactoryServer
All Implemented Interfaces:
CosTradingDynamic.DynamicPropEvalOperations, devsBridge.DevsFactoryOperations, devsBridge.PingableOperations, devsBridge.TradingDevsFactoryOperations, org.omg.CORBA.portable.InvokeHandler
Direct Known Subclasses:
SimpArcFactoryServer

public class DevsFactoryServer
extends devsBridge.TradingDevsFactoryPOA

Base JAVA implementation for a TradingDevsFactory (a DevsFactory that can be registered by a Trading Service). It does not implement the automatic model release after the scheduled time. Note, that it registers no models with the Trading Service. Descendants must overwrite method availableModels. Extend this class by createModelInstance, createTranslatorInstance, availableModels and availableTranslators orbd -ORBInitialPort 2809


Field Summary
protected  java.lang.String offerId
          Trading service key of this factory
protected  java.lang.Class orbClass
          reuse the Class object of ORB
protected  ORBHelper.ORBInfo orbInfo
          references to ORB and POA
protected  java.util.Map<devsBridge.Devs,java.util.Date> timeOutMap
          keep track of the models and the time they are created
 
Constructor Summary
DevsFactoryServer(ORBHelper.ORBInfo orbInfo)
          Constructor.
 
Method Summary
 int activeModelsCnt()
           
 java.lang.String[] availableModels()
           
 java.lang.String[] availableTranslators()
           
 devsBridge.Devs constructDevs(java.lang.String modelName, java.lang.String translatorName, int timeoutHours)
           
 devsBridge.DevsInit constructDevsInit(java.lang.Object instance, MessageTranslator trans, 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  java.lang.Object createInstance(java.lang.String modelName)
          Return an instance of given model name.
protected  MessageTranslator createTranslator(java.lang.String translatorName)
          Return an instance of given translator name.
 org.omg.CORBA.Any evalDP(java.lang.String name, org.omg.CORBA.TypeCode returned_type, org.omg.CORBA.Any extra_info)
           
protected  void finalize()
           
protected  java.util.Date insertModel(devsBridge.Devs devs, int timeOutHours)
          Keeps track of the created model and informs trading service of changed active model count.
protected static void invokeFactory(ORBHelper.ORBInfo orbInfo, DevsFactoryServer impl, java.lang.String factoryName, java.lang.String[] args)
          Starts the given implementation of a DevsFactoryServer within given orbInfo and given command line arguments.
static void main(java.lang.String[] args)
           
 java.lang.String ping(java.lang.String testString)
           
 void releaseModel(devsBridge.Devs devs)
           
protected  void removeModel(devsBridge.Devs devs)
          Remove the model from track keeping and inform TradingService of decreased active model count.
 void setOfferId(java.lang.String offerId)
          setter for the Trading key.
 void stopFactory()
          removes the service from TradingFactory
 
Methods inherited from class devsBridge.TradingDevsFactoryPOA
_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


orbClass

protected java.lang.Class orbClass
reuse the Class object of ORB


timeOutMap

protected java.util.Map<devsBridge.Devs,java.util.Date> timeOutMap
keep track of the models and the time they are created


offerId

protected java.lang.String offerId
Trading service key of this factory

Constructor Detail

DevsFactoryServer

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

Parameters:
orbInfo - ORB references.
Throws:
org.omg.CORBA.UserException - on any exception.
Method Detail

setOfferId

public void setOfferId(java.lang.String offerId)
setter for the Trading key.

Parameters:
offerId - the trading key.

insertModel

protected java.util.Date insertModel(devsBridge.Devs devs,
                                     int timeOutHours)
Keeps track of the created model and informs trading service of changed active model count.

Parameters:
devs - the Model to keep Track of
timeOutHours - a time after what to delete the model
Returns:
the Date of the call

removeModel

protected void removeModel(devsBridge.Devs devs)
Remove the model from track keeping and inform TradingService of decreased active model count.

Parameters:
devs -

stopFactory

public void stopFactory()
                 throws org.omg.CORBA.UserException
removes the service from TradingFactory

Throws:
org.omg.CORBA.UserException - on error

finalize

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

createInstance

protected java.lang.Object createInstance(java.lang.String modelName)
                                   throws devsBridge.DevsCorbaException
Return an instance of given model name. This implementation uses the Java Reflection API and requires fully qualified Java class names. Decendants should overwrite this method to return specific models.

Parameters:
modelName - name of the model to create.
Returns:
The model instance (Devs/DevsPorts/DevsInit)
Throws:
devsBridge.DevsCorbaException

createTranslator

protected MessageTranslator createTranslator(java.lang.String translatorName)
                                      throws devsBridge.DevsCorbaException
Return an instance of given translator name. This implementation uses the Java Reflection API and requires fully qualified Java class names. and the standard Translators Dbl, Int, String and PortNameMsgTranslator Decendants should overwrite this method to return specific translators for simple names

Parameters:
translatorName - name of the translator
Returns:
the Translator instance
Throws:
devsBridge.DevsCorbaException - if no corresponding translator can be created.

constructDevs

public devsBridge.Devs constructDevs(java.lang.String modelName,
                                     java.lang.String translatorName,
                                     int timeoutHours)
                              throws devsBridge.DevsCorbaException
Throws:
devsBridge.DevsCorbaException

constructDevsPorts

public devsBridge.DevsPorts constructDevsPorts(java.lang.String modelName,
                                               java.lang.String translatorName,
                                               int timeoutHours)
                                        throws devsBridge.DevsCorbaException
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
Throws:
devsBridge.DevsCorbaException

constructDevsInit

public devsBridge.DevsInit constructDevsInit(java.lang.String modelName,
                                             java.lang.String translatorName,
                                             int timeoutHours)
                                      throws devsBridge.DevsCorbaException
Throws:
devsBridge.DevsCorbaException

constructDevsInit

public devsBridge.DevsInit constructDevsInit(java.lang.Object instance,
                                             MessageTranslator trans,
                                             int timeoutHours)
                                      throws devsBridge.DevsCorbaException
Throws:
devsBridge.DevsCorbaException

releaseModel

public void releaseModel(devsBridge.Devs devs)
                  throws devsBridge.DevsCorbaException
Throws:
devsBridge.DevsCorbaException

availableTranslators

public java.lang.String[] availableTranslators()

availableModels

public java.lang.String[] availableModels()

activeModelsCnt

public int activeModelsCnt()

ping

public java.lang.String ping(java.lang.String testString)

evalDP

public org.omg.CORBA.Any evalDP(java.lang.String name,
                                org.omg.CORBA.TypeCode returned_type,
                                org.omg.CORBA.Any extra_info)
                         throws CosTradingDynamic.DPEvalFailure
Throws:
CosTradingDynamic.DPEvalFailure

invokeFactory

protected static void invokeFactory(ORBHelper.ORBInfo orbInfo,
                                    DevsFactoryServer impl,
                                    java.lang.String factoryName,
                                    java.lang.String[] args)
                             throws org.omg.CORBA.UserException
Starts the given implementation of a DevsFactoryServer within given orbInfo and given command line arguments. It will do the following.

Parameters:
orbInfo - The ORB and POA to use to create the Corba Object.
impl - The instance of the Server.
factoryName - The name of the factory (just for printing status information)
args - command line arguments
Throws:
org.omg.CORBA.UserException - if startup of the server fails.

main

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