test_class.declarator: tmpDir
test_class.modifier: private
test_class.original_string: private File tmpDir;
test_class.type: File
test_class.var_name: tmpDir
test_class.file: smart-zeppelin/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java
test_class.identifier: ApplicationLoaderTest
test_case.body: @Test
    public void loadUnloadApplication() throws Exception {
      // given
      LocalResourcePool resourcePool = new LocalResourcePool("pool1");
      DependencyResolver dep = new DependencyResolver(tmpDir.getAbsolutePath());
      ApplicationLoader appLoader = new ApplicationLoader(resourcePool, dep);
  
      HeliumPackage pkg1 = createPackageInfo(MockApplication1.class.getName(), "artifact1");
      ApplicationContext context1 = createContext("note1", "paragraph1", "app1");
  
      // when load application
      MockApplication1 app = (MockApplication1) ((ClassLoaderApplication)
          appLoader.load(pkg1, context1)).getInnerApplication();
  
      // then
      assertFalse(app.isUnloaded());
      assertEquals(0, app.getNumRun());
  
      // when unload
      app.unload();
  
      // then
      assertTrue(app.isUnloaded());
      assertEquals(0, app.getNumRun());
    }
test_case.class_method_signature: ApplicationLoaderTest.loadUnloadApplication()
test_case.full_signature: @Test public void loadUnloadApplication()
test_case.identifier: loadUnloadApplication
test_case.invocations: getAbsolutePath createPackageInfo getName createContext getInnerApplication load assertFalse isUnloaded assertEquals getNumRun unload assertTrue isUnloaded assertEquals getNumRun
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void loadUnloadApplication()
focal_class.declarator: logger = LoggerFactory.getLogger(ApplicationLoader.class)
focal_class.original_string: Logger logger = LoggerFactory.getLogger(ApplicationLoader.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: depResolver
focal_class.modifier: private final
focal_class.original_string: private final DependencyResolver depResolver;
focal_class.type: DependencyResolver
focal_class.var_name: depResolver
focal_class.declarator: resourcePool
focal_class.modifier: private final
focal_class.original_string: private final ResourcePool resourcePool;
focal_class.type: ResourcePool
focal_class.var_name: resourcePool
focal_class.declarator: cached
focal_class.modifier: private final
focal_class.original_string: private final Map<HeliumPackage, Class<Application>> cached;
focal_class.type: Map<HeliumPackage, Class<Application>>
focal_class.var_name: cached
focal_class.file: smart-zeppelin/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java
focal_class.identifier: ApplicationLoader
focal_class.class_method_signature: ApplicationLoader.ApplicationLoader(ResourcePool resourcePool, DependencyResolver depResolver)
focal_class.full_signature: public  ApplicationLoader(ResourcePool resourcePool, DependencyResolver depResolver)
focal_class.identifier: ApplicationLoader
focal_class.modifiers: public
focal_class.parameters: (ResourcePool resourcePool, DependencyResolver depResolver)
focal_class.signature:  ApplicationLoader(ResourcePool resourcePool, DependencyResolver depResolver)
focal_class.class_method_signature: ApplicationLoader.load(HeliumPackage packageInfo, ApplicationContext context)
focal_class.full_signature: public Application load(HeliumPackage packageInfo, ApplicationContext context)
focal_class.identifier: load
focal_class.modifiers: public
focal_class.parameters: (HeliumPackage packageInfo, ApplicationContext context)
focal_class.return: Application
focal_class.signature: Application load(HeliumPackage packageInfo, ApplicationContext context)
focal_class.class_method_signature: ApplicationLoader.findRequiredResourceSet(
        String [][] requiredResources, String noteId, String paragraphId)
focal_class.full_signature: public ResourceSet findRequiredResourceSet(
        String [][] requiredResources, String noteId, String paragraphId)
focal_class.identifier: findRequiredResourceSet
focal_class.modifiers: public
focal_class.parameters: (
        String [][] requiredResources, String noteId, String paragraphId)
focal_class.return: ResourceSet
focal_class.signature: ResourceSet findRequiredResourceSet(
        String [][] requiredResources, String noteId, String paragraphId)
focal_class.class_method_signature: ApplicationLoader.findRequiredResourceSet(String [][] requiredResources,
                                               String noteId,
                                               String paragraphId,
                                               ResourceSet resources)
focal_class.full_signature: static ResourceSet findRequiredResourceSet(String [][] requiredResources,
                                               String noteId,
                                               String paragraphId,
                                               ResourceSet resources)
focal_class.identifier: findRequiredResourceSet
focal_class.modifiers: static
focal_class.parameters: (String [][] requiredResources,
                                               String noteId,
                                               String paragraphId,
                                               ResourceSet resources)
focal_class.return: ResourceSet
focal_class.signature: ResourceSet findRequiredResourceSet(String [][] requiredResources,
                                               String noteId,
                                               String paragraphId,
                                               ResourceSet resources)
focal_class.class_method_signature: ApplicationLoader.loadClass(HeliumPackage packageInfo)
focal_class.full_signature: private Class<Application> loadClass(HeliumPackage packageInfo)
focal_class.identifier: loadClass
focal_class.modifiers: private
focal_class.parameters: (HeliumPackage packageInfo)
focal_class.return: Class<Application>
focal_class.signature: Class<Application> loadClass(HeliumPackage packageInfo)
focal_method.body: public Application load(HeliumPackage packageInfo, ApplicationContext context)
        throws Exception {
      if (packageInfo.getType() != HeliumPackage.Type.APPLICATION) {
        throw new ApplicationException(
            "Can't instantiate " + packageInfo.getType() + " package using ApplicationLoader");
      }
  
      // check if already loaded
      RunningApplication key =
          new RunningApplication(packageInfo, context.getNoteId(), context.getParagraphId());
  
      // get resource required by this package
      ResourceSet resources = findRequiredResourceSet(packageInfo.getResources(),
          context.getNoteId(), context.getParagraphId());
  
      // load class
      Class<Application> appClass = loadClass(packageInfo);
  
      // instantiate
      ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
      ClassLoader cl = appClass.getClassLoader();
      Thread.currentThread().setContextClassLoader(cl);
      try {
        Constructor<Application> constructor = appClass.getConstructor(ApplicationContext.class);
  
        Application app = new ClassLoaderApplication(constructor.newInstance(context), cl);
        return app;
      } catch (Exception e) {
        throw new ApplicationException(e);
      } finally {
        Thread.currentThread().setContextClassLoader(oldcl);
      }
    }
focal_method.class_method_signature: ApplicationLoader.load(HeliumPackage packageInfo, ApplicationContext context)
focal_method.full_signature: public Application load(HeliumPackage packageInfo, ApplicationContext context)
focal_method.identifier: load
focal_method.invocations: getType getType getNoteId getParagraphId findRequiredResourceSet getResources getNoteId getParagraphId loadClass getContextClassLoader currentThread getClassLoader setContextClassLoader currentThread getConstructor newInstance setContextClassLoader currentThread
focal_method.modifiers: public
focal_method.parameters: (HeliumPackage packageInfo, ApplicationContext context)
focal_method.return: Application
focal_method.signature: Application load(HeliumPackage packageInfo, ApplicationContext context)