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.geronimo.kernel.repository;
017:
018: import java.util.Stack;
019: import java.io.Serializable;
020:
021: import org.apache.geronimo.gbean.AbstractNameQuery;
022:
023: /**
024: * @version $Rev: 612745 $ $Date: 2008-01-16 23:54:17 -0800 (Wed, 16 Jan 2008) $
025: */
026: public class MissingDependencyException extends Exception {
027: private static final long serialVersionUID = -2557777157677213124L;
028: private Artifact query;
029: private Stack<Artifact> stack;
030:
031: public MissingDependencyException(Artifact query) {
032: super ();
033: this .query = query;
034: }
035:
036: public MissingDependencyException(Artifact query,
037: Stack<Artifact> stack) {
038: super ();
039: this .query = query;
040: this .stack = stack;
041: }
042:
043: public MissingDependencyException(Artifact query, Artifact parent) {
044: super ();
045: this .query = query;
046: this .stack = new Stack<Artifact>();
047: if (parent != null) {
048: this .stack.add(parent);
049: }
050: }
051:
052: public MissingDependencyException(String message, Artifact query,
053: Stack<Artifact> stack) {
054: super (message);
055: this .query = query;
056: this .stack = stack;
057: }
058:
059: public MissingDependencyException(String message, Artifact query,
060: Artifact parent) {
061: super (message);
062: this .query = query;
063: this .stack = new Stack<Artifact>();
064: if (parent != null) {
065: this .stack.add(parent);
066: }
067: }
068:
069: public String getMessage() {
070: String s = super .getMessage();
071: StringBuffer sb = new StringBuffer();
072: if (s != null) {
073: sb.append(s).append("\n");
074: }
075: if (query != null) {
076: sb.append("Missing dependency: ").append(query);
077: }
078: if (stack != null && !stack.isEmpty()) {
079: sb.append("\nParent stack:\n");
080: for (Artifact parent : stack) {
081: sb.append(" ").append(parent).append("\n");
082: }
083:
084: }
085: return sb.toString();
086: }
087:
088: public Artifact getQuery() {
089: return query;
090: }
091:
092: public void setQuery(Artifact query) {
093: this .query = query;
094: }
095:
096: public Stack<Artifact> getStack() {
097: return stack;
098: }
099:
100: public void setStack(Stack<Artifact> stack) {
101: this.stack = stack;
102: }
103: }
|