Home | History | Annotate | Download | only in framework
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *
     15  *  See the License for the specific language governing permissions and
     16  *  limitations under the License.
     17  */
     18 
     19 /**
     20  * @author Vitaly A. Provodin
     21  */
     22 
     23 /**
     24  * Created on 04.02.2005
     25  */
     26 package org.apache.harmony.jpda.tests.framework;
     27 
     28 import java.util.LinkedList;
     29 import java.util.List;
     30 
     31 /**
     32  * This class defines an interface to keep an information about all started
     33  * debuggees.
     34  * <p>
     35  * As a rule JPDA tests consist of two parts: the test that represents a
     36  * part of the debugger-side application and the debuggee part. It is a good
     37  * practice if the JPDA tests control debuggee's lifecycle (usually via JDWP
     38  * channel), but in some cases it can not be done, for example because of
     39  * product bugs.
     40  * <p>
     41  * This class is aimed to be an additional facility to stop each debuggee
     42  * activity if it can not be done by the test in the regular way via JDWP
     43  * channel.
     44  */
     45 public class DebuggeeRegister {
     46 
     47     LinkedList<DebuggeeWrapper> registered = new LinkedList<DebuggeeWrapper>();
     48 
     49     /**
     50      * Registers started debuggee.
     51      *
     52      * @param debuggee <code>DebuggeeWrapper</code> of the new started
     53      * debuggee to register
     54      */
     55     public void register(DebuggeeWrapper debuggee) {
     56        registered.add(debuggee);
     57     }
     58 
     59     /**
     60      * Unregisters specified debuggee.
     61      *
     62      * @param debuggee <code>DebuggeeWrapper</code> of the debuggee to unregister
     63      * returns true if debuggee was registered
     64      */
     65     public boolean unregister(DebuggeeWrapper debuggee) {
     66         return registered.remove(debuggee);
     67     }
     68 
     69     /**
     70      * Returns list of all registered DebuggeeWrappers.
     71      *
     72      * @return array of DebuggeeWrappers
     73      */
     74     public List<DebuggeeWrapper> getAllRegistered() {
     75         return registered;
     76     }
     77 
     78     /**
     79      * Stops each of registered DebuggeeWrappers by invoking DebuggeeWrapper.stop().
     80      */
     81     public void stopAllRegistered() {
     82         for (DebuggeeWrapper wrapper : registered) {
     83             if (wrapper != null) {
     84                 wrapper.stop();
     85             }
     86         }
     87         registered.clear();
     88     }
     89 }
     90