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) {
78 if (getClass() != obj.getClass())
80 AbstractFeatureWrapper other = (AbstractFeatureWrapper) obj;
81 if (feature == null) {
82 if (other.feature != null)
84 } else if (!feature.equals(other.feature))
90 public String toString() {
91 return feature.getName();
96 * @see org.apache.karaf.features.Feature#getId()
98 public String getId() {
99 return feature.getId();
104 * @see org.apache.karaf.features.Feature#getName()
106 public String getName() {
107 return feature.getName();
112 * @see org.apache.karaf.features.Feature#getDescription()
114 public String getDescription() {
115 return feature.getDescription();
120 * @see org.apache.karaf.features.Feature#getDetails()
122 public String getDetails() {
123 return feature.getDetails();
128 * @see org.apache.karaf.features.Feature#getVersion()
130 public String getVersion() {
131 return feature.getVersion();
136 * @see org.apache.karaf.features.Feature#hasVersion()
138 public boolean hasVersion() {
139 return feature.hasVersion();
144 * @see org.apache.karaf.features.Feature#getResolver()
146 public String getResolver() {
147 return feature.getResolver();
152 * @see org.apache.karaf.features.Feature#getInstall()
154 public String getInstall() {
155 return feature.getInstall();
160 * @see org.apache.karaf.features.Feature#getDependencies()
162 public List<Dependency> getDependencies() {
163 return feature.getDependencies();
168 * @see org.apache.karaf.features.Feature#getBundles()
170 public List<BundleInfo> getBundles() {
171 return feature.getBundles();
176 * @see org.apache.karaf.features.Feature#getConfigurations()
178 public Map<String, Map<String, String>> getConfigurations() {
179 return feature.getConfigurations();
184 * @see org.apache.karaf.features.Feature#getConfigurationFiles()
186 public List<ConfigFileInfo> getConfigurationFiles() {
187 return feature.getConfigurationFiles();
192 * @see org.apache.karaf.features.Feature#getConditional()
194 public List<? extends Conditional> getConditional() {
195 return feature.getConditional();
200 * @see org.apache.karaf.features.Feature#getStartLevel()
202 public int getStartLevel() {
203 return feature.getStartLevel();
208 * @see org.apache.karaf.features.Feature#getRegion()
210 public String getRegion() {
211 return feature.getRegion();