summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060518/java/sca/common
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060518/java/sca/common')
-rw-r--r--tags/java-M1-20060518/java/sca/common/LICENSE.txt202
-rw-r--r--tags/java-M1-20060518/java/sca/common/README.txt35
-rw-r--r--tags/java-M1-20060518/java/sca/common/pom.xml37
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java133
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java134
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java38
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java35
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java60
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java186
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java48
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java90
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/GeneratedClassLoader.java45
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java137
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider1
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider1
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java163
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/TestMessages.properties16
-rw-r--r--tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties1
18 files changed, 0 insertions, 1362 deletions
diff --git a/tags/java-M1-20060518/java/sca/common/LICENSE.txt b/tags/java-M1-20060518/java/sca/common/LICENSE.txt
deleted file mode 100644
index d645695673..0000000000
--- a/tags/java-M1-20060518/java/sca/common/LICENSE.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
diff --git a/tags/java-M1-20060518/java/sca/common/README.txt b/tags/java-M1-20060518/java/sca/common/README.txt
deleted file mode 100644
index 9b26d1690a..0000000000
--- a/tags/java-M1-20060518/java/sca/common/README.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-Apache Tuscany M1 build (May, 2006)
-===================================
-
-http://incubator.apache.org/tuscany/
-
-Tuscany is an effort undergoing incubation at the Apache Software Foundation
-(ASF), sponsored by the Web Services PMC.
-
-Incubation is required of all newly accepted projects until a further review
-indicates that the infrastructure, communications, and decision making process
-have stabilized in a manner consistent with other successful ASF projects.
-
-While incubation status is not necessarily a reflection of the completeness or
-stability of the code, it does indicate that the project has yet to be fully
-endorsed by the ASF.
-
-
-Support
--------
-
-Any problem with this release can be reported to the Tuscany mailing list
-or in the JIRA issue tracker.
-
-Mailing list subscription:
- tuscany-dev-subscribe@ws.apache.org
-
-Jira:
- http://issues.apache.org/jira/browse/Tuscany
-
-
-Thank you for using Tuscany!
-
-
-The Tuscany Team.
-
diff --git a/tags/java-M1-20060518/java/sca/common/pom.xml b/tags/java-M1-20060518/java/sca/common/pom.xml
deleted file mode 100644
index 861c33c7e1..0000000000
--- a/tags/java-M1-20060518/java/sca/common/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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>
- <parent>
- <groupId>org.apache.tuscany</groupId>
- <artifactId>tuscany-sca</artifactId>
- <version>incubating-M1</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tuscany-common</artifactId>
- <name>Tuscany Common</name>
- <description>Tuscany classes common to runtime and tools.</description>
- <version>incubating-M1</version>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
deleted file mode 100644
index 2bf802520d..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The root checked exception for the Tuscany runtime.
- *
- * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
- */
-public abstract class TuscanyException extends Exception {
- private static final long serialVersionUID = -7847121698339635268L;
- private List<String> contextStack;
- private String identifier;
-
- /**
- * Override constructor from Exception.
- *
- * @see Exception
- */
- public TuscanyException() {
- super();
- }
-
- /**
- * Override constructor from Exception.
- *
- * @param message passed to Exception
- * @see Exception
- */
- public TuscanyException(String message) {
- super(message);
- }
-
- /**
- * Override constructor from Exception.
- *
- * @param message passed to Exception
- * @param cause passed to Exception
- * @see Exception
- */
- public TuscanyException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Override constructor from Exception.
- *
- * @param cause passed to Exception
- * @see Exception
- */
- public TuscanyException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Returns a collection of names representing the context call stack where the error occured.
- * The top of the stack is the first element in the collection.
- *
- * @return a collection of names representing the context call stack
- */
- public List<String> returnContextNames() {
- if (contextStack == null) {
- contextStack = new ArrayList<String>();
- }
- return contextStack;
- }
-
- /**
- * Pushes a context name where an error occured onto the call stack.
- *
- * @param name the name of a context to push on the stack
- */
- public void addContextName(String name) {
- if (contextStack == null) {
- contextStack = new ArrayList<String>();
- }
- contextStack.add(name);
- }
-
- /**
- * Returns a string representing additional error information referred to in the error message.
- *
- * @return additional error information
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * Sets an additional error information referred to in the error message.
- *
- * @param identifier additional error information
- */
- public void setIdentifier(String identifier) {
- this.identifier = identifier;
- }
-
- public String getMessage() {
- if (identifier == null && contextStack == null) {
- return super.getMessage();
- }
- StringBuilder b = new StringBuilder(256);
- b.append(super.getMessage());
-
- if (identifier != null) {
- b.append(" [").append(identifier).append(']');
- }
- if (contextStack != null) {
- b.append("\nContext stack trace: ");
- for (int i = contextStack.size() - 1; i >= 0; i--) {
- b.append('[').append(contextStack.get(i)).append(']');
- }
- }
- return b.toString();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
deleted file mode 100644
index 60f2e2287a..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The root unchecked exception for the Tuscany runtime.
- *
- * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
- */
-
-public abstract class TuscanyRuntimeException extends RuntimeException {
- private static final long serialVersionUID = -759677431966121786L;
- private List<String> contextStack;
- private String identifier;
-
- /**
- * Override constructor from RuntimeException.
- *
- * @see RuntimeException
- */
- public TuscanyRuntimeException() {
- super();
- }
-
- /**
- * Override constructor from RuntimeException.
- *
- * @param message passed to RuntimeException
- * @see RuntimeException
- */
- public TuscanyRuntimeException(String message) {
- super(message);
- }
-
- /**
- * Override constructor from RuntimeException.
- *
- * @param message passed to RuntimeException
- * @param cause passed to RuntimeException
- * @see RuntimeException
- */
- public TuscanyRuntimeException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Override constructor from RuntimeException.
- *
- * @param cause passed to RuntimeException
- * @see RuntimeException
- */
- public TuscanyRuntimeException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Returns a collection of names representing the context call stack where the error occured.
- * The top of the stack is the first element in the collection.
- *
- * @return a collection of names representing the context call stack
- */
- public List<String> returnContextNames() {
- if (contextStack == null) {
- contextStack = new ArrayList<String>();
- }
- return contextStack;
- }
-
- /**
- * Pushes a context name where an error occured onto the call stack.
- *
- * @param name the name of a context to push on the stack
- */
- public void addContextName(String name) {
- if (contextStack == null) {
- contextStack = new ArrayList<String>();
- }
- contextStack.add(name);
- }
-
- /**
- * Returns a string representing additional error information referred to in the error message.
- *
- * @return additional error information
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * Sets an additional error information referred to in the error message.
- *
- * @param identifier additional error information
- */
- public void setIdentifier(String identifier) {
- this.identifier = identifier;
- }
-
- public String getMessage() {
- if (identifier == null && contextStack == null) {
- return super.getMessage();
- }
- StringBuilder b = new StringBuilder(256);
- b.append(super.getMessage());
-
- if (identifier != null) {
- b.append(" [").append(identifier).append(']');
- }
- if (contextStack != null) {
- b.append("\nContext stack trace: ");
- for (int i = contextStack.size() - 1; i >= 0; i--) {
- b.append('[').append(contextStack.get(i)).append(']');
- }
- }
- return b.toString();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
deleted file mode 100644
index 45134c7556..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor;
-
-import static java.lang.annotation.ElementType.METHOD;
-import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
-
-/**
- * Annotation that can be applied to methods in a monitoring interface
- * to indicate to logging frameworks the severity of the event.
- *
- * @version $Rev$ $Date$
- */
-@Target({METHOD})
-@Retention(RUNTIME)
-public @interface LogLevel {
-
- /**
- * The log level as specified by {@link java.util.logging.Level}.
- */
- @SuppressWarnings({"JavaDoc"}) String value();
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java
deleted file mode 100644
index aa92092005..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor;
-
-/**
- * A MonitorFactory creates implementations of components' monitor interfaces
- * that interface with a its monitoring scheme. For example, a implementation
- * may create versions that emit appropriate logging events or which send
- * notifications to a management API.
- *
- * @version $Rev$ $Date$
- */
-public interface MonitorFactory {
- /**
- * Return a monitor for a component's monitor interface.
- *
- * @param monitorInterface the component's monitoring interface
- * @return an implementation of the monitoring interface; will not be null
- */
- <T> T getMonitor(Class<T> monitorInterface);
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
deleted file mode 100644
index baf4e8b7cc..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor.impl;
-
-/**
- * Exception indicating an invalid log level has been passed.
- *
- * @version $Rev$ $Date$
- */
-public class InvalidLevelException extends IllegalArgumentException {
- private static final long serialVersionUID = 7767234706427841915L;
- private final String method;
- private final String level;
-
- /**
- * Constructor specifying the method name and the level affected.
- *
- * @param method the name of the method being monitored
- * @param level the invalid log level value
- */
- public InvalidLevelException(String method, String level) {
- super();
- this.method = method;
- this.level = level;
- }
-
- /**
- * Returns the name of the method being monitored.
- * @return the name of the method being monitored
- */
- public String getMethod() {
- return method;
- }
-
- /**
- * Returns the invalid log level specified.
- * @return the invalid log level that was specified
- */
- public String getLevel() {
- return level;
- }
-
- public String getMessage() {
- return "Invalid level for method " + method + " : " + level;
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
deleted file mode 100644
index daef77d4ae..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor.impl;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.WeakHashMap;
-import java.util.ResourceBundle;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.LogRecord;
-
-import org.apache.tuscany.common.monitor.LogLevel;
-import org.apache.tuscany.common.monitor.MonitorFactory;
-
-/**
- * A factory for monitors that forwards events to a {@link java.util.logging.Logger Java Logging (JSR47) Logger}.
- *
- * @version $Rev$ $Date$
- * @see java.util.logging
- */
-public class JavaLoggingMonitorFactory implements MonitorFactory {
- private final String bundleName;
- private final Level defaultLevel;
- private final Map<String, Level> levels;
-
- private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>();
-
- /**
- * Construct a MonitorFactory that will monitor the specified methods at the specified levels
- * and generate messages using java.util.logging.
- * <p/>
- * The supplied Properties can be used to specify custom log levels for specific monitor
- * methods. The key should be the method name in form returned by
- * <code>Class.getName() + '#' + Method.getName()</code> and the value the log level to use
- * as defined by {@link java.util.logging.Level}.
- *
- * @param levels definition of custom levels for specific monitored methods
- * @param defaultLevel the default log level to use
- * @param bundleName the name of a resource bundle that will be passed to the logger
- * @see java.util.logging.Logger
- */
- public JavaLoggingMonitorFactory(Properties levels, Level defaultLevel, String bundleName) {
- this.defaultLevel = defaultLevel;
- this.bundleName = bundleName;
- this.levels = new HashMap<String, Level>(levels.size());
- for (Map.Entry<Object, Object> entry : levels.entrySet()) {
- String method = (String) entry.getKey();
- String level = (String) entry.getValue();
- try {
- this.levels.put(method, Level.parse(level));
- } catch (IllegalArgumentException e) {
- throw new InvalidLevelException(method, level);
- }
- }
- }
-
- public synchronized <T> T getMonitor(Class<T> monitorInterface) {
- T proxy = getCachedMonitor(monitorInterface);
- if (proxy == null) {
- proxy = createMonitor(monitorInterface, bundleName);
- proxies.put(monitorInterface, new WeakReference<T>(proxy));
- }
- return proxy;
- }
-
- private <T>T getCachedMonitor(Class<T> monitorInterface) {
- WeakReference<?> ref = proxies.get(monitorInterface);
- return (ref != null) ? monitorInterface.cast(ref.get()) : null;
- }
-
- private <T>T createMonitor(Class<T> monitorInterface, String bundleName) {
- String className = monitorInterface.getName();
- Logger logger = Logger.getLogger(className);
- Method[] methods = monitorInterface.getMethods();
- Map<String, Level> levels = new HashMap<String, Level>(methods.length);
- for (Method method : methods) {
- String key = className + '#' + method.getName();
- Level level = this.levels.get(key);
-
- // if not specified the in config properties, look for an annotation on the method
- if (level == null) {
- LogLevel annotation = method.getAnnotation(LogLevel.class);
- if (annotation != null && annotation.value() != null) {
- try {
- level = Level.parse(annotation.value());
- } catch (IllegalArgumentException e) {
- // bad value, just use the default
- level = defaultLevel;
- }
- }
- }
- if (level == null) {
- level = defaultLevel;
- }
- levels.put(method.getName(), level);
- }
-
- ResourceBundle bundle = locateBundle(monitorInterface, bundleName);
-
- InvocationHandler handler = new LoggingHandler(logger, levels, bundle);
- return monitorInterface.cast(Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler));
- }
-
- private static <T>ResourceBundle locateBundle(Class<T> monitorInterface, String bundleName) {
- Locale locale = Locale.getDefault();
- ClassLoader cl = monitorInterface.getClassLoader();
- String packageName = monitorInterface.getPackage().getName();
- while (true) {
- try {
- return ResourceBundle.getBundle(packageName + '.' + bundleName, locale, cl);
- } catch (MissingResourceException e) {
- }
- int index = packageName.lastIndexOf('.');
- if (index == -1) {
- break;
- }
- packageName = packageName.substring(0, index);
- }
- try {
- return ResourceBundle.getBundle(bundleName, locale, cl);
- } catch (Exception e) {
- return null;
- }
- }
-
- private static final class LoggingHandler implements InvocationHandler {
- private final Logger logger;
- private final Map<String, Level> methodLevels;
- private final ResourceBundle bundle;
-
- public LoggingHandler(Logger logger, Map<String, Level> methodLevels, ResourceBundle bundle) {
- this.logger = logger;
- this.methodLevels = methodLevels;
- this.bundle = bundle;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String sourceMethod = method.getName();
- Level level = methodLevels.get(sourceMethod);
- if (level != null && logger.isLoggable(level)) {
- // construct the key for the resource bundle
- String className = logger.getName();
- String key = className + '#' + sourceMethod;
-
- LogRecord logRecord = new LogRecord(level, key);
- logRecord.setLoggerName(className);
- logRecord.setSourceClassName(className);
- logRecord.setSourceMethodName(sourceMethod);
- logRecord.setParameters(args);
- if (args != null) {
- for (Object o : args) {
- if (o instanceof Throwable) {
- logRecord.setThrown((Throwable) o);
- break;
- }
- }
- }
- logRecord.setResourceBundle(bundle);
- logger.log(logRecord);
- }
- return null;
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java
deleted file mode 100644
index 827aeec84c..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor.impl;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import org.apache.tuscany.common.monitor.MonitorFactory;
-
-/**
- * Implementation of a {@link MonitorFactory} that produces implementations that simply return.
- *
- * @version $Rev$ $Date$
- */
-public class NullMonitorFactory implements MonitorFactory {
- public <T> T getMonitor(Class<T> monitorInterface) {
- /*
- * This uses a reflection proxy to implement the monitor interface which
- * is a simple but perhaps not very performant solution. Performance
- * might be improved by code generating an implementation with empty methods.
- */
- return monitorInterface.cast(Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, NULL_MONITOR));
- }
-
- /**
- * Singleton wire hander that does nothing.
- */
- private static final InvocationHandler NULL_MONITOR = new InvocationHandler() {
- public Object invoke(Object proxy, Method method, Object[] args) {
- return null;
- }
- };
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
deleted file mode 100644
index 897c5e06c0..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.resource;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Interface which abstracts the implementation of something that is able to
- * load resources (such as a ClassLoader). All Tuscany code should use this
- * API rather than a ClassLoader directly in order to reduce the risk of
- * memory leaks due to ClassLoader references.
- *
- * @version $Rev: 379878 $ $Date: 2006-02-22 12:45:50 -0800 (Wed, 22 Feb 2006) $
- */
-public interface ResourceLoader {
-
- /**
- * Returns the parent resource loaders.
- *
- * @return resource loaders that are parents to this one
- */
- List<ResourceLoader> getParents();
-
- /**
- * Loads the class with the specified binary name.
- *
- * @param name the binary name of the class
- * @return the resulting Class object
- * @throws ClassNotFoundException if the class was not found
- * @see ClassLoader#loadClass(String)
- */
- Class<?> loadClass(String name) throws ClassNotFoundException;
-
- /**
- * Converts an array of bytes into a Class.
- *
- * @param bytes the bytecode for the class; must match the class file format
- * @return a Class defined from the supplied bytecode
- */
- Class<?> addClass(byte[] bytes);
-
- /**
- * Finds the first resource with the given name.
- * <p/>
- * Each parent is searched first (in the order returned by {@link #getParents()})
- * and the first resource located is found. If no parent returns a resource then
- * the first resource defined by this ResourceLoader is returned.
- *
- * @param name the resource name
- * @return a {@link URL} that can be used to read the resource, or null if no resource could be found
- */
- URL getResource(String name);
-
- /**
- * Find resources with the given name that are available from this
- * ResourceLoader or any of its parents.
- *
- * @param name the resource name
- * @return an Iterator of {@link URL} objects for the resource
- * @throws IOException if there was a problem locating the resources
- */
- Iterator<URL> getResources(String name) throws IOException;
-
- //FIXME this is temporary to work around classloader problems with SDO when running in Tomcat
-
- /**
- * Returns the underlying classloader this loader is wrapping.
- *
- * @return the underlying classloader this loader is wrapping
- */
- ClassLoader getClassLoader();
-
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/GeneratedClassLoader.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/GeneratedClassLoader.java
deleted file mode 100644
index 953908b9f2..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/GeneratedClassLoader.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed 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 org.apache.tuscany.common.resource.impl;
-
-/**
- * A class loader that allows new classes to be defined from an array of bytes.
- *
- * @version $Rev: 369102 $ $Date: 2006-01-14 13:48:56 -0800 (Sat, 14 Jan 2006) $
- */
-@SuppressWarnings({"CustomClassloader"})
-class GeneratedClassLoader extends ClassLoader {
-
- /**
- * Constructs a new GeneratedClassLoader.
- * @param classLoader the parent classloader
- */
- GeneratedClassLoader(ClassLoader classLoader) {
- super(classLoader);
- }
-
- /**
- * Converts an array of bytes into a Class.
- *
- * @param bytes the bytecode for the class; must match the class file format
- * @return a Class defined from the supplied bytecode
- */
- Class<?> addClass(byte[] bytes) {
- return defineClass(null, bytes, 0, bytes.length);
- }
-
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java b/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
deleted file mode 100644
index d306edf3b4..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.resource.impl;
-
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.apache.tuscany.common.resource.ResourceLoader;
-
-/**
- * Default implementation of the ResourceLoader interface
- *
- * @version $Rev: 369102 $ $Date: 2006-01-14 13:48:56 -0800 (Sat, 14 Jan 2006) $
- */
-@SuppressWarnings({"ClassLoader2Instantiation"})
-public class ResourceLoaderImpl implements ResourceLoader {
- private final WeakReference<ClassLoader> classLoaderReference;
- private WeakReference<GeneratedClassLoader> generatedClassLoaderReference;
- private final List<ResourceLoader> parents;
-
- /**
- * Constructs a new ResourceLoaderImpl to wrap a ClassLoader.
- *
- * @param classLoader the classloader to wrap
- */
- public ResourceLoaderImpl(ClassLoader classLoader) {
- classLoaderReference = new WeakReference<ClassLoader>(classLoader);
- generatedClassLoaderReference = new WeakReference<GeneratedClassLoader>(new GeneratedClassLoader(classLoader));
- ClassLoader parentCL = classLoader.getParent();
- if (null == parentCL) {
- parents = Collections.emptyList();
- } else {
- parents = Collections.singletonList((ResourceLoader) new ResourceLoaderImpl(parentCL));
- }
- }
-
-
- public ClassLoader getClassLoader() throws IllegalStateException {
- ClassLoader cl = classLoaderReference.get();
- if (cl == null) {
- throw new IllegalStateException("Referenced ClassLoader has been garbage collected");
- }
- return cl;
- }
-
- public List<ResourceLoader> getParents() {
- return parents;
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- GeneratedClassLoader cl = generatedClassLoaderReference.get();
- if (cl != null) {
- return Class.forName(name, true, cl);
- } else {
- return Class.forName(name, true, getClassLoader());
- }
- }
-
- public Class<?> addClass(byte[] bytes) {
- GeneratedClassLoader cl = generatedClassLoaderReference.get();
- if (cl == null) {
- cl = new GeneratedClassLoader(getClassLoader());
- generatedClassLoaderReference = new WeakReference<GeneratedClassLoader>(cl);
- }
- return cl.addClass(bytes);
- }
-
- public Iterator<URL> getResources(String name) throws IOException {
- return new EnumerationIterator<URL>(getClassLoader().getResources(name));
- }
-
- public URL getResource(String name) {
- return getClassLoader().getResource(name);
- }
-
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof ResourceLoaderImpl)) {
- return false;
- }
- final ResourceLoaderImpl other = (ResourceLoaderImpl) obj;
- return getClassLoader() == other.getClassLoader();
- }
-
- public int hashCode() {
- return getClassLoader().hashCode();
- }
-
- private static class EnumerationIterator<E> implements Iterator<E> {
- private final Enumeration<E> e;
-
- public EnumerationIterator(Enumeration<E> e) {
- this.e = e;
- }
-
- public boolean hasNext() {
- return e.hasMoreElements();
- }
-
- public E next() {
- // the try/catch is needed here to get IDEA to shut up
- // there should be no performance overhead here except when the Exception is thrown
- // so I am going to leave it in - feel free to remove if there is any issue
- try {
- return e.nextElement();
- } catch (NoSuchElementException e1) {
- throw e1;
- }
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider b/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider
deleted file mode 100644
index 6cf181502c..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.tuscany.common.logging.impl.JSR47LogProviderImpl \ No newline at end of file
diff --git a/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider b/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider
deleted file mode 100644
index 70456ec1d0..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.tuscany.common.resource.loader.impl.ResourceLoaderProviderImpl \ No newline at end of file
diff --git a/tags/java-M1-20060518/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java b/tags/java-M1-20060518/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
deleted file mode 100644
index 985f7ef9b6..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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 org.apache.tuscany.common.monitor.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.MonitorFactory;
-import org.apache.tuscany.common.monitor.LogLevel;
-
-/**
- * Test case for the JavaLoggingMonitorFactory.
- *
- * @version $Rev$ $Date$
- */
-public class JavaLoggingTestCase extends TestCase {
- private static final Logger logger = Logger.getLogger(Monitor.class.getName());
- private static final MockHandler handler = new MockHandler();
-
- private MonitorFactory factory;
-
- /**
- * Smoke test to ensure the logger is working.
- */
- public void testLogger() {
- logger.info("test");
- assertEquals(1, handler.logs.size());
- }
-
- /**
- * Test that no record is logged.
- */
- public void testUnloggedEvent() {
- Monitor mon = factory.getMonitor(Monitor.class);
- mon.eventNotToLog();
- assertEquals(0, handler.logs.size());
- }
-
- /**
- * Test the correct record is written for an event with no arguments.
- */
- public void testEventWithNoArgs() {
- Monitor mon = factory.getMonitor(Monitor.class);
- mon.eventWithNoArgs();
- assertEquals(1, handler.logs.size());
- LogRecord record = handler.logs.get(0);
- assertEquals(Level.INFO, record.getLevel());
- assertEquals(logger.getName(), record.getLoggerName());
- assertEquals(Monitor.class.getName() + "#eventWithNoArgs", record.getMessage());
- }
-
- /**
- * Test the correct record is written for an event defined by annotation.
- */
- public void testEventWithAnnotation() {
- Monitor mon = factory.getMonitor(Monitor.class);
- mon.eventWithAnnotation();
- assertEquals(1, handler.logs.size());
- LogRecord record = handler.logs.get(0);
- assertEquals(Level.INFO, record.getLevel());
- assertEquals(logger.getName(), record.getLoggerName());
- assertEquals(Monitor.class.getName() + "#eventWithAnnotation", record.getMessage());
- }
-
- /**
- * Test a Throwable is logged when passed to an event.
- */
- public void testEventWithThrowable() {
- Exception e = new Exception();
- Monitor mon = factory.getMonitor(Monitor.class);
- mon.eventWithThrowable(e);
- assertEquals(1, handler.logs.size());
- LogRecord record = handler.logs.get(0);
- assertEquals(Level.WARNING, record.getLevel());
- assertEquals(logger.getName(), record.getLoggerName());
- assertEquals(Monitor.class.getName() + "#eventWithThrowable", record.getMessage());
- assertSame(e, record.getThrown());
- }
-
- /**
- * Test the argument is logged.
- */
- public void testEventWithOneArg() {
- Monitor mon = factory.getMonitor(Monitor.class);
- mon.eventWithOneArg("ARG");
- assertEquals(1, handler.logs.size());
- LogRecord record = handler.logs.get(0);
- assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- logger.setUseParentHandlers(false);
- logger.addHandler(handler);
- handler.flush();
-
- String sourceClass = Monitor.class.getName();
- Properties levels = new Properties();
- levels.setProperty(sourceClass + "#eventWithNoArgs", "INFO");
- levels.setProperty(sourceClass + "#eventWithOneArg", "INFO");
- levels.setProperty(sourceClass + "#eventWithThrowable", "WARNING");
- factory = new JavaLoggingMonitorFactory(levels, Level.FINE, "TestMessages");
- }
-
- protected void tearDown() throws Exception {
- logger.removeHandler(handler);
- handler.flush();
- super.tearDown();
- }
-
- /**
- * Mock log handler to capture records.
- */
- public static class MockHandler extends Handler {
- List<LogRecord> logs = new ArrayList<LogRecord>();
-
- public void publish(LogRecord record) {
- logs.add(record);
- }
-
- public void flush() {
- logs.clear();
- }
-
- public void close() throws SecurityException {
- }
- }
-
- @SuppressWarnings({"JavaDoc"})
- public static interface Monitor {
- void eventNotToLog();
-
- void eventWithNoArgs();
-
- void eventWithOneArg(String msg);
-
- void eventWithThrowable(Exception e);
-
- @LogLevel("INFO")
- void eventWithAnnotation();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/TestMessages.properties b/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/TestMessages.properties
deleted file mode 100644
index e765ad2e0f..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/TestMessages.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
-#
-# Licensed 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.
-#
-# $Rev$ $Date$
-#
diff --git a/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties b/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties
deleted file mode 100644
index e16fa437fa..0000000000
--- a/tags/java-M1-20060518/java/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.tuscany.common.monitor.impl.JavaLoggingTestCase$Monitor#eventWithOneArg=Log message with arg={0} \ No newline at end of file