Archive

Archive for the ‘JAVA’ Category

Stripes, Spring, Play on the scene

December 15, 2010 2 comments

Currently we are working on decision which one of framework (MVC) candidates to use … stripes, play or spring (or combination )…  We’ve worked on simple task. The authentication (security) methods on stripes and play. The Security controller in Play is quite simple in default.
googling  results…

The best performance is to be found with the action based frameworks (no paradigm mismatch as the component based frameworks have). The Shortlist would be Stripes first and Spring the  second.  So how to extend this about PlayFramework ?

Stripes Framework (Pro):

  1. Fast
  2. SEO friendly links
  3. Elegant easy to understand code (1 thread per action).
  4. Low learning curve, any Java web developer can quickly learn it.
  5. 100% open source, no chance of future license changes.
  6. Focused and small integrates with any stack.

Stripes Framework (Against):

  1. Less well known
  2. Not full stack

Spring MVC (Pro):

  1. Fast
  2. SEO friendly links
  3. Lots of developers have worked with Spring (but less with Spring MVC).
  4. Full stack, part of Spring framework.

Spring MVC (Against):

  1. Higher learning curve
  2. More complex code: because beans need to be programmed tread safe, result is procedural code.
  3. You might need to buy licenses from VM Ware in the future if you want to get all latest patches.
  4. License terms can and have changed for future versions.
  5. Full stack, you might get more than you need.
Categories: brief news, JAVA

Stripes Framework: Why can it be useful for you ?

December 13, 2010 Leave a comment

These days I’m working with this framework and I’m reading about it also… so short comments I want to have noted as quick summary.  I’ll extend it latter:

  • Smart binding:  Stripes goes a long way to bind URLs, parameters,and events from HTTP to Java so that your code remains simple and straightforward. The names in your view templates match the names of your Java classes, methods, and properties, so theassociation between the two is very clear.
  • Auto loading:  Stripes automatically discovers and loads your Stripes-related classes, so you can add, rename, and remove classes without worrying about keeping any configuration files (XMLor otherwise) in sync.
  • Validation:  Stripes provides a powerful validation mechanism that is based on annotations.
  • Type conversion and formatting: Stripes gives you strong type support by automatically converting between Strings and common Java types and making it easy to add your own data types to its conversion system.
  • Layouts: With three tags from its tag library, Stripes gives you a simple and powerful reusable layout mechanism. You guess edit—no configuration files involved here either.
  • Localization:  Stripes tags have a default resource bundle lookup strategy so that localization is simple.
  • Exception handling: When an exception goes all the way up the stack without being handled, the servlet container shows a big ugly exception page. You don’t want your users to see that!  Stripes lets you show specific error pages for the exception types that youcare about and has a general “catch all” error page for all other exceptions.
  • Interceptors:  When handling a request,  Stripes goes through several life-cycle stages before providing a response. Interceptors letyou write code that is called before or after any of these stages, making it easy to alter the flow, change the data, and so on.  Interceptors are a great way of plugging in custom behavior.
  • Customizable URLs:  Stripes takes care of all the URL binding for you, so you can write your whole application without ever bothering with URLs.  However, if you need specific URL patterns,  Stripes lets you do that too.
  • Easy Ajax integration:  With the simple and transparent request response nature of Stripes, you can Ajaxify your applications by using your favorite Ajax framework as a front end and Stripes as a back end.
  • Testing:  Stripes comes with a built-in set of mock objects that help you write automated unit tests to make sure your application works as expected.
  • Easy extension and customization:  Stripes is designed in a modular fashion with many areas to hook into. You can plug in different behavior for any part of the framework. Extensibility is an are a where Stripes really shines, and if you’re not used to being able to easily insert custom code into a framework, you’re in for a real treat.
Categories: brief news, JAVA

discussionNotes: Google AppEngine and AmazonWeb Services as main actors

December 12, 2010 Leave a comment

