summaryrefslogtreecommitdiffstats
path: root/sandbox/slaws/logging
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/slaws/logging
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/slaws/logging')
-rw-r--r--sandbox/slaws/logging/pom.xml57
-rw-r--r--sandbox/slaws/logging/src/main/java/patha/Messages.properties21
-rw-r--r--sandbox/slaws/logging/src/main/java/patha/SomeTuscanyClassA.java35
-rw-r--r--sandbox/slaws/logging/src/main/java/pathb/SomeTuscanyClassB.java48
-rw-r--r--sandbox/slaws/logging/src/main/java/pathb/tuscany-messages_en.properties24
-rw-r--r--sandbox/slaws/logging/src/main/resources/tuscany-logging.properties73
-rw-r--r--sandbox/slaws/logging/src/main/resources/tuscany-messages_en.properties24
-rw-r--r--sandbox/slaws/logging/src/test/java/test/LoggingTestCase.java71
8 files changed, 353 insertions, 0 deletions
diff --git a/sandbox/slaws/logging/pom.xml b/sandbox/slaws/logging/pom.xml
new file mode 100644
index 0000000000..5bf4a3e0e7
--- /dev/null
+++ b/sandbox/slaws/logging/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator</artifactId>
+ <name>Apache Tuscany Calculator Sample</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-common-utilities</artifactId>
+ <version>2.0.1-incubator</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sandbox/slaws/logging/src/main/java/patha/Messages.properties b/sandbox/slaws/logging/src/main/java/patha/Messages.properties
new file mode 100644
index 0000000000..857c767484
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/java/patha/Messages.properties
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+TEST_MESSAGE = This is a test message with numbers {0}, {1}, {2}
diff --git a/sandbox/slaws/logging/src/main/java/patha/SomeTuscanyClassA.java b/sandbox/slaws/logging/src/main/java/patha/SomeTuscanyClassA.java
new file mode 100644
index 0000000000..ad29675074
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/java/patha/SomeTuscanyClassA.java
@@ -0,0 +1,35 @@
+package patha;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+public class SomeTuscanyClassA {
+
+ private static final Logger Log = LogUtils.getL7dLogger(SomeTuscanyClassA.class);
+
+ public SomeTuscanyClassA() {
+
+
+ Integer params[] = {8, 9, 4};
+
+
+ LogUtils.log(Log,
+ Level.INFO,
+ "TEST_MESSAGE",
+ null,
+ (Object[])params);
+
+ Exception ex = new IllegalStateException("TEST_MESSAGE");
+
+ LogUtils.log(Log,
+ Level.INFO,
+ "TEST_MESSAGE",
+ ex,
+ (Object[])params);
+
+
+ }
+
+}
diff --git a/sandbox/slaws/logging/src/main/java/pathb/SomeTuscanyClassB.java b/sandbox/slaws/logging/src/main/java/pathb/SomeTuscanyClassB.java
new file mode 100644
index 0000000000..5ad190d9c4
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/java/pathb/SomeTuscanyClassB.java
@@ -0,0 +1,48 @@
+package pathb;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+import patha.SomeTuscanyClassA;
+
+public class SomeTuscanyClassB {
+ private static final Logger Log = Logger.getLogger(SomeTuscanyClassA.class.getName());
+
+
+ public SomeTuscanyClassB() {
+
+ Logger Log1 = Logger.getLogger("pathb", "tuscany-messages");
+ Logger Log = Logger.getLogger(SomeTuscanyClassB.class.getName());
+ String rbName = Log.getResourceBundleName();
+
+ Log.log(Level.INFO,
+ "MESSAGE1");
+
+
+ String componentName = "Some component";
+
+ Log.log(Level.INFO,
+ "MESSAGE2", // message id
+ componentName); // parameter
+
+ Integer params[] = {8, 9, 4};
+
+ Log.log(Level.INFO,
+ "MESSAGE3", // message id
+ params); // parameter
+
+
+ Exception ex = new IllegalStateException("TEST_MESSAGE");
+
+ Log.log(Level.INFO,
+ "MESSAGE4", // message id
+ ex); // parameter
+
+
+ }
+
+}
diff --git a/sandbox/slaws/logging/src/main/java/pathb/tuscany-messages_en.properties b/sandbox/slaws/logging/src/main/java/pathb/tuscany-messages_en.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/java/pathb/tuscany-messages_en.properties
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception
diff --git a/sandbox/slaws/logging/src/main/resources/tuscany-logging.properties b/sandbox/slaws/logging/src/main/resources/tuscany-logging.properties
new file mode 100644
index 0000000000..3822dfa014
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/resources/tuscany-logging.properties
@@ -0,0 +1,73 @@
+# 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.
+
+############################################################
+# Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+# Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes. These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the WARNING and above levels.
+handlers= java.util.logging.ConsoleHandler, java.util.logging.FileHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers. For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= WARNING
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to WARNING and above.
+java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+#java.util.logging.ConsoleHandler.formatter = demos.ws_rm.common.ConciseFormatter
+
+
+############################################################
+# Logger specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+#com.xyz.foo.level = SEVERE
+
+patha.SomeTuscanyClassA.level=INFO
+pathb.SomeTuscanyClassB.level=INFO
+
diff --git a/sandbox/slaws/logging/src/main/resources/tuscany-messages_en.properties b/sandbox/slaws/logging/src/main/resources/tuscany-messages_en.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/sandbox/slaws/logging/src/main/resources/tuscany-messages_en.properties
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception
diff --git a/sandbox/slaws/logging/src/test/java/test/LoggingTestCase.java b/sandbox/slaws/logging/src/test/java/test/LoggingTestCase.java
new file mode 100644
index 0000000000..224ea32615
--- /dev/null
+++ b/sandbox/slaws/logging/src/test/java/test/LoggingTestCase.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package test;
+
+import java.io.InputStream;
+import java.util.logging.LogManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import patha.SomeTuscanyClassA;
+import pathb.SomeTuscanyClassB;
+
+
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class LoggingTestCase {
+
+
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testUtilLogger() throws Exception {
+
+ try {
+ InputStream logConfigStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("tuscany-logging.properties");
+ LogManager.getLogManager().readConfiguration(logConfigStream);
+ } catch(Exception ex) {
+ System.out.println("Can't find logging.properties on the classpath");
+ }
+
+ SomeTuscanyClassB stcB = new SomeTuscanyClassB();
+
+ }
+
+ //@Test
+ public void testSpecilizedLogger() throws Exception {
+
+
+
+ SomeTuscanyClassA stcA = new SomeTuscanyClassA();
+
+ }
+}