eGlobal Service Solutions Vietnam

————–***————- Building your dreams with my hands ————***————–

Building Struts2 Apps without XML Gluecode

Posted by kosoftvn on February 19, 2008

In this article, we jettison XML gluecode for “convention over configuration”. Using the SmartURLs plugin for Struts 2, we can autowire Action classes to page templates with search-engine-optimized URIs.

This article covers:

  • Exploiting convention over configuration
  • Eliminating XML gluecode
  • Validating input with annotations

What’s XML gluecode?

Success breeds success, and successful applications tend to grow larger and more complex over time. Most applications are so large and so complex that we can’t think about the entire application at once. To get through the day, we need to focus our attention on one thing at time.

One way to simplify complex applications is to separate concerns. We group similar tasks together, so that we can focus on one element of the application at a time. Two concerns that we like to separate are presentation logic and business logic. It’s easier to design presentation logic using a page template, and it’s easier to design business logic using conventional source code. Each concern is easy to manage on its own, but we need a way to put the concerns back together.

In a conventional Struts application, we glue concerns together using declarative statements in an XML document. In practice, we write a lot of XML stanzas that just say: “For this request, run this Java class and then render this page template.” “Example 1: struts.xml” shows a bit of XML gluecode.

“Example 1: struts.xml”

<action name="hello-world" class="actions.HelloWorld">
  <result>/results/hello-world.jsp</result>
</action>

At first, a dash of gluecode may seem trivial, but as applications grow in size, we can waste as much time fussing with gluecode as we spend on coding Action classes or writing JSP pages.

Nowadays, a popular way to avoid XML “gluecode” is to use “convention over configuration”.

What’s convention over configuration?

Instead of wiring components together with configuration files, another strategy is to use consistent naming conventions, and then make the conventions part of the application framework. Many Struts developers already use naming conventions to track which components go together. We just need to program the framework to observe the same kind of conventions that most of us already use.

For example, if a client requests a “hello-world.action”, it makes sense for the framework to look for a “HelloWorld.class” and/or a “hello-world.jsp”. If the Action class returns “small” as a result code, it makes sense to first look for a “hello-world-small.jsp” (or a “hello-world-small.vm”, you prefer Velocity templates). If “hello-world-small.jsp” is not found, then it would also make sense to check for a plain-old “hello-world.jsp”.

These matching rules may sound simplistic, but, in practice, a few simple rules is all that we need to write entire Struts applications without even a smidgeon of XML gluecode!

Should our conventions fall short, the SmartURLs plugin also provides annotations that we can use to override the matched action or result, on a case-by-case basis.

Does Struts 2 support convention over configuration by default?

The Struts 2 core offers a few features that can reduce configuration. But to get the full benefit of “convention over configuration”, we need to add a new plugin to the mix.

