Package: StandardKernelConfig

StandardKernelConfig

nameinstructionbranchcomplexitylinemethod
StandardKernelConfig()
M: 23 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
activate(ComponentContext)
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
deactivate(ComponentContext)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getProperty(String)
M: 55 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 SAP AG
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * SAP AG - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.nano.config.internal;
13:
14: import org.eclipse.virgo.nano.core.KernelConfig;
15: import org.osgi.service.component.ComponentContext;
16: import org.slf4j.Logger;
17: import org.slf4j.LoggerFactory;
18:
19: /**
20: *
21: * This class is the standard implementation for the KernelConfig interface. It enables access to the configurations provided by the kernel core.
22: * <p />
23: *
24: * <strong>Concurrent Semantics</strong><br />
25: * Thread safe.
26: */
27:
28: public class StandardKernelConfig implements KernelConfig {
29:         
30: private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
31:
32: private ComponentContext context;
33:
34: protected void activate(ComponentContext context) {
35: this.context = context;
36: LOGGER.debug("Activating StandardKernelConfig component with properties " + context.getProperties());
37: }
38:
39: protected void deactivate(ComponentContext context) {
40: LOGGER.debug("Deactivating StandardKernelConfig component");
41: this.context = null;
42: }
43:
44: @Override
45: public String getProperty(String name) {
46: Object value = this.context.getProperties().get(name);
47: LOGGER.debug(KernelConfig.class.getSimpleName() + ".getProperty() is called with name [" + name + "] value is [" + value + "]");
48:• if (value instanceof String || value == null) {
49: return (String) value;
50:• } else if (value instanceof String[] && ((String[]) value).length > 0) {
51: return ((String[]) value)[0];
52: } else {
53: return value.toString();
54: }
55: }
56:
57: }