Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.osgi.framework.internal;
 
 import java.util.List;
 
Represents the ACTIVE state of the system bundle.

Author(s):
thomas.diesler@jboss.com
Since:
04-Apr-2011
 
 public final class SystemBundleService extends AbstractBundleService<SystemBundleState> {
 
     // Provide logging
     static final Logger log = Logger.getLogger(SystemBundleService.class);
 
     private SystemBundleState bundleState;
 
     static void addService(ServiceTarget serviceTargetFrameworkState frameworkState) {
         SystemBundleService service = new SystemBundleService(frameworkState);
         ServiceBuilder<SystemBundleStatebuilder = serviceTarget.addService(.service);
         builder.addDependency(.FrameworkModuleProvider.classservice.injectedModuleProvider);
         builder.addDependency(.SystemPathsProvider.classservice.injectedSystemPaths);
         builder.addDependency(.BundleStoragePlugin.classservice.injectedBundleStorage);
         builder.addDependency(.ResolverPlugin.classservice.injectedResolverPlugin);
         builder.setInitialMode(.);
         builder.install();
     }
 
     private SystemBundleService(FrameworkState frameworkState) {
         super(frameworkState);
     }
 
     @Override
     public void start(StartContext contextthrows StartException {
         super.start(context);
         try {
              = createBundleState();
             .changeState(.);
             OSGiMetaData metadata = createOSGiMetaData();
             XModule resModule = .createResolverModule(metadata);
             .createBundleRevision(metadataresModule);
             .createBundleContext();
             .getValue().addModule(resModule);
             BundleManager bundleManager = getBundleManager();
             bundleManager.injectedSystemBundle.inject();
             bundleManager.addBundle();
         } catch (BundleException ex) {
             throw new StartException(ex);
         }
     }
 
     }
    @Override
        return ;
    }
    @Override
    public void stop(StopContext context) {
        super.stop(context);
        BundleManager bundleManager = getBundleManager();
        bundleManager.injectedSystemBundle.uninject();
    }
    private OSGiMetaData createOSGiMetaData() {
        // Initialize the OSGiMetaData
        SystemBundleState bundleState = getBundleState();
        OSGiMetaDataBuilder builder = OSGiMetaDataBuilder.createBuilder(bundleState.getSymbolicName(), bundleState.getVersion());
        SystemPathsProvider systemPackages = .getValue();
        List<StringexportedPackages = new ArrayList<String>();
        exportedPackages.addAll(systemPackages.getSystemPackages());
        if (exportedPackages.isEmpty() == true)
            throw new IllegalStateException("Framework system packages not available");
        // Construct framework capabilities from system packages
        for (String packageSpec : exportedPackages) {
            String packname = packageSpec;
            Version version = .;
            int versionIndex = packname.indexOf(";version=");
            if (versionIndex > 0) {
                packname = packageSpec.substring(0, versionIndex);
                version = Version.parseVersion(packageSpec.substring(versionIndex + 9));
            }
            builder.addExportPackages(packname + ";version=" + version);
        }
        return builder.getOSGiMetaData();
    }
New to GrepCode? Check out our FAQ X