Package com.github.dandelion.core

Examples of com.github.dandelion.core.Context


    assertThat(context.getBundles(false)).isEmpty();
  }
 
  @Test
  public void should_initialize_excluded_bundles_from_context(){
    Context context = new Context(new MockFilterConfig());
    context.getConfiguration().setBundleExcludes(Arrays.asList("bundle1"));
   
    request = new MockHttpServletRequest();
    request.setAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE, context);
   
    AssetRequestContext arc = AssetRequestContext.get(request);
View Full Code Here


    assertThat(arc.getExcludedCss()).isEmpty();
  }
 
  @Test
  public void should_initialize_excluded_js_from_context(){
    Context context = new Context(new MockFilterConfig());
    context.getConfiguration().setAssetJsExcludes(Arrays.asList("js1, js2"));
   
    request = new MockHttpServletRequest();
    request.setAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE, context);
   
    AssetRequestContext arc = AssetRequestContext.get(request);
View Full Code Here

  private MockHttpServletResponse response;
  private Context context;

  @Before
  public void setup() {
    context = new Context(new MockFilterConfig());
    request = new MockHttpServletRequest();
    request.setContextPath("/context");
    request.setAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE, context);
    response = new MockHttpServletResponse();
  }
View Full Code Here

   * @return the instance of {@link AssetRequestContext} associated with the
   *         current servlet request.
   */
  public static AssetRequestContext get(ServletRequest servletRequest) {
    Object attribute = servletRequest.getAttribute(AssetRequestContext.class.getCanonicalName());
    Context context = (Context) servletRequest.getAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE);
    if (attribute == null || !(attribute instanceof AssetRequestContext)) {
      attribute = new AssetRequestContext();
      ((AssetRequestContext) attribute).addBundles(context.getConfiguration().getBundleIncludes());
      ((AssetRequestContext) attribute).excludeBundles(context.getConfiguration().getBundleExcludes());
      ((AssetRequestContext) attribute).excludeJs(context.getConfiguration().getAssetJsExcludes());
      ((AssetRequestContext) attribute).excludeCss(context.getConfiguration().getAssetCssExcludes());
      servletRequest.setAttribute(AssetRequestContext.class.getCanonicalName(), attribute);
    }
    return AssetRequestContext.class.cast(attribute);
  }
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    getLogger().debug("Dandelion Asset servlet captured GET request {}", request.getRequestURI());

    Context context = (Context) request.getAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE);
    HttpHeadersConfigurer httpHeadersConfigurer = new HttpHeadersConfigurer(context);
   
    // Get the asset content thanks to the cache key
    String assetKey = context.getCacheManager().getCacheKeyFromRequest(request);
    AssetType assetType = AssetType.typeOfAsset(assetKey);
   
    // Configure response headers
    httpHeadersConfigurer.configureResponseHeaders(response, assetType.getContentType());
   
    // Send the asset's content
    PrintWriter writer = response.getWriter();
    writer.write(context.getCacheManager().getContent(assetKey));
   
    // The response is explicitely closed here instead of setting a
    // Content-Length header
    writer.close();
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    LOG.info("Initializing the Dandelion context");
    context = new Context(filterConfig);
    LOG.info("Dandelion context initialized");
  }
View Full Code Here

  private Context context;
  private MockHttpServletRequest request;
 
  @Before
  public void setup(){
    context = new Context(new MockFilterConfig());
    locator.initLocator(context);
    request = new MockHttpServletRequest();
    request.setAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE, context);
  }
View Full Code Here

  private Context context;
  private MockHttpServletRequest request;
 
  @Before
  public void setup(){
    context = new Context(new MockFilterConfig());
    locator.initLocator(context);
    request = new MockHttpServletRequest();
    request.setAttribute(WebConstants.DANDELION_CONTEXT_ATTRIBUTE, context);
  }
View Full Code Here

TOP

Related Classes of com.github.dandelion.core.Context

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.