本文整理汇总了Java中org.apache.qpid.proton.engine.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于org.apache.qpid.proton.engine包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import org.apache.qpid.proton.engine.Session; //导入依赖的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: onConnectionInit
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public void onConnectionInit(Event event) {
Connection conn = event.getConnection();
// Every session or link could have their own handler(s) if we
// wanted simply by adding the handler to the given session
// or link
Session ssn = conn.session();
// If a link doesn't have an event handler, the events go to
// its parent session. If the session doesn't have a handler
// the events go to its parent connection. If the connection
// doesn't have a handler, the events go to the reactor.
Sender snd = ssn.sender("sender");
conn.open();
ssn.open();
snd.open();
}
示例3: getConnection
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public Connection getConnection()
{
if (context instanceof Connection) {
return (Connection) context;
} else if (context instanceof Transport) {
Transport transport = getTransport();
if (transport == null) {
return null;
}
return ((TransportImpl) transport).getConnectionImpl();
} else {
Session ssn = getSession();
if (ssn == null) {
return null;
}
return ssn.getConnection();
}
}
示例4: getTransport
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public Transport getTransport()
{
if (context instanceof Transport) {
return (Transport) context;
} else if (context instanceof Connection) {
return ((Connection)context).getTransport();
} else {
Session session = getSession();
if (session == null) {
return null;
}
Connection connection = session.getConnection();
if (connection == null) {
return null;
}
return connection.getTransport();
}
}
示例5: getReactor
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public Reactor getReactor() {
if (context instanceof Reactor) {
return (Reactor) context;
} else if (context instanceof Task) {
return ((Task)context).getReactor();
} else if (context instanceof Transport) {
return ((TransportImpl)context).getReactor();
} else if (context instanceof Delivery) {
return ((Delivery)context).getLink().getSession().getConnection().getReactor();
} else if (context instanceof Link) {
return ((Link)context).getSession().getConnection().getReactor();
} else if (context instanceof Session) {
return ((Session)context).getConnection().getReactor();
} else if (context instanceof Connection) {
return ((Connection)context).getReactor();
} else if (context instanceof Selectable) {
return ((Selectable)context).getReactor();
}
return null;
}
示例6: testOpenSessionBeforeOpenConnection
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Test
public void testOpenSessionBeforeOpenConnection()
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
Session session = connection.session();
session.open();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
connection.open();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
}
示例7: testGetTransportWithDeliveryContext
import org.apache.qpid.proton.engine.Session; //导入依赖的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());
}
示例8: onRemoteClose
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public void onRemoteClose(Session session) throws Exception {
lock();
try {
session.close();
session.free();
} finally {
unlock();
}
AMQPSessionContext sessionContext = (AMQPSessionContext) session.getContext();
if (sessionContext != null) {
sessionContext.close();
sessions.remove(session);
session.setContext(null);
}
}
示例9: close
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public void close() throws NetworkException, MessagingException, TimeoutException
{
synchronized (_lock)
{
if (!_closed.get())
{
_closed.set(true);
if (_connected.get())
{
for (Session ssn : _sessions.keySet())
{
_sessions.get(ssn).closeImpl();
}
_sessions.clear();
_connection.close();
write();
closeNetworkConnection();
}
}
}
}
示例10: createSender
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
private void createSender(org.apache.qpid.proton.engine.Session session) throws Exception {
Sender sender = session.sender(subscriberInfo.getClientId());
Target target = new Target();
target.setAddress(subscriberInfo.getClientAddress());
sender.setTarget(target);
Source source = new Source();
source.setAddress(subscriberInfo.getClientAddress());
source.setDurable(TerminusDurability.UNSETTLED_STATE);
sender.setSource(source);
sender.open();
}
示例11: onSessionRemoteOpen
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public void onSessionRemoteOpen(Event evt) {
Session ssn = evt.getSession();
if (ssn.getLocalState() == EndpointState.UNINITIALIZED) {
ssn.open();
}
}
示例12: onSessionRemoteClose
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public void onSessionRemoteClose(Event evt) {
Session ssn = evt.getSession();
if (ssn.getLocalState() != EndpointState.CLOSED) {
ssn.close();
}
}
示例13: newOutgoing
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
public Sender newOutgoing(Session ssn, String remote, String local) {
Sender snd = ssn.sender(String.format("%s-%s", local, remote));
Source src = new Source();
src.setAddress(local);
snd.setSource(src);
Target tgt = new Target();
tgt.setAddress(remote);
snd.setTarget(tgt);
return snd;
}
示例14: newIncoming
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
public Receiver newIncoming(Session ssn, String remote, String local) {
Receiver rcv = ssn.receiver(String.format("%s-%s", remote, local));
Source src = new Source();
src.setAddress(remote);
rcv.setSource(src);
Target tgt = new Target();
tgt.setAddress(remote);
rcv.setTarget(tgt);
return rcv;
}
示例15: next
import org.apache.qpid.proton.engine.Session; //导入依赖的package包/类
@Override
public Session next(EnumSet<EndpointState> local, EnumSet<EndpointState> remote)
{
LinkNode.Query<SessionImpl> query = new EndpointImplQuery<SessionImpl>(local, remote);
LinkNode<SessionImpl> sessionNode = _node.next(query);
return sessionNode == null ? null : sessionNode.getValue();
}