[ 
https://issues.apache.org/jira/browse/FELIX-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806491#action_12806491
 ] 

Joel Schuster commented on FELIX-2021:
--------------------------------------

This patch will enable File Install to set the bundle start level:

_____________________________________________

Index: DirectoryWatcher.java
===================================================================
--- DirectoryWatcher.java       (revision 904607)
+++ DirectoryWatcher.java       (working copy)
@@ -52,8 +52,10 @@
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
 
 /**
  * -DirectoryWatcher-
@@ -88,6 +90,7 @@
     public final static String FILTER = "felix.fileinstall.filter";
     public final static String START_NEW_BUNDLES = 
"felix.fileinstall.bundles.new.start";
     public final static String NO_INITIAL_DELAY = 
"felix.fileinstall.noInitialDelay";
+    public final static String START_LEVEL = "felix.fileinstall.start.level";
 
     static final SecureRandom random = new SecureRandom();
 
@@ -103,6 +106,7 @@
     BundleContext context;
     String originatingFileName;
     boolean noInitialDelay;
+    int startLevel;
 
     // Map of all installed artifacts
     Map/* <File, Artifact> */ currentManagedArtifacts = new HashMap/* <File, 
Artifact> */();
@@ -131,6 +135,8 @@
         startBundles = getBoolean(properties, START_NEW_BUNDLES, true);  // by 
default, we start bundles.
         filter = (String) properties.get(FILTER);
         noInitialDelay = getBoolean(properties, NO_INITIAL_DELAY, false);
+        startLevel = getInt( properties, START_LEVEL, 1);
+        
         this.context.addBundleListener(this);
 
         FilenameFilter flt;
@@ -1087,6 +1093,21 @@
         {
             try
             {
+               ServiceReference ref = context.getServiceReference(
+                        
org.osgi.service.startlevel.StartLevel.class.getName());
+               if (ref != null)
+                {
+                       StartLevel sl = (StartLevel) context.getService(ref);
+                    if (sl != null)
+                    {
+                       sl.setBundleStartLevel( bundle, startLevel);
+                    } else {
+                       log( Logger.LOG_WARNING, "StartLevel service is 
unavailable.", null);
+                    }
+                } else {
+                       log( Logger.LOG_WARNING, "StartLevel service is 
unavailable.", null);
+                }
+                
                 bundle.start();
                 log(Logger.LOG_DEBUG, "Started bundle: " + 
bundle.getLocation(), null);
             }


_________________________________________


> Enable FileInstall to set Bundle Start Level
> --------------------------------------------
>
>                 Key: FELIX-2021
>                 URL: https://issues.apache.org/jira/browse/FELIX-2021
>             Project: Felix
>          Issue Type: Improvement
>          Components: File Install
>    Affects Versions: fileinstall-2.0.4
>         Environment: Felix/OSGi
>            Reporter: Joel Schuster
>            Priority: Minor
>             Fix For: fileinstall-2.0.8
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> The File Install utility bundle would be well suited to setting the bundle 
> start level during install.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to