It’s question which one choose for startUP project ? It’s fair to mention you want to run on Java Virtual Machine (JVM).  I guess you have three choices: Google AppEngine, Amazon Web Services or rent your own Server.  Which one is better ? Good question … I think it always good is to follow your knowledge base and your pocket ( money you have assigned for the project ) and comfort…

My Friend Fraktalek has published the new post “Google AppEngine vs. Amazon Web Service” so I don’t want to writing about similar things, you can read it.

Amazon has announced ONE YEAR free package to give you ability of using AWS Free Tier ( 613 MB of memory and 32-bit and 64-bit platform support). Management console allows you to set up your tier (t1.micro is that one for free).  You can choose op. system image to have installed there … and Amazon command line tools EC2 to connect to your new virtual system.  You can for example install Tomcat Server and use SimpleDB as main database …. What I want to note is that you have full administration rules. That means freedom.  In this way I’m very glad for Cloud Computing … You don’t have to care about hardware or something like this only choose what you want to use or install it.  I have also tested building small farm inside AWS  Cloud (IPs setups and firewalls etc. ).   I’m not able to say the economic payload (have to do calculation).  At the first look I think it’s good invest time to study AWS closer … example user could be WikiLeaks (no comment ) :)

Compare to GAE, which is the platform, AWS needs more time to read how it works. You are also forced to get better understanding around (Is it really bad ?). What you gain is the freedom.  GAE you could simply integrate to your IDE and don’t care how it’s working. Google engineers are too smart to make it works. You have to follow only restrictions which are everywhere especially in “FREE” cases ;)

The third choice is your own server… nice and cool but I think you need to have more money even for system upgrades …  it’s up to you!

Categories: Google, JAVA

Stripes Framework (IntelliJ IDEA 9.04) : Calculator Example as the new project

November 24, 2010 Leave a comment

Project is described on the Stripes main site  as the Beginner guide.  I’m using IntelliJ as my IDE for such applications. Here are steps how to avoid to common mistakes in web.xml setup.

What I have:

  1. IntelliJ IDEA 9.04
  2. Apache Tomcat 6.0.29
  3. Stripes 1.5.4

Create new project from scratch ( example “StripesExample” ).  You obtain project directory structure.  I’ll go from the top of this structure and add or change appropriate files inside. Before we start just do import of all Stripes and other necessary libraries for this example (commons-logging.jar, cos.jar, jstl.jar, log4j-1.2.15.jar, mail.jar,standard.jar, stripes.jar). Don’t forget  libraries are located in /WEB-INF/lib directory.

1. create new package inside “src” directory  (example: “examples.stripes“)
2. in this directory create new “CalculatorActionBean.java” and copy the source code. Don’t forget to change package name !
3. time to configure *.properties files (commons-logging.properties, log4j.properties, StripesResources.properties) . You can follow the manual. These files are located in “/WEB-INF/classes” directory
4. web.xml file configuration. It seems to be key to run the example properly.  If you have followed me  only do change in web.xml :

….
<filter>
<display-name>Stripes Filter</display-name>
<filter-name>StripesFilter</filter-name>
<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
<init-param>
<param-name>ActionResolver.Packages</param-name>
<param-value>examples.stripes</param-value>
</init-param>
</filter>
……

Now should be everything ready to deploy on Tomcat server directly from IDE…

Categories: JAVA, Ubuntu Geek

Google AppEngine and PlayFramework v1.1 the first experience

November 22, 2010 Leave a comment

This Blog post  is the brief  report how to easily deploy example GAE application “lists-with-gae“. I have spend couple of hours today playing with this cool new framework.   I decided to test Google AppEngine  deployment  of mine project as the last point today. This report will be focused only on the ”lists-with-gae” project.  This project is located in default gae plugin installation.  Check the GAE-version you want to install to you Play project.  I should point out I’m running under Ubuntu 10.04 !

# play install gae-1.1
# play install siena-1.3

Than you need to define your GAE plugin in the project in conf/application.conf

# Additional modules
# ~~~~~
# A module is another play! application. Add a line for each module you want
# to add to your application. Module paths are either absolutes or relative to
# the application root.
module.gae=${play.path}/modules/gae-1.1
module.siena=${play.path}/modules/siena-1.3


