service.getServiceInfos().get(0).addBinding(bindingInfo); ei = new EndpointInfo(service.getServiceInfos().get(0), transportId); ei.setName(portName); ei.setAddress(address);
public void stopServer(Server server) { String uri = "local://" + server.toString(); EndpointInfo ei = new EndpointInfo(); ei.setAddress(uri); try { Destination destination = getDestinationFactory().getDestination(ei, bus); destination.shutdown(); } catch (IOException e) { LOG.log(Level.WARNING, "Could not shutdown local destination.", e); } }
public static EndpointInfo createEndpointInfo(Bus bus, ServiceInfo serviceInfo, BindingInfo bindingInfo, String address) { String transportURI = getTransportId(bus, address); EndpointInfo endpointInfo = new EndpointInfo(serviceInfo, transportURI); if (address != null) { endpointInfo.setName(new QName(address)); endpointInfo.setAddress(address); } System.out.println("seting binding info:" + bindingInfo); endpointInfo.setBinding(bindingInfo); return endpointInfo; }
private EndpointInfo getEPInfo(Message message) { Endpoint ep = message.getExchange().getEndpoint(); return (ep == null) ? new EndpointInfo() : ep.getEndpointInfo(); }
private WebSocketDestination(final AbstractHTTPDestination delegate, final WebSocketRegistry registry) throws IOException { super(delegate.getBus(), registry, new EndpointInfo(), delegate.getPath(), false); this.delegate = delegate; this.cproviderFactory = new WebSocketContinuationFactory(registry); }
private EndpointInfo getEPInfo(Message message) { Endpoint ep = message.getExchange().getEndpoint(); return (ep == null) ? new EndpointInfo() : ep.getEndpointInfo(); }
@Override protected Client createClient() throws CreateException, Exception { String uri = getAddress(); int idx = uri.indexOf('?'); if (idx != -1) { uri = uri.substring(0, idx); } // remove username/password idx = uri.indexOf('@'); int slashIdx = uri.indexOf("//"); if (idx != -1 && slashIdx != -1) { uri = uri.substring(0, slashIdx + 2) + uri.substring(idx + 1); } EndpointInfo ei = new EndpointInfo(); ei.setAddress(uri); DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class); DestinationFactory df = dfm.getDestinationFactoryForUri(uri); if (df == null) { throw new Exception("Could not find a destination factory for uri " + uri); } Destination dest = df.getDestination(ei); MessageObserver mo = dest.getMessageObserver(); if (mo instanceof ChainInitiationObserver) { ChainInitiationObserver cMo = (ChainInitiationObserver) mo; Endpoint cxfEP = cMo.getEndpoint(); return new ClientImpl(getBus(), cxfEP); } else { throw new Exception("Could not create client! No Server was found directly on the endpoint: " + uri); } }
public static Endpoint getEndpoint(DestinationFactory df, String uri) throws IOException, EndpointNotFoundException { int idx = uri.indexOf('?'); if (idx != -1) { uri = uri.substring(0, idx); } EndpointInfo ei = new EndpointInfo(); ei.setAddress(uri); Destination d = df.getDestination(ei); if (d.getMessageObserver() == null) { // TODO is this the right Mule exception? throw new EndpointNotFoundException(uri); } MessageObserver mo = d.getMessageObserver(); if (!(mo instanceof ChainInitiationObserver)) { throw new EndpointNotFoundException(uri); } ChainInitiationObserver co = (ChainInitiationObserver) mo; return co.getEndpoint(); } }
public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); os.write(message); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); os.close(); return obs.getResponseStream().toByteArray(); }
public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); os.write(message); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); os.close(); return obs.getResponseStream().toByteArray(); }
public static Endpoint getEndpoint(DestinationFactory df, String uri) throws IOException, EndpointNotFoundException { int idx = uri.indexOf('?'); if (idx != -1) { uri = uri.substring(0, idx); } EndpointInfo ei = new EndpointInfo(); ei.setAddress(uri); Destination d = df.getDestination(ei); if (d.getMessageObserver() == null) { // TODO is this the right Mule exception? throw new EndpointNotFoundException(uri); } MessageObserver mo = d.getMessageObserver(); if (!(mo instanceof ChainInitiationObserver)) { throw new EndpointNotFoundException(uri); } ChainInitiationObserver co = (ChainInitiationObserver) mo; return co.getEndpoint(); }
public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei, getBus()); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); os.write(message); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); os.close(); return obs.getResponseStream().toByteArray(); }
public byte[] invokeBytes(String address, String transport, String message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); InputStream is = getResourceAsStream(message); if (is == null) { throw new RuntimeException("Could not find resource " + message); } IOUtils.copy(is, os); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); is.close(); os.close(); byte[] bs = obs.getResponseStream().toByteArray(); return bs; } public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception {
public void startServer(Server server) { Endpoint endpoint = server.getEndpoint(); Service service = endpoint.getService(); // synthesize a new binding BindingInfo bi = bindingFactory.createBindingInfo(service, ObjectBindingFactory.BINDING_ID, configuration); Binding binding = bindingFactory.createBinding(bi); String uri = "local://" + server.toString(); EndpointInfo ei = new EndpointInfo(); ei.setAddress(uri); try { // Register a new Destination locally for the Server Destination destination = getDestinationFactory().getDestination(ei, bus); destination.setMessageObserver(new OverrideBindingObserver(endpoint, binding, bus)); } catch (IOException e1) { LOG.log(Level.WARNING, "Could not create local destination.", e1); } }
public byte[] invokeBytes(String address, String transport, String message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); InputStream is = getResourceAsStream(message); if (is == null) { throw new RuntimeException("Could not find resource " + message); } IOUtils.copy(is, os); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); is.close(); os.close(); byte[] bs = obs.getResponseStream().toByteArray(); return bs; } public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception {
public byte[] invokeBytes(String address, String transport, String message) throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport); Conduit conduit = conduitInit.getConduit(ei, getBus()); TestMessageObserver obs = new TestMessageObserver(); conduit.setMessageObserver(obs); Message m = new MessageImpl(); conduit.prepare(m); OutputStream os = m.getContent(OutputStream.class); InputStream is = getResourceAsStream(message); if (is == null) { throw new RuntimeException("Could not find resource " + message); } IOUtils.copy(is, os); // TODO: shouldn't have to do this. IO caching needs cleaning // up or possibly removal... os.flush(); is.close(); os.close(); return obs.getResponseStream().toByteArray(); }
/** * @param address the address * @return a Destination for the address */ private Destination getDestination(Bus bus, String address, Message message) throws IOException { Destination destination = null; DestinationFactoryManager factoryManager = bus.getExtension(DestinationFactoryManager.class); DestinationFactory factory = factoryManager.getDestinationFactoryForUri(address); if (factory != null) { Endpoint ep = message.getExchange().getEndpoint(); EndpointInfo ei = new EndpointInfo(); ei.setName(new QName(ep.getEndpointInfo().getName().getNamespaceURI(), ep.getEndpointInfo().getName().getLocalPart() + ".decoupled")); ei.setAddress(address); destination = factory.getDestination(ei, bus); Conduit conduit = ContextUtils.getConduit(null, message); if (conduit != null) { MessageObserver ob = conduit.getMessageObserver(); ob = new InterposedMessageObserver(bus, ob); destination.setMessageObserver(ob); } } return destination; } protected static class InterposedMessageObserver implements MessageObserver {
private void unregisterServStatic(String add) throws Exception { Bus bus = getStaticBus(); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); DestinationFactory df = dfm .getDestinationFactory("http://cxf.apache.org/transports/http/configuration"); EndpointInfo ei = new EndpointInfo(); ei.setAddress(add); Destination d = df.getDestination(ei, bus); d.setMessageObserver(null); }
EndpointInfo ei = new EndpointInfo(); ei.setTransportId(transportId); ei.setName(serviceFactory.getService().getName());
public void twoWayTestWithCreateMessage(final TestCaseType testcase) throws Exception { String address = testcase.getAddress(); EndpointInfo endpointInfo = new EndpointInfo(); endpointInfo.setAddress(JMSTestUtil.getFullAddress(address, broker.getBrokerURL())); JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(staticBus, endpointInfo, null); ResourceCloser closer = new ResourceCloser(); try { Connection connection = closer.register(JMSFactory.createConnection(jmsConfig)); connection.start(); Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE)); Destination targetDest = jmsConfig.getTargetDestination(session); Destination replyToDestination = jmsConfig.getReplyToDestination(session, null); JMSSender sender = JMSFactory.createJmsSender(jmsConfig, null); Message jmsMessage = JMSTestUtil.buildJMSMessageFromTestCase(testcase, session, replyToDestination); sender.sendMessage(session, targetDest, jmsMessage); Message replyMessage = JMSUtil.receive(session, replyToDestination, jmsMessage.getJMSMessageID(), 10000, true); checkReplyMessage(replyMessage, testcase); } catch (JMSException e) { throw JMSUtil.convertJmsException(e); } finally { closer.close(); } }