Ejemplo n.º 1
0
 /*
  * This method will be invoked through the SpaceListener interface we registered once
  * we noticed we had an 'in' queue.
  */
 @Override
 public void notify(Object key, Object value) {
   Object obj = sp.inp(key);
   if (obj instanceof ISOMsg) {
     ISOMsg m = (ISOMsg) obj;
     if ("LAST".equals(sendMethod)) {
       try {
         ISOChannel c = server.getLastConnectedISOChannel();
         if (c == null) {
           throw new ISOException("Server has no active connections");
         }
         if (!c.isConnected()) {
           throw new ISOException("Client disconnected");
         }
         c.send(m);
       } catch (Exception e) {
         getLog().warn("notify", e);
       }
     } else if ("ALL".equals(sendMethod)) {
       String channelNames = getISOChannelNames();
       if (channelNames != null) {
         StringTokenizer tok = new StringTokenizer(channelNames, " ");
         while (tok.hasMoreTokens()) {
           try {
             ISOChannel c = server.getISOChannel(tok.nextToken());
             if (c == null) {
               throw new ISOException("Server has no active connections");
             }
             if (!c.isConnected()) {
               throw new ISOException("Client disconnected");
             }
             c.send(m);
           } catch (Exception e) {
             getLog().warn("notify", e);
           }
         }
       }
     }
   }
 }