org.apache.cxf.Bus - java examples

Here are the examples of the java api org.apache.cxf.Bus taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : UndertowHTTPDestination.java
Copyright Apache License 2.0
Author : apache
protected void doService(ServletContext context, HttpServletRequest req, HttpServletResponse resp) throws IOException {
    if (context == null) {
        context = servletContext;
    }
    HTTPServerPolicy sp = getServer();
    if (sp.isSetRedirectURL()) {
        resp.sendRedirect(sp.getRedirectURL());
        resp.flushBuffer();
        return;
    }
    ClreplacedLoaderHolder origLoader = null;
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    try {
        if (loader != null) {
            origLoader = ClreplacedLoaderUtils.setThreadContextClreplacedloader(loader);
        }
        invoke(null, context, req, resp);
    } finally {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
        if (origLoader != null) {
            origLoader.reset();
        }
    }
}

19 View Complete Implementation : JAXWSHttpSpiDestination.java
Copyright Apache License 2.0
Author : apache
/**
 * This is called by handlers for servicing requests
 *
 * @param req
 * @param resp
 * @throws IOException
 */
protected void doService(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    try {
        serviceRequest(req, resp);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
    }
}

19 View Complete Implementation : WSPolicyFeature.java
Copyright Apache License 2.0
Author : apache
public void initializePolicyEngine(Bus bus) {
    // this should never be null as features are initialized only
    // after the bus and all its extensions have been created
    PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
    synchronized (pe) {
        pe.setEnabled(enabled);
        pe.setIgnoreUnknownreplacedertions(ignoreUnknownreplacedertions);
        if (null != alternativeSelector) {
            pe.setAlternativeSelector(alternativeSelector);
        }
    }
}

19 View Complete Implementation : TestBase.java
Copyright Apache License 2.0
Author : apache
protected void common(String wsdl, QName portName, Clreplaced<?>... jaxbClreplacedes) throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    WSDLManagerImpl manager = new WSDLManagerImpl();
    XMLWSDLExtensionLoader.registerExtensors(manager);
    replacedertNotNull(bus.getExtension(WSDLManager.clreplaced));
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClreplaced().getResource(wsdl).toString(), new QName(portName.getNamespaceURI(), "XMLService"));
    org.apache.cxf.service.Service service = factory.create();
    EndpointInfo epi = service.getEndpointInfo(portName);
    replacedertNotNull(epi);
    serviceInfo = epi.getService();
    JAXBDataBinding db = new JAXBDataBinding();
    db.initialize(service);
    db.setContext(JAXBContext.newInstance(jaxbClreplacedes));
    service.setDataBinding(db);
    Endpoint endpoint = new EndpointImpl(bus, service, epi);
    xmlMessage.getExchange().put(Endpoint.clreplaced, endpoint);
    xmlMessage.getExchange().put(org.apache.cxf.service.Service.clreplaced, service);
}

19 View Complete Implementation : NettyServerTest.java
Copyright Apache License 2.0
Author : apache
@BeforeClreplaced
public static void start() throws Exception {
    Bus b = createStaticBus();
    BusFactory.setThreadDefaultBus(b);
    ep = Endpoint.publish("netty://http://localhost:" + PORT + "/SoapContext/SoapPort", new org.apache.hello_world_soap_http.GreeterImpl());
    URL wsdl = NettyServerTest.clreplaced.getResource("/wsdl/hello_world.wsdl");
    replacedertNotNull("WSDL is null", wsdl);
    SOAPService service = new SOAPService(wsdl);
    replacedertNotNull("Service is null", service);
    g = service.getSoapPort();
    replacedertNotNull("Port is null", g);
}

