Source Code : Context Aware Demo
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Context Aware Demo
/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/
///////////////////////////////////////////////////////////////////////////////
//File: aware.xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="contextAware" class="ContextAwareDemo"/>
</beans>
///////////////////////////////////////////////////////////////////////////////
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class ContextAwareDemo implements ApplicationContextAware {
private ApplicationContext ctx;
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
ctx = applicationContext;
}
public static void main(String[] args) {
ApplicationContext ctx = new FileSystemXmlApplicationContext(
"build/aware.xml");
ContextAwareDemo demo = (ContextAwareDemo) ctx.getBean("contextAware");
demo.displayAppContext();
}
public void displayAppContext() {
System.out.println(ctx);
}
}
Thank with us