001package votorola.s.gwt.scene.feed.ss; // Copyright 2011, Michael Allan.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola 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 Votorola Software. THE VOTOROLA 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 VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import java.io.*;
004import java.sql.*;
005import java.util.*;
006import votorola.a.*;
007import votorola.a.trust.*;
008import votorola.g.lang.*;
009
010
011/** A configurer of bites on the server side.  After the feed server has configured a bite
012  * according to its own requirements, it may process the bite through one or more biters
013  * for additional configuration.  The exact biters it uses for this purpose will depend
014  * on the current composition of the client, in particular on the type of scene it is
015  * displaying.  Different types of scene have different requirements in the way of extended
016  * bite properties.  Decorating the bites with those properties on the server side (using
017  * a biter) is intended as an optimization for speed.  It eliminates the need for client
018  * maps to make separate calls to the server for each bite displayed.  So users will be
019  * able to juxtapose any feed type with any scene type and the server won't be brought to
020  * its knees keeping all the combinations fed with data.  Biters (working on jigs) ought
021  * to be very fast.  They decorate the bite stream on the fly (in mid-transmission) with
022  * whatever additional data is required for the user's chosen scene, and they do so without
023  * a lot of garbage overhead.
024  */
025public interface Biter
026{
027
028
029   // - B i t e r ------------------------------------------------------------------------
030
031
032     /** Configures a bite.  Uses the various add/set methods of the bite jig to ensure
033       * that all necessary properties of the bite are set.
034       */
035     public void configure( BiteJig bite );
036
037
038
039   // ====================================================================================
040
041
042    /** Biter utilities.
043      */
044    public @ThreadSafe static final class U
045    {
046
047        private U() {}
048
049
050        /** Assembles an array of biters suitable for handling a particular request to a
051          * bite feed.  The biters ought to be invoked in the same order as stored in the
052          * array.  Do not hold them for any great length of time; they contain perishable
053          * data, such as network traces or counts.
054          */
055          @Warning("thread restricted object")
056        public static final Biter[] assembleBiters( final VoteServer.Run run )
057          throws IOException, SQLException
058        {
059            final NetworkTrace traceOrNull = run.trustserver().traceToReportT();
060            // We'll eventually do something more intelligent here, depending on which scene
061            // is currently shown in the theatre client.  But for now, it's OK to assemble
062            // all possible biters:
063            return new Biter[]
064            {
065                new votorola.s.gwt.scene.geo.GeomapBiterSS( run, traceOrNull ),
066                new votorola.s.gwt.scene.vote.VotespaceBiterSS( run )
067            };
068        }
069
070
071    }
072
073
074}