Package com.cognifide.slice.api.injector

Examples of com.cognifide.slice.api.injector.InjectorWithContext


    if (null == contextProvider) {
      throw new IllegalStateException("ContextProvider is not available");
    }

    final InjectorWithContext injector = injectorsRepository
        .getInjector(applicationName);
    if (injector == null) {
      throw new IllegalStateException("Guice injector not found: "
          + applicationName);
    }

    injector.pushContextProvider(contextProvider);

    try {
      final ModelProvider modelProvider = injector
          .getInstance(ModelProvider.class);
      final Resource resource = request.getResource();
      return (T) modelProvider.get(type, resource);
    } finally {
      injector.popContextProvider();
    }
  }
View Full Code Here


    if (!(adaptable instanceof Resource)) {
      return null;
    }
    Resource resource = (Resource) adaptable;

    InjectorWithContext injector = getInjector(resource);
    try {
      ModelProvider modelProvider = injector.getInstance(ModelProvider.class);
      return modelProvider.get(type, resource);
    } finally {
      injector.popContextProvider();
    }
  }
View Full Code Here

      injector.popContextProvider();
    }
  }

  private InjectorWithContext getInjector(Resource resource) {
    InjectorWithContext injector = repository.getInjector(injectorName);
    ContextProvider contextProvider = requestContextProvider.getContextProvider(injectorName);
    if (contextProvider == null) {
      ContextFactory factory = injector.getInstance(ContextFactory.class);
      Context context = factory.getResourceResolverContext(resource.getResourceResolver());
      contextProvider = new ConstantContextProvider(context);
    }
    injector.pushContextProvider(contextProvider);
    return injector;
  }
View Full Code Here

TOP

Related Classes of com.cognifide.slice.api.injector.InjectorWithContext

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.