Research Log of Web Science Students

Computer Science is not simply programming

Posts Tagged ‘Spring

Finally Speaking – Part 2

with one comment

So instead of bothering with adding Listeners by iteration, we did an object-oriented approach instead.

Well these are eye-openers for me, since I’m not used to object-oriented programming in web development.

Advertisements

Written by Paolo Sy

November 30, 2009 at 12:43 am

Posted in Hardwire

Tagged with , , ,

Into the fray

with one comment

In football, you know when a substitute is thrown into the fray when it’s extra time and his is team a goal behind. Although I can’t say that we’re a goal behind, we’re definitely a little bit behind schedule this week. Don’t ask me why. So I decided to wait a little bit and take a dip into web services.

So I guess I was wrong. There is a way to machine read dynamically generated pages. I met Miko, a WSG graduate student, last night and he told me that it’s definitely possible. It’s more or less like this: a crawling web agent will execute a script that will query the web service with parameters and then machine read the results.

All this time I’ve been assuming that the xml that will be machine read will be embedded in the jsp. Although I have seen somewhere that it’s possible, it’s probably not what is required. What is required is an rdf document that will contain information.
Read the rest of this entry »

Written by Jose Asuncion

November 25, 2009 at 7:00 pm

Posted in Hardwire

Tagged with , , , ,

Everyone, the power of polymorphism.

leave a comment »

remoteServiceServlet

I was able to implement a tutorial that exposes GWT RPC as a Spring Bean! Now I can make use of Dependency Injection to give the the GWT-RPC services its dependencies such as Data Access Objects and other service classes. Don’t I just love POJO based development? Most probably I can unit test this as well. Now that makes it sweeter!

The GWT community has come up with a solution to integrate GWT RPC into a Spring container. The key here is simply to find a way for RPCs to get into the Spring container and be forwarded to the server POJO. This was done by implementing the controller interface and then making use of GWT’s RemoteServletService and what have you to process the call.

This was done by

1. implementing Spring’s controller interface
2. inheriting GWT’s RemoteServletService

I understand a bit what’s going on in there and I have to say that was a really smart thing to do!

But I do have my comment

I think it’s too “heavy” for each service to be implemented as a controller. Maybe the GWTRPC controller can have a list of services which can be wired in Spring and the GWTRPC controller can figure out from the payload which class it will use.

Something like this

@Override
public String processCall(String payload) throws SerializationException {
RPCRequest rpcRequest = RPC.decodeRequest(payload,
            this.remoteServiceClass);

// delegate work to the spring injected service
return RPC.invokeAndEncodeResponse(this.remoteService, rpcRequest
        getMethod(), rpcRequest.getParameters());
}

instead of using this.remoteService, do something like getRemoteService(String payload) which returns the appropriate
service class.

Another job for another day I guess.

Written by Jose Asuncion

November 2, 2009 at 6:12 pm

Posted in Hardwire

Tagged with , ,

Learning GWT-RPC

leave a comment »

1. Well first off, I got to a bumpy start.  I wanted to add a GWT module to my developer sandbox but at first I didn’t know how.

You need a module file to make GWT work and the html file where the javascript generated by GWT will be hosted. Those are  pretty complicated to setup–manually. The module file is an xml file that needs a namespace and the javascript is very — well I don’t how to start explaining where to get that from. GWT doesn’t show you the generated javascript script.

But as it turns out, the GWT plug-in takes care of this for you! (Why didn’t I think of that in the first place?) Simply hit ctrl+n and create a module, html file or entry point.

2. So I tried applying what I’ve learned and after hurdling a few mistakes (no I still can’t make GWT RPC work), I finally find myself needing to learn how to integrate GWT with Spring for Hardwire’s requirements (since it uses the Spring framework).

This is the culprit:

<servlet-mapping>
        <servlet-name>SandboxServlet</servlet-name>
	<url-pattern>/</url-pattern>
</servlet-mapping>	

