Search in sources :

Example 16 with IListener

use of nl.nn.adapterframework.core.IListener in project iaf by ibissource.

the class Webservices method list.

private String list(IbisManager ibisManager) {
    XmlBuilder webservicesXML = new XmlBuilder("webservices");
    // RestListeners
    XmlBuilder restsXML = new XmlBuilder("rests");
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) a;
        Iterator recIt = adapter.getReceiverIterator();
        while (recIt.hasNext()) {
            IReceiver receiver = (IReceiver) recIt.next();
            if (receiver instanceof ReceiverBase) {
                ReceiverBase rb = (ReceiverBase) receiver;
                IListener listener = rb.getListener();
                if (listener instanceof RestListener) {
                    RestListener rl = (RestListener) listener;
                    if (rl.isView()) {
                        XmlBuilder restXML = new XmlBuilder("rest");
                        restXML.addAttribute("name", rb.getName());
                        restXML.addAttribute("uriPattern", rl.getUriPattern());
                        restsXML.addSubElement(restXML);
                    }
                }
            }
        }
    }
    webservicesXML.addSubElement(restsXML);
    // WSDL's
    XmlBuilder wsdlsXML = new XmlBuilder("wsdls");
    for (IAdapter a : ibisManager.getRegisteredAdapters()) {
        XmlBuilder wsdlXML = new XmlBuilder("wsdl");
        try {
            Adapter adapter = (Adapter) a;
            Wsdl wsdl = new Wsdl(adapter.getPipeLine());
            wsdlXML.addAttribute("name", wsdl.getName());
            wsdlXML.addAttribute("extention", getWsdlExtention());
        } catch (Exception e) {
            wsdlXML.addAttribute("name", a.getName());
            XmlBuilder errorXML = new XmlBuilder("error");
            if (e.getMessage() != null) {
                errorXML.setCdataValue(e.getMessage());
            } else {
                errorXML.setCdataValue(e.toString());
            }
            wsdlXML.addSubElement(errorXML);
        }
        wsdlsXML.addSubElement(wsdlXML);
    }
    webservicesXML.addSubElement(wsdlsXML);
    // ApiListeners
    XmlBuilder apiListenerXML = new XmlBuilder("apiListeners");
    SortedMap<String, ApiDispatchConfig> patternClients = ApiServiceDispatcher.getInstance().getPatternClients();
    for (Entry<String, ApiDispatchConfig> client : patternClients.entrySet()) {
        XmlBuilder apiXML = new XmlBuilder("apiListener");
        ApiDispatchConfig config = client.getValue();
        Set<String> methods = config.getMethods();
        for (String method : methods) {
            ApiListener listener = config.getApiListener(method);
            XmlBuilder methodXML = new XmlBuilder(method);
            String name = listener.getName();
            if (name.contains("listener of ["))
                name = name.substring(13, name.length() - 1);
            methodXML.addAttribute("name", name);
            methodXML.addAttribute("updateEtag", listener.getUpdateEtag());
            methodXML.addAttribute("isRunning", listener.isRunning());
            apiXML.addSubElement(methodXML);
        }
        apiXML.addAttribute("uriPattern", config.getUriPattern());
        apiListenerXML.addSubElement(apiXML);
    }
    webservicesXML.addSubElement(apiListenerXML);
    return webservicesXML.toXML();
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) IListener(nl.nn.adapterframework.core.IListener) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) Wsdl(nl.nn.adapterframework.soap.Wsdl) PipeRunException(nl.nn.adapterframework.core.PipeRunException) NamingException(javax.naming.NamingException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) RestListener(nl.nn.adapterframework.http.RestListener) IReceiver(nl.nn.adapterframework.core.IReceiver) ApiListener(nl.nn.adapterframework.http.rest.ApiListener) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) ApiDispatchConfig(nl.nn.adapterframework.http.rest.ApiDispatchConfig) IAdapter(nl.nn.adapterframework.core.IAdapter)

Aggregations

IListener (nl.nn.adapterframework.core.IListener)16 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)10 IReceiver (nl.nn.adapterframework.core.IReceiver)8 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 IAdapter (nl.nn.adapterframework.core.IAdapter)6 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)6 HashMap (java.util.HashMap)5 Adapter (nl.nn.adapterframework.core.Adapter)5 ISender (nl.nn.adapterframework.core.ISender)5 RestListener (nl.nn.adapterframework.http.RestListener)5 HasPhysicalDestination (nl.nn.adapterframework.core.HasPhysicalDestination)4 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)4 IThreadCountControllable (nl.nn.adapterframework.core.IThreadCountControllable)3 PipeRunException (nl.nn.adapterframework.core.PipeRunException)3 EsbJmsListener (nl.nn.adapterframework.extensions.esb.EsbJmsListener)3 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)3 IOException (java.io.IOException)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2