Search |
||
Getting started with HK2 - Part IPosted by ss141213 on January 28, 2008 at 6:30 AM PST
Now that I am working in HK2, I shall share my experiences of HK2 with others via my blogs. I firmly believe that examples are a great way to learn a new technology. So, I will start with a "Hello World" type application. The fact that you are reading this blog makes me think that you already know what HK2 is. Although HK2 is being used in development of ultra light-weight, modular, next generation GlassFish application server, any Java SE programmer can use it to write modular applications. It has a very nice component model with IoC support. In fact, this sample has nothing to do with server side programing. The complete sample along with Maven build scripts, etc. can be downloaded from here. Structure of the sample
hello-world-hk2-sample/
/pom.xml
/hello-startup/pom.xml
/src/main/java/sahoo/hello/startup/MyStartup.java
As you notice, even though there is only one module, named hello-startup, I have decided to keep a top level pom.xml with packaging type pom and kept hello-startup module in a sub-project. I have done so because I know, in reality, one has multiple modules, so why not get used to that kind of structure from beginning? Prerequisite: How to build (-f option to mvn instructs it to use a specified pom.xml. It is equivalent to cd to hello-world-hk2-sample and invoking 'mvn install') How to run mvn -f hello-world-hk2-sample/hello-startup/pom.xml hk2:run 2. Running a start up script: ./hello-world-hk2-sample/run.sh run.sh is a very simple script that copies all the necessary HK2 jar files from your Maven local repository to a directory called ./lib. It also copies your application jar files to ./lib. Then it launches HK2 using the following command: java -jar ./lib/hk2-0.2-SNAPSHOT.jar Note: There are a couple of variables like JAVA_HOME and MAVEN_REPO_LOCAL in run.sh that you need to configure for your environment. Sample Description: 2. Let's now take a look at our only class, MyStartup.java. Conclusion Useful Links: »
Related Topics >>
Java Enterprise Comments
Comments are listed in date ascending order (oldest first)
Submitted by secretplot on Mon, 2008-01-28 09:01.
why not osgi?
Submitted by anthavio on Mon, 2008-01-28 13:39.
Because sun. They like to disregard other's work and create own less then mediocre solutions. But I must admit hk2 ioc is quite springish
Submitted by antsh on Thu, 2008-01-31 06:25.
Thx for the tutorial, real help!!! You saved me a lot of time and nerves :)
Submitted by antsh on Thu, 2008-01-31 06:30.
Is it normal that I am getting an message when I run the hk.jar:
WARNING: No Main-Bundle module found in manifest of C:\Java_files\workspace\test\lib\hk2-core-0.2-SNAPSHOT.jar
Sahoo, Well I just had a look
Submitted by dew_drops on Sat, 2009-11-28 06:58.
Sahoo, Well I just had a look at your samples. I must say you are very creative and skilled person. I agree that examples are the best practical ways to learn things.
Voucher Codes
Submitted by ss141213 on Thu, 2008-01-31 08:01.
I am glad it helped you. There is a second tutorial available. Just check my latest blog.
Yes, it is normal to get that message. You are getting that message because the framework discovered the primordial module for you instead of you specifying it to the framework. I think I should change that to a INFO message rather than a warning.
Thanks,
Sahoo
Submitted by ss141213 on Wed, 2008-09-17 07:31.
I have updated the sample zip file. It now uses latest version of HK2.
I am glad it helped you.
Submitted by kirru on Sun, 2009-12-06 23:28.
I am glad it helped you. There is a second tutorial available. Just check my latest blog. Yes, it is normal to get that message. You are getting that message because the framework discovered the primordial module for you instead of you specifying it to the framework.
electronic cigarette
Re
Submitted by eoinmorgan on Sat, 2009-10-10 04:10.
Re
Submitted by eoinmorgan on Sat, 2009-10-10 04:11.
is a very simple script that copies all the necessary .
Buy Essay
Online Essay
Essay Writing Service
Essay Service
Thanks a lot for useful tips
Submitted by benhurt on Tue, 2009-11-17 14:00.
Thanks a lot for useful tips and guidelines for Java users.
Custom web design
I slightly read the sample
Submitted by susazero on Fri, 2009-11-20 21:46.
I slightly read the sample code in the sample file, But the explanation was enough to clear all doubts to use this script at my web site called muscle gain
hi
Submitted by 3zakkk on Sat, 2009-12-05 11:49.
It would be desirable to listen still to opinion of experts in this occasion
Venue Hire
nice
Submitted by kiddzyaaaa on Sun, 2009-12-06 23:16.
I am glad it helped you. There is a second tutorial available. Just check my latest blog. Yes, it is normal to get that message. You are getting that message because the framework discovered the primordial module for you instead of you specifying it to the framework.
electronic cigarette
nice
Submitted by kirru on Sun, 2009-12-06 23:23.
Because sun. They like to disregard other's work and create own less then mediocre solutions. But I must admit hk2 ioc is quite springish
electronic cigarette
Dental Implants Bristol
Submitted by cliftonsmiles on Thu, 2010-01-07 01:04.
t is normal to get that message. You are getting themessage because the framework discovered the primordial module for you instead of you specifying it to the framework...
Dental Implants Bristol
|
||
|