Package: KernelConfigurationPropertiesSource

KernelConfigurationPropertiesSource

nameinstructionbranchcomplexitylinemethod
KernelConfigurationPropertiesSource(KernelConfiguration)
M: 12 C: 9
43%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createProperties()
M: 6 C: 37
86%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
getConfigurationProperties()
M: 6 C: 5
45%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
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: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.nano.config.internal;
13:
14: import java.util.Collections;
15: import java.util.Map;
16: import java.util.Properties;
17:
18: /**
19: * Implementation of {@link PropertiesSource} that exposes the {@link KernelConfiguration} as {@link Properties}.
20: * <p />
21: * Ideally the properties exposed from instances of this object should not be overridden by properties from another
22: * source.
23: * <p/>
24: * <strong>Concurrent Semantics</strong><br />
25: *
26: * Threadsafe.
27: *
28: */
29: final class KernelConfigurationPropertiesSource implements PropertiesSource {
30:
31: static final String PROPERTY_WORK_DIRECTORY = "work.directory";
32:
33: static final String PROPERTY_HOME_DIRECTORY = "home.directory";
34:
35: static final String PROPERTY_DOMAIN = "domain";
36:
37: static final String KERNEL_CONFIGURATION_PID = "org.eclipse.virgo.kernel";
38:
39: static final String PROPERTY_KERNEL_STARTUP_WAIT_LIMIT = "org.eclipse.virgo.kernel.startup.wait.limit";
40:
41: private final KernelConfiguration kernelConfiguration;
42:
43: public KernelConfigurationPropertiesSource(KernelConfiguration kernelConfiguration) {
44: this.kernelConfiguration = kernelConfiguration;
45: }
46:
47: /**
48: * {@inheritDoc}
49: */
50: public Map<String, Properties> getConfigurationProperties() {
51: return Collections.singletonMap(KERNEL_CONFIGURATION_PID, createProperties());
52: }
53:
54: private Properties createProperties() {
55: Properties properties = new Properties();
56: properties.put(PROPERTY_DOMAIN, this.kernelConfiguration.getDomain());
57: properties.put(PROPERTY_HOME_DIRECTORY, this.kernelConfiguration.getHomeDirectory().getAbsolutePath());
58: properties.put(PROPERTY_WORK_DIRECTORY, this.kernelConfiguration.getWorkDirectory().getAbsolutePath());
59: properties.put(PROPERTY_KERNEL_STARTUP_WAIT_LIMIT, Integer.toString(this.kernelConfiguration.getStartupWaitLimit()));
60: return properties;
61: }
62:
63: }