All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.enunciate.modules.gwt.gwt-legacy-endpoint-interface.fmt Maven / Gradle / Ivy

Go to download

The Enunciate GWT module generates the artifacts to support the GWT application.

There is a newer version: 1.31
Show newest version
[#ftl]
[#--template for the client-side endpoint interface.--]
[@file name=("GWT" + endpointInterface.simpleName + ".java")  package=packageFor(endpointInterface) charset="utf-8"]
/**
 * ${(generatedCodeLicense!"")?replace("\n", "\n * ")}
 *
 * Generated by Enunciate.
 */
package ${packageFor(endpointInterface)};

/**
 * ${endpointInterface.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n * ")}
 */
public interface GWT${endpointInterface.simpleName} extends com.google.gwt.user.client.rpc.RemoteService {
  [@forEachWebMethod endpointInterface=endpointInterface considerFacets="true"]

  /**
   * ${webMethod.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n   * ")}
   */
  ${classnameFor(webMethod.webResult)} ${webMethod.simpleName}([#list webMethod.webParameters as param]${classnameFor(param)} ${param.simpleName}[#if param_has_next], [/#if][/#list]) [#if webMethod.webFaults?size > 0]throws [#list webMethod.webFaults as fault]${classnameFor(fault)}[#if fault_has_next], [/#if][/#list][/#if];
  [/@forEachWebMethod]

}
[/@file]
[@file name=("GWT" + endpointInterface.simpleName + "Async.java")  package=packageFor(endpointInterface) charset="utf-8"]
/**
 * ${(generatedCodeLicense!"")?replace("\n", "\n * ")}
 *
 * Generated by Enunciate.
 */
package ${packageFor(endpointInterface)};

/**
 * ${endpointInterface.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n * ")}
 */
public interface GWT${endpointInterface.simpleName}Async {
  [@forEachWebMethod endpointInterface=endpointInterface considerFacets="true"]

  /**
   * ${webMethod.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n   * ")}
   */
  void ${webMethod.simpleName}([#list webMethod.webParameters as param]${classnameFor(param)} ${param.simpleName}, [/#list]com.google.gwt.user.client.rpc.AsyncCallback callback);
  [/@forEachWebMethod]

}
[/@file]
[@file name=(endpointInterface.simpleName + ".java")  package=packageFor(endpointInterface) charset="utf-8"]
/**
 * ${(generatedCodeLicense!"")?replace("\n", "\n * ")}
 *
 * Generated by Enunciate.
 */
package ${packageFor(endpointInterface)};

/**
 * ${endpointInterface.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n * ")}
 */
public class ${endpointInterface.simpleName} {

  private final GWT${endpointInterface.simpleName}Async asyncInstance;

  public ${endpointInterface.simpleName}() {
    this("${baseDeploymentAddress}${gwtSubcontext}/${endpointInterface.serviceName}");
  }

  public ${endpointInterface.simpleName}(String url) {
    this.asyncInstance = (GWT${endpointInterface.simpleName}Async) com.google.gwt.core.client.GWT.create(GWT${endpointInterface.simpleName}.class);
    ((com.google.gwt.user.client.rpc.ServiceDefTarget) asyncInstance).setServiceEntryPoint(url);
  }

  [@forEachWebMethod endpointInterface=endpointInterface considerFacets="true"]

  /**
   * ${webMethod.docComment?default("(no documentation provided)")?chop_linebreak?replace("\n", "\n   * ")}
   */
  public void ${webMethod.simpleName}([#list webMethod.webParameters as param]${classnameFor(param)} ${param.simpleName}, [/#list]final ${webMethod.operationName?cap_first}ResponseCallback callback) {
    getAsyncInstance().${webMethod.simpleName}([#list webMethod.webParameters as param]${param.simpleName}, [/#list]new com.google.gwt.user.client.rpc.AsyncCallback() {
      public void onSuccess(Object object) {
      [#if !webMethod.returnType.void]
        [#if !webMethod.returnType.primitive]
        callback.onResponse((${classnameFor(webMethod.webResult)}) object);
        [#else]
        callback.onResponse(([@primitiveWrapper type=webMethod.returnType/]) object);
        [/#if]
      [#else]
        callback.onSuccess();
      [/#if]
      }

      public void onFailure(Throwable throwable) {
        callback.onError(throwable);
      }
    });
  }
  [/@forEachWebMethod]

  private GWT${endpointInterface.simpleName}Async getAsyncInstance() {
    return asyncInstance;
  }
  [@forEachWebMethod endpointInterface=endpointInterface considerFacets="true"]

  /**
   * Response callback for asynchronous calls to ${webMethod.simpleName}([#list webMethod.webParameters as param]${classnameFor(param)}[#if param_has_next], [/#if][/#list]).
   */
  public static interface ${webMethod.operationName?cap_first}ResponseCallback {
      [#if !webMethod.returnType.void]

    /**
     * Called asynchronously when a response is recieved.
     *
     * @param response The response.
     */
        [#if !webMethod.returnType.primitive]
    void onResponse(${classnameFor(webMethod.webResult)} response);
        [#else]
    void onResponse([@primitiveWrapper type=webMethod.returnType/] response);
        [/#if]
      [#else]
    /**
     * Called asynchronously on success of the call.
     */
    void onSuccess();
      [/#if]

    /**
     * Called asynchronously when an error is thrown.
     *
     * @param throwable The error that was thrown.
     */
    void onError(Throwable throwable);

  }
  [/@forEachWebMethod]

}
[/@file]




© 2015 - 2024 Weber Informatics LLC | Privacy Policy