public static synchronized Dispatch getDispatch()

in src/main/java/org/apache/cxf/cwiki/SiteExporter.java [244:283]


    public static synchronized Dispatch<Document> getDispatch() {
        if (dispatch == null) {
            
            FailoverFeature failover = new FailoverFeature();
            RetryStrategy rs = new RetryStrategy();
            rs.setMaxNumberOfRetries(25);
            List<String> alternateAddresses = new ArrayList<String>();
            alternateAddresses.add(ROOT + RPC_ROOT + apiVersion);
            alternateAddresses.add(ROOT + RPC_ROOT + apiVersion);
            alternateAddresses.add(ROOT + RPC_ROOT + apiVersion);
            rs.setAlternateAddresses(alternateAddresses);
            failover.setStrategy(rs);
            
            
            Service service = Service.create(new QName(SOAPNS, "Service"), failover);
            service.addPort(new QName(SOAPNS, "Port"), 
                            SOAPBinding.SOAP11HTTP_BINDING,
                            ROOT + RPC_ROOT + apiVersion);
    
            dispatch = service.createDispatch(new QName(SOAPNS, "Port"), 
                                              Document.class, Service.Mode.PAYLOAD);
            if (debug) {
                ((org.apache.cxf.jaxws.DispatchImpl<?>)dispatch).getClient()
                    .getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
                ((org.apache.cxf.jaxws.DispatchImpl<?>)dispatch).getClient()
                    .getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
            }
            HTTPConduit c = (HTTPConduit)((org.apache.cxf.jaxws.DispatchImpl<?>)dispatch)
                .getClient().getConduit();
            HTTPClientPolicy clientPol = c.getClient();
            if (clientPol == null) {
                clientPol = new HTTPClientPolicy();
            }
            //CAMEL has a couple of HUGE HUGE pages that take a long time to render
            clientPol.setReceiveTimeout(5 * 60 * 1000);
            c.setClient(clientPol);
            
        }
        return dispatch;
    }