Package org.osgi.service.prefs

Examples of org.osgi.service.prefs.Preferences


        return sl;
    }

    public Component registerComponent(Bundle bundle, ComponentDesc componentDesc, javax.jbi.component.Component innerComponent, SharedLibrary[] sharedLibraries) throws Exception {
        String name = componentDesc.getIdentification().getName();
        Preferences prefs = preferencesService.getUserPreferences(name);
        ComponentImpl component = new ComponentImpl(bundle, componentDesc, innerComponent, prefs, autoStart, sharedLibraries);
        component.setListenerRegistry(listenerRegistry);
        // populate props from the component meta-data
        Dictionary<String, String> props = new Hashtable<String, String>();
        props.put(NAME, name);
View Full Code Here


        return component;
    }

    public ServiceAssembly registerServiceAssembly(Bundle bundle, ServiceAssemblyDesc serviceAssemblyDesc, List<ServiceUnitImpl> sus) throws Exception {
        // Now create the SA and initialize it
        Preferences prefs = preferencesService.getUserPreferences(serviceAssemblyDesc.getIdentification().getName());
        ServiceAssemblyImpl sa = new ServiceAssemblyImpl(bundle, serviceAssemblyDesc, sus, prefs, endpointListener, autoStart);
        sa.setShutdownTimeout(shutdownTimeout);
        sa.setListenerRegistry(listenerRegistry);
        sa.init();
        serviceAssemblies.put(sa.getName(), sa);
View Full Code Here

    }

    public abstract String getName();

    public void init() throws Exception {
        Preferences prefs = getPreferences();
        long lastInstall = prefs.getLong(LAST_INSTALL, 0);
        isFirstInstall = lastInstall == 0;
        isModified = lastInstall == 0 || getBundle().getLastModified() > lastInstall;
        if (isModified && installRoot != null) {
            extractBundle(installRoot, getBundle(), "/");
            lastInstall = getBundle().getLastModified();
            prefs.put(AbstractLifecycleJbiArtifact.STATE, isAutoStart()
                            ? AbstractLifecycleJbiArtifact.State.Started.name()
                            : AbstractLifecycleJbiArtifact.State.Shutdown.name());
        }
    }
View Full Code Here

                            : AbstractLifecycleJbiArtifact.State.Shutdown.name());
        }
    }

    protected void postInstall() throws Exception {
        Preferences prefs = getPreferences();
        prefs.putLong(LAST_INSTALL, getBundle().getLastModified());
        prefs.flush();
    }
View Full Code Here

    protected Preferences getPreferences() {
        return deployer.getPreferencesService().getUserPreferences(getName());
    }

    protected void deletePreferences() throws BackingStoreException {
        Preferences prefs = getPreferences();
        prefs.clear();
        prefs.flush();
    }
View Full Code Here

        // Few components actually use this, but Ode is one of them
        File installRoot = new File(System.getProperty("servicemix.base"), "data/jbi/" + name + "/install");
        installRoot.mkdirs();
        extractBundle(installRoot, bundle, "/");
        // Instanciate component
        Preferences prefs = preferencesService.getUserPreferences(name);
        Class clazz = classLoader.loadClass(componentDesc.getComponentClassName());
        javax.jbi.component.Component innerComponent = (javax.jbi.component.Component) clazz.newInstance();
        ComponentImpl component = new ComponentImpl(componentDesc, innerComponent, prefs, autoStart, this);
        components.put(name, component);
        // populate props from the component meta-data
View Full Code Here

                }
            }
            return;
        }
        // Now create the SA and initialize it
        Preferences prefs = preferencesService.getUserPreferences(serviceAssembyDesc.getIdentification().getName());
        ServiceAssemblyImpl sa = new ServiceAssemblyImpl(serviceAssembyDesc, sus, prefs, autoStart);
        sa.init();
        serviceAssemblies.put(sa.getName(), sa);
        // populate props from the component meta-data
        Dictionary<String, String> props = new Hashtable<String, String>();
View Full Code Here

    protected void maybeWrapComponent(ServiceReference reference, javax.jbi.component.Component component) {
        String name = (String) reference.getProperty(NAME);
        if (name != null && !components.containsKey(name)) {
            String type = (String) reference.getProperty(TYPE);
            Preferences prefs = preferencesService.getUserPreferences(name);
            ComponentDesc componentDesc = new ComponentDesc();
            componentDesc.setIdentification(new Identification());
            componentDesc.getIdentification().setName(name);
            componentDesc.setType(type);
            ComponentImpl wrapper = new ComponentImpl(componentDesc, component, prefs, autoStart, this);
View Full Code Here

              return Status.OK_STATUS;
            try {
              // save the preferences nodes
              if (next.isAccessible()) {
                // save content type preferences
                Preferences projectPrefs = JSPFContentProperties.getPreferences(next, JSPFContentProperties.JSPCONTENTTYPE, false);
                if (projectPrefs != null)
                  projectPrefs.flush();
                // save language preferences
                projectPrefs = JSPFContentProperties.getPreferences(next, JSPFContentProperties.JSPLANGUAGE, false);
                if (projectPrefs != null)
                  projectPrefs.flush();

              }
            }
            catch (BackingStoreException e) {
              // we got an error saving
View Full Code Here

     */
    private boolean processPreferences(IProject currentProject, String key, IResourceDelta projectDelta, Set projectsToSave) {
      boolean resourceChanges = false;

      // get the project-key preference node
      Preferences projectPrefs = JSPFContentProperties.getPreferences(currentProject, key, false);
      if (projectPrefs == null)
        // no preferences for this project-key, just bail
        return false;
      String[] affectedResources;
      try {
        affectedResources = projectPrefs.keys();
      }
      catch (BackingStoreException e) {
        // problems with the project scope... we gonna miss the
        // changes (but will log)
        Logger.log(Logger.WARNING_DEBUG, "Problem retreiving JSP Fragment preferences", e); //$NON-NLS-1$
        return false;
      }

      // go through each preference key (which is really a file name)
      for (int i = 0; i < affectedResources.length; i++) {
        // see if preference key/file name was file that was changed
        IResourceDelta memberDelta = projectDelta.findMember(new Path(affectedResources[i]));
        // no changes for the given resource
        if (memberDelta == null)
          continue;
        if (memberDelta.getKind() == IResourceDelta.REMOVED) {
          resourceChanges = true;
          // remove the setting for the original location
          String currentValue = projectPrefs.get(affectedResources[i], null);
          projectPrefs.remove(affectedResources[i]);
          if ((memberDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
            // if moving, copy the setting for the new location
            IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(memberDelta.getMovedToPath().segment(0));
            Preferences targetPrefs = JSPFContentProperties.getPreferences(targetProject, key, true);
            targetPrefs.put(JSPFContentProperties.getKeyFor(memberDelta.getMovedToPath()), currentValue);
            if (targetProject != currentProject)
              projectsToSave.add(targetProject);
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.osgi.service.prefs.Preferences

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.