|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--submarine.core.EAISystem
The main class of the Submarine project.
It contains the rules of the EAI engine and it drives the plugins (connectors) of the system.
This class implements Runnable
so it can be launch as a Thread in an existing program
or as a standalone program using a very simple class.
This class is used typically in the way of the following sample :
try { EAISystem eai=new EAISystem(); eai.setConfig("config-file.xml"); Thread th = new Thread(eai); th.start(); } catch(Exception e) { System.err.println("Exception in main "+e); }The setConfig call, initializes the
PoolingFunctions
,
the ListeningFunctions
, creates the WritingFunctions
, prepares the Channels
and the Resources
.
.|--------------------| .|ListeningFunction
| .|--------------------| /-java.lang.Object--\ |-----------------------------------------| . \ / \ |Channel
X X | . \---------->|-------------| | | M M | . |EAISystem
|---->| |--------|L |------| L |------------| | . /---------->|-------------| | |Parser
|-->| XSLT |-->|Serializer
| | . / | |--------| |------| |------|-----| | .|--------------------| |---^-----------------------------|-------| .|PoolingFunction
| | java.lang.Object| .|--------------------| |--------|-----| |----------V------| . |Resource
| |WritingFunction
| . |--------------| |-----------------|
ListeningFunctions
submit to EAISystem the messages
joined to routing information
. PoolingFunctions
are lauched at a defined frequency by the EAISystem and
supply messages implementing the function getNextDocument
. In both cases messages are received by the function
submit
and added in the queue
if message
is asynchronous. If the message is synchronous, it is directly supplied to the
Channel's submit function
.( In this case an instance of the Channel
is created. Asynchronous messages waiting in the queue are taken out by a Thread in the
pool of Thread-Channel
. Then it is executed by the Channel.
A Channel execute a message following the steps of a Channel.
At the end of the processing, the resulting message is submited synchronously
or asyncronousely to a WritingFunction
.
Inner Class Summary | |
static class |
EAISystem.ErrorObject
Classe servant à encapsuler un message soumis au systeme accompagnée d'une erreur détectée. |
private class |
EAISystem.RunListeningFunction
Classe Runnable interne à EAISystem et destinée à lancer une ListeningFunction. |
private class |
EAISystem.RunPoolingFunction
Classe Runnable interne à EAISystem et destinée à lancer une PoolingFunction. |
static class |
EAISystem.Tools
Une classe contenant des méthodes statiques utiles pour la manipulation du XML et autre. |
Field Summary | |
private java.text.SimpleDateFormat |
_id_format
|
private java.io.File |
archivePath
|
private boolean |
bReloadConfig
used to indicate the server to reload its configuration at the next stop() call function. |
private java.util.Hashtable |
channelInfos
Channels list as defined in the configuration file. |
private int |
ChannelThreadCount
The maximum number of concurrent Channel-Thread. |
private java.lang.String |
configFile
the default configuration file name. |
private java.lang.String |
encoding
The file encoding for archives files and errors. |
SyncQueue |
errorQueue
|
private ListeningFunction |
internalListener
a special Listening function used to handle the server using telnet connection. |
static java.lang.String |
jndiConnectorsControler
|
static java.lang.String |
jndiSubmiter
|
private java.util.Hashtable |
listeningFunctions
|
static java.lang.String |
mainXMLElement
The main XML element tag that should appears in the configuration file. |
private java.util.Hashtable |
poolingFunctions
|
private java.util.Hashtable |
resources
The Resources list shared by the connectors list
as defined in the configuration file. |
private java.lang.Thread |
runThread
|
private java.lang.String |
serverId
The string identifier for the server. |
private boolean |
stopping
|
private java.util.Vector |
threads
List all the internally managed threads. |
private long |
txCounter
The last number used to create a message id. |
SyncQueue |
waitingQueue
The queue in which the asynchronous messages arrives. |
private java.util.Hashtable |
writingFunctions
WritingFunctions list as defined in the configuration file. |
Constructor Summary | |
EAISystem()
Default constructor. |
Method Summary | |
void |
archive(java.lang.String Channel,
java.lang.Object message,
Message.MsgContext ctx,
int type)
Archive un message pendant ses différentes phases de transformation par le Channel. |
private void |
createChannelInfos(org.w3c.dom.Element elm)
Initialise une nouvelle instance de ChannelInfos à partir d'un élément
XML.
|
private void |
createListeningFunction(org.w3c.dom.Element elm)
Crée une nouvelle ListeningFunction à partir d'un élément XML. |
private void |
createPoolingFunction(org.w3c.dom.Element elm)
Create a new PoolingFunction from an XML element. |
private void |
createResource(org.w3c.dom.Element elm)
Crée une nouvelle Resource à partir d'un élément XML. |
private void |
createWritingFunction(org.w3c.dom.Element elm)
Create a new WritingFunction from an XML element. |
ChannelInfos |
getChannelByName(java.lang.String name)
Retreive a ChannelInfos from its name. |
ConnectorsControler |
getControler()
returns the ConnectorsControler interface of the system. implementation of the SubmiterAware interface. |
ListeningFunction |
getListenerById(java.lang.String id)
Retreive a ListeningFunction from its id. |
private java.lang.String |
getNewDocId()
Crée un nouvel identifiant de document unique dans le systeme. |
PoolingFunction |
getPoolerById(java.lang.String id)
Retreive a PoolingFunction from its id. |
Resource |
getResourceById(java.lang.String id)
Retreive a Resource from its name. |
WritingFunction |
getWriterById(java.lang.String id)
Retreive a WritingFunction from its id. |
private void |
includeFiles(org.w3c.dom.Document doc,
java.util.List redFiles)
|
private void |
initSubmiterAware(java.lang.Object o)
Gives the Submiter interface of the Server to an object
if its implements interface SubmiterAware . |
void |
manageError(Message m,
java.lang.String error)
Traite une erreur intervenue durant l'exécution d'un Channel ou d'un connecteur. |
private boolean |
matchChannel(RouteInfos ri,
ChannelInfos ci,
java.lang.String ChannelName)
Détermine si un Channel correspond aux informations de routages fournies. |
void |
printQueues(java.io.PrintWriter pout)
Affiche les files d'attente et d'erreur sur le printer. |
void |
restart()
|
void |
run()
Implémentation de Runnable. |
protected java.lang.String[] |
selectChannels(RouteInfos infos)
Calcule la liste des noms de Channels pouvant correspondre aux informations de routages. |
private void |
setConfig(org.w3c.dom.Document doc)
|
void |
setConfig(java.lang.String fileName)
Cette méthode initialise le système EAI à partir d'un fichier de configuration XML. |
void |
stop()
Interrompt tous les threads lancé explicitement par le système et notifie le thread principal qui a lancé run() .
|
java.lang.Object |
submit(java.lang.Object message,
RouteInfos infos)
Soumet un message au Submiter. |
java.lang.Object |
submit(java.lang.Object message,
RouteInfos infos,
Message.MsgContext context)
Utilisé pour soumettre un nouveau message au systeme. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final java.lang.String mainXMLElement
public static final java.lang.String jndiSubmiter
public static final java.lang.String jndiConnectorsControler
private int ChannelThreadCount
private java.lang.String serverId
private long txCounter
private java.lang.String encoding
private java.util.Hashtable channelInfos
private java.util.Hashtable writingFunctions
private java.util.Hashtable poolingFunctions
private java.util.Hashtable listeningFunctions
private java.util.Hashtable resources
Resources
list shared by the connectors list
as defined in the configuration file.private ListeningFunction internalListener
private java.util.Vector threads
private java.io.File archivePath
private java.lang.Thread runThread
private boolean stopping
private boolean bReloadConfig
private java.lang.String configFile
public SyncQueue waitingQueue
public SyncQueue errorQueue
private java.text.SimpleDateFormat _id_format
Constructor Detail |
public EAISystem()
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
to create XML documents.Method Detail |
public WritingFunction getWriterById(java.lang.String id)
ConnectorsControler
interface.getWriterById
in interface ConnectorsControler
name
- The name of the WritingFunction the function should returns.public ListeningFunction getListenerById(java.lang.String id)
ConnectorsControler
interface.getListenerById
in interface ConnectorsControler
name
- The name of the ListeningFunction the function should returns.public PoolingFunction getPoolerById(java.lang.String id)
ConnectorsControler
interface.getPoolerById
in interface ConnectorsControler
name
- The name of the PoolingFunction the function should returns.public ChannelInfos getChannelByName(java.lang.String name)
ConnectorsControler
interface.getChannelByName
in interface ConnectorsControler
name
- The name of the ChannelInfos the function should returns.public Resource getResourceById(java.lang.String id)
ConnectorsControler
interface.getResourceById
in interface ConnectorsControler
name
- The name of the Resource the function should returns.public ConnectorsControler getControler()
SubmiterAware
interface.getControler
in interface Submiter
private void initSubmiterAware(java.lang.Object o)
Submiter
interface of the Server to an object
if its implements interface SubmiterAware
.o
- The object that should implements SubmiterAware.private void createWritingFunction(org.w3c.dom.Element elm)
This XML element should follows the syntax :
No control is made on the given element tag name.
<WritingFunction id="writing function name" class="package.class"/> <!-- @id identify the WritingFunction uniquely --> <!-- @class is the class name which implements interface WritingFunction --> <!-- A WritingFunction implements XMLConfigurable. After its creation, the new instance receive the same XML element in order to initialize specific informations. See the specific documentation class. -->
elm
- XML element following this syntax.private void createPoolingFunction(org.w3c.dom.Element elm)
This XML element should follows the syntax :
No control is made on the given element tag name.
<PoolingFunction id="pooling function name" class="package.class"> <!-- @id identify th PoolingFunction uniquely --> <!-- @class is the class name which implements interface WritingFunction --> <!-- A WritingFunction implements XMLConfigurable. After its creation, the new instance receive the same XML element in order to initialize specific informations. See the specific documentation class. --> <!-- A pooling function need to parameter thefrequency
and therouting information
so it is recomanded to have the two following elements: --> <RouteInfos> <!-- seeRouteInfos.init
for content details --> </RouteInfos> <!-- frequency in ms --> <frequency>1000</frequency> </PoolingFunction>
elm
- L'élément XML devant suivre cette syntaxe.private void createListeningFunction(org.w3c.dom.Element elm)
Cet élément XML doit suivre la syntaxe suivante :
Aucune vérification n'est faite sur le nom de l'élément dans cette fonction.
<ListeningFunction id="nom de la listening function" class="package.class"/> <!-- @id identifie la ListeningFunction de manière unique --> <!-- @class est la classe qui doit implémenter l'interface ListeningFunction --> <!-- Une ListeningFunction implémente XMLConfigurable. Après sa construction, l'instance reçoit ce même élément pouvant contenir des informations spécifiques à la classe reportez-vous à la documentation propre de la classe. -->
elm
- L'élément XML devant suivre cette syntaxe.private void createResource(org.w3c.dom.Element elm)
Cet élément XML doit suivre la syntaxe suivante :
Aucune vérification n'est faite sur le nom de l'élément dans cette fonction.
<Resource id="nom de la listening function" class="package.class"/>
<!-- @id identifie la Resource de manière unique -->
<!-- @class est la classe qui doit implémenter l'interface Resource
-->
<!-- Une Resource implémente XMLConfigurable. Après sa construction, l'instance
reçoit ce même élément pouvant contenir des informations spécifiques à la classe
reportez-vous à la documentation propre de la classe. -->
elm
- L'élément XML devant suivre cette syntaxe.private void createChannelInfos(org.w3c.dom.Element elm)
ChannelInfos
à partir d'un élément
XML.
La syntaxe de cet élément suit les règles suivantes :
<Channel name="Channel name">
<!-- @name identifie de façon unique le Channel -->
<!-- Le contenu de cet élément est décrit dans ChannelInfos.init
-->
</Channel>
elm
- l'élément à partir duquel le ChannelInfos est initialisépublic void setConfig(java.lang.String fileName)
La syntaxe XML attendue est la suivante:
<submarine> <global> <!-- Les informations configurant le serveur lui-même --> <server id="server-id"/> <listener port="9999"/> <!-- internal listener port --> <archive path="archive" encoding="ISO-8859-1"/> <!-- répertoire en encodage de l'archivage des messages --> <threads count="3"/> <!-- Nombre de Thread-Channel créés pour traiter les messages --> </global> <Includes> <!-- Included files have the same syntax and can also include files. --> < Include file="a-file.xml"/> </Includes> <PoolingFunctions> <PoolingFunction/> <!-- voirle détails
--> </PoolingFunctions> <ListeningFunctions> <ListeningFunction/> <!-- voirle détails
--> </ListeningFunctions/> <Channels> <Channel/> <!-- voirle détails
--> </Channels> <WritingFunctions> <WritingFunction/> <!-- voirle détails
--> </WritingFunctions> </submarine>
fileName
- le nom complet du fichier xml contenant la configutation. Ce
fichier peut être encodée de façon standard (UTF-8, UTF-16, ISO-xxxx-x). Le
parser utilisé est xerces.private void includeFiles(org.w3c.dom.Document doc, java.util.List redFiles) throws java.lang.Exception
private void setConfig(org.w3c.dom.Document doc) throws java.lang.Exception
public void stop()
run()
.
Cette methode arrête le système EAI.public void restart()
public void manageError(Message m, java.lang.String error)
Le traitement consiste en l'écriture d'un fichier dans le répertoire d'erreur du Channel.
Puis si le Channel contient un element on-error-writer, celui-ci est appelé de façon synchrone en donnant un EAISystem.ErrorObject en valeur d'entrée
m
- Le message en cours de traitement.error
- Le message d'erreur.public void run()
Les étapes sont les suivantes :
run
in interface java.lang.Runnable
private boolean matchChannel(RouteInfos ri, ChannelInfos ci, java.lang.String ChannelName)
L'algorithme est le suivant :
ri
- Les informations de routagesci
- Les informations du ChannelChannelName
- Le nom du Channelprotected java.lang.String[] selectChannels(RouteInfos infos)
matchChannel()
retourne vrai.infos
- Les informations de routage.public void printQueues(java.io.PrintWriter pout)
pout
- Le flux devant recevoir les informations sur les files.private java.lang.String getNewDocId()
Cet identifiant est une chaine construite de la manière suivante:
l'identifiant du serveur,
la date systeme au format yyyyMMdd,
l'heure systeme au format HHmmss,
la valeur courante de txCounter
.
public java.lang.Object submit(java.lang.Object message, RouteInfos infos, Message.MsgContext context)
submit
in interface Submiter
message
- Le message à soumettre.infos
- Les informations de routages.public java.lang.Object submit(java.lang.Object message, RouteInfos infos)
Submiter
submit
in interface Submiter
submarine.core.Submiter
message
- infos
- public void archive(java.lang.String Channel, java.lang.Object message, Message.MsgContext ctx, int type)
Archivable
, la méthode archive
est utilisée.
Tools.archiveXML
.
Channel
- Le nom du Channel. Servira à choisir le répertoire à utiliser ou a
créer dans le répertoire d'archive définis dans le serveur.message
- L'objet à archivé.ctx
- Le contexte du message. Le docId servira à construire le nom du
fichier.type
- Le type d'archive. Voir ChannelInfos.archive
.
|
Submarine project. free distribution of this software must include the opensource licence. Guénolé de Cadoudal. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |