EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.util]

COVERAGE SUMMARY FOR SOURCE FILE [VersionControlFilter.java]

nameclass, %method, %block, %line, %
VersionControlFilter.java100% (1/1)100% (6/6)75%  (49/65)82%  (18/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VersionControlFilter100% (1/1)100% (6/6)75%  (49/65)82%  (18/22)
doFilter (ServletRequest, ServletResponse, FilterChain): void 100% (1/1)59%  (23/39)67%  (8/12)
VersionControlFilter (): void 100% (1/1)100% (3/3)100% (1/1)
destroy (): void 100% (1/1)100% (1/1)100% (1/1)
init (FilterConfig): void 100% (1/1)100% (1/1)100% (1/1)
init (HttpServletRequest): void 100% (1/1)100% (7/7)100% (3/3)
initService (HttpServletRequest): void 100% (1/1)100% (14/14)100% (4/4)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.util;
16 
17import java.io.IOException;
18 
19import javax.servlet.Filter;
20import javax.servlet.FilterChain;
21import javax.servlet.FilterConfig;
22import javax.servlet.ServletException;
23import javax.servlet.ServletRequest;
24import javax.servlet.ServletResponse;
25import javax.servlet.http.HttpServletRequest;
26import javax.servlet.http.HttpServletResponse;
27 
28import org.apache.hivemind.Registry;
29import org.apache.hivemind.servlet.HiveMindFilter;
30 
31import com.caucho.hessian.io.HessianOutput;
32 
33/**
34 * This filter checks the version of the client and possibly return an exception
35 * through Hessian protocol.
36 *
37 * @author Jean-Francois Poilpret
38 */
39public class VersionControlFilter implements Filter
40{
41        public void init(FilterConfig config) throws ServletException
42        {
43        }
44        
45        public void destroy()
46        {
47        }
48        
49        public void doFilter(        ServletRequest        request, 
50                                                        ServletResponse        response, 
51                                                        FilterChain                chain)
52                throws IOException, ServletException
53        {
54                HttpServletRequest req = (HttpServletRequest) request;
55                HttpServletResponse res = (HttpServletResponse) response;
56 
57                init(req);
58 
59                // Check client version and set server version on response
60                Exception e = _controller.checkClientVersion(req, res);
61                
62                // If client version not supported
63                if (e == null)
64                {
65                        chain.doFilter(request, response);
66                }
67                else
68                {
69                        // And serialize it through hessian
70                        HessianOutput out = new HessianOutput(response.getOutputStream());
71                        out.startReply();
72                        out.writeFault("ServiceException", e.getMessage(), e);
73                        out.completeReply();
74                }
75        }
76        
77        protected void        init(HttpServletRequest request)
78        {
79                if (_controller == null)
80                {
81                        initService(request);
82                }
83        }
84 
85        synchronized protected void        initService(HttpServletRequest request)
86        {
87                if (_controller == null)
88                {
89                        Registry registry = HiveMindFilter.getRegistry(request);
90                        _controller = (VersionControlManager) registry.getService(
91                                        "hiveboard.server.VersionController", VersionControlManager.class);
92                }
93        }
94        
95        private VersionControlManager        _controller;
96}

[all classes][net.sourceforge.hiveboard.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov