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 com.google.common.base.Preconditions;
11 import java.util.LinkedHashSet;
12 import java.util.List;
14 import javax.xml.bind.JAXBException;
15 import org.apache.karaf.features.BundleInfo;
16 import org.apache.karaf.features.Conditional;
17 import org.apache.karaf.features.ConfigFileInfo;
18 import org.apache.karaf.features.Dependency;
19 import org.apache.karaf.features.Feature;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
25 * its underlying ConfigFileInfo's
27 * Delegates the the contained feature and provides additional methods.
29 public class AbstractFeatureWrapper implements Feature {
30 private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
31 protected Feature feature = null;
33 protected AbstractFeatureWrapper() {
34 // prevent instantiation without Feature
38 * @param f Feature to wrap
40 public AbstractFeatureWrapper(Feature f) {
41 Preconditions.checkNotNull(f,"FeatureWrapper requires non-null Feature in constructor");
46 * Get FeatureConfigSnapshotHolders appropriate to feed to the config subsystem
47 * from the underlying Feature Config files
49 public LinkedHashSet<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolders() throws Exception {
50 LinkedHashSet <FeatureConfigSnapshotHolder> snapShotHolders = new LinkedHashSet<FeatureConfigSnapshotHolder>();
51 for(ConfigFileInfo c: getConfigurationFiles()) {
53 snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this));
54 } catch (JAXBException e) {
55 LOG.debug("{} is not a config subsystem config file",c.getFinalname());
58 return snapShotHolders;
62 public int hashCode() {
65 result = prime * result + ((feature == null) ? 0 : feature.hashCode());
70 public boolean equals(Object obj) {
77 if (getClass() != obj.getClass()) {
80 AbstractFeatureWrapper other = (AbstractFeatureWrapper) obj;
81 if (feature == null) {
82 if (other.feature != null) {
85 } else if (!feature.equals(other.feature)) {
92 public String toString() {
93 return feature.getName();
98 * @see org.apache.karaf.features.Feature#getId()
100 public String getId() {
101 return feature.getId();
106 * @see org.apache.karaf.features.Feature#getName()
108 public String getName() {
109 return feature.getName();
114 * @see org.apache.karaf.features.Feature#getDescription()
116 public String getDescription() {
117 return feature.getDescription();
122 * @see org.apache.karaf.features.Feature#getDetails()
124 public String getDetails() {
125 return feature.getDetails();
130 * @see org.apache.karaf.features.Feature#getVersion()
132 public String getVersion() {
133 return feature.getVersion();
138 * @see org.apache.karaf.features.Feature#hasVersion()
140 public boolean hasVersion() {
141 return feature.hasVersion();
146 * @see org.apache.karaf.features.Feature#getResolver()
148 public String getResolver() {
149 return feature.getResolver();
154 * @see org.apache.karaf.features.Feature#getInstall()
156 public String getInstall() {
157 return feature.getInstall();
162 * @see org.apache.karaf.features.Feature#getDependencies()
164 public List<Dependency> getDependencies() {
165 return feature.getDependencies();
170 * @see org.apache.karaf.features.Feature#getBundles()
172 public List<BundleInfo> getBundles() {
173 return feature.getBundles();
178 * @see org.apache.karaf.features.Feature#getConfigurations()
180 public Map<String, Map<String, String>> getConfigurations() {
181 return feature.getConfigurations();
186 * @see org.apache.karaf.features.Feature#getConfigurationFiles()
188 public List<ConfigFileInfo> getConfigurationFiles() {
189 return feature.getConfigurationFiles();
194 * @see org.apache.karaf.features.Feature#getConditional()
196 public List<? extends Conditional> getConditional() {
197 return feature.getConditional();
202 * @see org.apache.karaf.features.Feature#getStartLevel()
204 public int getStartLevel() {
205 return feature.getStartLevel();
210 * @see org.apache.karaf.features.Feature#getRegion()
212 public String getRegion() {
213 return feature.getRegion();