Package com.sun.messaging.jmq.admin.bkrutil

Examples of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin


      }
        }
    }

    private void doPauseAllDests(BrokerDestListCObj bDestListCObj) {
  BrokerAdmin ba = bDestListCObj.getBrokerAdmin();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_DEST_PAUSE_ALL, ba.getKey()),
                acr.getString(acr.I_PAUSE_ALL_DESTS),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
            /*
             * Broker may take more time to complete the task than the specified
             * timeout value.
             * This value is used when refreshing the console in such cases.
             */
      if (!ba.isBusy())
                ba.setAssociatedObj(bDestListCObj);

            if (pauseAllDests(ba, DestType.DEST_TYPE_QUEUE, DestState.PAUSED)) {

    if (!populateBrokerDestinations((BrokerCObj)bDestListCObj.getParent())) return;

View Full Code Here


    }


    private void doPauseBroker(BrokerCObj bCObj) {

  BrokerAdmin ba = bCObj.getBrokerAdmin();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_BROKER_PAUSE, ba.getKey()),
                acr.getString(acr.I_PAUSE_BROKER),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
            /*
             * Broker may take more time to complete the task than the specified
             * timeout value.
             * This value is used when refreshing the console in such cases.
             */
      if (!ba.isBusy())
                ba.setAssociatedObj(bCObj);

            if (pauseBroker(ba)) {
                Enumeration e = bCObj.children();
                BrokerServiceListCObj bSvclCObj = null;
                while (e.hasMoreElements()) {
View Full Code Here

  return true;
    }

    private void doResumeBroker(BrokerCObj bCObj) {

  BrokerAdmin ba = bCObj.getBrokerAdmin();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_BROKER_RESUME, ba.getKey()),
                acr.getString(acr.I_RESUME_BROKER),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
            /*
             * Broker may take more time to complete the task than the specified
             * timeout value.
             * This value is used when refreshing the console in such cases.
             */
      if (!ba.isBusy())
                ba.setAssociatedObj(bCObj);

            if (resumeBroker(ba)) {
                Enumeration e = bCObj.children();
                BrokerServiceListCObj bSvclCObj = null;
                while (e.hasMoreElements()) {
View Full Code Here

        }
  return true;
    }

    private void doResumeAllDests(BrokerDestListCObj bDestListCObj) {
  BrokerAdmin ba = bDestListCObj.getBrokerAdmin();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_DEST_RESUME_ALL, ba.getKey()),
                acr.getString(acr.I_RESUME_ALL_DESTS),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
            /*
             * Broker may take more time to complete the task than the specified
             * timeout value.
             * This value is used when refreshing the console in such cases.
             */
      if (!ba.isBusy())
                ba.setAssociatedObj(bDestListCObj);

            if (resumeAllDests(ba, DestType.DEST_TYPE_QUEUE)) {

    if (!populateBrokerDestinations((BrokerCObj)bDestListCObj.getParent())) return;

View Full Code Here

      }
        }
    }

    private void doResumeDest(BrokerDestCObj bDestCObj) {
  BrokerAdmin ba = bDestCObj.getBrokerAdmin();
        DestinationInfo destInfo = bDestCObj.getDestinationInfo();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_DEST_RESUME, destInfo.name, ba.getKey()),
                acr.getString(acr.I_RESUME_DEST),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
            /*
             * Broker may take more time to complete the task than the specified
             * timeout value.
             * This value is used when refreshing the console in such cases.
             */
      if (!ba.isBusy())
                ba.setAssociatedObj(bDestCObj);

            if (resumeDest(ba, destInfo.name, destInfo.type)) {
          destInfo = queryDestinationInfo(ba, destInfo.name, destInfo.type);
    if (destInfo != null) {
                    bDestCObj.setDestinationInfo(destInfo);
View Full Code Here

        }
  return true;
    }

    private boolean refreshBrokerCObj(BrokerCObj bCObj) {
  BrokerAdmin ba = bCObj.getBrokerAdmin();
        Properties bkrProps = queryBrokerProps(ba);

        if (bkrProps != null)  {
            bCObj.setBrokerProps(bkrProps);
      return true;
View Full Code Here

        return destInfo;
    }

    private void doShutdownBroker(BrokerCObj bCObj) {

  BrokerAdmin ba = bCObj.getBrokerAdmin();

        int result = JOptionPane.showConfirmDialog(app.getFrame(),
                acr.getString(acr.Q_BROKER_SHUTDOWN, ba.getKey()),
                acr.getString(acr.I_SHUTDOWN_BROKER),
                JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.NO_OPTION)
            return;

  if (ba != null) {
      ba.setInitiator(true);

            /*
             * This value should be true only when restart is requested.
             */
            ba.setReconnect(false);

            if (shutdownBroker(ba)) {
                clearBroker(bCObj);
                app.getExplorer().nodeChanged((DefaultMutableTreeNode)bCObj);
                app.getInspector().refresh();
View Full Code Here

    ActionManager.RESUME);
    }


    public int getActiveActions()  {
  BrokerAdmin ba = getBrokerAdmin();
  int mask;
  if (ba.isConnected())
      mask = ActionManager.ADD | ActionManager.REFRESH |
        ActionManager.PAUSE | ActionManager.RESUME;
  else
      mask = 0;
View Full Code Here

  return (getActiveActions());
    }


    public int getActiveActions()  {
        BrokerAdmin ba = getBrokerAdmin();
        int mask;
        if (ba.isConnected())
            mask = ActionManager.REFRESH;
        else
            mask = 0;

        return (mask);
View Full Code Here

      return(ar.getString(ar.I_JMQCMD_TXN_STATE_UNKNOWN));
  }
    }

    private int runPause(BrokerCmdProperties brokerCmdProps) {
        BrokerAdmin   broker;
  String    input = null;
  String    yes, yesShort, no, noShort;

  yes = ar.getString(ar.Q_RESPONSE_YES);
  yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
  no = ar.getString(ar.Q_RESPONSE_NO);
  noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);

 
        broker = init();

        boolean force = brokerCmdProps.forceModeSet();

  // Check for the target argument
  String commandArg = brokerCmdProps.getCommandArg();

  if (CMDARG_BROKER.equals(commandArg)) {

            if (broker == null)  {
                Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
                return (1);
            }

            if (!force)
                broker = promptForAuthentication(broker);

            Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR));
            printBrokerInfo(broker);

      try {
    connectToBroker(broker);

            } catch (BrokerAdminException bae)  {
    handleBrokerAdminException(bae);

                Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
                return (1);
            }

            if (!force) {
                input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_BKR_OK), noShort);
                Globals.stdOutPrintln("");
            }

            if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
                try  {
                    broker.sendPauseMessage(null);
              broker.receivePauseReplyMessage();
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_SUC));

                } catch (BrokerAdminException bae)  {
        handleBrokerAdminException(bae);

                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
                    return (1);
                }

            } else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_NOOP));
                return (0);

            } else {
                Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
                Globals.stdOutPrintln("");
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_NOOP));
                return (1);
            }

  } else if (CMDARG_SERVICE.equals(commandArg)) {

            if (broker == null)  {
                Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
                return (1);
            }

            if (!force)
                broker = promptForAuthentication(broker);

      String svcName = brokerCmdProps.getTargetName();

            Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC));
      printServiceInfo();

      Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
      printBrokerInfo(broker);

            try {
                connectToBroker(broker);

            } catch (BrokerAdminException bae)  {
                handleBrokerAdminException(bae);
           
                Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
                return (1);
            }

      try {
          isAdminService(broker, svcName);

            } catch (BrokerAdminException bae)  {
    if (BrokerAdminException.INVALID_OPERATION == bae.getType())
                    bae.setBrokerErrorStr
                        (ar.getString(ar.I_ERROR_MESG) +
                         ar.getKString(ar.E_CANNOT_PAUSE_SVC, svcName));

                handleBrokerAdminException(bae);
           
                Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
                return (1);
            }

            if (!force) {
                input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_SVC_OK), noShort);
                Globals.stdOutPrintln("");
            }

            if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
                try  {
                    broker.sendPauseMessage(svcName);
        broker.receivePauseReplyMessage();
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_SUC));

                } catch (BrokerAdminException bae)  {
            handleBrokerAdminException(bae);

                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
                    return (1);
                }

            } else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_NOOP));
                return (0);

            } else {
                Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
                Globals.stdOutPrintln("");
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_NOOP));
                return (1);
            }

  } else if (CMDARG_DESTINATION.equals(commandArg)) {
      String destName, pauseTypeStr;
      BrokerCmdPrinter bcp = new BrokerCmdPrinter(2,4);
      String[] row = new String[2];
      boolean pauseAll = true;
      int destTypeMask;

      destName = brokerCmdProps.getTargetName();
      destTypeMask = getDestTypeMask(brokerCmdProps);
            pauseTypeStr = brokerCmdProps.getPauseType();

      if (destName != null)  {
    pauseAll = false;
      }

            if (broker == null)  {
    if (pauseAll)  {
                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
    } else  {
                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
    }
                return (1);
            }

            if (!force)
                broker = promptForAuthentication(broker);

      if (pauseAll)  {
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS));
      } else  {
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST));
          printDestinationInfo();
      }

      // Only print out the pause type if it was specified
      if (pauseTypeStr != null) {
                Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_USING_ATTR));

          row[0] = ar.getString(ar.I_JMQCMD_PAUSE_DST_TYPE);
                row[1] = pauseTypeStr;
          bcp.add(row);
          bcp.println();
      }


      Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
            printBrokerInfo(broker);

      try {
    connectToBroker(broker);

            } catch (BrokerAdminException bae)  {
    handleBrokerAdminException(bae);

    if (pauseAll)  {
                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
    } else  {
                    Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
    }
                return (1);
            }

            if (!force) {
    if (pauseAll)  {
                    input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_DSTS_OK), noShort);
    } else  {
                    input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_DST_OK), noShort);
    }
                Globals.stdOutPrintln("");
            }

            if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
                try  {
        int pauseType = getPauseTypeVal(pauseTypeStr);
                    broker.sendPauseMessage(destName, destTypeMask, pauseType);
              broker.receivePauseReplyMessage();
        if (pauseAll)  {
                        Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_SUC));
        } else  {
                        Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_SUC));
        }

                } catch (BrokerAdminException bae)  {
        handleBrokerAdminException(bae);

        if (pauseAll)  {
                        Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
        } else  {
                        Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
        }
                    return (1);
                }

            } else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
    if (pauseAll)  {
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_NOOP));
    } else  {
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_NOOP));
    }
                return (0);

            } else {
                Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
                Globals.stdOutPrintln("");
    if (pauseAll)  {
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_NOOP));
    } else  {
                    Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_NOOP));
    }
                return (1);
            }

  }

        broker.close();

        return (0);
    }
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.