You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2008/02/28 23:01:19 UTC
svn commit: r632129 - in /db/derby/code/trunk/java/engine/org/apache/derby:
iapi/error/ iapi/services/context/ iapi/services/i18n/
impl/services/monitor/ impl/services/replication/ impl/store/raw/log/
Author: djd
Date: Thu Feb 28 14:01:16 2008
New Revision: 632129
URL: http://svn.apache.org/viewvc?rev=632129&view=rev
Log:
DERBY-3452 The classes ShutdownException and ErrorStringBuilder have been moved from org.apache.derby.iapi.services.context to org.apache.derby.iapi.error, as they are more about errors than about contexts.
Contributed by Dibyendu Majumdar Email: dibyendu at mazumdar dot demon dot co dot uk
Added:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java (with props)
db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java (with props)
Removed:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ErrorStringBuilder.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ShutdownException.java
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/ReplicationLogger.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java?rev=632129&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java Thu Feb 28 14:01:16 2008
@@ -0,0 +1,127 @@
+/*
+
+ Derby - Class org.apache.derby.iapi.services.context.ErrorStringBuilder
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.iapi.error;
+
+import org.apache.derby.iapi.services.stream.PrintWriterGetHeader;
+
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+/**
+ * Class used to form error messages. Primary
+ * reason for existence is to allow a way to call
+ * printStackTrace() w/o automatically writting
+ * to a stream.
+ */
+public class ErrorStringBuilder
+{
+ private StringWriter stringWriter;
+ private PrintWriter printWriter;
+ private PrintWriterGetHeader headerGetter;
+
+ /**
+ ** Construct an error string builder
+ */
+ public ErrorStringBuilder(PrintWriterGetHeader headerGetter)
+ {
+ this.headerGetter = headerGetter;
+ this.stringWriter = new StringWriter();
+ this.printWriter = new PrintWriter(stringWriter);
+ }
+
+ /**
+ ** Append an error string
+ **
+ ** @param s the string to append
+ */
+ public void append(String s)
+ {
+ if (headerGetter != null)
+ printWriter.print(headerGetter.getHeader());
+ printWriter.print(s);
+ }
+
+
+ /**
+ ** Append an error string with a newline
+ **
+ ** @param s the string to append
+ */
+ public void appendln(String s)
+ {
+ if (headerGetter != null)
+ printWriter.print(headerGetter.getHeader());
+ printWriter.println(s);
+ }
+
+ /**
+ ** Print a stacktrace from the throwable in the error
+ ** buffer.
+ **
+ ** @param t the error
+ */
+ public void stackTrace(Throwable t)
+ {
+ int level = 0;
+ while(t != null)
+ {
+ if (level > 0)
+ printWriter.println("============= begin nested exception, level (" +
+ level + ") ===========");
+
+ t.printStackTrace(printWriter);
+
+ if (t instanceof java.sql.SQLException) {
+ Throwable next = ((java.sql.SQLException)t).getNextException();
+ t = (next == null) ? t.getCause() : next;
+ } else {
+ t = t.getCause();
+ }
+
+ if (level > 0)
+ printWriter.println("============= end nested exception, level (" +
+ level + ") ===========");
+
+ level++;
+
+ }
+
+ }
+
+ /**
+ ** Reset the buffer -- truncate it down to nothing.
+ **
+ */
+ public void reset()
+ {
+ // Is this the most effecient way to do this?
+ stringWriter.getBuffer().setLength(0);
+ }
+
+ /**
+ ** Get the buffer
+ */
+ public StringBuffer get()
+ {
+ return stringWriter.getBuffer();
+ }
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ErrorStringBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java?rev=632129&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java Thu Feb 28 14:01:16 2008
@@ -0,0 +1,34 @@
+/*
+
+ Derby - Class org.apache.derby.iapi.error.ShutdownException
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.iapi.error;
+
+/**
+ A ShutdownException is a runtime exception that is used
+ to notify code that the system has/is being shut down.
+*/
+
+public final class ShutdownException extends RuntimeException {
+
+ public ShutdownException() {
+ super("");
+ }
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ShutdownException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextManager.java Thu Feb 28 14:01:16 2008
@@ -24,7 +24,9 @@
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
+import org.apache.derby.iapi.error.ErrorStringBuilder;
import org.apache.derby.iapi.error.PassThroughException;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.monitor.Monitor;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/ContextService.java Thu Feb 28 14:01:16 2008
@@ -21,6 +21,7 @@
package org.apache.derby.iapi.services.context;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/context/SystemContext.java Thu Feb 28 14:01:16 2008
@@ -21,6 +21,7 @@
package org.apache.derby.iapi.services.context;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.error.ExceptionSeverity;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java Thu Feb 28 14:01:16 2008
@@ -21,8 +21,8 @@
package org.apache.derby.iapi.services.i18n;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.services.info.JVMInfo;
-import org.apache.derby.iapi.services.context.ShutdownException;
import java.util.Locale;
import java.util.MissingResourceException;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java Thu Feb 28 14:01:16 2008
@@ -35,12 +35,13 @@
import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.context.Context;
import org.apache.derby.iapi.services.context.ContextService;
-import org.apache.derby.iapi.services.context.ShutdownException;
import org.apache.derby.iapi.services.stream.InfoStreams;
import org.apache.derby.iapi.services.stream.PrintWriterGetHeader;
import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.error.ErrorStringBuilder;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.uuid.UUIDFactory;
import org.apache.derby.iapi.services.timer.TimerFactory;
@@ -58,7 +59,6 @@
import org.apache.derby.io.StorageFactory;
-import org.apache.derby.iapi.services.context.ErrorStringBuilder;
import org.apache.derby.iapi.services.info.JVMInfo;
import org.apache.derby.iapi.services.i18n.BundleFinder;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/ReplicationLogger.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/ReplicationLogger.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/ReplicationLogger.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/ReplicationLogger.java Thu Feb 28 14:01:16 2008
@@ -23,7 +23,7 @@
package org.apache.derby.impl.services.replication;
import org.apache.derby.iapi.reference.MessageId;
-import org.apache.derby.iapi.services.context.ErrorStringBuilder;
+import org.apache.derby.iapi.error.ErrorStringBuilder;
import org.apache.derby.iapi.services.monitor.Monitor;
public class ReplicationLogger {
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=632129&r1=632128&r2=632129&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Thu Feb 28 14:01:16 2008
@@ -29,7 +29,6 @@
import org.apache.derby.impl.store.raw.log.StreamLogScan;
// need this to print nested exception that corrupts the database
-import org.apache.derby.iapi.services.context.ErrorStringBuilder;
import org.apache.derby.iapi.services.info.ProductGenusNames;
import org.apache.derby.iapi.services.info.ProductVersionHolder;
@@ -42,7 +41,6 @@
import org.apache.derby.iapi.services.daemon.Serviceable;
import org.apache.derby.iapi.services.context.ContextManager;
import org.apache.derby.iapi.services.context.ContextService;
-import org.apache.derby.iapi.services.context.ShutdownException;
import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.services.monitor.ModuleControl;
import org.apache.derby.iapi.services.monitor.ModuleSupportable;
@@ -55,6 +53,8 @@
import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
import org.apache.derby.iapi.services.stream.PrintWriterGetHeader;
import org.apache.derby.iapi.services.stream.InfoStreams;
+import org.apache.derby.iapi.error.ErrorStringBuilder;
+import org.apache.derby.iapi.error.ShutdownException;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.services.i18n.MessageService;
import org.apache.derby.iapi.store.access.AccessFactory;