Question

I cannot find an answer in the Google docs. As I understand from the docs, the @Api annotation is applied to a class to indicate that it is part of the Endpoint API and the @ApiMethod then indicates which methods of that class is part of the Cloud API.

However, even if a method is not annotated with @ApiMethod the Google App Engine Cloud Endpoints Builder still includes that method as part of the Cloud API.

How can I exclude a method from the API? If it is not possible, is a good alternative then to pass the received API parameters to a separate object (which is a field of the annotated class) that do contain the required method?

I include the following code which is a class annotated with @Api for clarification (see comment on top of ggetStr method):

package com.barcodeapp.www.app;

import java.util.ArrayList;
import java.util.List;

import com.google.api.server.spi.config.Api;

@Api(
    name = "cetest",
    version = "v1",
    scopes = {EndpointsConstants.EMAIL_SCOPE},
    clientIds = {EndpointsConstants.WEB_CLIENT_ID, EndpointsConstants.ANDROID_CLIENT_ID, com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID},
    audiences = {EndpointsConstants.ANDROID_AUDIENCE}
)
public class CloudTest  {

   public List<String> list() {
        List<String> strs = new ArrayList<String>();
        strs.add("a"); strs.add("b");
        return strs;
   }

   /* THE FOLLOWING METHOD NEEDS TO BE EXCLUDED FROM CLOUD API */
   public String ggetStr() {
       return "abc";
   }

}

EDIT: I have included the library .jar file in the WAR/WEB-INF/lib folder - no difference.

Below is the two classes for completeness:

package com.cloudtest.lib;

public class ClassInLibProj {

}

and

package com.cloudtest.my;

public class ClassInLocalProj {

}

Thanks.

Was it helpful?

Solution

I may be wrong, but it seems that the only way currently for your method not to be included is to make that private in your class.

This is because:

  • If your method is annotated with APIMethod, then it is included
  • If you method is not annotated with APIMethod but it is public, it is taken too. This is likely because of the API annotation at the top.

There is an issue raised : https://code.google.com/p/googleappengine/issues/detail?id=10372&thanks=10372&ts=1386300958

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top