1 38 39 package org.jahia.services.cache; 40 41 import org.jahia.exceptions.JahiaInitializationException; 42 43 44 53 class JMSHubLookup implements Runnable { 54 55 56 final private static org.apache.log4j.Logger logger = 57 org.apache.log4j.Logger.getLogger (JMSHubLookup.class); 58 59 60 private long sleep; 61 62 63 private boolean running; 64 65 66 private JMSHub jmsHub; 67 68 69 74 public JMSHubLookup (JMSHub hub, long sleep) { 75 this.sleep = sleep; 76 this.jmsHub = hub; 77 running = false; 78 79 logger.debug ("New JMSHubLookup successfully instanciated!"); 80 } 81 82 85 public void run () { 86 running = true; 87 while (running) { 88 89 try { 90 jmsHub.internalConnect(); 91 running = false; 92 93 } catch (JahiaInitializationException e) { 94 logger.warn (e); 95 96 } catch (JMSConnectionException e) { 97 logger.warn (e); 98 } 99 100 synchronized (this) { 101 try { 102 if (running) { 103 logger.info ("Try to recontact the JMS Server in "+ sleep +" milliseconds."); 104 wait (sleep); } 106 } catch (InterruptedException ie) { 107 } 109 } 110 } 111 } 112 113 114 116 public synchronized void stop () { 117 running = false; 118 notifyAll(); 119 } 120 121 } 122 | Popular Tags |