|
2 | 2 |
|
3 | 3 | import dev.vml.es.acm.core.code.*; |
4 | 4 | import dev.vml.es.acm.core.code.script.ExtensionScriptSyntax; |
5 | | -import dev.vml.es.acm.core.osgi.*; |
| 5 | +import dev.vml.es.acm.core.osgi.InstanceInfo; |
| 6 | +import dev.vml.es.acm.core.osgi.InstanceType; |
| 7 | +import dev.vml.es.acm.core.osgi.OsgiEvent; |
| 8 | +import dev.vml.es.acm.core.osgi.OsgiEventCollector; |
| 9 | +import dev.vml.es.acm.core.osgi.OsgiScanner; |
| 10 | +import dev.vml.es.acm.core.osgi.OsgiUtils; |
6 | 11 | import dev.vml.es.acm.core.repo.Repo; |
7 | 12 | import dev.vml.es.acm.core.util.ExceptionUtils; |
8 | 13 | import dev.vml.es.acm.core.util.ResolverUtils; |
@@ -162,25 +167,44 @@ private void checkRepository(HealthStatus result, ResourceResolver resourceResol |
162 | 167 | } |
163 | 168 | } |
164 | 169 |
|
| 170 | + /** |
| 171 | + * @see <https://github.com/apache/felix-dev/blob/master/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java> 'checkValidity()' method |
| 172 | + */ |
165 | 173 | private void checkBundles(HealthStatus result) { |
166 | 174 | if (!config.bundleChecking()) { |
167 | 175 | return; |
168 | 176 | } |
| 177 | + |
| 178 | + try { |
| 179 | + osgiScanner.getBundleContext().getBundle(); |
| 180 | + } catch (Exception e) { |
| 181 | + result.issues.add(new HealthIssue( |
| 182 | + HealthIssueSeverity.CRITICAL, |
| 183 | + HealthIssueCategory.OSGI, |
| 184 | + "Bundle context not valid", |
| 185 | + ExceptionUtils.toString(e))); |
| 186 | + return; |
| 187 | + } |
| 188 | + |
169 | 189 | osgiScanner.scanBundles().filter(b -> !isBundleIgnored(b)).forEach(bundle -> { |
170 | 190 | if (osgiScanner.isFragment(bundle)) { |
171 | 191 | if (!osgiScanner.isBundleResolved(bundle)) { |
172 | 192 | result.issues.add(new HealthIssue( |
173 | 193 | HealthIssueSeverity.CRITICAL, |
174 | 194 | HealthIssueCategory.OSGI, |
175 | | - String.format("Bundle fragment not resolved: '%s'", bundle.getSymbolicName()), |
| 195 | + String.format( |
| 196 | + "Bundle fragment not resolved (%s): '%s'", |
| 197 | + OsgiUtils.bundleStateName(bundle.getState()), bundle.getSymbolicName()), |
176 | 198 | null)); |
177 | 199 | } |
178 | 200 | } else { |
179 | 201 | if (!osgiScanner.isBundleActive(bundle)) { |
180 | 202 | result.issues.add(new HealthIssue( |
181 | 203 | HealthIssueSeverity.CRITICAL, |
182 | 204 | HealthIssueCategory.OSGI, |
183 | | - String.format("Bundle not active: '%s'", bundle.getSymbolicName()), |
| 205 | + String.format( |
| 206 | + "Bundle not active (%s): '%s'", |
| 207 | + OsgiUtils.bundleStateName(bundle.getState()), bundle.getSymbolicName()), |
184 | 208 | null)); |
185 | 209 | } |
186 | 210 | } |
|
0 commit comments