01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
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.apache.jk.common;
18:
19: import java.io.IOException;
20: import java.io.RandomAccessFile;
21: import java.nio.MappedByteBuffer;
22: import java.nio.channels.FileChannel;
23:
24: import org.apache.jk.core.Msg;
25: import org.apache.jk.core.MsgContext;
26: import org.apache.tomcat.util.IntrospectionUtils;
27:
28: /** Shm implementation using JDK1.4 nio.
29: *
30: *
31: * @author Costin Manolache
32: */
33: public class Shm14 extends Shm {
34: // Not ready yet.
35:
36: MappedByteBuffer bb;
37:
38: public void init() {
39: try {
40: RandomAccessFile f = new RandomAccessFile(file, "rw");
41: FileChannel fc = f.getChannel();
42:
43: bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, f.length());
44: } catch (IOException ex) {
45: ex.printStackTrace();
46: }
47: }
48:
49: public void dumpScoreboard(String file) {
50: // We can only sync with our backing store.
51: bb.force();
52: // XXX we should copy the content to the file
53: }
54:
55: public void resetScoreboard() throws IOException {
56: // XXX Need to write the head
57: }
58:
59: public int invoke(Msg msg, MsgContext ep) throws IOException {
60: System.err.println("ChannelShm14.invoke: " + ep);
61:
62: //
63:
64: return 0;
65: }
66:
67: public void initCli() {
68: }
69:
70: public static void main(String args[]) {
71: try {
72: Shm14 shm = new Shm14();
73:
74: if (args.length == 0 || ("-?".equals(args[0]))) {
75: shm.setHelp(true);
76: return;
77: }
78:
79: IntrospectionUtils.processArgs(shm, args);
80: shm.execute();
81: } catch (Exception ex) {
82: ex.printStackTrace();
83: }
84: }
85:
86: }
|