Create new user in unix with root permissions

1. Add new user

root@0d9d9ddf04bb:~# useradd anil

2. set password

root@0d9d9ddf04bb:~# passwd anil
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

3. Tye sudo visudo, add below entry at the end

anil ALL=(ALL) NOPASSWD:ALL

Imagination vs Knowledge

Knowledge is limited
Imagination is unlimited

Knowledge takes you from A to B
Imagination takes you everywhere

I’m enough of an artist to draw freely on my imagination, which I think is more important than knowledge. Knowledge is limited. Imagination encircles the world. –Albert Einstein

 

Mac Tricks: Opening hidden directory in Finder

I had this requirement all the time to navigate through ~/.m2 directory from Finder – I found below step is very easy to open hidden directory from finder – 

1) Go to Terminal

2) open ~/.m2

That’s it.

Back with new blog

Back with new blog. 🙂

On Struts 2

I was just browsing through to find out new developments in Struts 2 and found the following are is nice articles on Struts 2.

http://www.infoq.com/articles/converting-struts-2-part1
http://www.infoq.com/articles/migrating-struts-2-part2

Summary of points:
– Dispatcher has been changed from servlet to filter
– Action class is not singleton. So no thread-safety issues for Action class
– Action class can be a simple POJO with a signature public String methodName()
– No tight coupling to container in Action class code.
– Injected dependencies with DI/IoC
– Concept of Interceptors
– Simplified Unit testing of action classes

Spring’s IoC

Spring Framwork is promoting loose coupling through a inversion of control (IoC). A powerful idea. When IoC is applied, objects are passively given their dependencies instead of creating or looking for dependent objects for themselves. This defers the architectural decisions to be taken at later point of time. In other terms, my class need not know what kind of implementation being injected by framework. The injected object can be remote object or local object. It could be a web service, EJB or an RMI object.

JSF Lifecycle

JSF Lifecycle Phases

1. Restore View

– If the request is first visit of page, builds the view of the page, wire event handlers and validator to each component in view and saves view in FacesContext

– If the action is post back, it restores the view which had already been created

2. Apply request values

– Recursively calls decode() on all the components in tree by extracting new values from request

– In case of conversion failure, stacks up error messages in faces context

– If there are any events queued up, notifies the interested listeners

– If any of the components have immediate attribute set to ‘true’, conversion, validation and events associated with component are done in this phase

– If the redirection to another web app or non-JSF page required, responseComplete() called on FacesContext

– If the validators or listeners call FacesContext’s renderResponse method, the lifecycle skips to render response phase.

3. Process Validations
– Registered validators on components triggered and error messages would be stacked into faces context if there are any validation issues

– If there are any events queued up, notifies the interested listeners

– If the redirection to another web app or non-JSF page required, responseComplete() called on FacesContext

– If the validators or listeners call FacesContext.renderResponse method, the lifecycle skips to render response phase.

4. Update model values phase

– Copies the values to backed bean properties

– In case of conversion issues, lifecycle advances to render response phase

– If the updateModels or listerners call FacesContext.renderResponse method, the lifecycle skips to render response phase.

– If there are any events queued up, notifies the interested listeners.

– If the redirection to another web app or non-JSF app required, responseComplete() called on FacesContext
– Invoke Application Phase

5. Handles the application level events

– If the redirection to another web app or non-JSF app required, responseComplete() called on FacesContext

6. Render Response Phase

– Renders the response

– If there are any validation errors, renders the error messages on page if there are messages tags.