use of org.springframework.context.support.AbstractApplicationContext in project dubbo by alibaba.
the class ServiceBean method setApplicationContext.
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
SpringExtensionFactory.addApplicationContext(applicationContext);
if (applicationContext != null) {
SPRING_CONTEXT = applicationContext;
try {
// 兼容Spring2.0.1
Method method = applicationContext.getClass().getMethod("addApplicationListener", new Class<?>[] { ApplicationListener.class });
method.invoke(applicationContext, new Object[] { this });
supportedApplicationListener = true;
} catch (Throwable t) {
if (applicationContext instanceof AbstractApplicationContext) {
try {
// 兼容Spring2.0.1
Method method = AbstractApplicationContext.class.getDeclaredMethod("addListener", new Class<?>[] { ApplicationListener.class });
if (!method.isAccessible()) {
method.setAccessible(true);
}
method.invoke(applicationContext, new Object[] { this });
supportedApplicationListener = true;
} catch (Throwable t2) {
}
}
}
}
}
use of org.springframework.context.support.AbstractApplicationContext in project spring-framework by spring-projects.
the class QuartzSchedulerLifecycleTests method destroyLazyInitSchedulerWithCustomShutdownOrderDoesNotHang.
// SPR-6354
@Test
public void destroyLazyInitSchedulerWithCustomShutdownOrderDoesNotHang() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass());
assertNotNull(context.getBean("lazyInitSchedulerWithCustomShutdownOrder"));
StopWatch sw = new StopWatch();
sw.start("lazyScheduler");
context.destroy();
sw.stop();
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
}
use of org.springframework.context.support.AbstractApplicationContext in project opennms by OpenNMS.
the class Main method run.
@Override
public void run() {
try {
// Parse arguments to initialize the configuration fields.
parseArguments(m_args);
// Test to make sure that we can use ICMP. If not, replace the ICMP
// implementation with NullPinger.
initializePinger();
// If we didn't get authentication information from the command line or
// system properties, then use an AWT window to prompt the user.
// Initialize a Spring {@link SecurityContext} that contains the
// credentials.
getAuthenticationInfo();
AbstractApplicationContext context = createAppContext();
PollerFrontEnd frontEnd = getPollerFrontEnd(context);
if (!m_gui && !m_scanReport) {
if (!frontEnd.isRegistered()) {
if (m_locationName == null) {
LOG.error("No location name provided. You must pass a location name the first time you start the Remote Poller!");
System.exit(27);
} else {
frontEnd.register(m_locationName);
}
}
}
} catch (Throwable e) {
// a fatal exception occurred
LOG.error("Exception occurred during registration!", e);
System.exit(27);
}
}
use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class Client method main.
public static void main(String[] args) throws Exception {
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/client.xml");
CamelContext context = applicationContext.getBean("camel", CamelContext.class);
context.start();
ProducerTemplate template = context.createProducerTemplate();
String out = template.requestBodyAndHeader("jms:queue:loan", null, Constants.PROPERTY_SSN, "Client-A", String.class);
System.out.println(out);
template.stop();
context.stop();
}
use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class CamelClient method main.
// START SNIPPET: e1
public static void main(final String[] args) throws Exception {
System.out.println("Notice this client requires that the CamelServer is already running!");
AbstractApplicationContext context = new ClassPathXmlApplicationContext("camel-client.xml");
// get the camel template for Spring template style sending of messages (= producer)
ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class);
System.out.println("Invoking the multiply with 22");
// as opposed to the CamelClientRemoting example we need to define the service URI in this java code
int response = (Integer) camelTemplate.sendBody("jms:queue:numbers", ExchangePattern.InOut, 22);
System.out.println("... the result is: " + response);
// we're done so let's properly close the application context
IOHelper.close(context);
}
Aggregations