[DOSGI-262] Add support for Features annotation
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
index 10e4a05..67d82a7 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
@@ -31,6 +31,7 @@
 import org.apache.cxf.dosgi.common.api.IntentsProvider;
 import org.apache.cxf.dosgi.common.intent.IntentManager;
 import org.apache.cxf.dosgi.common.util.PropertyHelper;
+import org.apache.cxf.feature.Features;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
@@ -197,6 +198,16 @@
         if (serviceBean instanceof IntentsProvider) {
             intents.addAll(((IntentsProvider)serviceBean).getIntents());
         }
+        Features features = serviceBean.getClass().getAnnotation(Features.class);
+        if (features != null && features.classes() != null) {
+            for (Class<?> clazz : features.classes()) {
+                try {
+                    intents.add(clazz.newInstance());
+                } catch (Exception e) {
+                    throw new RuntimeException("Could not instantiate feature from class " + clazz.getName(), e);
+                }
+            }
+        }
         return intents;
     }
     
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLogging.java b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLogging.java
new file mode 100644
index 0000000..8f46d82
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLogging.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.common.intent.impl;
+
+import org.apache.cxf.feature.Features;
+import org.apache.cxf.transport.common.gzip.GZIPFeature;
+
+@Features(classes = GZIPFeature.class)
+public class DummyServiceWithLogging {
+
+}
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLoggingIP.java b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLoggingIP.java
new file mode 100644
index 0000000..f0773c6
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/DummyServiceWithLoggingIP.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.common.intent.impl;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.cxf.dosgi.common.api.IntentsProvider;
+import org.apache.cxf.transport.common.gzip.GZIPFeature;
+
+public class DummyServiceWithLoggingIP implements IntentsProvider {
+
+    @Override
+    public List<?> getIntents() {
+        return Arrays.asList(new GZIPFeature());
+    }
+
+}
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImplTest.java b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImplTest.java
new file mode 100644
index 0000000..4f55b54
--- /dev/null
+++ b/common/src/test/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImplTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.common.intent.impl;
+
+import java.util.List;
+
+import org.apache.cxf.transport.common.gzip.GZIPFeature;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class IntentManagerImplTest {
+
+    @Test
+    public void testIntentsFromFeatureAnn() {
+        IntentManagerImpl im = new IntentManagerImpl();
+        List<Object> intents = im.getIntentsFromService(new DummyServiceWithLogging());
+        Assert.assertEquals(1, intents.size());
+        Object feature = intents.iterator().next();
+        Assert.assertEquals(GZIPFeature.class, feature.getClass());
+    }
+    
+    @Test
+    public void testIntentsFromIntentsProvider() {
+        IntentManagerImpl im = new IntentManagerImpl();
+        List<Object> intents = im.getIntentsFromService(new DummyServiceWithLoggingIP());
+        Assert.assertEquals(1, intents.size());
+        Object feature = intents.iterator().next();
+        Assert.assertEquals(GZIPFeature.class, feature.getClass());
+    }
+}