Author: jboynes
Date: Fri Mar 24 18:57:28 2006
New Revision: 388691
URL: http://svn.apache.org/viewcvs?rev=388691&view=rev
Log:
clean up IDEA warnings for common
Removed:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/io/util/
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
incubator/tuscany/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
Fri Mar 24 18:57:28 2006
@@ -5,34 +5,61 @@
/**
* 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;
- protected List<String> contextStack;
-
+ /**
+ * 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.
+ * 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(String name) {
+ public List<String> returnContextNames() {
if (contextStack == null) {
contextStack = new ArrayList<String>();
}
@@ -40,7 +67,9 @@
}
/**
- * Pushes a context name where an error occured onto the call stack
+ * 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) {
@@ -49,17 +78,19 @@
contextStack.add(name);
}
- private String identifier;
-
/**
- * Returns a string representing additional error information referred to
in the error message
+ * 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
+ * Sets an additional error information referred to in the error message.
+ *
+ * @param identifier additional error information
*/
public void setIdentifier(String identifier) {
this.identifier = identifier;
@@ -69,17 +100,18 @@
if (identifier == null && contextStack == null) {
return super.getMessage();
}
- StringBuffer b = new StringBuffer();
+ StringBuilder b = new StringBuilder(256);
+ b.append(super.getMessage());
+
if (identifier != null) {
- b.append(" [").append(identifier).append("]");
+ 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("]");
+ b.append('[').append(contextStack.get(i)).append(']');
}
}
- return super.getMessage() + b.toString();
-
+ return b.toString();
}
}
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
Fri Mar 24 18:57:28 2006
@@ -4,40 +4,63 @@
import java.util.List;
/**
- * The root unchecked exception for the Tuscany runtime
- *
+ * 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;
- protected List<String> contextStack;
-
- protected String moduleComponentName;
-
- protected String componentName;
-
+ /**
+ * 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.
+ * 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(String name) {
+ public List<String> returnContextNames() {
if (contextStack == null) {
contextStack = new ArrayList<String>();
}
@@ -45,7 +68,9 @@
}
/**
- * Pushes a context name where an error occured onto the call stack
+ * 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) {
@@ -54,17 +79,19 @@
contextStack.add(name);
}
- private String identifier;
-
/**
- * Returns a string representing additional error information referred to
in the error message
+ * 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
+ * Sets an additional error information referred to in the error message.
+ *
+ * @param identifier additional error information
*/
public void setIdentifier(String identifier) {
this.identifier = identifier;
@@ -74,18 +101,18 @@
if (identifier == null && contextStack == null) {
return super.getMessage();
}
- StringBuffer b = new StringBuffer();
+ StringBuilder b = new StringBuilder(256);
+ b.append(super.getMessage());
+
if (identifier != null) {
- b.append(" [").append(identifier).append("]");
+ 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("]");
+ b.append('[').append(contextStack.get(i)).append(']');
}
}
- return super.getMessage() + b.toString();
-
+ return b.toString();
}
-
}
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
Fri Mar 24 18:57:28 2006
@@ -30,8 +30,9 @@
@Target({METHOD})
@Retention(RUNTIME)
public @interface LogLevel {
+
/**
* The log level as specified by [EMAIL PROTECTED]
java.util.logging.Level}.
*/
- String value();
+ @SuppressWarnings({"JavaDoc"}) String value();
}
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
Fri Mar 24 18:57:28 2006
@@ -17,22 +17,39 @@
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;
}
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
Fri Mar 24 18:57:28 2006
@@ -32,7 +32,8 @@
/**
* A factory for monitors that forwards events to a [EMAIL PROTECTED]
java.util.logging.Logger Java Logging (JSR47) Logger}.
- *
+ *
+ * @see java.util.logging
* @version $Rev$ $Date$
*/
public class JavaLoggingMonitorFactory implements MonitorFactory {
@@ -43,10 +44,18 @@
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 [EMAIL PROTECTED] java.util.logging.Level}.
*
- * @param levels
- * @param defaultLevel
- * @param bundleName
+ * @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;
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
Fri Mar 24 18:57:28 2006
@@ -65,9 +65,8 @@
*
* @param name the resource name
* @return a [EMAIL PROTECTED] URL} that can be used to read the resource,
or null if no resource could be found
- * @throws IOException if there was a problem locating the resource
*/
- URL getResource(String name) throws IOException;
+ URL getResource(String name);
/**
* Find resources with the given name that are available from this
Modified:
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
(original)
+++
incubator/tuscany/java/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
Fri Mar 24 18:57:28 2006
@@ -89,7 +89,7 @@
return new
EnumerationIterator<URL>(getClassLoader().getResources(name));
}
- public URL getResource(String name) throws IOException {
+ public URL getResource(String name) {
return getClassLoader().getResource(name);
}
Modified:
incubator/tuscany/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
(original)
+++
incubator/tuscany/java/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
Fri Mar 24 18:57:28 2006
@@ -30,6 +30,8 @@
import org.apache.tuscany.common.monitor.LogLevel;
/**
+ * Test case for the JavaLoggingMonitorFactory.
+ *
* @version $Rev$ $Date$
*/
public class JavaLoggingTestCase extends TestCase {
@@ -39,19 +41,25 @@
private MonitorFactory factory;
/**
- * Smoke test to ensure the logger is working
+ * 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();
@@ -62,6 +70,9 @@
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();
@@ -72,6 +83,9 @@
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);
@@ -84,6 +98,9 @@
assertSame(e, record.getThrown());
}
+ /**
+ * Test the argument is logged.
+ */
public void testEventWithOneArg() {
Monitor mon = factory.getMonitor(Monitor.class);
mon.eventWithOneArg("ARG");
@@ -113,6 +130,9 @@
super.tearDown();
}
+ /**
+ * Mock log handler to capture records.
+ */
public static class MockHandler extends Handler {
List<LogRecord> logs = new ArrayList<LogRecord>();
@@ -128,14 +148,13 @@
}
}
+ @SuppressWarnings({"JavaDoc"})
public static interface Monitor {
void eventNotToLog();
void eventWithNoArgs();
void eventWithOneArg(String msg);
-
- void eventWithTwoArgs(String m1, String m2);
void eventWithThrowable(Exception e);
Modified:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
(original)
+++
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/config/impl/AbstractModuleComponentConfigurationLoader.java
Fri Mar 24 18:57:28 2006
@@ -65,11 +65,9 @@
// Load the sca.module file
URL moduleUrl;
- try {
- moduleUrl = resourceLoader.getResource(moduleFileName);
- } catch (IOException e) {
- throw new ConfigurationLoadException(moduleFileName, e);
- }
+ moduleUrl = resourceLoader.getResource(moduleFileName);
+
+
if (moduleUrl == null) {
throw new ConfigurationLoadException(moduleFileName);
}
Modified:
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java?rev=388691&r1=388690&r2=388691&view=diff
==============================================================================
---
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
(original)
+++
incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
Fri Mar 24 18:57:28 2006
@@ -16,7 +16,6 @@
*/
package org.apache.tuscany.tomcat.lifecycle.listener;
-import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -110,12 +109,7 @@
ResourceLoader resourceLoader = new
ResourceLoaderImpl(applicationClassLoader);
// Check if the web app contains an sca.module file
- URL url;
- try {
- url = resourceLoader.getResource("sca.module");
- } catch (IOException e) {
- url = null;
- }
+ URL url = resourceLoader.getResource("sca.module");
if (url != null) {
// The Web app has an sca.module file
// Get the module component name from the context
@@ -124,12 +118,12 @@
// Create an assembly model factory
AssemblyFactory modelFactory=new AssemblyFactoryImpl();
-
+
// Create an assembly model loader
List<SCDLModelLoader> scdlLoaders=new
ArrayList<SCDLModelLoader>();
scdlLoaders.add(new SystemSCDLModelLoader());
AssemblyModelLoader modelLoader=new
SCDLAssemblyModelLoaderImpl(scdlLoaders);
-
+
// Create an assembly model context
AssemblyModelContext modelContext = new
AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
@@ -145,11 +139,11 @@
// Get the system context
AggregateContext systemContext =
runtimeContext.getSystemContext();
-
+
// Load the system module component
ModuleComponentConfigurationLoader loader = new
ModuleComponentConfigurationLoaderImpl(modelContext);
ModuleComponent systemModuleComponent =
loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT,
SYSTEM_MODULE_COMPONENT);
-
+
// Register it with the system context
systemContext.registerModelObject(systemModuleComponent);
@@ -157,11 +151,11 @@
AggregateContext systemModuleComponentContext =
(AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
-
+
// Load the SCDL configuration of the application
module
String uri = context.getPath().substring(1);
ModuleComponent moduleComponent =
loader.loadModuleComponent(moduleComponentName, uri);
-
+
// Register it under the root application context
runtimeContext.getRootContext().registerModelObject(moduleComponent);
AggregateContext
moduleContext=(AggregateContext)runtimeContext.getContext(moduleComponent.getName());