Thursday, May 6, 2010

Best Leadership style

In our lives as a part of work , family, friends we come across leaders with different styles of operations and leadership qualities. Is there a one best leadership style ? ..Not really ..a leadership style in one situation might not go well in other situations. For example a crisis situation calls for a leader who is commanding and pace setting , where as the same leadership in other situations will be construed as a being a bully. Experts in psychology and organizational culture agree that a mix of leadership styles is the approach that gets the best results from the employees. Situational leadership is generally considered as the best way to go...Situational leadership calls for understanding the situation needs and dealing with appropriate style of leadership.
Richard Boyatzi and Daniel Goleman in their book Primal Leadership classify the leadership styles in

1. THE COMMANDING LEADER
Style: Gives clear directions and expects compliance.
Best used: In times of crisis, to kick-start a turnaround, and in dealing with "problem employees" who don't respond to other methods.
Most likely to say: "Do as I tel! you!"
2. THE PACE-SETTING LEADER
Style: Sets goals and expects them to be achieved.
Best used: For getting results from a motivated and competent team.
Most likely to say: "Go for itl"
3. THE VISIONARY LEADER
Style: Moves people towards a shared vision.
Best used: When a new strategic direction is needed.
Most likely to say: "Come with me."
4.THE COACHING LEADER
Style: Develops peopie for the future.
Best used: To help employees improve performance and develop long-term strengths.
Most likely to say: "Try this."
5.THE AFFILIATIVE LEADER
Style: Creates harmony and builds emotional bonds based on loyalty and trust.
Best used: To heal rifts in a team or to motivate people during stressful periods.
Most likely to say: "People come first."
6.THE DEMOCRATIC LEADER
Style: Forges consensus through participation.
Best used: To build "buy-in" and encourage Input.
Most likely to say: "What do you think?"

So what differentiates a leader from a great leader? It is the wisdom to decide on the best leadership style to employ in a given situation that differentiates a good leader from a great leader.




Tuesday, March 16, 2010

Access to ApplicationContext in Spring based Web applications

Recently in a Spring WS application , i had to get access to the Spring ApplicationContext and it turns out that it is not so well documented. Spring ApplicationContext can be created either by using
ClassPathXmlApplicationContext:
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml", "applicationContext-part2.xml"})

WebApplicationContext:

If we have access to the servletContext 

WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

In a web/Spring WS app, if we do not have access to the servletContext and if we would to like use the existing ApplicationContext , the following approach might be the way to go:


Create a class ApplicationContextContainer that implements ApplicaionContextAware and have it be defined as a
bean in Spring context xml file.

import org.springframework.beans.BeansException;

import org.springframework.context.ApplicationContext;

import org.springframework.context.ApplicationContextAware;

public class ApplicationContextContainer implements ApplicationContextAware {

private ApplicationContext appContext; 


@Override 

public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {

 this.appContext = applicationContext; 

} 
 

public ApplicationContext getAppContext(){

 return appContext; 

} 

}
Create a bean definition for the above class in the spring context file

 <bean id="applicationContextProvider"  class="com.test.ApplicationContextProvider"/>



And by injecting the bean applicationContextProvider, the spring ApplicationContext is accessible in the rest of the application.