Package juzu.impl.common

Examples of juzu.impl.common.JSON


      addChild(key, template);
    }
  }

  public JSON toJSON() {
    JSON json = new JSON();
    json.set("path", path.getCanonical());
    return json;
  }
View Full Code Here


  public Path.Absolute getPath() {
    return path;
  }

  public JSON toJSON() {
    JSON json = new JSON();
    json.set("element", element);
    json.set("template", getChild(TemplateMetaModel.KEY));
    return json;
  }
View Full Code Here

  public FileObject resolveResource(Path.Absolute path) throws NullPointerException, IllegalArgumentException {
    return model.processingContext.resolveResourceFromSourcePath(handle, path);
  }

  public JSON toJSON() {
    JSON json = new JSON();
    json.set("handle", handle);
    json.set("qn", handle.getPackageName().toString());
    json.map("templates", getChild(TemplateContainerMetaModel.KEY));
    json.map("controllers", getChild(ControllersMetaModel.KEY));
    return json;
  }
View Full Code Here

  public final HashMap<String, ParamDescriptor> parameters;

  public RouteDescriptor(JSON config) {

    HashMap<String, ParamDescriptor> parameters = null;
    JSON foo = config.getJSON("parameters");
    if (foo != null) {
      parameters = new HashMap<String, ParamDescriptor>();
      for (String name : foo.names()) {
        String pattern = foo.getJSON(name).getString("pattern");
        Boolean preservePath = foo.getJSON(name).getBoolean("preserve-path");
        Boolean captureGroup = foo.getJSON(name).getBoolean("capture-group");
        parameters.put(name, new ParamDescriptor(pattern, preservePath, captureGroup));
      }
    }

    //
View Full Code Here

  @Override
  public JSON getDescriptor(ApplicationMetaModel application) {
    AssetsMetaModel assetsMetaModel = application.getChild(AssetsMetaModel.KEY);
    Iterator<Asset> assetsIterator = assetsMetaModel.getAssets().iterator();
    if (assetsIterator.hasNext()) {
      JSON descriptor = new JSON();
      JSON assets = new JSON();
      while (assetsIterator.hasNext()) {
        Asset asset = assetsIterator.next();
        assets.set(asset.id, asset.getJSON());
      }
      descriptor.set("assets", assets);
      descriptor.set("package", "assets");
      return descriptor;
    } else {
View Full Code Here

  protected void preRemove() {
  }

  public JSON toJSON() {
    return new JSON();
  }
View Full Code Here

        ElementHandle.Type bindingValue = (ElementHandle.Type)binding.get("value");
        ElementHandle.Type bindingImplementation = (ElementHandle.Type)binding.get("implementation");
        String scope = (String)binding.get("scope");

        //
        JSON bindingJSON = new JSON().set("value", bindingValue.getName().toString());

        //
        TypeElement valueElt = env.get(bindingValue);
        TypeMirror valueTM = valueElt.asType();

        //
        if (bindingImplementation != null) {
          TypeElement implementationElt = env.get(bindingImplementation);
          DeclaredType implementationTM = (DeclaredType)implementationElt.asType();

          // Check class
          if (implementationElt.getKind() != ElementKind.CLASS) {
            throw IMPLEMENTATION_INVALID_TYPE.failure(env.get(key.getElement()), providerElt.getQualifiedName());
          }

          //
          Set<Modifier> modifiers = implementationElt.getModifiers();

          // Check not abstract
          if (modifiers.contains(Modifier.ABSTRACT)) {
            throw IMPLEMENTATION_NOT_ABSTRACT.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
          }

          //
          if (env.isAssignable(implementationTM, providerFactoryTM)) {
            // Check public
            if (!modifiers.contains(Modifier.PUBLIC)) {
              throw PROVIDER_FACTORY_NOT_PUBLIC.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }

            // Find zero arg constructor
            ExecutableElement emptyCtor = null;
            for (ExecutableElement ctorElt : ElementFilter.constructorsIn(env.getAllMembers(implementationElt))) {
              if (ctorElt.getParameters().isEmpty()) {
                emptyCtor = ctorElt;
                break;
              }
            }

            // Validate constructor
            if (emptyCtor == null) {
              throw PROVIDER_FACTORY_NO_ZERO_ARG_CTOR.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }
            if (!emptyCtor.getModifiers().contains(Modifier.PUBLIC)) {
              throw PROVIDER_FACTORY_NO_PUBLIC_CTOR.failure(env.get(key.getElement()), implementationElt.getQualifiedName());
            }
          }
          else if (env.isAssignable(implementationTM, rawProviderTM)) {
            TypeVariable T = (TypeVariable)providerTM.getTypeArguments().get(0);
            TypeMirror resolved = env.asMemberOf(implementationTM, T.asElement());
            if (env.isAssignable(resolved, valueTM)) {
              // OK
            }
            else {
              throw PROVIDER_NOT_ASSIGNABLE.failure(
                  env.get(key.getElement()),
                implementationElt.getQualifiedName(),
                resolved,
                valueElt.getQualifiedName());
            }
          }
          else if (env.isAssignable(implementationTM, valueTM)) {
            // OK
          }
          else {
            throw IMPLEMENTATION_NOT_ASSIGNABLE.failure(
                env.get(key.getElement()),
              implementationElt.getQualifiedName(),
              valueElt.getQualifiedName());
          }

          //
          bindingJSON.set("implementation", bindingImplementation.getName().toString());
        }

        // Add the declared scope if any
        if (scope != null) {
          bindingJSON.set("scope", scope);
        }

        //
        list.add(bindingJSON);
      }
    }

    //
    state.put(metaModel.getHandle(), new JSON().set("bindings", list));
  }
View Full Code Here

    };

    // Init plugins
    HashMap<String, ServiceDescriptor> descriptors = new HashMap<String, ServiceDescriptor>();
    for (ModuleService plugin : plugins.values()) {
      final JSON pluginConfig = context.getConfig().getJSON(plugin.getName());

      //
      ServiceContext pluginContext = new ServiceContext() {
        public JSON getConfig() {
          return pluginConfig;
View Full Code Here

    super("binding");
  }

  @Override
  public ServiceDescriptor init(ServiceContext context) throws Exception {
    JSON config = context.getConfig();
    ClassLoader loader = context.getClassLoader();
    if (config != null) {

      // Load factories via servicer loader mechanism
      ArrayList<ProviderFactory> factories = Tools.list(ServiceLoader.load(ProviderFactory.class, loader));

      //
      ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>();
      List<? extends JSON> bindings = config.getList("bindings", JSON.class);
      for (JSON binding : bindings) {
        String value = binding.getString("value");
        String scope = binding.getString("scope");
        String implementation = binding.getString("implementation");
View Full Code Here

    }
    return sources;
  }

  public JSON getJSON() {
    JSON json = new JSON().
        set("value", key.value).
        set("location", key.location.toString()).
        set("type", type);
    if (minified != null) {
      json.set("minified", minified);
    } else if (minifiersTypes.size() > 0) {
      json.set("minified", getMinifiedSource());
    }
    if (maxAge != null) {
      json.set("max-age", maxAge);
    }
    if (depends != null) {
      json.set("depends", depends);
    }
    if (header != null) {
      json.set("header", header);
    }
    return json;
  }
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.