Code dupliqué dans les classes Commande...Tag
this.callback = c;
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.tagServiceRemote = (ITagServiceRemote) context.lookup("TagService/local");
this.utilisateurServiceRemote = (IUtilisateurServiceRemote) context.lookup("UtilisateurService/local");
} catch (NamingException e) {
e.printStackTrace();
}
}
@Override
public void execute() throws RemoteException {
final ITag ta = this.tagServiceRemote.getTagById(this.tag.getIdentifiantServeur());
final Utilisateur uti = this.utilisateurServiceRemote.getUtilisateurById(this.tag.getCreateur().getIdentifiantServeur());
if ((ta != null) && (uti != null) && (this.identification.equalsIgnoreCase(this.tag.getCreateur().getIdentifiantServeur()))) {
Les constructeurs ont du code identique, les méthodes execute()
peuvent être redondantes aussi ==> Strategy Pattern ?