19 View Complete Implementation : Client.java
Copyright Apache License 2.0
Author : apache
public static void main(String[] args) throws Exception {
    try {
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = Client.clreplaced.getResource("/wssec.xml");
        Bus bus = bf.createBus(busFile.toString());
        BusFactory.setDefaultBus(bus);
        Map<String, Object> outProps = new HashMap<>();
        outProps.put("action", "UsernameToken Timestamp");
        outProps.put("preplacedwordType", "PreplacedwordDigest");
        outProps.put("user", "abcd");
        outProps.put("preplacedwordCallbackClreplaced", "demo.wssec.client.UTPreplacedwordCallback");
        Map<String, Object> inProps = new HashMap<>();
        inProps.put("action", "UsernameToken Timestamp");
        inProps.put("preplacedwordType", "PreplacedwordText");
        inProps.put("preplacedwordCallbackClreplaced", "demo.wssec.client.UTPreplacedwordCallback");
        GreeterService service = new GreeterService();
        Greeter port = service.getGreeterPort();
        org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port);
        client.getInInterceptors().add(new WSS4JInInterceptor(inProps));
        client.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
        String[] names = new String[] { "Anne", "Bill", "Chris", "Scott" };
        // make a sequence of 4 invocations
        for (int i = 0; i < 4; i++) {
            System.out.println("Invoking greetMe...");
            String response = port.greetMe(names[i]);
            System.out.println("response: " + response + "\n");
        }
        if (port instanceof Closeable) {
            ((Closeable) port).close();
        }
        bus.shutdown(true);
    } catch (UndeclaredThrowableException ex) {
        ex.getUndeclaredThrowable().printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        System.exit(0);
    }
}

19 View Complete Implementation : HTTPConduitTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testAuthPolicyFromEndpointInfo() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    AuthorizationPolicy ap = new AuthorizationPolicy();
    ap.setPreplacedword("preplacedword");
    ap.setUserName("testUser");
    ei.addExtensor(ap);
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();
    Message message = getNewMessage();
    // Test call
    conduit.prepare(message);
    Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
    replacedertNotNull("Authorization Header should exist", headers.get("Authorization"));
    replacedertEquals("Unexpected Authorization Token", "Basic " + Base64Utility.encode("testUser:preplacedword".getBytes()), headers.get("Authorization").get(0));
}

19 View Complete Implementation : JaxRsTestActivator.java
Copyright Apache License 2.0
Author : apache
@Override
protected Server createServer() {
    Bus bus = BusFactory.newInstance().createBus();
    bus.setExtension(JaxRsTestActivator.clreplaced.getClreplacedLoader(), ClreplacedLoader.clreplaced);
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setBus(bus);
    sf.setResourceClreplacedes(BookStore.clreplaced);
    sf.setAddress("/jaxrs");
    return sf.create();
}

19 View Complete Implementation : HeaderManagerImpl.java
Copyright Apache License 2.0
Author : apache
@NoJSR250Annotations(unlessNull = "bus")
public clreplaced HeaderManagerImpl implements HeaderManager {

    Map<String, HeaderProcessor> processors = new ConcurrentHashMap<>(4, 0.75f, 2);

    Bus bus;

    public HeaderManagerImpl() {
    }

    public HeaderManagerImpl(Bus b) {
        setBus(b);
    }

    public Bus getBus() {
        return bus;
    }

    @Resource
    public final void setBus(Bus bus) {
        this.bus = bus;
        if (null != bus) {
            bus.setExtension(this, HeaderManager.clreplaced);
        }
    }

    public HeaderProcessor getHeaderProcessor(String namespace) {
        return processors.get(namespace != null ? namespace : "");
    }

    public void registerHeaderProcessor(HeaderProcessor processor) {
        processors.put(processor.getNamespace(), processor);
    }
}

19 View Complete Implementation : WSPolicyFeature.java
Copyright Apache License 2.0
Author : apache
Policy resolveLocal(PolicyReference ref, final Bus bus, DescriptionInfo i) {
    String uri = ref.getURI().substring(1);
    String absoluteURI = i == null ? uri : i.getBaseURI() + uri;
    PolicyRegistry registry = bus.getExtension(PolicyEngine.clreplaced).getRegistry();
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new ReferenceResolver() {

        public Policy resolveReference(String uri) {
            PolicyBean pb = bus.getExtension(ConfiguredBeanLocator.clreplaced).getBeanOfType(uri, PolicyBean.clreplaced);
            if (null != pb) {
                PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
                return builder.getPolicy(pb.getElement());
            }
            return null;
        }
    };
    resolved = resolver.resolveReference(uri);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}

19 View Complete Implementation : KeyManagementUtils.java
Copyright Apache License 2.0
Author : apache
private static KeyStore loadKeyStore(String keyStoreLoc, String keyStoreType, String keyStorePswd, Bus bus) {
    if (keyStorePswd == null) {
        throw new SignatureException("No keystore preplacedword was defined");
    }
    try {
        InputStream is = getResourceStream(keyStoreLoc, bus);
        return CryptoUtils.loadKeyStore(is, keyStorePswd.toCharArray(), keyStoreType);
    } catch (Exception ex) {
        LOG.warning("Key store can not be loaded");
        throw new SignatureException("Key store can not be loaded", ex);
    }
}

