Friday, September 14, 2012

Security in JBOSS

We have discussed about how to create a simple enterprise application and how to deploy it into JBOSS server. In this article, we are going to discuss about how security achieve from JBOSS. So I am going to discuss about logging modules in jboss. Basically we have four logging modules. Those are,

  • Basic authentication mechanism
  • Form based authentication mechanism
  • Digest authentication mechanism
  • Client cert authentication mechanism
Those are the basic authentication mechanisms. Since next article, we are talking about those mechanisms.  

Saturday, September 8, 2012

Create Enterprise Application with JBOSS and Netbeans

We have discussed about how install jboss and how to start jboss with netbeans in previous topics. We are going to discuss about how create an enterprise application, how to create an EJB , how to call that EJB from a servlet and how to deploy that enterprise application into jboss server.
As the first step, lets see how to create an enterprise application in netbeans.
Open netbeans add go to file and click on New Project. Then click on JAVA EE and select Enterprise Application as show in figure below.
Then click next. After that add a name for your enterprise application and click next. Then select jboss-as as the server and select create EJB module and create web module tick buttons. Now click Finish. Now you will see three new nodes appear project tab.
Then we need to create an EJB. We are going to create stateless session bean in this example. My enterprise application name is "test". Then you can see a node called "test-ejb" in the project tab. Right click on that tab and click session bean.
Now you will see a window like below. Give a suitable name to your session bean. Then specify a package name. Then select stateless and local as shown below.
 Now you will see two classes created under source package-> ejb directory. click on testSessionBean.java  and right click on work area and select add business method as shown in the following figure.
Then you will see a windows like below figure. We are going to create small session bean that returns addition of two numbers. So we need to get two integer values as parameters and we need to return the addition of those two numbers as a integer.
Now you will see a method call businessMethod in the testSessionBean.java and testSessionBeanLocal.java classes. Change the return statement as follows. Then that method will return the addition of given two numbers.

 public int businessMethod(int num1, int num2) {
        return num1+num2;
    }

Then save the java file. We created a session bean. Now we need to create a web application. This web app will use above session bean.
Right click on testApp-war node in project tab and go to New and select Servlet. Then you will get a window. Give a suitable name for your servlet such as testServlet and give a package name. Then click next and click finish on next window. Now we can see a new servlet java class created under the source package and your package name directory.
Now we need to call above sessionBean. So right click on work area and select insert code as mentioned above. Then select call Enterprise Bean. Then you will see a window and you have to select our ejb that we created as shown in the figure.
Now you will see following code added to the servlet class.


@EJB
    private testSessionBeanLocal testSessionBean;

Since we need to call session bean, we need to add following code in side the try catch block that created in the servlet.


            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet testServlet</title>");
            out.println("</head>");
            out.println("<body>");
             out.println("<h1>Addition of 10 and 15 is "+testSessionBean.businessMethod(10, 15)+"</h1>");
            out.println("</body>");
            out.println("</html>");

We are almost finished. Now we need to deploy our enterprise application to the server. Right click on testApp node in the project tab and click deploy. Then deploy our web application and start the jboss server. After deploying we can access our web application through a web browser. Open a web browser and enter following URL.
http://localhost:8080/testApp-war/testServlet

Now you will see the addition of 10 and 15 display in web browser.

Cheers..!!


Thursday, August 16, 2012

JBOSS with NetBeans

We discussed about how to install JBOSS in your computer in previous post. But we didn't talk about how to start JBOSS server. We are going to talk about how to use JBOSS with netbeans IDE. Most of the JBOSS tutorials are based on eclipse IDE. But this article series is based on Netbeans IDE.

First open netbeans IDE. Then go to service tab and right click on servers node. Then click on add server as shown in the image.
Then you have to select JBoss Application Server from pop up box. Then press next. Now you have to browse your JBOSS stored folder. You have to select jboss-as directory. After that press finish. Now we successfully added JBOSS server to netbeans. Now we can start our JBOSS server from Netbeans. For that, write click on newly added jboss server and press start. Now we can see jboss-console. It will show starting JBOSS server.