The SmartURLs plugin for Struts 2 (http://cwiki.apache.org/S2PLUGINS/smarturls-plugin.html) offers a full-featured approach to convention over configuration. A request for “/my-action” is automatically mapped to a MyAction class and the result to a my-action.jsp page. To keep the system flexible, heuristic defaults look for alternative matches if MyAction class or my-action.jsp is not present. The matching rules are laid out in “Sidebar 1: SmartURLs Rules”

“Sidebar 1: SmartURLs rules”

URL to Action class (/my/package/hello-world):

  • A-1 Extract the final URL path segment (hello-world).
  • A-2 Upper-case the initial letter, and if any hyphen appears within the URL path, upper-case any following letter, and remove the hyphen (HelloWorld).
  • A-3 Convert the rest of the path to lowercase, and substitute slashes with dots (my.package.).
  • A-4 Check the base action packages for a class matching package + action (actions.my.package.HelloWorld).
  • A-5 If a matching Action is not found, use the package’s default Action class (ActionSupport).

Result code to Path:

  • B-1 Append the result-code returned by an Action to original URL path (/my/package/hello-world-success).
  • B-2 Check the base result folders for a matching JSP, Freemarker Template, or Velocity Template (/WEB-INF/results/my/package/hello-world-success.jsp).
  • B-3 If the template is not found, remove the response code, and try again (/WEB-INF/result/my/package/hello-world.jsp).
  • B-4 Raise a standard 404 error is a matching template is not found.

SmartURLs provides features like:

  • Extensionless URIs
  • Automatic binding of action URLs to conventional class and page names
  • Action URI format that is “Search Engine Optimization” (SEO) compliant
  • Annotations to specify a different action name, or even multiple names
  • Automatic support of JSP, Freemarker, and Velocity result types
  • Robust “index” page handling (/products will match actions.Products or actions.products.Index)

How would we write a SmartURLs “Hello World” page?

Frameworks like Struts decompose an application’s workflow into a series of actions. Each action might have associated with it several concerns, including input validation, business logic, persistence logic, message resources, text formatting, and an output resource. Each action has its own context, and which concerns are applied to any given action may vary according to circumstance.

The simplest use case for an action is rendering a page template without specifying any other concerns. (Just show me the @%#$^ page!) For our SmartURLs hello world example, let’s try the simplest case first and then add in some of the other concerns. “Sidebar 2: Render page template” outlines the use case.

Sidebar 2: Render page template”

System renders a page template without a custom Action class.

  1. Client requests an action resource.
  2. System determines there is no custom Action class configured for the resource.
  3. System renders page template for the resource using a default Action class.
  4. Client presents HTML version of the page template.

We can configure SmartURLs to expect page resources (JSP, Freemarker, or Velocity) to be found under “WEB-INF/results”. This location is accessible to the Struts 2 framework, but it is not directly accessible to a web browser. The page resources cannot be accessed except through Struts 2 (or another server-side component).

Into the “WEB-INF/results” folder, we can drop a simple JSP template, as shown by “Example 2: hello-world.jsp”.

“Example 2: hello-world.jsp”

<html>
 <body>
  <p>
   Hello World!
  </p>
  <p>
   It is now <%= new java.util.Date() %>.
  </p>
 </body>
</html>

With the SmartURLs plugin installed, we can fire up our web container and open the URL “http://localhost:8080/smartapp/hello-world”. (The hostname and port for your container may vary!)

In response, SmartURLs will render the “WEB-INF/results/hello-world.jsp” template, as shown in “Figure 1: Hello World!”

“Figure 1: Hello World!”

If the page renders, we know that SmartURLs is working!

Already, SmartURLs lets us

  • use extensionless URIs,
  • store templates under the secure WEB-INF folder, and
  • do without “gluecode” XML

How would we display our own data on the page?

As handy as checking the server time may be, we usually want to merge our own data into a page template. Typically, we want to set a property on a Struts Action and then display that property in the page.

The value of the property might come from a database, and be filtered through a set of business rules, but the page doesn’t need to know that. All the page needs to know is that the property is available, and it’s the page’s job to display the value, whatever it is. Conversely, the Action class doesn’t need to know anything about HTML or expression languages. It just sets the property.

Right now, our concern is whether the Action class and page template are automatically wired together by the framework. So all we really need to do is set an Action property to a known value, and see if the page displays the value we expect.

To test SmartURL’s autowiring, let’s add a HelloWorld class to an “actions” package in our application, as show in “Example 3: HelloWorldAction.java”.

“Example 3: HelloWorldAction.java”

package actions;
public class HelloWorldAction  {
  private String greeting;
  public String getGreeting() {
    return greeting;
  }
  public String execute() {
    greeting = "The server time is " + new java.util.Date().toString();
    return "success";
  }
}

Notice that this is a “POJO” Action class (a standard Struts 2 feature). We don’t need any of the framework’s special services, so we didn’t extend a base class or implement a special interface. The closest thing to a special feature is the execute method! One other concession is that we need to append “Action” as a suffix to the classname.

Also note that we changed the message slightly, so that we can be sure that our page is updated. The updated page is shown in “Example 4: hello-world.jsp (2)”

“Example 4: hello-world.jsp (2)”

<html>
 <body>
  <p>
   Hello World!
  </p>
  <p>
   ${greeting}
  </p>
 </body>
</html>

Of course, we could use a Struts 2 tag instead of the JSTL expression, but <s:property value=”greeting”/> seems verbose compared to “${greeting]”. Figure 2: “Hello World! (2)” shows the updated page.

“Figure 2: Hello World! (2)”

Can SmartURLs handle a data-entry workflow with input validation?

A strength of action frameworks, like Struts 2, is that, depending on the runtime circumstances, an action can change the workflow by selecting different output pages. For example, we might want to collect input on one page. If the input is correct, we might want to go to an output page. If the input is not correct, we might want return to the input page.

Since validation workflow is one of the special services that the framework provides, in “Example 5: HelloWorld.java (2)”, we extend our class from the ActionSupport class.

“Example 5: HelloWorld.java (2)”

package actions;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.*;
@Validation()
public class HelloWorld extends ActionSupport {
  private String greeting;
  @RequiredStringValidator(message="Please enter a greeting!")
  public String getGreeting() {
    return greeting;
  }
  public void setGreeting(String value) {
    greeting = value;
  }
}

Since we now extend the Action interface, the SmartURLs rules also lets us drop the “Action” suffix from the classname.

In Example 5, we use validation by annotation (another standard Struts 2 feature) to ensure that a message is entered. (Annotations, introduced in Java 5, are specified in the program source by using the @ symbol.) Struts 2 and the SmartURLs plugin use annotations as an alternative to XML gluecode. In Example 5, we use an annotation to “glue” a RequiredStringValidator to the message property. The core framework provides annotations for all the usual validators.

To collect an input message to validate, we can add another page template, as shown in “Example 6: hello-world-input.jsp”.

“Example 6: hello-world-input.jsp”

<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
 <body>
  <p>
   What would you like to say to the world?
  </p>
  <s:form action="hello-world">
    <s:textfield label="Greeting" name="greeting" />
    <s:submit />
  </s:form>
 </body>
</html>

“Figure 3: Hello World Input!” shows the page as it would be rendered.

“Figure 3: Hello World Input!”

If the message field is left blank, validation will fail, the HelloWorld Action will return an “input” result code, and SmartURLs will forward control back to “hello-world-input.jsp”, as shown by “Figure 4: Hello World Input! (2)”.

“Figure 4: Hello World Input! (2)”

If we manage to pass validation, a page renders like the one shown in “Example 5: Howdy”.

“Figure 5: Hello World Input! (3)!”

Note that we can implement this common workflow without any XML gluecode! In this workflow, the only metadata of any kind is the RequiredStringValidator annotation. The rest is driven by convention over configuration!

What if we wanted to redirect after submitting a form?

If a form passes validation, and we use it to update a database, we often want to “redirect” to a confirmation page. A redirect updates the page location in the web browser’s address bar. Among other things, a redirect ensures that people do not resubmit the form again by pressing refresh.

Struts 2 supports redirects through the @Result annotation. To redirect to another location on “success”, we can add a “@Result” annotation to the Action class. “Example 7: HelloWorld.java (3)” shows the @Result annotation.

“Example 7: HelloWorld.java (3)”

@Result(name="success", type="redirect", location="hello-world-view")
public class HelloWorld extends ActionSupport

The annotation in Example 7 implies that there is a hello-world-view action. To create one, all we need to do is rename hello-world.jsp to hello-world-view.jsp.

On success, the system will redirect from the Hello Action to “hello-world-view.jsp”, and display the greeting we entered through the “hello-world-input” action.

Or not.

By default, the Action properties are retained in request scope. If we redirect, we lose the first request scope and create a second. For now, the simplest solution is to keep our greeting in session scope. The complete, updated class is shown in “Example 8: HelloWorld.java (4)”.

“Example 8: HelloWorld.java (4)”

package actions;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.*;
import org.apache.struts2.interceptor.SessionAware;
import org.texturemedia.smarturls.Result;
@Validation()
@Result(name="success", type="redirect-action", location="hello-world-view")
public class HelloWorld extends ActionSupport implements SessionAware {
    private Map<String, String> session;
    public void setSession(Map value) {
        session = value;
    }
    protected Map<String, String> getSession() {
        Map<String, String> value = session;
        return value;
    }
    public static String GREETING_KEY = "greeting";
    @RequiredStringValidator(message="Please enter a greeting!")
    public String getGreeting() {
        return (String) getSession().get(GREETING_KEY);
    }
    public void setGreeting(String value) {
        getSession().put(GREETING_KEY,value);
    }
}

Now, to enter a greeting we can open “hello-world-input”, which submits to “hello-world”. If we successfully enter a greeting, “hello-world” stores the property in session scope, and redirects to “hello-world-view”. To complete the loop, we can add a link back to the data-entry page. “Example 9: hello-world-view.jsp” shows the updated page.

“Example 9: hello-world-view.jsp”

<html>
 <body>
  <p>
   Hello World!
  </p>
  <p>
   ${greeting}
  </p>
  <p>
  <a href="hello-world-input.do">Try again!</a>
  </p>
 </body>
</html>

At this point, our complete Hello World data-entry workflow is shown by

  • “Example 6: hello-world-input.jsp”,
  • “Example 7: HelloWorld.java (3)”, and
  • “Example 4: hello-world-view.jsp”

without a single line of XML gluecode!

How do we install the SmartURLs plugin?

To install the plugin, first add the SmartURLs JAR to the web application’s lib folder, along with the other Struts JARs. To get the most benefit from SmartURLs, we should make two small changes to the configuration. Among other things, these changes will let us use extensionless URLs.

Second, replace the standard Struts filter with the SmartURLs version. “Example web.xml” shows the SmartURLs <filter> and <filter-mapping> stanzas.

“Example 8: web.xml”

    <filter>
        <filter-name>
            struts2
        </filter-name>
        <filter-class>
            org.texturemedia.smarturls.SmartURLsFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>
            struts2
        </filter-name>
        <url-pattern>
            /*
        </url-pattern>
    </filter-mapping>

Third, in the application’s struts.xml, add the “constant” stanza shown in “Example 9: struts.xml”.

“Example 9: struts.xml”

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    <constant name="struts.devMode" value="false" />
    <constant name="struts.action.extension" value="" />
    <constant name="smarturls.action.packages" value="actions" />
    <constant name="smarturls.base.result.location" value="/WEB-INF/results/" ></constant>
    <constant name="struts.custom.i18n.resources" value="support.package" ></constant>
</struts>

A larger application may need to define some other one-time settings or package defaults. But not gluecode!

What’s the minimum installation we need for a SmartURLs application?

If you are using MyEclipse or Eclipse with Web Tools (WTP), you can create a Dynamic Web Application, and then

  1. Drop the usual Struts 2 JARs (freemarker, ognl, struts2-core, xwork2) under the standard “lib” folder, along with the SmartURLs plugin JARs (java-net-commons and smarturls-s2).
  2. Under “WebContent/WEB-INF”, create a “results” folder for page templates.
  3. Under the “src” folder, create a “struts.xml” based on Example 9, and a “actions” package for Action classes.

And you are ready to go!

Is that all there is?

We’ve walked through the simplest way to use SmartURLs. We’ve shown the simplest approach that requires the fewest annotations. Aside from the annotations we’ve shown, SmartURLs supports several others. For example, we can give an Action multiple names, or call methods other than execute.

The SmartURLs documentation details the various annotations and configuration options. For more of SmartURLS in action, a complete SmartURLs MailReader example application is also available as a ready-to-deploy WAR (check Resources at the end of the article).

Using SmartURLs conventions, we can write less code and still create powerful, enterprise-ready applications. We can then put the time we save toward improving the user interface and other parts of the application that make it more useful.

Today, SmartURLs is a third-party plugin, but work is underway to merge it with the standard CodeBehind Plugin for Struts 2.1. The CodeBehind plugin for Struts 2.0 offers similar capabilities, but fewer features.

Resources

  • SmartURLs plugin site (http://code.google.com/p/smarturls-s2/)
  • SmartURLs MailReader Example for Java 5 (http://husted.com/smart-urls/smart-urls.war)
  • Apache Struts site (http://struts.apache.org)

Biography

Ted Husted is a member of the Apache Software Foundation, an active member of the Apache Struts and Apache iBATIS Projects, and co-founder of the Apache Jakarta Commons. His books include JUnit in Action, Struts in Action, and Professional JSP Site Design. Ted has consulted with teams throughout the United States, including CitiGroup, Wells Fargo, and Pepsi Bottling Group. He provides onsite training to software development teams through his Struts Mentor site (www.StrutsMentor.com). This is the second in a series of articles about writing applications with Struts 2.

Posted in Java Technology | Leave a Comment »

Đường Xưa Mây Trắng

Posted by kosoftvn on January 13, 2008

Dưới đây là link tới truyện dài Đường Xưa Mây Trắng của Thiền sư Thích Nhất Hạnh.

http://vnthuquan.net/truyen/truyen.aspx?tid=2qtqv3m3237ntn1n4nmn31n343tq83a3q3m3237nvn

Posted in Blogs & Mics | Leave a Comment »

No death, No fear – Thích Nhất Hạnh

Posted by kosoftvn on January 13, 2008

Thich Nhat Hanh, No Death, No Fear, Part 1

“When conditions are sufficient things manifest.”

In my hermitage in France there is a bush of japonica, Japanese quince. The bush usually blossoms in the spring, but one winter it had been quite warm and the flower buds had come early. During the night a cold snap arrived and brought with it frost. The next day while dong walking meditation, I noticed that all the buds on the bush had died. I recognized this and thought, This New Year we will not have enough flowers to decorate the altar of the Buddha.

A few weeks later he weather became warm again. As I walked in my garden I saw new buds on the japonica manifesting another generation of flowers. I asked the japonica flowers: “Are you the same as the flowers that died in the frost or are you different flowers?” The flowers replied to me: “Thay, we are not the same and we are not different When conditions are sufficient we manifest and when conditions are not we go into hiding. It’s as simple as that.”

This is what the Buddha taught. When conditions are sufficient things manifest. When conditions are no longer sufficient things withdraw. They wait until the moment is right for them to manifest again.

Before giving birth to me, my mother was pregnant with another baby. She had a miscarriage, and that person wasn’t born. When I was young I used to ask the question: was that my brother or was that me? Who was trying to manifest at that time? If a baby has been lost it means that conditions were not enough for him to manifest and the child has decided to withdraw in order to wait for better conditions. “I had better withdraw; I’ll come back again soon, my dearest.” We have to respect his or her will. If you see the world with eyes like this, you will suffer much less. Was it my brother that my mother lost? Or maybe I was about to come out but instead I said, “It isn’t time yet,” so I withdrew.

Thich Nhat Hanh, No Death, No Fear, Part 2

“When we understand that we cannot be destroyed, we are liberated from fear.”

Becoming Nothing

Our greatest fear is that when we die we will become nothing. Many of us believe that our entire existence is only a life span beginning the moment we are born or conceived and ending the moment we die. We believe that we are born from nothing and when we die we become nothing. And so we are filled with fear of annihilation.

The Buddha has a very different understanding of our existence. It is the understanding that birth and death are notions. They are not real. The fact that we think they are true makes a powerful illusion that causes our suffering. The Buddha taught that there is no birth; there is no death; there is no coming; there is no going; there is no same; there is no different; there is no permanent self; there is no annihilation. We only think there is. When we understand that we cannot be destroyed, we are liberated from fear. It is a great relief. We can enjoy life and appreciate it in a new way.

Finding a Lost Loved One

The same thing happens when we lost any of our beloved ones. When conditions are not right to support life, they withdraw. When I lost my mother I suffered a lot. When we are only seven or eight years old it is difficult to think that one day we will lose our mother. Eventually we grow up and we all lose our mothers, but if you know how to practice, when the time comes for the separation you will not suffer too much. You will very quickly realize that your mother is always alive within you.

The day my mother died, I wrote in my journal, “A serious misfortune of my life has arrived.” I suffered for more than one year after the passing away of my mother. But one night, in the highlands of Vietnam, I was sleeping in the hut in my hermitage. I dreamed of my mother. I saw myself sitting with her, and we were having a wonderful talk. She looked young and beautiful, her hair flowing down. It was so pleasant to sit there and talk to her as if she had never died. When I woke up it was about two in the morning, and I felt very strongly that I had never lost my mother. The impression that my mother was still with me was very clear. I understood then that the idea of having lost my mother was just an idea. It was obvious in that moment that my mother is always alive in me.

Thich Nhat Hanh, No Death, No Fear, Part 3

“Walking slowly in the moonlight through the rows of tea plants, I noticed my mother was still with me.”

I opened the door and went outside. The entire hillside was bathed in moonlight. It was a hill covered with tea plants, and my hut was set behind the temple halfway up. Walking slowly in the moonlight through the rows of tea plants, I noticed my mother was still with me. She was the moonlight caressing me as she had done so often, very tenderly, very sweet… wonderful! Each time my feet touched the earth I knew my mother was there with me. I knew this body was not mine along but a living continuation of my mother and father and my grandparents and great-grandparents. Of all my ancestors. These feet that I saw as “my” feet were actually “our” feet. Together my mother and I were leaving footprints in the damp soil.

From that moment on the idea that I had lost my mother no longer existed. All I had to do was look at the palm of my hand, feel the breeze on my face or the earth under my feet to remember that my mother is always with me, available at any time.

When you lost a loved one, you suffer. but if you know how to look deeply, you have a chance to realize that his or her nature is truly the nature of no birth, no death. There is manifestation and there is the cessation of manifestation in order to have another manifestation. You have to be very keen and very alert in order to recognize the new manifestation of just one person. But with practice and with effort you can do it.

So, taking the hand of someone who knows the practice, together do walking meditation. Pay attention to all the leaves, the flowers, the birds and the dewdrops. If you can stop and look deeply, you will be able to recognize your beloved one manifesting again and again in different forms. You will again embrace the joy of life.

Thich Nhat Hanh, No Death, No Fear, Part 4

“Just because we do not perceive something, it is not correct to say it doesn’t exist.”

Nothing Is Born, Nothing Dies

A French scientist, whose name is Lavosier, declared, “Rien ne se cree, rien ne se perd.” “Nothing is born, nothing dies.” Although he did not practice as a Buddhist but as a scientist, he found the same truth the Buddha discovered.

Our true nature is the nature of no birth and no death. Only when we touch our true nature can we transcend the fear of non-being, the fear of annihilation.

The Buddha said that when conditions are sufficient something manifests and we say it exists. When one or two conditions fail and the thing does not manifest in the same way, we then say it does not exist. According to the Buddha, to qualify something as existing or not existing is wrong. In reality, there is no such thing as totally existing or totally not existing.

We can see this very easily with television and radio. We may be in a room that has no television or radio. And while we are in that room, we may think that television programs and radio programs do not exist in that room. But all of us know that the space in the room is full of signals. The signals of these programs are filling the air everywhere. We need only one more condition, a radio or television set, and may forms, colors and sounds will appear.

It would have been wrong to say that the signals do not exist because we did not have a radio or television to receive and manifest them. They only seemed not to exist because the causes and conditions were not enough to make the television program manifest. So at that moment, in that room, they do not exist. Just because we do not perceive something, it is not correct to say it doesn’t exist. It is only our notion of being and non-being that makes us think something exists or doesn’t exist. Notions of being and non-being cannot be applied to reality.

Posted in Blogs & Mics | Leave a Comment »

Bông hồng cài áo – Thích Nhất Hạnh

Posted by kosoftvn on January 13, 2008

Ý niệm về mẹ thường không thể tách rời với tình thương. Mà tình thương là một chất liệu ngọt ngào êm dịu và cố nhiên là ngon lành. Con trẻ thiếu tình thương thì không thể lớn lên được. Người lớn thiếu tình thương thì cũng không “lớn” lên được. Cằn cỗi, héo mòn.

Ngày mẹ tôi mất, tôi viết trong nhật ký: “Tai nạn lớn nhất đã xảy ra cho tôi rồi !” Lớn cách mấy mà mất mẹ, thì cũng như không lớn, cũng cảm thấy bơ vơ, lạc lõng, cũng không hơn gì kẻ mồ côi.

Những bài hát, những bài thơ ca tụng tình mẹ, bài nào cũng dễ thấy hay. Người viết dù không có tài ba, cũng có rung cảm chân thành; người hát ca, trừ là kẻ không có mẹ ngay từ thuở chưa có ý niệm, ai cũng cảm động khi nghe nói đến tình mẹ. Những bài hát ca ngợi tình mẹ đâu cũng có, thời nào cũng có. Bài thơ mất mẹ mà tôi thích nhất từ hồi nhỏ là một bài thơ giản dị. Mẹ đang còn sống, nhưng mỗi khi đọc bài thơ ấy thì sợ sệt, âu lo… sợ sệt lo âu cho một cái gì còn xa, chưa đến nhưng chắc chắn phải đến:

Năm xưa tôi còn nhỏ

Mẹ tôi đã qua đời!

Lần đầu tiên tôi hiểu

Thân phận kẻ mồ côi.

Quanh tôi ai cũng khóc

Im lặng tôi sầu thôi

Để dòng nước mắt chảy

Là bớt khổ đi rồi…

Hoàng hôn phủ trên mộ

Chuông chùa nhẹ rơi rơi

Tôi thấy tôi mất mẹ

Mất cả một bầu trời

Một bầu trời thương yêu dịu ngọt, lâu quá mình đã bơi lội trong đó, sung sướng mà không hay, để hôm nay bừng tỉnh thì đã mất rồi. Người nhà quê Việt Nam không ưa nói cách cao kỳ. Nói rằng bà mẹ già là một kho tàng của yêu thương, của hạnh phúc thì cũng đã là cao kỳ rồi. Nói mẹ già là một thứ chuối, một thứ xôi, một thứ đường ngọt dịu, người dân quê đã diễn tả được tình mẹ vừa giản dị, vừa đúng mức:

Mẹ già như chuối ba hương

Như xôi nếp một, như đường mía lau

Ngon biết bao nhiêu! Những lúc miệng vừa đắng vừa nhạt sau một cơn sốt, những lúc như thế thì không có món ăn gì có thể gợi được khẩu vị của ta. Chỉ khi nào mẹ đến, kéo chăn đắp lại ngực cho ta, đặt bàn tay trên trán nóng ta và than thở “Khổ chưa, con tôi,” ta mới cảm thấy đầy đủ, ấm áp, thấm nhuần chất ngọt của tình mẹ, ngọt thơm như chuối ba hương, dịu như xôi nếp một và đậm đà dịm cả cổ họng như đường mía lau.

Tình mẹ thì trường cửu, bất tuyệt; những chuối ba hương, đường mía lau, xôi nếp một ấy không bao giờ cùng tận. “Công cha như núi Thái Sơn, nghĩa mẹ như nước trong nguồn chảy ra”. Nước trong nguồn chảy ra thì bất tuyệt. Tình mẹ là gốc của mọi tình cảm thương yêu. Mẹ là giáo sư dạy về thuơng yêu, một phân khoa quan trọng nhất trong trường đại học cuộc đời.

Không có mẹ, tôi sẽ không biết thương yêu. Nhờ mẹ mà tôi biết được thế nào là tình nhân loại, tình chúng sinh; nhờ mẹ mà tôi có được chút ý niệm về đức từ bi. Vì mẹ là gốc của tình thương, nên ý niệm mẹ lấn trùm ý niệm thương yêu của tôn giáo vốn cũng dạy về tình thương. Đạo Phật có đức Quan Thế Âm, tôn sùng dưới hình thức mẹ. Em bé vừa mở miệng khóc thì mẹ đã chạy tới bên nôi. Mẹ hiện ra như một thiên thần dịu hiền làm tiêu tan khổ đau lo âu. Đạo Chúa có Đức Mẹ, thánh nữ đồng trinh Maria. Trong tín ngưỡng bình dân Việt có thánh mẫu Liễu Hạnh, cũng dưới hình thức mẹ.

Bởi vì chỉ cần nghe đến danh từ “mẹ” là ta đã thấy lòng tràn ngập yêu thương rồi. Mà từ yêu thương đi tới tín ngưỡng và hành động thì không xa mấy.

Tây phương không có ngày Vu Lan nhưng cũng có Mother’s Day, mồng 10 tháng 5. Tôi nhà quê không biết cái tục ấy. Có một ngày, tôi đi với thầy Thiên Ân tới nhà sách ở khu Ginza, Đông Kinh, nửa đường gặp mấy người sinh viên Nhật, bạn của thầy Thiên Ân. Có một cô sinh viên hỏi nhỏ thầy Thiên Ân một câu, rồi lấy trong sắc ra một bông hoa cẩm chướng màu trắng cài vào khuy áo áo tràng của tôi. Tôi lạ lùng, bỡ ngỡ, không biết cô làm gì, nhưng không dám hỏi, cố giữ vẻ tự nhiên nghĩ rằng có một tục lệ chi đó.

Sau khi họ nói chuyện xong, chúng tôi vào nhà sách, thầy Thiên Ân mới giảng cho tôi biết đó là ngày Mother’s Day, theo tục Tây Phương. Nếu anh còn mẹ, anh sẽ được cài hoa hồng trên áo, và anh sẽ tự hào được còn mẹ. Nếu anh mất mẹ, anh sẽ được cài trên áo một bông hoa màu trắng. Tôi nhìn lại bông hoa trắng trên áo mà cảm thấy tủi thân. Tôi cũng mồ côi như bất cứ đứa trẻ vô phúc khốn nạn nào, chúng tôi không có được cái tự hào cài trên áo một bông hoa màu hồng.

Người được hoa trắng sẽ thấy xót xa, nhớ thương không quên mẹ dù Người đã khuất. Người được hoa hồng sẽ thấy sung sướng nhớ rằng mình còn mẹ và sẽ cố gắng để làm vui lòng mẹ kẻo một mai người khuất núi có khóc than cũng không còn kịp nữa. Tôi thấy cái tục cài hoa đó đẹp và nghĩ rằng mình có thể bắt chước áp dụng trong ngày báo hiếu Vu Lan!

Mẹ là một dòng suối, một kho tàng vô tận, vậy mà lắm lúc ta không biết, để lãng phí một cách oan uổng. Mẹ là một món quà lớn nhất mà cuộc đời tặng cho ta. Những kẻ đã và đang có mẹ, đừng có đợi đến khi mẹ chết rồi mới nói : “Trời ơi, tôi sống bên mẹ suốt mấy mươi năm trời mà chưa có lúc nào nhìn kỹ được mặt mẹ”. Lúc nào cũng chỉ nhìn thoáng qua. Trao đổi vài câu ngắn ngủi. Xin tiền ăn quà. Đòi hỏi mọi chuyện. Ôm mẹ mà ngủ cho ấm. Giận dỗi. Hờn lẫy. Gây bao nhiêu chuyện rắc rối cho mẹ phải lo lắng, ốm mòn, thức khuya, dậy sớm vì con. Chết sớm cũng vì con. Để mẹ phải suốt đời bếp núc vá may, giặt rửa, dọn dẹp… Và để mình suốt đời bận rộn lên xuống ra vào lợi danh. Mẹ không có thì giờ nhìn kỹ con. Và con không có thì giờ nhìn kỹ mẹ. Để khi mẹ mất, mình có cảm nghĩ “như là mình chưa bao giờ có ý thức rằng mình có mẹ” Chiều nay khi đi học về hoặc khi đi làm việc ở sở về, em hãy vào trong phòng mẹ với một nụ cười thật trầm lặng và thật bền. Em hãy ngồi xuống bên mẹ. Sẽ bắt mẹ dừng kim chỉ, mà đừng nói năng chi. Rồi em sẽ nhìn mẹ thật lâu, thật kỹ để trông thấy mẹ và để biết rằng mẹ đang sống và đang ngồi bên em. Cầm tay mẹ, em sẽ hỏi một câu ngắn làm mẹ chú ý.

Em hỏi: “Mẹ ơị mẹ có biết không ?” Mẹ sẽ hơi ngạc nhiên và sẽ hỏi em, vừa hỏi vừa cười: “Biết gì?” Vẫn nhìn vào mắt mẹ, vẫn giữ nụ cười trầm lặng và bền, em sẽ nói: “Mẹ có biết là con thương mẹ không ?

Câu hỏi sẽ không cần được trả lời. Cho dù người lớn ba bốn mươi tuổi cũng có thể hỏi một câu như thế vì người là con của mẹ. Mẹ và em sẽ sung sướng, sẽ sống trong ý thức tình thương bất diệt và ngày mai mẹ mất, em sẽ không hối hận đau lòng.

Ngày Vu Lan ta nghe giảng và đọc sách nói nhiều về ngài Mục Kiền Liên và về sự hiếu đễ. Công cha, nghĩa mẹ. Bổn phận làm con. Ta lạy Phật cầu cho mẹ sống lâu. Hoặc lạy mười phương tăng chú nguyện cho mẹ được tiêu diêu nơi cực lạc, nếu mẹ đã mất. Con mà không có hiếu là con bỏ đi. Nhưng hiếu cũng do tình thương mà có; không có tình thương, hiếu chỉ là giả tạo, khô khan, vụng về, cố gắng, mệt nhọc – mà có tình thương là có đủ hết rồi. Cần chi nói đến bổn phận. Thương mẹ như vậy là đủ.

Mà thương mẹ không chỉ là một bổn phận, thương mẹ là một cái gì rất tự nhiên, như khát thì uống nước, con thì phải có mẹ, phải thương mẹ. Chữ “phải” đây không phải là luân lý, là bổn phận. “Phải” đây là lẽ đương nhiên. Con thì đương nhiên thương mẹ, mẹ thì đương nhiên thương con. Nếu mẹ không cần con và con không cần mẹ thì đó không phải là mẹ con. Đó là lạm dụng danh từ mẹ con.

Ngày xưa, thầy giáo hỏi rằng, con mà thương mẹ thì cần phải làm như thế nào ? Tôi trả lời: vâng lời cố gắng, giúp đỡ, phụng dưỡng lúc mẹ về già và thờ phụng khi mẹ khuất núi. Bây giờ thì tôi biết rằng con thương mẹ thì không phải “làm thế nào” gì hết. Cứ thương mẹ, thế là đủ lắm rồi, cần chi phải hỏi “làm như thế nào”.

Thương mẹ không phải là một vấn đề luân lý, đạo đức. Anh mà nghĩ rằng tôi viết bài này để khuyên anh về luân lý đạo đức là anh lầm. Thương mẹ là một vấn đề hưởng thụ. Mẹ như chuối ngọt, như đường mía lau, như xôi nếp một. Anh không hưởng thụ thì uổng cho anh. Chị không hưởng thụ thì uổng cho chị. Tôi chỉ cảnh cáo cho anh chị biết mà thôi. Để mai này, anh chị đừng có than thở rằng đời ta không còn gì cả. Một món quà như mẹ mà còn không vừa ý thì họa chăng có làm Ngọc Hoàng Thượng Đế mới vừa ý, mới bằng lòng, mới sung sướng. Nhưng tôi biết được Ngọc Hoàng không sung sướng đâu, bởi Ngọc Hoàng là đấng tự sinh không bao giờ có diễm phúc có được một bà mẹ.

Tôi kể chuyện này, anh đừng nói tôi khờ dại. Đáng lẽ chị tôi không nên đi lấy chồng và tôi không nên đi tu mới phải. Chúng tôi bỏ mẹ mà đi, người thì theo cuộc đời mới bên cạnh người con trai thương yêu, người thì đi theo lý tưởng đạo đức mình say mê và tôn thờ.

Ngày chị tôi đi lấy chồng, mẹ tôi lo lắng, lăng xăng, không tỏ vẻ buồn bã chi. Nhưng đến khi chúng tôi ăn qua loa để đợi rước dâu thì mẹ tôi không nuốt được miếng nào. Mẹ nói: “Mười tám năm trời nó ngồi ăn cơm với mình, bây giờ nó ăn bữa cuối cùng rồi nó đi ăn ở một nhà khác”. Chị tôi gục đầu xuống mâm cơm, khóc. Chị nói “Thôi con không đi lấy chồng nữa”. Nhưng rốt cuộc rồi chị cũng đi lấy chồng, còn tôi thì bỏ mẹ đi tu. “Các, ái, từ, sở, thân” là lời khen ngợi người có chí xuất gia. Tôi không tự hào chi về lời khen đó cả. Tôi thương mẹ nhưng tôi có lý tưởng, vì vậy phải xa mẹ. Thiệt thòi cho tôi, có thế thôi. Ở trên đời, có nhiều khi ta phải chọn lựa mà không có sự lựa chọn nào là không khổ đau. Anh không thể bắt cá hai tay. Chỉ khổ là vì muốn làm người nên anh phải khổ đau. Tôi không hối hận vì bỏ mẹ đi tu nhưng tôi tiếc thương cho tôi vô phúc thiệt thòi nên không được hưởng thụ tất cả kho tàng quý báu đó. Mỗi buổi chiều lạy Phật, tôi cầu nguyện cho mẹ. Nhưng tôi không được ăn chuối ba hương, xôi nếp một và đường mía lau.

Anh cũng đừng tưởng tôi khuyên anh không nên đuổi theo sự nghiệp mà chỉ nên ở nhà với mẹ. Tôi đã nói là tôi không khuyên răn ai hết – tôi không giảng luân lý đạo đức. Tôi chỉ nhắc nhở anh “mẹ là chuối, là xôi, là đường, là mật ngọt ngào, là tình thương”. Để anh đừng quên. Để chị đừng quên. Để em đừng quên. Quên là một lỗi lớn. Cũng không phải là lỗi nữa mà là một sự thiệt thòi. Mà tôi không muốn anh chị thiệt thòi, vô tình mà thiệt thòi. Tôi xin cài vào túi áo anh một hoa hồng để anh sung sướng, thế thôi.

Nếu có khuyên, thì tôi sẽ khuyên như thế này. Chiều nay khi đi học về, hoặc khi đi làm việc về, anh hãy vào trong phòng mẹ với một nụ cười thật trầm lặng và thật bền. Anh sẽ ngồi xuống bên mẹ. Sẽ bắt mẹ dừng kim chỉ, mà đừng nói năng chi. Rồi anh sẽ nhìn mẹ thật lâu, thật kỹ để trông thấy mẹ và để biết rằng mẹ đang sống và đang ngồi bên anh. Cầm tay mẹ, anh sẽ hỏi một câu ngắn làm mẹ chú ý. Anh hỏi: “Mẹ ơị mẹ có biết không ?”. Mẹ sẽ hơi ngạc nhiên và sẽ hỏi anh, vừa hỏi vừa cười: “Biết gì?” Vẫn nhìn vào mắt mẹ, vẫn giữ nụ cười trầm lặng và bền, anh sẽ nói: “Mẹ có biết là con thương mẹ không ?”. Câu hỏi sẽ không cần được trả lời. Cho dù người lớn ba bốn mươi tuổi cũng có thể hỏi một câu như thế vì ngươi là con của mẹ. Mẹ và anh sẽ sung sướng, sẽ sống trong ý thức tình thương bất diệt và ngày maị mẹ mất anh, anh sẽ không hối hận đau lòng tiếc rằng anh không có mẹ.

Đó là điệp khúc mà tôi muốn ca hát cho anh nghe hôm nay. Và anh hãy ca, chị hãy ca, em hãy ca cho cuộc đời đừng chìm trong vô tâm, quên lãng. Đóa hoa màu hồng tôi cài trên áo anh rồi đó. Anh hãy sung sướng đi !

(Để dâng mẹ và để làm quà Vu Lan cho những người nào có diễm phúc còn mẹ).

Bài hát bông hồng cài áo tại link sau: http://www.vnmusic.com.vn/music/index.php?aid=nghenhac&id=577

Posted in Blogs & Mics | Leave a Comment »

Sun Certificate

Posted by kosoftvn on December 11, 2007

If you are preparing for taking SCBCD v5 (EJB3) exam, the following materials may be useful:
 
* Simulator: (http://www.esnips.com/web/ethuware)
Ethuware EJBPlus v5 
 
* Books: (http://www.esnips.com/web/ethuware)
Apress.Beginning.EJB.3.Application.Development.Sep.2006.pdf
Apress.Pro.EJB.3.Java.Persistence.API.May.2006.pdf
Manning.EJB.3.in.Action.Apr.2007.pdf
OReilly.Enterprise.JavaBeans.3.0.5th.Edition.May.2006.chm
Wiley.Mastering.Enterprise.JavaBeans.3.0.4th.Edition.Jul.2006.pdf
 
* References:
http://www.nycjava.net/JSPWiki/Wiki.jsp?page=LinksToEJB3.0StudyMaterials

Author: Ha Thanh Thai

Posted in Java Technology | Leave a Comment »