19 View Complete Implementation : LoggingFactoryBeanListener.java
Copyright Apache License 2.0
Author : apache
private void addLoggingSupport(Endpoint endpoint, Bus bus, Logging annotation) {
    if (annotation != null) {
        LoggingFeature lf = new LoggingFeature();
        lf.setInMemThreshold(annotation.inMemThresHold());
        lf.setPrettyLogging(annotation.pretty());
        lf.setLimit(annotation.limit());
        lf.setLogBinary(annotation.logBinary());
        lf.setLogMultipart(annotation.logMultipart());
        lf.initialize(endpoint, bus);
    }
}

19 View Complete Implementation : UndertowHTTPServerEngine.java
Copyright Apache License 2.0
Author : apache
private boolean shouldCheckUrl(Bus bus) {
    Object prop = null;
    if (bus != null) {
        prop = bus.getProperty(DO_NOT_CHECK_URL_PROP);
    }
    if (prop == null) {
        prop = SystemPropertyAction.getPropertyOrNull(DO_NOT_CHECK_URL_PROP);
    }
    return !PropertyUtils.isTrue(prop);
}

19 View Complete Implementation : HTTPTransportFactoryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testGetDestination() {
    Bus bus = BusFactory.getDefaultBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPTransportFactory factory = bus.getExtension(HTTPTransportFactory.clreplaced);
    if (factory != null) {
        try {
            factory.getDestination(ei, bus);
            fail("Expect exception here.");
        } catch (IOException ex) {
            replacedertTrue("We should find some exception related to the HttpDestination", ex.getMessage().indexOf("HttpDestinationFactory") > 0);
        }
    }
}

19 View Complete Implementation : JoseUtils.java
Copyright Apache License 2.0
Author : apache
public static Properties loadProperties(String propertiesLocation, Bus bus) throws Exception {
    Properties props = new Properties();
    try (InputStream is = getResourceStream(propertiesLocation, bus)) {
        if (is == null) {
            throw new JoseException("The properties file " + propertiesLocation + " could not be read");
        }
        props.load(is);
    }
    return props;
}

19 View Complete Implementation : ColocInInterceptor.java
Copyright Apache License 2.0
Author : apache
public void handleMessage(Message msg) throws Fault {
    Exchange ex = msg.getExchange();
    if (ex.isOneWay()) {
        return;
    }
    Bus bus = ex.getBus();
    SortedSet<Phase> phases = new TreeSet<>(bus.getExtension(PhaseManager.clreplaced).getOutPhases());
    // TODO Set Coloc FaultObserver chain
    ColocUtil.setPhases(phases, Phase.SETUP, Phase.USER_LOGICAL);
    InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, phases);
    if (LOG.isLoggable(Level.FINER)) {
        LOG.finer("Processing Message at collocated endpoint.  Response message: " + msg);
    }
    // Initiate OutBound Processing
    BindingOperationInfo boi = ex.getBindingOperationInfo();
    Message outBound = ex.getOutMessage();
    if (boi != null) {
        outBound.put(MessageInfo.clreplaced, boi.getOperationInfo().getOutput());
    }
    outBound.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
    outBound.setInterceptorChain(chain);
    chain.doIntercept(outBound);
}

