KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jk > common > Shm14


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import java.io.RandomAccessFile JavaDoc;
21 import java.nio.MappedByteBuffer JavaDoc;
22 import java.nio.channels.FileChannel JavaDoc;
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     
35     
36     // Not ready yet.
37

38     private static org.apache.commons.logging.Log log=
39         org.apache.commons.logging.LogFactory.getLog( Shm14.class );
40     
41     MappedByteBuffer JavaDoc bb;
42
43     public void init() {
44         try {
45             RandomAccessFile JavaDoc f=new RandomAccessFile JavaDoc( file, "rw" );
46             FileChannel JavaDoc fc=f.getChannel();
47             
48             bb=fc.map( FileChannel.MapMode.READ_WRITE, 0, f.length());
49         } catch( IOException JavaDoc ex ) {
50             ex.printStackTrace();
51         }
52     }
53
54     public void dumpScoreboard(String JavaDoc 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 JavaDoc {
61         // XXX Need to write the head
62
}
63
64
65     public int invoke(Msg msg, MsgContext ep )
66         throws IOException JavaDoc
67     {
68         if (log.isDebugEnabled())
69             log.debug("ChannelShm14.invoke: " + ep );
70
71         //
72

73         return 0;
74     }
75
76     public void initCli() {
77     }
78
79     public static void main( String JavaDoc args[] ) {
80         try {
81             Shm14 shm=new Shm14();
82
83             if( args.length == 0 ||
84                 ( "-?".equals(args[0]) ) ) {
85                 shm.setHelp( true );
86                 return;
87             }
88
89             IntrospectionUtils.processArgs( shm, args);
90             shm.execute();
91         } catch( Exception JavaDoc ex ) {
92             ex.printStackTrace();
93         }
94     }
95
96 }
97
Popular Tags