/** * Récupère la liste des tâches d'un collaborateur pour l'itération choisie, et la transmet à la * JSP. * * @return URL de la page vers laquelle doit être redirigé le client. * @throws ServletException Si une erreur survient dans le controleur * @see owep.controle.CControleurBase#traiter() */ public String traiter() throws ServletException { java.util.ResourceBundle messages; messages = java.util.ResourceBundle.getBundle("MessagesBundle"); if (lProjet.getNbIterations() == 0) { String lMessage = messages.getString("AucuneIteration"); getRequete().setAttribute(CConstante.PAR_MESSAGE, lMessage); } try { // Transmet les données à la JSP d'affichage. getRequete().setAttribute(CConstante.PAR_COLLABORATEUR, mCollaborateur); getRequete().setAttribute(CConstante.PAR_PROJET, lProjet); // Sauvegarde de l'URL en session pour la liste de itérations mSession.setURLPagePrecedente("/Tache/ListeTacheVisu"); } catch (Exception eException) { eException.printStackTrace(); throw new ServletException(CConstante.EXC_TRAITEMENT); } // Ferme la connexion à la base de données. finally { try { getBaseDonnees().commit(); getBaseDonnees().close(); } catch (PersistenceException eException) { eException.printStackTrace(); throw new ServletException(CConstante.EXC_DECONNEXION); } } return "..\\JSP\\Tache\\TListeTacheVisu.jsp"; }
public void run() { try { int num = 0; stream.writeVerbose("start testing"); TestRace tr; TestRace testrace; OQLQuery oql; QueryResults qr; boolean succeed; int trials; Integer id = new Integer(5); out: for ( int i=0; i<trial; i++ ) { // create, modified, delete object try { switch ( cachetype ) { case 0: testrace = new TestRaceCount(); testrace.setId(5); break; case 1: testrace = new TestRaceTime(); testrace.setId(5); break; case 2: testrace = new TestRaceNone(); testrace.setId(5); break; case 3: testrace = new TestRaceUnlimited(); testrace.setId(5); break; default: testrace = null; } // create object //try { db.begin(); db.create( testrace ); // may throw duplicateIdentityException db.commit(); //} catch ( Exception e ) { // e.printStackTrace(); //} // load it and modify it succeed = false; trials = 0; while ( !succeed && trials < NUM_OF_RETRIAL ) { Thread.currentThread().sleep( 0 ); trials++; try { db.begin(); tr = (TestRace) db.load( _classType, id ); // may throw ObjectNotFoundException // LockNotGrantedException tr.incValue1(); db.commit(); succeed = true; } catch ( LockNotGrantedException e ) { succeed = false; // ethernet way of retry if ( db.isActive() ) db.rollback(); Thread.currentThread().sleep( (long) ((SLEEP_BASE_TIME^trials) * ran.nextDouble()) ); } catch ( TransactionAbortedException e ) { succeed = false; // ethernet way of retry if ( db.isActive() ) db.rollback(); Thread.currentThread().sleep( (long) ((SLEEP_BASE_TIME^trials) * ran.nextDouble()) ); } } if ( db.isActive() ) db.rollback(); // load it and release it succeed = false; trials = 0; while ( !succeed && trials < NUM_OF_RETRIAL ) { Thread.currentThread().sleep( 0 ); trials++; try { db.begin(); tr = (TestRace) db.load( _classType, id ); // may throw ObjectNotFoundException // LockNotGrantedException db.commit(); succeed = true; } catch ( LockNotGrantedException e ) { succeed = false; // ethernet way of retry if ( db.isActive() ) db.rollback(); Thread.currentThread().sleep( (long) ((SLEEP_BASE_TIME^trials) * ran.nextDouble()) ); } } if ( db.isActive() ) db.rollback(); // load it and delete it succeed = false; trials = 0; while ( !succeed && trials < NUM_OF_RETRIAL ) { Thread.currentThread().sleep( 0 ); trials++; try { db.begin(); tr = (TestRace) db.load( _classType, id ); // may throw ObjectNotFoundException // LockNotGrantedException db.remove( tr ); db.commit(); succeed = true; } catch ( LockNotGrantedException e ) { succeed = false; if ( db.isActive() ) db.rollback(); Thread.currentThread().sleep( (long) ((SLEEP_BASE_TIME^trials) * ran.nextDouble()) ); } catch ( TransactionAbortedException e ) { succeed = false; // ethernet way of retry if ( db.isActive() ) db.rollback(); Thread.currentThread().sleep( (long) ((SLEEP_BASE_TIME^trials) * ran.nextDouble()) ); } } if ( db.isActive() ) db.rollback(); if ( !succeed ) throw new Exception("Transaction can't not lock the object within "+trials+" trials"); } catch ( TransactionNotInProgressException e ) { stream.writeVerbose( "Thread <CreateDelete> will be killed. Unexcepted exception: "+e.getException() ); e.printStackTrace(); if ( db.isActive() ) try { db.rollback(); } catch ( TransactionNotInProgressException ee ) {} _errLeak = true; break out; } catch ( PersistenceException e ) { stream.writeVerbose( "Thread <CreateDelete> will be killed. Unexcepted exception: " ); e.printStackTrace(); if ( db.isActive() ) try { db.rollback(); } catch ( TransactionNotInProgressException ee ) {} _errLeak = true; break out; } catch ( Exception e ) { stream.writeVerbose( "Thread <CreateDelete> will be killed. Element not found: other exception: "+e ); e.printStackTrace(); if ( db.isActive() ) try { db.rollback(); } catch ( TransactionNotInProgressException ee ) {} _errLeak = true; break out; } } } finally { isDone = true; } }