@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()); }
@Override public List<Object> getIntentsFromService(Object serviceBean) { List<Object> intents = new ArrayList<>(); 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; }
IntentManagerImpl implements IntentManager { @Override public List<Object> getIntentsFromService(Object serviceBean) { List<Object> intents = new ArrayList<>(); 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; } }
IntentManagerImpl implements IntentManager { @Override public List<Object> getIntentsFromService(Object serviceBean) { List<Object> intents = new ArrayList<>(); 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; }  }
IntentManagerImpl implements IntentManager { @Override public List<Object> getIntentsFromService(Object serviceBean) { List<Object> intents = new ArrayList<>(); 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; }  @Activate void activate(BundleContext context); @Deactivate void deactivate(); synchronized void addIntent(Object intent, String intentName); synchronized void removeIntent(Object intent, String intentName); @Override @SuppressWarnings("unchecked") synchronized List<Object> getRequiredIntents(Set<String> requiredIntents); @Override T getIntent(Class<? extends T> type, List<Object> intents); @Override List<T> getIntents(Class<? extends T> type, List<Object> intents); synchronized String[] assertAllIntentsSupported(Set<String> requiredIntents); @Override Set<String> getExported(Map<String, Object> sd); @Override List<Object> getIntentsFromService(Object serviceBean); @Override Set<String> getImported(Map<String, Object> sd); }
IntentManagerImpl implements IntentManager { @Override public List<Object> getIntentsFromService(Object serviceBean) { List<Object> intents = new ArrayList<>(); 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; }  @Activate void activate(BundleContext context); @Deactivate void deactivate(); synchronized void addIntent(Object intent, String intentName); synchronized void removeIntent(Object intent, String intentName); @Override @SuppressWarnings("unchecked") synchronized List<Object> getRequiredIntents(Set<String> requiredIntents); @Override T getIntent(Class<? extends T> type, List<Object> intents); @Override List<T> getIntents(Class<? extends T> type, List<Object> intents); synchronized String[] assertAllIntentsSupported(Set<String> requiredIntents); @Override Set<String> getExported(Map<String, Object> sd); @Override List<Object> getIntentsFromService(Object serviceBean); @Override Set<String> getImported(Map<String, Object> sd);  }