before you return back to your project directory you have to edit your .bashrc file.  Define variable GAE_SDK:

export GAE_PATH=~/eclipse_helios/plugins/com.google.appengine.eclipse.sdkbundle.1.3.8_1.3.8.v201010161055/appengine-java-sdk-1.3.8/bin

than you have to change permission to the appcfg.sh file

#chmod +x  ~/eclipse_helios/plugins/com.google.appengine.eclipse.sdkbundle.1.3.8_1.3.8.v201010161055/appengine-java-sdk-1.3.8/bin/appcfg.sh

Note: It works perfectly. I have also tested to define unziped GAE directory directly but I received deployment errors! I recommend you to use Eclipse Plugin (Based on forum discussion)!

Now it’s time to run following command in the project ”lists-with-gae” directory:
#play gae:deploy

I don’t know why you still receive in log this warning but …

21:12:08,197 WARN  ~ Google App Engine module
21:12:08,197 WARN  ~ ~~~~~~~~~~~~~~~~~~~~~~~
21:12:08,197 WARN  ~ No Google App Engine environment found. Setting up a development environement

… don’t worry,  everything gonna be deployed to your GAE project.   Edit war/WEB-INF/appengine-web.xml  and define your project before you run command above

<appengine-web-app xmlns=”http://appengine.google.com/ns/1.0″>
<application>YOURTEST_PROJECT</application>
<version>2</version>
</appengine-web-app>

And now check it out …. it works :)

Categories: JAVA, Ubuntu Geek

Nowaday tale:: Not only for developers/testers

The King’s Challenge (a fable)
Once upon a time, a mighty king wanted to determine which of his three court wizards was the most powerful. So he put the three court wizards in the castle dungeon and declared whoever escaped from his respective dungeon cell first was the most powerful wizard in all the kingdom.

(…Before reading on, decide what you would do….)

The first wizard immediately started chanting mystical poems to open his cell door. The second wizard immediately started casting small polished stones and bits of bone on the floor to learn how he might open his cell door.The third wizard sat down across from his cell door and thought about the situation for a minute. Then he got up, walked over to the cell door and pulled on the door handle. The cell door swung open because it was closed but not locked. Thus, the third wizard escaped his cell first and became known as the most powerful wizard in all the kingdom.

Categories: brief news, JAVA

Fork-join queue and GPars – Groovy Parallel Systems

March 30, 2010 Leave a comment

I saw nice presentation about GPars project during CzJUG meeting.  Show has been done by Vaclav Pech.  (Great Speaker of last GeeCON 1st 2009 in Krakow )

Well back to the topic, Fork-join queue (Image 1) is the subset of queueing theory closely connected with mathematical theory of probability. I guess for those how have read book written by Cormen and comapny “Introduction to Algorithms” is probability not big surprise :) . It’s quite everywhere…

The GPars project is promising to be the way of handling tasks asynchronously, concurrently which are distributed over your hardware performance. Of course, everything is focused on Java platform with smart Groovy contribution.  The reason why I really do love using Groovy is its flexibility, which is even better in the latest  version 1.7. GPars main areas of utilization are following: Concurrent collection processing, Asynchronous operations, Fork/Join abstraction, Actor, Dataflow concurrency constructions and Save -> an mt-safe references to mutable state.  I think GPars has big potential because of Groovy … big power and programming is more fun.

Let’s try

Categories: brief news, GeeCON, JAVA

JavaCamp#2 KRAKOW – Google Android #1

February 20, 2010 Leave a comment

13.02.2010 wbudynku D6 Katedry Telekomunikacji, AGH (al. Mickiewicza 30) – Address of this event.   I hadn’t time to post everything earlier as I had to solve  couple of issues.

