KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > core > service > InvocationType


1 /**
2  *
3  * Copyright 2003-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
18 package org.apache.geronimo.core.service;
19
20 import java.io.ObjectStreamException JavaDoc;
21 import java.io.Serializable JavaDoc;
22
23 import org.apache.geronimo.core.service.Invocation;
24 import org.apache.geronimo.core.service.InvocationKey;
25
26 /**
27  *
28  *
29  *
30  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
31  */

32 public final class InvocationType implements Serializable JavaDoc, InvocationKey {
33     private static final StringInvocationKey INVOCATION_TYPE_KEY = new StringInvocationKey("INVOCATION_TYPE_KEY", false);
34
35     // Be careful here. If you change the ordinals, this class must be changed on evey client.
36
private static int MAX_ORDINAL = 3;
37     private static final InvocationType[] values = new InvocationType[MAX_ORDINAL + 1];
38     public static final InvocationType REMOTE = new InvocationType("REMOTE", 0, false, false);
39     public static final InvocationType HOME = new InvocationType("HOME", 1, false, true);
40     public static final InvocationType LOCAL = new InvocationType("LOCAL", 2, true, false);
41     public static final InvocationType LOCALHOME = new InvocationType("LOCALHOME", 3, false, false);
42
43     public static InvocationType getType(Invocation invocation) {
44         return (InvocationType) invocation.get(INVOCATION_TYPE_KEY);
45     }
46
47     public static void putType(Invocation invocation, InvocationType type) {
48         invocation.put(INVOCATION_TYPE_KEY, type);
49     }
50
51     private final transient String JavaDoc name;
52     private final transient boolean local;
53     private final transient boolean home;
54     private final int ordinal;
55
56     private InvocationType(String JavaDoc name, int ordinal, boolean local, boolean home) {
57         assert ordinal <= MAX_ORDINAL;
58         assert values[ordinal] == null;
59         this.name = name;
60         this.local = local;
61         this.home = home;
62         this.ordinal = ordinal;
63         values[ordinal] = this;
64     }
65     
66     /**
67      * @see org.apache.geronimo.core.service.InvocationKey#isTransient()
68      */

69     public boolean isTransient() {
70         return false;
71     }
72     
73
74     public boolean isRemoteInvocation() {
75         return !local;
76     }
77
78     public boolean isLocalInvocation() {
79         return local;
80     }
81
82     public boolean isHomeInvocation() {
83         return home;
84     }
85
86     public boolean isBeanInvocation() {
87         return !home;
88     }
89
90     public String JavaDoc toString() {
91         return name;
92     }
93
94     Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
95         return values[ordinal];
96     }
97
98 }
99
Popular Tags