Clover coverage report -
Coverage timestamp: Sun Oct 12 2003 22:54:40 PDT
file stats: LOC: 674   Methods: 27
NCLOC: 324   Classes: 4
 
 Source file Conditionals Statements Methods TOTAL
AbstractObjectBroker.java 78.3% 90.5% 88.9% 87.1%
coverage coverage
 1   
 /*
 2   
 
 3   
 VRMoo Common - Virtual Reality Object Oriented MUD Common Code
 4   
 Copyright (C) 2003  VRMoo Development Team
 5   
 
 6   
 
 7   
 This program is free software; you can redistribute it and/or modify
 8   
 it under the terms of the GNU General Public License as published by
 9   
 the Free Software Foundation; either version 2 of the License, or
 10   
 (at your option) any later version.
 11   
 
 12   
 This program is distributed in the hope that it will be useful,
 13   
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 14   
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15   
 GNU General Public License for more details.
 16   
 
 17   
 You should have received a copy of the GNU General Public License
 18   
 along with this program; if not, write to the Free Software
 19   
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 20   
 
 21   
 
 22   
 For information about VRMoo and its authors, please visit the website:
 23   
 http://www.vrmoo.org/
 24   
 
 25   
 */
 26   
 
 27   
 package org.vrmoo.common.objectbroker;
 28   
 
 29   
 import java.util.ArrayList;
 30   
 import java.util.HashMap;
 31   
 import java.util.Iterator;
 32   
 import java.util.List;
 33   
 import java.util.Map;
 34   
 import java.util.TreeSet;
 35   
 
 36   
 import org.vrmoo.common.data.BrokerableObject;
 37   
 import org.vrmoo.common.data.BrokerableObjectListener;
 38   
 import org.vrmoo.common.exception.VRMooException;
 39   
 import org.vrmoo.common.exception.VRMooParseException;
 40   
 import org.vrmoo.common.util.CommandHandler;
 41   
 import org.vrmoo.common.util.CommandProcessor;
 42   
 import org.vrmoo.common.util.MapListener;
 43   
 
 44   
 /**
 45   
  * Super class for all object broker classes that provides common functionality
 46   
  * that is used in all of them.
 47   
  *
 48   
  * @author Jeff Weston
 49   
  */
 50   
 public abstract class AbstractObjectBroker extends CommandHandler
 51   
         implements CommandProcessor, BrokerableObjectListener
 52   
 {
 53   
     /**
 54   
      * The list of <code>CommandHandler</code> instances that have requested to
 55   
      * be notified of <code>ObjectDataBroker</code> messages coming from this
 56   
      * class.
 57   
      */
 58   
     private List commandHandlers;
 59   
 
 60   
     /**
 61   
      * The list of listeners for any changes to the map of brokerable objects.
 62   
      */
 63   
     private List mapListeners;
 64   
 
 65   
     /**
 66   
      * The map of brokerable objects.
 67   
      */
 68   
     private Map brokerableObjectMap;
 69   
 
 70   
     /**
 71   
      * Determines if this instance of this class is a server instance.
 72   
      */
 73   
     private boolean isServerInstance;
 74   
 
 75   
     /**
 76   
      * Initialize the data handled by this class.
 77   
      *
 78   
      * @param isServerInstance   tell this instance if it is a server instance
 79   
      */
 80  24
     protected AbstractObjectBroker( boolean isServerInstance )
 81   
     {
 82  24
         commandHandlers = new ArrayList( );
 83  24
         mapListeners = new ArrayList( );
 84  24
         brokerableObjectMap = new HashMap( );
 85  24
         this.isServerInstance = isServerInstance;
 86   
 
 87  24
         if ( ! isServerInstance )
 88   
         {
 89  3
             addCommandProcessor(
 90   
                     new SetBrokerableObjectMapCommandProcessor( ) );
 91   
         }
 92   
 
 93  24
         addCommandProcessor( new SetBrokerableObjectCommandProcessor( ) );
 94  24
         addCommandProcessor( new RemoveBrokerableObjectCommandProcessor( ) );
 95   
     }
 96   
 
 97   
     /**
 98   
      * Returns the command prefix used to recognize commands that this
 99   
      * processor can handle.
 100   
      *
 101   
      * @return the command prefix
 102   
      */
 103  0
     public String getCommandPrefix( )
 104   
     {
 105  0
         return getBrokerPrefix( );
 106   
     }
 107   
 
 108   
     /**
 109   
      * Process a command matching the command prefix established by the
 110   
      * <code>getCommandPrefix()</code> method.
 111   
      *
 112   
      * @param command     the command to process
 113   
      * @param extraData   extra data that isn't part of the command but may
 114   
      *                      be needed for dealing with the command (such as
 115   
      *                      the ID of the client that sent the command)
 116   
      *
 117   
      * @throws VRMooException   for any errors while processing the command
 118   
      */
 119  48
     public synchronized void processCommand( String command, String extraData )
 120   
             throws VRMooException
 121   
     {
 122  48
         String objectDataBrokerCommand = command.substring(
 123   
                 getBrokerPrefix( ).length( ) ).trim( );
 124   
 
 125  48
         handleCommand( objectDataBrokerCommand, extraData );
 126   
     }
 127   
 
 128   
     /**
 129   
      * Notifies this class that a <code>BrokerableObject</code> that it is
 130   
      * listing to has changed.
 131   
      *
 132   
      * @param brokerableObject   the <code>BrokerableObject</code> that changed
 133   
      */
 134  4
     public synchronized void brokerableObjectChanged(
 135   
             BrokerableObject brokerableObject )
 136   
     {
 137  4
         setBrokerableObject( brokerableObject, null );
 138   
     }
 139   
 
 140   
     /**
 141   
      * Add a new <code>CommandHandler</code> to the list of command handlers
 142   
      * for this class.
 143   
      *
 144   
      * @param commandHandler   the <code>CommandHandler</code> to add
 145   
      */
 146  42
     public synchronized void addCommandHandler( CommandHandler commandHandler )
 147   
     {
 148  42
         if ( ! commandHandlers.contains( commandHandler ) )
 149   
         {
 150  42
             commandHandlers.add( commandHandler );
 151   
         }
 152   
     }
 153   
 
 154   
     /**
 155   
      * Remove a <code>CommandHandler</code> from the list of command handlers
 156   
      * for this class.
 157   
      *
 158   
      * @param commandHandler   the <code>CommandHandler</code> to remove
 159   
      */
 160  42
     public synchronized void removeCommandHandler(
 161   
             CommandHandler commandHandler )
 162   
     {
 163  42
         if ( commandHandlers.contains( commandHandler ) )
 164   
         {
 165  42
             commandHandlers.remove( commandHandler );
 166   
         }
 167   
     }
 168   
 
 169   
     /**
 170   
      * Add a new <code>MapListener</code> to the list of map listeners
 171   
      * for this class.
 172   
      *
 173   
      * @param mapListener   the <code>MapListener</code> to add
 174   
      */
 175  0
     public synchronized void addMapListener( MapListener mapListener )
 176   
     {
 177  0
         if ( ! mapListeners.contains( mapListener ) )
 178   
         {
 179  0
             mapListeners.add( mapListener );
 180   
         }
 181   
     }
 182   
 
 183   
     /**
 184   
      * Remove a <code>MapListener</code> from the list of map listeners
 185   
      * for this class.
 186   
      *
 187   
      * @param mapListener   the <code>MapListener</code> to remove
 188   
      */
 189  0
     public synchronized void removeMapListener( MapListener mapListener )
 190   
     {
 191  0
         if ( mapListeners.contains( mapListener ) )
 192   
         {
 193  0
             mapListeners.remove( mapListener );
 194   
         }
 195   
     }
 196   
 
 197   
     /**
 198   
      * Inform this class that a new client has connected. Sends a command to the
 199   
      * client that populates its map of brokerable objects.
 200   
      *
 201   
      * @param clientID   the ID of the new client
 202   
      *
 203   
      * @throws VRMooException   for any errors that occur
 204   
      */
 205  1
     public synchronized void clientConnected( int clientID )
 206   
             throws VRMooException
 207   
     {
 208  1
         if ( isServerInstance )
 209   
         {
 210  1
             broadcastCommand( "sendCommand: world: " +
 211   
                               getBrokerPrefix( ) + " " +
 212   
                               "setBrokerableObjectMap: " +
 213   
                               toEncodedString( ), "" + clientID );
 214   
         }
 215   
     }
 216   
 
 217   
     /**
 218   
      * Protected method for broadcasting a command from subclasses
 219   
      * to all command handlers that requested to receive them. The
 220   
      * extraData parameter is used to specify a specific client
 221   
      * that should be sent the command. If extraData is null, all
 222   
      * clients are sent the command, otherwise only the client
 223   
      * that matches the clientID sent within the extraData
 224   
      * parameter.
 225   
      * <P>
 226   
      * It is up to the <code>CommandHandler</code> to interpret
 227   
      * the extraData parameter and determine whether or not pass
 228   
      * the command on based upon its value. We will still send the
 229   
      * command to every registered <code>CommandHandler</code>.
 230   
      * Since <code>CommandHandler</code> has no notion of a
 231   
      * clientID, or even if it's a client at all, we can't make
 232   
      * that determination here.
 233   
      *
 234   
      * @param command     the command to broadcast
 235   
      * @param extraData   the clientID to limit our broadcast to, null if all
 236   
      *                      clients should receive the broadcast
 237   
      */
 238  33
     protected synchronized void broadcastCommand(
 239   
             String command, String extraData )
 240   
     {
 241  33
         for ( int i = 0; i < commandHandlers.size( ); i++ )
 242   
         {
 243  33
             CommandHandler commandHandler =
 244   
                     ( CommandHandler ) commandHandlers.get( i );
 245  33
             try
 246   
             {
 247  33
                 commandHandler.handleCommand( command, extraData );
 248   
             }
 249   
             catch ( VRMooException e )
 250   
             {
 251  0
                 e.printStackTrace( );
 252   
             }
 253   
         }
 254   
     }
 255   
 
 256   
     /**
 257   
      * If this is a client instance and the source of the new
 258   
      * <code>BrokerableObject</code> is local, it sends the new
 259   
      * <code>BrokerableObject</code> to the server. If this is a client
 260   
      * instance and the source of the new <code>BrokerableObject</code>
 261   
      * is remote, or if this is a server instance, it adds or replaces
 262   
      * the <code>BrokerableObject</code> in the brokerableObjectMap.
 263   
      * Uses the name of the <code>BrokerableObject</code> as the key
 264   
      * and the <code>BrokerableObject</code> as the value. If the key
 265   
      * does not exist, it adds the <code>BrokerableObject</code>. If
 266   
      * the key already exists, the <code>BrokerableObject</code> with
 267   
      * that key is replaced with the new <code>BrokerableObject</code>.
 268   
      *
 269   
      * @param brokerableObject   the brokerable object to add or replace
 270   
      * @param source             the source of the brokerable object
 271   
      */
 272  39
     protected synchronized void setBrokerableObject(
 273   
             BrokerableObject brokerableObject, String source )
 274   
     {
 275  39
         String command = "sendCommand: world: " +
 276   
                          getBrokerPrefix( ) + " setBrokerableObject: " +
 277   
                          brokerableObject.toEncodedString( );
 278   
 
 279  39
         if ( isServerInstance )
 280   
         {
 281  24
             broadcastCommand( command, null );
 282  24
             brokerableObjectMap.put( brokerableObject.getName( ),
 283   
                                      brokerableObject );
 284  24
             brokerableObject.addBrokerableObjectListener( this );
 285  24
             fireItemAdded( brokerableObject.getName( ) );
 286   
         }
 287   
         else
 288   
         {
 289  15
             if ( source == null )
 290   
             {
 291  3
                 broadcastCommand( command, null );
 292   
             }
 293   
             else
 294   
             {
 295  12
                 brokerableObjectMap.put( brokerableObject.getName( ),
 296   
                                          brokerableObject );
 297  12
                 brokerableObject.addBrokerableObjectListener( this );
 298  12
                 fireItemAdded( brokerableObject.getName( ) );
 299   
             }
 300   
         }
 301   
     }
 302   
 
 303   
     /**
 304   
      * Determines if the brokerable object map contains an object with the
 305   
      * specified name.
 306   
      *
 307   
      * @param name   the object name to search for
 308   
      *
 309   
      * @return true if found, false if not
 310   
      */
 311  9
     protected boolean containsBrokerableObject( String name )
 312   
     {
 313  9
         return ( brokerableObjectMap.containsKey( name ) );
 314   
     }
 315   
 
 316   
     /**
 317   
      * Gets a brokerable object with the specified name.
 318   
      *
 319   
      * @param objectName   the object name to search for.
 320   
      *
 321   
      * @return the matching <code>BrokerableObject</code>
 322   
      *
 323   
      * @throws VRMooException if the object name isn't found
 324   
      */
 325  18
     protected synchronized BrokerableObject getBrokerableObject(
 326   
             String objectName ) throws VRMooException
 327   
     {
 328  18
         if ( brokerableObjectMap.containsKey( objectName ) )
 329   
         {
 330  14
             return ( BrokerableObject ) brokerableObjectMap.get( objectName );
 331   
         }
 332   
         else
 333   
         {
 334  4
             throw new VRMooException( "BrokerableObject <" + objectName +
 335   
                                       "> not found." );
 336   
         }
 337   
     }
 338   
 
 339   
     /**
 340   
      * Get the name of all of the brokerable objects available from this class.
 341   
      *
 342   
      * @return the array of object names
 343   
      */
 344  27
     protected synchronized String[ ] getBrokerableObjectNames( )
 345   
     {
 346  27
         String[ ] names = new String[ brokerableObjectMap.size( ) ];
 347  27
         Iterator iter = new TreeSet(
 348   
                 brokerableObjectMap.keySet( ) ).iterator( );
 349   
 
 350  27
         int i = 0;
 351  27
         while ( iter.hasNext( ) )
 352   
         {
 353  18
             names[ i++ ] = ( String ) iter.next( );
 354   
         }
 355  27
         return names;
 356   
     }
 357   
 
 358   
     /**
 359   
      * Remove the brokerable object with the specified name.
 360   
      *
 361   
      * @param objectName   the name of the brokerable object to remove
 362   
      *
 363   
      * @param source             the source of the remove request
 364   
      */
 365  6
     protected synchronized void removeBrokerableObject(
 366   
             String objectName, String source )
 367   
     {
 368  6
         String command = "sendCommand: world: " + getBrokerPrefix( ) +
 369   
                          " removeBrokerableObject: " +
 370   
                          objectName;
 371   
 
 372  6
         if ( isServerInstance )
 373   
         {
 374  4
             broadcastCommand( command, null );
 375  4
             removeBrokerableObjectListener( objectName );
 376  4
             brokerableObjectMap.remove( objectName );
 377  4
             fireItemDeleted( objectName );
 378   
         }
 379   
         else
 380   
         {
 381  2
             if ( source == null )
 382   
             {
 383  1
                 broadcastCommand( command, null );
 384   
             }
 385   
             else
 386   
             {
 387  1
                 removeBrokerableObjectListener( objectName );
 388  1
                 brokerableObjectMap.remove( objectName );
 389  1
                 fireItemDeleted( objectName );
 390   
             }
 391   
         }
 392   
     }
 393   
 
 394   
     /**
 395   
      * Get the prefix used by broker sub-class when sending or receiving
 396   
      * commands.
 397   
      *
 398   
      * @return the prefix used for sending and receiving commands
 399   
      */
 400   
     protected abstract String getBrokerPrefix( );
 401   
 
 402   
     /**
 403   
      * Get an instance of a brokerable object by parsing a string of encoded
 404   
      * data representing the object.
 405   
      *
 406   
      * @param data   the encoded data for the object
 407   
      *
 408   
      * @return the parsed <code>BrokerableObject</code>
 409   
      *
 410   
      * @throws VRMooParseException for any parsing errors that occur
 411   
      */
 412   
     protected abstract BrokerableObject parseBrokerableObject( String data )
 413   
             throws VRMooParseException;
 414   
 
 415   
     /**
 416   
      * Remove all of the brokerable objects.
 417   
      */
 418  23
     private void removeAllBrokerableObjects( )
 419   
     {
 420  23
         String[ ] objectNames = getBrokerableObjectNames( );
 421   
 
 422  23
         for ( int i = 0; i < objectNames.length; i++ )
 423   
         {
 424  9
             removeBrokerableObjectListener( objectNames[ i ] );
 425  9
             brokerableObjectMap.remove( objectNames[ i ] );
 426  9
             fireItemDeleted( objectNames[ i ] );
 427   
         }
 428   
     }
 429   
 
 430   
     /**
 431   
      * Private method used to remove the listener this object set on a
 432   
      * <code>BrokerableObject</code> earlier.
 433   
      *
 434   
      * @param name   the name of the <code>BrokerableObject</code>
 435   
      */
 436  14
     private void removeBrokerableObjectListener( String name )
 437   
     {
 438  14
         BrokerableObject brokerableObject =
 439   
             ( BrokerableObject ) brokerableObjectMap.get( name );
 440   
 
 441  14
         if ( brokerableObject != null )
 442   
         {
 443  14
             brokerableObject.addBrokerableObjectListener( this );
 444   
         }
 445   
     }
 446   
 
 447   
     /**
 448   
      * Private method used to set the list of brokerable objects when another
 449   
      * <code>AbstractOBjectBroker</code> gives us a new list of brokerable
 450   
      * objects.
 451   
      *
 452   
      * @param brokerableObjectData   the new list of brokerable objects
 453   
      *
 454   
      * @throws VRMooParseException   for any parsing errors that occur
 455   
      */
 456  23
     private void handleSetBrokerableObjectMap( String brokerableObjectData )
 457   
             throws VRMooParseException
 458   
     {
 459  23
         removeAllBrokerableObjects( );
 460  23
         brokerableObjectData = brokerableObjectData.trim( );
 461  23
         int itemEnd = brokerableObjectData.indexOf( ">" );
 462  23
         while ( ( brokerableObjectData.indexOf( "<" ) == 0 ) &&
 463   
                 ( itemEnd != -1 ) )
 464   
         {
 465  8
             String item = brokerableObjectData.substring( 1, itemEnd );
 466  8
             int nextIndex = brokerableObjectData.indexOf( "<", itemEnd );
 467  8
             if ( nextIndex != -1 )
 468   
             {
 469  3
                 brokerableObjectData =
 470   
                         brokerableObjectData.substring( nextIndex ).trim( );
 471   
             }
 472   
             else
 473   
             {
 474  5
                 brokerableObjectData = "";
 475   
             }
 476  8
             itemEnd = brokerableObjectData.indexOf( ">" );
 477   
 
 478  8
             setBrokerableObject( parseBrokerableObject( item ), "server" );
 479   
         }
 480   
     }
 481   
 
 482   
     /**
 483   
      * Convert the map of brokerable objects to its encoded <code>String</code>
 484   
      * representation.
 485   
      *
 486   
      * @return the encoded <code>String</code>
 487   
      *
 488   
      * @throws VRMooException   for any errors that occur
 489   
      */
 490  1
     private String toEncodedString( ) throws VRMooException
 491   
     {
 492  1
         StringBuffer result = new StringBuffer( );
 493  1
         String[ ] names = getBrokerableObjectNames( );
 494   
 
 495  1
         for ( int i = 0; i < names.length; i++ )
 496   
         {
 497  2
             BrokerableObject brokerableObject =
 498   
                     getBrokerableObject( names[ i ] );
 499   
 
 500  2
             if ( i > 0 )
 501   
             {
 502  1
                 result.append( ", " );
 503   
             }
 504   
 
 505  2
             result.append( "< " );
 506  2
             result.append( brokerableObject.toEncodedString( ) );
 507  2
             result.append( " >" );
 508   
         }
 509  1
         return result.toString( );
 510   
     }
 511   
 
 512   
     /**
 513   
      * Sends a message to all map listeners that a new item has been added.
 514   
      *
 515   
      * @param name   the name of the item that was added
 516   
      */
 517  36
     private void fireItemAdded( String name )
 518   
     {
 519  36
         for ( int i = 0; i < mapListeners.size( ); i++ )
 520   
         {
 521  0
             MapListener mapListener = ( MapListener ) mapListeners.get( i );
 522  0
             mapListener.addItem( name );
 523   
         }
 524   
     }
 525   
 
 526   
     /**
 527   
      * Sends a message to all map listeners that an item has been deleted.
 528   
      *
 529   
      * @param name   the name of the item that was deleted
 530   
      */
 531  14
     private void fireItemDeleted( String name )
 532   
     {
 533  14
         for ( int i = 0; i < mapListeners.size( ); i++ )
 534   
         {
 535  0
             MapListener mapListener = ( MapListener ) mapListeners.get( i );
 536  0
             mapListener.deleteItem( name );
 537   
         }
 538   
     }
 539   
 
 540   
     /**
 541   
      * Private inner class implementing the <code>CommandProcessor</code>
 542   
      * interface for dealing with the "setBrokerableObjectMap" command sent
 543   
      * from another <code>AbstractObjectBroker</code>.
 544   
      */
 545   
     private class SetBrokerableObjectMapCommandProcessor
 546   
             implements CommandProcessor
 547   
     {
 548   
         /**
 549   
          * The prefix for the command handled by this processor.
 550   
          */
 551   
         private static final String PREFIX = "setBrokerableObjectMap:";
 552   
 
 553   
         /**
 554   
          * Returns the command prefix used to recognize commands that this
 555   
          * processor can handle.
 556   
          *
 557   
          * @return the command prefix
 558   
          */
 559  28
         public String getCommandPrefix( )
 560   
         {
 561  28
             return PREFIX;
 562   
         }
 563   
 
 564   
         /**
 565   
          * Process a command matching the command prefix established by the
 566   
          * <code>getCommandPrefix()</code> method.
 567   
          *
 568   
          * @param command     the command to process
 569   
          * @param extraData   extra data that isn't part of the command but may
 570   
          *                      be needed for dealing with the command (such as
 571   
          *                      the ID of the client that sent the command)
 572   
          *
 573   
          * @throws VRMooParseException   for any parsing errors that occur
 574   
          */
 575  23
         public void processCommand( String command, String extraData )
 576   
                 throws VRMooParseException
 577   
         {
 578  23
             String brokerableObjectData =
 579   
                     command.substring( PREFIX.length( ) ).trim( );
 580  23
             handleSetBrokerableObjectMap( brokerableObjectData );
 581   
         }
 582   
     }
 583   
 
 584   
     /**
 585   
      * Private inner class implementing the <code>CommandProcessor</code>
 586   
      * interface for dealing with the "setBrokerableObject" command sent from
 587   
      * another <code>AbstractObjectBroker</code>.
 588   
      */
 589   
     private class SetBrokerableObjectCommandProcessor
 590   
             implements CommandProcessor
 591   
     {
 592   
         /**
 593   
          * The prefix for the command handled by this processor.
 594   
          */
 595   
         private static final String PREFIX = "setBrokerableObject:";
 596   
 
 597   
         /**
 598   
          * Returns the command prefix used to recognize commands that this
 599   
          * processor can handle.
 600   
          *
 601   
          * @return the command prefix
 602   
          */
 603  48
         public String getCommandPrefix( )
 604   
         {
 605  48
             return PREFIX;
 606   
         }
 607   
 
 608   
         /**
 609   
          * Process a command matching the command prefix established by the
 610   
          * <code>getCommandPrefix()</code> method.
 611   
          *
 612   
          * @param command     the command to process
 613   
          * @param extraData   extra data that isn't part of the command but may
 614   
          *                      be needed for dealing with the command (such as
 615   
          *                      the ID of the client that sent the command)
 616   
          *
 617   
          * @throws VRMooParseException   for any parsing errors that occur
 618   
          */
 619  5
         public void processCommand( String command, String extraData )
 620   
                 throws VRMooParseException
 621   
         {
 622  5
             String source = ( isServerInstance ? extraData : "server" );
 623  5
             String brokerableObjectData =
 624   
                     command.substring( PREFIX.length( ) ).trim( );
 625  5
             setBrokerableObject(
 626   
                     parseBrokerableObject( brokerableObjectData ), source );
 627   
         }
 628   
     }
 629   
 
 630   
     /**
 631   
      * Private inner class implementing the <code>CommandProcessor</code>
 632   
      * interface for dealing with the "removeBrokerableObject" command sent from
 633   
      * another <code>AbstractObjectBroker</code>.
 634   
      */
 635   
     private class RemoveBrokerableObjectCommandProcessor
 636   
             implements CommandProcessor
 637   
     {
 638   
         /**
 639   
          * The prefix for the command handled by this processor.
 640   
          */
 641   
         private static final String PREFIX = "removeBrokerableObject:";
 642   
 
 643   
         /**
 644   
          * Returns the command prefix used to recognize commands that this
 645   
          * processor can handle.
 646   
          *
 647   
          * @return the command prefix
 648   
          */
 649  48
         public String getCommandPrefix( )
 650   
         {
 651  48
             return PREFIX;
 652   
         }
 653   
 
 654   
         /**
 655   
          * Process a command matching the command prefix established by the
 656   
          * <code>getCommandPrefix()</code> method.
 657   
          *
 658   
          * @param command     the command to process
 659   
          * @param extraData   extra data that isn't part of the command but may
 660   
          *                      be needed for dealing with the command (such as
 661   
          *                      the ID of the client that sent the command)
 662   
          *
 663   
          * @throws VRMooParseException   for any parsing errors that occur
 664   
          */
 665  2
         public void processCommand( String command, String extraData )
 666   
                 throws VRMooParseException
 667   
         {
 668  2
             String source = ( isServerInstance ? extraData : "server" );
 669  2
             String name = command.substring( PREFIX.length( ) ).trim( );
 670  2
             removeBrokerableObject( name, source );
 671   
         }
 672   
     }
 673   
 }
 674