Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.StaticWebApplicationContext.registerSingleton()


  }

  public void testSatisfiedBeanPropertyDependencyWithAutowireByName() throws Exception {
    String path = "/BeanProperty.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("testBean", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.setAutowireModeName("AUTOWIRE_BY_NAME");
    hm.register(BeanPropertyController.class, new PathMap(path));
    hm.setApplicationContext(wac);
View Full Code Here


  }

  public void testUnsatisfiedBeanPropertyDependencyWithAutowireByName() throws Exception {
    String path = "/BeanProperty.htm";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
    hm.register(BeanPropertyController.class, new PathMap(path));
    try {
View Full Code Here

  public void testMultiplePaths() throws Exception {
    String path1 = "/Constructor.htm";
    String path2 = "path2.cgi";
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("test", TestBean.class, new MutablePropertyValues());

    HashUrlMapHandlerMapping hm = new HashUrlMapHandlerMapping();
    hm.register(ConstructorController.class, new PathMap[] { new PathMap(path1), new PathMap(path2) });
    hm.setApplicationContext(wac);
    ConstructorController cc = (ConstructorController) wac.getBean(ConstructorController.class.getName());
View Full Code Here

  }

  public void testInternalResourceViewResolverWithContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
View Full Code Here

  public void testInternalResourceViewResolverWithContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
    props.setProperty("key1", "value1");
View Full Code Here

  }

  public void testInternalResourceViewResolverWithSpecificContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
View Full Code Here

  public void testInternalResourceViewResolverWithSpecificContextBeans() throws Exception {
    MockServletContext sc = new MockServletContext();
    final StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("myBean", TestBean.class);
    wac.registerSingleton("myBean2", TestBean.class);
    wac.setServletContext(sc);
    wac.refresh();
    InternalResourceViewResolver vr = new InternalResourceViewResolver();
    Properties props = new Properties();
    props.setProperty("key1", "value1");
View Full Code Here

    assertEquals("message2", lc.getResourceBundle().getString("code2"));
  }

  public void testXmlViewResolver() throws Exception {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.registerSingleton("testBean", TestBean.class);
    wac.setServletContext(new MockServletContext());
    wac.refresh();
    TestBean testBean = (TestBean) wac.getBean("testBean");
    XmlViewResolver vr = new XmlViewResolver();
    vr.setLocation(new ClassPathResource("org/springframework/web/servlet/view/views.xml"));
View Full Code Here

  public void testBeanNameViewResolver() throws ServletException {
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    MutablePropertyValues pvs1 = new MutablePropertyValues();
    pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp"));
    wac.registerSingleton("example1", InternalResourceView.class, pvs1);
    MutablePropertyValues pvs2 = new MutablePropertyValues();
    pvs2.addPropertyValue(new PropertyValue("url", "/example2.jsp"));
    wac.registerSingleton("example2", JstlView.class, pvs2);
    BeanNameViewResolver vr = new BeanNameViewResolver();
    vr.setApplicationContext(wac);
View Full Code Here

    MutablePropertyValues pvs1 = new MutablePropertyValues();
    pvs1.addPropertyValue(new PropertyValue("url", "/example1.jsp"));
    wac.registerSingleton("example1", InternalResourceView.class, pvs1);
    MutablePropertyValues pvs2 = new MutablePropertyValues();
    pvs2.addPropertyValue(new PropertyValue("url", "/example2.jsp"));
    wac.registerSingleton("example2", JstlView.class, pvs2);
    BeanNameViewResolver vr = new BeanNameViewResolver();
    vr.setApplicationContext(wac);
    wac.refresh();

    View view = vr.resolveViewName("example1", Locale.getDefault());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.