19 View Complete Implementation : StaxSTSServer.java
Copyright Apache License 2.0
Author : apache
protected void run() {
    URL busFile = StaxSTSServer.clreplaced.getResource("stax-cxf-sts.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);
    try {
        new StaxSTSServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

19 View Complete Implementation : WSPolicyFeature.java
Copyright Apache License 2.0
Author : apache
@Override
public void initialize(Server server, Bus bus) {
    Endpoint endpoint = server.getEndpoint();
    Policy p = initializeEndpointPolicy(endpoint, bus);
    PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
    EndpointInfo ei = endpoint.getEndpointInfo();
    EndpointPolicy ep = pe.getServerEndpointPolicy(ei, null, null);
    pe.setServerEndpointPolicy(ei, ep.updatePolicy(p, createMessage(endpoint, bus)));
    // Add policy to the service model (and consequently to the WSDL)
    // FIXME - ideally this should probably be moved up to where the policies are applied to the
    // endpoint, rather than this late.  As a consequence of its location, you have to declare a
    // ws policy feature on every endpoint in order to get any policy attachments into the
    // wsdl.  Alternatively add to the WSDLServiceBuilder somehow.
    ServiceModelPolicyUpdater pu = new ServiceModelPolicyUpdater(ei);
    for (PolicyProvider pp : ((PolicyEngineImpl) pe).getPolicyProviders()) {
        if (pp instanceof ExternalAttachmentProvider) {
            pu.addPolicyAttachments(((ExternalAttachmentProvider) pp).getAttachments());
        }
    }
}

19 View Complete Implementation : WebSocketTransportFactoryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testGetDestination() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("ws://localhost:8888/bar/foo");
    WebSocketTransportFactory factory = bus.getExtension(WebSocketTransportFactory.clreplaced);
    replacedertNotNull(factory);
    Destination dest = factory.getDestination(ei, bus);
    replacedertNotNull(dest);
}

19 View Complete Implementation : FactoryBeanListenerManager.java
Copyright Apache License 2.0
Author : apache
@Resource
public final void setBus(Bus bus) {
    this.bus = bus;
    this.bus.setExtension(this, FactoryBeanListenerManager.clreplaced);
    ConfiguredBeanLocator loc = bus.getExtension(ConfiguredBeanLocator.clreplaced);
    if (loc != null) {
        for (FactoryBeanListener f : loc.getBeansOfType(FactoryBeanListener.clreplaced)) {
            listeners.add(0, f);
        }
    }
}

19 View Complete Implementation : BusExtensionPostProcessor.java
Copyright Apache License 2.0
Author : apache
@NoJSR250Annotations
public clreplaced BusExtensionPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered {

    private Bus bus;

    private ApplicationContext context;

    public void setApplicationContext(ApplicationContext ctx) {
        context = ctx;
    }

    public int getOrder() {
        return 1001;
    }

    public Object postProcessAfterInitialization(Object bean, String beanId) {
        return bean;
    }

    public Object postProcessBeforeInitialization(Object bean, String beanId) {
        if (bean instanceof BusExtension && null != getBus()) {
            Clreplaced<? extends Object> cls = ((BusExtension) bean).getRegistrationType();
            registerExt(bean, cls);
        } else if (bean instanceof Bus && Bus.DEFAULT_BUS_ID.equals(beanId)) {
            bus = (Bus) bean;
        }
        return bean;
    }

    private <T> void registerExt(Object bean, Clreplaced<T> cls) {
        getBus().setExtension(cls.cast(bean), cls);
    }

    private Bus getBus() {
        if (bus == null) {
            bus = (Bus) context.getBean(Bus.DEFAULT_BUS_ID);
        }
        return bus;
    }
}

19 View Complete Implementation : ServiceContractResolverRegistryImpl.java
Copyright Apache License 2.0
Author : apache
/**
 * Sets the bus with which the registry is replacedociated.
 *
 * @param b
 */
public final void setBus(Bus b) {
    this.bus = b;
    if (bus != null) {
        bus.setExtension(this, ServiceContractResolverRegistry.clreplaced);
    }
}

19 View Complete Implementation : WSPolicyFeature.java
Copyright Apache License 2.0
Author : apache
protected Policy resolveExternal(PolicyReference ref, String baseURI, Bus bus) {
    PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
    ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
    PolicyRegistry registry = bus.getExtension(PolicyEngine.clreplaced).getRegistry();
    Policy resolved = registry.lookup(ref.getURI());
    if (null != resolved) {
        return resolved;
    }
    return resolver.resolveReference(ref.getURI());
}

19 View Complete Implementation : CXFNonSpringServlet.java
Copyright Apache License 2.0
Author : apache
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    ClreplacedLoaderHolder origLoader = null;
    Bus origBus = null;
    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
        try {
            if (loader != null) {
                origLoader = ClreplacedLoaderUtils.setThreadContextClreplacedloader(loader);
            }
            if (bus != null) {
                origBus = BusFactory.getAndSetThreadDefaultBus(bus);
            }
            HttpServletRequest httpRequest = (HttpServletRequest) request;
            if (controller.filter(new HttpServletRequestFilter(httpRequest, super.getServletName()), (HttpServletResponse) response)) {
                return;
            }
        } finally {
            if (origBus != bus) {
                BusFactory.setThreadDefaultBus(origBus);
            }
            if (origLoader != null) {
                origLoader.reset();
            }
        }
    }
    chain.doFilter(request, response);
}

