Example #1
0
 @Override
 public void onConnectionInit(Event event) {
   Connection conn = event.getConnection();
   Session ssn = conn.session();
   Sender snd = ssn.sender("sender");
   conn.open();
   ssn.open();
   snd.open();
 }
Example #2
0
 void init() throws NetworkException {
   synchronized (_lock) {
     _collector = Collector.Factory.create();
     _transport = Transport.Factory.create();
     _connection = Connection.Factory.create();
     String id = _settings.getId();
     _connection.collect(_collector);
     _connection.setContainer(
         id == null || id.trim().equals("") ? UUID.randomUUID().toString() : id);
     _connection.setHostname(_settings.getHost());
     _transport.bind(_connection);
     Sasl sasl = _transport.sasl();
     sasl.client();
     sasl.setMechanisms(new String[] {"ANONYMOUS"});
     _connection.open();
     _connected.set(true);
     write();
   }
 }
Example #3
0
 @Override
 public org.splash.messaging.Session createSession()
     throws NetworkException, MessagingException, TimeoutException {
   synchronized (_lock) {
     if (_closed.get()) {
       throw new MessagingException("Connection is closed");
     }
     Session ssn = _connection.session();
     SessionImpl session = new SessionImpl(this, ssn);
     _sessions.put(ssn, session);
     session.init();
     return session;
   }
 }
Example #4
0
 @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();
       }
     }
   }
 }
Example #5
0
 @Override
 public String getRemoteID() {
   return _connection != null ? _connection.getRemoteContainer() : null;
 }
Example #6
0
 @Override
 public String getRemoteHostname() {
   return _connection != null ? _connection.getRemoteHostname() : null;
 }