KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > frontend > SetVersionHeaderAction


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
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 package org.outerj.daisy.frontend;
17
18 import org.apache.cocoon.acting.Action;
19 import org.apache.cocoon.environment.*;
20 import org.apache.avalon.framework.thread.ThreadSafe;
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.avalon.framework.activity.Initializable;
23 import org.outerj.daisy.util.VersionHelper;
24
25 import java.util.Map JavaDoc;
26
27 /**
28  * Sets a HTTP header containing the Daisy Version.
29  * This action should typically be put somewhere at the start of the sitemap.
30  */

31 public class SetVersionHeaderAction implements Action, ThreadSafe, Initializable {
32     private static String JavaDoc versionString;
33
34     public void initialize() throws Exception JavaDoc {
35         versionString = VersionHelper.getVersionString(SetVersionHeaderAction.class.getClassLoader(),
36                 "org/outerj/daisy/frontend/versioninfo.properties");
37     }
38
39     public Map JavaDoc act(Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc source, Parameters parameters) throws Exception JavaDoc {
40         Response response = ObjectModelHelper.getResponse(objectModel);
41         response.setHeader("X-Daisy-Version", versionString);
42         return null;
43     }
44 }
45
Popular Tags