19 View Complete Implementation : SoapBindingFactoryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testFactory() throws Exception {
    Definition d = createDefinition("/wsdl_soap/hello_world.wsdl");
    Bus bus = getMockBus();
    BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
    bus.getExtension(BindingFactoryManager.clreplaced);
    expectLastCall().andReturn(bfm).anyTimes();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.clreplaced);
    expect(bus.getExtension(DestinationFactoryManager.clreplaced)).andStubReturn(dfm);
    control.replay();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap_http", "SOAPService")).get(0);
    BindingInfo bi = serviceInfo.getBindings().iterator().next();
    replacedertTrue(bi instanceof SoapBindingInfo);
    SoapBindingInfo sbi = (SoapBindingInfo) bi;
    replacedertEquals("doreplacedent", sbi.getStyle());
    replacedertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
    replacedertTrue(sbi.getSoapVersion() instanceof Soap11);
    BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap_http", "sayHi"));
    SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.clreplaced);
    replacedertNotNull(sboi);
    replacedertEquals("doreplacedent", sboi.getStyle());
    replacedertEquals("", sboi.getAction());
    BindingMessageInfo input = boi.getInput();
    SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.clreplaced);
    replacedertEquals("literal", bodyInfo.getUse());
    List<MessagePartInfo> parts = bodyInfo.getParts();
    replacedertNotNull(parts);
    replacedertEquals(1, parts.size());
}

19 View Complete Implementation : Server.java
Copyright Apache License 2.0
Author : apache
@EnableAutoConfiguration
@SpringBootApplication
public clreplaced Server {

    @Autowired
    private Bus bus;

    public static void main(String[] args) {
        SpringApplication.run(Server.clreplaced, args);
    }

    @Bean
    org.apache.cxf.endpoint.Server cxfServer(@Qualifier("cxf") final Tracer tracer) {
        final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
        endpoint.setBus(bus);
        endpoint.setAddress("/");
        endpoint.setServiceBean(new Catalog());
        endpoint.setProvider(new OpenTracingFeature(tracer));
        endpoint.setProvider(new JacksonJsonProvider());
        return endpoint.create();
    }

    @Bean
    @Qualifier("cxf")
    Tracer cxfTracer() {
        return new Configuration("cxf-service").withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1)).withReporter(new ReporterConfiguration().withSender(new SenderConfiguration().withEndpoint("http://localhost:14268/api/traces"))).getTracer();
    }
}

19 View Complete Implementation : MultipleEndpointObserver.java
Copyright Apache License 2.0
Author : apache
public void onMessage(Message message) {
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    ClreplacedLoaderHolder origLoader = null;
    try {
        if (loader != null) {
            origLoader = ClreplacedLoaderUtils.setThreadContextClreplacedloader(loader);
        }
        Exchange exchange = message.getExchange();
        if (exchange == null) {
            exchange = new ExchangeImpl();
            exchange.setInMessage(message);
            message.setExchange(exchange);
        }
        message = createMessage(message);
        message.setExchange(exchange);
        exchange.setInMessage(message);
        setExchangeProperties(exchange, message);
        // setup chain
        PhaseInterceptorChain chain = createChain();
        message.setInterceptorChain(chain);
        chain.add(bus.getInInterceptors());
        if (bindingInterceptors != null) {
            chain.add(bindingInterceptors);
        }
        if (routingInterceptors != null) {
            chain.add(routingInterceptors);
        }
        if (endpoints != null) {
            exchange.put(ENDPOINTS, endpoints);
        }
        chain.doIntercept(message);
    } finally {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
        if (origLoader != null) {
            origLoader.reset();
        }
    }
}

19 View Complete Implementation : SpringBusFactoryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testForLifeCycle() {
    BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.clreplaced);
    Bus bus = new SpringBusFactory().createBus();
    BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.clreplaced);
    lifeCycleManager.registerLifeCycleListener(bl);
    EasyMock.reset(bl);
    bl.preShutdown();
    EasyMock.expectLastCall();
    bl.postShutdown();
    EasyMock.expectLastCall();
    EasyMock.replay(bl);
    bus.shutdown(true);
    EasyMock.verify(bl);
}

