1 package com.teamkonzept.webman.mainint; 2 3 import com.teamkonzept.webman.*; 4 import com.teamkonzept.webman.db.*; 5 6 import com.teamkonzept.webman.mainint.db.*; 7 import com.teamkonzept.webman.mainint.db.queries.*; 8 9 import com.teamkonzept.field.*; 10 import com.teamkonzept.field.db.*; 11 import com.teamkonzept.field.db.queries.*; 12 13 import com.teamkonzept.publishing.markups.*; 14 15 import com.teamkonzept.db.*; 16 import com.teamkonzept.web.*; 17 import com.teamkonzept.lib.*; 18 import com.teamkonzept.webman.mainint.events.CachedEventDistributor; 19 import com.teamkonzept.webman.mainint.events.ParameterTypes; 20 import com.teamkonzept.webman.mainint.events.*; 21 22 import com.oroinc.text.regex.*; 23 24 import de.webman.util.log4j.WebmanCategory; 25 import de.webman.acl.ACEventDistributor; 26 import de.webman.generator.GREventDistributor; 27 import de.webman.content.CEEventDistributor; 28 import de.webman.template.TEEventDistributor; 29 import de.webman.form.CTEventDistributor; 30 import de.webman.sitetree.STEventDistributor; 31 import de.webman.duplication.DUEventDistributor; 32 import de.webman.documenttype.DTEventDistributor; 33 import de.webman.config.COEventDistributor; 34 35 36 import java.io.*; 37 import java.util.*; 38 import java.sql.*; 39 40 46 public class WebManThread extends CachedEventDistributor implements FrameConstants, DatabaseDefaults, ParameterTypes 47 { 48 51 private static TKVector classVector= null; 52 53 static boolean initialized = false; 54 55 56 private static WebManThread instance = new WebManThread(); 57 58 59 private static WebmanCategory cat = (WebmanCategory)WebmanCategory.getInstance(WebManThread.class.getName()); 60 61 65 public static WebManThread getInstance() 66 { 67 return instance; 68 } 69 70 public static TKVector getClassVector() 71 { 72 try 73 { 74 if(classVector == null) 75 classVector = registerAllFields(); 76 } 77 catch (Throwable t) 78 { 79 cat.fatal("registerFields", t); 80 } 81 return classVector; 82 } 83 84 85 private WebManThread() 86 { 87 95 addEventHandler(StartEventHandler.getInstance()); 97 addEventHandler(EmptyEventHandler.getInstance()); 98 addEventHandler(new CEEventDistributor()); 99 addEventHandler(new COEventDistributor()); 100 addEventHandler(new CTEventDistributor()); 101 addEventHandler(new MEEventHandler()); 102 addEventHandler(new DTEventDistributor()); 103 addEventHandler(new TEEventDistributor()); 104 addEventHandler(new STEventDistributor()); 105 addEventHandler(new ACEventDistributor()); 106 addEventHandler(new GREventDistributor()); 107 addEventHandler(new DUEventDistributor()); 108 addEventHandler(new FrameOrientationHandler()); 109 addEventHandler(WebmanExceptionHandler.getInstance()); 110 } 111 112 115 public boolean isHandler(TKEvent evt) 116 { 117 return true; 118 } 119 120 126 public TKEvent createEvent (TKHttpInterface http) 127 { 128 return new TKUserEvent(http); 129 } 130 131 134 public static TKVector registerAllFields() throws TKException 135 { 136 try 137 { 138 TKQuery q = TKWebmanDBManager.newQuery(TKDBFormFieldClassGet.class); 140 q.execute(); 141 ResultSet rs = q.fetchResultSet(); 142 143 classVector = new TKVector(); 145 while(rs.next()){ 146 String rowArray[] = { rs.getString("FIELD_TYPE"), rs.getString("FIELD_CLASS") }; 147 classVector.addElement(rowArray); 148 } 149 150 for (int i=0; i < classVector.size(); i++) { 152 Object element = classVector.elementAt(i); 153 String classInfoArray[] = (String []) element; 154 TKFieldRegistry.registry.registerClass(classInfoArray[0], classInfoArray[1]); 155 } 156 } 157 catch (SQLException e) 158 { 159 throw WebmanExceptionHandler.getException(e); 160 } 161 return classVector; 162 } 163 164 165 public void traceHttpEnv (TKEvent evt) 166 { 167 cat.info( "getOwnName() = "+evt.getHttpInterface().getOwnName()); 168 cat.info( "getOwnURL() = "+evt.getHttpInterface().getOwnURL()); 169 cat.info( "getOwnPath() = "+evt.getHttpInterface().getOwnPath()); 170 cat.info( "getDocumentRoot() = "+evt.getHttpInterface().getDocumentRoot()); 171 cat.info( "getServerName() = "+evt.getHttpInterface().getServerName()); 172 cat.info( "getRemoteUser() = "+evt.getHttpInterface().getRemoteUser()); 173 } 174 175 176 public static synchronized void init(TKEvent evt ) throws TKException{ 177 if (initialized) 178 return; 179 TKUploadField.initStaticsForUpload(evt.getHttpInterface().getDocumentRoot()); 181 182 183 186 if(classVector == null) 187 classVector = registerAllFields(); 188 TKMarkupAdmin.setup(); 189 initialized = true; 190 } 191 192 public void handleEvent( TKEvent evt) throws TKException 193 { 194 try 195 { 196 cat.access("Event : " + evt.getName()); 197 TKWebmanDBManager.initConnection("/webmandb.ini", !initialized); 198 TKPrepQuery.enableCleanup(); 199 if (!initialized) 200 init(evt); 201 evt.checkChecker(); 203 super.handleEvent(evt); 204 } 205 catch (Throwable t) 206 { 207 boolean close = false; 208 210 if (t instanceof TKException) 211 close = WebmanExceptionHandler.handleException((TKException)t, evt); 212 else 213 close = WebmanExceptionHandler.handleException(WebmanExceptionHandler.getException(t), evt); 214 deRegister( close ); 216 initialized = false; 217 219 } 220 deRegister( false ); 221 } 222 223 void deRegister(boolean close) throws TKDatabaseException 224 { 225 try 226 { 227 TKWebmanDBManager.deregister( close ); 228 } 229 catch (SQLException e) 230 { 231 throw new TKDatabaseException(e.toString(),UNDEFINED, NORMAL_SEVERITY, false,e); 232 } 233 } 234 } 235
| Popular Tags
|