Announcement Announcement Module
Collapse
No announcement yet.
Initialize SpringContext on SAR-deployment Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initialize SpringContext on SAR-deployment

    Hi,

    I was wondering if it's possible to initialize the SpringContext when deploying a SAR file on JBoss. I have a Spring managed JMX bean and another way is to create a webapp which we have done for another component but it's a bit overkill.

    Maybe someone has a another idea on how to initilize the context when deploying a different kind of archive?

    Thanks,
    Maarten

  • #2
    I haven't used jboss for quite some time, but IIRC, the SAR has the ability to bootstrap a class when deployed by the server. Using this bootstrap point, you can trigger the loading of Spring's application context.

    Comment


    • #3
      <code>
      <mbean code="bean.jmx.ApplicationContextService" name="spring:service=context">
      <attribute name="ContextConfigLocation">appContext.xml,poolCo ntext.xml,jobContext.xml</attribute>
      </mbean>
      </code>
      class:
      <code>
      public class ApplicationContextService implements applicationContextServiceMBean{

      private String contextConfigLocation;
      private ConfigurableApplicationContext context;


      public void start(){
      context = new ClassPathXmlApplicationContext(contextConfigLocati on.split(","));
      }

      public void stop(){
      context.close();
      }

      public void setContextConfigLocation(String contextConfigLocation) {
      this.contextConfigLocation = contextConfigLocation;
      }
      </code>

      Comment

      Working...
      X