idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
137,200
public void setClassLoader ( ClassLoader loader ) { _loader = loader ; PresentsConnection conn = getConnection ( ) ; if ( conn != null ) { conn . setClassLoader ( loader ) ; } }
Configures this session with a custom class loader that will be used when unserializing classes from the network .
137,201
public void endSession ( ) { _clmgr . clientSessionWillEnd ( this ) ; Connection conn = getConnection ( ) ; if ( conn != null ) { setConnection ( null ) ; _conmgr . closeConnection ( conn ) ; } if ( _clobj != null ) { try { sessionDidEnd ( ) ; } catch ( Exception e ) { log . warning ( "Choked in sessionDidEnd " + this ...
Forcibly terminates a client s session . This must be called from the dobjmgr thread .
137,202
public void handleMessage ( Message message ) { if ( _throttle == null ) { return ; } else if ( _throttle . throttleOp ( message . received ) ) { handleThrottleExceeded ( ) ; } dispatchMessage ( message ) ; }
from interface Connection . MessageHandler
137,203
protected void dispatchMessage ( Message message ) { _messagesIn ++ ; MessageDispatcher disp = _disps . get ( message . getClass ( ) ) ; if ( disp == null ) { log . warning ( "No dispatcher for message" , "msg" , message ) ; return ; } disp . dispatch ( this , message ) ; }
Processes a message without throttling .
137,204
protected void startSession ( Name authname , AuthRequest req , PresentsConnection conn , Object authdata ) { _authname = authname ; _areq = req ; _authdata = authdata ; setConnection ( conn ) ; _clmgr . resolveClientObject ( _authname , this ) ; _sessionStamp = System . currentTimeMillis ( ) ; }
Initializes this client instance with the specified username connection instance and client object and begins a client session .
137,205
protected void resumeSession ( AuthRequest req , PresentsConnection conn ) { Connection oldconn = getConnection ( ) ; if ( oldconn != null && ! oldconn . isClosed ( ) ) { log . info ( "Closing stale connection" , "old" , oldconn , "new" , conn ) ; oldconn . close ( ) ; } _areq = req ; setConnection ( conn ) ; if ( _clo...
Called by the client manager when a new connection arrives that authenticates as this already established client . This must only be called from the congmr thread .
137,206
protected void finishResumeSession ( ) { if ( _clobj == null ) { log . info ( "Missing client object for resuming session " + this + "." ) ; endSession ( ) ; return ; } clearSubscrips ( false ) ; _clobj . getLocal ( ClientLocal . class ) . secret = getSecret ( ) ; sessionWillResume ( ) ; sendBootstrap ( ) ; if ( _messa...
This is called from the dobjmgr thread to complete the session resumption . We call some call backs and send the bootstrap info to the client .
137,207
protected void safeEndSession ( ) { if ( ! _omgr . isRunning ( ) ) { log . info ( "Dropping end session request as we're shutting down " + this + "." ) ; } else { _omgr . postRunnable ( new Runnable ( ) { public void run ( ) { endSession ( ) ; } } ) ; } }
Queues up a runnable on the object manager thread where we can safely end the session .
137,208
protected synchronized void unmapSubscrip ( int oid ) { ClientProxy rec ; synchronized ( _subscrips ) { rec = _subscrips . remove ( oid ) ; } if ( rec != null ) { rec . unsubscribe ( ) ; } else { boolean alreadyDestroyed = _destroyedSubs . remove ( oid ) ; if ( ! alreadyDestroyed ) { log . warning ( "Missing subscripti...
Makes a note that this client is no longer subscribed to this object . The subscription map is used to clean up after the client when it goes away .
137,209
protected void clearSubscrips ( boolean verbose ) { for ( ClientProxy rec : _subscrips . values ( ) ) { if ( verbose ) { log . info ( "Clearing subscription" , "client" , this , "obj" , rec . object . getOid ( ) ) ; } rec . unsubscribe ( ) ; } _subscrips . clear ( ) ; }
Clears out the tracked client subscriptions . Called when the client goes away and shouldn t be called otherwise .
137,210
protected void sendBootstrap ( ) { BootstrapData data = createBootstrapData ( ) ; populateBootstrapData ( data ) ; postMessage ( new BootstrapNotification ( data ) , null ) ; }
This is called once we have a handle on the client distributed object . It sends a bootstrap notification to the client with all the information it will need to interact with the server .
137,211
protected synchronized void setConnection ( PresentsConnection conn ) { long now = System . currentTimeMillis ( ) ; if ( _conn != null ) { if ( conn == null ) { _connectTime += ( ( now - _networkStamp ) / 1000 ) ; _messagesDropped = 0 ; } _conn . clearMessageHandler ( ) ; } _conn = conn ; if ( _conn != null ) { _conn ....
Sets our connection reference in a thread safe way . Also establishes the back reference to us as the connection s message handler .
137,212
protected void finishCompoundMessage ( ) { if ( -- _compoundDepth == 0 ) { CompoundDownstreamMessage downstream = _compound ; _compound = null ; if ( ! downstream . msgs . isEmpty ( ) ) { postMessage ( downstream , null ) ; } } }
Sends the compound message created in startCompoundMessage .
137,213
protected boolean postMessage ( DownstreamMessage msg , PresentsConnection expect ) { PresentsConnection conn = getConnection ( ) ; if ( expect != null && conn != expect ) { return false ; } if ( _compound != null ) { _compound . msgs . add ( msg ) ; return true ; } if ( conn != null ) { conn . postMessage ( msg ) ; _m...
Queues a message for delivery to the client .
137,214
protected void throttleUpdated ( ) { int messagesPerSec ; synchronized ( _pendingThrottles ) { if ( _pendingThrottles . size ( ) == 0 ) { log . warning ( "Received throttleUpdated but have no pending throttles" , "client" , this ) ; return ; } messagesPerSec = _pendingThrottles . remove ( 0 ) ; } _throttle . reinit ( 1...
Notifies this client that its throttle was updated .
137,215
public V get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { return _sync . innerGet ( unit . toNanos ( timeout ) ) ; }
from interface Future
137,216
public void requestProcessed ( Object result ) { @ SuppressWarnings ( "unchecked" ) V value = ( V ) result ; _sync . innerSet ( value ) ; }
from interface InvocationService . ResultListener
137,217
protected DSetEditor < E > createEditor ( DObject setter , String setName , Class < ? > entryClass , String [ ] editableFields , ObjectEditorTable . FieldInterpreter interp , EntryGrouper < E > grouper , String group ) { return new DSetEditor < E > ( setter , setName , entryClass , editableFields , interp , getDisplayF...
Creates a DSetEditor for displaying the given group .
137,218
public String getPeerHostName ( String region ) { return ( ALWAYS_CONNECT_INTERNAL || Objects . equal ( this . region , region ) ) ? hostName : publicHostName ; }
Returns the host name to which peers in the specified region should connect .
137,219
public void setClassLoader ( ClassLoader loader ) { _loader = loader ; if ( _comm != null ) { _comm . setClassLoader ( loader ) ; } }
Configures the client with a custom class loader which will be used when reading objects off of the network .
137,220
public void registerFlushDelay ( Class < ? > objclass , long delay ) { ClientDObjectMgr omgr = ( ClientDObjectMgr ) getDObjectManager ( ) ; omgr . registerFlushDelay ( objclass , delay ) ; }
Instructs the distributed object manager associated with this client to allow objects of the specified class to linger around the specified number of milliseconds after their last subscriber has been removed before the client finally removes its object proxy and flushes the object . Normally objects are flushed immedia...
137,221
public synchronized boolean logon ( ) { if ( _comm != null ) { return false ; } _observers . apply ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientWillLogon ( _client ) ; } } ) ; _comm = createCommunicator ( ) ; _comm . setClassLoader ( _loader ) ; _comm . logon ( ) ; ...
Requests that this client connect and logon to the server with which it was previously configured .
137,222
public boolean logoff ( boolean abortable ) { if ( _comm == null ) { log . warning ( "Ignoring request to logoff because we're not logged on." ) ; return true ; } final boolean [ ] rejected = new boolean [ ] { false } ; _observers . apply ( new ObserverOps . Client ( this ) { protected void notify ( ClientObserver obs ...
Requests that the client log off of the server to which it is connected .
137,223
public String [ ] prepareStandaloneLogon ( ) { _standalone = true ; _observers . apply ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientWillLogon ( _client ) ; } } ) ; return getBootGroups ( ) ; }
Prepares the client for a standalone mode logon . Returns the set of bootstrap service groups that should be supplied to the invocation manager to create our fake bootstrap record .
137,224
public void standaloneLogon ( BootstrapData data , DObjectManager omgr ) { if ( ! _standalone ) { throw new IllegalStateException ( "Must call prepareStandaloneLogon() first." ) ; } gotBootstrap ( data , omgr ) ; }
Logs this client on in standalone mode with the faked bootstrap data and shared local distributed object manager .
137,225
public void standaloneLogoff ( ) { notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientDidLogoff ( _client ) ; } } ) ; cleanup ( null ) ; }
For standalone mode this notifies observers that the client has logged off and cleans up .
137,226
protected synchronized void setOutgoingMessageThrottle ( int msgsPerSec ) { log . info ( "Updating outgoing message throttle" , "msgsPerSec" , msgsPerSec ) ; _outThrottle . reinit ( msgsPerSec , 1000L ) ; _comm . postMessage ( new ThrottleUpdatedMessage ( ) ) ; }
Configures the outgoing message throttle . This is done when the server informs us that a new rate is in effect .
137,227
protected void tick ( ) { if ( _comm == null ) { return ; } long now = RunAnywhere . currentTimeMillis ( ) ; if ( _dcalc != null ) { if ( _dcalc . isDone ( ) ) { if ( debugLogMessages ( ) ) { log . info ( "Time offset from server: " + _serverDelta + "ms." ) ; } _dcalc = null ; } else if ( _dcalc . shouldSendPing ( ) ) ...
Called every five seconds ; ensures that we ping the server if we haven t communicated in a long while and periodically resyncs the client and server clock deltas .
137,228
protected void gotClientObject ( ClientObject clobj ) { _clobj = clobj ; notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientDidLogon ( _client ) ; } } ) ; }
Called by the invocation director when it successfully subscribes to the client object immediately following logon .
137,229
protected void getClientObjectFailed ( final Exception cause ) { notifyObservers ( new ObserverOps . Client ( this ) { protected void notify ( ClientObserver obs ) { obs . clientFailedToLogon ( _client , cause ) ; } } ) ; }
Called by the invocation director if it fails to subscribe to the client object after logon .
137,230
protected void clientObjectDidChange ( ClientObject clobj ) { _clobj = clobj ; _cloid = _clobj . getOid ( ) ; notifyObservers ( new ObserverOps . Session ( this ) { protected void notify ( SessionObserver obs ) { obs . clientObjectDidChange ( _client ) ; } } ) ; }
Called by the invocation director when it discovers that the client object has changed .
137,231
public Deque < Subfield > getSubfield ( String subfieldId ) { return subfields . stream ( ) . filter ( subfield -> subfield . getId ( ) . equals ( subfieldId ) ) . collect ( Collectors . toCollection ( LinkedList :: new ) ) ; }
Return all subfields of a given subfield ID . Multiple occurences may occur .
137,232
public MarcField matchValue ( Pattern pattern ) { if ( value != null && pattern . matcher ( value ) . matches ( ) ) { return this ; } for ( Subfield subfield : subfields ) { if ( pattern . matcher ( subfield . getValue ( ) ) . matches ( ) ) { return this ; } } return null ; }
Search for fields that match a pattern .
137,233
public String toTagIndicatorKey ( ) { return ( tag == null ? EMPTY_STRING : tag ) + KEY_DELIMITER + ( indicator == null ? EMPTY_STRING : indicator ) ; }
A MARC field can be denoted by a key independent of values . This key is a string consisting of tag and indicator delimited by a dollar sign .
137,234
public String toKey ( ) { return ( tag == null ? EMPTY_STRING : tag ) + KEY_DELIMITER + ( indicator == null ? EMPTY_STRING : indicator ) + KEY_DELIMITER + subfieldIds ; }
A MARC field can be denoted by a key independent of values . This key is a string consisting of tag indicator subfield IDs delimited by a dollar sign .
137,235
public void updateOccupantStatus ( BodyObject body , final byte status ) { if ( body . status != status ) { body . setStatus ( status ) ; body . getLocal ( BodyLocal . class ) . statusTime = System . currentTimeMillis ( ) ; } updateOccupantInfo ( body , new OccupantInfo . Updater < OccupantInfo > ( ) { public boolean u...
Updates the connection status for the given body object s occupant info in the specified location .
137,236
public void setIdle ( ClientObject caller , boolean idle ) { BodyObject bobj = _locator . forClient ( caller ) ; byte nstatus = ( idle ) ? OccupantInfo . IDLE : OccupantInfo . ACTIVE ; if ( bobj == null || bobj . status == nstatus ) { return ; } log . debug ( "Setting user idle state" , "user" , bobj . username , "stat...
from interface BodyProvider
137,237
public Stats getStats ( boolean snapshot ) { synchronized ( this ) { if ( snapshot ) { _recent = _current ; _current = new Stats ( ) ; _current . maxQueueSize = _queue . size ( ) ; } return _recent ; } }
Returns a recent snapshot of runtime statistics tracked by the invoker .
137,238
public final void requestProcessed ( Object result ) { @ SuppressWarnings ( "unchecked" ) T casted = ( T ) result ; requestCompleted ( casted ) ; }
from InvocationService . ResultListener
137,239
public void requestFailed ( Exception cause ) { if ( _chain != null ) { _chain . requestFailed ( cause ) ; } else if ( _invChain != null ) { _invChain . requestFailed ( ( cause instanceof InvocationException ) ? cause . getMessage ( ) : InvocationCodes . INTERNAL_ERROR ) ; } else { Object [ ] logArgs = MoreObjects . fi...
Override this to handle a request failed in your own way .
137,240
public void requestCompleted ( T result ) { if ( _chain != null ) { _chain . requestCompleted ( result ) ; } else if ( _invChain instanceof InvocationService . ResultListener ) { ( ( InvocationService . ResultListener ) _invChain ) . requestProcessed ( result ) ; } else if ( _invChain instanceof InvocationService . Con...
Override this to handle a request completion in your own way .
137,241
public void init ( CrowdContext ctx , PlaceConfig config ) { _ctx = ctx ; _config = config ; _view = createPlaceView ( _ctx ) ; applyToDelegates ( new DelegateOp ( PlaceControllerDelegate . class ) { public void apply ( PlaceControllerDelegate delegate ) { delegate . init ( _ctx , _config ) ; } } ) ; didInit ( ) ; }
Initializes this place controller with a reference to the context that they can use to access client services and to the configuration record for this place . The controller should create as much of its user interface that it can without having access to the place object because this will be invoked in parallel with th...
137,242
protected void addDelegate ( PlaceControllerDelegate delegate ) { if ( _delegates == null ) { _delegates = Lists . newArrayList ( ) ; } _delegates . add ( delegate ) ; }
Adds the supplied delegate to the list for this controller .
137,243
public void gotConfigInfo ( String [ ] keys , int [ ] oids ) { _csubscribers = new ConfigObjectSubscriber [ keys . length ] ; for ( int ii = 0 ; ii < keys . length ; ii ++ ) { _csubscribers [ ii ] = new ConfigObjectSubscriber ( ) ; _csubscribers [ ii ] . subscribeConfig ( keys [ ii ] , oids [ ii ] ) ; } }
documentation inherited from interface AdminService . ConfigInfoListener
137,244
public List < MarcField > getFields ( String tag ) { return marcFields . stream ( ) . filter ( marcField -> marcField . getTag ( ) . equals ( tag ) ) . collect ( Collectors . toList ( ) ) ; }
Return the MARC fields of this record with a given tag .
137,245
public List < MarcField > filterKey ( Pattern pattern ) { return marcFields . stream ( ) . map ( field -> field . matchKey ( pattern ) ) . filter ( Objects :: nonNull ) . collect ( Collectors . toList ( ) ) ; }
Return a list of MARC fields of this record where key pattern matches were found .
137,246
public List < MarcField > filterValue ( Pattern pattern ) { return marcFields . stream ( ) . map ( field -> field . matchValue ( pattern ) ) . filter ( Objects :: nonNull ) . collect ( Collectors . toList ( ) ) ; }
Return a list of MARC fields of this record where pattern matches were found .
137,247
public static SessionFactory newSessionFactory ( final Class < ? extends Credentials > credsClass , final Class < ? extends PresentsSession > sessionClass , final Class < ? extends Name > nameClass , final Class < ? extends ClientResolver > resolverClass ) { return new SessionFactory ( ) { public Class < ? extends Pres...
Creates a session factory that handles clients with the supplied credentials and authentication name .
137,248
public void init ( DObjectManager omgr , final int cloid , Client client ) { if ( _clobj != null ) { log . warning ( "Zoiks, client object around during invmgr init!" ) ; cleanup ( ) ; } _omgr = omgr ; _client = client ; _omgr . subscribeToObject ( cloid , new Subscriber < ClientObject > ( ) { public void objectAvailab...
Initializes the invocation director . This is called when the client establishes a connection with the server .
137,249
public void registerReceiver ( InvocationDecoder decoder ) { _reclist . add ( decoder ) ; if ( _clobj != null ) { assignReceiverId ( decoder ) ; } }
Registers an invocation notification receiver by way of its notification event decoder .
137,250
public void unregisterReceiver ( String receiverCode ) { for ( Iterator < InvocationDecoder > iter = _reclist . iterator ( ) ; iter . hasNext ( ) ; ) { InvocationDecoder decoder = iter . next ( ) ; if ( decoder . getReceiverCode ( ) . equals ( receiverCode ) ) { iter . remove ( ) ; } } if ( _clobj != null ) { Registrat...
Removes a receiver registration .
137,251
protected void assignReceiverIds ( ) { _clobj . startTransaction ( ) ; try { _clobj . setReceivers ( new DSet < Registration > ( ) ) ; for ( InvocationDecoder decoder : _reclist ) { assignReceiverId ( decoder ) ; } } finally { _clobj . commitTransaction ( ) ; } }
Called when we log on ; generates mappings for all receivers registered prior to logon .
137,252
public void eventReceived ( DEvent event ) { if ( event instanceof InvocationResponseEvent ) { InvocationResponseEvent ire = ( InvocationResponseEvent ) event ; handleInvocationResponse ( ire . getRequestId ( ) , ire . getMethodId ( ) , ire . getArgs ( ) ) ; } else if ( event instanceof InvocationNotificationEvent ) { ...
Process notification and response events arriving on user object .
137,253
protected void handleInvocationResponse ( int reqId , int methodId , Object [ ] args ) { ListenerMarshaller listener = _listeners . remove ( reqId ) ; if ( listener == null ) { log . warning ( "Received invocation response for which we have no registered listener. " + "It is possible that this listener was flushed beca...
Dispatches an invocation response .
137,254
protected void handleInvocationNotification ( int receiverId , int methodId , Object [ ] args ) { InvocationDecoder decoder = _receivers . get ( receiverId ) ; if ( decoder == null ) { log . warning ( "Received notification for which we have no registered receiver" , "recvId" , receiverId , "methodId" , methodId , "arg...
Dispatches an invocation notification .
137,255
protected void handleClientObjectChanged ( int newCloid ) { _omgr . subscribeToObject ( newCloid , new Subscriber < ClientObject > ( ) { public void objectAvailable ( ClientObject clobj ) { DSet < Registration > receivers = _clobj . receivers ; _clobj = clobj ; _clobj . addListener ( InvocationDirector . this ) ; _clob...
Called when the server has informed us that our previous client object is going the way of the Dodo because we re changing screen names . We subscribe to the new object and report to the client once we ve got our hands on it .
137,256
public PlaceManager createPlace ( PlaceConfig config ) throws InstantiationException , InvocationException { return createPlace ( config , null , null ) ; }
Creates and registers a new place manager with no delegates .
137,257
public PlaceManager createPlace ( PlaceConfig config , List < PlaceManagerDelegate > delegates ) throws InstantiationException , InvocationException { return createPlace ( config , delegates , null ) ; }
Creates and registers a new place manager along with the place object to be managed . The registry takes care of tracking the creation of the object and informing the manager when it is created .
137,258
public Iterator < PlaceObject > enumeratePlaces ( ) { final Iterator < PlaceManager > itr = _pmgrs . values ( ) . iterator ( ) ; return new Iterator < PlaceObject > ( ) { public boolean hasNext ( ) { return itr . hasNext ( ) ; } public PlaceObject next ( ) { PlaceManager plmgr = itr . next ( ) ; return ( plmgr == null ...
Returns an enumeration of all of the registered place objects . This should only be accessed on the dobjmgr thread and shouldn t be kept around across event dispatches .
137,259
protected PlaceManager createPlace ( PlaceConfig config , List < PlaceManagerDelegate > delegates , PreStartupHook hook ) throws InstantiationException , InvocationException { PlaceManager pmgr = null ; try { pmgr = createPlaceManager ( config ) ; if ( delegates != null ) { for ( PlaceManagerDelegate delegate : delegat...
Creates a place manager using the supplied config injects dependencies into and registers the supplied list of delegates runs the supplied pre - startup hook and finally returns it .
137,260
protected void unmapPlaceManager ( PlaceManager pmgr ) { int ploid = pmgr . getPlaceObject ( ) . getOid ( ) ; if ( _pmgrs . remove ( ploid ) == null ) { log . warning ( "Requested to unmap unmapped place manager" , "pmgr" , pmgr ) ; } }
Called by the place manager when it has been shut down .
137,261
public synchronized static boolean isStreamable ( Class < ? > target ) { maybeInit ( ) ; if ( _streamers . containsKey ( target ) || target . isEnum ( ) ) { return true ; } if ( target . isArray ( ) ) { return isStreamable ( target . getComponentType ( ) ) ; } return Streamable . class . isAssignableFrom ( target ) || ...
Returns true if the supplied target class can be streamed using a streamer .
137,262
public static Class < ? > getStreamerClass ( Object object ) { return ( object instanceof Enum < ? > ) ? ( ( Enum < ? > ) object ) . getDeclaringClass ( ) : object . getClass ( ) ; }
Returns the class that should be used when streaming this object . In general that is the object s natural class but for enum values that might be its declaring class as enums use classes in a way that would otherwise pollute our id to class mapping space .
137,263
public static Class < ? > getCollectionClass ( Class < ? > clazz ) { if ( Streamable . class . isAssignableFrom ( clazz ) ) { return null ; } for ( Class < ? > collClass : BasicStreamers . CollectionStreamer . SPECIFICITY_ORDER ) { if ( collClass . isAssignableFrom ( clazz ) ) { return collClass ; } } return null ; }
If the specified class is not Streamable and is a Collection type return the most specific supported Collection interface type ; otherwise return null .
137,264
protected static Streamer create ( Class < ? > target ) throws IOException { boolean isInner = false , isStatic = Modifier . isStatic ( target . getModifiers ( ) ) ; try { isInner = ( target . getDeclaringClass ( ) != null ) ; } catch ( Throwable t ) { log . warning ( "Failure checking innerness of class" , "class" , t...
Create the appropriate Streamer for a newly - seen class .
137,265
public void applyToOccupants ( OccupantOp op ) { if ( _plobj != null ) { for ( OccupantInfo info : _plobj . occupantInfo ) { op . apply ( info ) ; } } }
Applies the supplied occupant operation to each occupant currently present in this place .
137,266
public void init ( PlaceRegistry registry , InvocationManager invmgr , RootDObjectManager omgr , BodyLocator locator , PlaceConfig config ) { _registry = registry ; _invmgr = invmgr ; _omgr = omgr ; _locator = locator ; _config = config ; applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void ...
Called by the place registry after creating this place manager .
137,267
public void addDelegate ( PlaceManagerDelegate delegate ) { if ( _delegates == null ) { _delegates = Lists . newArrayList ( ) ; } if ( _omgr != null ) { delegate . init ( this , _omgr , _invmgr ) ; delegate . didInit ( _config ) ; } _delegates . add ( delegate ) ; }
Adds the supplied delegate to the list for this manager .
137,268
public void applyToDelegates ( DelegateOp op ) { if ( _delegates != null ) { for ( int ii = 0 , ll = _delegates . size ( ) ; ii < ll ; ii ++ ) { PlaceManagerDelegate delegate = _delegates . get ( ii ) ; if ( op . shouldApply ( delegate ) ) { op . apply ( delegate ) ; } } } }
Applies the supplied operation to this manager s registered delegates .
137,269
public void startup ( PlaceObject plobj ) { _plobj = plobj ; if ( shouldCreateSpeakService ( ) ) { plobj . setSpeakService ( addProvider ( createSpeakHandler ( plobj ) , SpeakMarshaller . class ) ) ; } plobj . addListener ( this ) ; plobj . addListener ( _bodyUpdater ) ; plobj . addListener ( _occListener ) ; plobj . a...
Called by the place manager after the place object has been successfully created .
137,270
public void registerMessageHandler ( String name , MessageHandler handler ) { if ( _msghandlers == null ) { _msghandlers = Maps . newHashMap ( ) ; } _msghandlers . put ( name , handler ) ; }
Registers a particular message handler instance to be used when processing message events with the specified name .
137,271
public void messageReceived ( MessageEvent event ) { if ( _msghandlers != null ) { MessageHandler handler = _msghandlers . get ( event . getName ( ) ) ; if ( handler != null ) { handler . handleEvent ( event , this ) ; } } if ( event . isPrivate ( ) ) { int srcoid = event . getSourceOid ( ) ; DObject source = ( srcoid ...
from interface MessageListener
137,272
protected < T extends InvocationMarshaller < ? > > T addProvider ( InvocationProvider prov , Class < T > mclass ) { T marsh = _invmgr . registerProvider ( prov , mclass ) ; _marshallers . add ( marsh ) ; return marsh ; }
Registers an invocation provider and notes the registration such that it will be automatically cleared when this manager shuts down .
137,273
protected < T extends InvocationMarshaller < ? > > T addDispatcher ( InvocationDispatcher < T > disp ) { T marsh = _invmgr . registerDispatcher ( disp ) ; _marshallers . add ( marsh ) ; return marsh ; }
Registers an invocation dispatcher and notes the registration such that it will be automatically cleared when this manager shuts down .
137,274
protected void bodyEntered ( final int bodyOid ) { log . debug ( "Body entered" , "where" , where ( ) , "oid" , bodyOid ) ; applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . bodyEntered ( bodyOid ) ; } } ) ; cancelShutdowner ( ) ; }
Called when a body object enters this place .
137,275
protected void bodyLeft ( final int bodyOid ) { log . debug ( "Body left" , "where" , where ( ) , "oid" , bodyOid ) ; Integer key = Integer . valueOf ( bodyOid ) ; if ( _plobj . occupantInfo . containsKey ( key ) ) { _plobj . removeFromOccupantInfo ( key ) ; } OccupantInfo leaver = _occInfo . remove ( bodyOid ) ; apply...
Called when a body object leaves this place .
137,276
protected void bodyUpdated ( final OccupantInfo info ) { applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . bodyUpdated ( info ) ; } } ) ; }
Called when a body s occupant info is updated .
137,277
protected void placeBecameEmpty ( ) { applyToDelegates ( new DelegateOp ( PlaceManagerDelegate . class ) { public void apply ( PlaceManagerDelegate delegate ) { delegate . placeBecameEmpty ( ) ; } } ) ; checkShutdownInterval ( ) ; }
Called when we transition from having bodies in the place to not having any bodies in the place . Some places may take this as a sign to pack it in others may wish to stick around . In any case they can override this method to do their thing .
137,278
protected void checkShutdownInterval ( ) { long idlePeriod = idleUnloadPeriod ( ) ; if ( idlePeriod > 0L && _shutdownInterval == null ) { ( _shutdownInterval = _omgr . newInterval ( new Runnable ( ) { public void run ( ) { log . debug ( "Unloading idle place '" + where ( ) + "'." ) ; shutdown ( ) ; } } ) ) . schedule (...
Called on startup and when the place is empty .
137,279
public static void sendInfo ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . INFO ) ; }
Sends a system INFO message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server .
137,280
public static void sendFeedback ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . FEEDBACK ) ; }
Sends a system FEEDBACK message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server .
137,281
public static void sendAttention ( DObject speakObj , String bundle , String message ) { sendSystem ( speakObj , bundle , message , SystemMessage . ATTENTION ) ; }
Sends a system ATTENTION message notification to the specified object with the supplied message content . A system message is one that will be rendered where the speak messages are rendered but in a way that makes it clear that it is a message from the server .
137,282
public static void sendMessage ( DObject speakObj , ChatMessage msg ) { if ( speakObj == null ) { log . warning ( "Dropping speak message, no speak obj '" + msg + "'." , new Exception ( ) ) ; return ; } speakObj . postMessage ( ChatCodes . CHAT_NOTIFICATION , new Object [ ] { msg } ) ; if ( ! ( msg instanceof UserMessa...
Send the specified message on the specified object .
137,283
protected static void sendSystem ( DObject speakObj , String bundle , String message , byte level ) { sendMessage ( speakObj , new SystemMessage ( message , bundle , level ) ) ; }
Send the specified system message on the specified dobj .
137,284
public static Twilight getTwilight ( double sunDistanceRadians ) { double altDegrees = 90.0 - Math . toDegrees ( sunDistanceRadians ) ; if ( altDegrees >= 0.0 ) { return Twilight . DAYLIGHT ; } else if ( altDegrees >= - 6.0 ) { return Twilight . CIVIL ; } else if ( altDegrees >= - 12.0 ) { return Twilight . NAUTICAL ; ...
Return the twilight condition for a point which is a given great circle distance from the current sub solar point .
137,285
public static Position getSubSolarPoint ( Calendar time ) { double jd = TimeUtil . getJulianDayNumber ( time ) ; double T = ( jd - 2451545.0 ) / 36525 ; double M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T ; double L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T ; double DL = ( 1.914...
Returns the position on the Earth s surface for which the sun appears to be straight above .
137,286
public void elementUpdated ( ElementUpdatedEvent event ) { dispatchMethod ( event . getName ( ) + "Updated" , new Object [ ] { event . getIndex ( ) , event . getValue ( ) } ) ; }
from interface ElementUpdateListener
137,287
public void dispatchMethod ( String name , Object [ ] arguments ) { Method method = _mcache . get ( name ) ; if ( method == null ) { if ( ! _mcache . containsKey ( name ) ) { _mcache . put ( name , method = resolveMethod ( name , arguments ) ) ; } } if ( method != null ) { try { method . invoke ( _target , arguments ) ...
Dynamically looks up the method in question on our target and dispatches an event if it does .
137,288
protected Method resolveMethod ( String name , Object [ ] arguments ) { Class < ? > [ ] ptypes = new Class < ? > [ arguments . length ] ; for ( int ii = 0 ; ii < arguments . length ; ii ++ ) { ptypes [ ii ] = arguments [ ii ] == null ? null : arguments [ ii ] . getClass ( ) ; } try { return _finder . findMethod ( name ...
Looks for a method that matches the supplied signature .
137,289
public static Transport getInstance ( Type type , int channel ) { if ( _unordered == null ) { int length = Type . values ( ) . length ; _unordered = new Transport [ length ] ; @ SuppressWarnings ( { "unchecked" } ) HashIntMap < Transport > [ ] ordered = ( HashIntMap < Transport > [ ] ) new HashIntMap < ? > [ length ] ;...
Returns the shared instance with the specified parameters .
137,290
public Transport combine ( Transport other ) { return getInstance ( _type . combine ( other . _type ) , ( _channel == other . _channel ) ? _channel : 0 ) ; }
Returns a transport that satisfies the requirements of this and the specified other transport .
137,291
public void broadcast ( Name from , String bundle , String msg , boolean attention , boolean forward ) { byte levelOrMode = ( from != null ) ? ChatCodes . BROADCAST_MODE : ( attention ? SystemMessage . ATTENTION : SystemMessage . INFO ) ; broadcast ( from , levelOrMode , bundle , msg , forward ) ; }
Broadcasts the specified message to all place objects in the system .
137,292
public void broadcast ( Name from , byte levelOrMode , String bundle , String msg , boolean forward ) { if ( _broadcastObject != null ) { broadcastTo ( _broadcastObject , from , levelOrMode , bundle , msg ) ; } else { for ( Iterator < PlaceObject > iter = _plreg . enumeratePlaces ( ) ; iter . hasNext ( ) ; ) { PlaceObj...
Broadcast with support for a customizable level or mode .
137,293
public void deliverTell ( UserMessage message , Name target , TellListener listener ) throws InvocationException { BodyObject tobj = _locator . lookupBody ( target ) ; if ( tobj == null ) { if ( _chatForwarder != null && _chatForwarder . forwardTell ( message , target , listener ) ) { return ; } throw new InvocationExc...
Delivers a tell message to the specified target and notifies the supplied listener of the result . It is assumed that the teller has already been permissions checked .
137,294
public void deliverTell ( BodyObject target , UserMessage message ) { SpeakUtil . sendMessage ( target , message ) ; SpeakUtil . noteMessage ( target , message . speaker , message ) ; }
Delivers a tell notification to the specified target player . It is assumed that the message is coming from some server entity and need not be permissions checked or notified of the result .
137,295
protected void broadcastTo ( DObject object , Name from , byte levelOrMode , String bundle , String msg ) { if ( from == null ) { SpeakUtil . sendSystem ( object , bundle , msg , levelOrMode ) ; } else { SpeakUtil . sendSpeak ( object , from , bundle , msg , levelOrMode ) ; } }
Direct a broadcast to the specified object .
137,296
public void appendReport ( StringBuilder report , long now , long sinceLast , boolean reset ) { PresentsConMgrStats stats = getStats ( ) ; long eventCount = stats . eventCount - _lastStats . eventCount ; int connects = stats . connects - _lastStats . connects ; int disconnects = stats . disconnects - _lastStats . disco...
from interface ReportManager . Reporter
137,297
public boolean setPrivateKey ( PrivateKey key ) { if ( SecureUtil . ciphersSupported ( key ) ) { _privateKey = key ; return true ; } return false ; }
Sets the private key if the ciphers are supported .
137,298
protected int handleDatagram ( DatagramChannel listener , long when ) { InetSocketAddress source ; _databuf . clear ( ) ; try { source = ( InetSocketAddress ) listener . receive ( _databuf ) ; } catch ( IOException ioe ) { log . warning ( "Failure receiving datagram." , ioe ) ; return 0 ; } if ( source == null ) { log ...
Called when a datagram message is ready to be read off its channel .
137,299
public void openOutgoingConnection ( Connection conn , String hostname , int port ) throws IOException { SocketChannel sockchan = SocketChannel . open ( ) ; sockchan . configureBlocking ( false ) ; conn . init ( this , sockchan , System . currentTimeMillis ( ) ) ; _connectq . append ( Tuple . newTuple ( conn , new Inet...
Opens an outgoing connection to the supplied address . The connection will be opened in a non - blocking manner and added to the connection manager s select set . Messages posted to the connection prior to it being actually connected to its destination will remain in the queue . If the connection fails those messages w...