User: user57
Date: 01/12/08 22:05:49
Modified: jetty/src/main/org/jboss/jetty JBossLogSink.java
JBossUserRealm.java JBossWebApplicationContext.java
Jetty.java JettyResolver.java JettyService.java
Log:
o Using jboss Logger instead of Category
o Each class uses its own Logger, so it is easier to track down where
the messages come from (unless they are part of the sink then who knows)
o Changed some startup logs from info to debug
Revision Changes Path
1.8 +15 -13 contrib/jetty/src/main/org/jboss/jetty/JBossLogSink.java
Index: JBossLogSink.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossLogSink.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JBossLogSink.java 2001/11/21 23:13:01 1.7
+++ JBossLogSink.java 2001/12/09 06:05:49 1.8
@@ -5,45 +5,47 @@
* See terms of license at gnu.org.
*/
-// $Id: JBossLogSink.java,v 1.7 2001/11/21 23:13:01 jules_gosnell Exp $
+// $Id: JBossLogSink.java,v 1.8 2001/12/09 06:05:49 user57 Exp $
package org.jboss.jetty;
import java.util.HashMap;
-import org.apache.log4j.Category;
+
import org.mortbay.util.Code;
import org.mortbay.util.Frame;
import org.mortbay.util.Log;
import org.mortbay.util.LogSink;
+import org.jboss.logging.Logger;
+
/* ------------------------------------------------------------ */
/**
* This class bidges the API between Jetty and Log4J.
*
* @author <a href="mailto:">Jules Gosnell</a>
- * @version $Id: JBossLogSink.java,v 1.7 2001/11/21 23:13:01 jules_gosnell Exp $
+ * @version $Id: JBossLogSink.java,v 1.8 2001/12/09 06:05:49 user57 Exp $
* @since 1.0
* @see org.mortbay.util.LogSink
*/
public class JBossLogSink
implements LogSink
{
- Category _log;
+ Logger _log;
boolean _started = false;
HashMap _dispatch = new HashMap();
- interface Logger {void log(String s);}
+ interface MyLogger {void log(String s);}
public
JBossLogSink()
{
// populate the dispatch map...
- _dispatch.put(Log.DEBUG, new Logger(){public void log(String
s){_log.debug(s);}});
- _dispatch.put(Log.EVENT, new Logger(){public void log(String
s){_log.info(s);}});
- _dispatch.put(Log.WARN, new Logger(){public void log(String
s){_log.warn("WARNING: "+s);}});
- _dispatch.put(Log.ASSERT, new Logger(){public void log(String
s){_log.error(s);}});
- _dispatch.put(Log.FAIL, new Logger(){public void log(String
s){_log.error(s);}});
+ _dispatch.put(Log.DEBUG, new MyLogger(){public void log(String
s){_log.debug(s);}});
+ _dispatch.put(Log.EVENT, new MyLogger(){public void log(String
s){_log.info(s);}});
+ _dispatch.put(Log.WARN, new MyLogger(){public void log(String
s){_log.warn("WARNING: "+s);}});
+ _dispatch.put(Log.ASSERT, new MyLogger(){public void log(String
s){_log.error(s);}});
+ _dispatch.put(Log.FAIL, new MyLogger(){public void log(String
s){_log.error(s);}});
}
// 'LifeCycle' interface
@@ -51,7 +53,7 @@
initialize(Object log)
throws InterruptedException
{
- _log = (Category) log;
+ _log = (Logger) log;
}
public void
@@ -143,7 +145,7 @@
{
boolean debugging=Code.debug();
- Logger logger=(Logger)_dispatch.get(tag);
+ MyLogger logger=(MyLogger)_dispatch.get(tag);
if (logger!=null)
{
logger.log(msg+(debugging?", "+frame:""));
@@ -151,7 +153,7 @@
else
{
log(msg+" - "+tag+(debugging?", "+frame:""));
- _log.warn("WARNING: JBossLogSink doesn't understand tag: '"+tag+"'");
+ _log.warn("JBossLogSink doesn't understand tag: '"+tag+"'");
}
}
1.10 +17 -13 contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java
Index: JBossUserRealm.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossUserRealm.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JBossUserRealm.java 2001/12/03 04:15:51 1.9
+++ JBossUserRealm.java 2001/12/09 06:05:49 1.10
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: JBossUserRealm.java,v 1.9 2001/12/03 04:15:51 starksm Exp $
+// $Id: JBossUserRealm.java,v 1.10 2001/12/09 06:05:49 user57 Exp $
package org.jboss.jetty;
@@ -16,7 +16,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.security.auth.Subject;
-import org.apache.log4j.Category;
+
import org.jboss.security.AuthenticationManager;
import org.jboss.security.RealmMapping;
import org.jboss.security.SecurityAssociation;
@@ -26,10 +26,12 @@
import org.mortbay.http.UserPrincipal;
import org.mortbay.http.UserRealm;
+import org.jboss.logging.Logger;
+
/** An implementation of UserRealm that integrates with the JBossSX
* security manager associted with the web application.
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
// TODO
@@ -44,7 +46,7 @@
JBossUserPrincipal(String name)
{
super(name);
- _log.info("Security- created JBossUserRealm::JBossUserPrincipal: "+name);
+ _log.info("created JBossUserRealm::JBossUserPrincipal: "+name);
}
public boolean
@@ -81,10 +83,10 @@
password="";
char[] passwordChars = password.toCharArray();
- _log.info("Security- authenticating: Name:"+userName+" Password:"+password);
+ _log.info("authenticating: Name:"+userName+" Password:"+password);
if(_securityMgr!=null &&_securityMgr.isValid(this, passwordChars))
{
- _log.info("Security- JBossUserPrincipal: "+userName+" is authenticated");
+ _log.info("JBossUserPrincipal: "+userName+" is authenticated");
SecurityAssociation.setPrincipal(this);
SecurityAssociation.setCredential(passwordChars);
authenticated=true;
@@ -100,7 +102,7 @@
}
else
{
- _log.warn("WARNING: Security- JBossUserPrincipal: "+userName+" is NOT
authenticated");
+ _log.warn("JBossUserPrincipal: "+userName+" is NOT authenticated");
}
return authenticated;
@@ -115,12 +117,12 @@
Set requiredRoles = Collections.singleton(new SimplePrincipal(role));
if(_realmMapping!=null && _realmMapping.doesUserHaveRole(this, requiredRoles))
{
- _log.info("Security- JBossUserPrincipal: "+userName+" is in Role: "+role);
+ _log.info("JBossUserPrincipal: "+userName+" is in Role: "+role);
isUserInRole = true;
}
else
{
- _log.warn("WARNING: Security- JBossUserPrincipal: "+userName+" is NOT in Role:
"+role);
+ _log.warn("JBossUserPrincipal: "+userName+" is NOT in Role: "+role);
}
return isUserInRole;
@@ -133,7 +135,7 @@
}
}
- private Category _log=Category.getInstance("Jetty");
+ private Logger _log;
private String _realmName;
private AuthenticationManager _securityMgr;
private RealmMapping _realmMapping;
@@ -145,7 +147,9 @@
JBossUserRealm(String realmName)
{
_realmName = realmName;
- _log.info("Security- created JBossUserRealm: "+_realmName);
+
+ _log = Logger.getLogger(JBossUserRealm.class.getName() + "#" + _realmName);
+ _log.info("initializing");
try
{
@@ -162,7 +166,7 @@
}
catch (NamingException e)
{
- _log.error("ERROR: Security- Could not create initial Context", e);
+ _log.error("Could not create initial Context", e);
}
}
@@ -192,7 +196,7 @@
public UserPrincipal
getUser(String userName)
{
- _log.info("Security- JBossUserPrincipal: "+userName);
+ _log.info("JBossUserPrincipal: "+userName);
return ensureUser(userName);
}
1.10 +20 -19
contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java
Index: JBossWebApplicationContext.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JBossWebApplicationContext.java 2001/12/05 01:32:23 1.9
+++ JBossWebApplicationContext.java 2001/12/09 06:05:49 1.10
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: JBossWebApplicationContext.java,v 1.9 2001/12/05 01:32:23 jules_gosnell Exp
$
+// $Id: JBossWebApplicationContext.java,v 1.10 2001/12/09 06:05:49 user57 Exp $
// A Jetty HttpServer with the interface expected by JBoss'
// J2EEDeployer...
@@ -16,9 +16,9 @@
import java.net.URL;
import java.net.URLClassLoader;
import javax.xml.parsers.DocumentBuilder;
-import org.apache.log4j.Category;
import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
import org.jboss.web.WebApplication;
+import org.jboss.logging.Logger;
import org.mortbay.http.ContextLoader;
import org.mortbay.http.HttpServer;
import org.mortbay.http.handler.SecurityHandler;
@@ -30,7 +30,7 @@
JBossWebApplicationContext
extends WebApplicationContext
{
- Category _log;
+ Logger _log;
WebDescriptorParser _descriptorParser;
WebApplication _webApp;
DocumentBuilder _parser;
@@ -38,14 +38,15 @@
public
JBossWebApplicationContext(HttpServer httpServer,
String contextPathSpec,
- Category log,
WebDescriptorParser descriptorParser,
WebApplication webApp,
DocumentBuilder parser)
{
super(httpServer, contextPathSpec);
- _log = log;
+ _log = Logger.getLogger(JBossWebApplicationContext.class.getName() +
+ "#" + contextPathSpec);
+
_descriptorParser = descriptorParser;
_webApp = webApp;
_parser = parser;
@@ -153,12 +154,12 @@
if (url.getProtocol().equals("file"))
classpath+=(classpath.length()==0?"":separator)+url.getPath();
else
- _log.warn("WARNING: non-file URL encountered in ClassLoader - jsp
compilation may fail");
+ _log.warn("non-file URL encountered in ClassLoader - jsp compilation may
fail");
}
}
else
{
- _log.warn("WARNING: non URLClassLoader("+cl+") encountered - jsp compilation
may fail");
+ _log.warn("non URLClassLoader("+cl+") encountered - jsp compilation may
fail");
}
}
@@ -173,7 +174,7 @@
}
catch (Exception e)
{
- _log.warn("WARNING: could not find Servlet API jar", e);
+ _log.warn("could not find Servlet API jar", e);
}
try
@@ -183,7 +184,7 @@
}
catch (Exception e)
{
- _log.warn("WARNING: could not find Jasper jar", e);
+ _log.warn("could not find Jasper jar", e);
}
try
@@ -193,10 +194,10 @@
}
catch (Exception e)
{
- _log.warn("WARNING: could not find J2EE jar", e);
+ _log.warn("could not find J2EE jar", e);
}
- _log.info("default JSP CLASSPATH:"+classpath);
+ _log.info("default JSP CLASSPATH: "+classpath);
return classpath;
}
@@ -222,7 +223,7 @@
// }
// catch (Exception e)
// {
- // _log.warn("WARNING: could not find Servlet API jar", e);
+ // _log.warn("could not find Servlet API jar", e);
// }
//
// try
@@ -232,7 +233,7 @@
// }
// catch (Exception e)
// {
- // _log.warn("WARNING: could not find Jasper jar", e);
+ // _log.warn("could not find Jasper jar", e);
// }
//
// _log.info("default JSP CLASSPATH:"+fileClassPath);
@@ -264,7 +265,7 @@
}
catch (Exception e)
{
- _log.error("ERROR: problem locating web.xml");
+ _log.error("problem locating web.xml", e);
}
try
@@ -276,24 +277,24 @@
}
catch (FileNotFoundException e)
{
- _log.info("no jboss-web.xml found");
+ _log.debug("no jboss-web.xml found");
}
catch (Exception e)
{
- _log.error("ERROR: problem locating jboss-web.xml");
+ _log.error("problem locating jboss-web.xml", e);
}
try
{
- _log.info("setting up ENC...");
+ _log.debug("setting up ENC...");
_descriptorParser.parseWebAppDescriptors(_webApp.getClassLoader(),
_webApp.getWebApp(),
_webApp.getJbossWeb());
- _log.info("setting up ENC succeeded");
+ _log.debug("setting up ENC succeeded");
}
catch (Exception e)
{
- _log.error("ERROR: setting up ENC failed");
+ _log.error("failed to setup ENC", e);
}
}
}
1.30 +18 -18 contrib/jetty/src/main/org/jboss/jetty/Jetty.java
Index: Jetty.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/Jetty.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Jetty.java 2001/12/05 01:32:26 1.29
+++ Jetty.java 2001/12/09 06:05:49 1.30
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: Jetty.java,v 1.29 2001/12/05 01:32:26 jules_gosnell Exp $
+// $Id: Jetty.java,v 1.30 2001/12/09 06:05:49 user57 Exp $
// A Jetty HttpServer with the interface expected by JBoss'
// J2EEDeployer...
@@ -16,18 +16,18 @@
import java.util.Hashtable;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.log4j.Category;
import org.jboss.deployment.DeploymentException;
import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
import org.jboss.web.WebApplication;
import org.mortbay.jetty.servlet.WebApplicationContext;
+import org.jboss.logging.Logger;
/**
* <description>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Julian Gosnell</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
- * @version $Revision: 1.29 $
+ * @version $Revision: 1.30 $
*
* <p><b>Revisions:</b>
*
@@ -45,15 +45,14 @@
{
static DocumentBuilderFactory _factory=DocumentBuilderFactory.newInstance();
DocumentBuilder _parser;
- Category _log;
+ Logger _log = Logger.getLogger(Jetty.class);
- Jetty(Category log)
+ Jetty()
{
super();
- _log=log;
// resolver should be populated from a configuration file.
- JettyResolver resolver=new JettyResolver(_log);
+ JettyResolver resolver = new JettyResolver();
// populate dtd resolver
URL stdWeb22=findResourceInJar("javax/servlet/resources/web-app_2_2.dtd");
@@ -73,13 +72,13 @@
}
catch (Exception e)
{
- _log.error("ERROR: problem building descriptor parser", e);
+ _log.error("problem building descriptor parser", e);
}
// check support for JSP compilation...
if
(findResourceInJar("com/sun/tools/javac/v8/resources/javac.properties")==null)
- _log.warn("WARNING: JSP compilation requires $JAVA_HOME/lib/tools.jar on your
JBOSS_CLASSPATH");
+ _log.warn("JSP compilation requires $JAVA_HOME/lib/tools.jar on your
JBOSS_CLASSPATH");
}
//----------------------------------------
@@ -152,14 +151,14 @@
try
{
- _log.info("loading config: "+configUrl);
+ _log.info("loading configuration: "+configUrl);
configure(configUrl);
- _log.info("loaded config: "+configUrl);
+ _log.debug("configuratin loaded");
_configuration=configUrl;
}
catch (Exception e)
{
- _log.error("ERROR: problem loading configuration: "+configUrl, e);
+ _log.error("problem loading configuration: "+configUrl, e);
}
}
@@ -188,10 +187,11 @@
// check whether the context already exists... - a bit hacky,
// could be nicer...
if (getContext(null, contextPath, 0)!=null)
- _log.warn("WARNING: A WebApplication is already deployed in context
'"+contextPath+"' - proceed at your own risk.");
+ _log.warn("A WebApplication is already deployed in context '"+contextPath+"' -
proceed at your own risk.");
// deploy the WebApp
- WebApplicationContext app=new JBossWebApplicationContext(this, contextPath,
_log, descriptorParser, wa, _parser);
+ WebApplicationContext app=
+ new JBossWebApplicationContext(this, contextPath, descriptorParser, wa,
_parser);
String virtualHost=null;
addContext(virtualHost, app);
@@ -209,7 +209,7 @@
}
catch (Exception e)
{
- _log.error("ERROR: problem deploying "+warUrl+" to "+contextPath, e);
+ _log.error("problem deploying "+warUrl+" to "+contextPath, e);
throw new DeploymentException(e.getMessage());
}
@@ -233,11 +233,11 @@
_deployed.remove(warUrl);
- _log.info("successfully undeployed "+warUrl);
+ _log.info("Successfully undeployed "+warUrl);
}
catch (Exception e)
{
- _log.error("ERROR: problem undeploying "+warUrl, e);
+ _log.error("problem undeploying "+warUrl, e);
throw new DeploymentException(e.getMessage());
}
}
@@ -263,7 +263,7 @@
}
catch (Exception e)
{
- _log.error("ERROR: Could not find resource: "+name, e);
+ _log.error("Could not find resource: "+name, e);
}
return url;
1.6 +7 -6 contrib/jetty/src/main/org/jboss/jetty/JettyResolver.java
Index: JettyResolver.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyResolver.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JettyResolver.java 2001/11/21 23:13:01 1.5
+++ JettyResolver.java 2001/12/09 06:05:49 1.6
@@ -12,10 +12,11 @@
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
-import org.apache.log4j.Category;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+import org.jboss.logging.Logger;
+
// I could use a Hashtable instead of HashMap, but the current usage
// of this class (populate/write and then use/read) makes this
// unecessary. If at a later date usage changes this should be
@@ -24,13 +25,13 @@
public class JettyResolver
implements EntityResolver
{
- protected Category _log;
+ protected Logger _log = Logger.getLogger(JettyResolver.class);
protected HashMap _map=new HashMap();
public
- JettyResolver(Category log)
+ JettyResolver()
{
- _log=log;
+ // nothing
}
public InputSource
@@ -42,7 +43,7 @@
if (url==null)
{
- _log.warn("WARNING: no resolution for "+publicId+" - are you using a
supported JSDK version?");
+ _log.warn("no resolution for "+publicId+" - are you using a supported JSDK
version?");
}
else
{
@@ -54,7 +55,7 @@
}
catch (IOException e)
{
- _log.error("ERROR: bad resolution "+publicId+" : "+url, e);
+ _log.error("bad resolution "+publicId+" : "+url, e);
}
}
1.35 +26 -15 contrib/jetty/src/main/org/jboss/jetty/JettyService.java
Index: JettyService.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JettyService.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- JettyService.java 2001/12/09 05:24:24 1.34
+++ JettyService.java 2001/12/09 06:05:49 1.35
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: JettyService.java,v 1.34 2001/12/09 05:24:24 user57 Exp $
+// $Id: JettyService.java,v 1.35 2001/12/09 06:05:49 user57 Exp $
package org.jboss.jetty;
@@ -16,7 +16,7 @@
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.apache.log4j.Category;
+import org.jboss.logging.Logger;
import org.jboss.deployment.DeploymentException;
import org.jboss.web.AbstractWebContainer.WebDescriptorParser;
import org.jboss.web.AbstractWebContainer;
@@ -25,11 +25,10 @@
import org.mortbay.util.Log;
/**
- * A service to launch jetty from JMX.
+ * A service to launch jetty from JMX.
*
- * @see <related>
- * @author <a href="mailto:[EMAIL PROTECTED]">Julian Gosnell</a>
- * @version $Revision: 1.34 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Julian Gosnell</a>
+ * @version $Revision: 1.35 $
*/
// NOTES
@@ -43,7 +42,7 @@
{
public static final String NAME = "Jetty";
- Category _log = Category.getInstance(getClass().getName());
+ Logger _log = Logger.getLogger(JettyService.class);
JettyMBean _mbean = null;
DebugMBean _debug = null;
Jetty _jetty = null;
@@ -81,7 +80,7 @@
JBossLogSink logSink = new JBossLogSink();
try
{
- logSink.initialize(_log);
+ logSink.initialize(Logger.getLogger("org.jboss.jetty.Jetty"));
}
catch(Exception e)
{
@@ -118,7 +117,9 @@
System.getProperties().load(propertiesIn);
- _log.debug("Loaded properties from: "+props);
+ if (_log.isDebugEnabled()) {
+ _log.debug("Loaded properties from: "+props);
+ }
}
protected void
@@ -127,7 +128,7 @@
org.mortbay.jetty.jmx.ModelMBeanImpl.setJettyDomain("Jetty");
// make a Jetty...
- Jetty tmp = new Jetty(_log); // tmp - until we have initialised it...
+ Jetty tmp = new Jetty();
tmp.setJettyHome(getJettyHome());
tmp.setWebDefault(getWebDefault());
tmp.setUnpackWars(getUnpackWars());
@@ -312,7 +313,9 @@
public void
setPublishMBeans(boolean publishMBeans)
{
- _log.debug("set PublishMBeans to "+publishMBeans);
+ if (_log.isDebugEnabled()) {
+ _log.debug("set PublishMBeans to "+publishMBeans);
+ }
_publishMBeans=publishMBeans;
}
@@ -333,7 +336,9 @@
public void
setUnpackWars(boolean unpackWars)
{
- _log.debug("set UnpackWars to "+unpackWars);
+ if (_log.isDebugEnabled()) {
+ _log.debug("set UnpackWars to "+unpackWars);
+ }
if (isInitialised())
_jetty.setUnpackWars(unpackWars);
@@ -357,7 +362,9 @@
public void
setWebDefault(String webDefault)
{
- _log.debug("set WebDefault to "+webDefault);
+ if (_log.isDebugEnabled()) {
+ _log.debug("set WebDefault to "+webDefault);
+ }
if (isInitialised())
_jetty.setWebDefault(webDefault);
@@ -381,7 +388,9 @@
public void
setConfiguration(String configUrl)
{
- _log.debug("set Configuration to "+configUrl);
+ if (_log.isDebugEnabled()) {
+ _log.debug("set Configuration to "+configUrl);
+ }
if (isInitialised())
_jetty.setConfiguration(configUrl);
@@ -405,7 +414,9 @@
public void
setJettyHome(String jettyHome)
{
- _log.debug("set JettyHome to "+jettyHome);
+ if (_log.isDebugEnabled()) {
+ _log.debug("set JettyHome to "+jettyHome);
+ }
if (isInitialised())
_jetty.setJettyHome(jettyHome);
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development