-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintServiceFactoryServer.java
More file actions
30 lines (26 loc) · 1.03 KB
/
PrintServiceFactoryServer.java
File metadata and controls
30 lines (26 loc) · 1.03 KB
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
import java.net.*;
import java.rmi.*;
import java.rmi.registry.*;
/*
* Qui si da vita al processo Server.
*/
public class PrintServiceFactoryServer {
public static void main(String[] args) {
try {
// Viene creato un oggetto concreto di tipo PrintServiceFactoryImpl (sarebbe il punto di accesso del client per la creazione degli oggetti remoti)
PrintServiceFactory psf = new PrintServiceFactoryImpl();
// Si avvia il registro che è ospitato dal processo server
LocateRegistry.createRegistry(1099);
// L'oggetto viene caricato nel registro con il nome di printservicefactory
Naming.bind("rmi://127.0.0.1/printservicefactory", psf);
} catch(AccessException e) {
System.err.println("Bind operation not permitted");
} catch (RemoteException e) {
System.err.println("Registry could not be contacted");
} catch (MalformedURLException e) {
System.err.println("Wrong URL for binding");
} catch (AlreadyBoundException e) {
System.err.println("Object alreay bound to the registry");
}
}
}