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;
017:
018: /**
019: * @version $Rev: 602704 $ $Date: 2007-12-09 09:58:22 -0800 $
020: */
021: public enum InterfaceType {
022: EJB_HOME("Home"), EJB_OBJECT("Remote"), EJB_LOCAL_HOME("LocalHome"), EJB_LOCAL(
023: "Local"), BUSINESS_LOCAL("Local"), BUSINESS_LOCAL_HOME(
024: "LocalHome"), BUSINESS_REMOTE("Remote"), BUSINESS_REMOTE_HOME(
025: "Home"), SERVICE_ENDPOINT("ServiceEndpoint"), UNKNOWN(
026: "Unknown");
027:
028: private final String specName;
029:
030: InterfaceType(String name) {
031: this .specName = name;
032: }
033:
034: public String getSpecName() {
035: return specName;
036: }
037:
038: public boolean isHome() {
039: switch (this ) {
040: case EJB_HOME:
041: return true;
042: case EJB_LOCAL_HOME:
043: return true;
044: case BUSINESS_LOCAL_HOME:
045: return true;
046: case BUSINESS_REMOTE_HOME:
047: return true;
048: }
049: return false;
050: }
051:
052: public boolean isComponent() {
053: switch (this ) {
054: case EJB_OBJECT:
055: return true;
056: case EJB_LOCAL:
057: return true;
058: }
059: return false;
060: }
061:
062: public boolean isBusiness() {
063: switch (this ) {
064: case BUSINESS_LOCAL:
065: return true;
066: case BUSINESS_REMOTE:
067: return true;
068: }
069: return false;
070: }
071:
072: public boolean isRemote() {
073: switch (this ) {
074: case EJB_HOME:
075: return true;
076: case EJB_OBJECT:
077: return true;
078: case BUSINESS_REMOTE:
079: return true;
080: case BUSINESS_REMOTE_HOME:
081: return true;
082: }
083: return false;
084: }
085:
086: public boolean isLocal() {
087: switch (this ) {
088: case EJB_LOCAL_HOME:
089: return true;
090: case EJB_LOCAL:
091: return true;
092: case BUSINESS_LOCAL:
093: return true;
094: case BUSINESS_LOCAL_HOME:
095: return true;
096: }
097: return false;
098: }
099:
100: public InterfaceType getCounterpart() {
101: switch (this ) {
102: case EJB_HOME:
103: return InterfaceType.EJB_OBJECT;
104: case EJB_LOCAL_HOME:
105: return InterfaceType.EJB_LOCAL;
106: case BUSINESS_REMOTE_HOME:
107: return InterfaceType.BUSINESS_REMOTE;
108: case BUSINESS_LOCAL_HOME:
109: return InterfaceType.BUSINESS_LOCAL;
110: case EJB_OBJECT:
111: return InterfaceType.EJB_HOME;
112: case EJB_LOCAL:
113: return InterfaceType.EJB_LOCAL_HOME;
114: case BUSINESS_REMOTE:
115: return InterfaceType.BUSINESS_REMOTE_HOME;
116: case BUSINESS_LOCAL:
117: return InterfaceType.BUSINESS_LOCAL_HOME;
118: default:
119: throw new IllegalArgumentException(
120: "InterfaceType has no counterpart: " + this);
121: }
122: }
123: }
|