001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.util;
017:
018: import java.io.ByteArrayOutputStream;
019: import java.io.PrintWriter;
020:
021: import org.apache.openejb.OpenEJBException;
022:
023: public class OpenEJBErrorHandler {
024:
025: private static Logger _logger = Logger.getInstance(
026: LogCategory.OPENEJB, "org.apache.openejb.util.resources");
027: private static Messages _messages = new Messages(
028: "org.apache.openejb.util.resources");
029:
030: public static void handleUnknownError(Throwable error,
031: String systemLocation) {
032:
033: ByteArrayOutputStream baos = new ByteArrayOutputStream();
034: PrintWriter pw = new PrintWriter(baos);
035: error.printStackTrace(pw);
036: pw.flush();
037: pw.close();
038:
039: _logger.error("ge0001", systemLocation, new String(baos
040: .toByteArray()));
041:
042: /*
043: * An error broadcasting system is under development.
044: * At this point an appropriate error would be broadcast to all listeners.
045: */
046: }
047:
048: public static void propertiesObjectIsNull(String systemLocation)
049: throws OpenEJBException {
050:
051: throw new OpenEJBException(_messages.format("ge0002",
052: systemLocation));
053: }
054:
055: public static void propertyFileNotFound(String propertyfileName,
056: String systemLocation) throws OpenEJBException {
057:
058: throw new OpenEJBException(_messages.format("ge0003",
059: propertyfileName, systemLocation));
060: }
061:
062: public static void propertyNotFound(String propertyName,
063: String propertyfileName) throws OpenEJBException {
064:
065: throw new OpenEJBException(_messages.format("ge0004",
066: propertyName, propertyfileName));
067: }
068:
069: public static void propertyValueIsIllegal(String propertyName,
070: String value) throws OpenEJBException {
071:
072: throw new OpenEJBException(_messages.format("ge0005",
073: propertyName, value));
074: }
075:
076: public static void propertyValueIsIllegal(String propertyName,
077: String value, String message) throws OpenEJBException {
078:
079: throw new OpenEJBException(_messages.format("ge0006",
080: propertyName, value, message));
081: }
082:
083: public static void classNotFound(String systemLocation,
084: String className) throws OpenEJBException {
085:
086: throw new OpenEJBException(_messages.format("ge0007",
087: systemLocation, className));
088: }
089:
090: public static void classNotAccessible(String systemLocation,
091: String className) throws OpenEJBException {
092:
093: throw new OpenEJBException(_messages.format("ge0008",
094: systemLocation, className));
095: }
096:
097: public static void classNotIntantiateable(String systemLocation,
098: String className) throws OpenEJBException {
099:
100: throw new OpenEJBException(_messages.format("ge0009",
101: systemLocation, className));
102: }
103:
104: public static void classNotIntantiateableForUnknownReason(
105: String systemLocation, String className,
106: String exceptionClassName, String message)
107: throws OpenEJBException {
108:
109: throw new OpenEJBException(_messages.format("ge0011",
110: systemLocation, className, exceptionClassName, message));
111: }
112:
113: public static void classNotIntantiateableFromCodebaseForUnknownReason(
114: String systemLocation, String className, String codebase,
115: String exceptionClassName, String message)
116: throws OpenEJBException {
117: throw new OpenEJBException(_messages.format("ge0012",
118: systemLocation, className, codebase,
119: exceptionClassName, message));
120: }
121:
122: public static void classCodebaseNotFound(String systemLocation,
123: String className, String codebase, Exception e)
124: throws OpenEJBException {
125:
126: throw new OpenEJBException(_messages.format("ge0010",
127: systemLocation, className, codebase, e.getMessage(), e));
128: }
129:
130: public static void configurationParsingError(String messageType,
131: String message, String line, String column) {
132:
133: _logger.error("as0001", messageType, message, line, column);
134: /*
135: * An error broadcasting system is under development.
136: * At this point an appropriate error would be broadcast to all listeners.
137: */
138: }
139:
140: }
|