RRRRHHHH_Code
08aaf3b19060c67249a3f3e206690c260e881713
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
package dataAccess; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.border.EmptyBorder; import com.db4o.ObjectServer; import com.db4o.cs.Db4oClientServer; import com.db4o.cs.config.ServerConfiguration; import configuration.ConfigXML; import domain.Account; import domain.Booking; import domain.Offer; import domain.Owner; import domain.RuralHouse; public class DB4oServerManager extends JDialog { /** * */ private static final long serialVersionUID = 1L; private final JPanel contentPanel = new JPanel(); JTextArea textArea; ObjectServer server; private ServerConfiguration configurationCS; /** * Launch the application. */ public static void main(String[] args) { try { DB4oServerManager dialog = new DB4oServerManager (); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } /** * Create the dialog. */ public DB4oServerManager () { setTitle("DB4oManagerServer: running the database server"); setBounds(100, 100, 486, 180); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { textArea = new JTextArea(); contentPanel.add(textArea); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.append("\n\n\nClosing the database... "); try { server.close(); } catch (Exception e1) { } System.exit(1); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } ConfigXML c=ConfigXML.getInstance(); try{ if (c.getDataBaseOpenMode().equals("initialize")) new File(c.getDb4oFilename()).delete(); configurationCS = Db4oClientServer.newServerConfiguration(); configurationCS.common().activationDepth(c.getActivationDepth()); configurationCS.common().updateDepth(c.getUpdateDepth()); configurationCS.common().objectClass(Owner.class).cascadeOnDelete(true); configurationCS.common().objectClass(Booking.class).cascadeOnUpdate(true); configurationCS.common().objectClass(RuralHouse.class) .cascadeOnUpdate(true); configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true); configurationCS.common().objectClass(Offer.class).cascadeOnUpdate(true); configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true); server = Db4oClientServer.openServer(configurationCS, c.getDb4oFilename(),c.getDatabasePort()); textArea.append("\nConnection to the database '"+c.getDb4oFilename()+"' opened in port "+c.getDatabasePort()); server.grantAccess(c.getUser(),c.getPassword()); textArea.append("\nAccess granted to: "+c.getUser()); textArea.append("\nPress button to exit this database server... "); } catch (Exception e) { textArea.append("Something has happened in DB4oManagerServer: "+e.toString()); } } } |
Commits for RRRRHHHH_CoderuralHousesDB/src/dataAccess/DB4oServerManager.java
Revision | Author | Commited | Message |
---|---|---|---|
08aaf3 ... | camjan | Wed 20 May, 2015 21:26:51 +0000 | Started with the separated DB with the given code |