diff --git a/b6Middleware/b6middleware.install4j b/b6Middleware/b6middleware.install4j index 0baa3ba..b5a34ed 100644 --- a/b6Middleware/b6middleware.install4j +++ b/b6Middleware/b6middleware.install4j @@ -1,7 +1,7 @@ - + @@ -646,29 +646,43 @@ return console.askYesNo(message, true); - - + + - - - + + + - - + + - + + + + + + + + + + + + + + + diff --git a/b6Middleware/c4jMiddleware.jar b/b6Middleware/c4jMiddleware.jar index e475721..eba2d11 100644 Binary files a/b6Middleware/c4jMiddleware.jar and b/b6Middleware/c4jMiddleware.jar differ diff --git a/b6Middleware/src/ABSTRACT/com/commander4j/Connector/InboundConnectorABSTRACT.java b/b6Middleware/src/ABSTRACT/com/commander4j/Connector/InboundConnectorABSTRACT.java index 5c0f9c4..d5d1069 100644 --- a/b6Middleware/src/ABSTRACT/com/commander4j/Connector/InboundConnectorABSTRACT.java +++ b/b6Middleware/src/ABSTRACT/com/commander4j/Connector/InboundConnectorABSTRACT.java @@ -130,6 +130,11 @@ public boolean getEnabled() return this.enabled; } + public void resetInBoundConnectorCount() + { + inboundConnectorMessageCount = (long) 0; + } + public Boolean processInboundFile(String filename) { Boolean result = false; diff --git a/b6Middleware/src/ABSTRACT/com/commander4j/Connector/OutboundConnectorABSTRACT.java b/b6Middleware/src/ABSTRACT/com/commander4j/Connector/OutboundConnectorABSTRACT.java index 9bcdc62..1f4e3b2 100644 --- a/b6Middleware/src/ABSTRACT/com/commander4j/Connector/OutboundConnectorABSTRACT.java +++ b/b6Middleware/src/ABSTRACT/com/commander4j/Connector/OutboundConnectorABSTRACT.java @@ -34,6 +34,11 @@ public Long getOutboundConnectorCount() { return outboundConnectorCount; } + + public void resetOutBoundConnectorCount() + { + outboundConnectorCount = (long) 0; + } public OutboundInterface getOutboundInterface() { diff --git a/b6Middleware/src/com/commander4j/Interface/Mapping/Map.java b/b6Middleware/src/com/commander4j/Interface/Mapping/Map.java index 6e960fa..b693545 100644 --- a/b6Middleware/src/com/commander4j/Interface/Mapping/Map.java +++ b/b6Middleware/src/com/commander4j/Interface/Mapping/Map.java @@ -36,11 +36,23 @@ public Long getInboundMapMessageCount() public void resetOutboundMapMessageCount() { outboundMapMsgCount = (long) 0; + + int OutboundIntCount = getNumberofOutboundInterfaces(); + + if (OutboundIntCount > 0) + { + for (int x = 0; x < OutboundIntCount; x++) + { + getOutBoundInterface(x).connector.resetOutBoundConnectorCount(); + } + } } public void resetInboundMapMessageCount() { inboundMapMsgCount = (long) 0; + + getInboundInterface().connector.resetInBoundConnectorCount(); } public Long getOutboundMapMessageCount() @@ -52,23 +64,52 @@ public String toString() { int OutboundIntCount = getNumberofOutboundInterfaces(); String outboundTypeList = ""; + String outboundPathList = ""; if (OutboundIntCount > 0) { for (int x = 0; x < OutboundIntCount; x++) - { - getOutBoundInterface(x).getType(); + { if (x > 0) { outboundTypeList = outboundTypeList + "+"; } outboundTypeList = outboundTypeList + getOutBoundInterface(x).getType(); - + outboundPathList = outboundPathList + "
" +util.padString("",true,70," ")+util.padString(getOutBoundInterface(x).getType(),true,10," ")+" "+util.padString(getOutBoundInterface(x).connector.getOutboundConnectorCount().toString(),true,5," ")+" "+getOutBoundInterface(x).getOutputPath(); + +// System.out.println("----------------------------"); +// System.out.println("Map ID :"+getId()); +// System.out.println("Map Description :"+getDescription()); +// System.out.println("Map InboundMapMessageCount :"+getInboundMapMessageCount()); +// System.out.println("Map OutboundMapMessageCount :"+getOutboundMapMessageCount()); +// System.out.println("Interface ID :"+getOutBoundInterface(x).getId()); +// System.out.println("Interface Description :"+getOutBoundInterface(x).getDescription()); +// System.out.println("Connector Type :"+getOutBoundInterface(x).connector.getType()); +// System.out.println("Connector Path :"+getOutBoundInterface(x).connector.getPath()); +// System.out.println("Connector Count :"+getOutBoundInterface(x).connector.getOutboundConnectorCount()); +// System.out.println("----------------------------"); } } - return util.padString(getId(), true, 7, " ") + " " + util.padString(getDescription(), true, 70, " ") + " " + util.padString(getInboundInterface().getType(), true, 10, " ") + " " + util.padString(outboundTypeList, true, 12, " ") - + util.padString(getInboundMapMessageCount().toString(), false, 8, " ") + " " + util.padString(getOutboundMapMessageCount().toString(), false, 8, " ") + " " + getInboundInterface().getInputPath(); + + String result = ""+ + util.padString(getId(), true, 7, " ") + + " " + + util.padString(getDescription(), true, 35, " ") + + ""+ + util.padString(getInboundMapMessageCount().toString(), false, 8, " ") + + " " + "" + + util.padString(getOutboundMapMessageCount().toString(), false, 8, " ") + + " "+""+ + util.padString(getInboundInterface().getType(), true, 10, " ") + + " " + + util.padString(getInboundInterface().connector.getInboundConnectorMessageCount().toString(),true,5," ")+ + " " + + getInboundInterface().getInputPath()+outboundPathList+""; + + result = result.replace(" ", " "); + + return result; } public void setId(String ID) diff --git a/b6Middleware/src/com/commander4j/mw/StartGUI.java b/b6Middleware/src/com/commander4j/mw/StartGUI.java index 94eddb0..c50103a 100644 --- a/b6Middleware/src/com/commander4j/mw/StartGUI.java +++ b/b6Middleware/src/com/commander4j/mw/StartGUI.java @@ -24,7 +24,6 @@ import javax.swing.ListModel; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; -import javax.swing.border.BevelBorder; import javax.swing.border.EmptyBorder; import com.commander4j.Interface.Mapping.Map; @@ -37,12 +36,10 @@ public class StartGUI extends JFrame private static final long serialVersionUID = 1L; private JPanel contentPane; - // private StartMW smw = new StartMW(); private JButton btnStart; private JButton btnStop; - private JPanel panelStatus = new JPanel(); - private JLabel lblStatus = new JLabel("Ready"); - private JPanel progressBarInterface = new JPanel(); + + private JLabel lblStatus = new JLabel(); private final JLabel lblInterfaceStatus = new JLabel("Interface Status :"); private JLabel label_NoOfMaps = new JLabel(""); private JList4j listMaps = new JList4j(); @@ -61,10 +58,11 @@ private void ConfirmExit() if (question == 0) { - Common.smw.StopMiddleware(); + Common.smw.stopMaps(); System.exit(0); } - } else + } + else { System.exit(0); } @@ -83,20 +81,20 @@ private void populateList(String defaultitem) DefaultComboBoxModel defComboBoxMod = new DefaultComboBoxModel(); int sel = -1; - if (Common.smw.isRunning()) - { - for (int j = 0; j < Common.smw.cfg.getMaps().size(); j++) - { - defComboBoxMod.addElement(Common.smw.cfg.getMaps().get(j)); + for (int j = 0; j < Common.smw.cfg.getMaps().size(); j++) + { + defComboBoxMod.addElement(Common.smw.cfg.getMaps().get(j)); - } } + ListModel jList1Model = defComboBoxMod; listMaps.setModel(jList1Model); listMaps.setCellRenderer(Common.renderer_list); listMaps.ensureIndexIsVisible(sel); + + label_NoOfMaps.setText(String.valueOf(Common.smw.cfg.getMaps().size())); } public static void main(String[] args) @@ -108,9 +106,9 @@ public void run() try { frame = new StartGUI(); - + GraphicsDevice gd = Utility.getGraphicsDevice(); - + GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle screenBounds = gc.getBounds(); @@ -119,7 +117,8 @@ public void run() frame.setVisible(true); - } catch (Exception e) + } + catch (Exception e) { e.printStackTrace(); } @@ -136,16 +135,15 @@ public StartGUI() setTitle("Commander4j Middleware" + " " + StartMain.version); util.initLogging(""); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - - setSize(1319, 765); - + + setSize(1142, 662); + contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); addWindowListener(new WindowListener()); - JButton btnClose = new JButton(Common.icon_close); btnClose.setFont(new Font("Dialog", Font.PLAIN, 12)); btnClose.setText("Close"); @@ -156,7 +154,7 @@ public void actionPerformed(ActionEvent e) ConfirmExit(); } }); - btnClose.setBounds(911, 657, 150, 38); + btnClose.setBounds(863, 586, 150, 38); contentPane.add(btnClose); btnStart = new JButton(Common.icon_ok); @@ -164,7 +162,7 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) { - Common.smw.StartMiddleware(); + Common.smw.runMaps(); if (Common.smw.cfg.getMapDirectoryErrorCount() > 0) { String errorMessage = ""; @@ -176,15 +174,16 @@ public void actionPerformed(ActionEvent e) JOptionPane.showMessageDialog(frame, errorMessage, "Map Errors", JOptionPane.ERROR_MESSAGE); - } else + } + else { btnStart.setEnabled(false); btnStop.setEnabled(true); - lblStatus.setText("Running"); - label_NoOfMaps.setText(String.valueOf(Common.smw.cfg.getMaps().size())); + populateList(""); btnClose.setEnabled(false); - progressBarInterface.setBackground(new Color(0, 128, 0)); + lblStatus.setBackground(new Color(0, 128, 0)); + lblStatus.setText("Running"); } } }); @@ -193,41 +192,36 @@ public void actionPerformed(ActionEvent e) btnStart.setText("Start"); btnStart.setSelectedIcon(Common.icon_cancel); btnStart.setOpaque(true); - btnStart.setBounds(261, 657, 150, 38); + btnStart.setBounds(213, 586, 150, 38); contentPane.add(btnStart); - - panelStatus.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); - panelStatus.setBounds(0, 707, 1320, 30); - contentPane.add(panelStatus); - panelStatus.setLayout(null); - - lblStatus.setFont(new Font("Dialog", Font.PLAIN, 12)); - lblStatus.setBounds(4, 0, 1320, 25); + + lblStatus.setFont(new Font("Dialog", Font.BOLD, 12)); lblStatus.setHorizontalAlignment(SwingConstants.LEFT); - panelStatus.add(lblStatus); - - progressBarInterface.setForeground(new Color(0, 128, 0)); - progressBarInterface.setBounds(151, 15, 15, 15); - progressBarInterface.setPreferredSize(new Dimension(40, 40)); - progressBarInterface.setBackground(Color.RED); - contentPane.add(progressBarInterface); - lblInterfaceStatus.setFont(new Font("Dialog", Font.PLAIN, 12)); + lblStatus.setForeground(Color.BLACK); + lblStatus.setBounds(151, 12, 131, 22); + lblStatus.setPreferredSize(new Dimension(40, 40)); + lblStatus.setBackground(new Color (238,238,238)); + lblStatus.setOpaque(true); + lblStatus.setText("Idle"); + + contentPane.add(lblStatus); + lblInterfaceStatus.setFont(new Font("Dialog", Font.BOLD, 12)); lblInterfaceStatus.setHorizontalAlignment(SwingConstants.TRAILING); lblInterfaceStatus.setBounds(12, 12, 131, 22); contentPane.add(lblInterfaceStatus); JLabel lblNumberOfMaps = new JLabel("Number of Maps :"); - lblNumberOfMaps.setFont(new Font("Dialog", Font.PLAIN, 12)); + lblNumberOfMaps.setFont(new Font("Dialog", Font.BOLD, 12)); lblNumberOfMaps.setHorizontalAlignment(SwingConstants.TRAILING); - lblNumberOfMaps.setBounds(181, 12, 131, 22); + lblNumberOfMaps.setBounds(305, 12, 131, 22); contentPane.add(lblNumberOfMaps); - label_NoOfMaps.setBounds(319, 12, 60, 22); + label_NoOfMaps.setBounds(443, 12, 60, 22); contentPane.add(label_NoOfMaps); JScrollPane scrollPaneMaps = new JScrollPane(); - scrollPaneMaps.setBounds(0, 65, 1313, 580); + scrollPaneMaps.setBounds(0, 80, 1141, 503); contentPane.add(scrollPaneMaps); listMaps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -236,14 +230,21 @@ public void actionPerformed(ActionEvent e) JButton buttonHelp = new JButton((Icon) null); buttonHelp.setFont(new Font("Dialog", Font.PLAIN, 12)); buttonHelp.setText("Help"); - buttonHelp.setBounds(749, 657, 150, 38); + buttonHelp.setBounds(701, 586, 150, 38); contentPane.add(buttonHelp); - JLabel lblIdDescriptionType = new JLabel(" Map Id Description Input Output(s) In Out Input Path"); - lblIdDescriptionType.setForeground(Color.BLUE); - lblIdDescriptionType.setFont(new Font("Courier New", Font.PLAIN, 12)); - lblIdDescriptionType.setBounds(0, 46, 1300, 22); + JLabel lblIdDescriptionType_1 = new JLabel(" Map Map Connector Connector Path(s)"); + JLabel lblIdDescriptionType = new JLabel("Map Id Description In Out Type Count Input / Output"); + lblIdDescriptionType.setForeground(Color.BLACK); + lblIdDescriptionType.setFont(new Font("Courier New", Font.BOLD, 12)); + lblIdDescriptionType.setBounds(0, 58, 1300, 22); contentPane.add(lblIdDescriptionType); + + + lblIdDescriptionType_1.setForeground(Color.BLACK); + lblIdDescriptionType_1.setFont(new Font("Courier New", Font.BOLD, 12)); + lblIdDescriptionType_1.setBounds(0, 42, 1300, 22); + contentPane.add(lblIdDescriptionType_1); JButton btnRefresh = new JButton((Icon) null); btnRefresh.addActionListener(new ActionListener() @@ -255,7 +256,7 @@ public void actionPerformed(ActionEvent e) }); btnRefresh.setText("Refresh"); btnRefresh.setFont(new Font("Dialog", Font.PLAIN, 12)); - btnRefresh.setBounds(587, 657, 150, 38); + btnRefresh.setBounds(539, 586, 150, 38); contentPane.add(btnRefresh); btnStop = new JButton(Common.icon_cancel); @@ -264,13 +265,13 @@ public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e) { populateList(""); - Common.smw.StopMiddleware(); + Common.smw.stopMaps(); btnStart.setEnabled(true); btnStop.setEnabled(false); - lblStatus.setText("Stopped"); btnClose.setEnabled(true); - progressBarInterface.setBackground(Color.RED); + lblStatus.setBackground(Color.RED); + lblStatus.setText("Stopped"); } }); btnStop.setEnabled(false); @@ -278,7 +279,13 @@ public void actionPerformed(ActionEvent e) btnStop.setOpaque(true); btnStop.setMnemonic(KeyEvent.VK_ENTER); btnStop.setFont(new Font("Dialog", Font.PLAIN, 12)); - btnStop.setBounds(423, 657, 150, 38); + btnStop.setBounds(375, 586, 150, 38); contentPane.add(btnStop); + + Common.smw.init(); + Common.smw.loadMaps(); + + populateList(""); + } } diff --git a/b6Middleware/src/com/commander4j/mw/StartMain.java b/b6Middleware/src/com/commander4j/mw/StartMain.java index ea7ecff..0c0c938 100644 --- a/b6Middleware/src/com/commander4j/mw/StartMain.java +++ b/b6Middleware/src/com/commander4j/mw/StartMain.java @@ -16,7 +16,7 @@ public class StartMain Logger logger = org.apache.logging.log4j.LogManager.getLogger((StartMain.class)); public MiddlewareConfig cfg; - public static String version = "5.25"; + public static String version = "5.31"; Boolean running = false; LogArchiveThread archiveLog; StatusThread statusthread; @@ -28,26 +28,40 @@ public Boolean isRunning() return running; } - public Boolean StartMiddleware() + public Boolean init() { Boolean result = true; - - logger.debug("Application starting"); + + logger.debug("Application Initialisation"); + util.initLogging(""); - + logger.debug("*************************"); logger.debug("** STARTING **"); logger.debug("*************************"); - + return result; + } + + public Boolean loadMaps() + { + Boolean result = true; + cfg = new MiddlewareConfig(); cfg.loadMaps(System.getProperty("user.dir") + File.separator + "xml" + File.separator + "config" + File.separator + "config.xml"); - + logger.debug("*************************"); logger.debug("** MAPS LOADED **"); logger.debug("*************************"); - + + return result; + } + + public Boolean runMaps() + { + Boolean result = true; + if ((cfg.getMapDirectoryErrorCount() == 0) || (Common.runMode.equals("Service"))) { @@ -88,11 +102,11 @@ public Boolean StartMiddleware() Common.emailqueue.addToQueue(true,"Monitor", "Error Starting ["+Common.configName+"] "+StartMain.version+" on "+ util.getClientName(), "Errors :-\n\n"+errorMsg, ""); result = false; } - - return result; + + return result; } - - public Boolean StopMiddleware() + + public Boolean stopMaps() { Boolean result = true; diff --git a/b6Middleware/src/com/commander4j/mw/StartService.java b/b6Middleware/src/com/commander4j/mw/StartService.java index fa95f8d..ccd0cbb 100644 --- a/b6Middleware/src/com/commander4j/mw/StartService.java +++ b/b6Middleware/src/com/commander4j/mw/StartService.java @@ -17,11 +17,14 @@ public StartService() public Integer start(String[] args) { + Common.smw.init(); + Common.smw.loadMaps(); + Integer result = 0; AddShutdownHookSample sample = new AddShutdownHookSample(); sample.attachShutDownHook(); - if (Common.smw.StartMiddleware()) + if (Common.smw.runMaps()) { while (shutdown.equals(false)) @@ -30,7 +33,6 @@ public Integer start(String[] args) { JWait.oneSec(); } - } } @@ -40,7 +42,9 @@ public Integer start(String[] args) public static void main(String[] args) { Common.sservice = new StartService(); + Common.sservice.start(args); + System.exit(0); } @@ -48,7 +52,9 @@ public int stop(int exitCode) { shutdown = true; - Common.smw.StopMiddleware(); + + Common.smw.stopMaps(); + return exitCode; } @@ -65,7 +71,7 @@ public void run() logger.info("Waiting for threads to stop."); - Common.smw.StopMiddleware(); + Common.smw.stopMaps(); logger.info("All threads have stopped.");; }