19 View Complete Implementation : StaxSTSServer.java
Copyright Apache License 2.0
Author : apache
protected void run() {
    URL busFile = StaxSTSServer.clreplaced.getResource("stax-cxf-sts.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);
    try {
        new StaxSTSServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

19 View Complete Implementation : AbstractMessageResponseTimeInterceptor.java
Copyright Apache License 2.0
Author : apache
protected boolean isServiceCounterEnabled(Exchange ex) {
    Bus bus = ex.getBus();
    CounterRepository counterRepo = bus.getExtension(CounterRepository.clreplaced);
    if (counterRepo == null) {
        return false;
    }
    ObjectName serviceCounterName = getServiceCounterName(ex);
    Counter serviceCounter = counterRepo.getCounter(serviceCounterName);
    // If serviceCounter is null, we need to wait ResponseTimeOutInterceptor to create it , hence set to true
    return serviceCounter == null || serviceCounter.isEnabled();
}

19 View Complete Implementation : SseProvidersExtension.java
Copyright Apache License 2.0
Author : apache
@Override
public void busCreated(Bus bus) {
    Object providers = bus.getProperty(BUS_PROVIDERS);
    final List<?> sseProviders = Arrays.asList(new SseContextProvider(), new SseEventSinkContextProvider());
    if (providers instanceof List) {
        final List<?> existing = new ArrayList<>((List<?>) providers);
        existing.addAll(CastUtils.cast(sseProviders));
        bus.setProperty(BUS_PROVIDERS, existing);
    } else {
        bus.setProperty(BUS_PROVIDERS, sseProviders);
    }
}

19 View Complete Implementation : HTTPConduitURLConnectionTest.java
Copyright Apache License 2.0
Author : apache
/**
 * This test verifies that the "prepare" call places an HttpURLConnection on
 * the Message and that its URL matches the endpoint.
 */
@Test
public void testConnectionURL() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();
    Message message = getNewMessage();
    conduit.prepare(message);
    HttpURLConnection con = (HttpURLConnection) message.get("http.connection");
    replacedertEquals("Unexpected URL address", con.getURL().toString(), ei.getAddress());
}

19 View Complete Implementation : AbstractDataBinding.java
Copyright Apache License 2.0
Author : apache
/**
 * This call is used to set the bus. It should only be called once.
 *
 * @param bus
 */
@Resource(name = "cxf")
public void setBus(Bus bus) {
    replacedert this.bus == null || this.bus == bus;
    this.bus = bus;
}

19 View Complete Implementation : ClientMessageObserver.java
Copyright Apache License 2.0
Author : apache
public void onMessage(Message m) {
    Message message = cfg.getConduitSelector().getEndpoint().getBinding().createMessage(m);
    message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
    message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
    PhaseInterceptorChain chain = AbstractClient.setupInInterceptorChain(cfg);
    message.setInterceptorChain(chain);
    message.getExchange().setInMessage(message);
    Bus bus = cfg.getBus();
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    ClreplacedLoaderHolder origLoader = null;
    try {
        if (loader != null) {
            origLoader = ClreplacedLoaderUtils.setThreadContextClreplacedloader(loader);
        }
        // execute chain
        chain.doIntercept(message);
    } finally {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
        if (origLoader != null) {
            origLoader.reset();
        }
        synchronized (message.getExchange()) {
            message.getExchange().notifyAll();
        }
    }
}

19 View Complete Implementation : WSPolicyFeature.java
Copyright Apache License 2.0
Author : apache
@Override
public void initialize(Bus bus) {
    initializePolicyEngine(bus);
    Collection<Policy> loadedPolicies = null;
    if (policyElements != null || policyReferenceElements != null) {
        loadedPolicies = new ArrayList<>();
        PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
        if (null != policyElements) {
            for (Element e : policyElements) {
                loadedPolicies.add(builder.getPolicy(e));
            }
        }
        if (null != policyReferenceElements) {
            for (Element e : policyReferenceElements) {
                PolicyReference pr = builder.getPolicyReference(e);
                Policy resolved = resolveReference(pr, builder, bus, null);
                if (null != resolved) {
                    loadedPolicies.add(resolved);
                }
            }
        }
    }
    Policy thePolicy = new Policy();
    if (policies != null) {
        for (Policy p : policies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    if (loadedPolicies != null) {
        for (Policy p : loadedPolicies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    if (!thePolicy.isEmpty()) {
        PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
        synchronized (pe) {
            pe.addPolicy(thePolicy);
        }
    }
}

19 View Complete Implementation : AbstractPolicyProvider.java
Copyright Apache License 2.0
Author : apache
public final void setBus(Bus b) {
    bus = b;
    if (null != bus) {
        setBuilder(bus.getExtension(PolicyBuilder.clreplaced));
        PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
        if (pe != null) {
            setRegistry(pe.getRegistry());
            ((PolicyEngineImpl) pe).addPolicyProvider(this);
        }
    }
}

19 View Complete Implementation : JaxwsBasicAuthTest.java
Copyright Apache License 2.0
Author : apache
@org.junit.Test
public void testBasicAuth() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JaxwsBasicAuthTest.clreplaced.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = JaxwsBasicAuthTest.clreplaced.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItPort");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.clreplaced);
    updateAddressPort(port, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(port);
    }
    doubleIt(port, 25);
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}

19 View Complete Implementation : EndpointImplTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testEqualsAndHashCode() throws Exception {
    Bus bus = new ExtensionManagerBus();
    Service svc = new ServiceImpl();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    EndpointInfo ei2 = new EndpointInfo();
    ei2.setAddress("http://nowhere.com/foo/bar");
    Endpoint ep = new EndpointImpl(bus, svc, ei);
    Endpoint ep1 = new EndpointImpl(bus, svc, ei);
    Endpoint ep2 = new EndpointImpl(bus, svc, ei2);
    int hashcode = ep.hashCode();
    int hashcode1 = ep1.hashCode();
    int hashcode2 = ep2.hashCode();
    replacedertEquals("hashcodes must be equal", hashcode, hashcode1);
    replacedertNotEquals("hashcodes must not be equal", hashcode, hashcode2);
    // replacedertEquals("reflexivity violated", ep, ep);
    replacedertNotEquals("two objects must not be equal", ep, ep1);
    replacedertNotEquals("two objects must not be equal", ep, ep2);
    ep.put("custom", Boolean.TRUE);
    replacedertEquals("hashcode must remain equal", hashcode, ep.hashCode());
}

19 View Complete Implementation : WebSocketDestinationFactory.java
Copyright Apache License 2.0
Author : apache
private static DestinationRegistry getDestinationRegistry(Bus bus) {
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.clreplaced);
    try {
        DestinationFactory df = dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
        if (df instanceof HTTPTransportFactory) {
            HTTPTransportFactory transportFactory = (HTTPTransportFactory) df;
            return transportFactory.getRegistry();
        }
    } catch (Exception e) {
    // why are we throwing a busexception if the DF isn't found?
    }
    return null;
}

19 View Complete Implementation : ResourceAdapterImplTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testStopWithNonEmptyBusCache() throws Exception {
    ResourceAdapterImpl rai = new ResourceAdapterImpl();
    rai.setBusCache(new HashSet<>());
    Bus bus = EasyMock.createMock(Bus.clreplaced);
    bus.shutdown(true);
    EasyMock.expectLastCall();
    EasyMock.replay(bus);
    rai.registerBus(bus);
    rai.stop();
    EasyMock.verify(bus);
}

19 View Complete Implementation : WebServiceConfig.java
Copyright Apache License 2.0
Author : apache
@Configuration
public clreplaced WebServiceConfig {

    @Autowired
    private Bus bus;

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, new HelloPortImpl());
        endpoint.publish("/Hello");
        return endpoint;
    }
}

19 View Complete Implementation : JaxWsDynamicClientFactory.java
Copyright Apache License 2.0
Author : apache
/**
 * Create a new instance using a default <tt>Bus</tt>.
 *
 * @return the new instance
 * @see CXFBusFactory#getDefaultBus()
 */
public static JaxWsDynamicClientFactory newInstance() {
    Bus bus = BusFactory.getThreadDefaultBus();
    return new JaxWsDynamicClientFactory(bus);
}

19 View Complete Implementation : AsyncHttpTransportFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target, Bus bus) throws IOException {
    HTTPConduit conduit = null;
    // need to updated the endpointInfo
    endpointInfo.setAddress(getAddress(endpointInfo));
    conduit = factory.createConduit(bus, endpointInfo, target);
    // Spring configure the conduit.
    String address = conduit.getAddress();
    if (address != null && address.indexOf('?') != -1) {
        address = address.substring(0, address.indexOf('?'));
    }
    HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.clreplaced);
    if (c1 != null) {
        c1.configure(conduit.getBeanName(), address, conduit);
    }
    configure(bus, conduit, conduit.getBeanName(), address);
    conduit.finalizeConfig();
    return conduit;
}

