0

I'm learning to use the Google App Engine for a project. I've created a sample web application with the java sdk, in which all the business logic is in the servlets.

Where should be right to put the business logic if I want also to expose the application functionalities through a RESTful web service (which I understood that is possible with additional framework as Restlet)?

There is any development framework that can help me in this?

shutdown11
  • 53
  • 1
  • 5

1 Answers1

1

Right place to put the business logic would certainly not be servlets. You should put logic in service, and data access classes. Be careful while choosing a framework on GAE as cold start may hurt badly. As for REST framework on GAE, RESTlet has gained some positive response.

Refer RESTful application on Google App Engine Java? and Implementing REST Service (JSON) on Google AppEngine

Community
  • 1
  • 1
kdabir
  • 9,623
  • 3
  • 43
  • 45
  • Thank you very much for your answer and references that you gave me. But I still have some doubts. Aren't Services just classes that extend Servlets for RPC needed in GWT? And how can I call a service from another Servlet? I wasn't able to find nothing about this. – shutdown11 Aug 04 '11 at 08:39
  • Generally speaking Services are indeed plain Java classes optionally implementing predefined interfaces (but do not have to extend Servlets as you mentioned). Now that you mentioned GWT, in this context services are used for RPC and they do extend GWT's RemoteServiceServlet. I am not very familiar with GWT. I would suggest reading GWT docs. But do not confuse yourself between REST services, and GWT services. They are different. – kdabir Aug 04 '11 at 14:11
  • Thank you for the clarification. I havent found anything about these Services, can you give me any references to the documentation or examples? How are they instantiated? – shutdown11 Aug 04 '11 at 16:57
  • Now when you say 'these Services', I am assuming you are talking about GWT services. check if [this](http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html) helps. – kdabir Aug 04 '11 at 17:31
  • No, sorry if I wasn't clear and I keep bothering you... I meant the services that you suggested, "plain Java classes optionally implementing predefined interfaces (but do not have to extend)"... I'd love to find any examples of them.. – shutdown11 Aug 04 '11 at 17:41
  • Usually service classes are kept stateless and are either injected with help of Spring or alike or are made singleton and looked up by Factories. That said, this is not a rule and Service classes can be stateful (like stateful EJBs). Service classes usually implement the contrac. See [this](http://stackoverflow.com/questions/871434/java-utility-class-vs-service) SO question and [this](http://appfuse.org/display/APF/Services) – kdabir Aug 04 '11 at 17:56
  • Thank you very much. The fact the GAE doesn't support EJBs was just the reason that pushed me to write this question. I will look through the examples you posted. – shutdown11 Aug 04 '11 at 18:13