You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/10/25 15:26:08 UTC
svn commit: r328356 - in /incubator/woden/java/src/org/apache/woden:
ErrorReporter.java internal/BaseWSDLReader.java internal/DOMWSDLReader.java
internal/ErrorReporter.java internal/ErrorReporterImpl.java
Author: jkaputin
Date: Tue Oct 25 06:25:55 2005
New Revision: 328356
URL: http://svn.apache.org/viewcvs?rev=328356&view=rev
Log:
Exported ErrorReporter to the API, extracting the
interface and changing the class suffix to 'Impl'.
Added:
incubator/woden/java/src/org/apache/woden/ErrorReporter.java
- copied, changed from r307289, incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java
incubator/woden/java/src/org/apache/woden/internal/ErrorReporterImpl.java
- copied, changed from r307289, incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java
Removed:
incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java
Modified:
incubator/woden/java/src/org/apache/woden/internal/BaseWSDLReader.java
incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
Copied: incubator/woden/java/src/org/apache/woden/ErrorReporter.java (from r307289, incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java)
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/ErrorReporter.java?p2=incubator/woden/java/src/org/apache/woden/ErrorReporter.java&p1=incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java&r1=307289&r2=328356&rev=328356&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java (original)
+++ incubator/woden/java/src/org/apache/woden/ErrorReporter.java Tue Oct 25 06:25:55 2005
@@ -1,53 +1,21 @@
-/**
- * Copyright 2005 Apache Software Foundation
+/*
+ * Created on 25-Oct-2005
*
- * 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.
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
*/
-package org.apache.woden.internal;
+package org.apache.woden;
import java.util.Locale;
-import org.apache.woden.ErrorHandler;
-import org.apache.woden.ErrorInfo;
-import org.apache.woden.WSDLException;
-import org.apache.woden.internal.ErrorInfoImpl;
-import org.apache.woden.internal.MessageFormatter;
-import org.apache.woden.internal.util.PropertyUtils;
/**
- * This class reports errors that occur while parsing, validating or
- * manipulating WSDL descriptions, such as XML parser errors or violations
- * of the rules defined in the WSDL specification. That is, errors that
- * relate specifically to the WSDL. It does not report system runtime
- * or configuration errors, which are instead treated as exceptions.
- *
- * TODO for now we will treat any error returned by the XML parser as a
- * fatal error, but we may need to rethink this later.
- * <p>
- * An error originates with an error key, a set of message arguments and
- * a severity (warning, error or fatal error). A formatted message is
- * produced and the error is then handled according to the severity.
- * <p/>
- * The error reporter supports the 'en' (English) locale by default
- * and has a default error handler (i.e. a default implementation of
- * ErrorHandler). However, a different locale may be configured
- * via <code>setLocale</code> and a custom error handler implementation
- * may be configured as a system property.
- *
- * @author jkaputin@apache.org
+ * @author kaputin
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
*/
-public class ErrorReporter {
-
+public interface ErrorReporter {
//TODO: add further behaviour as requirements emerge - e.g.
//using a xml locator object to report line/col numbers.
@@ -58,144 +26,6 @@
public static final short SEVERITY_ERROR = 2;
public static final short SEVERITY_FATAL_ERROR = 3;
-
- //the ISO-639 language code for the required locale
- protected static final String LOCALE_LANGUAGE =
- "org.apache.woden.locale-language";
-
- //the class name of a custom error handler
- protected static final String ERROR_HANDLER_NAME =
- "org.apache.woden.error-handler-name";
-
- //"true" or "false" to continue parsing after a fatal error
- protected static final String CONTINUE_AFTER_FATAL_ERROR =
- "org.apache.woden.continue-after-fatal-error";
-
-
- //Used for localization of error messages.
- private Locale fLocale;
-
- //Combines parameterized message text with message parameters
- private MessageFormatter fMessageFormatter;
-
- //Used only if no custom error handler has been specified
- private ErrorHandler fDefaultErrorHandler;
-
- //Custom error handler to use instead of the default error handler
- private ErrorHandler fErrorHandler;
-
- /*
- * TODO fContinueAfterFatalError and related code has been commented out for
- * the time being. If we cannot identify a use case for it, it will be removed.
- *
- //Flag to continue parsing for further errors after a fatal error has occurred.
- private boolean fContinueAfterFatalError;
- */
-
- /**
- * The default constructor sets the instance variables. It uses default
- * implementations for <code>fMessageFormatter</code> and
- * <code>fDefaultErrorHandler</code>. It checks for optional properties that
- * specify the settings for the remaining variables.
- * For <code>fLocale</code>, property org.apache.woden.locale can be used to
- * specify the ISO-639 language code for the required locale. If it is omitted
- * it will default to "en" for English. There is also a setter method which will
- * override any value set by this constructor.
- * For <code>fErrorHandler</code>, property org.apache.woden.error-handler-name
- * can be used to specify the class name of the custom error handler or if
- * omitted, it is set to null. There is also a setter method which will
- * override any value set by this constructor.
- * <p/>
- * Their are several alternatives for specifying these properties, so the property lookup
- * mechanism is encapsulated in a separate <code>PropertyUtils</code> class.
- * <p/>
- * TODO fContinueAfterFatalError and related code has been commented out for
- * the time being. If we cannot identify a use case for it, it will be removed.
- * <p/>
- * For <code>fContinueAfterFatalError</code>,
- * org.apache.woden.continue-after-fatal-error can be used to specify
- * "true" or "false". If this property is omitted or contains any other value,
- * default to "true".
-
- * @throws WSDLException wraps exceptions that may occur while creating
- * objects from Class names specified as properties (e.g.
- * ClassNotFoundException, InstantiationException and IllegalAccessException).
- *
- */
- public ErrorReporter() throws WSDLException
- {
- fMessageFormatter = new MessageFormatter();
- fDefaultErrorHandler = new ErrorHandlerImpl();
-
- //Set the locale using the language code property if specified.
-
- String localeLanguage = PropertyUtils.findProperty(LOCALE_LANGUAGE);
-
- if (localeLanguage != null) {
- fLocale = new Locale(localeLanguage);;
- }
-
- //TODO handle an unsupported locale lang code (e.g. use system locale and
- //log a warning message?)
-
-
- //Set the custom error handler from the error handler property if specified.
-
- String errorHandlerName = PropertyUtils.findProperty(ERROR_HANDLER_NAME);
-
- if (errorHandlerName != null)
- {
- try
- {
- Class cl = Class.forName(errorHandlerName);
-
- fErrorHandler = (ErrorHandler)cl.newInstance();
- }
- catch (Exception e)
- {
- /*
- Catches:
- ClassNotFoundException
- InstantiationException
- IllegalAccessException
- */
-
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
- "Problem instantiating the customer error handler.",
- e);
- }
- } else {
- fErrorHandler = null;
- }
-
- /*
- * TODO fContinueAfterFatalError and related code has been commented out for
- * the time being. If we cannot identify a use case for it, it will be removed.
- *
- //Indicate whether to continue parsing after a fatal error has occurred.
- //Flag defaults to true if the property is omitted or invalid.
-
- String continueString =
- PropertyUtils.findProperty(CONTINUE_AFTER_FATAL_ERROR);
-
- if(continueString != null) {
- if(continueString.equalsIgnoreCase("false")) {
- fContinueAfterFatalError = false;
- }
- else if(continueString.equalsIgnoreCase("true")){
- fContinueAfterFatalError = true;
- }
- else {
- fContinueAfterFatalError = true;
- //TODO: warning msg about invalid value defaulting to true?
- }
- }
- else {
- fContinueAfterFatalError = true;
- }
- */
-
- }
/**
* Invoke the message formatter to convert the key and arguments into a
@@ -210,12 +40,8 @@
* @param severity a short indicating warning, error or fatal error.
*
*/
- public void reportError(String key, Object[] arguments, short severity)
- throws WSDLException {
-
- reportError(key, arguments, severity, null);
- }
-
+ public void reportError(String key, Object[] arguments, short severity)
+ throws WSDLException;
/**
* Invoke the message formatter to convert the key and arguments into a
@@ -233,64 +59,9 @@
* @param severity a short indicating warning, error or fatal error.
*
*/
- public void reportError(String key, Object[] arguments, short severity,
- Throwable targetException) throws WSDLException {
-
- String message = fMessageFormatter.formatMessage(fLocale, key, arguments);
-
- //TODO need to properly initialize ErrorInfo
- ErrorInfo errorInfo =
- new ErrorInfoImpl(null, null, 0, 0, key, message, targetException);
-
- ErrorHandler eh =
- (fErrorHandler != null) ? fErrorHandler : fDefaultErrorHandler;
-
-
- if(severity == SEVERITY_WARNING) {
- eh.warning(errorInfo);
- }
- else if(severity == SEVERITY_ERROR) {
- eh.error(errorInfo);
- }
- else if(severity == SEVERITY_FATAL_ERROR) {
- eh.fatalError(errorInfo);
-
- //For our purposes, we consider it impossible or inappropriate to
- //continue processing after a fatal error, so we throw an exception.
-
- //TODO check later to see if any use cases emerge that would require
- //processing to continue after a fatal error and hence, the use of the
- //fContinueAfterFatalError flag.
-
- if(targetException == null) {
- throw new WSDLException(WSDLException.INVALID_WSDL,
- "Fatal WSDL error:\n" + errorInfo.toString());
- }
- else if(targetException instanceof WSDLException) {
- throw (WSDLException)targetException;
- }
- else {
- throw new WSDLException(WSDLException.OTHER_ERROR,
- "Fatal error.",
- targetException);
- }
-
- /*
- * TODO fContinueAfterFatalError and related code has been commented out for
- * the time being. If we cannot identify a use case for it, it will be removed.
- *
- if(!fContinueAfterFatalError) {
- throw new WSDLException(WSDLException.WSDL_ERROR,
- "Stopping after a fatal error.");
- }
- */
- }
- else {
- //TODO externalize these messages for localization
- throw new IllegalArgumentException("Invalid severity: " + severity);
- }
- }
-
+ public void reportError(String key, Object[] arguments, short severity,
+ Throwable targetException) throws WSDLException;
+
/**
* Set a custom error handler on this error reporter to replace the
* default error handler.
@@ -303,19 +74,15 @@
* @param errorHandler the custom error handler
*
*/
- public void setErrorHandler(ErrorHandler errorHandler) {
- fErrorHandler = errorHandler;
- }
-
+ public void setErrorHandler(ErrorHandler errorHandler);
+
/**
* Return the custom error handler if one has been set,
* otherwise return the default error handler.
*
* @return the ErrorHandler used by this error reporter
*/
- public ErrorHandler getErrorHandler() {
- return (fErrorHandler != null) ? fErrorHandler : fDefaultErrorHandler;
- }
+ public ErrorHandler getErrorHandler();
/**
* Set the Locale used for localization of error messages.
@@ -328,16 +95,12 @@
* @param locale the required locale
*
*/
- public void setLocale(Locale locale) {
- fLocale = locale;
- }
+ public void setLocale(Locale locale);
/**
* @return the Locale used for localization of error messages.
*/
- public Locale getLocale() {
- return fLocale;
- }
+ public Locale getLocale();
/**
* Returns a formatted message string for the specified message key and arguments.
@@ -350,10 +113,5 @@
* @param arugments an Object array of message parameters
* @return the formatted message string
*/
- public String getFormattedMessage(String key, Object[] arguments)
- {
- String message = fMessageFormatter.formatMessage(fLocale, key, arguments);
- return message;
- }
-
-}
+ public String getFormattedMessage(String key, Object[] arguments);
+}
\ No newline at end of file
Modified: incubator/woden/java/src/org/apache/woden/internal/BaseWSDLReader.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/BaseWSDLReader.java?rev=328356&r1=328355&r2=328356&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/BaseWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/BaseWSDLReader.java Tue Oct 25 06:25:55 2005
@@ -17,6 +17,7 @@
import java.util.Locale;
import org.apache.woden.ErrorHandler;
+import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
@@ -44,7 +45,7 @@
protected ReaderFeatures features;
protected BaseWSDLReader() throws WSDLException {
- fErrorReporter= new ErrorReporter();
+ fErrorReporter= new ErrorReporterImpl();
features = new ReaderFeatures();
}
Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=328356&r1=328355&r2=328356&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Tue Oct 25 06:25:55 2005
@@ -28,6 +28,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
import org.apache.woden.internal.schema.SchemaConstants;
import org.apache.woden.internal.schema.SchemaImpl;
Copied: incubator/woden/java/src/org/apache/woden/internal/ErrorReporterImpl.java (from r307289, incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java)
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/ErrorReporterImpl.java?p2=incubator/woden/java/src/org/apache/woden/internal/ErrorReporterImpl.java&p1=incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java&r1=307289&r2=328356&rev=328356&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/ErrorReporter.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/ErrorReporterImpl.java Tue Oct 25 06:25:55 2005
@@ -18,6 +18,7 @@
import java.util.Locale;
import org.apache.woden.ErrorHandler;
import org.apache.woden.ErrorInfo;
+import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
import org.apache.woden.internal.ErrorInfoImpl;
import org.apache.woden.internal.MessageFormatter;
@@ -46,19 +47,11 @@
*
* @author jkaputin@apache.org
*/
-public class ErrorReporter {
+public class ErrorReporterImpl implements ErrorReporter {
//TODO: add further behaviour as requirements emerge - e.g.
//using a xml locator object to report line/col numbers.
- //TODO: move these to a constants class so callers can use these constants
- //independently of this class?
- public static final short SEVERITY_WARNING = 1;
-
- public static final short SEVERITY_ERROR = 2;
-
- public static final short SEVERITY_FATAL_ERROR = 3;
-
//the ISO-639 language code for the required locale
protected static final String LOCALE_LANGUAGE =
"org.apache.woden.locale-language";
@@ -122,7 +115,7 @@
* ClassNotFoundException, InstantiationException and IllegalAccessException).
*
*/
- public ErrorReporter() throws WSDLException
+ public ErrorReporterImpl() throws WSDLException
{
fMessageFormatter = new MessageFormatter();
fDefaultErrorHandler = new ErrorHandlerImpl();
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org