Enabled better logging for sample apps
git-svn-id: https://svn.apache.org/repos/asf/incubator/jsecurity/trunk@711099 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index 11cd49a..c360e84 100644
--- a/build.xml
+++ b/build.xml
@@ -279,10 +279,18 @@
<ant dir="samples/quickstart"/>
</target>
- <target name="samples.quickstart.run" depends="samples.quickstart" description="Runs the sample quickstart class">
+ <target name="samples.quickstart.run" depends="samples.quickstart" description="Runs the quickstart class">
<ant dir="samples/quickstart" target="run"/>
</target>
+ <target name="samples.standalone" depends="jar" description="Creates the standalone .jar">
+ <ant dir="samples/standalone"/>
+ </target>
+
+ <target name="samples.standalone.run" depends="samples.standalone" description="Runs the standalone sample class">
+ <ant dir="samples/standalone" target="run"/>
+ </target>
+
<target name="samples.web" depends="jar" description="Creates the JSecurity sample webapp .war">
<ant dir="samples/web"/>
</target>
diff --git a/samples/quickstart/build.xml b/samples/quickstart/build.xml
index 3071571..dfe3836 100644
--- a/samples/quickstart/build.xml
+++ b/samples/quickstart/build.xml
@@ -45,9 +45,10 @@
<pathelement location="${classes.dir}"/>
<fileset dir="${lib.dir}/samples">
<include name="ehcache.jar"/>
+ <include name="commons-logging.jar"/>
+ <include name="log4j.jar"/>
<!-- needed by ehcache, not jsecurity: -->
<include name="backport-util-concurrent.jar"/>
- <include name="commons-logging.jar"/>
<!-- Not normally needed, but mac os x JDK needs it for some reason: -->
<include name="xercesImpl.jar"/>
</fileset>
@@ -79,13 +80,20 @@
<src path="${src.dir}"/>
</javac>
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <include name="**/*.properties"/>
+ <include name="**/*.ini"/>
+ </fileset>
+ </copy>
+
</target>
- <target name="jar" depends="compile" description="Creates a .jar of the Spring sample app classes">
+ <target name="jar" depends="compile" description="Creates a .jar of the quickstart classes">
<mkdir dir="${dist.dir}"/>
- <jar jarfile="${dist.dir}/jsecurity-quickstart.jar">
+ <jar jarfile="${dist.dir}/jsecurity-${module.name}.jar">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
<include name="**/*.properties"/>
@@ -102,9 +110,9 @@
<!-- ===================================================================
- dist - create distribution war (which will be used for deployment)
- =================================================================== -->
- <target name="dist" depends="compile,jar" description="Creates the quickstart .jar"/>
+ <target name="dist" depends="compile,jar" description="Creates the ${module.name} .jar"/>
- <target name="run" depends="dist" description="Runs the simple quickstart class">
+ <target name="run" depends="dist" description="Runs the simple ${module.name} class">
<java classname="Quickstart" classpathref="run.path"/>
diff --git a/samples/quickstart/src/log4j.properties b/samples/quickstart/src/log4j.properties
new file mode 100644
index 0000000..62ee20c
--- /dev/null
+++ b/samples/quickstart/src/log4j.properties
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+log4j.rootLogger=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m %n
+
+# General Apache libraries
+log4j.logger.org.apache=WARN
+
+# Spring
+log4j.logger.org.springframework=WARN
+
+# Default JSecurity logging
+log4j.logger.org.jsecurity=TRACE
+
+# Disable verbose logging
+log4j.logger.org.jsecurity.util.ThreadContext=WARN
+log4j.logger.org.jsecurity.cache.ehcache.EhCache=WARN
\ No newline at end of file
diff --git a/samples/standalone/build.xml b/samples/standalone/build.xml
new file mode 100644
index 0000000..c84a85a
--- /dev/null
+++ b/samples/standalone/build.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project name="standalone" default="dist">
+
+ <property name="root.base.dir" value="../.."/>
+
+ <!-- "extend" parent build definition -->
+ <import file="../../build.xml"/>
+
+ <!-- Module properties -->
+ <property name="module.name" value="standalone"/>
+ <property name="module.base.dir" value="${root.base.dir}/samples/${module.name}"/>
+ <property name="dist.jar.name" value="${project.name}-${module.name}.jar"/>
+ <property name="dist.jar" value="${root.dist.dir}/${dist.jar.name}"/>
+ <property name="dist.dir" value="${build.dir}/dist"/>
+
+ <path id="compile.path">
+ <fileset dir="${lib.dir}/samples" includes="**/*.jar"/>
+ <fileset dir="${root.dist.dir}" includes="jsecurity.jar"/>
+ </path>
+
+ <path id="run.path">
+ <pathelement location="${classes.dir}"/>
+ <fileset dir="${lib.dir}/samples">
+ <include name="ehcache.jar"/>
+ <include name="commons-beanutils.jar"/>
+ <include name="commons-logging.jar"/>
+ <include name="log4j.jar"/>
+ <!-- needed by ehcache, not jsecurity: -->
+ <include name="backport-util-concurrent.jar"/>
+ <!-- Not normally needed, but mac os x JDK needs it for some reason: -->
+ <include name="xercesImpl.jar"/>
+ </fileset>
+ <fileset dir="${root.dist.dir}" includes="jsecurity.jar"/>
+ </path>
+
+ <!-- ===================================================================
+ - clean - clean all build remnants from this submodule
+ - ==================================================================== -->
+ <target name="clean" description="Cleans the ${module.name} build">
+ <echo message="cleaning ${module.name} module"/>
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <!-- ===================================================================
+ - compile - compile Java source files
+ - =================================================================== -->
+ <target name="compile" description="Compiles the ${module.name} classes">
+
+ <mkdir dir="${classes.dir}"/>
+ <mkdir dir="${classes.dir}/META-INF"/>
+
+ <javac destdir="${classes.dir}"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}"
+ failonerror="true"
+ classpathref="compile.path">
+ <src path="${src.dir}"/>
+ </javac>
+
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <include name="**/*.properties"/>
+ <include name="**/*.ini"/>
+ </fileset>
+ </copy>
+
+ </target>
+
+ <target name="jar" depends="compile" description="Creates a .jar of the ${module.name} classes">
+
+ <mkdir dir="${dist.dir}"/>
+
+ <jar jarfile="${dist.dir}/jsecurity-${module.name}.jar">
+ <fileset dir="${classes.dir}">
+ <include name="**/*.class"/>
+ <include name="**/*.properties"/>
+ </fileset>
+ <manifest>
+ <attribute name="Implementation-Title"
+ value="${project.name}-${module.name}"/>
+ <attribute name="Implementation-Version" value="${version}"/>
+ <attribute name="${project.name}-Version" value="${version}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <!-- ===================================================================
+ - dist - create distribution war (which will be used for deployment)
+ - =================================================================== -->
+ <target name="dist" depends="compile,jar" description="Creates the ${module.name} .jar"/>
+
+ <target name="run" depends="dist" description="Runs the simple ${module.name} class">
+
+ <java classname="Standalone" classpathref="run.path"/>
+
+ </target>
+
+</project>
diff --git a/samples/standalone/src/log4j.properties b/samples/standalone/src/log4j.properties
new file mode 100644
index 0000000..7235c6f
--- /dev/null
+++ b/samples/standalone/src/log4j.properties
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+log4j.rootLogger=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m %n
+
+# General Apache libraries
+log4j.logger.org.apache=WARN
+
+# Spring
+log4j.logger.org.springframework=WARN
+
+# Default JSecurity logging
+log4j.logger.org.jsecurity=TRACE
+
+# Disable verbose logging
+log4j.logger.org.jsecurity.util.ThreadContext=WARN
+log4j.logger.org.jsecurity.cache.ehcache.EhCache=WARN
+
diff --git a/src/org/jsecurity/session/mgt/eis/CachingSessionDAO.java b/src/org/jsecurity/session/mgt/eis/CachingSessionDAO.java
index 8c291a3..a1c2693 100644
--- a/src/org/jsecurity/session/mgt/eis/CachingSessionDAO.java
+++ b/src/org/jsecurity/session/mgt/eis/CachingSessionDAO.java
@@ -64,7 +64,6 @@
this.cacheManager = cacheManager;
//force cache reload:
this.activeSessions = null;
- getActiveSessionsCacheLazy();
}
/**