Package org.eclipse.osgi.storagemanager

Examples of org.eclipse.osgi.storagemanager.ManagedOutputStream


    if (permissionStorage == null || isReadOnly() || !permissionStorage.isDirty())
      return;
    if (Debug.DEBUG && Debug.DEBUG_GENERAL)
      Debug.println("About to save permission data ..."); //$NON-NLS-1$
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(PERM_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(PERMDATA_VERSION);
        // always write the default permissions first
        String[] defaultPerms = permissionStorage.getPermissionData(null);
        out.writeInt(defaultPerms == null ? 0 : defaultPerms.length);
        if (defaultPerms != null)
          for (int i = 0; i < defaultPerms.length; i++)
            out.writeUTF(defaultPerms[i]);
        String[] locations = permissionStorage.getLocations();
        out.writeInt(locations == null ? 0 : locations.length);
        if (locations != null)
          for (int i = 0; i < locations.length; i++) {
            out.writeUTF(locations[i]);
            String[] perms = permissionStorage.getPermissionData(locations[i]);
            out.writeInt(perms == null ? 0 : perms.length);
            if (perms != null)
              for (int j = 0; j < perms.length; j++)
                out.writeUTF(perms[j]);
          }
        String[] condPerms = permissionStorage.getConditionalPermissionInfos();
        out.writeInt(condPerms == null ? 0 : condPerms.length);
        if (condPerms != null)
          for (int i = 0; i < condPerms.length; i++)
            out.writeUTF(condPerms[i]);
        out.close();
        permissionStorage.setDirty(false);
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here


    if (stateManager == null || isReadOnly() || (timeStamp == stateManager.getSystemState().getTimeStamp() && !stateManager.saveNeeded()))
      return;
    if (Debug.DEBUG && Debug.DEBUG_GENERAL)
      Debug.println("Saving bundle data ..."); //$NON-NLS-1$
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(LocationManager.BUNDLE_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(BUNDLEDATA_VERSION);
        out.writeLong(stateManager.getSystemState().getTimeStamp());
        out.writeInt(initialBundleStartLevel);
        out.writeLong(nextId);

        StorageHook[] storageHooks = adaptor.getHookRegistry().getStorageHooks();
        out.writeInt(storageHooks.length);
        for (int i = 0; i < storageHooks.length; i++) {
          out.writeUTF((String) storageHooks[i].getKey());
          out.writeInt(storageHooks[i].getStorageVersion());
        }

        Bundle[] bundles = context.getBundles();
        out.writeInt(bundles.length);
        for (int i = 0; i < bundles.length; i++) {
          long id = bundles[i].getBundleId();
          out.writeLong(id);
          if (id != 0) {
            BundleData data = ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundles[i]).getBundleData();
            saveBaseData((BaseData) data, out);
          }
        }
        out.close();
        // update the 'timeStamp' after the changed Meta data is saved.
        timeStamp = stateManager.getSystemState().getTimeStamp();
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here

    if (permissionStorage == null || isReadOnly() || !permissionStorage.isDirty())
      return;
    if (Debug.DEBUG_GENERAL)
      Debug.println("About to save permission data ..."); //$NON-NLS-1$
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(PERM_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(PERMDATA_VERSION);
        // always write the default permissions first
        String[] defaultPerms = permissionStorage.getPermissionData(null);
        out.writeInt(defaultPerms == null ? 0 : defaultPerms.length);
        if (defaultPerms != null)
          for (int i = 0; i < defaultPerms.length; i++)
            out.writeUTF(defaultPerms[i]);
        String[] locations = permissionStorage.getLocations();
        out.writeInt(locations == null ? 0 : locations.length);
        if (locations != null)
          for (int i = 0; i < locations.length; i++) {
            out.writeUTF(locations[i]);
            String[] perms = permissionStorage.getPermissionData(locations[i]);
            out.writeInt(perms == null ? 0 : perms.length);
            if (perms != null)
              for (int j = 0; j < perms.length; j++)
                out.writeUTF(perms[j]);
          }
        String[] condPerms = permissionStorage.getConditionalPermissionInfos();
        out.writeInt(condPerms == null ? 0 : condPerms.length);
        if (condPerms != null)
          for (int i = 0; i < condPerms.length; i++)
            out.writeUTF(condPerms[i]);
        out.close();
        permissionStorage.setDirty(false);
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here

    if (stateManager == null || isReadOnly() || (timeStamp == stateManager.getSystemState().getTimeStamp() && !stateManager.saveNeeded()))
      return;
    if (Debug.DEBUG_GENERAL)
      Debug.println("Saving bundle data ..."); //$NON-NLS-1$
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(LocationManager.BUNDLE_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(BUNDLEDATA_VERSION);
        out.writeLong(stateManager.getSystemState().getTimeStamp());
        out.writeInt(initialBundleStartLevel);
        out.writeLong(nextId);

        StorageHook[] hooks = adaptor.getHookRegistry().getStorageHooks();
        out.writeInt(hooks.length);
        for (int i = 0; i < hooks.length; i++) {
          out.writeUTF((String) hooks[i].getKey());
          out.writeInt(hooks[i].getStorageVersion());
        }

        Bundle[] bundles = context.getBundles();
        out.writeInt(bundles.length);
        for (int i = 0; i < bundles.length; i++) {
          long id = bundles[i].getBundleId();
          out.writeLong(id);
          if (id != 0) {
            BundleData data = ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundles[i]).getBundleData();
            saveBaseData((BaseData) data, out);
          }
        }
        out.close();
        // update the 'timeStamp' after the changed Meta data is saved.
        timeStamp = stateManager.getSystemState().getTimeStamp();
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here

  private void savePermissionStorage() {
    if (permissionStorage == null || isReadOnly() || !permissionStorage.isDirty())
      return;
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(PERM_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(PERMDATA_VERSION);
        // always write the default permissions first
        String[] defaultPerms = permissionStorage.getPermissionData(null);
        out.writeInt(defaultPerms == null ? 0 : defaultPerms.length);
        if (defaultPerms != null)
          for (int i = 0; i < defaultPerms.length; i++)
            out.writeUTF(defaultPerms[i]);
        String[] locations = permissionStorage.getLocations();
        out.writeInt(locations == null ? 0 : locations.length);
        if (locations != null)
          for (int i = 0; i < locations.length; i++) {
            out.writeUTF(locations[i]);
            String[] perms = permissionStorage.getPermissionData(locations[i]);
            out.writeInt(perms == null ? 0 : perms.length);
            if (perms != null)
              for (int j = 0; j < perms.length; j++)
                out.writeUTF(perms[j]);
          }
        String[] condPerms = permissionStorage.getConditionalPermissionInfos();
        out.writeInt(condPerms == null ? 0 : condPerms.length);
        if (condPerms != null)
          for (int i = 0; i < condPerms.length; i++)
            out.writeUTF(condPerms[i]);
        out.close();
        permissionStorage.setDirty(false);
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here

  private void saveBundleDatas() {
    // the cache and the state match
    if (stateManager == null || isReadOnly() || (timeStamp == stateManager.getSystemState().getTimeStamp() && !stateManager.saveNeeded()))
      return;
    try {
      ManagedOutputStream fmos = storageManager.getOutputStream(LocationManager.BUNDLE_DATA_FILE);
      DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fmos));
      boolean error = true;
      try {
        out.writeByte(BUNDLEDATA_VERSION);
        out.writeLong(stateManager.getSystemState().getTimeStamp());
        out.writeInt(initialBundleStartLevel);
        out.writeLong(nextId);

        StorageHook[] storageHooks = adaptor.getHookRegistry().getStorageHooks();
        out.writeInt(storageHooks.length);
        for (int i = 0; i < storageHooks.length; i++) {
          out.writeUTF((String) storageHooks[i].getKey());
          out.writeInt(storageHooks[i].getStorageVersion());
        }

        Bundle[] bundles = context.getBundles();
        out.writeInt(bundles.length);
        for (int i = 0; i < bundles.length; i++) {
          long id = bundles[i].getBundleId();
          out.writeLong(id);
          if (id != 0) {
            BundleData data = ((org.eclipse.osgi.framework.internal.core.AbstractBundle) bundles[i]).getBundleData();
            saveBaseData((BaseData) data, out);
          }
        }
        out.close();
        // update the 'timeStamp' after the changed Meta data is saved.
        timeStamp = stateManager.getSystemState().getTimeStamp();
        error = false;
      } finally {
        // if something happens, don't close a corrupt file
        if (error) {
          fmos.abort();
          try {
            out.close();
          } catch (IOException e) {/*ignore*/
          }
        }
 
View Full Code Here

TOP

Related Classes of org.eclipse.osgi.storagemanager.ManagedOutputStream

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.