use of org.apache.cxf.tools.plugin.Plugin in project cxf by apache.
the class JAXWSProfileTest method testLoadPlugins.
@Test
public void testLoadPlugins() {
PluginLoader loader = PluginLoader.getInstance();
assertNotNull(loader);
loader.loadPlugin("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-plugin.xml");
assertEquals(3, loader.getPlugins().size());
Plugin plugin = null;
for (Plugin p : loader.getPlugins().values()) {
if (p.getName().contains("jaxws")) {
plugin = p;
}
}
assertNotNull(plugin);
assertEquals("tools-jaxws-frontend", plugin.getName());
assertEquals("2.0", plugin.getVersion());
assertEquals("apache cxf", plugin.getProvider());
Map<String, FrontEnd> frontends = loader.getFrontEnds();
assertNotNull(frontends);
assertEquals(3, frontends.size());
FrontEnd frontend = getFrontEnd(frontends, 0);
assertEquals("jaxws", frontend.getName());
assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws", frontend.getPackage());
assertEquals("JAXWSProfile", frontend.getProfile());
assertNotNull(frontend.getGenerators());
assertNotNull(frontend.getGenerators().getGenerator());
assertEquals(2, frontend.getGenerators().getGenerator().size());
assertEquals("AntGenerator", getGenerator(frontend, 0).getName());
assertEquals("ImplGenerator", getGenerator(frontend, 1).getName());
FrontEndProfile profile = loader.getFrontEndProfile("jaxws");
assertNotNull(profile);
List<FrontEndGenerator> generators = profile.getGenerators();
assertNotNull(generators);
assertEquals(2, generators.size());
assertTrue(generators.get(0) instanceof AntGenerator);
assertTrue(generators.get(1) instanceof ImplGenerator);
Processor processor = profile.getProcessor();
assertNotNull(processor);
assertTrue(processor instanceof WSDLToJavaProcessor);
AbstractWSDLBuilder builder = profile.getWSDLBuilder();
assertNotNull(builder);
assertTrue(builder instanceof JAXWSDefinitionBuilder);
Class<?> container = profile.getContainerClass();
assertEquals(container, JAXWSContainer.class);
assertEquals("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml", profile.getToolspec());
}
use of org.apache.cxf.tools.plugin.Plugin in project cxf by apache.
the class PluginLoader method getPlugin.
protected Plugin getPlugin(String resource) throws JAXBException, FileNotFoundException {
Plugin plugin = plugins.get(resource);
if (plugin == null) {
InputStream is = null;
if (new File(resource).exists()) {
is = new BufferedInputStream(new FileInputStream(new File(resource)));
} else {
is = getClass().getResourceAsStream(resource);
}
if (is == null) {
Message msg = new Message("PLUGIN_MISSING", LOG, resource);
LOG.log(Level.SEVERE, msg.toString());
throw new ToolException(msg);
}
plugin = getPlugin(is);
if (plugin == null || StringUtils.isEmpty(plugin.getName())) {
Message msg = new Message("PLUGIN_LOAD_FAIL", LOG, resource);
LOG.log(Level.SEVERE, msg.toString());
throw new ToolException(msg);
}
plugins.put(resource, plugin);
}
return plugin;
}
use of org.apache.cxf.tools.plugin.Plugin in project cxf by apache.
the class PluginLoader method getPlugin.
protected Plugin getPlugin(URL url) throws IOException, JAXBException, FileNotFoundException {
Plugin plugin = plugins.get(url.toString());
InputStream is = null;
if (plugin == null) {
is = url.openStream();
plugin = getPlugin(is);
if (plugin == null || StringUtils.isEmpty(plugin.getName())) {
Message msg = new Message("PLUGIN_LOAD_FAIL", LOG, url);
LOG.log(Level.SEVERE, msg.toString());
throw new ToolException(msg);
}
plugins.put(url.toString(), plugin);
}
if (is == null) {
return getPlugin(url.toString());
}
return plugin;
}
use of org.apache.cxf.tools.plugin.Plugin in project cxf by apache.
the class PluginLoaderTest method testLoadPlugins.
@Test
public void testLoadPlugins() throws Exception {
PluginLoader loader = PluginLoader.getInstance();
assertEquals(3, loader.getPlugins().size());
Plugin plugin = getPlugin(loader, 0);
assertNotNull(plugin.getName());
Map<String, FrontEnd> frontends = loader.getFrontEnds();
assertNotNull(frontends);
assertEquals(3, frontends.size());
FrontEnd frontend = getFrontEnd(frontends, 0);
assertEquals("jaxws", frontend.getName());
assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws", frontend.getPackage());
assertEquals("JAXWSProfile", frontend.getProfile());
assertNotNull(frontend.getGenerators());
assertNotNull(frontend.getGenerators().getGenerator());
assertEquals("AntGenerator", getGenerator(frontend, 0).getName());
assertEquals("JAXWSContainer", frontend.getContainer().getName());
assertEquals("jaxws-toolspec.xml", frontend.getContainer().getToolspec());
loader.getFrontEndProfile("jaxws");
Map<String, DataBinding> databindings = loader.getDataBindings();
assertNotNull(databindings);
assertEquals(5, databindings.size());
DataBinding databinding = databindings.get("jaxb");
assertNotNull(databinding);
assertEquals("jaxb", databinding.getName());
assertEquals("org.apache.cxf.tools.wsdlto.databinding.jaxb", databinding.getPackage());
assertEquals("JAXBDataBinding", databinding.getProfile());
}
Aggregations