Beispiel #1
0
 public void exec(CLIContext cli, String[] args) throws Exception {
   this.p = cli.getOutputStream();
   this.cli = cli;
   this.ansi = cli.getConsoleReader().getTerminal().isANSISupported();
   if (args.length == 1) {
     usage(cli);
     return;
   }
   for (int i = 1; i < args.length; i++) {
     try {
       Logger logger = (Logger) NameRegistrar.get("logger." + args[i]);
       logger.addListener(this);
     } catch (NameRegistrar.NotFoundException e) {
       cli.println("Logger " + args[i] + " not found -- ignored.");
     }
   }
   cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'});
   for (int i = 1; i < args.length; i++) {
     try {
       Logger logger = (Logger) NameRegistrar.get("logger." + args[i]);
       logger.removeListener(this);
     } catch (NameRegistrar.NotFoundException e) {
     }
   }
 }
    public void run() {

      try {

        if (muxName != null) {
          MUX destMux = (MUX) NameRegistrar.get("mux." + muxName);

          ISOMsg response = null;

          if (isInquiry(m)) {
            jum_repeat_advice = 0;
          }
          if (isAdviceRepeat(m)) {
            jum_repeat_advice++;
          }
          response = destMux.request(m, timeout);

          if (response != null) {
            try {
              if (isPaymentOrAdvice(m)) {
                // if (jum_repeat_advice > 1) {
                //    source.send(response);
                // }
              } else {
                if (isAdviceRepeat(m)) {
                  if (jum_repeat_advice > 2) {
                    source.send(response);
                  }
                } else {
                  source.send(response);
                }
              }
            } catch (IOException ex) {
              Logger.getLogger(MyListenerInquiryComplete.class.getName())
                  .log(Level.SEVERE, null, ex);
            } catch (VetoException ex) {
              Logger.getLogger(MyListenerInquiryComplete.class.getName())
                  .log(Level.SEVERE, null, ex);
            }
          }
        } else if (channelName != null) {
          Channel destChannel = (Channel) NameRegistrar.get(channelName);
          destChannel.send(m);
        }
      } catch (NotFoundException ex) {
        Logger.getLogger(MyListenerInquiryComplete.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ISOException e) {
        // evt.addMessage (e);

      }
      // Logger.log (evt);
    }
Beispiel #3
0
 private void showLoggers(CLIContext cli) {
   NameRegistrar nr = NameRegistrar.getInstance();
   int maxw = 0;
   Iterator iter = NameRegistrar.getAsMap().entrySet().iterator();
   StringBuilder sb = new StringBuilder("available loggers:");
   while (iter.hasNext()) {
     Map.Entry entry = (Map.Entry) iter.next();
     String key = (String) entry.getKey();
     if (key.startsWith("logger.") && entry.getValue() instanceof Logger) {
       sb.append(' ');
       sb.append(key.substring(7));
     }
   }
   cli.println(sb.toString());
 }
Beispiel #4
0
 private void showTMs(CLIContext cli) {
   NameRegistrar nr = NameRegistrar.getInstance();
   int maxw = 0;
   Iterator iter = NameRegistrar.getMap().entrySet().iterator();
   StringBuilder sb = new StringBuilder("available transaction managers:");
   while (iter.hasNext()) {
     Map.Entry entry = (Map.Entry) iter.next();
     String key = (String) entry.getKey();
     if (entry.getValue() instanceof TransactionManager) {
       sb.append(' ');
       sb.append(key);
     }
   }
   cli.println(sb.toString());
 }
Beispiel #5
0
  private void initServer() throws ConfigurationException {
    if (port == 0) {
      throw new ConfigurationException("Port value not set");
    }
    newChannel();
    if (channel == null) {
      throw new ConfigurationException("ISO Channel is null");
    }

    if (!(channel instanceof ServerChannel)) {
      throw new ConfigurationException(channelString + "does not implement ServerChannel");
    }

    ThreadPool pool = null;
    pool = new ThreadPool(minSessions, maxSessions);
    pool.setLogger(log.getLogger(), getName() + ".pool");

    server = new ISOServer(port, (ServerChannel) channel, pool);
    server.setLogger(log.getLogger(), getName() + ".server");
    server.setName(getName());
    if (socketFactoryString != null) {
      ISOServerSocketFactory sFac =
          (ISOServerSocketFactory) getFactory().newInstance(socketFactoryString);
      if (sFac != null && sFac instanceof LogSource) {
        ((LogSource) sFac).setLogger(log.getLogger(), getName() + ".socket-factory");
      }
      server.setSocketFactory(sFac);
    }
    getFactory().setConfiguration(server, getPersist());
    addServerSocketFactory();
    addListeners(); // ISORequestListener
    addISOServerConnectionListeners();
    NameRegistrar.register(getName(), this);
    new Thread(server).start();
  }
 @Override
 protected void initService() throws Exception {
   super.initService();
   log.info("MySql Connection Pool is initializing.....");
   pool = initMySqlConnectionPool();
   NameRegistrar.register("connection.pool.MySqlConnectionPool", this);
   log.info("MySql Connection Pool initialed.");
 }
Beispiel #7
0
 public JComponent create(UI ui, Element e) {
   try {
     TransactionManager tm =
         (TransactionManager) NameRegistrar.get(e.getAttributeValue("transaction-manager"));
     return new TMMonitor(ui, tm);
   } catch (NameRegistrar.NotFoundException ex) {
     return new JTextArea(ex.toString());
   }
 }
 public static DatabaseConnection getConnection() {
   MySqlConnectionPool mySqlPool = null;
   try {
     mySqlPool = (MySqlConnectionPool) NameRegistrar.get("connection.pool.MySqlConnectionPool");
   } catch (NotFoundException e) {
     e.printStackTrace();
   }
   if (mySqlPool == null) return null;
   return mySqlPool.getDBConnection();
 }
    public void run() {

      try {

        if (muxName != null) {
          MUX destMux = (MUX) NameRegistrar.get("mux." + muxName);

          ISOMsg response = null;

          if (isReversal(m)) {
            Thread.sleep(Long.parseLong(delay));
          }
          if (!isReversalRepeat(m)) {
            response = destMux.request(m, timeout);
          }

          if (response != null) {
            try {
              if (!isPayment(m)) {
                source.send(response);
              }

            } catch (IOException ex) {
              Logger.getLogger(MyListenerReversalDelay.class.getName()).log(Level.SEVERE, null, ex);
            } catch (VetoException ex) {
              Logger.getLogger(MyListenerReversalDelay.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        } else if (channelName != null) {
          Channel destChannel = (Channel) NameRegistrar.get(channelName);
          destChannel.send(m);
        }
      } catch (InterruptedException ex) {
        Logger.getLogger(MyListenerReversalDelay.class.getName()).log(Level.SEVERE, null, ex);
      } catch (NotFoundException ex) {
        Logger.getLogger(MyListenerReversalDelay.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ISOException e) {
        // evt.addMessage (e);

      }
      // Logger.log (evt);
    }
Beispiel #10
0
 /**
  * @param cfg
  *     <ul>
  *       <li>sequencer - a sequencer used to store counters
  *       <li>unset - space delimited list of fields to be unset
  *       <li>valid - space delimited list of valid fields
  *       <li>comma delimited list of fields to be unset when applying filter
  *       <li>xzy - property named "xyz"
  *     </ul>
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     String seqName = cfg.get("sequencer", null);
     unsetFields = ISOUtil.toIntArray(cfg.get("unset", ""));
     validFields = ISOUtil.toIntArray(cfg.get("valid", ""));
     if (seqName != null) {
       seq = (Sequencer) NameRegistrar.get("sequencer." + cfg.get("sequencer"));
     } else if (seq == null) {
       seq = new VolatileSequencer();
     }
   } catch (NameRegistrar.NotFoundException e) {
     throw new ConfigurationException(e);
   }
 }
Beispiel #11
0
 public void exec(CLIContext cli, String[] args) throws Exception {
   this.p = cli.getOutputStream();
   this.cli = cli;
   this.ansi = cli.getConsoleReader().getTerminal().isANSISupported();
   if (args.length == 1) {
     usage(cli);
     return;
   }
   for (int i = 1; i < args.length; i++) {
     try {
       Object obj = NameRegistrar.get(args[i]);
       if (obj instanceof TransactionManager) {
         ((TransactionManager) obj).addListener(this);
       } else {
         cli.println(
             "Object '"
                 + args[i]
                 + "' is not an instance of TransactionManager ("
                 + obj.toString()
                 + ")");
       }
     } catch (NameRegistrar.NotFoundException e) {
       cli.println("TransactionManager '" + args[i] + "' not found -- ignored.");
     }
   }
   cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'});
   for (int i = 1; i < args.length; i++) {
     try {
       Object obj = NameRegistrar.get(args[i]);
       if (obj instanceof TransactionManager) {
         ((TransactionManager) obj).removeListener(this);
       }
     } catch (NameRegistrar.NotFoundException ignored) {
     }
   }
 }
Beispiel #12
0
  public String getTraceNumberSequence() throws ISOException, NotFoundException {

    int maxCounter = 999999;
    int counter = 0;

    Sequencer sequencer = (Sequencer) NameRegistrar.get("sequencer.tracenumber");

    counter = sequencer.get("tracenumber");
    if (counter > maxCounter) {
      sequencer.set("tracenumber", 0);
      counter = sequencer.get("tracenumber");
    }

    Calendar c = Calendar.getInstance();

    return ISOUtil.zeropad(Integer.toString(counter), 6);
  }
Beispiel #13
0
  public String getTraceNumber() throws ISOException, NotFoundException {

    int maxCounter = 99999;
    int counter = 0;

    Sequencer sequencer = (Sequencer) NameRegistrar.get("sequencer.tracenumber");

    counter = sequencer.get("tracenumber");
    if (counter > maxCounter) {
      sequencer.set("tracenumber", 0);
      counter = sequencer.get("tracenumber");
    }

    Calendar c = Calendar.getInstance();

    return ISOUtil.zeropad(Integer.toString(c.get(Calendar.DAY_OF_MONTH)), 2)
        + ISOUtil.zeropad(Integer.toString(c.get(Calendar.MINUTE)), 2)
        + ISOUtil.zeropad(Integer.toString(c.get(Calendar.SECOND)), 2)
        + ISOUtil.zeropad(Integer.toString(c.get(Calendar.MILLISECOND)), 3)
        + ISOUtil.zeropad(Integer.toString(counter), 5);
  }
Beispiel #14
0
 public void stopService() {
   NameRegistrar.unregister(getName());
 }
Beispiel #15
0
 public void startService() {
   // we re-register just in case the component was soft-stopped
   NameRegistrar.register(getName(), this);
   new Thread(this).start();
 }
Beispiel #16
0
 public void initService() {
   NameRegistrar.register(getName(), this);
 }
Beispiel #17
0
 public boolean isAlreadySignon(String bankCode) throws NotFoundException {
   ActiveData data = (ActiveData) NameRegistrar.get("dat." + "LoggedInstitution");
   return data.search(bankCode);
 }
 @Override
 protected void stopService() throws Exception {
   NameRegistrar.unregister(getName());
 }
Beispiel #19
0
 public void setName(String name) {
   this.name = name;
   NameRegistrar.register("channel." + name, this);
 }
Beispiel #20
0
 public void start() {
   super.start();
   NameRegistrar.register("QBeanFactory." + getName(), this);
 }
Beispiel #21
0
 protected void startService() throws Exception {
   NameRegistrar.register(getName(), sm);
 }
Beispiel #22
0
 @Override
 public void destroyService() {
   NameRegistrar.unregister(getName());
   NameRegistrar.unregister("server." + getName());
 }
  @Override
  protected void startService() throws Exception {
    new Thread(new DemoThread(this)).start();

    NameRegistrar.register(getName(), this);
  }
Beispiel #24
0
 public void stop() {
   super.stop();
   NameRegistrar.unregister("QBeanFactory." + getName());
 }
  /*
   * (non-Javadoc)
   *
   * @see org.jpos.q2.QBeanSupport#startService()
   */
  public void startService() {
    ApplicationContext dependencyCtx = null;

    if ((null != springCtxDepRegistrationKey)
        && (springCtxDepRegistrationKey.trim().length() > 0)) {
      try {
        log.debug(
            String.format(
                "Spring Q2MBean '%s' : search for Spring context dependency '%s' in NameRegistrar",
                getName(), springCtxDepRegistrationKey));

        Object object = NameRegistrar.get(springCtxDepRegistrationKey);
        if (object instanceof Spring) {
          dependencyCtx = ((Spring) object).getContext();
        } else if (object instanceof ApplicationContext) {
          dependencyCtx = ((ApplicationContext) object);
        } else {
          String errMsg =
              String.format(
                  "Spring Q2MBean '%s' : spring context dependency '%s' found in NameRegistrar but is not a Spring ApplicaitonContext, neither a Spring QBean",
                  getName(), springCtxDepRegistrationKey);
          log.error(errMsg);
          throw new RuntimeException(errMsg);
        }

        log.debug(
            String.format(
                "Spring Q2MBean '%s' : Spring context dependency '%s' found in NameRegistrar",
                getName(), springCtxDepRegistrationKey));
      } catch (NotFoundException e) {
        if (!this.springCtxDepOptional) {
          log.error(
              String.format(
                  "Spring Q2MBean '%s' : spring context dependency '%s' not found in NameRegistrar",
                  getName(), springCtxDepRegistrationKey));
          throw new RuntimeException(e);
        } else {
          log.info(
              String.format(
                  "Spring Q2MBean '%s' : optional spring context dependency '%s' not found in NameRegistrar",
                  getName(), springCtxDepRegistrationKey));
        }
      }
    }

    try {
      if (null == dependencyCtx) {
        context = new FileSystemXmlApplicationContext(configFiles);
      } else {
        context = new FileSystemXmlApplicationContext(configFiles, dependencyCtx);
      }
      log.info(String.format("Spring Q2MBean '%s' : spring context has been loaded", getName()));
    } catch (BeansException e) {
      log.error(
          String.format(
              "Spring Q2MBean '%s' : an error occured while loading this spring context. Error message = %s",
              getName(), e.getMessage()));
      throw e;
    }

    NameRegistrar.register(getName(), this);
  }