Package juzu.impl.plugin.asset

Examples of juzu.impl.plugin.asset.AssetService


      // For now we hardcode this
      Response.Status status = (Response.Status)response;

      //
      AssetService assetPlugin = (AssetService)handler.getBridge().getApplication().getPlugin("asset");

      //
      http.getRequestContext().send(assetPlugin, status);

      //
View Full Code Here


      //
      Response.Status status = (Response.Status)response;

      //
      final AssetService assetPlugin = (AssetService)bridge.getApplication().getPlugin("asset");

      //
      Stream stream = new Stream() {

        /** . */
        private Charset charset = Tools.ISO_8859_1;

        /** . */
        private String mimeType = null;

        /** . */
        private Stream dataStream = null;

        /** . */
        private final LinkedList<String> assets = new LinkedList<String>();

        public void provide(Chunk chunk) {
          if (chunk instanceof Chunk.Property) {
            Chunk.Property<?> property = (Chunk.Property<?>)chunk;
            if (property.type == PropertyType.ENCODING) {
              charset = (Charset)property.value;
            } else if (property.type == PropertyType.MIME_TYPE) {
              mimeType = (String)property.value;
            } else if (property.type == PropertyType.HEADER) {
              Map.Entry<String, String[]> header = (Map.Entry<String, String[]>)property.value;
              for (String value : header.getValue()) {
                resp.addProperty(header.getKey(), value);
              }
            } if (property.type == PropertyType.TITLE) {
              if (resp instanceof RenderResponse) {
                ((RenderResponse)resp).setTitle((String)property.value);
              }
            } else if (property.type == PropertyType.META_TAG) {
              Map.Entry<String, String> metaTag = (Map.Entry<String, String>)property.value;
              Element elt = resp.createElement("meta");
              elt.setAttribute("name", metaTag.getKey());
              elt.setAttribute("content", metaTag.getValue());
              resp.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, elt);
            } else if (property.type == PropertyType.ASSET) {
              assets.add(((String)property.value));
            } else if (property.type == PropertyType.HEADER_TAG) {
              Element headerTag = (Element)property.value;
              Element responseTag = resp.createElement(headerTag.getTagName());
              for (Node child : Tools.children(headerTag)) {
                child = responseTag.getOwnerDocument().importNode(headerTag, true);
                responseTag.appendChild(child);
              }
              resp.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headerTag);
            }
          } else if (chunk instanceof Chunk.Data) {
            Chunk.Data data = (Chunk.Data)chunk;
            if (dataStream == null) {
              Iterable<Asset> resolvedAssets = assetPlugin.getAssetManager().resolveAssets(assets);
              for (Asset resolvedAsset : resolvedAssets) {
                Element elt;
                if (resolvedAsset.isStylesheet()) {
                  int pos = resolvedAsset.getURI().lastIndexOf('.');
                  String ext = pos == -1 ? "css" : resolvedAsset.getURI().substring(pos + 1);
View Full Code Here

    Application application = new Application(injector, descriptor, resourceResolver);
    application.start();
    InjectionContext<?, ?> injectionContext = application.getInjectionContext();

    //
    AssetService assetPlugin = injectionContext.get(AssetService.class).get();

    //
    if (assetServer != null) {

      assetServer.register(application, runMode.getCacheAssets());
    }

    //
    this.injectionContext = injectionContext;
    this.assetManager = assetPlugin.getAssetManager();
    this.descriptor = descriptor;
    this.application = application;
    this.classLoader = moduleLifeCycle.getClassLoader();

    // For application start (perhaps we could remove that)
View Full Code Here

TOP

Related Classes of juzu.impl.plugin.asset.AssetService

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.