19 View Complete Implementation : ConfiguredEndpointTest.java
Copyright Apache License 2.0
Author : apache
private void initializeBus() {
    Bus bus = BusFactory.getDefaultBus();
    SoapBindingFactory bindingFactory = new SoapBindingFactory();
    bus.getExtension(BindingFactoryManager.clreplaced).registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.clreplaced);
    SoapTransportFactory soapDF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
    LocalTransportFactory localTransport = new LocalTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
}

19 View Complete Implementation : TestBase.java
Copyright Apache License 2.0
Author : apache
protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(wsdlUrl);
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.clreplaced);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.clreplaced);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.clreplaced);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.clreplaced)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.clreplaced)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}

19 View Complete Implementation : ListBussesCommand.java
Copyright Apache License 2.0
Author : apache
@Override
public Object execute() throws Exception {
    List<Bus> busses = getBusses();
    ShellTable table = new ShellTable();
    if (terminal != null && terminal.getWidth() > 0) {
        table.size(terminal.getWidth());
    }
    table.column("Name");
    table.column("State");
    for (Bus bus : busses) {
        String name = bus.getId();
        String state = bus.getState().toString();
        table.addRow().addContent(name, state);
    }
    table.print(System.out, !noFormat);
    return null;
}

19 View Complete Implementation : PolicyExtensionsTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testCXF4258() {
    Bus bus = null;
    try {
        bus = new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/disable-policy-bus.xml", false);
        replacedertionBuilderRegistry abr = bus.getExtension(replacedertionBuilderRegistry.clreplaced);
        replacedertNotNull(abr);
        PolicyEngine e = bus.getExtension(PolicyEngine.clreplaced);
        replacedertNotNull(e);
        replacedertNoPolicyInterceptors(bus.getInInterceptors());
        replacedertNoPolicyInterceptors(bus.getInFaultInterceptors());
        replacedertNoPolicyInterceptors(bus.getOutFaultInterceptors());
        replacedertNoPolicyInterceptors(bus.getOutInterceptors());
    } finally {
        if (null != bus) {
            bus.shutdown(true);
            BusFactory.setDefaultBus(null);
        }
    }
}

