Package org.apache.wicket.spring

Examples of org.apache.wicket.spring.SpringBeanLocator


   */
  public Object getFieldValue(Field field, Object fieldOwner) {

    if (field.isAnnotationPresent(SpringBean.class)) {
      SpringBean annot = field.getAnnotation(SpringBean.class);
      SpringBeanLocator locator = new SpringBeanLocator(annot.name(),
          field.getType(), contextLocator);

      // only check the cache if the bean is a singleton
      if (locator.isSingletonBean() && cache.containsKey(locator)) {
        return cache.get(locator);
      }

      if (failFast) {
        testLocator(locator, fieldOwner, field);
      }

      Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
          locator);
      // only put the proxy into the cache if the bean is a singleton
      if (locator.isSingletonBean()) {
        cache.put(locator, proxy);
      }
      return proxy;
    } else {
      return null;
View Full Code Here


  {
    Bean bean = new Bean();

    ctx.putBean("bean", bean);

    SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator);
    assertTrue(locator.locateProxyTarget() == bean);
  }
View Full Code Here

  {
    Bean bean = new Bean();
   
    ctx.putBean("bean", bean);

    SpringBeanLocator locator = (SpringBeanLocator) Objects
        .cloneObject(new SpringBeanLocator(Bean.class, ctxLocator));

    assertNotNull(locator.locateProxyTarget());
  }
View Full Code Here

  /**
   * tests error if bean with class is not in the context
   */
  public void testLookupByClassNotFound()
  {
    SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator);
    try
    {
      locator.locateProxyTarget();
      fail();
    }
    catch (IllegalStateException e)
    {
      // noop
View Full Code Here

  {
    Bean bean = new Bean();
    ctx.putBean("somebean", bean);
    ctx.putBean("somebean2", bean);

    SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator);
    try
    {
      locator.locateProxyTarget();
      fail();
    }
    catch (IllegalStateException e)
    {
      // noop
View Full Code Here

  public void testLookupByName()
  {
    Bean bean = new Bean();
    ctx.putBean("bean", bean);

    SpringBeanLocator locator = new SpringBeanLocator("bean", Bean.class, ctxLocator);
    assertTrue(locator.locateProxyTarget() == bean);

  }
View Full Code Here

  public void testLookupByNameAfterDeserialization()
  {
    Bean bean = new Bean();
    ctx.putBean("bean", bean);

    SpringBeanLocator locator = (SpringBeanLocator) Objects
        .cloneObject(new SpringBeanLocator("bean", Bean.class, ctxLocator));

    assertNotNull(locator.locateProxyTarget());
  }
View Full Code Here

  /**
   * tests error if no bean with name found
   */
  public void testLookupByNameNotFound()
  {
    SpringBeanLocator locator = new SpringBeanLocator("bean", Bean.class, ctxLocator);
    try
    {
      locator.locateProxyTarget();
      fail();
    }
    catch (IllegalStateException e)
    {
      // noop
View Full Code Here

   */
  public void testConstructorArguments()
  {
    try
    {
      SpringBeanLocator locator = new SpringBeanLocator(null, ctxLocator);
      fail();
    }
    catch (IllegalArgumentException e)
    {
      // noop
    }

    try
    {
      SpringBeanLocator locator = new SpringBeanLocator(Bean.class, null);
      fail();
    }
    catch (IllegalArgumentException e)
    {
      // noop
View Full Code Here

   * tests error when context not found
   */
  public void testContextNotFound()
  {
    SpringContextLocatorMock ctxLocator = new SpringContextLocatorMock(null);
    SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator);
    try
    {
      locator.locateProxyTarget();
    }
    catch (IllegalStateException e)
    {
      // noop
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.spring.SpringBeanLocator

Copyright © 2018 www.massapicom. 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.