##### Coverage Report - org.apache.turbine.services.jsonrpc.TurbineJsonRpcService

Classes in this File | Line Coverage | Branch Coverage | Complexity
TurbineJsonRpcService |
0% | 0/18
0% | 0/2
| 1.2;1,2

1 |  |
     package org.apache.turbine.services.jsonrpc;
2 |  |
3 |  |
     /*
4 |  |
      * Licensed to the Apache Software Foundation (ASF) under one
5 |  |
      * or more contributor license agreements.  See the NOTICE file
6 |  |
      * distributed with this work for additional information
7 |  |
      * regarding copyright ownership.  The ASF licenses this file
8 |  |
      * to you under the Apache License, Version 2.0 (the
9 |  |
      * "License"); you may not use this file except in compliance
10 |  |
      * with the License.  You may obtain a copy of the License at
11 |  |
      *
12 |  |
      *   http://www.apache.org/licenses/LICENSE-2.0
13 |  |
      *
14 |  |
      * Unless required by applicable law or agreed to in writing,
15 |  |
      * software distributed under the License is distributed on an
16 |  |
      * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 |  |
      * KIND, either express or implied.  See the License for the
18 |  |
      * specific language governing permissions and limitations
19 |  |
      * under the License.
20 |  |
      */
21 |  |
22 |  |
     import java.io.CharArrayWriter;
23 |  |
24 |  |
     import javax.servlet.http.HttpServletRequest;
25 |  |
     import javax.servlet.http.HttpSession;
26 |  |
27 |  |
     import org.apache.commons.logging.Log;
28 |  |
     import org.apache.commons.logging.LogFactory;
29 |  |
     import org.apache.turbine.services.TurbineBaseService;
30 |  |
31 |  |
     import com.metaparadigm.jsonrpc.JSONRPCBridge;
32 |  |
33 |  |
     /**
34 |  |
      * This is a service that will respond to JSON-RPC calls.
35 |  |
      *
36 |  |
      * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
37 |  |
      * @version $Id: TurbineJsonRpcService.java 712125 2008-11-07 13:47:28Z seade $
38 |  |
      */
39 | 0 |
     public class TurbineJsonRpcService
40 |  |
             extends TurbineBaseService
41 |  |
             implements JsonRpcService
42 |  |
     {
43 |  |
         /** Log. */
44 | 0 |
         private static Log log = LogFactory.getLog(TurbineJsonRpcService.class);
45 |  |
46 |  |
         /** The key used to store the bridge in the session. */
47 |  |
         public static final String JSON_BRIDGE_KEY = "JSONRPCBridge";
48 |  |
         /**
49 |  |
          * The debug option for the bridge can be enabled by enabling debug level
50 |  |
          * logging for this class.
51 |  |
          */
52 | 0 |
         private static final boolean DEBUG = log.isDebugEnabled();
53 |  |
54 |  |
         public Object processCall(CharArrayWriter cdata,
55 |  |
                 JSONRPCBridge json_bridge, HttpServletRequest request)
56 |  |
         {
57 | 0 |
             return JSONProcessor.processCall(cdata, json_bridge, request);
58 |  |
         }
59 |  |
60 |  |
         public void registerObjectGlobal(String key, Object value)
61 |  |
         {
62 | 0 |
             JSONRPCBridge.getGlobalBridge().setDebug(DEBUG);
63 | 0 |
             JSONRPCBridge.getGlobalBridge().registerObject(key, value);
64 | 0 |
         }
65 |  |
66 |  |
         public void registerObject(HttpSession session, String key, Object value)
67 |  |
         {
68 | 0 |
             JSONRPCBridge json_bridge = getBridge(session);
69 | 0 |
             json_bridge.setDebug(DEBUG);
70 | 0 |
             json_bridge.registerObject(key, value);
71 | 0 |
         }
72 |  |
73 |  |
         public JSONRPCBridge getBridge(HttpSession session)
74 |  |
         {
75 | 0 |
             JSONRPCBridge json_bridge = (JSONRPCBridge) session.getAttribute(JSON_BRIDGE_KEY);
76 | 0 |
             if (json_bridge == null)
77 |  |
             {
78 | 0 |
                 json_bridge = new JSONRPCBridge();
79 | 0 |
                 session.setAttribute(JSON_BRIDGE_KEY, json_bridge);
80 |  |
             }
81 | 0 |
             return json_bridge;
82 |  |
         }
83 |  |
84 |  |
         public void clearBridge(HttpSession session)
85 |  |
         {
86 | 0 |
             session.removeAttribute(JSON_BRIDGE_KEY);
87 | 0 |
         }
88 |  |
89 |  |
     // The following is modeled on XmlRpcSercice.
90 |  |
     //    /**
91 |  |
     //     * Initialize the JsonRpcService.
92 |  |
     //     *
93 |  |
     //     * @throws InitializationException Something went wrong in the init stage.
94 |  |
     //     */
95 |  |
     //    public void init() throws InitializationException
96 |  |
     //    {
97 |  |
     //        //Configuration conf = getConfiguration();
98 |  |
     //        setInit(true);
99 |  |
     //    }
100 |  |
     //
101 |  |
     //    /**
102 |  |
     //     * Shuts down this service, stopping running threads.
103 |  |
     //     */
104 |  |
     //    public void shutdown()
105 |  |
     //    {
106 |  |
     //        setInit(false);
107 |  |
     //    }
108 |  |
109 |  |
     }