org.apache.tiles.request.ApplicationContext类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.apache.tiles.request.ApplicationContext类的一些代码示例,展示了ApplicationContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext类的具体详情如下:
包路径:org.apache.tiles.request.ApplicationContext
类名称:ApplicationContext

ApplicationContext介绍

[英]Defines a set of methods which tiles use to communicate to the tiles container and runtime environment. There is only one application context per container.
[中]定义一组方法,平铺使用这些方法与平铺容器和运行时环境通信。每个容器只有一个应用程序上下文。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
  if (definitions != null) {
    List<ApplicationResource> result = new LinkedList<>();
    for (String definition : definitions) {
      Collection<ApplicationResource> resources = applicationContext.getResources(definition);
      if (resources != null) {
        result.addAll(resources);
      }
    }
    return result;
  }
  else {
    return super.getSources(applicationContext);
  }
}

代码示例来源:origin: org.apache.tiles/tiles-test-common

/** {@inheritDoc} */
  @Override
  protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
    List<ApplicationResource> urls = new ArrayList<ApplicationResource>();
    urls.addAll(applicationContext
        .getResources("/WEB-INF/**/tiles-defs*.xml"));
    urls.add(applicationContext.getResource(
        "classpath:/org/apache/tiles/classpath-defs.xml"));
    urls.add(applicationContext.getResource(
        "classpath:/org/apache/tiles/freemarker-classpath-defs.xml"));
    urls.add(applicationContext.getResource(
      "classpath:/org/apache/tiles/velocity-classpath-defs.xml"));
    return urls;
  }
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
public Object getContext() {
  return context.getContext();
}

代码示例来源:origin: org.apache.struts/struts2-tiles-plugin

@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
  Collection<ApplicationResource> resources = new ArrayList<>();
  Set<String> definitions = getTilesDefinitions(applicationContext.getInitParams());
  for (String definition : definitions) {
    resources.addAll(applicationContext.getResources(definition));
  }
  if (resources.contains(null)) {
    LOG.warn("Some resources were not found. Definitions: {}. Found resources: {}", definitions, resources);
  }
  List<ApplicationResource> filteredResources = new ArrayList<>();
  for (ApplicationResource resource : resources) {
    if (resource != null && Locale.ROOT.equals(resource.getLocale())) {
      filteredResources.add(resource);
    }
  }
  return filteredResources;
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
public ApplicationResource getResource(String localePath) {
  return context.getResource(localePath);
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/**
 * Returns the application scope.
 *
 * @return The application scope.
 */
public Map<String, Object> getApplicationScope() {
  return applicationContext.getApplicationScope();
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
public Map<String, String> getInitParams() {
  return context.getInitParams();
}

代码示例来源:origin: org.apache.tiles/tiles-extras

try {
  Collection<ApplicationResource> resources = applicationContext
      .getResources("classpath*:META-INF/MANIFEST.MF");
  ApplicationResource mainResource = applicationContext.getResource("/META-INF/MANIFEST.MF");
  if (mainResource != null) {
    resources.add(mainResource);

代码示例来源:origin: org.apache.tiles/tiles-el

/** {@inheritDoc} */
public void setApplicationContext(ApplicationContext applicationContext) {
  Object context = applicationContext.getContext();
  if (context instanceof ServletContext) {
    this.servletContext = (ServletContext) context;
  } else {
    throw new IllegalArgumentException(
        "The application context does not hold an instance of "
        + "ServletContext, consider using JuelExpressionFactoryFactory");
  }
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
public ApplicationResource getResource(ApplicationResource base, Locale locale) {
  return context.getResource(base, locale);
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
public Map<String, Object> getApplicationScope() {
  return context.getApplicationScope();
}

代码示例来源:origin: pl.edu.icm.synat/synat-ui-commons

super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory);
Map<String, String> parameters = new HashMap<>();
parameters.putAll(applicationContext.getInitParams());
parameters.putAll(getFreemarkerServletInitParameters(applicationContext));
parameters.put("NoCache", "true");

代码示例来源:origin: org.springframework/spring-webmvc

@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
  if (definitions != null) {
    List<ApplicationResource> result = new LinkedList<>();
    for (String definition : definitions) {
      Collection<ApplicationResource> resources = applicationContext.getResources(definition);
      if (resources != null) {
        result.addAll(resources);
      }
    }
    return result;
  }
  else {
    return super.getSources(applicationContext);
  }
}

代码示例来源:origin: org.apache.tiles/tiles-test-alt

/** {@inheritDoc} */
  @Override
  protected ApplicationContext createTilesApplicationContext(
      ApplicationContext preliminaryContext) {
    return new WildcardServletApplicationContext(
        (ServletContext) preliminaryContext.getContext());
  }
}

代码示例来源:origin: org.apache.tiles/tiles-test-alt

/** {@inheritDoc} */
@Override
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
  List<ApplicationResource> urls = new ArrayList<ApplicationResource>(URL_COUNT);
  urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-defs.xml"));
  urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-freemarker-defs.xml"));
  urls.add(applicationContext.getResource("classpath:/org/apache/tiles/test/alt/defs/tiles-alt-velocity-defs.xml"));
  return urls;
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/**
 * Registers an application context. It will be registered into itself as an
 * attribute, using the {@link #APPLICATION_CONTEXT_ATTRIBUTE} name.
 *
 * @param applicationContext The application context to register.
 */
public static void register(ApplicationContext applicationContext) {
  applicationContext.getApplicationScope().put(
      APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
}

代码示例来源:origin: org.apache.tiles/tiles-request-api

/** {@inheritDoc} */
  public Collection<ApplicationResource> getResources(String path) {
    return context.getResources(path);
  }
}

代码示例来源:origin: org.apache.tiles/tiles-extras

/** {@inheritDoc} */
@Override
protected ApplicationContext createTilesApplicationContext(
    ApplicationContext preliminaryContext) {
  return new WildcardServletApplicationContext(
      (ServletContext) preliminaryContext.getContext());
}

代码示例来源:origin: org.apache.tiles/tiles-core

/**
 * Returns a list containing the resources to be parsed. By default, it returns a
 * list containing the resource at "/WEB-INF/tiles.xml".
 * @param applicationContext The Tiles application context.
 * @return The resources.
 * @since 2.1.1
 */
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
  List<ApplicationResource> retValue = new ArrayList<ApplicationResource>(1);
  retValue.add(applicationContext.getResource("/WEB-INF/tiles.xml"));
  return retValue;
}

代码示例来源:origin: org.apache.tiles/tiles-api

/**
 * Returns the container to be used in the application registered under a specific key.
 *
 * @param context The Tiles application context object to use.
 * @param key The key under which the container will be stored.
 * @return The container object.
 * @since 3.0.0
 */
public static TilesContainer getContainer(ApplicationContext context,
    String key) {
  if (key == null) {
    key = CONTAINER_ATTRIBUTE;
  }
  return (TilesContainer) context.getApplicationScope().get(key);
}

相关文章