PDA

View Full Version : Initialize SpringContext on SAR-deployment


mroosendaal
Mar 27th, 2006, 05:20 AM
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

Costin Leau
Mar 27th, 2006, 07:18 PM
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.

wims.tijd
Sep 2nd, 2006, 02:32 PM
<code>
<mbean code="bean.jmx.ApplicationContextService" name="spring:service=context">
<attribute name="ContextConfigLocation">appContext.xml,poolContext.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>