Hello![]()
je dois realiser un client ftp en java ! j'ai fais un petit client qui peut aploader un fichier(ascii & bin) é j'ai fait l'interface avec netbeans
mtn je veux rassembler mon client dans un seul projet mais je veux bien l'organiser
et utiliser le pattern mvc, mais je suis pas sur de ma conception donc je vais la proposer et si vous pouvez m'aider à bien l'améliorer s'il y'a des erreurs :
package com.ftp.observer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 public interface Observable { public void ajouterObservateur(Observateur obs); public void supprimerObservateur(); public void notifierObservateur(String str); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 public interface Observateur { public void evenements(String txt); }
package com.ftp.controler
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public class AbstractControler { protected AbstarctFtp aFtp; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 public class FtpControler extends AbstractControler{ }
package com.ftp.model
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import java.util.ArrayList; import com.ftp.observer.Observable; import com.ftp.observer.Observateur; public abstract class AbstarctFtp implements Observable { private ArrayList<Observateur> listeObservateur = new ArrayList<Observateur>(); public abstract void setHost(String host); public abstract void setPasse(String passe); public abstract void setUser(String user); public abstract String getHost(); public abstract String getPasse(); public abstract String getUser(); protected abstract void seConnecter(String host) throws IOException; protected abstract void seConnecter(String host, int port) throws IOException; protected abstract void seConnecter(String host, int port, String user, String passe) throws IOException; protected abstract String lireLigne() throws IOException; protected abstract void deconnecter() throws IOException; protected abstract String pwD() throws IOException; protected abstract String liste() throws IOException; protected abstract boolean cwD(String dir) throws IOException; protected abstract boolean stor(File file) throws IOException; protected abstract boolean stor(InputStream inputStream, String filename) throws IOException; protected abstract boolean bin() throws IOException; protected abstract boolean ascii() throws IOException; public void ajouetObservateur(Observateur obs){ this.listeObservateur.add(obs); } public void supprimerObservateur(){ listeObservateur = new ArrayList<Observateur>(); } public void notifierObservateur(String str){ for(Observateur obs:listeObservateur){ obs.evenements(str); } } }package com.ftp.vue
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 public class FtpClient extends AbstarctFtp{ public synchronized void seConnecter(String host, int port, String pseudo,String password) throws IOException{ } public synchronized void disconnect() throws IOException { } public synchronized boolean stor(InputStream inputStream, String filename) throws IOException { } // et toutes les methodes abstraite de la classe mere AbstractFtp! }
que pensez-vous de ça?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 public class fenetre extends javax.swing.JFrame implements Observateur { }
:-°
voici l'architectre en uml (j'ai pas trouver un editeur rapide donc j'ai fais ça a la main j'espere qu'il soit assez claire pour que vous pouvez m'aider
![]()
Partager