Code dupliqué dans les classes Commande...Contexte
public CommandeCreerContexte(final String i, final IContexte co, final CallBack<IContexte> ca) {
super();
this.identification = i;
this.contexte = co;
this.callback = ca;
final Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
try {
final Context context = new InitialContext(env);
this.contexteServiceRemote = (IContexteServiceRemote) context.lookup("ContexteService/local");
this.utilisateurServiceRemote = (IUtilisateurServiceRemote) context.lookup("UtilisateurService/local");
} catch (NamingException e) {
e.printStackTrace();
}
}
@Override
public void execute() throws RemoteException {
final IContexte ctx = this.contexteServiceRemote.getContexteById(this.contexte.getIdentifiantServeur());
final Utilisateur uti = this.utilisateurServiceRemote.getUtilisateurById(this.contexte.getCreateur().getIdentifiantServeur());
Constructeurs avec un code identique. Voir si nécessité de supprimer le code rendondant dans les méthodes execute()
==> Strategy Pattern ??