Bug 2907: Make sure we are properly bumped to Karaf 3.0.3
[controller.git] / opendaylight / config / config-persister-feature-adapter / src / main / java / org / opendaylight / controller / configpusherfeature / internal / AbstractFeatureWrapper.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.configpusherfeature.internal;
9
10 import com.google.common.base.Preconditions;
11 import java.util.LinkedHashSet;
12 import java.util.List;
13 import javax.xml.bind.JAXBException;
14 import org.apache.karaf.features.BundleInfo;
15 import org.apache.karaf.features.Conditional;
16 import org.apache.karaf.features.ConfigFileInfo;
17 import org.apache.karaf.features.ConfigInfo;
18 import org.apache.karaf.features.Dependency;
19 import org.apache.karaf.features.Feature;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /*
24  * Wrap a Feature for the purposes of extracting the FeatureConfigSnapshotHolders from
25  * its underlying ConfigFileInfo's
26  *
27  * Delegates the the contained feature and provides additional methods.
28  */
29 public class AbstractFeatureWrapper implements Feature {
30     private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
31     protected Feature feature = null;
32
33     protected AbstractFeatureWrapper() {
34         // prevent instantiation without Feature
35     }
36
37     /*
38      * @param f Feature to wrap
39      */
40     public AbstractFeatureWrapper(final Feature f) {
41         Preconditions.checkNotNull(f,"FeatureWrapper requires non-null Feature in constructor");
42         this.feature = f;
43     }
44
45     /*
46      * Get FeatureConfigSnapshotHolders appropriate to feed to the config subsystem
47      * from the underlying Feature Config files
48      */
49     public LinkedHashSet<FeatureConfigSnapshotHolder> getFeatureConfigSnapshotHolders() throws Exception {
50         final LinkedHashSet <FeatureConfigSnapshotHolder> snapShotHolders = new LinkedHashSet<FeatureConfigSnapshotHolder>();
51         for(final ConfigFileInfo c: getConfigurationFiles()) {
52             try {
53                 snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this));
54             } catch (final JAXBException e) {
55                 LOG.debug("{} is not a config subsystem config file",c.getFinalname());
56             }
57         }
58         return snapShotHolders;
59     }
60
61     @Override
62     public int hashCode() {
63         final int prime = 31;
64         int result = 1;
65         result = prime * result + ((feature == null) ? 0 : feature.hashCode());
66         return result;
67     }
68
69     @Override
70     public boolean equals(final Object obj) {
71         if (this == obj) {
72             return true;
73         }
74         if (obj == null) {
75             return false;
76         }
77         if (getClass() != obj.getClass()) {
78             return false;
79         }
80         final AbstractFeatureWrapper other = (AbstractFeatureWrapper) obj;
81         if (feature == null) {
82             if (other.feature != null) {
83                 return false;
84             }
85         } else if (!feature.equals(other.feature)) {
86             return false;
87         }
88         return true;
89     }
90
91     @Override
92     public String toString() {
93         return feature.getName();
94     }
95
96     /**
97      * @return
98      * @see org.apache.karaf.features.Feature#getId()
99      */
100     @Override
101     public String getId() {
102         return feature.getId();
103     }
104
105     /**
106      * @return
107      * @see org.apache.karaf.features.Feature#getName()
108      */
109     @Override
110     public String getName() {
111         return feature.getName();
112     }
113
114     /**
115      * @return
116      * @see org.apache.karaf.features.Feature#getDescription()
117      */
118     @Override
119     public String getDescription() {
120         return feature.getDescription();
121     }
122
123     /**
124      * @return
125      * @see org.apache.karaf.features.Feature#getDetails()
126      */
127     @Override
128     public String getDetails() {
129         return feature.getDetails();
130     }
131
132     /**
133      * @return
134      * @see org.apache.karaf.features.Feature#getVersion()
135      */
136     @Override
137     public String getVersion() {
138         return feature.getVersion();
139     }
140
141     /**
142      * @return
143      * @see org.apache.karaf.features.Feature#hasVersion()
144      */
145     @Override
146     public boolean hasVersion() {
147         return feature.hasVersion();
148     }
149
150     /**
151      * @return
152      * @see org.apache.karaf.features.Feature#getResolver()
153      */
154     @Override
155     public String getResolver() {
156         return feature.getResolver();
157     }
158
159     /**
160      * @return
161      * @see org.apache.karaf.features.Feature#getInstall()
162      */
163     @Override
164     public String getInstall() {
165         return feature.getInstall();
166     }
167
168     /**
169      * @return
170      * @see org.apache.karaf.features.Feature#getDependencies()
171      */
172     @Override
173     public List<Dependency> getDependencies() {
174         return feature.getDependencies();
175     }
176
177     /**
178      * @return
179      * @see org.apache.karaf.features.Feature#getBundles()
180      */
181     @Override
182     public List<BundleInfo> getBundles() {
183         return feature.getBundles();
184     }
185
186     /**
187      * @return
188      * @see org.apache.karaf.features.Feature#getConfigurations()
189      */
190     @Override
191     public List<ConfigInfo> getConfigurations() {
192         return feature.getConfigurations();
193     }
194
195     /**
196      * @return
197      * @see org.apache.karaf.features.Feature#getConfigurationFiles()
198      */
199     @Override
200     public List<ConfigFileInfo> getConfigurationFiles() {
201         return feature.getConfigurationFiles();
202     }
203
204     /**
205      * @return
206      * @see org.apache.karaf.features.Feature#getConditional()
207      */
208     @Override
209     public List<? extends Conditional> getConditional() {
210         return feature.getConditional();
211     }
212
213     /**
214      * @return
215      * @see org.apache.karaf.features.Feature#getStartLevel()
216      */
217     @Override
218     public int getStartLevel() {
219         return feature.getStartLevel();
220     }
221
222     /**
223      * @return
224      * @see org.apache.karaf.features.Feature#getRegion()
225      */
226     @Override
227     public String getRegion() {
228         return feature.getRegion();
229     }
230
231 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.