View Javadoc

1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.geronimo.common;
18  
19  /**
20   * A problem with an EJB reference
21   *
22   * @version $Rev: 390932 $ $Date: 2006-04-02 17:45:37 -0700 (Sun, 02 Apr 2006) $
23   */
24  public class UnresolvedEJBRefException extends DeploymentException {
25      private final String refName;
26      private final boolean local;
27      private final boolean session;
28      private final String homeInterface;
29      private final String beanInterface;
30  
31      public UnresolvedEJBRefException(String refName, boolean local, boolean session, String homeInterface,
32                                       String beanInterface, boolean foundMultiple) {
33          super(createMessage(refName, local, session, homeInterface, beanInterface, foundMultiple));
34          this.refName = refName;
35          this.local = local;
36          this.session = session;
37          this.homeInterface = homeInterface;
38          this.beanInterface = beanInterface;
39      }
40  
41      public String getRefName() {
42          return refName;
43      }
44  
45      public boolean isLocal() {
46          return local;
47      }
48  
49      public boolean isSession() {
50          return session;
51      }
52  
53      public String getHomeInterface() {
54          return homeInterface;
55      }
56  
57      public String getBeanInterface() {
58          return beanInterface;
59      }
60  
61      private static String createMessage(String refName, boolean local, boolean session, String homeInterface,
62                                       String beanInterface, boolean foundMultiple) {
63          StringBuffer msg = new StringBuffer();
64          if (foundMultiple) {
65              msg.append("Two or more EJBs were found");
66          } else {
67              msg.append("Could not find an EJB");
68          }
69          msg.append(" for reference ").append(refName).append(" to a ");
70          msg.append((local ? "local " : "remote "));
71          msg.append((session ? "session" : "entity"));
72  
73          msg.append(" bean that has the home interface ").append(homeInterface);
74          msg.append(" and the ").append(local ? "local" : "remote");
75          msg.append(" interface ").append(beanInterface);
76  
77          return msg.toString();
78      }
79  }