Example usage for com.liferay.portal.kernel.jsonwebservice JSONWebServiceActionsManagerUtil registerJSONWebServiceAction

List of usage examples for com.liferay.portal.kernel.jsonwebservice JSONWebServiceActionsManagerUtil registerJSONWebServiceAction

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.jsonwebservice JSONWebServiceActionsManagerUtil registerJSONWebServiceAction.

Prototype

public static void registerJSONWebServiceAction(String contextName, String contextPath, Object actionObject,
            Class<?> actionClass, Method actionMethod, String path, String method) 

Source Link

Usage

From source file:com.liferay.alloy.mvc.jsonwebservice.AlloyControllerInvokerManager.java

License:Open Source License

public void registerController(ThemeDisplay themeDisplay, AlloyPortlet alloyPortlet, Portlet portlet,
        String controller, Class<? extends AlloyController> controllerClass) {

    if (_locked) {
        return;//from  ww w .  j  a  v  a2 s  .  com
    }

    if (_alloyControllerInvokers.containsKey(controller)) {
        AlloyControllerInvoker alloyControllerInvoker = _alloyControllerInvokers.get(controller);

        JSONWebServiceActionsManagerUtil.unregisterJSONWebServiceActions(alloyControllerInvoker);
    }

    Class<? extends AlloyControllerInvoker> alloyControllerInvokerClass = null;

    AlloyControllerInvoker alloyControllerInvoker = null;

    try {
        alloyControllerInvokerClass = createAlloyControllerInvokerClass(controllerClass);

        Constructor<? extends AlloyControllerInvoker> constructor = alloyControllerInvokerClass
                .getConstructor();

        alloyControllerInvoker = constructor.newInstance();

        alloyControllerInvoker.setProperties(themeDisplay, alloyPortlet, portlet, controller, controllerClass);

        _alloyControllerInvokers.put(controller, alloyControllerInvoker);
    } catch (NoClassNecessaryException ncne) {
        return;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    for (Method method : alloyControllerInvokerClass.getDeclaredMethods()) {
        JSONWebServiceActionsManagerUtil.registerJSONWebServiceAction(_contextName, _contextPath,
                alloyControllerInvoker, alloyControllerInvokerClass, method, getAPIPath(controller, method),
                "GET");
    }
}