Tuesday, November 29, 2011

Making a Spring bean Applicationcontext aware

Suppose we have a webapplication with spring,
and we are initializing spring’s WebApplicationContext by configuring ContextLoaderListener in web.xml.
How can we get an instance of spring’s applicationContext object?
Possible solutions:
While configuring spring through web.xml the spring ApplicationContext object is set in the ServletContext.
To get ApplicationContext we say

So we can get spring ApplicationContext only where ServletContext is avaliable i.e. in Servlet,ServletFilter or any implementation class of ServletContextListener.
What if we dont want to write a servletFilter or ServletContextListener .
What if we need to access a spring bean before a servletFilter or servlet is called(for authentication)and we dont want to write a ServletContextListener.
How can we obtain spring’s applicationContext in this case?
One way to achieve this would be to use the ApplicationContextAware interface provided by Spring.
Create a class which implements ApplicationContextAware. The method, “setApplicationContext(…)” gets called during the creation of this bean, providing the reference to the context. Our program should store this for a later interaction with the context.

Initialize the new bean in applicationContext.xml

Now we can call the static method, ApplicationContextProvider.getApplicationContext(), from any class in our application, to get assess to the Spring ApplicationContext.

http://blog.imaginea.com/making-a-spring-bean-applicationcontext-aware/

Monday, November 21, 2011

Increasing VDI file size on VirtualBox

This little tutorial explains how to increase size of existing .vdi virtual hard drive file once the guest OS is already installed on it. I’ve taken a KISS approach describing each end every single step.

http://www.llakomy.com/articles/increasing-vdi-file-size-on-virtualbox-part-1-using-hdclone
http://www.llakomy.com/articles/increasing-vdi-file-size-on-virtualbox-part-2-merging-partitions-with-gparted

what are Agile and Scrum development methodology?

In software development Agile is a set of values and principles formulated by a group of the industry leading figures in 2001.
Scrum is a concrete software development methodology that can be traced back to 1995 and was created by two of the original signatories of Agile Manifesto. Scrum supports Agile values.
The early approach to software project management usually referred to as “waterfall model” implies a sequence of clearly defined steps necessary to complete any project: define, plan, organise, execute and then close.
This represents a very neat, simple and above all convenient abstraction from the project management theorist point of view. When one stage follows another it is possible to define clear inputs and outputs for each stage, isolate and identify techniques and tools that are most useful at every phase. This is a clear example of reductionism in tackling project management complexity: keep splitting the whole into smaller bits until you get to understand each bit in isolation and then hopefully you will master the mechanics of their totality.
But as soon as the waterfall abstraction was presented it started to leak. Firstly it turned out that real-life process can not be clearly cut into stages, often definition is still changed on what it seems to be planning, organisation or even execution stage. So, in theory, the stages were allowed to overlap and theoreticians started drawing all sorts of diagrams there it’s possible to see how the definition stage gradually runs out as execution starts picking up during the organisation stage. Then, again only in theory, it is possible to accurately estimate during the planning stage how long it is going to take to develop a piece of software. Obviously, in actual practise, the estimates and other plans have to be tweaked right through the execution phase which gave birth to a string of complex yet not very meaningful methods as Earned Value Management.
The chronic problems with the waterfall abstraction gave birth to a number of “agile” project management methods (Agile, Scrum, XP Programming etc) that despite many differences at the more detailed level use the same fundamental principles to tackle product development complexity:
  • The project is organised as a number of small iterations through the classic project stages (definition, planning, organisation, execution and closure).
  • Each iteration aims at a relatively small yet semantically complete increment in product functionality or non-functional characteristics.
  • Strong end-user involvement throughout the project.
Since every iteration goes through a separate definition and planning stage the time horizon for various estimation and planning activities is greatly reduced. It helps achieve greater accuracy, hence make it easier to access feasibility, measure value and costs etc.
Small increments help controlling the scope, evaluate utility of the changes and keep users involved since there is always a fresh version of fully functioning product. It is also much easier to organise a number of teams working on a large project simultaneously when increments are kept small, this really helps tackling task dependencies.
The user feedback is key to iterative methods, since it helps the product evolve gradually in a right direction providing greater utility at the end as opposed to the uncertainly of user reaction that is natural to punctuated equilibrium driven by the waterfall “big-bang” approach.

http://stackoverflow.com/questions/677778/what-are-agile-and-scrum-development-methodology

Sunday, November 20, 2011

Error: “\Java\jre6\lib\ext\QTJava.zip was unexpected at this time.”

After installation of Weblogic Server if you get an error: “\Java\jre6\lib\ext\QTJava.zip was unexpected at this time.” This can be solved as under,

Check if QTJava.zip is set in %CLASSPATH% environment variable CLASSPATH=.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip

Remove C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip from %CLASSPATH% environment variable and restart the computer.

