org.osgi.framework.Bundle.getDataFile()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.osgi.framework.Bundle.getDataFile()方法的一些代码示例,展示了Bundle.getDataFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getDataFile()方法的具体详情如下:
包路径:org.osgi.framework.Bundle
类名称:Bundle
方法名:getDataFile

Bundle.getDataFile介绍

[英]Creates a File object for a file in the persistent storage area provided for this bundle by the Framework. This method will return null if the platform does not have file system support or this bundle is a fragment bundle.

A File object for the base directory of the persistent storage area provided for this bundle by the Framework can be obtained by calling this method with an empty string as filename.

If the Java Runtime Environment supports permissions, the Framework will ensure that this bundle has the java.io.FilePermission with actions read, write, delete for all files (recursively) in the persistent storage area provided for this bundle.
[中]为框架为此捆绑包提供的持久存储区域中的文件创建文件对象。如果平台没有文件系统支持,或者此捆绑包是片段捆绑包,则此方法将返回null。
通过使用空字符串作为文件名调用此方法,可以获得框架为此捆绑包提供的持久存储区域的基本目录的文件对象。
如果Java运行时环境支持权限,框架将确保此捆绑包具有Java权限。木卫一。FilePermission,对该捆绑包提供的持久存储区域中的所有文件执行读取、写入、删除(递归)操作。

代码示例

代码示例来源:origin: org.eclipse/org.eclipse.osgi

public File getDataFile(String filename) {
    Bundle current = systemBundle;
    if (current != null)
      return current.getDataFile(filename);
    return null;
  }
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi

public File getDataFile(String filename) {
    Bundle current = systemBundle;
    if (current != null)
      return current.getDataFile(filename);
    return null;
  }
}

代码示例来源:origin: apache/felix

public File getDataFile(String filename)
{
  return m_bundle.getDataFile(filename);
}

代码示例来源:origin: org.apache.felix/org.apache.felix.connect

public File getDataFile(String filename)
{
  return m_bundle.getDataFile(filename);
}

代码示例来源:origin: org.apache.xbean/xbean-bundleutils

public File getDataFile(String filename) {
  return bundle.getDataFile(filename);
}

代码示例来源:origin: org.ops4j.pax.cdi/pax-cdi-weld

public File getDataFile(String filename) {
  return bundle.getDataFile(filename);
}

代码示例来源:origin: jboss-switchyard/release

private File getDataDirectory(final Bundle bundle) {
    final File dataDirectory = bundle.getDataFile("");
    final File deploymentsDirectory = new File(dataDirectory, "bpel");
    if (!deploymentsDirectory.exists()) {
      deploymentsDirectory.mkdirs();
      deploymentsDirectory.deleteOnExit();
    }
    return deploymentsDirectory;
  }
}

代码示例来源:origin: jboss-switchyard/release

private File getDeploymentsDirectory() {
    final Bundle bundle = FrameworkUtil.getBundle(getClass());
    final File dataDirectory = bundle.getDataFile("");
    final File deploymentsDirectory = new File(dataDirectory, "deployments");
    if (!deploymentsDirectory.exists()) {
      deploymentsDirectory.mkdir();
      deploymentsDirectory.deleteOnExit();
    }
    return deploymentsDirectory;
  }
}

代码示例来源:origin: org.ogema.ref-impl/internal-api

public static String getCurrentAppStoragePath() {
    String result;
    AppID app = currentAppThreadLocale.get();
    result = app.getBundle().getDataFile("").getAbsolutePath();
    return result;
  }
}

代码示例来源:origin: org.wisdom-framework/resource-controller

/**
 * Creates an install of the {@link org.wisdom.resources.WebJarDeployer}.
 *
 * @param context          the bundle context
 * @param webJarController the instance of controller in which libraries are added and removed
 */
public WebJarDeployer(BundleContext context, WebJarController webJarController) {
  super("jar");
  this.context = context;
  this.controller = webJarController;
  cache = context.getBundle().getDataFile("webjars");
  if (!cache.isDirectory()) {
    boolean made = cache.mkdirs();
    LOGGER.debug("Creating webjars directory : {}", made);
  }
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.base/org.eclipse.scada.base.pipe

public static File getDefaultDirectory ()
{
  final String dir = System.getProperty ( "org.eclipse.scada.base.pipe.storage", null );
  final File fdir;
  if ( dir == null )
  {
    final File base = FrameworkUtil.getBundle ( PipeServiceImpl.class ).getDataFile ( null );
    if ( base == null )
    {
      throw new IllegalStateException ( "Unable to get root folder of bundle data directory" );
    }
    fdir = new File ( base, "storage" );
  }
  else
  {
    fdir = new File ( dir );
  }
  if ( !fdir.exists () )
  {
    fdir.mkdirs ();
  }
  if ( !fdir.isDirectory () )
  {
    throw new IllegalStateException ( String.format ( "'%s' is not a valid directory or could not be created", fdir ) );
  }
  return fdir;
}

代码示例来源:origin: org.onap.ccsdk.sli.core/utils-provider

dataFile = bundle.getDataFile(filename);
if(dataFile.exists()) {
  dataFile.delete();

代码示例来源:origin: org.osgi/osgi.enroute.configurer.simple.provider

File dir = currentBundle.getDataFile("");
File out = IO.getFile(dir, safe);

代码示例来源:origin: org.eclipse/osgi

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: com.github.veithen.cosmos/cosmos-equinox

private PermissionInfo[] getFileRelativeInfos(PermissionInfo[] permissionInfos, Bundle bundle) {
  if (permissionInfos == null)
    return permissionInfos;
  PermissionInfo[] results = new PermissionInfo[permissionInfos.length];
  for (int i = 0; i < permissionInfos.length; i++) {
    results[i] = permissionInfos[i];
    if ("java.io.FilePermission".equals(permissionInfos[i].getType())) { //$NON-NLS-1$
      if (!"<<ALL FILES>>".equals(permissionInfos[i].getName())) { //$NON-NLS-1$
        File file = new File(permissionInfos[i].getName());
        if (!file.isAbsolute()) { // relative name
          try {
            File target = bundle.getDataFile(permissionInfos[i].getName());
            if (target != null)
              results[i] = new PermissionInfo(permissionInfos[i].getType(), target.getPath(), permissionInfos[i].getActions());
          } catch (IllegalStateException e) {
            // can happen if the bundle has been uninstalled;
            // we just keep the original permission in this case.
          }
        }
      }
    }
  }
  return results;
}

代码示例来源:origin: io.fabric8.patch/patch-management

dataFileBackupDir.mkdirs();
final Bundle b = bundlesWithData.get(key);
FileUtils.copyDirectory(b.getDataFile(""), dataFileBackupDir, new FileFilter() {
  @Override
  public boolean accept(File pathname) {

相关文章