001    package javax.realtime;
002    
003    /** Abstract superclass for all monitor control policy objects. */
004    public abstract class MonitorControl {
005        
006        protected static MonitorControl defaultMonitorControl = null;
007    
008        /** Create an instance of <code>MonitorControl</code>. */
009        public MonitorControl() {}
010    
011        /** Gets the monitor control policy of the given instance of
012         *  <code>this</code>.
013         *
014         *  @return The monitor control policy object.
015         */
016        public static MonitorControl getMonitorControl() {
017            return defaultMonitorControl;
018        }
019    
020        /** Gets the monitor control policy of the given instance of
021         *  <code>Object</code>.
022         *
023         *  @return The monitor control policy object.
024         */
025        public static MonitorControl getMonitorControl(Object monitor) {
026            return ((MonitorControl)monitor).getMonitorControl();
027        }
028    
029        /** Sets the default monitor behavior for object monitors used by
030         *  synchronized statements and methods in the system. The type
031         *  of the policy object determines the type of behavior. Conforming
032         *  implementations must support priority ceiling emulation and
033         *  priority inheritance for fixed priority preemptive threads.
034         *
035         *  @param policy The new monitor control policy. If null nothing happens.
036         */
037        public static void setMonitorControl(MonitorControl policy) {
038            defaultMonitorControl = policy;
039        }
040    
041        /** Has the same effect as <code>setMonitorControl()</code>, except
042         *  that the policy only affects the indicated object monitor.
043         *
044         *  @param monitor The monitor for which the new policy will be in use.
045         *                 The policy will take effect on the first attempt to
046         *                 lock the monitor after the completion of this method.
047         *                 If null nothing will happen.
048         *  @param policy The new policy for the object. If null nothing will happen.
049         */
050        public static void setMonitorControl(Object monitor,
051                                             MonitorControl monCtl) {
052            ((MonitorControl)monitor).setMonitorControl(monCtl);
053        }
054    }