Package org.apache.felix.framework.util

Examples of org.apache.felix.framework.util.StringMap


        activations.add(main);
       
        try
        {
            // Start up the OSGI framework
            m_felix = new Felix(new StringMap(m_configProps, false), activations);
            m_felix.start();
        }
        catch (Exception ex)
        {
            System.err.println("Could not create framework: " + ex);
View Full Code Here


        {
            return;
        }

        // Setup OSGi configuration propery map
        StringMap configMap = new StringMap(false);

        // Add the bundle provided service interface package and the core OSGi
        // packages to be exported from the class path via the system bundle.
        configMap.put(FRAMEWORK_SYSTEMPACKAGES,
                "org.osgi.framework; version=1.3.0," +
                "org.osgi.service.packageadmin; version=1.2.0," +
                "org.osgi.service.startlevel; version=1.0.0," +
                "org.osgi.service.url; version=1.0.0," +
                "org.osgi.util.tracker; version=1.0.0," +
                "org.apache.qpid.junit.extensions.util; " + QPID_VER_SUFFIX +
                "org.apache.qpid; " + QPID_VER_SUFFIX +
                "org.apache.qpid.common; " + QPID_VER_SUFFIX +
                "org.apache.qpid.exchange; " + QPID_VER_SUFFIX +
                "org.apache.qpid.framing; " + QPID_VER_SUFFIX +
                "org.apache.qpid.management.common.mbeans.annotations; " + QPID_VER_SUFFIX +
                "org.apache.qpid.protocol; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.binding; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.configuration; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.configuration.plugins; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.configuration.management; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.exchange; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.logging; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.logging.actors; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.logging.subjects; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.management; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.persistent; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.plugins; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.protocol; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.queue; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.registry; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.security; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.security.access; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.security.access.plugins; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.virtualhost; " + QPID_VER_SUFFIX +
                "org.apache.qpid.server.virtualhost.plugins; " + QPID_VER_SUFFIX +
                "org.apache.qpid.util; " + QPID_VER_SUFFIX +
                "org.apache.commons.configuration; version=1.0.0," +
                "org.apache.commons.lang; version=1.0.0," +
                "org.apache.commons.lang.builder; version=1.0.0," +
                "org.apache.commons.logging; version=1.0.0," +
                "org.apache.log4j; version=1.2.12," +
                "javax.management.openmbean; version=1.0.0," +
                "javax.management; version=1.0.0"
            );
       
        // No automatic shutdown hook
        configMap.put("felix.shutdown.hook", "false");
       
        // Add system activator
        List<BundleActivator> activators = new ArrayList<BundleActivator>();
        _activator = new Activator();
        activators.add(_activator);
        configMap.put(SYSTEMBUNDLE_ACTIVATORS_PROP, activators);

        if (cachePath != null)
        {
            File cacheDir = new File(cachePath);
            if (!cacheDir.exists() && cacheDir.canWrite())
            {
                _logger.info("Creating plugin cache directory: " + cachePath);
                cacheDir.mkdir();
            }
           
            // Set plugin cache directory and empty it
            _logger.info("Cache bundles in directory " + cachePath);
            configMap.put(FRAMEWORK_STORAGE, cachePath);
        }
        configMap.put(FRAMEWORK_STORAGE_CLEAN, FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
       
        // Set directory with plugins to auto-deploy
        _logger.info("Auto deploying bundles from directory " + pluginPath);
        configMap.put(AUTO_DEPLOY_DIR_PROPERY, pluginPath);
        configMap.put(AUTO_DEPLOY_ACTION_PROPERY, AUTO_DEPLOY_INSTALL_VALUE + "," + AUTO_DEPLOY_START_VALUE);       
       
        // Start plugin manager and trackers
        _felix = new Felix(configMap);
        try
        {
View Full Code Here

      // Must put the URL handler first because it is used during
      // the auto-update process.
      activators.add(new EPURLHandlerActivator());
      activators.add(new EclipseProjectURLAutoUpdater());

      StringMap stringMap = new StringMap(configProperties, false);
      stringMap.put("felix.systembundle.activators", activators);

      framework = (Felix)frameworkFactory.newFramework(stringMap);
      framework.init();
      AutoProcessor.process(stringMap, framework.getBundleContext());
      framework.start();
View Full Code Here

      // Must put the URL handler first because it is used during
      // the auto-update process.
      activators.add(new EPURLHandlerActivator());
      activators.add(new EclipseProjectURLAutoUpdater());

      StringMap stringMap = new StringMap(configProperties);
      stringMap.put("felix.systembundle.activators", activators);

      framework = (Felix)frameworkFactory.newFramework(stringMap);
      framework.init();
      AutoProcessor.process(stringMap, framework.getBundleContext());
      framework.start();
View Full Code Here

    }

    private void initializeProperties(Dictionary dict)
    {
        // Create a case-insensitive map for the properties.
        Map props = new StringMap();

        if (dict != null)
        {
            // Make sure there are no duplicate keys.
            Enumeration keys = dict.keys();
            while (keys.hasMoreElements())
            {
                Object key = keys.nextElement();
                if (props.get(key) == null)
                {
                    props.put(key, dict.get(key));
                }
                else
                {
                    throw new IllegalArgumentException("Duplicate service property: " + key);
                }
            }
        }

        // Add the framework assigned properties.
        props.put(Constants.OBJECTCLASS, m_classes);
        props.put(Constants.SERVICE_ID, m_serviceId);

        // Update the service property map.
        m_propMap = props;
    }
View Full Code Here

        Map result = null;

        // Spec says empty local returns raw headers.
        if (locale.length() == 0)
        {
            result = new StringMap(adapt(BundleRevisionImpl.class).getHeaders());
        }

        // If we have no result, try to get it from the cached headers.
        if (result == null)
        {
            synchronized (m_cachedHeaders)
            {
                // If the bundle is uninstalled, then we should always return
                // the uninstalled headers, which are the default locale as per
                // the spec.
                if (m_uninstalledHeaders != null)
                {
                    result = m_uninstalledHeaders;
                }
                // If the bundle has been updated, clear the cached headers.
                else if (getLastModified() > m_cachedHeadersTimestamp)
                {
                    m_cachedHeaders.clear();
                }
                // Otherwise, returned the cached headers if they exist.
                else
                {
                    // Check if headers for this locale have already been resolved
                    if (m_cachedHeaders.containsKey(locale))
                    {
                        result = (Map) m_cachedHeaders.get(locale);
                    }
                }
            }
        }

        // If the requested locale is not cached, then try to create it.
        if (result == null)
        {
            // Get a modifiable copy of the raw headers.
            Map headers = new StringMap(adapt(BundleRevisionImpl.class).getHeaders());
            // Assume for now that this will be the result.
            result = headers;

            // Check to see if we actually need to localize anything
            boolean localize = false;
            for (Iterator it = headers.values().iterator(); !localize && it.hasNext(); )
            {
                if (((String) it.next()).startsWith("%"))
                {
                    localize = true;
                }
            }

            if (!localize)
            {
                // If localization is not needed, just cache the headers and return
                // them as-is. Not sure if this is useful
                updateHeaderCache(locale, headers);
            }
            else
            {
                // Do localization here and return the localized headers
                String basename = (String) headers.get(Constants.BUNDLE_LOCALIZATION);
                if (basename == null)
                {
                    basename = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
                }

                // Create ordered list of revisions to search for localization
                // property resources.
                List<BundleRevision> revisionList = createLocalizationRevisionList(
                    adapt(BundleRevisionImpl.class));

                // Create ordered list of files to load properties from
                List<String> resourceList = createLocalizationResourceList(basename, locale);

                // Create a merged props file with all available props for this locale
                boolean found = false;
                Properties mergedProperties = new Properties();
                for (BundleRevision br : revisionList)
                {
                    for (String res : resourceList)
                    {
                        URL temp = ((BundleRevisionImpl) br).getEntry(res + ".properties");
                        if (temp != null)
                        {
                            found = true;
                            try
                            {
                                mergedProperties.load(
                                    temp.openConnection().getInputStream());
                            }
                            catch (IOException ex)
                            {
                                // File doesn't exist, just continue loop
                            }
                        }
                    }
                }

                // If the specified locale was not found, then the spec says we should
                // return the default localization.
                if (!found && !locale.equals(Locale.getDefault().toString()))
                {
                    result = getCurrentLocalizedHeader(Locale.getDefault().toString());
                }
                // Otherwise, perform the localization based on the discovered
                // properties and cache the result.
                else
                {
                    // Resolve all localized header entries
                    for (Iterator it = headers.entrySet().iterator(); it.hasNext(); )
                    {
                        Map.Entry entry = (Map.Entry) it.next();
                        String value = (String) entry.getValue();
                        if (value.startsWith("%"))
                        {
View Full Code Here

    **/
    public Felix(Map configMap)
    {
        super();
        // Copy the configuration properties; convert keys to strings.
        m_configMutableMap = new StringMap();
        if (configMap != null)
        {
            for (Iterator i = configMap.entrySet().iterator(); i.hasNext(); )
            {
                Map.Entry entry = (Map.Entry) i.next();
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public void doLaunch() {
    // Create a case-insensitive configuration property map.
    Map configMap = new StringMap(false);
    // Configure the Felix instance to be embedded.
    // configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
    // Add core OSGi packages to be exported from the class path
    // via the system bundle.
    configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
        "org.osgi.framework; version=1.3.0,"
            + "org.osgi.service.packageadmin; version=1.2.0,"
            + "org.osgi.service.startlevel; version=1.0.0,"
            + "org.osgi.service.url; version=1.0.0");

    configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN,
        Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);

    // Explicitly specify the directory to use for caching bundles.
    // configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");

    try {
      // Create host activator;

      List list = new ArrayList();

      // list.add(new HostActivator());
      configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
          "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
      configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
      configMap.put("felix.log.level", "4");

      // Now create an instance of the framework with
      // our configuration properties and activator.
      felix = new Felix(configMap);
      felix.init();
View Full Code Here

    private boolean _empty;
    private Map<String, ACLPluginFactory> _securityPlugins;

    public PluginManager(String plugindir) throws Exception
    {
        StringMap configMap = new StringMap(false);

        // Tell felix it's being embedded
        configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
        // Add the bundle provided service interface package and the core OSGi
        // packages to be exported from the class path via the system bundle.
        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0,"
                + "org.osgi.service.packageadmin; version=1.2.0," +
                "org.osgi.service.startlevel; version=1.0.0," +
                "org.osgi.service.url; version=1.0.0," +
                "org.apache.qpid.framing; version=0.2.1," +
                "org.apache.qpid.server.exchange; version=0.2.1," +
                "org.apache.qpid.server.management; version=0.2.1,"+
                "org.apache.qpid.protocol; version=0.2.1,"+
                "org.apache.qpid.server.virtualhost; version=0.2.1," +
                "org.apache.qpid; version=0.2.1," +
                "org.apache.qpid.server.queue; version=0.2.1," +
                "javax.management.openmbean; version=1.0.0,"+
                "javax.management; version=1.0.0,"+
                "org.apache.qpid.junit.extensions.util; version=0.6.1,"
                );
       
        if (plugindir == null)
        {
          _empty = true;
            return;
        }
       
        // Set the list of bundles to load
        File dir = new File(plugindir);
        if (!dir.exists())
        {
          _empty = true;
            return;
        }
        StringBuffer pluginJars = new StringBuffer();
       
        if (dir.isDirectory())
        {
            for (String child : dir.list())
            {
                if (child.endsWith("jar"))
                {
                    pluginJars.append(String.format(" file:%s%s%s", plugindir,File.separator,child));
                }
            }
        }
        if (pluginJars.length() == 0)
        {
            _empty = true;
            return;
        }
           
        configMap.put(FelixConstants.AUTO_START_PROP + ".1", pluginJars.toString());
        configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, plugindir);
       
        List<BundleActivator> activators = new ArrayList<BundleActivator>();
        _activator = new Activator();
        activators.add(_activator);
View Full Code Here

    private Activator _activator = null;
    private boolean _empty;

    public PluginManager(String plugindir) throws Exception
    {
        StringMap configMap = new StringMap(false);

        // Tell felix it's being embedded
        configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
        // Add the bundle provided service interface package and the core OSGi
        // packages to be exported from the class path via the system bundle.
        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES, "org.osgi.framework; version=1.3.0,"
                + "org.osgi.service.packageadmin; version=1.2.0," +
                "org.osgi.service.startlevel; version=1.0.0," +
                "org.osgi.service.url; version=1.0.0," +
                "org.apache.qpid.framing; version=0.2.1," +
                "org.apache.qpid.server.exchange; version=0.2.1," +
                "org.apache.qpid.server.management; version=0.2.1,"+
                "org.apache.qpid.protocol; version=0.2.1,"+
                "org.apache.qpid.server.virtualhost; version=0.2.1," +
                "org.apache.qpid; version=0.2.1," +
                "org.apache.qpid.server.queue; version=0.2.1," +
                "javax.management.openmbean; version=1.0.0,"+
                "javax.management; version=1.0.0,"+
                "org.apache.qpid.junit.extensions.util; version=0.6.1,"
                );
       
        if (plugindir == null)
        {
          _empty = true;
            return;
        }
       
        // Set the list of bundles to load
        File dir = new File(plugindir);
        if (!dir.exists())
        {
          _empty = true;
            return;
        }
        StringBuffer pluginJars = new StringBuffer();
       
        if (dir.isDirectory())
        {
            for (String child : dir.list())
            {
                if (child.endsWith("jar"))
                {
                    pluginJars.append(String.format(" file:%s%s%s", plugindir,File.separator,child));
                }
            }
        }
        if (pluginJars.length() == 0)
        {
            _empty = true;
            return;
        }
           
        configMap.put(FelixConstants.AUTO_START_PROP + ".1", pluginJars.toString());
        configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, plugindir);
       
        List<BundleActivator> activators = new ArrayList<BundleActivator>();
        _activator = new Activator();
        activators.add(_activator);
View Full Code Here

TOP

Related Classes of org.apache.felix.framework.util.StringMap

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.