uk.co.grahamcox.spring.cli.options
Class CommandLineBeanPostProcessor

java.lang.Object
  extended by uk.co.grahamcox.spring.cli.options.CommandLineBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.context.ApplicationContextAware

public class CommandLineBeanPostProcessor
extends Object
implements org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.context.ApplicationContextAware

Bean post processor for creating the CommandLine object properly and for automatically wiring command line options into created beans

Author:
graham

Constructor Summary
CommandLineBeanPostProcessor()
           
 
Method Summary
 Object postProcessAfterInitialization(Object bean, String name)
          Do nothing
 Object postProcessBeforeInitialization(Object bean, String name)
          This now does two things.
 void setApplicationContext(org.springframework.context.ApplicationContext context)
          Set the Application Context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineBeanPostProcessor

public CommandLineBeanPostProcessor()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext context)
                           throws org.springframework.beans.BeansException
Set the Application Context

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Parameters:
context - the context
Throws:
org.springframework.beans.BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String name)
                                      throws org.springframework.beans.BeansException
Do nothing

Specified by:
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String name)
                                       throws org.springframework.beans.BeansException
This now does two things. If the arguments and commandLineParser objects are bound, and the bean is a CommandLine object then try to actually instantiate the command line from the Options object in the context, using the bound arguments and parser If this isn't the case and the bean has at least one method with the WireOption annotation then attempt to wire into that setter the value from the named command line option

Specified by:
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException


Copyright © 2011. All Rights Reserved.