Package juzu.impl.common

Examples of juzu.impl.common.JSON


      this.type = type;
    }

    @Override
    public JSON toJSON() {
      return new JSON().set("type", type.getName());
    }
View Full Code Here


      return type;
    }

    @Override
    public JSON toJSON() {
      return new JSON().set("value", value).set("type", type.getName());
    }
View Full Code Here

    return assetsPath;
  }

  @Override
  public ServiceDescriptor init(ServiceContext context) throws Exception {
    JSON config = context.getConfig();
    String assetsPath;
    List<AssetMetaData> assets;
    if (config != null) {
      String packageName = config.getString("package");
      assets = load(packageName, config.getJSON("assets"));
      assetsPath = "/" + Name.parse(application.getPackageName()).append(packageName).toString().replace('.', '/') + "/";
    } else {
      assets = Collections.emptyList();
      assetsPath = null;
    }
View Full Code Here

      JSON assets) throws Exception {
    List<AssetMetaData> abc = Collections.emptyList();
    if (assets != null && assets.getSize() > 0) {
      abc = new ArrayList<AssetMetaData>();
      for (String id : assets.names()) {
        JSON asset = assets.getJSON(id);
        AssetLocation location = AssetLocation.safeValueOf(asset.getString("location"));

        //
        if (location == null) {
          location = AssetLocation.APPLICATION;
        }

        //
        String type = asset.getString("type");

        //
        String value = asset.getString("value");
        if (location == AssetLocation.APPLICATION && !value.startsWith("/")) {
          value = "/" + application.getPackageName().replace('.', '/') + "/" + packageName.replace('.', '/') + "/" + value;
        }
        String minified = asset.getString("minified");
        if (location == AssetLocation.APPLICATION && minified != null && !minified.startsWith("/")) {
          minified = "/" + application.getPackageName().replace('.', '/') + "/" + packageName.replace('.', '/') + "/" + minified;
        }
        Boolean header = asset.getBoolean("header");

        //
        Integer maxAge = asset.getInteger("max-age");

        //
        AssetMetaData descriptor = new AssetMetaData(
          id,
          type,
          location,
          value,
          header,
          minified,
          maxAge,
          asset.getArray("depends", String.class)
        );
        abc.add(descriptor);
      }
    }
    return abc;
View Full Code Here

  }

  public JSON toJSON() {

    //
    JSON json = new JSON();

    //
    json.set("path", path);
    json.set("handle", handle);

    //
    if (parameters != null && parameters.size() > 0) {
      JSON b = new JSON();
      for (Map.Entry<String, ParamDescriptor> parameter : parameters.entrySet()) {
        ParamDescriptor value = parameter.getValue();
        b.set(parameter.getKey(), new JSON().
            set("pattern", value.getPattern()).
            set("preserve-path", value.getPreservePath()).
            set("capture-group", value.getCaptureGroup())
        );
      }
View Full Code Here

      } else {
        try {
          URL configURL = getClassLoader().getResource("juzu/config.json");
          if (configURL != null) {
            String configValue = Tools.read(configURL);
            JSON config = (JSON)JSON.parse(configValue);
            String sourcePathValue = config.getString("sourcepath");
            if (sourcePathValue != null) {
              File sourcePathRoot = new File(sourcePathValue);
              if (sourcePathRoot.isDirectory() && sourcePathRoot.exists()) {
                sourcePath = new DiskFileSystem(sourcePathRoot);
              }
View Full Code Here

        @Override
        public int compare(RouteMetaModel o1, RouteMetaModel o2) {
          return ((Integer)o1.priority).compareTo(o2.priority);
        }
      });
      return new JSON().map("routes", list);
    }
    return null;
  }
View Full Code Here

  private ApplicationDescriptor(ClassLoader loader, Class<?> applicationClass) throws Exception {


    // Load config
    JSON config;
    InputStream in = null;
    try {
      String configPath = applicationClass.getPackage().getName().replace('.', '/') + "/config.json";
      in = loader.getResourceAsStream(configPath);
      String s = Tools.read(in);
View Full Code Here

      try {
        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream in = cl.getResourceAsStream("juzu/config.json");
        String serializedConfig = Tools.read(in);
        JSON config = (JSON)JSON.parse(serializedConfig);
        JSON applications = config.getJSON("application");
        if (applications.names().size() != 1) {
          throw new RuntimeException("Was expecting application size to be 1 instead of " + applications);
        }
        String packageFQN = applications.names().iterator().next();
        ApplicationDescriptor descriptor = ApplicationDescriptor.create(cl, packageFQN);
        // For now we don't resolve anything...
        ResourceResolver resourceResolver = new ResourceResolver() {
          public URL resolve(String uri) {
            return null;
View Full Code Here

    for (ControllerMetaModel controller : ac) {
      controllers.add(controller.getHandle().getName() + "_");
    }

    //
    JSON config = new JSON();
    config.set("default", ac.defaultController != null ? ac.defaultController.toString() : null);
    config.set("error", ac.errorController != null ? ac.errorController.toString() : null);
    config.set("escapeXML", ac.escapeXML);
    config.map("controllers", controllers);

    //
    return config;
  }
View Full Code Here

TOP

Related Classes of juzu.impl.common.JSON

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.