GraniteStartLevel.java
4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.osgi.framework.Bundle
* org.osgi.framework.BundleContext
* org.osgi.framework.FrameworkEvent
* org.osgi.framework.FrameworkListener
* org.osgi.framework.ServiceReference
* org.osgi.framework.ServiceRegistration
* org.osgi.service.startlevel.StartLevel
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.granite.startup.impl;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.startlevel.StartLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class GraniteStartLevel
implements StartLevel,
FrameworkListener {
private final Logger log;
private final StartLevel delegatee;
private int oldStartLevel;
static void setup(BundleContext context) {
ServiceReference slr = context.getServiceReference(StartLevel.class.getName());
if (slr == null) {
return;
}
StartLevel delegatee = (StartLevel)context.getService(slr);
if (delegatee == null) {
return;
}
GraniteStartLevel gsl = new GraniteStartLevel(delegatee);
context.registerService(StartLevel.class.getName(), (Object)gsl, (Dictionary)new Hashtable<String, Object>(){});
context.addFrameworkListener((FrameworkListener)gsl);
}
private GraniteStartLevel(StartLevel delegatee) {
this.log = LoggerFactory.getLogger(this.getClass());
this.delegatee = delegatee;
this.oldStartLevel = this.delegatee.getStartLevel();
this.log.info("GraniteStartLevel replacing {}; current start level is {}", (Object)delegatee, (Object)this.oldStartLevel);
}
public int getStartLevel() {
int sl = this.delegatee.getStartLevel();
this.log.info("getStartLevel() -> {}", (Object)sl);
return sl;
}
public void setStartLevel(int startlevel) {
this.log.info("setStartLevel(" + this.delegatee.getStartLevel() + " -> " + startlevel + ")", (Throwable)new Exception());
this.delegatee.setStartLevel(startlevel);
}
public int getBundleStartLevel(Bundle bundle) {
int sl = this.delegatee.getBundleStartLevel(bundle);
this.log.info("getBundleStartLevel() -> {}", (Object)sl);
return sl;
}
public void setBundleStartLevel(Bundle bundle, int startlevel) {
this.log.info("setBundleStartLevel({}, {} -> {})", new Object[]{bundle.getBundleId(), this.delegatee.getBundleStartLevel(bundle), startlevel});
this.delegatee.setBundleStartLevel(bundle, startlevel);
}
public int getInitialBundleStartLevel() {
int sl = this.delegatee.getInitialBundleStartLevel();
this.log.info("getInitialBundleStartLevel() -> {}", (Object)sl);
return sl;
}
public void setInitialBundleStartLevel(int startlevel) {
this.log.info("setInitialBundleStartLevel({} -> {})", new Object[]{this.delegatee.getInitialBundleStartLevel(), startlevel});
this.delegatee.setInitialBundleStartLevel(startlevel);
}
public boolean isBundlePersistentlyStarted(Bundle bundle) {
boolean bps = this.delegatee.isBundlePersistentlyStarted(bundle);
this.log.info("isBundlePersistentlyStarted({}) -> {}", (Object)bundle.getBundleId(), (Object)bps);
return bps;
}
public boolean isBundleActivationPolicyUsed(Bundle bundle) {
boolean bapu = this.delegatee.isBundleActivationPolicyUsed(bundle);
this.log.info("isBundleActivationPolicyUsed({}) -> {}", (Object)bundle.getBundleId(), (Object)bapu);
return bapu;
}
public void frameworkEvent(FrameworkEvent event) {
if (event.getType() == 8) {
int startLevel = this.delegatee.getStartLevel();
this.log.info("Startlevel changed to {} (was {})", (Object)startLevel, (Object)this.oldStartLevel);
this.oldStartLevel = startLevel;
} else if (event.getType() == 1) {
int startLevel = this.delegatee.getStartLevel();
this.log.info("Framework started at {}", (Object)startLevel);
}
}
}