- This project includes two programs.
- One for CORBA File Share Register Server
- Another for CORBA File Share Client with Sockets.
- The two programs can be separated and work well.
- Waiting Maven auto-building completed.
- Choose Java 8 as the Project JDK.
- Installed MySQL and Workbench.
- Prepared a MySQL connection with hostname, port, username, and password.
- Place the values of the following three constants in DatabaseConnector.java to your MySQL connection setting.
private static final String URL = "jdbc:mysql://localhost:3306/";
private static final String USERNAME = "root";
private static final String PASSWORD = "MyNewPass";
- Then Run FileRegisterServer.java
- Note the server IP of the FileRegisterServer.
- Waiting Maven auto-building completed.
- Choose Java 8 as the Project JDK.
- Place the value of the constant in FileShareClient.java to your real CORBA server IP.
private static final String CORBA_SERVER_IP_ADDRESS = "198.18.0.1";
- Then run FileShareClient.java.
- Go to the root of your computer to find the shared and received files i.e.
Users/rocky/CORBA-based-P2P-file-sharing-application
- If you are facing problems, please read Setup Details for solutions.
- This project is using Maven for Dependency management!
- See dependencies in pom.xml
- Java 8 is the best choice because the CORBA module has been removed from Java 11 or later.
- Some JDK versions report errors.
- Java 8.0.392-amzn downloaded from SDKMan is working fine for me.
mysql-connector-java
has already added to pom.xml. You can change the version.
- Place the values of the following three constants in DatabaseConnector.java.
private static final String URL = "jdbc:mysql://localhost:3306/";
private static final String USERNAME = "root";
private static final String PASSWORD = "MyNewPass";
- There is an
idlj
program that comes with the JDK for generating the stub and skeleton code in Java - Use the following command to execute FileShare.idl
idlj -fall src/main/java/FileShare.idl
- It has been added to the Java main method
- No need execution in Command Line
- No need adding argument in Run/Debug Configurations
- However, you need add your real CORBA server IP to FileShareClient.java
Runtime.getRuntime().exec("orbd -ORBInitialPort 1050 -ORBInitialHost localhost");
// Set the ORB properties programmatically
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBInitialPort", "1050");
props.put("org.omg.CORBA.ORBInitialHost", "localhost");
// create and initialize the ORB with the specified properties
ORB orb = ORB.init(args, props);
- Change to your real CORBA server IP in FileShareClient.java
private static final String CORBA_SERVER_IP_ADDRESS = "198.18.0.1";
System.out.printf("Get the file register server from %s:1050\n", CORBA_SERVER_IP_ADDRESS);
fileShare = CORBAConnector.getFileShareServer(CORBA_SERVER_IP_ADDRESS);
- Then following codes in CORBAConnector.java will work.
// Set the ORB properties programmatically
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBInitialPort", "1050");
props.put("org.omg.CORBA.ORBInitialHost", ip);
// create and initialize the ORB with the specified properties
ORB orb = ORB.init(new String[]{}, props);
- Server socket thread will be running at the backend until you stop the client program.
- It can be connected by different IPs if you have more than one interfaces, such as Ethernet, Wi-Fi, VPN, Cellular.
- The client will ask you to choose the correct IP you will use in your local network to test.
- There will be a new child thread to interact with a new client socket.
- When request file sharing, a new client socket thread will be created and connect to the server socket.
- The program will continue until last client socket thread dead.