本文整理汇总了Java中org.apache.qpid.proton.engine.Transport.bind方法的典型用法代码示例。如果您正苦于以下问题:Java Transport.bind方法的具体用法?Java Transport.bind怎么用?Java Transport.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Transport
的用法示例。
在下文中一共展示了Transport.bind方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetTransportWithDeliveryContext
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void testGetTransportWithDeliveryContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
Session session = connection.session();
Sender sender = session.sender("mySender");
Delivery delivery = sender.delivery("tag".getBytes());
EventImpl event = createEvent(delivery, Event.Type.DELIVERY);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例2: test
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void test()
{
Connection connection1 = Proton.connection();
Connection connection2 = Proton.connection();;
Transport transport1 = Proton.transport();
transport1.bind(connection1);
Transport transport2 = Proton.transport();
transport2.bind(connection2);
assertEquals(EndpointState.UNINITIALIZED, connection1.getLocalState());
assertEquals(EndpointState.UNINITIALIZED, connection1.getRemoteState());
connection1.open();
connection2.open();
}
示例3: selected
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
public void selected() throws IOException {
SocketChannel sock = socket.accept();
System.out.println("ACCEPTED: " + sock);
Connection conn = Connection.Factory.create();
conn.collect(collector);
Transport transport = Transport.Factory.create();
Sasl sasl = transport.sasl();
sasl.setMechanisms("ANONYMOUS");
sasl.server();
sasl.done(Sasl.PN_SASL_OK);
transport.bind(conn);
new ChannelHandler(sock, SelectionKey.OP_READ, transport);
}
示例4: makeTransport
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private static Transport makeTransport(Connection conn) {
Transport transport = Transport.Factory.create();
Sasl sasl = transport.sasl();
sasl.setMechanisms("ANONYMOUS");
sasl.client();
transport.bind(conn);
return transport;
}
示例5: handleOpen
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private void handleOpen(Reactor reactor, Event event) {
Connection connection = event.getConnection();
if (connection.getRemoteState() != EndpointState.UNINITIALIZED) {
return;
}
// Outgoing Reactor connections set the virtual host automatically using the
// following rules:
String vhost = connection.getHostname();
if (vhost == null) {
// setHostname never called, use the host from the connection's
// socket address as the default virtual host:
String conAddr = reactor.getConnectionAddress(connection);
if (conAddr != null) {
Address addr = new Address(conAddr);
connection.setHostname(addr.getHost());
}
} else if (vhost.isEmpty()) {
// setHostname called explictly with a null string. This allows
// the application to completely avoid sending a virtual host
// name
connection.setHostname(null);
} else {
// setHostname set by application - use it.
}
Transport transport = Proton.transport();
int maxFrameSizeOption = reactor.getOptions().getMaxFrameSize();
if (maxFrameSizeOption != 0) {
transport.setMaxFrameSize(maxFrameSizeOption);
}
if (reactor.getOptions().isEnableSaslByDefault()) {
Sasl sasl = transport.sasl();
sasl.client();
sasl.setMechanisms("ANONYMOUS");
}
transport.bind(connection);
}
示例6: testGetTransportWithConnectionContext
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void testGetTransportWithConnectionContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
EventImpl event = createEvent(connection, Event.Type.CONNECTION_BOUND);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例7: testGetTransportWithTransportContext
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void testGetTransportWithTransportContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
EventImpl event = createEvent(transport, Event.Type.TRANSPORT);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例8: testGetTransportWithSessionContext
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void testGetTransportWithSessionContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
Session session = connection.session();
EventImpl event = createEvent(session, Event.Type.SESSION_INIT);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例9: testGetTransportWithLinkContext
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Test
public void testGetTransportWithLinkContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
Session session = connection.session();
Link link = session.receiver("myReceiver");
EventImpl event = createEvent(link, Event.Type.LINK_INIT);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例10: login
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public boolean login() throws LoginException {
boolean success = false;
try {
List<X509Certificate> certs = new ArrayList<>();
if(isAuthenticatedUsingCerts(certs)) {
success = populateUserAndRolesFromCert(certs.get(0));
} else {
Transport transport = Proton.transport();
Connection connection = Proton.connection();
transport.bind(connection);
Sasl sasl = transport.sasl();
sasl.client();
Socket socket = createSocket();
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();
transport.open();
// write Headers
writeToNetwork(connection, out);
SaslMechanism mechanism = chooseSaslMechanismAndSendInit(connection, in, out);
performSaslSteps(connection, in, out, mechanism);
if (isSaslAuthenticated(connection, mechanism)) {
performConnectionOpen(connection, in, out);
getUserAndRolesFromConnection(connection);
success = true;
} else {
LOG.debug("Login failed");
}
connection.close();
transport.close();
socket.close();
}
} catch (IOException | UnsupportedCallbackException | InvalidNameException e) {
LoginException loginException = new LoginException("Exception attempting to authenticate using SASL delegation");
loginException.initCause(e);
LOG.warn(e);
throw loginException;
}
loginSucceeded = success;
return success;
}
示例11: run
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
@Override
public void run(Selectable selectable) {
Reactor reactor = selectable.getReactor();
try {
SocketChannel socketChannel = ((ServerSocketChannel)selectable.getChannel()).accept();
if (socketChannel == null) {
throw new ReactorInternalException("Selectable readable, but no socket to accept");
}
Handler handler = BaseHandler.getHandler(AcceptorImpl.this);
if (handler == null) {
handler = reactor.getHandler();
}
Connection conn = reactor.connection(handler);
Record conn_recs = conn.attachments();
conn_recs.set(CONNECTION_ACCEPTOR_KEY, Acceptor.class, AcceptorImpl.this);
InetSocketAddress peerAddr = (InetSocketAddress)socketChannel.getRemoteAddress();
if (peerAddr != null) {
Address addr = new Address();
addr.setHost(peerAddr.getHostString());
addr.setPort(Integer.toString(peerAddr.getPort()));
conn_recs.set(ReactorImpl.CONNECTION_PEER_ADDRESS_KEY, Address.class, addr);
}
Transport trans = Proton.transport();
int maxFrameSizeOption = reactor.getOptions().getMaxFrameSize();
if (maxFrameSizeOption != 0) {
trans.setMaxFrameSize(maxFrameSizeOption);
}
if(reactor.getOptions().isEnableSaslByDefault()) {
Sasl sasl = trans.sasl();
sasl.server();
sasl.setMechanisms("ANONYMOUS");
sasl.done(SaslOutcome.PN_SASL_OK);
}
trans.bind(conn);
IOHandler.selectableTransport(reactor, socketChannel.socket(), trans);
} catch(IOException ioException) {
sel.error();
}
}
示例12: doMultiplePemTrustCertificatesTestImpl
import org.apache.qpid.proton.engine.Transport; //导入方法依赖的package包/类
private void doMultiplePemTrustCertificatesTestImpl(String serverKeystore) throws Exception {
Transport clientTransport = Proton.transport();
Transport serverTransport = Proton.transport();
TransportPumper pumper = new TransportPumper(clientTransport, serverTransport);
Connection clientConnection = Proton.connection();
Connection serverConnection = Proton.connection();
SslDomain clientSslDomain = SslDomain.Factory.create();
clientSslDomain.init(Mode.CLIENT);
clientSslDomain.setPeerAuthentication(VerifyMode.VERIFY_PEER);
clientSslDomain.setTrustedCaDb(CA_CERTS);
clientTransport.ssl(clientSslDomain);
SslDomain serverSslDomain = SslDomain.Factory.create();
serverSslDomain.init(Mode.SERVER);
SSLContext serverSslContext = createSslContext(serverKeystore, PASSWORD, SERVER_JKS_TRUSTSTORE, PASSWORD);
serverSslDomain.setSslContext(serverSslContext);
serverTransport.ssl(serverSslDomain);
clientConnection.setContainer(CLIENT_CONTAINER);
serverConnection.setContainer(SERVER_CONTAINER);
clientTransport.bind(clientConnection);
serverTransport.bind(serverConnection);
assertConditions(clientTransport);
assertConditions(serverTransport);
clientConnection.open();
assertEndpointState(clientConnection, ACTIVE, UNINITIALIZED);
assertEndpointState(serverConnection, UNINITIALIZED, UNINITIALIZED);
assertConditions(clientTransport);
assertConditions(serverTransport);
pumper.pumpAll();
assertEndpointState(clientConnection, ACTIVE, UNINITIALIZED);
assertEndpointState(serverConnection, UNINITIALIZED, ACTIVE);
assertConditions(clientTransport);
assertConditions(serverTransport);
serverConnection.open();
assertEndpointState(clientConnection, ACTIVE, UNINITIALIZED);
assertEndpointState(serverConnection, ACTIVE, ACTIVE);
assertConditions(clientTransport);
assertConditions(serverTransport);
pumper.pumpAll();
assertEndpointState(clientConnection, ACTIVE, ACTIVE);
assertEndpointState(serverConnection, ACTIVE, ACTIVE);
assertConditions(clientTransport);
assertConditions(serverTransport);
}