Package com.cognifide.slice.api.context

Examples of com.cognifide.slice.api.context.ContextProvider


  public static <T> T getFromCurrentPath(final PageContext pageContext, final Class<T> type,
      final String appName) {
    final SlingHttpServletRequest request = SliceTagUtils.slingRequestFrom(pageContext);
    final InjectorsRepository injectorsRepository = SliceTagUtils.injectorsRepositoryFrom(pageContext);
    final ContextProvider contextProvider = SliceTagUtils.contextProviderFrom(pageContext);

    return getFromCurrentPath(request, injectorsRepository, contextProvider, type, appName);
  }
View Full Code Here


   *
   * @return current ContextProvider
   */
  @Override
  public ContextProvider popContextProvider() {
    final ContextProvider result = contextScope.getContextProvider();
    contextScope.setContextProvider(contextProviders.pop());
    return result;
  }
View Full Code Here

  private <T> T get(Class<T> type, ExecutionContextImpl executionItem) {
    return (T) get(Key.get(type), executionItem);
  }

  private Object get(Key<?> key, ExecutionContextImpl executionItem) {
    final ContextProvider oldContextProvider = contextScope.getContextProvider();
    contextScope.setContextProvider(contextProvider);

    if ((executionItem.getResource() == null) && (executionItem.getPath() != null)) {
      executionItem.setPath(currentExecutionContext.getAbsolutePath(executionItem.getPath()));
    }
View Full Code Here

    this.key = key;
  }

  @Override
  public T get() {
    final ContextProvider contextProvider = this.contextScope.getContextProvider();
    if (null == contextProvider) {
      return null;
    }

    final Context context = contextProvider.getContext();
    synchronized (context) {
      if (context.contains(key)) {
        return context.get(key);
      }
View Full Code Here

   *
   * @return current ContextProvider
   */
  @Override
  public ContextProvider popContextProvider() {
    final ContextProvider result = contextScope.getContextProvider();
    contextScope.setContextProvider(contextProviders.pop());
    return result;
  }
View Full Code Here

   *
   * Return Context instance for current thread. It contains most current ServletRequest and ServletResponse
   * instances.
   */
  public ContextProvider getContextProvider(final String injectorName) {
    return new ContextProvider() {
      @Override
      public Context getContext() {
        return contexts.get().get(injectorName);
      }
    };
View Full Code Here

  private <T> T get(Class<T> type, ExecutionContextImpl executionItem) {
    return (T) get(Key.get(type), executionItem);
  }

  private Object get(Key<?> key, ExecutionContextImpl executionItem) {
    final ContextProvider oldContextProvider = contextScope.getContextProvider();
    contextScope.setContextProvider(contextProvider);

    if ((executionItem.getResource() == null) && (executionItem.getPath() != null)) {
      executionItem.setPath(currentExecutionContext.getAbsolutePath(executionItem.getPath()));
    }
View Full Code Here

      final Class<T> type) {
    final SlingHttpServletRequest request = SliceTagUtils
        .slingRequestFrom(pageContext);
    final InjectorsRepository injectorsRepository = SliceTagUtils
        .injectorsRepositoryFrom(pageContext);
    final ContextProvider contextProvider = SliceTagUtils
        .contextProviderFrom(pageContext);

    return SliceTagUtils.getFromCurrentPath(request, injectorsRepository,
        contextProvider, type);
  }
View Full Code Here

      final PageContext pageContext = (PageContext) getJspContext();
      final SlingHttpServletRequest request = SliceTagUtils.slingRequestFrom(pageContext);
      final InjectorsRepository injectorsRepository = SliceTagUtils
          .injectorsRepositoryFrom(pageContext);
      final ContextProvider contextProvider = SliceTagUtils.contextProviderFrom(pageContext);

      final Object model = SliceTagUtils.getFromCurrentPath(request, injectorsRepository,
          contextProvider, type, appName);
      pageContext.setAttribute(var, model, PageContext.PAGE_SCOPE);
    } finally {
View Full Code Here

    }
  }

  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);
    }
View Full Code Here

TOP

Related Classes of com.cognifide.slice.api.context.ContextProvider

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.