Package co.cask.cdap.api.app

Examples of co.cask.cdap.api.app.Application


    // Load the JAR using the JAR class load and load the manifest file.
    File unpackedJarDir = Files.createTempDir();

    try {
      Application app;
      try {
        if ("LOCAL".equals(locationFactory)) {
          lf = new LocalLocationFactory();
        } else if ("DISTRIBUTED".equals(locationFactory)) {
          lf = new HDFSLocationFactory(new Configuration());
        } else {
          LOG.error("Unknown location factory specified");
          return -1;
        }

        Program archive = Programs.createWithUnpack(lf.create(jarFilename), unpackedJarDir);
        Object appMain = archive.getMainClass().newInstance();
        if (!(appMain instanceof Application)) {
          LOG.error(String.format("Application main class is of invalid type: %s",
                                  appMain.getClass().getName()));
          return -1;
        }

        app = (Application) appMain;

      } catch (Exception e) {
        LOG.error(e.getMessage());
        return -1;
      }

      // Now, we are ready to call configure on application.
      // Setup security manager, this setting allows only output file to be written.
      // Nothing else can be done from here on other than creating that file.
      ApplicationSecurity.builder()
        .add(new FilePermission(outputFile.getAbsolutePath(), "write"))
        .apply();
 
      // Now, we call configure, which returns application specification.
      DefaultAppConfigurer configurer = new DefaultAppConfigurer(app);
      app.configure(configurer, new ApplicationContext());
      ApplicationSpecification specification = configurer.createApplicationSpec();

      // Convert the specification to JSON.
      // We write the Application specification to output file in JSON format.
      try {
View Full Code Here


        if (!(appMain instanceof Application)) {
          throw new IllegalStateException(String.format("Application main class is of invalid type: %s",
                                                        appMain.getClass().getName()));
        }

        Application app = (Application) appMain;
        result.set(createResponse(app));
      } finally {
        removeDir(unpackedJarDir);
      }
View Full Code Here

    try {
      Object appInstance = applicationClz.newInstance();
      ApplicationSpecification appSpec;

      if (appInstance instanceof Application) {
        Application app = (Application) appInstance;
        DefaultAppConfigurer configurer = new DefaultAppConfigurer(app);
        app.configure(configurer, new ApplicationContext());
        appSpec = configurer.createApplicationSpec();
      } else {
        throw new IllegalArgumentException("Application class does not represent application: "
                                             + applicationClz.getName());
      }
View Full Code Here

TOP

Related Classes of co.cask.cdap.api.app.Application

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.