Nantes Université

Skip to content

Code dupliqué dans les classes Commande...Tache

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.tacheServiceRemote = (ITacheServiceRemote) context.lookup("TacheService/local");
			this.utilisateurServiceRemote = (IUtilisateurServiceRemote) context.lookup("UtilisateurService/local");
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void execute() throws RemoteException {
		final ITache tac = this.tacheServiceRemote.getTacheById(this.tache.getIdentifiantServeur());
		final Utilisateur uti = this.utilisateurServiceRemote.getUtilisateurById(this.tache.getCreateur().getIdentifiantServeur());

Constructeurs ont un code identique, execute() peut être réduit grace à un pattern strategy