Announcement Announcement Module
Collapse
No announcement yet.
spring standalone app Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring standalone app

    hi all,
    sorry this might look like a silly question but i have been so used to run apps in application servers that now i am little in trouble.
    I have to write a standalone Spring application that listen to an MQ, picks messages and insert content of the message in a database.
    Currently on our system we don't have an application server, so i was wondering how am i going to implement this....
    as a running thread?
    any other alternatives?

    thanks in advance and regards
    marco

  • #2
    You might be able to use mdp. Take a look at http://static.springframework.org/sp...rence/jms.html. You should be able to bring the app up by instantiating the appcontext from a class with a main method and let spring handle the threading.

    Comment


    • #3
      This is a loaded question. Is it going to be a Swing/SWT app or Main program of some type?

      Here is some pointers that might help
      No you don't need J2EE container to run Spring.
      You would obviously need a Java program with main() method in it ( I assume you know that ) and there are various ways to instantiate Spring Bean Factory and/or Application Context (see a quick example below).
      Code:
      public static void main(String[] args) {
            ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
      		
            ITest test = (ITest) context.getBean("testTarget");
            test.foo("Foo");
            System.out.println("Done");
      }
      If you are running it in Swing/SWT app then you would include this code in the appropriate place within your GUI container.

      If you are planing to implement your own container you can look at implementation of Main class of Tomcat, Servicemix, JBoss and other containers (Servicemix would be preferable since it is Spring based)
      small example would be:
      Code:
      public static void main(String args[]) {
              try {
                 ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
                  . . . . .
                  Object lock = new Object();
                  synchronized (lock) {
                      lock.wait();  
                  }
                  
              } catch (Exception e) {
                  e.printStackTrace();
              }
      }
      Hope it helps

      Oleg Zhurakousky

      Comment


      • #4
        Hi all,
        thanks for all replies.... well it's going to be a standalone app (with Main())...
        i m going to check out servicemix as it looks exactly what i need

        regards
        marco

        Comment


        • #5
          In order to simplify main management, I have created https://jira.springsource.org/browse/SPR-9044. If you like the proposed approach, please vote for it.

          Comment

          Working...
          X