<servlet-mapping>
	<servlet-name>lookupService</servlet-name>
	<url-pattern>/Rex/lookup</url-pattern>
</servlet-mapping>

Instead of the RPC going to the lookupService, it goes to the DispatcherServlet a.k.a Sandbox. That’s why I get this error:

11 1, 09 5:20:59 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/org.sandbox.Rex/lookup] 
in DispatcherServlet with name 'sandbox'

I could do a workaround by making all the requests to the url /app/*, meaning dynamic pages to go to the Sandbox dispatcher servlet while on the other hand all rpc calls destined for the lookupService must address to the url services/*.

But this is ugly, would you want to type in http://hard-wire.appspot.com/app/ to go to hardwire? I didn’t think so.

Besides I’ve always wanted the the RPC service to be exposed as a spring bean so that I can make use of the other POJOs I’ve made.

Ergo, I am going back tomorrow and work on doing this tutorial instead. Pretty neat stuff if you ask me.

Written by Jose Asuncion

November 1, 2009 at 6:36 pm

Posted in Hardwire

Tagged with , ,

Stuck at a crossroad with GWT

leave a comment »

I am studying GWT so that Hardwire will now be AJAX enabled. It’s easier to do our client side code in GWT since there are a lot of professionally written libraries out there that we can harness, like drag and drop which is one of the features educators want in a Personal Learning Environment.

But I am a bit lost now.

I got off to a good start by learning the fundamentals of Client-Server communication with GWT.

Next, I jumped into unit testing GWT which from my experience makes software development faster.

 

But so far I find myself lacking in confidence. I haven’t tried writing code that makes an RPC and I can’t unit test my code because I am worried about GWT-Spring integration. Doing a google search only gives scary results. But I know GWT-Spring integration is vital because I need to use the Dependency Injection for the web services so that I can use the Spring beans that all the other components that Hardwire uses.

Take the persistence manager factory (pmf) for example, the documentation says that it is one of the most expensive things you can have in an instance of your app and that it should be only called once. I am sure some of our web services will need to hit the database, I just can’t tell what they are right now because we don’t know what features to implement yet. Thing is, HardWire only needs one pmf in the whole app.

That means whether you’re a GWT web service or a data access object the reference you have you to the pmf should only point to one pmf.

That means I have to find a way to integrate GWT web server into Spring.

But wait! I still have the issue of lack of confidence in using pure GWT client – server.

I feel I need to slow down a little bit. So where was I?

I pretty much know how to code UI with GWT.

I know, at least in theory, how to make a GWT RPC call and implement a GWT RPC server.

Next is unit testing and then integration with Spring.

Alright fine. Computer Science lessons come in lecture-lab combinations. I will practice doing client server first and then unit testing and then the part that creeps the hell out of me, Spring Integration.

Happy Halloween! 😀

Written by Jose Asuncion

October 31, 2009 at 3:36 pm

Posted in Hardwire

Tagged with , ,

Everything Needs Getting Used To

leave a comment »

Even web development under Java. Well, I’m enjoying JSP since it’s full of tags, but the behind-the-scenes work (i.e. packages, classes, and what-not) still manages to confuse me.

Written by Paolo Sy

September 15, 2009 at 10:31 pm

Posted in Hardwire

Tagged with , , ,

Libraries and Build Path

leave a comment »

Spring is harder to learn than I thought. There are lots of setting up to do and lots of concepts to grasp. The dependendy injection set up was confusing. Implementation, DAO, Service, Persistence, and many more must be set up before we could start coding. Some of the setup codes were quite advanced we don’t know why we should put them in the project. Gah! Spring gives us headache!

Spring is harder to learn than I thought. There are lots of setting up to do and lots of concepts to grasp. The dependendy injection set up was confusing. Implementation, DAO, Service, Persistence, and many more must be set up before we could start coding. Some of the setup codes were quite advanced we don’t know why we should put them in the project. Gah! Spring gives us headache!

Written by Daniela

September 14, 2009 at 3:22 pm

Posted in ProjectriX

Tagged with , , ,