本文整理汇总了Java中org.apache.qpid.proton.engine.Connection.setHostname方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.setHostname方法的具体用法?Java Connection.setHostname怎么用?Java Connection.setHostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Connection
的用法示例。
在下文中一共展示了Connection.setHostname方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import org.apache.qpid.proton.engine.Connection; //导入方法依赖的package包/类
private <T extends Link> T resolve(String remote, String local,
LinkResolver<T> resolver,
LinkConstructor<T> constructor) {
String host = remote.substring(2).split("/", 2)[0];
T link = resolver.resolve(remote);
if (link == null) {
Connection conn = connections.get(host);
if (conn == null) {
conn = Connection.Factory.create();
conn.collect(collector);
conn.setHostname(host);
conn.open();
connections.put(host, conn);
}
Session ssn = conn.session();
ssn.open();
link = constructor.create(ssn, remote, local);
link.open();
}
return link;
}
示例2: testOutputTooBigToBeWrittenInOneGo
import org.apache.qpid.proton.engine.Connection; //导入方法依赖的package包/类
@Test
public void testOutputTooBigToBeWrittenInOneGo()
{
int smallMaxFrameSize = 512;
_transport = new TransportImpl(smallMaxFrameSize);
Connection conn = new ConnectionImpl();
_transport.bind(conn);
// Open frame sized in order to produce a frame that will almost fill output buffer
conn.setHostname(stringOfLength("x", 500));
conn.open();
// Close the connection to generate a Close frame which will cause an overflow
// internally - we'll get the remaining bytes on the next interaction.
conn.close();
ByteBuffer buf = _transport.getOutputBuffer();
assertEquals("Expecting buffer to be full", smallMaxFrameSize, buf.remaining());
buf.position(buf.limit());
_transport.outputConsumed();
buf = _transport.getOutputBuffer();
assertTrue("Expecting second buffer to have bytes", buf.remaining() > 0);
assertTrue("Expecting second buffer to not be full", buf.remaining() < Transport.MIN_MAX_FRAME_SIZE);
}
示例3: createEndpoint
import org.apache.qpid.proton.engine.Connection; //导入方法依赖的package包/类
@Override
protected Connection createEndpoint(JmsConnectionInfo resourceInfo) {
String hostname = getParent().getVhost();
if (hostname == null) {
hostname = getParent().getRemoteURI().getHost();
} else if (hostname.isEmpty()) {
hostname = null;
}
Map<Symbol, Object> props = new LinkedHashMap<Symbol, Object>();
props.put(AmqpSupport.PRODUCT, MetaDataSupport.PROVIDER_NAME);
props.put(AmqpSupport.VERSION, MetaDataSupport.PROVIDER_VERSION);
props.put(AmqpSupport.PLATFORM, MetaDataSupport.PLATFORM_DETAILS);
Connection connection = getParent().getProtonConnection();
connection.setHostname(hostname);
connection.setContainer(resourceInfo.getClientId());
connection.setDesiredCapabilities(new Symbol[] { SOLE_CONNECTION_CAPABILITY, DELAYED_DELIVERY, ANONYMOUS_RELAY, SHARED_SUBS});
connection.setProperties(props);
return connection;
}
示例4: performConnectionOpen
import org.apache.qpid.proton.engine.Connection; //导入方法依赖的package包/类
private void performConnectionOpen(Connection connection, InputStream in, OutputStream out) throws IOException, LoginException {
connection.setHostname(saslHostname);
connection.setContainer(container);
connection.open();
writeToNetwork(connection, out);
readFromNetwork(connection, in, () -> connection.getRemoteState() == EndpointState.UNINITIALIZED);
}
示例5: handleOpen
import org.apache.qpid.proton.engine.Connection; //导入方法依赖的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);
}