3 import java.awt.BorderLayout;
4 import java.awt.FlowLayout;
5 import java.io.BufferedReader;
7 import java.io.InputStreamReader;
8 import java.rmi.Naming;
9 import java.rmi.RMISecurityManager;
10 import java.rmi.RemoteException;
12 import javax.swing.JButton;
13 import javax.swing.JDialog;
14 import javax.swing.JPanel;
15 import javax.swing.border.EmptyBorder;
17 import configuration.ConfigXML;
19 import javax.swing.JTextArea;
21 import com.db4o.ObjectServer;
22 import com.db4o.cs.Db4oClientServer;
23 import com.db4o.cs.config.ServerConfiguration;
28 import java.awt.event.ActionListener;
29 import java.awt.event.ActionEvent;
31 public class DB4oManagerServer extends JDialog {
33 private final JPanel contentPanel = new JPanel();
36 private ServerConfiguration configurationCS;
39 * Launch the application.
41 public static void main(String[] args) {
43 DB4oManagerServer dialog = new DB4oManagerServer();
44 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
45 dialog.setVisible(true);
46 } catch (Exception e) {
54 public DB4oManagerServer() {
55 setTitle("DB4oManagerServer: running the database server");
56 setBounds(100, 100, 486, 180);
57 getContentPane().setLayout(new BorderLayout());
58 contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
59 getContentPane().add(contentPanel, BorderLayout.CENTER);
60 contentPanel.setLayout(new BorderLayout(0, 0));
62 textArea = new JTextArea();
63 contentPanel.add(textArea);
66 JPanel buttonPane = new JPanel();
67 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
68 getContentPane().add(buttonPane, BorderLayout.SOUTH);
70 JButton okButton = new JButton("OK");
71 okButton.addActionListener(new ActionListener() {
72 public void actionPerformed(ActionEvent e) {
73 textArea.append("\n\n\nClosing the database... ");
76 } catch (Exception e1) {
81 okButton.setActionCommand("OK");
82 buttonPane.add(okButton);
83 getRootPane().setDefaultButton(okButton);
86 JButton cancelButton = new JButton("Cancel");
87 cancelButton.setActionCommand("Cancel");
88 buttonPane.add(cancelButton);
92 ConfigXML c=ConfigXML.getInstance();
97 if (c.getDataBaseOpenMode().equals("initialize")) new File(c.getDb4oFilename()).delete();
99 configurationCS = Db4oClientServer.newServerConfiguration();
100 configurationCS.common().activationDepth(c.getActivationDepth());
101 configurationCS.common().updateDepth(c.getUpdateDepth());
102 configurationCS.common().objectClass(Owner.class).cascadeOnDelete(true);
104 server = Db4oClientServer.openServer(configurationCS,
105 c.getDb4oFilename(),c.getDatabasePort());
107 textArea.append("\nConnection to the database '"+c.getDb4oFilename()+"' opened in port "+c.getDatabasePort());
109 server.grantAccess(c.getUser(),c.getPassword());
111 textArea.append("\nAccess granted to: "+c.getUser());
115 textArea.append("\nPress button to exit this database server... ");
117 } catch (Exception e) {
118 textArea.append("Something has happened in DB4oManagerServer: "+e.toString());