EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveremoting.caucho]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractRemoteServiceInvoker.java]

nameclass, %method, %block, %line, %
AbstractRemoteServiceInvoker.java0%   (0/1)0%   (0/3)0%   (0/233)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractRemoteServiceInvoker0%   (0/1)0%   (0/3)0%   (0/233)0%   (0/41)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
AbstractRemoteServiceInvoker (PublishServiceContribution, SerializerFactory):... 0%   (0/1)0%   (0/47)0%   (0/9)
invoke (HttpServletRequest, HttpServletResponse): void 0%   (0/1)0%   (0/182)0%   (0/31)

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.hiveremoting.caucho;
16 
17import java.io.InputStream;
18import java.io.OutputStream;
19import java.util.Enumeration;
20import java.util.HashMap;
21import java.util.Map;
22 
23import javax.servlet.ServletException;
24import javax.servlet.http.HttpServletRequest;
25import javax.servlet.http.HttpServletResponse;
26 
27import org.apache.commons.logging.Log;
28import org.apache.commons.logging.LogFactory;
29import org.apache.hivemind.internal.ServicePoint;
30 
31import com.caucho.hessian.io.SerializerFactory;
32 
33/**
34 * @author Jean-Francois Poilpret
35 */
36public abstract class AbstractRemoteServiceInvoker implements RemoteServiceInvoker
37{
38        static private final Log        _logger = LogFactory.getLog(AbstractRemoteServiceInvoker.class);
39 
40        protected AbstractRemoteServiceInvoker(        PublishServiceContribution        contrib,
41                                                                                        SerializerFactory                        factory)
42        {
43                ServicePoint service = contrib.getServiceId();
44                _logger.debug("<init> '" + service.getExtensionPointId() + "'");
45                _factory = factory;
46                _serviceId = contrib.getUrlPath();
47                _secure = contrib.isSecure();
48                _handler = contrib.getContextHandler();
49                _logger.debug("<init> '" + service.getExtensionPointId() + "' ended");
50        }
51 
52        //CSOFF: IllegalCatchCheck
53        public void        invoke(HttpServletRequest request, HttpServletResponse response)
54                throws ServletException
55        {
56                if (_secure && !request.isSecure())
57                {
58                        _logger.error("invoke(" + _serviceId + ") request is not secure");
59                        throw new ServletException("Request must be secure but is not!");
60                }
61                if (_handler != null)
62                {
63                        Map<String, String> context = new HashMap<String, String>();
64                        //#### Note that the following call may return null with some
65                        // Servlet Containers (which ones? I dunno)
66                        Enumeration headers = request.getHeaderNames();
67                        while (headers.hasMoreElements())
68                        {
69                                String key = (String) headers.nextElement();
70                                String value = request.getHeader(key);
71                                context.put(key, value);
72                        }
73                        _handler.extractContext(context);
74                }
75                try
76                {
77                        invoke(request.getInputStream(), response.getOutputStream());
78                }
79                catch (RuntimeException e)
80                {
81                        _logger.error("invoke(" + _serviceId + ")", e);
82                        throw e;
83                }
84                catch (ServletException e)
85                {
86                        _logger.error("invoke(" + _serviceId + ")", e);
87                        throw e;
88                }
89                catch (Throwable e) 
90                {
91                        _logger.error("invoke(" + _serviceId + ")", e);
92                        throw new ServletException(e);
93                }
94                finally
95                {
96                        if (_handler != null)
97                        {
98                                Map<String, String> context = new HashMap<String, String>();
99                                _handler.initContext(context);
100                                for (Map.Entry<String, String> entry: context.entrySet())
101                                {
102                                        response.setHeader(entry.getKey(), entry.getValue());
103                                }
104                        }
105                }
106        }
107        //CSON: IllegalCatchCheck
108 
109        //CSOFF: IllegalThrowsCheck
110        abstract protected void        invoke(InputStream is, OutputStream os)
111                throws Throwable;
112        //CSON: IllegalThrowsCheck
113 
114        protected final SerializerFactory                _factory;
115        protected final String                                        _serviceId;
116        protected final boolean                                        _secure;
117    protected final RemoteContextHandler        _handler;
118}

[all classes][net.sourceforge.hiveremoting.caucho]
EMMA 2.0.5312 (C) Vladimir Roubtsov