View Javadoc
1 /* ==================================================================== 2 * Bigyo Software License, version 1.1 3 * 4 * Copyright (c) 2004, Zsombor Gegesy. All rights reserved. 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. Neither the name of the Bigyo Group nor the name "Bigyo" nor 18 * the names of its contributors may be used to endorse or promote 19 * products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 * ==================================================================== 36 */ 37 38 package net.sf.bigyo.container; 39 40 import java.io.File; 41 import java.io.FileNotFoundException; 42 import java.io.FileReader; 43 import java.io.IOException; 44 import java.io.Reader; 45 import java.lang.reflect.Constructor; 46 import java.lang.reflect.InvocationTargetException; 47 import java.lang.reflect.Method; 48 import java.util.ArrayList; 49 import java.util.HashMap; 50 import java.util.Iterator; 51 import java.util.List; 52 import java.util.Map; 53 54 import net.sf.bigyo.api.ContainerException; 55 import net.sf.bigyo.api.LifecycleListener; 56 import net.sf.bigyo.api.ReconfigurationManager; 57 import net.sf.bigyo.api.ServiceLocator; 58 import net.sf.bigyo.container.api.Constants; 59 import net.sf.bigyo.container.api.Registry; 60 import net.sf.bigyo.container.api.Repository; 61 import net.sf.bigyo.container.profile.ProfileChecker; 62 import net.sf.bigyo.model.ComponentConfig; 63 import net.sf.bigyo.model.ObjectDependency; 64 65 import org.apache.avalon.fortress.util.dag.Vertex; 66 import org.apache.log4j.LogManager; 67 import org.apache.log4j.Logger; 68 69 import com.thoughtworks.xstream.XStream; 70 import com.thoughtworks.xstream.io.StreamException; 71 72 /*** 73 * Created on 2004.03.31. 74 * @author zsombor 75 * 76 */ 77 public class Main { 78 79 final static Logger LOG = LogManager.getLogger(Main.class); 80 81 XStream xstream; 82 83 //List compConfigs= new ArrayList(); 84 //Map componentConfigMapping = new HashMap(); 85 Map builtComponents = new HashMap(); 86 //List startupComponents = new ArrayList(); 87 88 //List vertices = new ArrayList(); 89 90 RepositoryImpl loader = new RepositoryImpl(this); 91 RegistryImpl registry; 92 93 private List lifecycleListeners = new ArrayList(); 94 int lifecycle = 0; 95 96 ProfileChecker checker; 97 98 private CompactReflectionConverter compactReflectionConverter; 99 100 public Main() { 101 LOG.info("create component registry"); 102 createXStream(); 103 registry = new RegistryImpl(xstream); 104 } 105 106 public Repository getRepository() { 107 return loader; 108 } 109 110 public Registry getRegistry() { 111 return registry; 112 } 113 114 /*** 115 * Create the container from the specified registry file. 116 * 117 * @param componentRegistryFile 118 * the path to the xml file. 119 * @throws FileNotFoundException 120 * if no registry is found 121 */ 122 public Main(String componentRegistryFile) throws FileNotFoundException { 123 createXStream(); 124 registry = new RegistryImpl(componentRegistryFile, xstream); 125 } 126 127 /*** 128 * Create the container from the specified registry stream. 129 * 130 * @param componentRegistryReader 131 */ 132 public Main(Reader componentRegistryReader) { 133 createXStream(); 134 registry = new RegistryImpl(componentRegistryReader, xstream); 135 } 136 137 /*** 138 * @deprecated this is an internal API method, please avoid the usage 139 */ 140 public void createXStream() { 141 xstream = new XStream(); 142 xstream.alias("description", ComponentDescription.class); 143 xstream.alias("config", ComponentConfig.class); 144 xstream.alias("depend", ObjectDependency.class); 145 xstream.alias("class-depend", ClassDependency.class); 146 compactReflectionConverter = new CompactReflectionConverter(xstream); 147 xstream.registerConverter(compactReflectionConverter); 148 149 } 150 151 /*** 152 * load additional registry file from the specified source. 153 * 154 * @param source 155 */ 156 public void loadComponentRegistry(Reader source) { 157 registry.loadRegistry(source); 158 } 159 160 /*protected Object createComponentFromFile(String componentConfigFile) throws FileNotFoundException, 161 ContainerException, StreamException { 162 LOG.info("create component from file " + componentConfigFile); 163 ComponentConfig config = (ComponentConfig) xstream.fromXML(new FileReader(componentConfigFile)); 164 165 return createComponent(config); 166 }*/ 167 168 /*** 169 * @param config 170 * @throws ClassNotFoundException 171 * @throws InstantiationException 172 * @throws IllegalAccessException 173 * @throws InvocationTargetException 174 */ 175 private Object createComponent(ComponentConfig config,boolean start) throws ContainerException { 176 try { 177 ComponentDescription desc = registry.getComponentDescription(config); 178 if (desc == null) 179 throw new ContainerException("No component registered with the '" + config.getClassAlias() + "' alias!"); 180 181 Class componentClass = Class.forName(desc.getClassName()); 182 if (config.getConfigBean() == null) { 183 LOG.info("config is null, use no-arg constructor for " + desc.getClassName()); 184 return setupDependencies(componentClass.newInstance(), desc, config,start); 185 } 186 Constructor[] constructors = componentClass.getDeclaredConstructors(); 187 for (int i = 0; i < constructors.length; i++) { 188 Class[] params = constructors[i].getParameterTypes(); 189 if (params.length == 1 && params[0].isInstance(config.getConfigBean())) { 190 // found the constructor 191 Object[] initParams = new Object[1]; 192 LOG.info("constructor for " + componentClass + " with " + params[0] + " parameter found."); 193 initParams[0] = config.getConfigBean(); 194 return setupDependencies(constructors[i].newInstance(initParams), desc, config,start); 195 196 } 197 } 198 throw new ContainerException("No constructor found for " + desc.getClassName() + " with one " 199 + desc.getConfigClass() + " parameter!"); 200 } catch (ClassNotFoundException e) { 201 throw new ContainerException("Class not found![" + e.getMessage() + "]", e); 202 } catch (InstantiationException e) { 203 throw new ContainerException("Instantiation error![" + e.getMessage() + "]", e); 204 } catch (IllegalAccessException e) { 205 throw new ContainerException("Illegal access error![" + e.getMessage() + "]", e); 206 } catch (InvocationTargetException e) { 207 throw new ContainerException("Invocation target error![" + e.getMessage() + "]", e); 208 } 209 } 210 211 /*** 212 * @param object 213 * @param config 214 */ 215 private Object setupDependencies(Object component, ComponentDescription desc, ComponentConfig config,boolean start) 216 throws ContainerException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { 217 218 List satisfiedDeps = new ArrayList(); 219 Method[] methods = component.getClass().getMethods(); 220 221 if (config.getNeededObjects() != null) { 222 LOG.info("dependencies: " + config.getNeededObjects()); 223 for (Iterator iter = config.getNeededObjects().iterator(); iter.hasNext();) { 224 ObjectDependency d = (ObjectDependency) iter.next(); 225 Object dependantObject = getComponent(d.getObjectName(),start); 226 LOG.info("set dependant object " + dependantObject + " on " + component); 227 228 ComponentConfig depConfig = loader.getComponentConfig(d.getObjectName()); 229 ClassDependency depDesc = desc.getDependency(depConfig.getClassAlias()); 230 231 String setterMethod = d.getSetterMethodName(); 232 if (setterMethod == null) { 233 if (depDesc != null) { 234 setterMethod = depDesc.getMethodName(); 235 LOG.info("guess setter method :" + config.getClassAlias() + "." + setterMethod + "('" 236 + d.getObjectName() + "') from component description"); 237 } else { 238 // check for 'provide' 239 ComponentDescription depCompDesc = getComponentDescription(depConfig); 240 if (depCompDesc.getProvides() != null) { 241 for (Iterator provIter = depCompDesc.getProvides().iterator(); provIter.hasNext();) { 242 String provide = (String) provIter.next(); 243 depDesc = desc.getDependency(provide); 244 if (depDesc != null) { 245 setterMethod = depDesc.getMethodName(); 246 if (setterMethod != null) { 247 LOG.info("guess setter method :" + config.getClassAlias() + "." + setterMethod 248 + "('" + d.getObjectName() + "') from provided component '" 249 + depDesc.getClassAlias() + "'"); 250 break; 251 } 252 } 253 } 254 } 255 } 256 } 257 258 if (setterMethod != null) { 259 boolean found = false; 260 for (int i = 0; i < methods.length; i++) { 261 if (isMatchingSetter(dependantObject, methods[i], setterMethod)) { 262 263 callSetter(component, dependantObject, depDesc, methods[i]); 264 if (depDesc != null) 265 satisfiedDeps.add(depDesc); 266 found = true; 267 break; 268 } 269 } 270 if (!found) 271 throw new ContainerException("No setter method found as '" + desc.getClassName() + '.' 272 + setterMethod + '(' + d.getObjectName() + ')'); 273 } else { 274 LOG.info("no setter specified for object dependency '" + d.getObjectName() + "' on '" 275 + config.getInstanceName() + "'"); 276 } 277 } 278 } 279 List deps = desc.getDepends(); 280 if (deps != null) { 281 for (int i = 0; i < deps.size(); i++) { 282 ClassDependency dep = (ClassDependency) deps.get(i); 283 if (ClassDependency.REQUIRED.equals(dep.getDependencyType())) { 284 if (!satisfiedDeps.contains(dep)) { 285 List guessedComponents = loader.getObjectsFor(dep.getClassAlias()); 286 if (guessedComponents.size() == 1) { 287 // csak egy darab megfelelo komponens van van a 288 // repository-ban, meg probaljuk beallitani azt 289 290 ComponentConfig depConfig = (ComponentConfig) guessedComponents.get(0); 291 LOG.warn("no explicit dependency provided for " + config.getInstanceName() + '(' 292 + config.getClassAlias() + ") for a '" + dep.getClassAlias() 293 + "', found candidate component:'" + depConfig.getInstanceName() + "'"); 294 295 String setterMethod = dep.getMethodName(); 296 Object dependantObject = getComponent(depConfig.getInstanceName()); 297 298 boolean found = false; 299 for (int j = 0; j < methods.length; j++) { 300 if (isMatchingSetter(dependantObject, methods[j], setterMethod)) { 301 callSetter(component, dependantObject, dep, methods[j]); 302 found = true; 303 break; 304 } 305 } 306 if (!found) 307 throw new ContainerException("No setter method found as '" + desc.getClassName() + '.' 308 + setterMethod + '(' + depConfig.getInstanceName() + ')'); 309 310 } else { 311 throw new ContainerException("Required dependency for " + config.getInstanceName() + '(' 312 + config.getClassAlias() + ") for a '" + dep.getClassAlias() 313 + "' not satisfied! [possible candidate component number:" 314 + guessedComponents.size() + ']'); 315 } 316 } 317 } 318 319 } 320 } 321 322 return component; 323 } 324 325 /*** 326 * @param component 327 * @param dependantObject 328 * @param depDesc 329 * @param methods 330 * @param i 331 * @throws IllegalAccessException 332 * @throws InvocationTargetException 333 */ 334 private void callSetter(Object component, Object dependantObject, ClassDependency depDesc, Method method) 335 throws IllegalAccessException, InvocationTargetException { 336 Object[] params = new Object[1]; 337 LOG.info("found method " + method + " (desc:" + depDesc + ')'); 338 params[0] = dependantObject; 339 method.invoke(component, params); 340 } 341 342 /*** 343 * @param dependantObject 344 * @param methods 345 * @param setterMethod 346 * @param i 347 * @return 348 */ 349 private boolean isMatchingSetter(Object dependantObject, Method method, String setterMethod) { 350 return setterMethod.equals(method.getName()) && (method.getParameterTypes().length == 1) 351 && (method.getParameterTypes()[0].isAssignableFrom(dependantObject.getClass())); 352 } 353 354 /*** 355 * betolti az adott konyvtarban levo osszes .conf.xml -re vegzodo fajlt. 356 * 357 * @param directory 358 * @throws IOException 359 */ 360 public void loadConfigurations(File directory) throws ContainerException { 361 //RepositoryImpl loader = new RepositoryImpl(this); 362 loader.loadConfigurations(directory); 363 loader.run(); 364 //this.loader = loader; 365 } 366 367 public void refreshConfiguration(File directory) throws ContainerException { 368 if (loader == null) 369 throw new ContainerException("RepositoryImpl is null!"); 370 List result = loader.refreshComponents(directory); 371 LOG.info("Found " + result.size() + " new component"); 372 for (int i = 0; i < result.size(); i++) { 373 String instanceName = (String) result.get(i); 374 LOG.info("Init '" + instanceName + "'"); 375 getComponent(instanceName,false); 376 } 377 // start ... 378 for (int i = 0; i < result.size(); i++) { 379 String instanceName = (String) result.get(i); 380 Object component = getComponent(instanceName); 381 ComponentConfig c = loader.getComponentConfig(instanceName); 382 if (component != null) { 383 LOG.info("Start '" + instanceName + "'"); 384 startComponent(component, c); 385 } 386 387 } 388 389 } 390 391 public Object getComponent(String name) throws ContainerException { 392 return getComponent(name,true); 393 } 394 395 public Object getComponent(String name,boolean start) throws ContainerException { 396 Object component = builtComponents.get(name); 397 if (component != null) 398 return component; 399 ComponentConfig config = loader.getComponentConfig(name); 400 if (config == null) 401 throw new ContainerException("No component found with name '" + name + "'!"); 402 component = createComponent(config,start); 403 builtComponents.put(name, component); 404 405 notifyListeners(component, config); 406 if (component instanceof LifecycleListener) { 407 lifecycleListeners.add(component); 408 } 409 if (start) { 410 LOG.info("Start '" + name + "'"); 411 startComponent(component, config); 412 413 } 414 return component; 415 } 416 417 /*** 418 * @param component 419 * @param config 420 */ 421 private void notifyListeners(Object component, ComponentConfig config) { 422 for (Iterator iter = lifecycleListeners.iterator(); iter.hasNext();) { 423 LifecycleListener listener = (LifecycleListener) iter.next(); 424 listener.componentCreated(component, config); 425 } 426 427 } 428 429 protected void notifyReconfigurationListeners(Object component, Object oldConfigBean, ComponentConfig newConfig) { 430 for (Iterator iter = lifecycleListeners.iterator(); iter.hasNext();) { 431 LifecycleListener listener = (LifecycleListener) iter.next(); 432 listener.componentReconfigured(component, oldConfigBean, newConfig); 433 } 434 } 435 436 public List getStartupComponentNames() { 437 return loader.startupComponents; 438 } 439 440 public synchronized void startup() throws ContainerException { 441 if (lifecycle == 0) { 442 lifecycle = 1; 443 } else { 444 throw new ContainerException("Container not in 'INIT' phase![" + lifecycle + ']'); 445 } 446 447 builtComponents.put(Constants.SERVICE_LOCATOR, new ContainerServiceLocator()); 448 builtComponents.put(Constants.RECONFIGURATION_MANAGER, new ContainerReconfigurationManager()); 449 450 try { 451 for (int i = 0; i < loader.vertices.size(); i++) { 452 Vertex v = (Vertex) loader.vertices.get(i); 453 ComponentConfig c = (ComponentConfig) v.getNode(); 454 if (loader.startupComponents.contains(c.getInstanceName())) { 455 LOG.info("component " + v.getName() + " startup"); 456 getComponent(v.getName(),false); 457 LOG.info("succeed"); 458 } else { 459 LOG.info("not startup component " + v.getName() + " [style:" + c.getLifeCycle() + "]"); 460 //getComponent(v.getName()); 461 } 462 } 463 LOG.info("call start methods"); 464 for (int i = 0; i < loader.vertices.size(); i++) { 465 Vertex v = (Vertex) loader.vertices.get(i); 466 ComponentConfig c = (ComponentConfig) v.getNode(); 467 Object component = builtComponents.get(c.getInstanceName()); 468 if (component != null) { 469 startComponent(component, c); 470 } 471 } 472 } catch (ContainerException c) { 473 LOG.warn("startup failed:" + c.getMessage()); 474 stop(); 475 throw c; 476 } 477 478 } 479 480 /*** 481 * @param component 482 * @param c 483 */ 484 private void startComponent(Object component, ComponentConfig config) throws ContainerException { 485 ComponentDescription desc = getComponentDescription(config); 486 // built in component havent got any compDesc. unfortunately. 487 if (desc != null && desc.getStart() != null) { 488 LOG.info("start method('" + desc.getStart() + "') called on " + config.getInstanceName()); 489 try { 490 call(component, desc.lookupClass(), desc.getStart()); 491 } catch (SecurityException e) { 492 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 493 } catch (IllegalArgumentException e) { 494 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 495 } catch (NoSuchMethodException e) { 496 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 497 throw new ContainerException("Class description is not correct, no method '" + desc.getStart() 498 + "' found in " + desc.getClassName(), e); 499 } catch (IllegalAccessException e) { 500 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 501 throw new ContainerException("Class description is not correct, no public method '" + desc.getStart() 502 + "' found in " + desc.getClassName(), e); 503 } catch (InvocationTargetException e) { 504 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 505 throw new ContainerException("Runtime error at '" + desc.getStart() + "' in " 506 + config.getInstanceName() + '(' + desc.getClassName() + ')', e.getTargetException()); 507 } catch (ClassNotFoundException e) { 508 LOG.warn("error during starting component:" + config.getInstanceName() + ':' + e.getMessage(), e); 509 } 510 } 511 512 } 513 514 public void stop() throws ContainerException { 515 if (lifecycle == 1) { 516 lifecycle = 2; 517 } else { 518 throw new ContainerException("Container not in 'STARTED' phase![" + lifecycle + ']'); 519 } 520 LOG.info("call stop methods"); 521 for (int i = loader.vertices.size() - 1; 0 <= i; i--) { 522 Vertex v = (Vertex) loader.vertices.get(i); 523 ComponentConfig c = (ComponentConfig) v.getNode(); 524 Object component = builtComponents.get(c.getInstanceName()); 525 if (component != null) { 526 stopComponent(component, c); 527 } 528 } 529 LOG.info("container finished."); 530 531 } 532 533 /*** 534 * @param c 535 */ 536 private void stopComponent(Object component, ComponentConfig config) throws ContainerException { 537 ComponentDescription desc = getComponentDescription(config); 538 539 if (desc != null && desc.getStop() != null) { 540 LOG.info("stop method('" + desc.getStop() + "') called on " + config.getInstanceName()); 541 try { 542 call(component, desc.lookupClass(), desc.getStop()); 543 } catch (SecurityException e) { 544 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 545 } catch (IllegalArgumentException e) { 546 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 547 } catch (NoSuchMethodException e) { 548 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 549 throw new ContainerException("Class description is not correct, no method '" + desc.getStop() 550 + "' found in " + desc.getClassName(), e); 551 } catch (IllegalAccessException e) { 552 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 553 throw new ContainerException("Class description is not correct, no public method '" + desc.getStop() 554 + "' found in " + desc.getClassName(), e); 555 } catch (InvocationTargetException e) { 556 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 557 throw new ContainerException("Runtime error at '" + desc.getStop() + "' in " 558 + config.getInstanceName() + '(' + desc.getClassName() + ')', e.getTargetException()); 559 } catch (ClassNotFoundException e) { 560 LOG.warn("error during stopping component:" + config.getInstanceName() + ':' + e.getMessage(), e); 561 } 562 } 563 } 564 565 /*** 566 * @param component 567 * @param class1 568 * @param string 569 * @param object 570 */ 571 private void call(Object component, Class class1, String string) throws SecurityException, NoSuchMethodException, 572 IllegalArgumentException, IllegalAccessException, InvocationTargetException { 573 Method m = class1.getMethod(string, new Class[0]); 574 m.invoke(component, new Object[0]); 575 } 576 577 public XStream getXStream() { 578 return xstream; 579 } 580 581 /*** 582 * Teszt metodus. 583 * 584 * @deprecated @param 585 * conf 586 * @return 587 */ 588 public String getAsXML(ComponentConfig conf) { 589 return xstream.toXML(conf); 590 } 591 592 593 class ContainerServiceLocator implements ServiceLocator { 594 /* 595 * (non-Javadoc) 596 * 597 * @see net.sf.bigyo.container.ServiceLocator#getComponent(java.lang.String) 598 */ 599 public Object getComponent(String name) { 600 return Main.this.builtComponents.get(name); 601 } 602 603 } 604 605 606 class ContainerReconfigurationManager implements ReconfigurationManager { 607 608 /* 609 * (non-Javadoc) 610 * 611 * @see net.sf.bigyo.api.ReconfigurationManager#reconfigureComponent(net.sf.bigyo.model.ComponentConfig) 612 */ 613 public void reconfigureComponent(ComponentConfig newConfig) { 614 LOG.info("reconfigure component " + newConfig + " bean:" + newConfig.getConfigBean()); 615 Main.this.loader.reconfigureComponent(newConfig); 616 } 617 } 618 619 /*** 620 * @param c 621 * @return 622 */ 623 ComponentDescription getComponentDescription(ComponentConfig c) { 624 return registry.getComponentDescription(c); 625 } 626 627 public boolean hasProfile(String name) { 628 assert checker != null : "No ProfileChecker provided!"; 629 return checker.hasProfile(name); 630 } 631 632 /*** 633 * @return Returns the compactReflectionConverter. 634 */ 635 public CompactReflectionConverter getCompactReflectionConverter() { 636 return compactReflectionConverter; 637 } 638 639 /*** 640 * @return Returns the checker. 641 */ 642 public ProfileChecker getProfileChecker() { 643 return checker; 644 } 645 646 /*** 647 * @param checker 648 * The checker to set. 649 */ 650 public void setProfileChecker(ProfileChecker checker) { 651 this.checker = checker; 652 } 653 654 655 public class ConfigurationChecker implements Runnable { 656 657 int sleepTime; 658 String directory; 659 660 /*** 661 * @param container 662 * @param directory 663 * @param sleepTime 664 */ 665 public ConfigurationChecker(String directory, int sleepTime) { 666 this.directory = directory; 667 this.sleepTime = sleepTime; 668 } 669 670 /* 671 * (non-Javadoc) 672 * 673 * @see java.lang.Runnable#run() 674 */ 675 public void run() { 676 try { 677 while (true) { 678 Thread.sleep(sleepTime); 679 LOG.info("checking '" + directory + "'"); 680 try { 681 Main.this.refreshConfiguration(new File(directory)); 682 } catch (ContainerException e1) { 683 LOG.warn("Error during checking configuration:" + e1.getMessage(), e1); 684 } 685 } 686 } catch (InterruptedException e) { 687 LOG.warn("Interrupted exception " + e.getMessage(), e); 688 } 689 } 690 691 } 692 693 }

This page was automatically generated by Maven