Examples of instanceFor()


Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

      public <T> T instanceFor(Class<T> type) {
        Container container = containersByThread.get();
        if (container == null) {
          return picoContainer.getComponent(type);
        }
        return container.instanceFor(type);
      }

      public <T> boolean canProvide(Class<T> type) {
        return instanceFor(type) != null;
      }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

          // suckable ognl doesnt support dependency injection or
          // anything alike... just that suckable context... therefore
          // procedural
          // programming and ognl live together forever!
          Container container = (Container) context.get(Container.class);
          Converter<?> converter = container.instanceFor(Converters.class).to(type);
          ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class);
          Object result = converter.convert((String) value, type, bundle);
          super.setProperty(context, target, key, result);
          return;
        }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

    public <T> T instanceFor(Class<T> type) {
      Container container = containersByThread.get();
      if (container == null) {
        return picoContainer.getComponent(type);
      }
      return container.instanceFor(type);
    }

    public <T> boolean canProvide(Class<T> type) {
      return instanceFor(type) != null;
    }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

    public <T> T instanceFor(Class<T> type) {
      Container container = containersByThread.get();
      if (container == null) {
        return picoContainer.getComponent(type);
      }
      return container.instanceFor(type);
    }

    public <T> boolean canProvide(Class<T> type) {
      return instanceFor(type) != null;
    }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

      return null;
    }
    return new Injectable() {
      public Object getValue() {
        Container container = getContainer();
        return (IoCComponentProvider) (container.canProvide(type) ? container
          .instanceFor(type) : null);
      }
    };
  }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

      public <T> T instanceFor(Class<T> type) {
        Container container = containersByThread.get();
        if (container == null) {
          return picoContainer.getComponent(type);
        }
        return container.instanceFor(type);
      }

      public <T> boolean canProvide(Class<T> type) {
        return instanceFor(type) != null;
      }
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

    XStreamBuilder builder = XStreamBuilderImpl.cleanInstance(new MessageConverter());
    XStreamJSONSerialization jsonSerialization = new XStreamJSONSerialization(response, extractor, initializer, builder);
    XStreamXMLSerialization xmlSerialization = new XStreamXMLSerialization(response, extractor, initializer, builder);
   
    Container container = mock(Container.class);
    when(container.instanceFor(JSONSerialization.class)).thenReturn(jsonSerialization);
    when(container.instanceFor(XMLSerialization.class)).thenReturn(xmlSerialization);
   
    MockLocalization mockLocalization = new MockLocalization(new SingletonResourceBundle("message.cat", "Just another {0} in {1}"));

    serialization = new I18nMessageSerialization(container , mockLocalization);
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

    XStreamJSONSerialization jsonSerialization = new XStreamJSONSerialization(response, extractor, initializer, builder);
    XStreamXMLSerialization xmlSerialization = new XStreamXMLSerialization(response, extractor, initializer, builder);
   
    Container container = mock(Container.class);
    when(container.instanceFor(JSONSerialization.class)).thenReturn(jsonSerialization);
    when(container.instanceFor(XMLSerialization.class)).thenReturn(xmlSerialization);
   
    MockLocalization mockLocalization = new MockLocalization(new SingletonResourceBundle("message.cat", "Just another {0} in {1}"));

    serialization = new I18nMessageSerialization(container , mockLocalization);
 
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

  @Test
  public void shouldRemovePreviouslyRegisteredComponentIfRegisteringAgain() {
  provider.register(Base.class, MyFirstImplementation.class);
  provider.register(Base.class,MySecondImplementation.class);
  Container container = provider.provideRequestContainer(webRequest);
  Base instance = container.instanceFor(Base.class);
  assertThat(instance.getClass(), is(typeCompatibleWith(MySecondImplementation.class)));
  }

  @Test
  public void shouldRemovePreviouslyRegisteredComponentIfRegisteringAgainInAnotherScope() {
View Full Code Here

Examples of br.com.caelum.vraptor.ioc.Container.instanceFor()

  @Test
  public void shouldRemovePreviouslyRegisteredComponentIfRegisteringAgainInAnotherScope() {
  provider.register(Base.class, MyFirstImplementation.class);
  provider.register(Base.class,AppImplementation.class);
  Container container = provider.provideRequestContainer(webRequest);
  Base instance = container.instanceFor(Base.class);
  assertThat(instance.getClass(), is(typeCompatibleWith(AppImplementation.class)));
  }

}
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.