KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > common > UnresolvedEJBRefException


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
23  */

24 public class UnresolvedEJBRefException extends DeploymentException {
25     private final String JavaDoc refName;
26     private final boolean local;
27     private final boolean session;
28     private final String JavaDoc homeInterface;
29     private final String JavaDoc beanInterface;
30
31     public UnresolvedEJBRefException(String JavaDoc refName, boolean local, boolean session, String JavaDoc homeInterface,
32                                      String JavaDoc 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 JavaDoc 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 JavaDoc getHomeInterface() {
54         return homeInterface;
55     }
56
57     public String JavaDoc getBeanInterface() {
58         return beanInterface;
59     }
60
61     private static String JavaDoc createMessage(String JavaDoc refName, boolean local, boolean session, String JavaDoc homeInterface,
62                                      String JavaDoc beanInterface, boolean foundMultiple) {
63         StringBuffer JavaDoc msg = new StringBuffer JavaDoc();
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 }
80
Popular Tags