01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.needle.gigaspaces.store;
18:
19: import java.io.Externalizable;
20: import java.io.IOException;
21: import java.io.ObjectInput;
22: import java.io.ObjectOutput;
23:
24: import com.j_spaces.core.client.ClientUIDHandler;
25: import com.j_spaces.core.client.EntryInfo;
26: import com.j_spaces.core.client.MetaDataEntry;
27:
28: /**
29: * A file lock represent a lock held by an application.
30: *
31: * @author kimchy
32: */
33: public class FileLock extends MetaDataEntry implements Externalizable {
34:
35: private static final String CLASS_NAME = FileLock.class.getName();
36:
37: public String indexName;
38:
39: public String lockName;
40:
41: public FileLock() {
42:
43: }
44:
45: public FileLock(String indexName, String lockName) {
46: this .indexName = indexName;
47: this .lockName = lockName;
48: String uid = ClientUIDHandler.createUIDFromName(indexName
49: + lockName, CLASS_NAME);
50: __setEntryInfo(new EntryInfo(uid, 0));
51: }
52:
53: public void readExternal(ObjectInput in) throws IOException,
54: ClassNotFoundException {
55: super ._readExternal(in);
56: indexName = in.readUTF();
57: lockName = in.readUTF();
58: }
59:
60: public void writeExternal(ObjectOutput out) throws IOException {
61: super._writeExternal(out);
62: out.writeUTF(indexName);
63: out.writeUTF(lockName);
64: }
65: }
|