SpringPluginContext extends DefaultPluginContext implements ApplicationContextAware { @Override public <T> T getPlugin(String pluginName) { final T plugin = super.getPlugin(pluginName); if (plugin == null) { try { return (T) applicationContext.getBean(pluginName); } catch (NoSuchBeanDefinitionException e) { return null; } } return plugin; }  @Override void setApplicationContext(ApplicationContext applicationContext); @Override T getPlugin(String pluginName); @Override T getPlugin(Class<T> pluginClass); @Override boolean hasPlugin(Class<T> pluginClass); @Override boolean hasPlugin(String pluginName);  }
@Test public void shouldLoadFromBothPCandSC() { final TestPlugin plugin = sut.getPlugin(TestPlugin.class); final TestBean bean = sut.getPlugin(TestBean.class); assertNotNull(plugin); assertNotNull(bean); }
@Test public void shouldLoadFromPC() { final TestPlugin plugin = sut.getPlugin(TestPlugin.class); assertNotNull(plugin); }
@Test public void shouldLoadFromSC() { final TestBean bean = sut.getPlugin(TestBean.class); assertNotNull(bean); }