public void stop(BundleContext context) throws Exception { ConverterRegistry.getRegistry().dispose(); //later : //registration.unregister(); }
public Set<String> getFroms() { initializeIfNeeded(); return converters.keySet(); }
public IConverter findConverter(String from, String to, String via) throws XDocConverterException { return internalFindConverter(from, to, via, true); }
public IConverter getConverter( Options options ) throws XDocConverterException { return ConverterRegistry.getRegistry().findConverter( getKind(), options.getTo(), options.getVia() ); }
public void start(BundleContext context) throws Exception { ClassLoader backup = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); ConverterRegistry.getRegistry().initialize(); Thread.currentThread().setContextClassLoader(backup); //TODO : discuss with Angelo to behave that way under OSGi context : // Collection<String> froms = ConverterRegistry.getRegistry().getFroms(); // for (String from : froms) { // ConverterFrom converterFrom = ConverterRegistry.getRegistry() // .getConverterFrom(from); // Collection<ConverterTo> tos = converterFrom.getConvertersTo(); // for (ConverterTo to : tos) { // Collection<String> vias = to.getVias(); // for (String via : vias) { // Dictionary<String, String> properties=new java.util.Hashtable<String,String>(); // properties.put("From", from); // properties.put("to", to.getTo()); // properties.put("via", via); // ServiceRegistration registration= context.registerService(IConverter.class.getName(), // ConverterRegistry.getRegistry().findConverter(from, to.getTo(), via), // properties); // // } // // } // } }
public IConverter findConverter(Options options) throws XDocConverterException { return findConverter(options.getFrom(), options.getTo(), options.getVia()); }
private IConverter internalFindConverter(String from, String to, String via, boolean throwError) throws XDocConverterException { initializeIfNeeded(); ConverterFrom fromConverters = getConverterFrom(from); if (fromConverters == null) { String msg = String.format("Cannot find converters from=%s", from);
public IConverter getConverter(Options options) { return getConverter(options.getFrom(), options.getTo(), options.getVia()); }
public byte[] convert( byte[] document, Options options ) throws XDocReportException { try { IConverter converter = ConverterRegistry.getRegistry().findConverter( options ); InputStream in = getInputStream( document ); ByteArrayOutputStream out = new ByteArrayOutputStream(); converter.convert( in, out, options ); return out.toByteArray(); } catch ( XDocConverterException e ) { throw new XDocReportException( e ); } }
public ConverterFrom getConverterFrom(String from) { initializeIfNeeded(); return converters.get(from); }
public IConverter getConverter(String from, String to, String via) { try { return internalFindConverter(from, to, via, false); } catch (XDocConverterException e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(e.getMessage()); } return null; } }