We will see how to create small EJB and how to deploy that EJB to the JBOSS AS from netbeans.

Wednesday, August 15, 2012

Install JBOSS in your computer

This article describes how to install JBOSS AS in your computer. This is the first article of series of article. I am going to cover login modules, Clustering and load balancing in JBOSS. First let's see how to install JBOSS in your computer.
In this tutorial series, I am using JBOSS AS 5.1. You can download JBOSS AS 5 from JBOSS website. This is the link for JBOSS website.
http://www.jboss.org/jbossas/downloads/

According to your OS you can download zip or tar file. Installing JBOSS is very easy. We don't have to do anything. First we need to create a folder called "jboss" in C drive. If you want, you can create this folder in any of your partition. Then you have to extract that downloaded zip file into that folder. Now we installed JBOSS in your computer.

My next post will be on how to start jboss server from netbeans and command prompt.

Thursday, March 31, 2011

සිංහලෙන් PHP ඉගෙන ගමුද? (Learn PHP in sinhala)

මුලින්ම බලමු PHP කියන්නේ මොකක්ද කියල. PHP කියන්නේ වෙබ් අඩවි නිර්මාණය කරන්න උදව් වන කේතන බෂාවක්(Programming language). මෙය server side වෙබ් අඩවි නිර්මාණය කිරීමට තමයි යොදා ගන්නේ.තවත් ආකාරයකට කිව්වොත් dynamic වෙබ් අඩවි නිර්මාණය කරන්න තමයි PHP යොදා ගන්නේ.ඒ කියන්නේ දත්ත හුවමාරු කරන වෙබ් අඩවි වලදී බොහෝ විට යොදා ගන්නේ PHP තමයි.මෙහිදී ගොඩක් වෙලාවට databases එහෙම භාවිත වෙනවා.ඒ නිසා ඒ නිසා ඔයාලට  databases ගැනත් පොඩි දැනුමක් ලබා ගන්න පුළුවන් වෙයි කියල හිතෙනවා මේ ටික කියෙව්වම.  PHP දැනගෙන ඉන්න එක හොදයි කියල හිතුනා .

මුලින්ම මේකට අදාල මෘදුකාංග ගැන කියන්නම්.ඊළගට පල කරන පොස්ට් වලින් බලමු අපි කොහොමද PHP වලින් වැඩ කරන්නේ කියල.

අපිට databases හදාගන්න ඕනි වෙන මෘදුකාංගයක් තියනව.එක download කරගෙන මේ වැඩ කරන එක ගොඩක් ලේසි.ඒ නිසා පහල තියන ලින්ක් එකට ගිහින් ඒ මෘදුකාංගය download කර ගන්න.මේ මෘදුකාංගයේ නම තමයි wamp sever.
http://www.wampserver.com/en/download.php
එක download කරලා install කරගන්නකො.එක සාමාන්යෙන් C drive එකේ wamp කියල ෆෝල්ඩර් එකක් හැදිලා තියෙයි.ඊට පස්සේ wamp sever එක රන් කරන්න.එතකොට task bar එකේ පහත ආකාරයේ icon එකක් දකින්න ලබෙයි.එක උඩ click කරම පහත ආකාරයේ වින්ඩෝ එකක් ලැබෙයි.

මෙහිදී අපේ මැෂින් එකේ Apache server එකයි  PHP හා  MySQL යන 3 ම  configure වෙනවා.ඒ නිසා අපට manually configure කරන්න අවශ්‍ය වන්නේ නැ. මහිදී අපේ මැෂින් එකම server එකක් විදිහට වැඩ කරනවා. ඉහතින් ලැබුණු වින්ඩෝ එකේ Localhost click කරාම ඔයාලගේ වෙබ් බ්‍රව්සර් එකේ Localhost දිග හැරෙයි.ඒ වගේම  PHPMyadminn click කරාම අපි ඉදිරියේදී කතා කරන්න බලාපොරොත්තු වෙන database හද ගන්නා අවශ්‍ය වන වින්ඩෝ එක ඔයාලගේ වෙබ් බ්‍රව්සර් එකේ දක්නට ලැබෙයි.
මීලග පොස්ට් ඒකෙන බලමු සරල login page එකක් කොහොමද හදාගන්නේ කියල. මේ ලිපිය දැනට ඉවර කරනවා එහෙනම්.

