2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.configpusherfeature.internal;
10 import java.util.LinkedHashSet;
11 import java.util.List;
14 import javax.xml.bind.JAXBException;
16 import org.apache.karaf.features.BundleInfo;
17 import org.apache.karaf.features.Conditional;
18 import org.apache.karaf.features.ConfigFileInfo;
19 import org.apache.karaf.features.Dependency;
20 import org.apache.karaf.features.Feature;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 import com.google.common.base.Preconditions;
27 * Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
28 * its underlying ConfigFileInfo's
30 * Delegates the the contained feature and provides additional methods.
32 public class AbstractFeatureWrapper implements Feature {
33 private static final Logger LOGGER = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
34 protected Feature feature = null;
36 protected AbstractFeatureWrapper() {
37 // prevent instantiation without Feature
41 * @param f Feature to wrap
43 public AbstractFeatureWrapper(Feature f) {
44 Preconditions.checkNotNull(f,"FeatureWrapper requires non-null Feature in constructor");
49 * Get FeatureConfigSnapshotHolders appropriate to feed to the config subsystem
50 * from the underlying Feature Config files
52 public LinkedHashSet<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolders() throws Exception {
53 LinkedHashSet <FeatureConfigSnapshotHolder> snapShotHolders = new LinkedHashSet<FeatureConfigSnapshotHolder>();
54 for(ConfigFileInfo c: getConfigurationFiles()) {
56 snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this));
57 } catch (JAXBException e) {
58 LOGGER.debug("{} is not a config subsystem config file",c.getFinalname());
61 return snapShotHolders;
65 public int hashCode() {
68 result = prime * result + ((feature == null) ? 0 : feature.hashCode());
73 public boolean equals(Object obj) {
80 if (getClass() != obj.getClass()) {
83 AbstractFeatureWrapper other = (AbstractFeatureWrapper) obj;
84 if (feature == null) {
85 if (other.feature != null) {
88 } else if (!feature.equals(other.feature)) {
95 public String toString() {
96 return feature.getName();
101 * @see org.apache.karaf.features.Feature#getId()
103 public String getId() {
104 return feature.getId();
109 * @see org.apache.karaf.features.Feature#getName()
111 public String getName() {
112 return feature.getName();
117 * @see org.apache.karaf.features.Feature#getDescription()
119 public String getDescription() {
120 return feature.getDescription();
125 * @see org.apache.karaf.features.Feature#getDetails()
127 public String getDetails() {
128 return feature.getDetails();
133 * @see org.apache.karaf.features.Feature#getVersion()
135 public String getVersion() {
136 return feature.getVersion();
141 * @see org.apache.karaf.features.Feature#hasVersion()
143 public boolean hasVersion() {
144 return feature.hasVersion();
149 * @see org.apache.karaf.features.Feature#getResolver()
151 public String getResolver() {
152 return feature.getResolver();
157 * @see org.apache.karaf.features.Feature#getInstall()
159 public String getInstall() {
160 return feature.getInstall();
165 * @see org.apache.karaf.features.Feature#getDependencies()
167 public List<Dependency> getDependencies() {
168 return feature.getDependencies();
173 * @see org.apache.karaf.features.Feature#getBundles()
175 public List<BundleInfo> getBundles() {
176 return feature.getBundles();
181 * @see org.apache.karaf.features.Feature#getConfigurations()
183 public Map<String, Map<String, String>> getConfigurations() {
184 return feature.getConfigurations();
189 * @see org.apache.karaf.features.Feature#getConfigurationFiles()
191 public List<ConfigFileInfo> getConfigurationFiles() {
192 return feature.getConfigurationFiles();
197 * @see org.apache.karaf.features.Feature#getConditional()
199 public List<? extends Conditional> getConditional() {
200 return feature.getConditional();
205 * @see org.apache.karaf.features.Feature#getStartLevel()
207 public int getStartLevel() {
208 return feature.getStartLevel();
213 * @see org.apache.karaf.features.Feature#getRegion()
215 public String getRegion() {
216 return feature.getRegion();