Recently, I have integrated DWR (direct web remoting) in a spring application. There are some ways to do that, I'm going to explain only one, that uses spring support for namespaces introduced since Spring 2.0.
The first step is adding a new servlet in web.xml and map it to /dwr/*:
Second step is adding the namespace to our applicationContext:
This allows us to use DWR namespace for spring. Now, we are able to add the DWR controller to manage DWR requests:
We have setup dwr with spring, it's as easy as it seems. Supposing we have a service that returns a java.util.List of Article class. Article could be a simple bean like this:
To setup getLastArticles() as a remote ajax method with Spring we only have to annotate the related ArticleService spring bean:
That's all. We are telling DWR to convert our bean Article to JSON. And, only the method specified in dwr:include tag, is callable by ajax. We can call this method from any view in our web application. In the next episode, I will explain how.
Using DWR with Springframework (II)
lunes, 27 de julio de 2009
Deploying your own jar in OC4J 10.1.3
I recently had a big problem working with Oracle Application Server 10.1.3 at work. We are developing a web application based on spring and hibernate. The application was only an Eclipse project, and I thought that it was a mistake because we were mixing in a single project business layer, controller, view, and data acces. So, I thought splitting the project in some little ones, would be a great deal:
Extension-Name: com.yourcompany.yourpackage
Specification-Title:
Specification-Version:
Specification-Vendor:
Implementation-Version:
Implementation-Vendor-Id: com.yourcompany.yourpackage
Implementation-Vendor:
Implementation-Title:
Obviously, you have to fill-in the file with the appropiate values. The second step is including our manifest.mf file in maven's build:
Now, the next time you run mvn package your manifest.mf will be included in your jar and oc4j classloader will load your own jars.
- Model: a project containing domain code, in our case, hibernate entities.
- DAO: Data acces objects.
- DTO: Data transfer objects.
- Util: util classes.
- Service: Business code.
- Web: Web app, controllers and configuration files (application context, hibernate maps, etc...)
Extension-Name: com.yourcompany.yourpackage
Specification-Title:
Specification-Version:
Specification-Vendor:
Implementation-Version:
Implementation-Vendor-Id: com.yourcompany.yourpackage
Implementation-Vendor:
Implementation-Title:
Obviously, you have to fill-in the file with the appropiate values. The second step is including our manifest.mf file in maven's build:
Now, the next time you run mvn package your manifest.mf will be included in your jar and oc4j classloader will load your own jars.
Suscribirse a:
Comentarios (Atom)