2 package com
.interrupt
.bob
.base
;
4 import java
.util
.ArrayList
;
5 import java
.util
.Iterator
;
7 import java
.util
.HashMap
;
10 import org
.apache
.log4j
.Logger
;
12 import com
.interrupt
.bob
.FindFiles
;
13 import com
.interrupt
.bob
.core
.Memory
;
14 import com
.interrupt
.bob
.core
.MemoryField
;
15 import com
.interrupt
.bob
.core
.Queue
;
16 import com
.interrupt
.bob
.handler
.DefinitionHandler
;
17 import com
.interrupt
.bob
.handler
.BobHandler
;
18 import com
.interrupt
.bob
.handler
.HandlerField
;
19 import com
.interrupt
.bob
.handler
.IHandlerField
;
20 import com
.interrupt
.bob
.handler
.XMLHandler
;
21 import com
.interrupt
.bob
.processor
.DocumentProcessor
;
22 import com
.interrupt
.bob
.processor
.ProcessorException
;
23 import com
.interrupt
.bob
.util
.Util
;
25 public class BobSystem
{
28 private Logger logger
= Logger
.getLogger(BobSystem
.class);
31 public static String DEFINITIONS
= "definition.list";
32 public static String SYSTEM
= "bob.system";
34 private List definitions
= null;
35 private IBob system
= null;
36 private Map _messageMap
= null;
37 //private boolean _initialised = false;
39 _messageMap
= new HashMap();
44 private static BobSystem _instance
= null;
45 public static BobSystem
getInstance() {
47 if(_instance
== null) {
48 _instance
= new BobSystem();
55 public void setMessage(String _name
, Object _val
) {
56 _messageMap
.put(_name
,_val
);
58 public Object
getMessage(String _name
) {
59 return _messageMap
.get(_name
);
64 public List
getDefinitions() {
67 public void setDefinitions(List defs
) {
73 public IBob
getSystem() {
76 public void setSystem(IBob sys
) {
81 public void buildSystem( List plist
) {
84 StringBuilder fileString_b
= new StringBuilder();
85 Iterator fileIter
= plist
.iterator();
86 while( fileIter
.hasNext() ) {
88 fileString_b
.append( " " );
89 fileString_b
.append( (String
)fileIter
.next() );
92 String fileString_s
= fileString_b
.toString();
95 logger
.debug( "INPUT List["+ fileString_s
+"]" );
98 DocumentProcessor dprocessor
= null;
101 DefinitionHandler dhandler
= new DefinitionHandler();
102 dhandler
.setFiles( fileString_s
);
103 dhandler
.setOut( Util
.DEF
);
105 IHandlerField hfield
= new HandlerField();
106 hfield
.setName("tagList");
107 hfield
.setValue("${"+ Util
.DEF
+"}");
109 BobHandler bhandler
= new BobHandler();
110 bhandler
.setFiles( fileString_s
);
111 bhandler
.setOut( Util
.SYS
);
112 bhandler
.addHandlerField(hfield
);
114 dprocessor
= new DocumentProcessor();
115 dprocessor
.addHandler(dhandler
);
116 dprocessor
.addHandler(bhandler
);
117 dprocessor
.process();
120 Queue queue
= dprocessor
.getQueue();
121 logger
.debug( "HERE 1 / Queue["+ queue
+"]" );
123 Memory memory
= (Memory
)queue
.getMemory();
125 MemoryField defField
= (MemoryField
)memory
.findMemoryFieldByName( Util
.DEF
);
126 logger
.debug( "HERE 2 / defField["+ defField
+"]" );
127 definitions
= (List
)defField
.getValue(defField
);
129 MemoryField sysField
= (MemoryField
)memory
.findMemoryFieldByName( Util
.SYS
);
130 logger
.debug( "HERE 3 / sysField["+ sysField
+"]" );
131 system
= (IBob
)sysField
.getValue(sysField
);
133 logger
.debug("============== END ==================");
134 system
.toXML( System
.out
);
135 logger
.debug("\n\n\n");
138 catch(ProcessorException e
) {