001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.invocation;
023:
024: import java.io.Serializable;
025: import java.io.ObjectStreamException;
026:
027: /** Type safe enumeration used for keys in the Invocation object. This relies
028: * on an integer id as the identity for a key. When you add a new key enum
029: * value you must assign it an ordinal value of the current MAX_KEY_ID+1 and
030: * update the MAX_KEY_ID value.
031: *
032: * @author Scott.Stark@jboss.org
033: * @version $Revision: 57209 $
034: */
035: public final class InvocationKey implements Serializable {
036: /** The serial version ID */
037: private static final long serialVersionUID = -5117370636698417671L;
038:
039: /** The max ordinal value in use for the InvocationKey enums. When you add a
040: * new key enum value you must assign it an ordinal value of the current
041: * MAX_KEY_ID+1 and update the MAX_KEY_ID value.
042: */
043: private static final int MAX_KEY_ID = 18;
044:
045: /** The array of InvocationKey indexed by ordinal value of the key */
046: private static final InvocationKey[] values = new InvocationKey[MAX_KEY_ID + 1];
047:
048: /**
049: * Transactional information with the invocation.
050: */
051: public static final InvocationKey TRANSACTION = new InvocationKey(
052: "TRANSACTION", 0);
053:
054: /**
055: * Security principal assocated with this invocation.
056: */
057: public static final InvocationKey PRINCIPAL = new InvocationKey(
058: "PRINCIPAL", 1);
059:
060: /**
061: * Security credential assocated with this invocation.
062: */
063: public static final InvocationKey CREDENTIAL = new InvocationKey(
064: "CREDENTIAL", 2);
065:
066: /** Any authenticated Subject associated with the invocation */
067: public static final InvocationKey SUBJECT = new InvocationKey(
068: "SUBJECT", 14);
069:
070: /**
071: * We can keep a reference to an abstract "container" this invocation
072: * is associated with.
073: */
074: public static final InvocationKey OBJECT_NAME = new InvocationKey(
075: "CONTAINER", 3);
076:
077: /**
078: * The type can be any qualifier for the invocation, anything (used in EJB).
079: */
080: public static final InvocationKey TYPE = new InvocationKey("TYPE",
081: 4);
082:
083: /**
084: * The Cache-ID associates an instance in cache somewhere on the server
085: * with this invocation.
086: */
087: public static final InvocationKey CACHE_ID = new InvocationKey(
088: "CACHE_ID", 5);
089:
090: /**
091: * The invocation can be a method invocation, we give the method to call.
092: */
093: public static final InvocationKey METHOD = new InvocationKey(
094: "METHOD", 6);
095:
096: /**
097: * The arguments of the method to call.
098: */
099: public static final InvocationKey ARGUMENTS = new InvocationKey(
100: "ARGUMENTS", 7);
101:
102: /**
103: * Invocation context
104: */
105: public static final InvocationKey INVOCATION_CONTEXT = new InvocationKey(
106: "INVOCATION_CONTEXT", 8);
107:
108: /**
109: * Enterprise context
110: */
111: public static final InvocationKey ENTERPRISE_CONTEXT = new InvocationKey(
112: "ENTERPRISE_CONTEXT", 9);
113:
114: /**
115: * The invoker-proxy binding name
116: */
117: public static final InvocationKey INVOKER_PROXY_BINDING = new InvocationKey(
118: "INVOKER_PROXY_BINDING", 10);
119:
120: /**
121: * The invoker
122: */
123: public static final InvocationKey INVOKER = new InvocationKey(
124: "INVOKER", 11);
125:
126: /**
127: * The JNDI name of the EJB.
128: */
129: public static final InvocationKey JNDI_NAME = new InvocationKey(
130: "JNDI_NAME", 12);
131:
132: /**
133: * The EJB meta-data for the {@link javax.ejb.EJBHome} reference.
134: */
135: public final static InvocationKey EJB_METADATA = new InvocationKey(
136: "EJB_METADATA", 13);
137:
138: /** The EJB home proxy bound for use by getEJBHome */
139: public final static InvocationKey EJB_HOME = new InvocationKey(
140: "EJB_HOME", 14);
141:
142: /** The SOAP Message Context that is available to the SLSB during a service endpoint invocation */
143: public final static InvocationKey SOAP_MESSAGE_CONTEXT = new InvocationKey(
144: "SOAP_MESSAGE_CONTEXT", 15);
145:
146: /** The SOAP Message that is available to the SLSB during a service endpoint invocation */
147: public final static InvocationKey SOAP_MESSAGE = new InvocationKey(
148: "SOAP_MESSAGE", 16);
149:
150: /** The JAAC context id associated with the invocatio */
151: public final static InvocationKey JACC_CONTEXT_ID = new InvocationKey(
152: "JACC_CONTEXT_ID", 17);
153:
154: /** The key enum symbolic value */
155: private final transient String name;
156: /** The persistent integer representation of the key enum */
157: private final int ordinal;
158:
159: private InvocationKey(String name, int ordinal) {
160: this .name = name;
161: this .ordinal = ordinal;
162: values[ordinal] = this ;
163: }
164:
165: public String toString() {
166: return name;
167: }
168:
169: Object readResolve() throws ObjectStreamException {
170: return values[ordinal];
171: }
172: }
|