I was in Krakow since 10.2 morning.  When I approached I sent SMS message to my friend to pick me up.  I still don’t know why but I turned off my mobile.  That wasn’t funny because I forgot my PIN to keep myself back.  My friend only knew that I’m in Railway station but nothing else. I was very glad I’ve  received his car photo before my trip. I found his parked car after while.  Than I waited another 45 minutes till he arrived back.  After this issue everything went right :) .

We’ve visited Google office and had very nice talk with Krakow Director. He gave me NexusONE for Presentation. It was very nice because Nexus1 hasn’t been introduce before to Java Community.  I’m sure they love such piece of hardware.

JavaCamp was great as all speakers were amazing in general. I have listened all other presentations in Polish, as my training. I did understand quite good (” Google AppEngine,”Jak czerpać przyjemność z programowania w świecie krótkich terminów i parcia na słupk”,” Java/JEE Performance Test Planning – How To Plan Successful Performance Tuning of Java/JEE applications”) :) but I’m still pupil.  I haven’t feel similar atmosphere in Czech before, that’s maybe why I was so happy there.  I really don’t know why students are not so active here in Prague, maybe they are, only I haven’t seen it, but where is the true?.  I’m still excited by motivation of students I met during JavaCamp.  I found out also on my presentation were older guys (>7).  Maybe they were professors, got feeling. Such Events could smartly push whole university being forward, that’s the other possible impact of professors interest even on Saturday.

During JavaCamp break (>20min) we had a pizza ordered. I got lot of question to answer so not so much time to eat pizza. Others were testing Nexus and comparing with other Android powered mobile phones. Honestly, I do note here. Nexus looks much nicer in real compare to other mobiles even iPhone… this is not only mine opinion.  Nexus design looks smart and no so provoke. You get really nice feeling to work with N1.    But back to pizza break. I found only last 2 pieces …

Here is much better overview about  whole JavaCamp on this blog, Have a look and enjoy ….

PS: I post this with delay because I received couple of urgent issues after my return back.

Categories: GeeCON, Google Android, JAVA

Polish Java User Group – Java Camp #2 on 13.2.2010

February 8, 2010 1 comment

On Saturday I’m going to give presentation about Android Application development.  The best news I’ll have the Nexus ONE smartphone there. So presentation will be more interesting, definitely. I have to thank you to Google guys :)

Outlook to Android Platform Application Development (OAPAD) -  presentation is focused on Androrid 2.1 (>=1.6). It shows,  how to deal with Intents, Geocoding, SQLite database, XML files. Overview around general project structure and permissions. (Introduction of the Nexus ONE phone)

I’m looking forward to be there. Only I’m little sad because of direct train connection has been canceled. I don’t understand why.

Categories: JAVA

Groovy: MySQL connection with UTF-8 encoding/charset

February 1, 2010 Leave a comment

The UTF-8 is an important encoding because of the following reasons. It’s ASCII compatible, easily supported, compact and efficient for most scripts, easily processed, unlike other multibyte encodings.

When I worked on data conversion procedure used for Machines in industry I found out that UTF-8 is one of the most important thing.  It’s very clever to keep your attention here because it could damage many things and Machines don’t do so.

I suppose you have well setup your IDE and Database to ‘UTF-8′. When you are importing data to Database you have seen crapped letters like ‘âøñè?’. Maybe you spend hours by googling why?  Try out following in Groovy, of course:

Sql sql = Sql.newInstance(
jdbc:mysql://localhost:3306/your_database?useUnicode=true&characterEncoding=UTF-8“,
“user”, “pass”, “com.mysql.jdbc.Driver”)

// We assume db table similar to:
sql.execute(“”"
CREATE TABLE IF NOT EXISTS `your_databset` (
`id` bigint(32) NOT NULL AUTO_INCREMENT,
`text` varchar(500) NOT NULL,

) CHARSET=utf8;
“”")

The most important is the line starts with “jdbc:mysql://localhost …“. Although utf-8 charset behaves very well inside your IDE log output if you don’t have setupcharacterEncoding=UTF-8 letters become to be crapped. My issue was caused by Czech charset.

Categories: brief news, JAVA
Follow

Get every new post delivered to your Inbox.