From: <bsc...@us...> - 2009-01-26 12:50:21
|
Revision: 4055 http://unicore.svn.sourceforge.net/unicore/?rev=4055&view=rev Author: bschuller Date: 2009-01-26 12:47:50 +0000 (Mon, 26 Jan 2009) Log Message: ----------- nicer logging, watch log config file and re-configure if it was modified Modified Paths: -------------- gateway/trunk/docs/GW.doc gateway/trunk/src/main/java/eu/unicore/gateway/ConsignorProducer.java gateway/trunk/src/main/java/eu/unicore/gateway/DynamicSiteOrganiser.java gateway/trunk/src/main/java/eu/unicore/gateway/Gateway.java gateway/trunk/src/main/java/eu/unicore/gateway/GatewayHandler.java gateway/trunk/src/main/java/eu/unicore/gateway/GatewayProperties.java gateway/trunk/src/main/java/eu/unicore/gateway/StaticSiteOrganiser.java gateway/trunk/src/main/java/eu/unicore/gateway/VSite.java gateway/trunk/src/main/java/eu/unicore/gateway/WSAHandler.java gateway/trunk/src/main/java/eu/unicore/gateway/base/AuthSSLX509TrustManager.java gateway/trunk/src/main/java/eu/unicore/gateway/base/CustomSslSocketConnector.java gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyLogger.java gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyServer.java gateway/trunk/src/main/java/eu/unicore/gateway/base/ProxyValidatorFactory.java gateway/trunk/src/main/java/eu/unicore/gateway/base/Servlet.java gateway/trunk/src/main/java/eu/unicore/gateway/client/AuthSSLProtocolSocketFactory.java gateway/trunk/src/main/java/eu/unicore/gateway/client/HttpClientFactory.java gateway/trunk/src/main/java/eu/unicore/gateway/properties/SecurityProperties.java gateway/trunk/src/main/java/eu/unicore/gateway/soap/Soap12.java gateway/trunk/src/main/java/eu/unicore/gateway/soap/SoapVersion.java gateway/trunk/src/main/java/eu/unicore/gateway/util/CustomHttpConnection.java gateway/trunk/src/main/java/eu/unicore/gateway/util/UpdateProtocolMethod.java Added Paths: ----------- gateway/trunk/src/main/java/eu/unicore/gateway/util/FileWatcher.java Modified: gateway/trunk/docs/GW.doc =================================================================== (Binary files differ) Modified: gateway/trunk/src/main/java/eu/unicore/gateway/ConsignorProducer.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/ConsignorProducer.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/ConsignorProducer.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -56,8 +56,7 @@ */ public class ConsignorProducer { - private static final Logger log = Logger.getLogger( - ConsignorProducer.class.getName()); + private static final Logger log = Logger.getLogger("unicore.gateway."+ConsignorProducer.class.getSimpleName()); //last CACHE_SIZE tokens are cached (but only if not-signed mode is on). private static final int CACHE_SIZE = 8; private String myDN; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/DynamicSiteOrganiser.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/DynamicSiteOrganiser.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/DynamicSiteOrganiser.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -4,7 +4,7 @@ import org.apache.log4j.Logger; public class DynamicSiteOrganiser extends BaseSiteOrganiser { - Logger logger=Logger.getLogger(DynamicSiteOrganiser.class); + private static final Logger logger=Logger.getLogger("unicore.gateway."+DynamicSiteOrganiser.class.getSimpleName()); public boolean register(String name, URI realURI){ try{ Modified: gateway/trunk/src/main/java/eu/unicore/gateway/Gateway.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/Gateway.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/Gateway.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -29,8 +29,12 @@ package eu.unicore.gateway; +import java.io.File; +import java.io.FileNotFoundException; import java.net.URI; import java.util.Calendar; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; @@ -40,6 +44,7 @@ import eu.unicore.gateway.base.JettyServer; import eu.unicore.gateway.client.HttpClientFactory; import eu.unicore.gateway.properties.SecurityProperties; +import eu.unicore.gateway.util.FileWatcher; import eu.unicore.gateway.util.ProtocolPluginHandler; import eu.unicore.security.CertificateUtils; @@ -48,9 +53,9 @@ */ public class Gateway { - public static final String VERSION="1.1.3"; + public static final String VERSION="1.2.0"; - private static final Logger log = Logger.getLogger(Gateway.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+Gateway.class.getSimpleName()); private static SiteOrganiser organiser; @@ -145,6 +150,30 @@ jetty.start(); } + + + /** + * sets up a watchdog that checks for changes to the log4j configuration file, + * and re-configures log4j if that file has changed + */ + private void startLogConfigWatcher(){ + final String logConfig=System.getProperty("log4j.configuration"); + try{ + Runnable r=new Runnable(){ + public void run(){ + log.info("LOG CONFIG MODIFIED, re-configuring."); + PropertyConfigurator.configure(logConfig); + } + }; + FileWatcher fw=new FileWatcher(new File(logConfig),r); + Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(fw, 5, 5, TimeUnit.SECONDS); + }catch(FileNotFoundException fex){ + log.warn("Log configuration file <"+logConfig+"> not found."); + } + } + + + public static void main(String[] args) throws Exception { String message="UNICORE Gateway "+VERSION+" starting."; @@ -170,7 +199,6 @@ Gateway.setSiteOrganiser(organiser); securityProperties=new SecurityProperties(); HttpClientFactory.getInstance(securityProperties, gatewayProperties); - PropertyConfigurator.configure("conf/logging.properties"); //init crl checker stuff String crlProps=System.getProperty("crlmanager.properties.file"); @@ -184,7 +212,9 @@ } } - new Gateway(hostURI, securityProperties).start(); + Gateway gw=new Gateway(hostURI, securityProperties); + gw.startLogConfigWatcher(); + gw.start(); message="Startup complete."; log.info(message); System.out.println(message); Modified: gateway/trunk/src/main/java/eu/unicore/gateway/GatewayHandler.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/GatewayHandler.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/GatewayHandler.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -82,7 +82,7 @@ */ public class GatewayHandler implements eu.unicore.gateway.base.Handler { - protected static Logger log=Logger.getLogger(GatewayHandler.class); + protected static final Logger log=Logger.getLogger("unicore.gateway."+GatewayHandler.class.getSimpleName()); private boolean chunked = false; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/GatewayProperties.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/GatewayProperties.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/GatewayProperties.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -37,7 +37,8 @@ public class GatewayProperties extends RingoProperties { - private static final Logger log = Logger.getLogger(GatewayProperties.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+GatewayProperties.class.getSimpleName()); + public static final String CLASSPATH_GATEWAY_PROPERTIES = "/gateway.properties"; public static final File FILE_GATEWAY_PROPERTIES = new File("."+File.separator+"conf"+File.separator+"gateway.properties"); Modified: gateway/trunk/src/main/java/eu/unicore/gateway/StaticSiteOrganiser.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/StaticSiteOrganiser.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/StaticSiteOrganiser.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -44,7 +44,7 @@ public class StaticSiteOrganiser extends BaseSiteOrganiser { - private static final Logger log = Logger.getLogger(StaticSiteOrganiser.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+StaticSiteOrganiser.class.getSimpleName()); private ConnectionsProperties props; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/VSite.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/VSite.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/VSite.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -41,7 +41,7 @@ public class VSite extends Site { - private static final Logger log = Logger.getLogger(VSite.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+VSite.class.getSimpleName()); private final String name; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/WSAHandler.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/WSAHandler.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/WSAHandler.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -11,7 +11,7 @@ public class WSAHandler implements Handler { - public static String WSA_200508_NAMESPACE="http://www.w3.org/2005/08/addressing"; + public static final String WSA_200508_NAMESPACE="http://www.w3.org/2005/08/addressing"; //deal with wsa headers public void invoke(MessageExchange exchange) throws Exception { Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/AuthSSLX509TrustManager.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/AuthSSLX509TrustManager.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/AuthSSLX509TrustManager.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -55,8 +55,7 @@ private X509TrustManager defaultTrustManager = null; - private static final Logger LOG = Logger - .getLogger(AuthSSLX509TrustManager.class); + private static final Logger LOG = Logger.getLogger("unicore.gateway."+AuthSSLX509TrustManager.class.getSimpleName()); /** * Constructor for AuthSSLX509TrustManager. Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/CustomSslSocketConnector.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/CustomSslSocketConnector.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/CustomSslSocketConnector.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -67,7 +67,7 @@ public class CustomSslSocketConnector extends SslSocketConnector { - Logger log=Logger.getLogger(CustomSslSocketConnector.class); + private final static Logger log=Logger.getLogger(CustomSslSocketConnector.class); private transient Password password; private transient Password keyPassword; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyLogger.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyLogger.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyLogger.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -11,7 +11,7 @@ */ public class JettyLogger implements Logger { - private static org.apache.log4j.Logger log=org.apache.log4j.Logger.getLogger("eu.unicore.gateway.Jetty"); + private static final org.apache.log4j.Logger log=org.apache.log4j.Logger.getLogger("unicore.gateway."+JettyLogger.class.getSimpleName()); public void debug(String msg, Throwable th) { log.debug(msg, th); Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyServer.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyServer.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/JettyServer.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -59,8 +59,9 @@ * @author schuller */ public class JettyServer { - protected static Logger logger=Logger.getLogger(JettyServer.class); + private static final Logger logger=Logger.getLogger("unicore.gateway."+JettyServer.class.getSimpleName()); + private Server theServer; private URI url; private int port; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/ProxyValidatorFactory.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/ProxyValidatorFactory.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/ProxyValidatorFactory.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -14,7 +14,7 @@ */ public class ProxyValidatorFactory { - private static final Logger LOG = Logger.getLogger(ProxyValidatorFactory.class); + private static final Logger LOG = Logger.getLogger("unicore.gateway."+ProxyValidatorFactory.class.getSimpleName()); /** * Modified: gateway/trunk/src/main/java/eu/unicore/gateway/base/Servlet.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/base/Servlet.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/base/Servlet.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -57,7 +57,6 @@ import eu.unicore.gateway.SiteOrganiser; import eu.unicore.gateway.VSite; import eu.unicore.gateway.client.HttpClientFactory; -import eu.unicore.gateway.util.ProtocolPluginHandler; /** * Simple servlet for doing GET, PUT and POST<br/> @@ -66,8 +65,10 @@ * the headers in the request. */ public class Servlet extends HttpServlet { - protected static final long serialVersionUID=2L; - protected static Logger logger=Logger.getLogger(Servlet.class); + + private static final long serialVersionUID=2L; + + private static final Logger logger=Logger.getLogger("unicore.gateway."+Servlet.class.getSimpleName()); @Override Modified: gateway/trunk/src/main/java/eu/unicore/gateway/client/AuthSSLProtocolSocketFactory.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/client/AuthSSLProtocolSocketFactory.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/client/AuthSSLProtocolSocketFactory.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -62,7 +62,7 @@ public class AuthSSLProtocolSocketFactory implements SecureProtocolSocketFactory { - private static final Logger LOG =Logger.getLogger(AuthSSLProtocolSocketFactory.class); + private static final Logger LOG =Logger.getLogger("unicore.gateway."+AuthSSLProtocolSocketFactory.class.getSimpleName()); private SSLContext sslcontext = null; @@ -153,7 +153,7 @@ if (sec.getKeystore()!= null) { KeyStore keystore = createKeyStore(sec.getKeystore(),sec.getKeystorePassword(),sec.getKeystoreType(),sec.getKeystoreAlias()); if (LOG.isDebugEnabled()) { - Enumeration aliases = keystore.aliases(); + Enumeration<String> aliases = keystore.aliases(); while (aliases.hasMoreElements()) { String alias = (String)aliases.nextElement(); Certificate[] certs = keystore.getCertificateChain(alias); @@ -178,7 +178,7 @@ if (sec.getTruststore() != null) { KeyStore truststore = createKeyStore(sec.getTruststore(),sec.getTruststorePassword(),sec.getTruststoreType(),null); if (LOG.isDebugEnabled()) { - Enumeration aliases = truststore.aliases(); + Enumeration<String> aliases = truststore.aliases(); while (aliases.hasMoreElements()) { String alias = (String)aliases.nextElement(); LOG.debug("Trusted certificate '" + alias + "':"); Modified: gateway/trunk/src/main/java/eu/unicore/gateway/client/HttpClientFactory.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/client/HttpClientFactory.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/client/HttpClientFactory.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -48,7 +48,7 @@ public class HttpClientFactory { - private static final Logger log = Logger.getLogger(HttpClientFactory.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+HttpClientFactory.class.getSimpleName()); private int sockettimeout; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/properties/SecurityProperties.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/properties/SecurityProperties.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/properties/SecurityProperties.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -31,7 +31,6 @@ import java.io.File; -import org.apache.commons.logging.Log; import org.apache.log4j.Logger; import eu.unicore.gateway.util.RProperties; @@ -39,7 +38,7 @@ public class SecurityProperties extends RProperties { - private static final Logger log = Logger.getLogger(SecurityProperties.class); + private static final Logger log = Logger.getLogger("unicore.gateway."+SecurityProperties.class.getSimpleName()); public static final String CLASSPATH_SECURITY_PROPERTIES = "/security.properties"; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/soap/Soap12.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/soap/Soap12.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/soap/Soap12.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -26,8 +26,6 @@ /** * Represents the SOAP 1.2 version - * - * @version $Revision: 1.6 $ */ public class Soap12 implements SoapVersion { public static final String XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"; Modified: gateway/trunk/src/main/java/eu/unicore/gateway/soap/SoapVersion.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/soap/SoapVersion.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/soap/SoapVersion.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -23,7 +23,7 @@ import javax.xml.stream.XMLStreamWriter; /** - * @version $Revision: 1.4 $ + * used to identify the SOAP version used in the current message exchange */ public interface SoapVersion { Modified: gateway/trunk/src/main/java/eu/unicore/gateway/util/CustomHttpConnection.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/util/CustomHttpConnection.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/util/CustomHttpConnection.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -20,7 +20,7 @@ */ public class CustomHttpConnection extends HttpConnection { - protected static Logger logger=Logger.getLogger(CustomHttpConnection.class); + private static final Logger logger=Logger.getLogger("unicore.gateway."+CustomHttpConnection.class.getSimpleName()); public CustomHttpConnection(Connector connector, EndPoint endpoint, Server server) { super(connector, endpoint, server); Added: gateway/trunk/src/main/java/eu/unicore/gateway/util/FileWatcher.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/util/FileWatcher.java (rev 0) +++ gateway/trunk/src/main/java/eu/unicore/gateway/util/FileWatcher.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -0,0 +1,42 @@ +package eu.unicore.gateway.util; + +import java.io.File; +import java.io.FileNotFoundException; + +/** + * helper to watch a file and invoke a specific action if it was modified. + * This should be executed periodically, for example using a scheduled executor + * service. + * + * @author schuller + */ +public class FileWatcher implements Runnable{ + + private final File target; + + private final Runnable action; + + private long lastAccessed; + + public FileWatcher(File target, Runnable action)throws FileNotFoundException{ + if(!target.exists() || !target.canRead()){ + throw new FileNotFoundException("File "+target.getAbsolutePath()+ + " does not exist or is not readable."); + } + this.target=target; + this.action=action; + lastAccessed=target.lastModified(); + } + + /** + * check if target file has been touched and invoke + * the action if it has + */ + public void run(){ + if(target.lastModified()>lastAccessed){ + lastAccessed=target.lastModified(); + action.run(); + } + } + +} Modified: gateway/trunk/src/main/java/eu/unicore/gateway/util/UpdateProtocolMethod.java =================================================================== --- gateway/trunk/src/main/java/eu/unicore/gateway/util/UpdateProtocolMethod.java 2009-01-26 09:11:24 UTC (rev 4054) +++ gateway/trunk/src/main/java/eu/unicore/gateway/util/UpdateProtocolMethod.java 2009-01-26 12:47:50 UTC (rev 4055) @@ -17,7 +17,7 @@ */ public class UpdateProtocolMethod extends ExpectContinueMethod { - private ProtocolPluginHandler handler; + private final ProtocolPluginHandler handler; /** * construct a new method and pass in the custom protocol handler This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |