| Subcribe via RSS

My little example of Aspect-Oriented Programming

April 25th, 2008 | No Comments | Posted in AOP

I have been reading the SpringFramework for like 2 days and AOP. I just want to give out an example of AOP. I don’t want to use and technical words, such as Point-cut, or advice, etc, because It’s too hard to define those words for me. ^_^

I will present the easiest example. If developers want to add more function to a class, like logging. The code in classes will be like mess. Like these

// codes for logging
// your codes //transaction code
// another code

It’s too mess for production. Here the AOP would help you. You can add logging method to your production and create a XML or configuration (AOP configuration) and let the method you just created execute before or after your execution point or even around. This solution would not affect you production at all, because the logging code runs across your production not with your production. If developers feel bad about the new code, they can just drop it out of the production. It would not affect your production at all. It’s like the new code run across the old code.


Here’s your transaction service, and you would like to add logging service to your production.


an OOP would be like this. The logging service would run along with the transaction service. Developers have to decode the production or might have to redeploy the production again. What if you cannot drop the production, because it’s running?

Here’s the AOP comes and helps developers. Developers create logging service without to decode the production or even drop the production off. They just create a logging service and deploy the logging service which runs across with the production. It’s called Cross-cutting concerns. The production would not be affected at all.

Tutorial : AOP (Aspect-oriented Programming)

April 24th, 2008 | No Comments | Posted in AOP

Last night, I was amazed by Spring Framework, I have been reading this book for four hours and I ended up with AOP. I would like to summary my thoughts through this website. I will come back and write again this evening.

However, I cannot, in the name of god, explain these definitions better than this man. P’Chanwit’s blog
He explained the definitions very clearly. Moreover, this is from Narisa.com blog. So, I would not be competitive.

I will present an easier example later in the next topic.

Tutorial : Struts version 1 in action

April 20th, 2008 | No Comments | Posted in Struts

From the previous chapter, I wrote about how to build an EJB from scratch. This topic, I will be presenting how to combine struts version 1 with the previous topic.

First, we need the latest struts version 1. Actually, I wanted to write about struts2, but I don’t have enough energy to do that, because struts version2 is very difference to version1. So, I will write version 1 first and then migrate to version2 later.

This is the difference between Struts1 and Struts2

So, First we need to look at the hierarchy of the project. We have

src folder: where you can keep your .java files.
WebContent folder: where you can keep your content files, such as .jsp files and libs. In WebContent we have to create WEB-INF to store web.xml and struts-config.xml to tell struts that we are using Struts Framework.
WebContent/WEB-INF/classes
folder: this folder we can keep our .class files.

The next thing is we have to modified web.xml to tell java that we are going to use Struts and configure about struts-config.xml.

Next, modified the index.jsp to use struts taglib

Now, we are heading to code the main program. I have created TestStrutsEJBAction.java which is extended from org.apache.struts.action.Action in Struts1 we have to extend org.apache.struts.action.Action, but in Struts2 we don’t have to extend Action, just the class that implements execute method.

After we have created Action class we have to create ActionForm that request the parameters from the form, or jsp file. This class have to extend ActionForm, or we can develop more than that by extending ValidateForm. This class have to have parameters that the names match the jsp file inside html:form.

The last thing is the key file, struts-config.xml

This is the end, the next thing is we pack this project and deploy to application server. We can use ANT or any framework you like.

This is the example of my build.xml file, I use ANY, because I want to build my project from scratch. If you can use Eclipse to deploy to the application server, that’s fine. In build.xml I use war task to pack all the files you needed to WAR.

So, I can summary into the following steps
1. Create Struts project and include all the filed the project need, such as struts libraries.
2. Config web.xml and struts.xml
3. Write Jsp file, modified by using struts taglib, you can use plain html if you want.
4. Write Action class which extends org…struts.action.Action.
5. Write ActionForm which extends org…struts.action.ActionForm.
6. Pack the project into war file.
7. Deploy into application server.

Next topic, I will be improving this project by using AJAX.

Tags:

Tutorial : Oracle Web Portal

April 18th, 2008 | No Comments | Posted in Applications, Oracle, Web Portal

Yesterday, I had a chance to study Oracle Web Portal with my latest company, they ask me to research portal before I will be being trained this Saturday.

So, first thing first I have to know what is web portal, I cannot give this definition better than wikipedia, thus I hand out this task to them. The Definition. I will give just a brief definition. It’s just like a dynamic web, which you can add Portlets to the web and create report and form within a click. It’s easy to mange and administer, because oracle has lots of tools to do those tasks. Or regions, items, tabs and portlets can be added to the web without write a single code. You can maintain web portal graphically. Users and Groups can also be maintained, hence the administrator can grant accessibility to users and groups so they can access to which pages and which portlets they can use. Users and groups are come from LADP (Oracle Internet Directory).

The best example I can give you is http://www.yahoo.com. It’s has lots of portlets in their web, such as weather, stock prices, etc… . Or if I want to say, web portal is a CMS (Content Management System) that can add a small application that can do certain function to a web. Moreover, developers can also develop their own portlets and deploy on a web application server and register portlets to web portal.

More information?

Tags: , ,

Tutorial : XSD and XML

April 5th, 2008 | No Comments | Posted in XML

I encountered this problem once, when I was taking the exam. It was hard, because I haven’t done this thing before. So, I decided to post this topic to remember my thought.

XSD is a XML Schema Definition. It’s like the file that describes XML document. In this topic, I will be writing some sample documents about XSD.

Reference:

Tags: ,