[jboss-svn-commits] JBoss Portal SVN: r5199 - in branches/JBoss_Portal_Branch_2_4/portlet: . src/main/org/jboss/portal/portlet/container src/main/org/jboss/portal/test/framework/portlet/components src/main/org/jboss/portal/test/portlet/jsr168 src/main/org/jboss/portal/test/portlet/jsr168/misc src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j src/resources/test/jsr168 src/resources/test/jsr168/misc src/resources/test/jsr168/misc/log4j-war src/resources/test/jsr168/misc/log4j-war/WEB-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 14 12:27:25 EDT 2006
Author: julien at jboss.com
Date: 2006-09-14 12:27:16 -0400 (Thu, 14 Sep 2006)
New Revision: 5199
Added:
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLogger.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLoggerFactory.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jTestSuite.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/LoggingPortlet.java
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/web.xml
Modified:
branches/JBoss_Portal_Branch_2_4/portlet/build.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/components/AbstractUniversalTestPortlet.java
Log:
JBPORTAL-1036 : Portlet container uses a log4j logger that use the portlet class name as category which leads to create a logger and prevent that portlet to uses its own logger factory
Modified: branches/JBoss_Portal_Branch_2_4/portlet/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-09-14 16:27:16 UTC (rev 5199)
@@ -441,6 +441,8 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.portletmode.PortletModeTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.portletconfig.PortletConfigTestSuite"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatcherTestSuite"/>
+ <!--Misc Tests-->
+ <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.log4j.Log4jTestSuite"/>
<!--Test Framework test-->
<!--<test todir="${test.reports}" name="org.jboss.portal.test.framework.basic.BasicTestCase"/>-->
</x-test>
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -110,9 +110,6 @@
/** User data constraint. */
protected Set userDataConstraints;
- /** Logger for portlet. */
- protected Logger portletLog;
-
/** Return info. */
protected PortletInfo info;
@@ -128,8 +125,7 @@
this.metaData = metaData;
this.jbossMetaData = jbossMetaData;
this.valve = new Valve();
- this.log = Logger.getLogger(PortletContainer.class);
- this.portletLog = Logger.getLogger(metaData.getClassName());
+ this.log = Logger.getLogger("org.jboss.portal.portlet.container." + metaData.getClassName().replace('.', '_'));
this.started = false;
}
@@ -419,7 +415,7 @@
}
catch (RuntimeException e)
{
- portletLog.error("The portlet threw a runtime exception", e);
+ log.error("The portlet threw a runtime exception", e);
}
finally
{
@@ -458,7 +454,7 @@
}
catch (Exception e)
{
- portletLog.error("The portlet threw an exception", e);
+ log.error("The portlet threw an exception", e);
//
if (e instanceof PortletSecurityException)
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/components/AbstractUniversalTestPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/components/AbstractUniversalTestPortlet.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/components/AbstractUniversalTestPortlet.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -24,7 +24,6 @@
import org.apache.log4j.Logger;
import org.jboss.portal.test.framework.container.TestCaseContext;
import org.jboss.portal.test.framework.container.result.Result;
-import org.jboss.portal.test.framework.container.result.AssertResult;
import org.jboss.portal.test.framework.container.result.FailureResult;
import org.jboss.portal.test.framework.portlet.Joinpoint;
import org.jboss.portal.test.framework.portlet.Sequence;
@@ -56,7 +55,7 @@
{
/** . */
- private final Logger log = Logger.getLogger(getClass());
+ private final Logger log = createLogger();
/** The component id. */
private String componentId;
@@ -293,5 +292,25 @@
protected void reset()
{
}
+
+ /**
+ * Can be subclassed to provide an alternative way to create the logger.
+ */
+ protected Logger createLogger()
+ {
+ if (log != null)
+ {
+ throw new IllegalStateException("The logger should not be re");
+ }
+ return Logger.getLogger(getClass());
+ }
+
+ /**
+ * Return the logger.
+ */
+ public final Logger getLogger()
+ {
+ return log;
+ }
}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLogger.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLogger.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLogger.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.portlet.jsr168.misc.log4j;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CustomLogger extends Logger
+{
+ public CustomLogger(String name)
+ {
+ super(name);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLoggerFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLoggerFactory.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/CustomLoggerFactory.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.portlet.jsr168.misc.log4j;
+
+import org.apache.log4j.spi.LoggerFactory;
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CustomLoggerFactory implements LoggerFactory
+{
+ public CustomLoggerFactory()
+ {
+ }
+
+ public Logger makeNewLoggerInstance(String name)
+ {
+ return new CustomLogger(name);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jSequenceBuilder.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.portlet.jsr168.misc.log4j;
+
+import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
+import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.Sequence;
+import org.jboss.portal.test.framework.portlet.universal.UTP1;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.container.result.Result;
+import org.jboss.portal.test.framework.container.result.EndTestResult;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.log4j.Logger;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5113 $
+ */
+public class Log4jSequenceBuilder extends SequenceRegistryBuilder
+{
+ public void createLog4j(SequenceRegistry registry)
+ {
+ Sequence seq = new Sequence();
+ registry.addSequence("TestLog4j", seq);
+ seq.addAction(0, LoggingPortlet.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
+ {
+ Logger logger = ((LoggingPortlet)portlet).getLogger();
+ assertNotNull(logger);
+ assertTrue("Logger is an instance of " + logger.getClass().getName() + " instead of ", logger instanceof CustomLogger);
+ return new EndTestResult();
+ }
+ });
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jTestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jTestSuite.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/Log4jTestSuite.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.portlet.jsr168.misc.log4j;
+
+import junit.framework.Test;
+import org.jboss.portal.test.framework.container.client.TestSuite;
+import org.jboss.portal.test.framework.container.client.TestCase;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 2972 $
+ */
+public class Log4jTestSuite
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("test-jsr168-misc-log4j.war");
+ suite.addTest(new TestCase("TestLog4j"));
+ return suite;
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/LoggingPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/LoggingPortlet.java 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/misc/log4j/LoggingPortlet.java 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.portlet.jsr168.misc.log4j;
+
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.Joinpoint;
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoggingPortlet extends AbstractUniversalTestPortlet
+{
+ public final static Joinpoint RENDER_JOINPOINT = new Joinpoint("LoggingPortlet", Joinpoint.PORTLET_RENDER);
+
+ protected Logger createLogger()
+ {
+ return Logger.getLogger(getClass().getName(), new CustomLoggerFactory());
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/portlet.xml 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/portlet.xml 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.jsr168.misc.log4j.LoggingPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/web.xml 2006-09-14 15:42:02 UTC (rev 5198)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/misc/log4j-war/WEB-INF/web.xml 2006-09-14 16:27:16 UTC (rev 5199)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <listener>
+ <listener-class>org.jboss.portal.test.portlet.jsr168.misc.log4j.Log4jSequenceBuilder</listener-class>
+ </listener>
+
+</web-app>
More information about the jboss-svn-commits
mailing list