19 View Complete Implementation : SpringBusFactoryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testDefault() {
    Bus bus = new SpringBusFactory().createBus();
    replacedertNotNull(bus);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.clreplaced);
    replacedertNotNull("No binding factory manager", bfm);
    replacedertNotNull("No configurer", bus.getExtension(Configurer.clreplaced));
    replacedertNotNull("No resource manager", bus.getExtension(ResourceManager.clreplaced));
    replacedertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.clreplaced));
    replacedertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.clreplaced));
    replacedertNotNull("No phase manager", bus.getExtension(PhaseManager.clreplaced));
    replacedertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.clreplaced));
    replacedertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.clreplaced));
    replacedertNotNull("No service registry", bus.getExtension(ServerRegistry.clreplaced));
    try {
        bfm.getBindingFactory("http://cxf.apache.org/unknown");
    } catch (BusException ex) {
    // expected
    }
    replacedertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
    replacedertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
    replacedertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
    replacedertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
}

19 View Complete Implementation : JAXRSClientFactoryBeanTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testInvokePathEmptyAllowed() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    bus.setProperty("allow.empty.path.template.value", true);
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setBus(bus);
    bean.setAddress("http://bar");
    bean.setResourceClreplaced(BookInterface.clreplaced);
    BookInterface store = bean.create(BookInterface.clreplaced);
    replacedertNotNull(store.getBook(""));
}

19 View Complete Implementation : CodeFirstWSDLTest.java
Copyright Apache License 2.0
Author : apache
private Definition createService(Clreplaced<?> clazz) throws Exception {
    JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz);
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info);
    Bus bus = getBus();
    bean.setBus(bus);
    Service service = bean.create();
    InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
    replacedertEquals(5, i.getOperations().size());
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setServiceBean(clazz.newInstance());
    svrFactory.setAddress(address);
    svrFactory.create();
    Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
    replacedertEquals(1, bindings.size());
    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
    return wsdlBuilder.build();
}