    001    package org.apache.turbine.services.jsonrpc;
    002
    003    /*
    004     * Licensed to the Apache Software Foundation (ASF) under one
    005     * or more contributor license agreements.  See the NOTICE file
    006     * distributed with this work for additional information
    007     * regarding copyright ownership.  The ASF licenses this file
    008     * to you under the Apache License, Version 2.0 (the
    009     * "License"); you may not use this file except in compliance
    010     * with the License.  You may obtain a copy of the License at
    011     *
    012     *   http://www.apache.org/licenses/LICENSE-2.0
    013     *
    014     * Unless required by applicable law or agreed to in writing,
    015     * software distributed under the License is distributed on an
    016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017     * KIND, either express or implied.  See the License for the
    018     * specific language governing permissions and limitations
    019     * under the License.
    020     */
    021
    022    import java.io.CharArrayWriter;
    023
    024    import javax.servlet.http.HttpServletRequest;
    025    import javax.servlet.http.HttpSession;
    026
    027    import org.apache.turbine.services.TurbineServices;
    028
    029    import com.metaparadigm.jsonrpc.JSONRPCBridge;
    030
    031    /**
    032     * This is a static accessor class for {@link JsonRpcService}.
    033     *
    034     * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    035     * @version $Id: TurbineJsonRpc.java 712125 2008-11-07 13:47:28Z seade $
    036     */
    037    public abstract class TurbineJsonRpc
    038    {
    039        /**
    040         * Returns system's configured implementation of {@link JsonRpcService}.
    041         *
    042         * @return an implementation of <code>JsonRpcService</code>
    043         */
    044        public static JsonRpcService getService()
    045        {
    046            return (JsonRpcService) TurbineServices.getInstance()
    047                    .getService(JsonRpcService.SERVICE_NAME);
    048        }
    049
    050        public static Object processCall(CharArrayWriter cdata,
    051                JSONRPCBridge json_bridge, HttpServletRequest request)
    052        {
    053            return getService().processCall(cdata, json_bridge, request);
    054        }
    055
    056        public static void registerObject(HttpSession session, String key, Object value)
    057        {
    058            getService().registerObject(session, key, value);
    059        }
    060
    061        public static void registerObjectGlobal(String key, Object value)
    062        {
    063            getService().registerObjectGlobal(key, value);
    064        }
    065
    066        public static JSONRPCBridge getBridge(HttpSession session)
    067        {
    068            return getService().getBridge(session);
    069        }
    070
    071        public static void clearBridge(HttpSession session)
    072        {
    073            getService().clearBridge(session);
    074        }
    075    }