Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.Latch


    }

    public void setUp() throws Exception {
        Configuration.setConfiguration(new GeronimoLoginConfiguration());

        startLatch = new Latch();
        shutdownLatch = new Latch();
        stopLatch = new Latch();

        super.setUp();

        GBeanMBean gbean = new GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
        propertiesRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
View Full Code Here


     *
     * @param work Work to be executed.
     */
    public void doExecute(WorkerContext work)
            throws WorkException, InterruptedException {
        Latch latch = work.provideStartLatch();
        execute(work);
        latch.acquire();
    }
View Full Code Here

     *
     * @param work Work to be executed.
     */
    public void doExecute(WorkerContext work)
            throws WorkException, InterruptedException {
        Latch latch = work.provideEndLatch();
        execute(work);
        latch.acquire();
    }
View Full Code Here

        }
    }

    public void setUp() throws Exception {
        eup = new EchoUpProtocol();
        startLatch = new Latch();
        failed = false;
    }
View Full Code Here

    public void setStoppedRoutingTimeout(long stoppedRoutingTimeout) {
        this.stoppedRoutingTimeout = stoppedRoutingTimeout;
    }

    private Sync createNewRouterLock() {
        Latch lock = new Latch();
        return new TimeoutSync(lock, stoppedRoutingTimeout);
    }
View Full Code Here

    public void setStoppedRoutingTimeout(long stoppedRoutingTimeout) {
        this.stoppedRoutingTimeout = stoppedRoutingTimeout;
    }

    private Sync createNewRouterLock() {
        Latch lock = new Latch();
        return new TimeoutSync(lock, stoppedRoutingTimeout);
    }
View Full Code Here

    public void setStoppedRoutingTimeout(long stoppedRoutingTimeout) {
        this.stoppedRoutingTimeout = stoppedRoutingTimeout;
    }

    private Sync createNewRouterLock() {
        Latch lock = new Latch();
        return new TimeoutSync(lock, stoppedRoutingTimeout);
    }
View Full Code Here

* */
public class SyncWorkExecutor implements WorkExecutor {

    public void doExecute(WorkerContext work, Executor executor)
            throws WorkException, InterruptedException {
        Latch latch = work.provideEndLatch();
        executor.execute(work);
        latch.acquire();
    }
View Full Code Here

* */
public class StartWorkExecutor implements WorkExecutor {

    public void doExecute(WorkerContext work, Executor executor)
            throws WorkException, InterruptedException {
        Latch latch = work.provideStartLatch();
        executor.execute(work);
        latch.acquire();
    }
View Full Code Here

     */
    public void doTestAsynchRecover() throws JMSException, InterruptedException {
       
        final Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        final String errorMessage[] = new String[]{null};
        final Latch doneLatch = new Latch();
       
        MessageConsumer consumer = session.createConsumer(dest);       
       
        MessageProducer producer = session.createProducer(dest);
        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
        producer.send(session.createTextMessage("First"));
        producer.send(session.createTextMessage("Second"));
       
        consumer.setMessageListener(new MessageListener(){
            int counter;
            public void onMessage(Message msg) {
                counter++;
                try {
                    TextMessage message = (TextMessage)msg;
                    switch( counter ) {
                      case 1:
                            assertEquals("First", message.getText());
                            assertFalse(message.getJMSRedelivered());
                            message.acknowledge();
                         
                            break;                       
                      case 2:
                            assertEquals("Second", message.getText());
                            assertFalse(message.getJMSRedelivered());
                            session.recover();
                            break;
                           
                      case 3:
                            assertEquals("Second", message.getText());
                            assertTrue(message.getJMSRedelivered());                           
                            message.acknowledge();
                          doneLatch.release();
                          break;
                         
                      default:
                          errorMessage[0]="Got too many messages: "+counter;
                          doneLatch.release();
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                  errorMessage[0]="Got exception: "+e;
                  doneLatch.release();
                }
            }
        });
        connection.start();
       
        if( doneLatch.attempt(1000*5) ) {
            if( errorMessage[0]!=null ) {
                fail(errorMessage[0]);
            }           
        } else {
            fail("Timeout waiting for async message delivery to complete.");
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.Latch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.