http://ora-soa.blogspot.com/2011/06/error-javajre6libextqtjavazip-was.html

Saturday, November 19, 2011

tablesorter

tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. It has many useful features including:
  • Multi-column sorting
  • Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
  • Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)
  • Extensibility via widget system
  • Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+
  • Small code size
http://tablesorter.com/docs/

Tuesday, November 15, 2011

Linux Tutorial Series - Part 01 (Install and Update and Upgrade Ubuntu)

Linux Tutorial Series - Part 01 (Install and Update and Upgrade Ubuntu) 
Linux Tutorial Series Part 02 (Securing Ubuntu 11.04)

Checked vs Unchecked exception


Unchecked exceptions are those that extend RuntimeException class. Compiler will never force you to catch such exception or force you to declare it in the method using throws keyword. All other exception types (that do not extend RuntimeException) are checked and therefore must be declared to be thrown and/or catched.
Checked exceptions are used when you want the caller of your method (i.e the user of your API) to explicitly handle the exceptional case in your API. Checked exceptions are declared when you believe the call will be able to do something meaningful with that exceptional case, like retrying the call, rolling changes back or converting it into some user-readable error message.
If you believe that there is nothing useful the call can do about the exception (especially when it represents a bug, or a wrong usage of your API), then the exception should be unchecked. Also, an API with too many checked exceptions can be annoying to program with (e.g. try using java reflection API=)

http://stackoverflow.com/questions/4639432/checked-vs-unchecked-exception

Sunday, November 13, 2011

Why do we use Interface? Is it only for Standardization?

Purposes of Interfaces

  • create loosely coupled software
  • support design by contract (an implementor must provide the entire interface)
  • allow for pluggable software
  • allow different objects to interact easily
  • hide implementation details of classes from each other
  • facilitate reuse of software
Analogy 1: Much like the US space shuttle, Russian Soyuz spacecraft and Chinese Shenzhou 5 can all dock to the International Space Station, because they implement the same docking interface. (This is the just an example - I don't know if it's true in real life however let's suspend our disbelief for the sake of an example)
Analogy 2: Like you can plug various computer monitors into your home computer. You can plug a wall-size TV into it, an old CRT (the thick kind), a 20" flat screen, or a braille machine for the blind to "see" by touch. There's compatibility among these various/different devices and your computer because they all agree on interface standards.
Details of C# interfaces -- With C#/OOP interfaces you're doing the same kind of thing but in the unseen/virtual world.
You're correct about standardization, but also flexibility, scalability, extensibility, maintainability, reusability, testability and power.
(The more you use software interfaces the more these "buzz words" will be understood. And always consider interfaces in the real world because they have done us equally well.)

http://stackoverflow.com/questions/2026054/why-do-we-use-interface-is-it-only-for-standardization

Saturday, November 12, 2011

Strategy Pattern

In computer programming, the strategy pattern (also known as the policy pattern) is a particular software design pattern, whereby algorithms can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Called ConcreteStrategyAdd's execute()
Called ConcreteStrategySubtract's execute()
Called ConcreteStrategyMultiply's execute()
http://en.wikipedia.org/wiki/Strategy_pattern

Tuesday, November 8, 2011

Agile programming for non-technical people

I like to cook, so I use a soup analogy. Traditional waterfall would be like following a strict recipe, measuring and timing everything exactly, without tasting it until it's completely finished. Agile is like starting with stock and a few basic ingredients, tasting it frequently and adding what your taste-tests show that it "needs."

http://stackoverflow.com/questions/233599/agile-programming-for-non-technical-people

What is “Agile Development”?

I reckon Agile and Iterative provides an excellent overview of the subject.
There are a number of agile processes out there:
An agile process tends to focus on iterations, and client feedback, to allow for the inevitabilty of changing requirements.
A waterfall process tries to define all requirements up front, and tends to be more inflexible to changing requirements.
In fact, the book gives an interesting account into why the fallacy of waterfall was perpetuated for so long.
I definitely recommend having a skim through this book if you can find it.
Also, IMHO what employers tend to be looking for when asking about Agile experience:
It pays to be aware of the following, but I wouldn't go on about these unless the company in question really has bought into agile. These disciplines are not always universally appreciated (which is a shame, as they are just as vital to preventing an agile project from accumulating cruft)
http://stackoverflow.com/questions/240602/what-is-agile-development

Saturday, November 5, 2011

Template Design Pattern

You have a base class with a template method that lists actions you want to execute. Inheriting class is what actually implements methods customizing them as appropriate for the type of robot that you are creating.
Automotive Robot:
Starting....
Getting a carburetor....
Installing the carburetor....
Revving the engine....
Stopping....

Cookie Robot:
Starting....
Getting a flour and sugar....
Baking a cookie....
Crunching a cookie....
Stopping....
Cookie Robot:
Starting....
Getting a flour and sugar....
Baking a cookie....
Stopping....