2 * Package with the business logic of the application.
6 import java.awt.BorderLayout;
7 import java.awt.FlowLayout;
10 import javax.swing.JButton;
11 import javax.swing.JDialog;
12 import javax.swing.JPanel;
13 import javax.swing.border.EmptyBorder;
15 import configuration.ConfigXML;
17 import javax.swing.JTextArea;
18 import javax.xml.ws.Endpoint;
21 import java.awt.event.ActionListener;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.WindowAdapter;
24 import java.awt.event.WindowEvent;
27 * It runs the business logic server as a separate process.
29 public class BusinessLogicServer extends JDialog {
34 private static final long serialVersionUID = 1L;
35 private final JPanel contentPanel = new JPanel();
40 public static void main(String[] args) {
42 BusinessLogicServer dialog = new BusinessLogicServer();
43 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
44 dialog.setVisible(true);
45 } catch (Exception e) {
51 public BusinessLogicServer() {
52 addWindowListener(new WindowAdapter() {
54 public void windowClosed(WindowEvent arg0) {
58 setTitle("BusinessLogicServer: running the business logic");
59 setBounds(100, 100, 486, 209);
60 getContentPane().setLayout(new BorderLayout());
61 contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
62 getContentPane().add(contentPanel, BorderLayout.CENTER);
63 contentPanel.setLayout(new BorderLayout(0, 0));
65 textArea = new JTextArea();
66 contentPanel.add(textArea);
69 JPanel buttonPane = new JPanel();
70 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
71 getContentPane().add(buttonPane, BorderLayout.SOUTH);
73 JButton okButton = new JButton("OK");
74 okButton.addActionListener(new ActionListener() {
75 public void actionPerformed(ActionEvent e) {
76 textArea.append("\n\n\nClosing the server... ");
83 okButton.setActionCommand("OK");
84 buttonPane.add(okButton);
85 getRootPane().setDefaultButton(okButton);
88 JButton cancelButton = new JButton("Cancel");
89 cancelButton.setActionCommand("Cancel");
90 buttonPane.add(cancelButton);
94 ConfigXML c=ConfigXML.getInstance();
96 if (c.isBusinessLogicLocal()) {
97 textArea.append("\nERROR, the business logic is configured as local");
104 if (!c.isDatabaseLocal()) {
105 System.out.println("\nWARNING: Please be sure ObjectdbManagerServer is launched\n in machine: "+c.getDatabaseNode()+" port: "+c.getDatabasePort()+"\n");
108 service= "http://"+c.getBusinessLogicNode() +":"+ c.getBusinessLogicPort()+"/ws/"+c.getBusinessLogicName();
110 Endpoint.publish(service, new BLFacadeImplementation());
114 catch (Exception e) {
115 System.out.println("Error in BusinessLogicServer: "+e.toString());
116 textArea.append("\nYou should have not launched DBManagerServer...\n");
117 textArea.append("\n\nOr maybe there is a BusinessLogicServer already launched...\n");
121 textArea.append("Running service at:\n\t" + service);
122 textArea.append("\n\n\nPress button to exit this server... ");
124 } catch (Exception e) {
125 textArea.append(e.toString());