Ejemplo n.º 1
0
  public void getActionMethodNames(
      ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException {

    PrintWriter printWriter = resourceResponse.getWriter();

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    String contextName = ParamUtil.getString(resourceRequest, "contextName");

    Map<String, Set<JSONWebServiceActionMapping>> jsonWebServiceActionMappingsMap =
        getServiceJSONWebServiceActionMappingsMap(contextName);

    String serviceClassName = ParamUtil.getString(resourceRequest, "serviceClassName");

    Set<JSONWebServiceActionMapping> jsonWebServiceActionMappingsSet =
        jsonWebServiceActionMappingsMap.get(serviceClassName);

    for (JSONWebServiceActionMapping jsonWebServiceActionMapping :
        jsonWebServiceActionMappingsSet) {

      JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

      Method method = jsonWebServiceActionMapping.getActionMethod();

      String actionMethodName = method.getName();

      jsonObject.put("actionMethodName", actionMethodName);

      jsonArray.put(jsonObject);
    }

    printWriter.write(jsonArray.toString());
  }
Ejemplo n.º 2
0
  protected JSONArray getServiceClassNamesToContextNamesJSONArray() {
    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    Set<String> contextNames = _jsonWebServiceActionsManager.getContextNames();

    for (String contextName : contextNames) {
      Map<String, Set<JSONWebServiceActionMapping>> jsonWebServiceActionMappingsMap =
          getServiceJSONWebServiceActionMappingsMap(contextName);

      for (Map.Entry<String, Set<JSONWebServiceActionMapping>> entry :
          jsonWebServiceActionMappingsMap.entrySet()) {

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

        jsonObject.put("serviceClassName", entry.getKey());

        Set<JSONWebServiceActionMapping> jsonWebServiceActionMappingsSet = entry.getValue();

        Iterator<JSONWebServiceActionMapping> iterator = jsonWebServiceActionMappingsSet.iterator();

        JSONWebServiceActionMapping firstJSONWebServiceActionMapping = iterator.next();

        jsonObject.put("contextName", firstJSONWebServiceActionMapping.getContextName());

        jsonArray.put(jsonObject);
      }
    }

    return jsonArray;
  }
Ejemplo n.º 3
0
  protected Map<String, Set<JSONWebServiceActionMapping>> getServiceJSONWebServiceActionMappingsMap(
      String contextName) {

    Map<String, Set<JSONWebServiceActionMapping>> jsonWebServiceActionMappingsMap =
        new LinkedHashMap<>();

    List<JSONWebServiceActionMapping> jsonWebServiceActionMappings =
        _jsonWebServiceActionsManager.getJSONWebServiceActionMappings(contextName);

    for (JSONWebServiceActionMapping jsonWebServiceActionMapping : jsonWebServiceActionMappings) {

      Object actionObject = jsonWebServiceActionMapping.getActionObject();

      Class<?> serviceClass = actionObject.getClass();

      Class[] serviceInterfaces = serviceClass.getInterfaces();

      for (Class<?> serviceInterface : serviceInterfaces) {
        Annotation[] declaredAnnotations = serviceInterface.getDeclaredAnnotations();

        for (Annotation declaredAnnotation : declaredAnnotations) {
          if (!(declaredAnnotation instanceof AccessControlled)) {
            continue;
          }

          String serviceClassName = serviceInterface.getName();

          Set<JSONWebServiceActionMapping> jsonWebServiceActionMappingsSet =
              jsonWebServiceActionMappingsMap.get(serviceClassName);

          if (jsonWebServiceActionMappingsSet == null) {
            jsonWebServiceActionMappingsSet = new LinkedHashSet<>();

            jsonWebServiceActionMappingsMap.put(serviceClassName, jsonWebServiceActionMappingsSet);
          }

          jsonWebServiceActionMappingsSet.add(jsonWebServiceActionMapping);
        }
      }
    }

    return jsonWebServiceActionMappingsMap;
  }