sysrep:rmi
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sysrep:rmi [2013/10/09 07:37] – orel | sysrep:rmi [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 99: | Line 99: | ||
| * Modifez l’interface " | * Modifez l’interface " | ||
| - | * String sayHello() throws RemoteException; | ||
| * String sayEcho(String echo) throws RemoteException; | * String sayEcho(String echo) throws RemoteException; | ||
| * Ajoutez la méthode suivante, qui manipule le type //Message// défini par l' | * Ajoutez la méthode suivante, qui manipule le type //Message// défini par l' | ||
| Line 105: | Line 104: | ||
| * Ajoutez la méthode suivante qui termine proprement le serveur. Consultez la documentation de la classe " | * Ajoutez la méthode suivante qui termine proprement le serveur. Consultez la documentation de la classe " | ||
| * void goodbye() throws RemoteException; | * void goodbye() throws RemoteException; | ||
| + | * Utilisez la methode // | ||
| * Modifiez le code du serveur pour qu'il instancie 2 objets distribués de type Hello, nommé " | * Modifiez le code du serveur pour qu'il instancie 2 objets distribués de type Hello, nommé " | ||
| * Ajoutez maintenant la méthode suivante, qui manipule un objet de type Remote, par exemple Hello, pour effectuer l' | * Ajoutez maintenant la méthode suivante, qui manipule un objet de type Remote, par exemple Hello, pour effectuer l' | ||
| Line 129: | Line 129: | ||
| __Exercice__ : | __Exercice__ : | ||
| * Faire une proposition d' | * Faire une proposition d' | ||
| - | * Implantation. Utilisez les compléments Java fournis à la fin de cette page ;-) | + | * Implantation. Utilisez les compléments Java disponibles [[sysrep: |
| + | * Quelques éléments de correction pour vous aider : [[sysrep: | ||
| + | {{ sysrep: | ||
| ====Generic Engine==== | ====Generic Engine==== | ||
| Line 161: | Line 163: | ||
| | EngineClient.java | x | | | | EngineClient.java | x | | | ||
| - | Pour mettre en oeuvre cette application, | + | Pour mettre en oeuvre cette application, |
| - | * " | + | |
| - | * " | + | |
| - | De plus, pour que le serveur télécharge dynamiquement la classe MyTask fourni par le client, il faut donner des permissions supplémentaires au serveur en installant un // | + | |
| <code java> | <code java> | ||
| Line 179: | Line 178: | ||
| </ | </ | ||
| - | __Tutoriel__ | + | En résumé, pour lancer votre application distribuée |
| - | ====Compléments Java==== | + | <code bash> |
| + | # lancement serveur | ||
| + | $ cd server | ||
| + | $ ls | ||
| + | all.policy | ||
| + | $ rmiregistry & # ou utiliser createRegistry() dans EngineServer | ||
| + | $ java -Djava.security.policy=all.policy EngineServer | ||
| - | + | # lancement client | |
| - | __Readline__ : Pour lire une chaîne de caractères sur la ligne de commande, il faut taper un truc comme ça : | + | $ cd client |
| - | + | $ ls | |
| - | < | + | |
| - | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | + | $ java -Djava.rmi.server.codebase=file:///$PWD/ EngineClient localhost # avec MyTask.class dans $PWD |
| - | try { | + | |
| - | String msg = in.readLine(); | + | |
| - | } catch(IOException e) { /* ... */ } | + | |
| - | </ | + | |
| - | + | ||
| - | __StringTokenizer__ | + | |
| - | + | ||
| - | <code java> | + | |
| - | StringTokenizer st = new StringTokenizer(" | + | |
| - | while (st.hasMoreTokens()) System.out.println(st.nextToken()); | + | |
| </ | </ | ||
| - | Affiche ici : | + | __Tutoriel__ |
| + | ====Fourmis==== | ||
| - | < | + | FIXME : Ajouter un nouvel exo sur un programme Java simulant l' |
| - | this | + | |
| - | is | + | |
| - | a | + | |
| - | test | + | |
| - | </ | + | |
| - | __HashMap and Generics__ : Voici un petit exemple d' | ||
| - | |||
| - | <code java> | ||
| - | HashMap< | ||
| - | map.put(1, " | ||
| - | map.put(2, " | ||
| - | String name = map.get(2) | ||
| - | |||
| - | for (Integer key : map.keySet()) | ||
| - | System.out.println(" | ||
| - | </ | ||
| - | |||
| - | __Intrinsic Locks and Synchronization__ : En java chaque objet dispose d'un verrou intrinséque (mutex), qui est utile pour synchroniser l' | ||
| - | |||
| - | <code java> | ||
| - | class FooBar { | ||
| - | synchronized void foo() { ...} | ||
| - | synchronized void bar() { ...} | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Soit on déclare un bloc de code " | ||
| - | |||
| - | <code java> | ||
| - | Object lock = new Object; | ||
| - | synchronized(lock) { | ||
| - | ... | ||
| - | ... | ||
| - | } | ||
| - | </ | ||
sysrep/rmi.1381304257.txt.gz · Last modified: 2024/03/18 15:05 (external edit)
