01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.jk.common;
19:
20: import java.io.IOException;
21: import java.io.RandomAccessFile;
22: import java.nio.MappedByteBuffer;
23: import java.nio.channels.FileChannel;
24:
25: import org.apache.jk.core.Msg;
26: import org.apache.jk.core.MsgContext;
27: import org.apache.tomcat.util.IntrospectionUtils;
28:
29: /** Shm implementation using JDK1.4 nio.
30: *
31: *
32: * @author Costin Manolache
33: */
34: public class Shm14 extends Shm {
35:
36: // Not ready yet.
37:
38: private static org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory
39: .getLog(Shm14.class);
40:
41: MappedByteBuffer bb;
42:
43: public void init() {
44: try {
45: RandomAccessFile f = new RandomAccessFile(file, "rw");
46: FileChannel fc = f.getChannel();
47:
48: bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, f.length());
49: } catch (IOException ex) {
50: ex.printStackTrace();
51: }
52: }
53:
54: public void dumpScoreboard(String file) {
55: // We can only sync with our backing store.
56: bb.force();
57: // XXX we should copy the content to the file
58: }
59:
60: public void resetScoreboard() throws IOException {
61: // XXX Need to write the head
62: }
63:
64: public int invoke(Msg msg, MsgContext ep) throws IOException {
65: if (log.isDebugEnabled())
66: log.debug("ChannelShm14.invoke: " + ep);
67:
68: //
69:
70: return 0;
71: }
72:
73: public void initCli() {
74: }
75:
76: public static void main(String args[]) {
77: try {
78: Shm14 shm = new Shm14();
79:
80: if (args.length == 0 || ("-?".equals(args[0]))) {
81: shm.setHelp(true);
82: return;
83: }
84:
85: IntrospectionUtils.processArgs(shm, args);
86: shm.execute();
87: } catch (Exception ex) {
88: ex.printStackTrace();
89: }
90: }
91:
92: }
|