Package br.com.caelum.vraptor.ioc

Examples of br.com.caelum.vraptor.ioc.Container


    @SuppressWarnings("unchecked")
    public Object convertValue(Map context, Object target, Member member, String propertyName, Object value,
            Class toType) {
        Type genericType = genericTypeToConvert(target, member);
        Class type = rawTypeOf(genericType);
        Container container = (Container) context.get(Container.class);
        if (type.isArray() && !value.getClass().isArray()) {
          Class arrayType = type.getComponentType();
          Object array = Array.newInstance(arrayType, 1);
          Array.set(array, 0, convert(value, arrayType, container));
          return array;
View Full Code Here


        PicoComponentRegistry componentRegistry = new PicoComponentRegistry(this.picoContainer, componentFactoryRegistry);

        this.picoContainer.addComponent(componentRegistry);
        this.picoContainer.addComponent(componentFactoryRegistry);
       
        picoContainer.addComponent(Container.class, new Container() {
      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

        if (!type.equals(String.class)) {
          // 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

    private static final Logger logger = LoggerFactory.getLogger(PicoProvider.class);
  private final Container container;

    private final class AppScopedContainer implements Container {
    public <T> T instanceFor(Class<T> type) {
      Container container = containersByThread.get();
      if (container == null) {
        return picoContainer.getComponent(type);
      }
      return container.instanceFor(type);
    }
View Full Code Here

  private static final Logger logger = LoggerFactory.getLogger(PicoProvider.class);
  private final Container container;

  private final class AppScopedContainer implements Container {
    public <T> T instanceFor(Class<T> type) {
      Container container = containersByThread.get();
      if (container == null) {
        return picoContainer.getComponent(type);
      }
      return container.instanceFor(type);
    }
View Full Code Here

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

        PicoComponentRegistry componentRegistry = new PicoComponentRegistry(this.picoContainer, componentFactoryRegistry);

        this.picoContainer.addComponent(componentRegistry);
        this.picoContainer.addComponent(componentFactoryRegistry);

        picoContainer.addComponent(Container.class, new Container() {
      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

    HibernateProxyInitializer initializer = new HibernateProxyInitializer();
    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

  private static boolean started;
  private static boolean stoped;
  public static class MyProvider implements ContainerProvider {
   
    public <T> T provideForRequest(RequestInfo vraptorRequest, Execution<T> execution) {
    Container container = (Container) vraptorRequest.getServletContext().getAttribute("container");
    return execution.insideRequest(container);
  }
View Full Code Here

  public void stop() {
  }
 
  public Container getContainer() {
    return new Container() {
       
        public <T> T instanceFor(Class<T> type) {
          return type.cast(handler);
        }
       
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.ioc.Container

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.