spring 几个有用的类
public class ApplicationContextUtil implements ApplicationContextAware {Logger logger = LoggerFactory.getLogger(ApplicationContextUtil.class);public static Map<String, CamelContext> map;@Overridepublic void setApplicationContext(ApplicationContext applicationContext)throws BeansException {map = applicationContext.getBeansOfType(CamelContext.class);//getBeansOfType 返回bean的实例匹配给定的对象类型(包括子类),}}public class ChannelBetListener implements ApplicationListener<ContextRefreshedEvent>{private static Logger logger=LoggerFactory.getLogger(ChannelBetListener.class);@Resource(name="channelCamelContext")CamelContext camelContext;@Produceprivate ProducerTemplate drawProducer;@Overridepublic void onApplicationEvent(ContextRefreshedEvent event) {try{//加载配置文件后所干的事}catch(Exception e){e.printStackTrace();}}}@Configurationpublic class MinaConfiguration { public @Bean IoAcceptor ioAcceptor(){ return new NioSocketAcceptor(); } public @Bean LoggingFilter loggingFiler(){ return new LoggingFilter();//相当于<bean id="" class=""></bean> } public @Bean ProtocolCodecFilter protocolCodecFilter(){ return new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))); }}