コード例 #1
0
 @Override
 public void preLoadDPUs(List<DPUTemplateRecord> dpus) {
   for (DPUTemplateRecord dpu : dpus) {
     try {
       install(dpu);
     } catch (ModuleException e) {
       LOG.warn("Failed to pre-load dpu: {}", dpu.getJarPath(), e);
     }
   }
 }
コード例 #2
0
 @Override
 public Dictionary<String, String> getJarProperties(DPUTemplateRecord dpu) {
   try {
     BundleContainer container = install(dpu);
     return container.getHeaders();
   } catch (ModuleException e) {
     LOG.error("Failed to install bundle: {}", dpu.getJarDirectory(), e);
   }
   return null;
 }
コード例 #3
0
  @Override
  public void beginUpdate(DPUTemplateRecord dpu) {
    final String directory = dpu.getJarDirectory();
    // first we need lock on this directory
    lockUpdate(directory);
    // now we are the only one running .. we can work

    BundleContainer container = bundles.get(directory);
    if (container == null) {
      // bundle is not loaded .. create one, so we can lock it
      container = new BundleContainer(context, directory);
      bundles.put(directory, container);
    }

    // we secure that there exist record for DPU we wan't to load
  }
コード例 #4
0
  @Override
  public void delete(DPUTemplateRecord dpu) {
    final String directory = dpu.getJarDirectory();
    lockUpdate(directory);
    // delete directory
    final File directoryFile = new File(getDPUDirectory(), directory);
    LOG.debug("Deleting {}", directory.toString());
    try {
      FileUtils.deleteDirectory(directoryFile);
    } catch (IOException e) {
      LOG.error("Failed to delete directory.", e);
    }
    // uninstall
    uninstall(directory);

    releaseUpdate(directory);
  }
コード例 #5
0
  @Override
  public void endUpdate(DPUTemplateRecord dpu, boolean updateFailed) {
    final String directory = dpu.getJarDirectory();
    BundleContainer container = bundles.get(directory);
    if (container == null) {
      // bundle does not exist
    } else {
      // bundle exist
      if (updateFailed) {
        // we have to remove and uninstall the bundle
        try {
          container.uninstall();
        } catch (BundleException e) {
          LOG.error("Can't unistall bundle after update failure.", e);
        }
        // in every case remove from bundles
        bundles.remove(directory);
      }
    }

    // release lock for given directory
    releaseUpdate(directory);
  }
コード例 #6
0
 /**
  * If container is not installed yet then install it. In every case return the installed instance
  * of {@link BundleContainer} for given directory. The container is installed as DPU container.
  *
  * @param dpu
  * @return
  * @throw ModuleException
  */
 private BundleContainer install(DPUTemplateRecord dpu) throws ModuleException {
   return install(dpu.getJarDirectory(), dpu.getJarName());
 }
コード例 #7
0
 @Override
 public void unLoad(DPUTemplateRecord dpu) {
   final String directory = dpu.getJarDirectory();
   unLoad(directory);
 }