Wednesday, January 26, 2011

Download madhura font for madhura dictionery..

අපේ කට්ටිය වැඩි පුරම භාවිත කරන සිංහල ඉංග්‍රීසි ශබ්දකෝෂය තමයි මධුර කියන්නේ. ඒත් එක බා ගත්තට සිංහල ෆොන්ට් එක එන්නේ නැනේ. එක අපි වෙනම බා ගෙන ඉන්ස්ටෝල් කරගන්න ඕනේ. ඉතින් මම ඒ ලින්ක් එක දෙන්නම්. එතකොට ඔයාලටත් මධුර ශබ්දකෝෂයට ඕනේ වෙන සිංහල ෆොන්ට් එක ලේසියෙන්ම ඉන්ස්ටෝල් කරගන්න පුළුවන්.
මෙතනින්  ඔයාලට පුළුවන් ඒ ෆොන්ට් එක බා ගත කරන්න.
ඔයාලට මධුර ශබ්දකෝෂය බා ගත කරන්න ලින්ක් එකත් මම දෙන්නම්කො.
මධුර ශබ්දකෝෂය

මධුර ෆොන්ට් එක බා ගත්තට පස්සේ ඔයාලට කරන්න තියෙන්නේ මම පහල දීල තියන පාර දිගේ ගිහින් කොපි කරලා පේස්ට් කරන්න විතරයි.
Control Panel -> Appearance and Personalization -> Fonts

Tuesday, December 28, 2010

කෝපි පේස්ට් කරන්නේ නැතුවම සින්හලෙන් ටයිප් කරමුද?

මම කලින් පොස්ට් එකේදී කිව්වනේ ගුගල් ට්‍රාන්ස්ලටෙර් එක ගැන. එකේදී අපිට කොපි පේස්ට් කරන්න ඕනිනේ. එත් දැන් කියන්න යන ක්‍රමයේදී එහෙම ඕනිත් නැ. ඒ උනාට මේකත් ගුගල් ගේ වැඩක්ම තමයි.
මේකට ඉස්සෙල්ලාම අපේ පරිගණකයේ language format එක සිංහලට හදල ඉන්න ඕනේ. එක කරන්නේ මෙහෙමයි.
Control Panel\Clock, Language, and Region ගිහින් region and language තෝරන්න. එතකොට මේ වගේ පෙට්ටියක් පෙනේවි. එකේ format එක  sinhala(sri lanka) තෝරන්න.

දැන් ඔයාලට task bar එකේ මෙහෙම දෙයක් පෙනෙයි. එක ක්ලික් කරලා Sl (sri lanka) තෝරන්න.
ඊට පස්සේ ඔයාලට පොඩි දෙයක් download කරලා  install කරගන්න ඕනේ. ඒ සදහා මෙතන ඔබන්න. එකෙන් dowlnoad කරලා  install කරන්ගන්නකෝ. ඊට පස්සේ task bar එකේ පහත පෙන්වල තියෙන තැනට  ගහින් එකේ Google sinhale input කියන එක තොරන්නකෝ. 

දැන් වැඩේ හරි. දැන් ඔයාලට තියෙන්නේ word processor එකේ හරි  web browser එකේ හරි අපි දන්නා  විදිහට ටයිප් කරන්න තමයි. ඒ කියන්නේ අපි කෙටි පණිවිඩ යවන්න සිංග්ලිෂ් තියෙන්නේ. එන්න ඒ විදිහට  ටයිප් කරන්න තමයි තියෙන්නේ. මේක  folder නම් කරන්නත් යොදා ගන්න පුළුවන්.
සිංහලෙන් ටයිප් කරන්න මේක හරි ලේසි ක්‍රමයක්. ඔයාලත් කරලා බලන්නකෝ.
මම අපේ ටික්කට ස්තුතියි කියන්න ඕනේ. මොකද එයාගෙන් තමයි මත මේක දැනගත්තේ.