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.client;
017:
018: import java.io.IOException;
019: import java.io.ObjectInput;
020: import java.io.ObjectOutput;
021:
022: public class JNDIRequest implements ClusterableRequest {
023:
024: private transient int requestMethod = -1;
025: private transient String requestString;
026: private transient String moduleId;
027: private transient int serverHash;
028:
029: public JNDIRequest() {
030: }
031:
032: public JNDIRequest(int requestMethod, String requestString) {
033: this .requestMethod = requestMethod;
034: this .requestString = requestString;
035: }
036:
037: public byte getRequestType() {
038: return RequestMethodConstants.JNDI_REQUEST;
039: }
040:
041: public int getRequestMethod() {
042: return requestMethod;
043: }
044:
045: public String getRequestString() {
046: return requestString;
047: }
048:
049: public String getModuleId() {
050: return moduleId;
051: }
052:
053: public void setModuleId(String moduleId) {
054: this .moduleId = moduleId;
055: }
056:
057: public void setRequestMethod(int requestMethod) {
058: this .requestMethod = requestMethod;
059: }
060:
061: public void setRequestString(String requestString) {
062: this .requestString = requestString;
063: }
064:
065: public void setServerHash(int serverHash) {
066: this .serverHash = serverHash;
067: }
068:
069: public int getServerHash() {
070: return serverHash;
071: }
072:
073: public void readExternal(ObjectInput in) throws IOException,
074: ClassNotFoundException {
075: byte version = in.readByte(); // future use
076:
077: requestMethod = in.readByte();
078: requestString = in.readUTF();
079: moduleId = (String) in.readObject();
080: serverHash = in.readInt();
081: }
082:
083: public void writeExternal(ObjectOutput out) throws IOException {
084: // write out the version of the serialized data for future use
085: out.writeByte(1);
086:
087: out.writeByte((byte) requestMethod);
088: out.writeUTF(requestString);
089: out.writeObject(moduleId);
090: out.writeInt(serverHash);
091: }
092:
093: public String toString() {
094: StringBuilder sb = new StringBuilder(100);
095:
096: switch (requestMethod) {
097: case RequestMethodConstants.JNDI_LOOKUP:
098: sb.append("JNDI_LOOKUP:");
099: break;
100: case RequestMethodConstants.JNDI_LIST:
101: sb.append("JNDI_LIST:");
102: break;
103: case RequestMethodConstants.JNDI_LIST_BINDINGS:
104: sb.append("JNDI_LIST_BINDINGS:");
105: break;
106: }
107: sb.append(this .moduleId).append(":");
108: sb.append(this.requestString);
109: return sb.toString();
110: }
111:
112: }
|