Example usage for org.springframework.context ApplicationContext getBean

List of usage examples for org.springframework.context ApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext getBean.

Prototype

<T> T getBean(String name, Class<T> requiredType) throws BeansException;

Source Link

Document

Return an instance, which may be shared or independent, of the specified bean.

Usage

From source file:com.apress.prospringintegration.ftp.FtpOutbound.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/ftp/ftp-outbound-context.xml");
    MessageChannel ftpChannel = context.getBean("ftpChannel", MessageChannel.class);
    File file = new File("readme.txt");
    Message<File> message = MessageBuilder.withPayload(file).build();
    ftpChannel.send(message);// w  ww  .  j  av a  2s  . c  o  m
}

From source file:com.apress.prospringintegration.social.mail.PopMail.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/pop-mail.xml");

    DirectChannel inputChannel = context.getBean("inputChannel", DirectChannel.class);

    inputChannel.subscribe(new MessageHandler() {
        public void handleMessage(Message<?> message) throws MessagingException {
            LOG.info("Message: " + message);
        }/*from  w w w . j a  va2s  .c o m*/
    });
}

From source file:com.swg.flooring.App.java

public static void main(String[] args) {
    //        FlooringOrderArchiveConfig configuration = new FlooringOrderArchiveConfigImpl();
    //        FlooringIDGeneratorDao generator = new FlooringIDGeneratorDaoImpl();
    //        FlooringStateRegistryDao registry = new FlooringStateRegistryDaoImpl();
    //        FlooringProductInventoryDao inventory = new FlooringProductInventoryDaoImpl();
    //        FlooringOrderArchiveWriter writer = new FlooringOrderArchiveWriterImpl();
    //        FlooringOrderArchiveReader reader = new FlooringOrderArchiveReaderImpl();
    //        FlooringOrderArchiveDao archive = new FlooringOrderArchiveDaoImpl(writer, reader);
    //        //from  w  w  w . j  av a  2 s  . c  o  m
    //        UserIO io = new UserIOImpl();
    //        FlooringView view = new FlooringView(io);
    //        
    //        FlooringService serv = new FlooringServiceImpl(
    //                archive, inventory, registry, generator, configuration, audit);
    //        
    //        FlooringController ctrl = new FlooringController(view, serv);    

    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    FlooringController ctrl = ctx.getBean("ctrl", FlooringController.class);

    ctrl.run();
}

From source file:com.apress.prospringintegration.ftp.SftpOutbound.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/ftp/sftp-outbound-context.xml");
    MessageChannel ftpChannel = context.getBean("ftpChannel", MessageChannel.class);
    File file = new File("readme.txt");
    Message<File> message = MessageBuilder.withPayload(file).build();
    ftpChannel.send(message);//from   w  ww.j  a  v a 2 s.c  om
}

From source file:com.apress.prospringintegration.social.mail.ImapMail.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/imap-mail.xml");

    DirectChannel inputChannel = context.getBean("inputChannel", DirectChannel.class);

    inputChannel.subscribe(new MessageHandler() {
        public void handleMessage(Message<?> message) throws MessagingException {
            LOG.info("Message: " + message);
        }/*  w  w  w  . ja  v a 2  s. c  om*/
    });
}

From source file:com.tvd.common.channel.HelloWorldExample.java

public static void main(String args[]) {
    String cfg = "channel/context.xml";
    @SuppressWarnings("resource")
    ApplicationContext context = new ClassPathXmlApplicationContext(cfg);
    MessageChannel channel = context.getBean("names", MessageChannel.class);
    Message<String> message = MessageBuilder.withPayload("World").build();
    channel.send(message);/*  w  w w  .  j  a  v  a  2  s .co  m*/
}

From source file:org.springone2gx_2011.integration.loadbalancing.LbFailoverDemo.java

public static void main(String[] args) {
    ActiveMqTestUtils.prepare();//w ww  .  j a  va 2 s.  c  o m
    ApplicationContext context = new ClassPathXmlApplicationContext("lb-config.xml", LbFailoverDemo.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
    inputChannel.send(new GenericMessage<String>("A"));
    inputChannel.send(new GenericMessage<String>("B"));
    inputChannel.send(new GenericMessage<String>("C"));
}

From source file:com.apress.prospringintegration.social.mail.ImapIdleMail.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/imap-idle-mail.xml");

    DirectChannel inputChannel = context.getBean("inputChannel", DirectChannel.class);

    inputChannel.subscribe(new MessageHandler() {
        public void handleMessage(Message<?> message) throws MessagingException {
            LOG.info("Message: " + message);
        }/*from  w w w . j a  v  a 2  s . com*/
    });
}

From source file:com.swcguild.flooringmastery.FlooringMasteryApp.java

public static void main(String[] args) throws FileNotFoundException {

    ApplicationContext ctxFactory = new ClassPathXmlApplicationContext("applicationContext.xml");
    FlooringMasteryController flooringMasteryController = ctxFactory.getBean("controllerBean",
            FlooringMasteryController.class);

    flooringMasteryController.run();/*www  .ja  v  a2  s. c o  m*/
}

From source file:olegz.scala.spring.SpringDemo.java

/**
 * @param args//w  ww  .jav  a 2s .  co  m
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("scala-config.xml", SpringDemo.class);
    SimpleSpringBean functionDirect = context.getBean("functionDirect", SimpleSpringBean.class);
    functionDirect.printMessage("Hello Spring-Scala");

    SimpleSpringBean functionViaFactoryBean = context.getBean("functionViaFactoryBean", SimpleSpringBean.class);
    functionViaFactoryBean.printMessage("Hello Spring-Scala");
}