idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
137,300
protected void startOutgoingConnection ( final Connection conn , InetSocketAddress addr ) { final SocketChannel sockchan = conn . getChannel ( ) ; try { conn . selkey = sockchan . register ( _selector , SelectionKey . OP_CONNECT ) ; NetEventHandler handler ; if ( sockchan . connect ( addr ) ) { _outConnValidator . vali...
Starts the connection process for an outgoing connection . This is called as part of the conmgr tick for any pending outgoing connections .
137,301
protected void processAuthedConnections ( long iterStamp ) { AuthingConnection conn ; while ( ( conn = _authq . getNonBlocking ( ) ) != null ) { try { PresentsConnection rconn = new PresentsConnection ( ) ; rconn . init ( this , conn . getChannel ( ) , iterStamp ) ; rconn . selkey = conn . selkey ; rconn . inheritStrea...
Converts connections that have completed the authentication process into full running connections and notifies the client manager that new connections have been established .
137,302
protected boolean writeDatagram ( PresentsConnection conn , byte [ ] data ) { InetSocketAddress target = conn . getDatagramAddress ( ) ; if ( target == null ) { log . warning ( "No address to send datagram" , "conn" , conn ) ; return false ; } _databuf . clear ( ) ; _databuf . put ( data ) . flip ( ) ; try { return con...
Sends a datagram to the specified connection .
137,303
public OccupantInfo getOccupantInfo ( Name username ) { try { for ( OccupantInfo info : occupantInfo ) { if ( info . username . equals ( username ) ) { return info ; } } } catch ( Throwable t ) { log . warning ( "PlaceObject.getOccupantInfo choked." , t ) ; } return null ; }
Looks up a user s occupant info by name .
137,304
public static double getJulianDayNumber ( Calendar time ) { if ( time == null ) { time = GregorianCalendar . getInstance ( TimeZone . getTimeZone ( "GMT" ) ) ; } double jd = BASE_JD + time . getTimeInMillis ( ) / MILLISEC_PER_DAY ; return jd ; }
Calculate the Julian day number corresponding to the time provided
137,305
protected final int decodeLength ( ) { if ( _have < HEADER_SIZE ) { return - 1 ; } _buffer . rewind ( ) ; int length = ( _buffer . get ( ) & 0xFF ) << 24 ; length += ( _buffer . get ( ) & 0xFF ) << 16 ; length += ( _buffer . get ( ) & 0xFF ) << 8 ; length += ( _buffer . get ( ) & 0xFF ) ; _buffer . position ( _have ) ;...
Decodes and returns the length of the current frame from the buffer if possible . Returns - 1 otherwise .
137,306
public static void addExistingImports ( String asFile , ImportSet imports ) { Matcher m = AS_PUBLIC_CLASS_DECL . matcher ( asFile ) ; int searchTo = asFile . length ( ) ; if ( m . find ( ) ) { searchTo = m . start ( ) ; } m = AS_IMPORT . matcher ( asFile . substring ( 0 , searchTo ) ) ; while ( m . find ( ) ) { imports...
Adds an existing ActionScript file s imports to the given ImportSet .
137,307
public static void convertBaseClasses ( ImportSet imports ) { imports . replace ( "byte" , "com.threerings.util.Byte" ) ; imports . replace ( "boolean" , "com.threerings.util.langBoolean" ) ; imports . replace ( "[B" , "flash.utils.ByteArray" ) ; imports . replace ( "float" , "com.threerings.util.Float" ) ; imports . r...
Converts java types to their actionscript equivalents for ooo - style streaming .
137,308
public void noteClassMappingsReceived ( Collection < Class < ? > > sclasses ) { if ( _classmap == null ) { throw new RuntimeException ( "Missing class map" ) ; } for ( Class < ? > sclass : sclasses ) { ClassMapping cmap = _classmap . get ( sclass ) ; if ( cmap == null ) { throw new RuntimeException ( "No class mapping ...
Notes that the receiver has received the mappings for a group of classes and thus that from now on only the codes need be sent .
137,309
public void noteInternMappingsReceived ( Collection < String > sinterns ) { if ( _internmap == null ) { throw new RuntimeException ( "Missing intern map" ) ; } for ( String sintern : sinterns ) { Short code = _internmap . get ( sintern ) ; if ( code == null ) { throw new RuntimeException ( "No intern mapping for " + si...
Notes that the receiver has received the mappings for a group of interns and thus that from now on only the codes need be sent .
137,310
public void write ( int b ) throws IOException { int newcount = count + 1 ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } buf [ count ] = ( byte ) b ; count = newcount ; }
Write an integer .
137,311
public void write ( byte [ ] b , int offset , int length ) throws IOException { if ( length == 0 ) { return ; } int newcount = count + length ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } System . arraycopy ( b , offset , buf , count , length ) ; count = newcount ; }
Write byte array .
137,312
public void skip ( int length ) { int newcount = count + length ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } count = newcount ; }
Skip a number of bytes .
137,313
public void parseEvents ( MarcXchangeEventConsumer consumer ) throws XMLStreamException { Objects . requireNonNull ( consumer ) ; if ( builder . getMarcListeners ( ) != null ) { for ( Map . Entry < String , MarcListener > entry : builder . getMarcListeners ( ) . entrySet ( ) ) { consumer . setMarcListener ( entry . get...
Run XML stream parser over an XML input stream with an XML event consumer .
137,314
public int wrapFields ( String type , ChunkStream < byte [ ] , BytesReference > stream , boolean withCollection ) throws IOException { int count = 0 ; MarcListener marcListener = builder . getMarcListener ( type ) ; if ( marcListener == null ) { return count ; } try { if ( withCollection ) { if ( marcListener instanceo...
Pass a given chunk stream to a MARC generator chunk by chunk . Can process any MARC streams not only separator streams .
137,315
public long wrapRecords ( ChunkStream < byte [ ] , BytesReference > stream , boolean withCollection ) throws IOException { final AtomicInteger l = new AtomicInteger ( ) ; try { MarcRecordListener marcRecordListener = builder . getMarcRecordListener ( ) ; if ( withCollection ) { if ( marcRecordListener instanceof Conten...
Wrap records into a collection . Can process any MARC streams not only separator streams .
137,316
protected void gotAuthResponse ( AuthResponse rsp ) throws LogonException { AuthResponseData data = rsp . getData ( ) ; if ( ! data . code . equals ( AuthResponseData . SUCCESS ) ) { throw new LogonException ( data . code ) ; } logonSucceeded ( data ) ; }
Subclasses must call this method when they receive the authentication response .
137,317
public void setAccessor ( Accessor < E > accessor ) { removeAll ( ) ; _accessor = accessor ; _table = new ObjectEditorTable ( _entryClass , _editableFields , _accessor . getInterp ( _interp ) , _displayFields ) ; add ( new JScrollPane ( _table ) , BorderLayout . CENTER ) ; }
Sets the logic for how this editor interacts with its underlying data .
137,318
protected void addEntry ( E entry ) { if ( _entryFilter == null || _entryFilter . apply ( entry ) ) { int index = _keys . insertSorted ( getKey ( entry ) ) ; _table . insertDatum ( entry , index ) ; } }
Handles the addition of an entry assuming our filter allows it .
137,319
protected void removeKey ( Comparable < ? > key ) { int index = _keys . indexOf ( key ) ; if ( index != - 1 ) { _keys . remove ( index ) ; _table . removeDatum ( index ) ; } }
Takes care of removing a key from
137,320
public void actionPerformed ( ActionEvent event ) { CommandEvent ce = ( CommandEvent ) event ; _accessor . updateEntry ( _setName , ( DSet . Entry ) ce . getArgument ( ) ) ; }
documentation inherited from interface ActionListener
137,321
public void clear ( String layerName ) { synchronized ( this ) { log . info ( "clearing cache for layer " + layerName ) ; for ( String key : cache . keySet ( ) ) { if ( key . contains ( layerName ) ) remove ( key ) ; } } }
TOOD improve this
137,322
public synchronized void put ( WmsRequest request , byte [ ] image ) { synchronized ( this ) { String key = getKey ( request ) ; keys . remove ( key ) ; keys . add ( key ) ; if ( keys . size ( ) > maxSize ) remove ( keys . get ( 0 ) ) ; if ( maxSize > 0 && layers . containsAll ( request . getLayers ( ) ) ) { cache . pu...
Sets the cached image for the request .
137,323
public static String cloneArgument ( Class < ? > dsclazz , Field field , String name ) { Class < ? > clazz = field . getType ( ) ; if ( clazz . isArray ( ) || dsclazz . equals ( clazz ) ) { return "(" + name + " == null) ? null : " + name + ".clone()" ; } else if ( dsclazz . isAssignableFrom ( clazz ) ) { return "(" + ...
Potentially clones the supplied argument if it is the type that needs such treatment .
137,324
public static String readClassName ( File source ) throws IOException { String pkgname = null , name = null ; BufferedReader bin = new BufferedReader ( new FileReader ( source ) ) ; String line ; while ( ( line = bin . readLine ( ) ) != null ) { Matcher pm = PACKAGE_PATTERN . matcher ( line ) ; if ( pm . find ( ) ) { p...
Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name .
137,325
public void bodyRemovedFromChannel ( ChatChannel channel , final int bodyId ) { _peerMan . invokeNodeAction ( new ChannelAction ( channel ) { protected void execute ( ) { ChannelInfo info = _channelMan . _channels . get ( _channel ) ; if ( info != null ) { info . participants . remove ( bodyId ) ; } else if ( _channelM...
When a body loses channel membership this method should be called so that any server that happens to be hosting that channel can be told that the body in question is now a participant .
137,326
public void collectChatHistory ( final Name user , final ResultListener < ChatHistoryResult > lner ) { _peerMan . invokeNodeRequest ( new NodeRequest ( ) { public boolean isApplicable ( NodeObject nodeobj ) { return true ; } protected void execute ( InvocationService . ResultListener listener ) { listener . requestProc...
Collects all chat messages heard by the given user on all peers .
137,327
public void speak ( ClientObject caller , final ChatChannel channel , String message , byte mode ) { BodyObject body = _locator . forClient ( caller ) ; final UserMessage umsg = new UserMessage ( body . getVisibleName ( ) , null , message , mode ) ; if ( _channels . containsKey ( channel ) ) { dispatchSpeak ( channel ,...
from interface ChannelSpeakProvider
137,328
protected void resolveAndDispatch ( final ChatChannel channel ) { NodeObject . Lock lock = new NodeObject . Lock ( "ChatChannel" , channel . getLockName ( ) ) ; _peerMan . performWithLock ( lock , new PeerManager . LockedOperation ( ) { public void run ( ) { ( ( CrowdNodeObject ) _peerMan . getNodeObject ( ) ) . addToH...
Resolves the channel specified in the supplied action and then dispatches it .
137,329
protected void resolutionComplete ( ChatChannel channel , Set < Integer > parts ) { ChannelInfo info = new ChannelInfo ( ) ; info . channel = channel ; info . participants = parts ; _channels . put ( channel , info ) ; for ( UserMessage msg : _resolving . remove ( channel ) ) { dispatchSpeak ( channel , msg ) ; } }
This should be called when a channel s participant set has been resolved .
137,330
protected void resolutionFailed ( ChatChannel channel , Exception cause ) { log . warning ( "Failed to resolve chat channel" , "channel" , channel , cause ) ; _resolving . remove ( channel ) ; }
This should be called if channel resolution fails .
137,331
protected void dispatchSpeak ( ChatChannel channel , final UserMessage message ) { final ChannelInfo info = _channels . get ( channel ) ; if ( info == null ) { log . warning ( "Requested to dispatch speak on unhosted channel" , "channel" , channel , "msg" , message ) ; return ; } if ( ! info . participants . contains (...
Requests that we dispatch the supplied message to all participants of the specified chat channel . The speaker will be validated prior to dispatching the message as the originating server does not have the information it needs to validate the speaker and must leave that to us the channel hosting server .
137,332
protected void deliverSpeak ( ChatChannel channel , UserMessage message , int [ ] bodyIds ) { channel = intern ( channel ) ; for ( int bodyId : bodyIds ) { BodyObject bobj = getBodyObject ( bodyId ) ; if ( bobj != null && shouldDeliverSpeak ( channel , message , bobj ) ) { _chatHistory . record ( channel , bobj . getCh...
Delivers the supplied chat channel message to the specified bodies .
137,333
protected void closeIdleChannels ( ) { long now = System . currentTimeMillis ( ) ; Iterator < Map . Entry < ChatChannel , ChannelInfo > > iter = _channels . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry < ChatChannel , ChannelInfo > entry = iter . next ( ) ; if ( now - entry . getValue ( ) . ...
Called periodically to check for and close any channels that have been idle too long .
137,334
protected ChatChannel intern ( ChatChannel channel ) { ChannelInfo chinfo = _channels . get ( channel ) ; if ( chinfo != null ) { return chinfo . channel ; } return channel ; }
Returns a widely referenced instance equivalent to the given channel if one is available . This reduces memory usage since clients send new channel instances with each message .
137,335
public static < E extends Enum < E > > StreamableEnumSet < E > noneOf ( Class < E > elementType ) { return new StreamableEnumSet < E > ( elementType ) ; }
Creates an empty set of the specified type .
137,336
public static < E extends Enum < E > > StreamableEnumSet < E > allOf ( Class < E > elementType ) { StreamableEnumSet < E > set = new StreamableEnumSet < E > ( elementType ) ; for ( E constant : elementType . getEnumConstants ( ) ) { set . add ( constant ) ; } return set ; }
Creates a set containing all elements of the specified type .
137,337
public static < E extends Enum < E > > StreamableEnumSet < E > copyOf ( StreamableEnumSet < E > s ) { return s . clone ( ) ; }
Creates a set containing all elements in the set provided .
137,338
public static < E extends Enum < E > > StreamableEnumSet < E > of ( E first , E ... rest ) { StreamableEnumSet < E > set = new StreamableEnumSet < E > ( first . getDeclaringClass ( ) ) ; set . add ( first ) ; for ( E e : rest ) { set . add ( e ) ; } return set ; }
Creates a set consisting of the specified elements .
137,339
public boolean add ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { return false ; } } if ( _size + 1 >= _oids . length ) { expand ( ) ; } _oids [ _size ++ ] = oid ; return true ; }
Adds the specified object id to the list if it is not already there .
137,340
public boolean remove ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { System . arraycopy ( _oids , ii + 1 , _oids , ii , -- _size - ii ) ; return true ; } } return false ; }
Removes the specified oid from the list .
137,341
public boolean contains ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { return true ; } } return false ; }
Returns true if the specified oid is in the list false if not .
137,342
public JPanel getEditor ( PresentsContext ctx , Field field ) { if ( field . getType ( ) . equals ( Boolean . TYPE ) ) { return new BooleanFieldEditor ( ctx , field , this ) ; } else { return new AsStringFieldEditor ( ctx , field , this ) ; } }
Returns the editor panel for the specified field .
137,343
public void getConfigInfo ( AdminService . ConfigInfoListener arg1 ) { AdminMarshaller . ConfigInfoMarshaller listener1 = new AdminMarshaller . ConfigInfoMarshaller ( ) ; listener1 . listener = arg1 ; sendRequest ( GET_CONFIG_INFO , new Object [ ] { listener1 } ) ; }
from interface AdminService
137,344
public void dispatchRequest ( ClientObject source , int methodId , Object [ ] args ) throws InvocationException { log . warning ( "Requested to dispatch unknown method" , "provider" , provider , "sourceOid" , source . getOid ( ) , "methodId" , methodId , "args" , args ) ; }
Dispatches the specified method to our provider .
137,345
public void speak ( String arg1 , byte arg2 ) { sendRequest ( SPEAK , new Object [ ] { arg1 , Byte . valueOf ( arg2 ) } ) ; }
from interface SpeakService
137,346
public static boolean isBlank ( Name name ) { return ( name == null || name . toString ( ) . equals ( BLANK . toString ( ) ) ) ; }
Returns true if this name is null or blank false if it contains useful data . This works on derived classes as well .
137,347
public String getNormal ( ) { if ( _normal == null ) { _normal = normalize ( _name ) ; if ( _normal . equals ( _name ) ) { _normal = _name ; } } return _normal ; }
Returns the normalized version of this name .
137,348
public boolean scheduleRegularReboot ( ) { int freq = getDayFrequency ( ) ; int hour = getRebootHour ( ) ; if ( freq <= 0 ) { return false ; } Calendars . Builder cal = Calendars . now ( ) ; int curHour = cal . get ( Calendar . HOUR_OF_DAY ) ; cal = cal . zeroTime ( ) . addHours ( hour ) . addDays ( ( curHour < hour ) ...
Schedules our next regularly scheduled reboot .
137,349
public void cancelReboot ( ) { if ( _interval != null ) { _interval . cancel ( ) ; _interval = null ; } _nextReboot = 0L ; _rebootSoon = false ; _initiator = null ; }
Cancel the currently scheduled reboot if any .
137,350
public int preventReboot ( String whereFrom ) { if ( whereFrom == null ) { throw new IllegalArgumentException ( "whereFrom must be descriptive." ) ; } int lockId = _nextRebootLockId ++ ; _rebootLocks . put ( lockId , whereFrom ) ; return lockId ; }
Called by an entity that would like to prevent a reboot .
137,351
protected void scheduleReboot ( long rebootTime , boolean exact , String initiator ) { cancelReboot ( ) ; long now = System . currentTimeMillis ( ) ; rebootTime = Math . max ( rebootTime , now ) ; long delay = rebootTime - now ; int [ ] warnings = getWarnings ( ) ; int level = - 1 ; for ( int ii = warnings . length - 1...
Schedule a reboot .
137,352
protected String getRebootMessage ( String key , int minutes ) { String msg = getCustomRebootMessage ( ) ; if ( StringUtil . isBlank ( msg ) ) { msg = "m.reboot_msg_standard" ; } return MessageBundle . compose ( key , MessageBundle . taint ( "" + minutes ) , msg ) ; }
Composes the given reboot message with the minutes and either the custom or standard details about the pending reboot .
137,353
protected void doWarning ( int level , int minutes ) { _rebootSoon = ( level > - 1 ) ; int [ ] warnings = getWarnings ( ) ; if ( level == warnings . length ) { if ( checkLocks ( ) ) { return ; } log . info ( "Performing automatic server reboot/shutdown, as scheduled by: " + _initiator ) ; broadcast ( "m.rebooting_now" ...
Do a warning schedule the next .
137,354
protected boolean checkLocks ( ) { if ( _rebootLocks . isEmpty ( ) ) { return false ; } log . info ( "Reboot delayed due to outstanding locks" , "locks" , _rebootLocks . elements ( ) ) ; broadcast ( "m.reboot_delayed" ) ; ( _interval = _omgr . newInterval ( new Runnable ( ) { public void run ( ) { doWarning ( getWarnin...
Check to see if there are outstanding reboot locks that may delay the reboot returning false if there are none .
137,355
protected void notifyObservers ( int level ) { final int warningsLeft = getWarnings ( ) . length - level - 1 ; final long msLeft = _nextReboot - System . currentTimeMillis ( ) ; _observers . apply ( new ObserverList . ObserverOp < PendingShutdownObserver > ( ) { public boolean apply ( PendingShutdownObserver observer )...
Notify all PendingShutdownObservers of the pending shutdown!
137,356
public void registerFlushDelay ( Class < ? > objclass , long delay ) { _delays . put ( objclass , Long . valueOf ( delay ) ) ; }
Registers an object flush delay .
137,357
public void processMessage ( Message msg ) { if ( _client . getRunQueue ( ) . isRunning ( ) ) { _actions . append ( msg ) ; _client . getRunQueue ( ) . postRunnable ( this ) ; } else { log . info ( "Dropping message as RunQueue is shutdown" , "msg" , msg ) ; } }
Called by the communicator when a message arrives from the network layer . We queue it up for processing and request some processing time on the main thread .
137,358
public void cleanup ( ) { for ( PendingRequest < ? > req : _penders . values ( ) ) { for ( Subscriber < ? > sub : req . targets ) { sub . requestFailed ( req . oid , new ObjectAccessException ( "Client connection closed" ) ) ; } } _penders . clear ( ) ; _flusher . cancel ( ) ; _flushes . clear ( ) ; _dead . clear ( ) ;...
Called when the client is cleaned up due to having disconnected from the server .
137,359
protected void dispatchEvent ( DEvent event ) { int remoteOid = event . getTargetOid ( ) ; DObject target = _ocache . get ( remoteOid ) ; if ( target == null ) { if ( ! _dead . containsKey ( remoteOid ) ) { log . warning ( "Unable to dispatch event on non-proxied object " + event + "." ) ; } return ; } _client . conver...
Called when a new event arrives from the server that should be dispatched to subscribers here on the client .
137,360
protected void dispatchEvent ( int remoteOid , DObject target , DEvent event ) { try { boolean notify = event . applyToObject ( target ) ; if ( event instanceof ObjectDestroyedEvent ) { _ocache . remove ( remoteOid ) ; } if ( notify ) { target . notifyListeners ( event ) ; } } catch ( Exception e ) { log . warning ( "F...
Dispatches an event on an already resolved target object .
137,361
protected < T extends DObject > void registerObjectAndNotify ( ObjectResponse < T > orsp ) { T obj = orsp . getObject ( ) ; obj . setManager ( this ) ; _ocache . put ( obj . getOid ( ) , obj ) ; PendingRequest < ? > req = _penders . remove ( obj . getOid ( ) ) ; if ( req == null ) { log . warning ( "Got object, but no ...
Registers this object in our proxy cache and notifies the subscribers that were waiting for subscription to this object .
137,362
protected void flushObject ( DObject obj ) { int ooid = obj . getOid ( ) ; _ocache . remove ( ooid ) ; _dead . put ( ooid , obj ) ; _comm . postMessage ( new UnsubscribeRequest ( ooid ) ) ; }
Flushes a distributed object subscription issuing an unsubscribe request to the server .
137,363
protected void flushObjects ( ) { long now = System . currentTimeMillis ( ) ; for ( Iterator < IntMap . IntEntry < FlushRecord > > iter = _flushes . intEntrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { IntMap . IntEntry < FlushRecord > entry = iter . next ( ) ; FlushRecord rec = entry . getValue ( ) ; if ( rec . e...
Called periodically to flush any objects that have been lingering due to a previously enacted flush delay .
137,364
public static Cipher getAESCipher ( int mode , byte [ ] key ) { try { Cipher cipher = Cipher . getInstance ( "AES/CBC/PKCS5Padding" ) ; SecretKeySpec aesKey = new SecretKeySpec ( key , "AES" ) ; cipher . init ( mode , aesKey , IVPS ) ; return cipher ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed t...
Creates our AES cipher .
137,365
public static Cipher getRSACipher ( int mode , Key key ) { try { Cipher cipher = Cipher . getInstance ( "RSA" ) ; cipher . init ( mode , key ) ; return cipher ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to create cipher" , gse ) ; } return null ; }
Creates our RSA cipher .
137,366
public static KeyPair genRSAKeyPair ( int bits ) { try { KeyPairGenerator kpg = KeyPairGenerator . getInstance ( "RSA" ) ; kpg . initialize ( bits ) ; return kpg . genKeyPair ( ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to create key pair" , gse ) ; } return null ; }
Creates an RSA key pair .
137,367
public static PublicKey stringToRSAPublicKey ( String str ) { try { BigInteger mod = new BigInteger ( str . substring ( 0 , str . indexOf ( SPLIT ) ) , 16 ) ; BigInteger exp = new BigInteger ( str . substring ( str . indexOf ( SPLIT ) + 1 ) , 16 ) ; RSAPublicKeySpec keySpec = new RSAPublicKeySpec ( mod , exp ) ; KeyFac...
Creates a public key from the supplied string .
137,368
public static PrivateKey stringToRSAPrivateKey ( String str ) { try { BigInteger mod = new BigInteger ( str . substring ( 0 , str . indexOf ( SPLIT ) ) , 16 ) ; BigInteger exp = new BigInteger ( str . substring ( str . indexOf ( SPLIT ) + 1 ) , 16 ) ; RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec ( mod , exp ) ; Ke...
Creates a private key from the supplied string .
137,369
public static byte [ ] encryptBytes ( PublicKey key , byte [ ] secret , byte [ ] salt ) { byte [ ] encrypt = new byte [ secret . length + salt . length ] ; for ( int ii = 0 ; ii < secret . length ; ii ++ ) { encrypt [ ii ] = secret [ ii ] ; } for ( int ii = 0 ; ii < salt . length ; ii ++ ) { encrypt [ secret . length +...
Encrypts a secret key and salt with a public key .
137,370
public static byte [ ] decryptBytes ( PrivateKey key , byte [ ] encrypted , byte [ ] salt ) { try { byte [ ] decrypted = getRSACipher ( key ) . doFinal ( encrypted ) ; for ( int ii = 0 ; ii < salt . length ; ii ++ ) { if ( decrypted [ decrypted . length - salt . length + ii ] != salt [ ii ] ) { return null ; } } byte [...
Decrypts a secret key and checks for tailing salt .
137,371
public static byte [ ] xorBytes ( byte [ ] data , byte [ ] key ) { byte [ ] xored = new byte [ data . length ] ; for ( int ii = 0 ; ii < data . length ; ii ++ ) { xored [ ii ] = ( byte ) ( data [ ii ] ^ key [ ii % key . length ] ) ; } return xored ; }
XORs a byte array against a key .
137,372
public void commit ( ) { clearTarget ( ) ; int size = _events . size ( ) ; switch ( size ) { case 0 : break ; case 1 : _omgr . postEvent ( _events . get ( 0 ) ) ; break ; default : _transport = _events . get ( 0 ) . getTransport ( ) ; for ( int ii = 1 ; ii < size ; ii ++ ) { _transport = _events . get ( ii ) . getTrans...
Commits this transaction by posting this event to the distributed object event queue . All participating dobjects will have their transaction references cleared and will go back to normal operation .
137,373
public PlaceConfig moveTo ( BodyObject source , int placeOid ) throws InvocationException { PlaceManager pmgr = _plreg . getPlaceManager ( placeOid ) ; if ( pmgr == null ) { log . info ( "Requested to move to non-existent place" , "who" , source . who ( ) , "placeOid" , placeOid ) ; throw new InvocationException ( NO_S...
Moves the specified body from whatever location they currently occupy to the location identified by the supplied place oid .
137,374
public void leaveOccupiedPlace ( BodyObject source ) { Place oldloc = source . location ; if ( oldloc == null ) { return ; } PlaceManager pmgr = _plreg . getPlaceManager ( oldloc . placeOid ) ; if ( pmgr == null ) { log . warning ( "Body requested to leave no longer existent place?" , "boid" , source . getOid ( ) , "pl...
Removes the specified body from the place object they currently occupy . Does nothing if the body is not currently in a place .
137,375
public void init ( int invOid , int invCode , InvocationDirector invDir ) { _invOid = invOid ; _invCode = invCode ; _invdir = invDir ; }
Initializes this invocation marshaller instance with the requisite information to allow it to operate in the wide world . This is called by the invocation manager when an invocation provider is registered and should not be called otherwise .
137,376
protected void sendRequest ( int methodId , Object [ ] args , Transport transport ) { _invdir . sendRequest ( _invOid , _invCode , methodId , args , transport ) ; }
Called by generated invocation marshaller code ; packages up and sends the specified invocation service request .
137,377
public static FieldMarshaller getFieldMarshaller ( Field field ) { if ( _marshallers == null ) { _marshallers = createMarshallers ( ) ; } if ( useFieldAccessors ( ) ) { Method reader = null , writer = null ; try { reader = field . getDeclaringClass ( ) . getMethod ( getReaderMethodName ( field . getName ( ) ) , READER_...
Returns a field marshaller appropriate for the supplied field or null if no marshaller exists for the type contained by the field in question .
137,378
protected void sendOutgoingMessages ( long iterStamp ) { if ( _oflowqs . size ( ) > 0 ) { for ( OverflowQueue oq : _oflowqs . values ( ) . toArray ( new OverflowQueue [ _oflowqs . size ( ) ] ) ) { try { if ( oq . writeOverflowMessages ( iterStamp ) ) { _oflowqs . remove ( oq . conn ) ; } } catch ( IOException ioe ) { o...
Writes all queued overflow and normal messages to their respective sockets . Connections that already have established overflow queues will have their messages appended to their overflow queue instead so that they are delivered in the proper order .
137,379
protected boolean writeMessage ( Connection conn , byte [ ] data , PartialWriteHandler pwh ) { if ( conn . isClosed ( ) ) { return true ; } if ( data == ASYNC_CLOSE_REQUEST ) { closeConnection ( conn ) ; return true ; } if ( data . length > 1024 * 1024 ) { log . warning ( "Refusing to write very large message" , "conn"...
Writes a message out to a connection passing the buck to the partial write handler if the entire message could not be written .
137,380
protected void connectionFailed ( Connection conn , IOException ioe ) { _handlers . remove ( conn . selkey ) ; _connections . remove ( conn . getConnectionId ( ) ) ; _oflowqs . remove ( conn ) ; synchronized ( this ) { _stats . disconnects ++ ; } }
Called by a connection if it experiences a network failure .
137,381
protected void connectionClosed ( Connection conn ) { _handlers . remove ( conn . selkey ) ; _connections . remove ( conn . getConnectionId ( ) ) ; _oflowqs . remove ( conn ) ; synchronized ( this ) { _stats . closes ++ ; } }
Called by a connection when it discovers that it s closed .
137,382
public static < K , V > StreamableHashMap < K , V > newMap ( Map < ? extends K , ? extends V > map ) { return new StreamableHashMap < K , V > ( map ) ; }
Creates StreamableHashMap populated with the same values as the provided Map .
137,383
public void shutdown ( ) { if ( _chatdir != null ) { _chatdir . removeChatFilter ( this ) ; _chatdir = null ; } _ctx . getClient ( ) . removeClientObserver ( this ) ; }
Called to shut down the mute director .
137,384
public void setMuted ( Name username , boolean mute ) { boolean changed = mute ? _mutelist . add ( username ) : _mutelist . remove ( username ) ; String feedback ; if ( mute ) { feedback = "m.muted" ; } else { feedback = changed ? "m.unmuted" : "m.notmuted" ; } _chatdir . displayFeedback ( null , MessageBundle . tcompo...
Mute or unmute the specified user .
137,385
public String filter ( String msg , Name otherUser , boolean outgoing ) { if ( ( otherUser != null ) && isMuted ( otherUser ) ) { if ( outgoing ) { _chatdir . displayFeedback ( null , "m.no_tell_mute" ) ; } return null ; } return msg ; }
documentation inherited from interface ChatFilter
137,386
protected void notifyObservers ( final Name username , final boolean muted ) { _observers . apply ( new ObserverList . ObserverOp < MuteObserver > ( ) { public boolean apply ( MuteObserver observer ) { observer . muteChanged ( username , muted ) ; return true ; } } ) ; }
Notify our observers of a change in the mutelist .
137,387
public void clearDispatcher ( InvocationMarshaller < ? > marsh ) { _omgr . requireEventThread ( ) ; if ( marsh == null ) { log . warning ( "Refusing to unregister null marshaller." , new Exception ( ) ) ; return ; } if ( _dispatchers . remove ( marsh . getInvocationCode ( ) ) == null ) { log . warning ( "Requested to r...
Clears out a dispatcher registration . This should be called to free up resources when an invocation service is no longer going to be used .
137,388
public List < InvocationMarshaller < ? > > getBootstrapServices ( String [ ] bootGroups ) { List < InvocationMarshaller < ? > > services = Lists . newArrayList ( ) ; for ( String group : bootGroups ) { services . addAll ( _bootlists . get ( group ) ) ; } return services ; }
Constructs a list of all bootstrap services registered in any of the supplied groups .
137,389
public Class < ? > getDispatcherClass ( int invCode ) { Object dispatcher = _dispatchers . get ( invCode ) ; return ( dispatcher == null ) ? null : dispatcher . getClass ( ) ; }
Get the class that is being used to dispatch the specified invocation code for informational purposes .
137,390
protected void dispatchRequest ( int clientOid , int invCode , int methodId , Object [ ] args , Transport transport ) { ClientObject source = ( ClientObject ) _omgr . getObject ( clientOid ) ; if ( source == null ) { log . info ( "Client no longer around for invocation request" , "clientOid" , clientOid , "code" , invC...
Called when we receive an invocation request message . Dispatches the request to the appropriate invocation provider via the registered invocation dispatcher .
137,391
public void setClientInfo ( String msg , String ltype ) { message = msg ; localtype = ltype ; bundle = null ; timestamp = System . currentTimeMillis ( ) ; }
Once this message reaches the client the information contained within is changed around a bit .
137,392
protected int innerCompare ( Comparable < Object > co1 , Comparable < Object > co2 ) { return co1 . compareTo ( co2 ) ; }
Override this to customize the comparation itself . E . g . inversing it .
137,393
protected void processClass ( File source ) { CtClass clazz ; InputStream in = null ; try { clazz = _pool . makeClass ( in = new BufferedInputStream ( new FileInputStream ( source ) ) ) ; } catch ( IOException ioe ) { System . err . println ( "Failed to load " + source + ": " + ioe ) ; return ; } finally { StreamUtil ....
Processes a class file .
137,394
protected synchronized void createAgent ( int agentId ) { Subscriber < AgentObject > delegator = new Subscriber < AgentObject > ( ) { public void objectAvailable ( AgentObject agentObject ) { BureauDirector . this . objectAvailable ( agentObject ) ; } public void requestFailed ( int oid , ObjectAccessException cause ) ...
Creates a new agent when the server requests it .
137,395
protected synchronized void destroyAgent ( int agentId ) { Agent agent = null ; agent = _agents . remove ( agentId ) ; if ( agent == null ) { log . warning ( "Lost an agent, id " + agentId ) ; } else { try { agent . stop ( ) ; } catch ( Throwable t ) { log . warning ( "Stopping an agent caused an exception" , t ) ; } S...
Destroys an agent at the server s request .
137,396
protected synchronized void objectAvailable ( AgentObject agentObject ) { int oid = agentObject . getOid ( ) ; log . info ( "Object " + oid + " now available" ) ; Agent agent ; try { agent = createAgent ( agentObject ) ; agent . init ( agentObject ) ; agent . start ( ) ; } catch ( Throwable t ) { log . warning ( "Could...
Callback for when the a request to subscribe to an object finishes and the object is available .
137,397
public void handleSuccess ( ) { if ( _listener instanceof InvocationService . ConfirmListener ) { reportRequestProcessed ( ) ; } else if ( _listener instanceof InvocationService . ResultListener && _resultSet ) { reportRequestProcessed ( _result ) ; } }
Handles the success case which by default posts a response to a ConfirmListener . If you need something else or to repond to a ResultListener you ll need to override this .
137,398
public void handleFailure ( Exception error ) { if ( error instanceof InvocationException ) { _listener . requestFailed ( error . getMessage ( ) ) ; } else { if ( _args != null ) { log . warning ( getFailureMessage ( ) , ArrayUtil . append ( _args , error ) ) ; } else { log . warning ( getFailureMessage ( ) , error ) ;...
Handles the failure case by logging the error and reporting an internal error to the listener .
137,399
public void addConstraint ( Shutdowner lhs , Constraint constraint , Shutdowner rhs ) { switch ( constraint ) { case RUNS_BEFORE : _cycle . addShutdownConstraint ( lhs , Lifecycle . Constraint . RUNS_BEFORE , rhs ) ; break ; case RUNS_AFTER : _cycle . addShutdownConstraint ( lhs , Lifecycle . Constraint . RUNS_AFTER , ...
Adds a constraint that a certain shutdowner must be run before another .