package textbender.a.u.chromography; // Copyright 2006, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Textbender Software"), to deal in the Textbender Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Textbender Software, and to permit persons to whom the Textbender Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Textbender Software. THE TEXTBENDER SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE TEXTBENDER SOFTWARE OR THE USE OR OTHER DEALINGS IN THE TEXTBENDER SOFTWARE. import java.beans.*; import java.rmi.*; import java.rmi.server.*; import java.util.concurrent.atomic.*; import textbender.a.r.desk.*; import textbender.g.beans.*; import textbender.g.lang.*; import textbender.g.util.logging.*; /** Shadow-select service implementation. */ public final class Chromography1 extends UnicastRemoteObject implements Chromography { private static final AtomicReference instanceA = new AtomicReference(); /** Creates the single instance of Chromography1 and registers it as a service. */ public Chromography1() throws RemoteException { if( !instanceA.compareAndSet( /*expect*/null, Chromography1.this )) throw new IllegalStateException(); LoggerX.i(getClass()).config( "creating host service" ); HostServiceRegistry1.i().addService( Chromography.class, Chromography1.this ); } // ```````````````````````````````````````````````````````````````````````````````````` // Initialized early, for use in other initializers. private final PropertyChangeSupport propertyChangeSupport // OPT for dispatch speed per textbender.a.u.transfer.PRTransfer1.propertyChangeSupport = new PropertyChangeSupport( Chromography1.this ); private final HostServiceRegistry.UniqueID uniqueID = HostServiceRegistry1.i().nextUniqueID(); // - P r o p e r t y - C h a n g e - L i s t e n e r - R . R e g i s t r y ------------ public @ThreadSafe void addPropertyChangeListener( PropertyChangeListenerR listener ) { propertyChangeSupport.addPropertyChangeListener ( new PropertyChangeListenerR.WrapperL( listener, propertyChangeDispatchCatcher )); } public @ThreadSafe void disabledPropertyChangeListener( PropertyChangeListenerR listener ) { propertyChangeSupport.removePropertyChangeListener ( new PropertyChangeListenerR.WrapperL( listener, propertyChangeDispatchCatcher )); // LoggerX.i(getClass()).finest( "listener list down to: " + propertyChangeSupport.getPropertyChangeListeners().length ); } // - C h r o m o g r a p h y ---------------------------------------------------------- public @ThreadSafe synchronized ReferenceSeries getReferenceSeries() { return referenceSeries; }; // private @ThreadRestricted("holds this") ReferenceSeries referenceSeries = new ReferenceSeries0( /*origin*/uniqueID ); private @ThreadRestricted("holds this") ReferenceSeries referenceSeries; public @ThreadSafe synchronized void setReferenceSeries( final ReferenceSeries newReferenceSeries ) { if( Run.i().spool().isUnwinding() ) return; // if( newReferenceSeries == null ) throw new NullPointerException(); PropertyChangeEventAD e = new PropertyChangeEventAD ( Chromography1.this, "referenceSeries", referenceSeries, newReferenceSeries, propertyChangeSupport ); referenceSeries = newReferenceSeries; DeskDaemon.i().executor().execute( e ); // enqueue in sync, for correct e order } //// P r i v a t e /////////////////////////////////////////////////////////////////////// private final PropertyChangeListenerR.DispatchCatcher propertyChangeDispatchCatcher = new PropertyChangeListenerR.DispatchCatcher( /*registry*/Chromography1.this ); }