You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2015/04/07 16:55:15 UTC
svn commit: r1671863 - in /sling/trunk/bundles/commons/logservice: pom.xml
src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Author: cziegeler
Date: Tue Apr 7 14:55:15 2015
New Revision: 1671863
URL: http://svn.apache.org/r1671863
Log:
SLING-4563 : Log start level number on STARTLEVEL CHANGED event
Modified:
sling/trunk/bundles/commons/logservice/pom.xml
sling/trunk/bundles/commons/logservice/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Modified: sling/trunk/bundles/commons/logservice/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice/pom.xml?rev=1671863&r1=1671862&r2=1671863&view=diff
==============================================================================
--- sling/trunk/bundles/commons/logservice/pom.xml (original)
+++ sling/trunk/bundles/commons/logservice/pom.xml Tue Apr 7 14:55:15 2015
@@ -98,7 +98,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>4.0.0</version>
+ <version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
Modified: sling/trunk/bundles/commons/logservice/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java?rev=1671863&r1=1671862&r2=1671863&view=diff
==============================================================================
--- sling/trunk/bundles/commons/logservice/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java (original)
+++ sling/trunk/bundles/commons/logservice/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java Tue Apr 7 14:55:15 2015
@@ -38,6 +38,7 @@ import org.osgi.service.component.Compon
import org.osgi.service.log.LogEntry;
import org.osgi.service.log.LogListener;
import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -347,7 +348,12 @@ public class LogSupport implements Synch
message = "FrameworkEvent PACKAGES REFRESHED";
break;
case FrameworkEvent.STARTLEVEL_CHANGED:
- message = "FrameworkEvent STARTLEVEL CHANGED";
+ // bundle must be the system bundle
+ final Bundle bundle = event.getBundle();
+ // StartLevel service is always there
+ final ServiceReference slRef = bundle.getBundleContext().getServiceReference(StartLevel.class.getName());
+ final StartLevel sl = (StartLevel) bundle.getBundleContext().getService(slRef);
+ message = "FrameworkEvent STARTLEVEL CHANGED to " + sl.getStartLevel();
break;
case FrameworkEvent.WARNING:
message = "FrameworkEvent WARNING";
@@ -359,7 +365,7 @@ public class LogSupport implements Synch
message = "FrameworkEvent " + event.getType();
}
- LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
+ final LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
message, exception);
fireLogEvent(entry);
}
Re: svn commit: r1671863 - in /sling/trunk/bundles/commons/logservice:
pom.xml src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Posted by Carsten Ziegeler <cz...@apache.org>.
Am 09.04.15 um 07:13 schrieb Chetan Mehrotra:
> On Wed, Apr 8, 2015 at 2:19 PM, Carsten Ziegeler <cz...@apache.org>
> wrote:
>
>> We could think about getting the start level service outside of the
>> event handling and releasing it there.
>>
>
> Yup that would be cleaner and might be performant also!
>
I changed the code accordingly.
Carsten
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org
Re: svn commit: r1671863 - in /sling/trunk/bundles/commons/logservice:
pom.xml src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Posted by Chetan Mehrotra <ch...@gmail.com>.
On Wed, Apr 8, 2015 at 2:19 PM, Carsten Ziegeler <cz...@apache.org>
wrote:
> We could think about getting the start level service outside of the
> event handling and releasing it there.
>
Yup that would be cleaner and might be performant also!
Chetan Mehrotra
Re: svn commit: r1671863 - in /sling/trunk/bundles/commons/logservice:
pom.xml src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Posted by Carsten Ziegeler <cz...@apache.org>.
Am 08.04.15 um 10:24 schrieb Chetan Mehrotra:
> On Tue, Apr 7, 2015 at 8:25 PM, <cz...@apache.org> wrote:
>
>> + final ServiceReference slRef =
>> bundle.getBundleContext().getServiceReference(StartLevel.class.getName());
>> + final StartLevel sl = (StartLevel)
>> bundle.getBundleContext().getService(slRef);
>> + message = "FrameworkEvent STARTLEVEL CHANGED to " +
>> sl.getStartLevel();
>>
>
>
> Just for completeness should not we unget the service also.
>
If the bundle is stopped, the service is unget by the framework
nevertheless.
We could think about getting the start level service outside of the
event handling and releasing it there.
I'll see if I can make the code look nicer
Carsten
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org
Re: svn commit: r1671863 - in /sling/trunk/bundles/commons/logservice:
pom.xml src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
Posted by Chetan Mehrotra <ch...@gmail.com>.
On Tue, Apr 7, 2015 at 8:25 PM, <cz...@apache.org> wrote:
> + final ServiceReference slRef =
> bundle.getBundleContext().getServiceReference(StartLevel.class.getName());
> + final StartLevel sl = (StartLevel)
> bundle.getBundleContext().getService(slRef);
> + message = "FrameworkEvent STARTLEVEL CHANGED to " +
> sl.getStartLevel();
>
Just for completeness should not we unget the service also.
Chetan Mehrotra