idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
38,200
public MutableArray insertDate ( int index , Date value ) { return insertValue ( index , value ) ; }
Inserts a Date object at the given index .
38,201
public MutableArray insertArray ( int index , Array value ) { return insertValue ( index , value ) ; }
Inserts an Array object at the given index .
38,202
public MutableArray insertDictionary ( int index , Dictionary value ) { return insertValue ( index , value ) ; }
Inserts a Dictionary object at the given index .
38,203
public MutableArray remove ( int index ) { synchronized ( lock ) { if ( ! internalArray . remove ( index ) ) { throwRangeException ( index ) ; } return this ; } }
Removes the object at the given index .
38,204
public FLSliceResult getContents ( C4BlobKey blobKey ) throws LiteCoreException { return new FLSliceResult ( getContents ( handle , blobKey . getHandle ( ) ) ) ; }
Reads the entire contents of a blob into memory . Caller is responsible for freeing it .
38,205
public C4BlobReadStream openReadStream ( C4BlobKey blobKey ) throws LiteCoreException { return new C4BlobReadStream ( openReadStream ( handle , blobKey . getHandle ( ) ) ) ; }
Opens a blob for reading as a random - access byte stream .
38,206
public MValue get ( long index ) { if ( index < 0 || index >= values . size ( ) ) { return MValue . EMPTY ; } MValue value = values . get ( ( int ) index ) ; if ( value . isEmpty ( ) && ( baseArray != null ) ) { value = new MValue ( baseArray . get ( index ) ) ; values . set ( ( int ) index , value ) ; } return value ; }
Returns a reference to the MValue of the item at the given index . If the index is out of range returns an empty MValue .
38,207
public static String getVersionInfo ( ) { String info = versionInfo . get ( ) ; if ( info == null ) { info = String . format ( Locale . ENGLISH , VERSION_INFO , getLibInfo ( ) , getSysInfo ( ) ) ; versionInfo . compareAndSet ( null , info ) ; } return info ; }
This is the full library build and environment information .
38,208
public static String getLibInfo ( ) { String info = libInfo . get ( ) ; if ( info == null ) { info = String . format ( Locale . ENGLISH , LIB_INFO , C4 . getVersion ( ) ) ; libInfo . compareAndSet ( null , info ) ; } return info ; }
This is the short library build information .
38,209
public static String getSysInfo ( ) { String info = sysInfo . get ( ) ; if ( info == null ) { info = String . format ( Locale . ENGLISH , SYS_INFO , System . getProperty ( "os.name" , "unknown" ) ) ; sysInfo . compareAndSet ( null , info ) ; } return info ; }
This is information about the system on which we are running .
38,210
public Map < String , Object > toMap ( ) { synchronized ( lock ) { final Map < String , Object > result = new HashMap < > ( ) ; for ( String key : internalDict ) { result . put ( key , Fleece . toObject ( getMValue ( internalDict , key ) . asNative ( internalDict ) ) ) ; } return result ; } }
Gets content of the current object as an Map . The values contained in the returned Map object are all JSON based values .
38,211
public String getString ( int index ) { check ( index ) ; final Object obj = fleeceValueToObject ( index ) ; return obj instanceof String ? ( String ) obj : null ; }
The projecting result value at the given index as a String object
38,212
public Number getNumber ( int index ) { check ( index ) ; return CBLConverter . asNumber ( fleeceValueToObject ( index ) ) ; }
The projecting result value at the given index as a Number object
38,213
public int getInt ( int index ) { check ( index ) ; final FLValue flValue = values . get ( index ) ; return flValue != null ? ( int ) flValue . asInt ( ) : 0 ; }
The projecting result value at the given index as a integer value
38,214
public float getFloat ( int index ) { check ( index ) ; final FLValue flValue = values . get ( index ) ; return flValue != null ? flValue . asFloat ( ) : 0.0F ; }
The projecting result value at the given index as a float value
38,215
public double getDouble ( int index ) { check ( index ) ; final FLValue flValue = values . get ( index ) ; return flValue != null ? flValue . asDouble ( ) : 0.0 ; }
The projecting result value at the given index as a double value
38,216
public boolean getBoolean ( int index ) { check ( index ) ; final FLValue flValue = values . get ( index ) ; return flValue != null && flValue . asBool ( ) ; }
The projecting result value at the given index as a boolean value
38,217
public Blob getBlob ( int index ) { check ( index ) ; final Object obj = fleeceValueToObject ( index ) ; return obj instanceof Blob ? ( Blob ) obj : null ; }
The projecting result value at the given index as a Blob object
38,218
public Date getDate ( int index ) { check ( index ) ; return DateUtils . fromJson ( getString ( index ) ) ; }
The projecting result value at the given index as an Array object
38,219
public Array getArray ( int index ) { check ( index ) ; final Object obj = fleeceValueToObject ( index ) ; return obj instanceof Array ? ( Array ) obj : null ; }
The projecting result value at the given index as a Array object
38,220
public Dictionary getDictionary ( int index ) { check ( index ) ; final Object obj = fleeceValueToObject ( index ) ; return obj instanceof Dictionary ? ( Dictionary ) obj : null ; }
The projecting result value at the given index as a Dictionary object
38,221
public List < Object > toList ( ) { final List < Object > array = new ArrayList < > ( ) ; for ( int i = 0 ; i < count ( ) ; i ++ ) { array . add ( values . get ( i ) . asObject ( ) ) ; } return array ; }
Gets all values as an List . The value types of the values contained in the returned List object are Array Blob Dictionary Number types String and null .
38,222
public Map < String , Object > toMap ( ) { final List < Object > values = toList ( ) ; final Map < String , Object > dict = new HashMap < > ( ) ; for ( String name : rs . getColumnNames ( ) . keySet ( ) ) { final int index = indexForColumnName ( name ) ; if ( index >= 0 ) { dict . put ( name , values . get ( index ) ) ; } } return dict ; }
Gets all values as a Dictionary . The value types of the values contained in the returned Dictionary object are Array Blob Dictionary Number types String and null .
38,223
public Expression isNullOrMissing ( ) { return new UnaryExpression ( this , UnaryExpression . OpType . Null ) . or ( new UnaryExpression ( this , UnaryExpression . OpType . Missing ) ) ; }
Creates an IS NULL OR MISSING expression that evaluates whether or not the current expression is null or missing .
38,224
public static void throwException ( int domain , int code , String msg ) throws LiteCoreException { throw new LiteCoreException ( domain , code , msg ) ; }
NOTE called to throw LiteCoreException from native code to Java
38,225
public void compact ( ) throws CouchbaseLiteException { synchronized ( lock ) { mustBeOpen ( ) ; try { getC4Database ( ) . compact ( ) ; } catch ( LiteCoreException e ) { throw CBLStatus . convertException ( e ) ; } } }
Compacts the database file by deleting unused attachment files and vacuuming the SQLite database
38,226
public void close ( ) throws CouchbaseLiteException { synchronized ( lock ) { if ( c4db == null ) { return ; } Log . i ( DOMAIN , "Closing %s at path %s" , this , getC4Database ( ) . getPath ( ) ) ; if ( activeReplications . size ( ) > 0 ) { throw new CouchbaseLiteException ( "Cannot close the database. Please stop all of the replicators before closing the database." , CBLError . Domain . CBLITE , CBLError . Code . BUSY ) ; } if ( activeLiveQueries . size ( ) > 0 ) { throw new CouchbaseLiteException ( "Cannot close the database. Please remove all of the query listeners before closing the database." , CBLError . Domain . CBLITE , CBLError . Code . BUSY ) ; } cancelPurgeTimer ( ) ; closeC4DB ( ) ; freeC4Observers ( ) ; freeC4DB ( ) ; shutdownExecutorService ( ) ; } }
Closes a database .
38,227
public void delete ( ) throws CouchbaseLiteException { synchronized ( lock ) { mustBeOpen ( ) ; Log . i ( DOMAIN , "Deleting %s at path %s" , this , getC4Database ( ) . getPath ( ) ) ; if ( activeReplications . size ( ) > 0 ) { throw new CouchbaseLiteException ( "Cannot delete the database. Please stop all of the replicators before closing the database." , CBLError . Domain . CBLITE , CBLError . Code . BUSY ) ; } if ( activeLiveQueries . size ( ) > 0 ) { throw new CouchbaseLiteException ( "Cannot delete the database. Please remove all of the query listeners before closing the " + "database." , CBLError . Domain . CBLITE , CBLError . Code . BUSY ) ; } cancelPurgeTimer ( ) ; deleteC4DB ( ) ; freeC4Observers ( ) ; freeC4DB ( ) ; shutdownExecutorService ( ) ; } }
Deletes a database .
38,228
private boolean save ( Document document , boolean deletion , ConcurrencyControl concurrencyControl ) throws CouchbaseLiteException { if ( deletion && ! document . exists ( ) ) { throw new CouchbaseLiteException ( "Cannot delete a document that has not yet been saved." , CBLError . Domain . CBLITE , CBLError . Code . NOT_FOUND ) ; } C4Document curDoc = null ; C4Document newDoc = null ; synchronized ( lock ) { mustBeOpen ( ) ; prepareDocument ( document ) ; boolean commit = false ; beginTransaction ( ) ; try { try { newDoc = save ( document , null , deletion ) ; commit = true ; } catch ( LiteCoreException e ) { if ( ! ( e . domain == C4Constants . ErrorDomain . LITE_CORE && e . code == C4Constants . LiteCoreError . CONFLICT ) ) { throw CBLStatus . convertException ( e ) ; } } if ( newDoc == null ) { if ( concurrencyControl . equals ( ConcurrencyControl . FAIL_ON_CONFLICT ) ) { return false ; } try { curDoc = getC4Database ( ) . get ( document . getId ( ) , true ) ; } catch ( LiteCoreException e ) { if ( deletion && e . domain == C4Constants . ErrorDomain . LITE_CORE && e . code == C4Constants . LiteCoreError . NOT_FOUND ) { return true ; } else { throw CBLStatus . convertException ( e ) ; } } if ( deletion && curDoc . deleted ( ) ) { document . replaceC4Document ( curDoc ) ; curDoc = null ; return true ; } try { newDoc = save ( document , curDoc , deletion ) ; } catch ( LiteCoreException e ) { throw CBLStatus . convertException ( e ) ; } } document . replaceC4Document ( newDoc ) ; commit = true ; } finally { if ( curDoc != null ) { curDoc . retain ( ) ; curDoc . release ( ) ; } try { endTransaction ( commit ) ; } catch ( CouchbaseLiteException e ) { if ( newDoc != null ) { newDoc . release ( ) ; } throw e ; } } return true ; } }
The main save method .
38,229
void start ( ) { synchronized ( lock ) { if ( query . getDatabase ( ) == null ) { throw new IllegalArgumentException ( "associated database should not be null." ) ; } observing = true ; releaseResultSet ( ) ; query . getDatabase ( ) . getActiveLiveQueries ( ) . add ( this ) ; if ( dbListenerToken == null ) { dbListenerToken = query . getDatabase ( ) . addChangeListener ( this ) ; } update ( 0 ) ; } }
Starts observing database changes and reports changes in the query result .
38,230
private void stop ( boolean removeFromList ) { synchronized ( lock ) { observing = false ; willUpdate = false ; if ( query != null && query . getDatabase ( ) != null && dbListenerToken != null ) { query . getDatabase ( ) . removeChangeListener ( dbListenerToken ) ; dbListenerToken = null ; } if ( removeFromList && query != null && query . getDatabase ( ) != null ) { query . getDatabase ( ) . getActiveLiveQueries ( ) . remove ( this ) ; } releaseResultSet ( ) ; } }
Stops observing database changes .
38,231
public C4Replicator createReplicator ( C4Socket openSocket , int push , int pull , byte [ ] options , C4ReplicatorListener listener , Object replicatorContext ) throws LiteCoreException { return new C4Replicator ( handle , openSocket . handle , push , pull , options , listener , replicatorContext ) ; }
- Fleece - related
38,232
void addNetworkReachabilityListener ( NetworkReachabilityListener listener ) { synchronized ( listeners ) { listeners . add ( listener ) ; if ( listeners . size ( ) == 1 ) { startListening ( ) ; } } }
Add Network Reachability Listener
38,233
void removeNetworkReachabilityListener ( NetworkReachabilityListener listener ) { synchronized ( listeners ) { listeners . remove ( listener ) ; if ( listeners . size ( ) == 0 ) { stopListening ( ) ; } } }
Remove Network Reachability Listener
38,234
void notifyListenersNetworkReachable ( ) { final Set < NetworkReachabilityListener > copy = new HashSet < > ( listeners ) ; for ( NetworkReachabilityListener listener : copy ) { if ( listener != null ) { listener . networkReachable ( ) ; } } }
Notify listeners that the network is now reachable
38,235
void notifyListenersNetworkUneachable ( ) { final Set < NetworkReachabilityListener > copy = new HashSet < > ( listeners ) ; for ( NetworkReachabilityListener listener : copy ) { if ( listener != null ) { listener . networkUnreachable ( ) ; } } }
Notify listeners that the network is now unreachable
38,236
public Object getValue ( int index ) { synchronized ( lock ) { return getMValue ( internalArray , index ) . asNative ( internalArray ) ; } }
Gets value at the given index as an object . The object types are Blob Array Dictionary Number or String based on the underlying data type ; or nil if the value is nil .
38,237
public String getString ( int index ) { synchronized ( lock ) { final Object obj = getMValue ( internalArray , index ) . asNative ( internalArray ) ; return obj instanceof String ? ( String ) obj : null ; } }
Gets value at the given index as a String . Returns null if the value doesn t exist or its value is not a String .
38,238
public Number getNumber ( int index ) { synchronized ( lock ) { return CBLConverter . asNumber ( getMValue ( internalArray , index ) . asNative ( internalArray ) ) ; } }
Gets value at the given index as a Number . Returns null if the value doesn t exist or its value is not a Number .
38,239
public int getInt ( int index ) { synchronized ( lock ) { return CBLConverter . asInteger ( getMValue ( internalArray , index ) , internalArray ) ; } }
Gets value at the given index as an int . Floating point values will be rounded . The value true is returned as 1 false as 0 . Returns 0 if the value doesn t exist or does not have a numeric value .
38,240
public long getLong ( int index ) { synchronized ( lock ) { return CBLConverter . asLong ( getMValue ( internalArray , index ) , internalArray ) ; } }
Gets value at the given index as an long . Floating point values will be rounded . The value true is returned as 1 false as 0 . Returns 0 if the value doesn t exist or does not have a numeric value .
38,241
public float getFloat ( int index ) { synchronized ( lock ) { return CBLConverter . asFloat ( getMValue ( internalArray , index ) , internalArray ) ; } }
Gets value at the given index as an float . Integers will be converted to float . The value true is returned as 1 . 0 false as 0 . 0 . Returns 0 . 0 if the value doesn t exist or does not have a numeric value .
38,242
public double getDouble ( int index ) { synchronized ( lock ) { return CBLConverter . asDouble ( getMValue ( internalArray , index ) , internalArray ) ; } }
Gets value at the given index as an double . Integers will be converted to double . The value true is returned as 1 . 0 false as 0 . 0 . Returns 0 . 0 if the property doesn t exist or does not have a numeric value .
38,243
public boolean getBoolean ( int index ) { synchronized ( lock ) { return CBLConverter . asBoolean ( getMValue ( internalArray , index ) . asNative ( internalArray ) ) ; } }
Gets value at the given index as a boolean .
38,244
public Blob getBlob ( int index ) { synchronized ( lock ) { return ( Blob ) getMValue ( internalArray , index ) . asNative ( internalArray ) ; } }
Gets value at the given index as a Blob . Returns null if the value doesn t exist or its value is not a Blob .
38,245
public Array getArray ( int index ) { synchronized ( lock ) { final Object obj = getMValue ( internalArray , index ) . asNative ( internalArray ) ; return obj instanceof Array ? ( Array ) obj : null ; } }
Gets a Array at the given index . Return null if the value is not an array .
38,246
public Dictionary getDictionary ( int index ) { synchronized ( lock ) { final Object obj = getMValue ( internalArray , index ) . asNative ( internalArray ) ; return obj instanceof Dictionary ? ( Dictionary ) obj : null ; } }
Gets a Dictionary at the given index . Return null if the value is not an dictionary .
38,247
public List < Object > toList ( ) { synchronized ( lock ) { final int count = ( int ) internalArray . count ( ) ; final List < Object > result = new ArrayList < > ( count ) ; for ( int index = 0 ; index < count ; index ++ ) { result . add ( Fleece . toObject ( getMValue ( internalArray , index ) . asNative ( internalArray ) ) ) ; } return result ; } }
Gets content of the current object as an List . The values contained in the returned List object are all JSON based values .
38,248
public C4Document update ( byte [ ] body , int flags ) throws LiteCoreException { return new C4Document ( update ( handle , body , flags ) ) ; }
- Purging and Expiration
38,249
public C4QueryEnumerator run ( C4QueryOptions options , AllocSlice parameters ) throws LiteCoreException { if ( parameters == null ) { parameters = new AllocSlice ( null ) ; } return new C4QueryEnumerator ( run ( handle , options . isRankFullText ( ) , parameters . getHandle ( ) ) ) ; }
- Creates a database index to speed up subsequent queries .
38,250
@ SuppressWarnings ( { "MethodName" , "PMD.MethodNamingConventions" } ) public static void socket_open ( long socket , Object socketFactoryContext , String scheme , String hostname , int port , String path , byte [ ] optionsFleece ) { Log . e ( TAG , "CBLWebSocket.socket_open()" ) ; Map < String , Object > options = null ; if ( optionsFleece != null ) { options = FLValue . fromData ( optionsFleece ) . asDict ( ) ; } if ( scheme . equalsIgnoreCase ( C4Replicator . C4_REPLICATOR_SCHEME_2 ) ) { scheme = WEBSOCKET_SCHEME ; } else if ( scheme . equalsIgnoreCase ( C4Replicator . C4_REPLICATOR_TLS_SCHEME_2 ) ) { scheme = WEBSOCKET_SECURE_CONNECTION_SCHEME ; } final AbstractCBLWebSocket c4sock ; try { c4sock = new CBLWebSocket ( socket , scheme , hostname , port , path , options ) ; } catch ( Exception e ) { Log . e ( TAG , "Failed to instantiate C4Socket: " + e ) ; e . printStackTrace ( ) ; return ; } REVERSE_LOOKUP_TABLE . put ( socket , c4sock ) ; c4sock . start ( ) ; }
!! Called by reflection! Don t change the name .
38,251
public void start ( ) { synchronized ( lock ) { Log . i ( DOMAIN , "Replicator is starting ....." ) ; if ( c4repl != null ) { Log . i ( DOMAIN , "%s has already started" , this ) ; return ; } Log . i ( DOMAIN , "%s: Starting" , this ) ; retryCount = 0 ; internalStart ( ) ; } }
Starts the replicator . This method returns immediately ; the replicator runs asynchronously and will report its progress throuh the replicator change notification .
38,252
public void stop ( ) { synchronized ( lock ) { Log . i ( DOMAIN , "%s: Replicator is stopping ..." , this ) ; if ( c4repl != null ) { c4repl . stop ( ) ; } else { Log . i ( DOMAIN , "%s: Replicator has been stopped or offlined ..." , this ) ; } if ( c4ReplStatus . getActivityLevel ( ) == C4ReplicatorStatus . ActivityLevel . OFFLINE ) { Log . i ( DOMAIN , "%s: Replicator has been offlined; " + "make the replicator into the stopped state now." , this ) ; final C4ReplicatorStatus c4replStatus = new C4ReplicatorStatus ( ) ; c4replStatus . setActivityLevel ( C4ReplicatorStatus . ActivityLevel . STOPPED ) ; this . c4StatusChanged ( c4replStatus ) ; } if ( reachabilityManager != null ) { reachabilityManager . removeNetworkReachabilityListener ( this ) ; } } }
Stops a running replicator . This method returns immediately ; when the replicator actually stops the replicator will change its status s activity level to kCBLStopped and the replicator change notification will be notified accordingly .
38,253
public void resetCheckpoint ( ) { synchronized ( lock ) { if ( c4ReplStatus != null && c4ReplStatus . getActivityLevel ( ) != C4ReplicatorStatus . ActivityLevel . STOPPED ) { throw new IllegalStateException ( "Replicator is not stopped. Resetting checkpoint is only allowed when the replicator is in the " + "stopped state." ) ; } shouldResetCheckpoint = true ; } }
Resets the local checkpoint of the replicator meaning that it will read all changes since the beginning of time from the remote database . This can only be called when the replicator is in a stopped state .
38,254
public void setParameters ( Parameters parameters ) { final LiveQuery liveQuery ; synchronized ( lock ) { this . parameters = parameters != null ? parameters . readonlyCopy ( ) : null ; liveQuery = this . query ; } if ( liveQuery != null ) { liveQuery . start ( ) ; } }
Set parameters should copy the given parameters . Set a new parameter will also re - execute the query if there is at least one listener listening for changes .
38,255
private static Endpoint initServiceEndpoint ( EndpointRegistry epRegistry , String contextPath , String servletName ) { if ( contextPath . startsWith ( "/" ) ) contextPath = contextPath . substring ( 1 ) ; final ObjectName oname = ObjectNameFactory . create ( Endpoint . SEPID_DOMAIN + ":" + Endpoint . SEPID_PROPERTY_CONTEXT + "=" + contextPath + "," + Endpoint . SEPID_PROPERTY_ENDPOINT + "=" + servletName ) ; Endpoint endpoint = epRegistry . getEndpoint ( oname ) ; if ( endpoint == null ) { throw Messages . MESSAGES . cannotObtainEndpoint ( oname ) ; } injectServiceAndHandlerResources ( endpoint ) ; return endpoint ; }
Initialize the service endpoint
38,256
public Configurer createServerConfigurer ( BindingCustomization customization , WSDLFilePublisher wsdlPublisher , ArchiveDeployment dep ) { ServerBeanCustomizer customizer = new ServerBeanCustomizer ( ) ; customizer . setBindingCustomization ( customization ) ; customizer . setWsdlPublisher ( wsdlPublisher ) ; customizer . setDeployment ( dep ) ; return new JBossWSConfigurerImpl ( customizer ) ; }
A convenient method for getting a jbossws cxf server configurer
38,257
private static String rewriteSoapAddress ( SOAPAddressRewriteMetadata sarm , String origAddress , String newAddress , String uriScheme ) { try { URL url = new URL ( newAddress ) ; String path = url . getPath ( ) ; String host = sarm . getWebServiceHost ( ) ; String port = getDotPortNumber ( uriScheme , sarm ) ; StringBuilder sb = new StringBuilder ( uriScheme ) ; sb . append ( "://" ) ; sb . append ( host ) ; sb . append ( port ) ; if ( isPathRewriteRequired ( sarm ) ) { sb . append ( SEDProcessor . newInstance ( sarm . getWebServicePathRewriteRule ( ) ) . processLine ( path ) ) ; } else { sb . append ( path ) ; } final String urlStr = sb . toString ( ) ; ADDRESS_REWRITE_LOGGER . addressRewritten ( origAddress , urlStr ) ; return urlStr ; } catch ( MalformedURLException e ) { ADDRESS_REWRITE_LOGGER . invalidAddressProvidedUseItWithoutRewriting ( newAddress , origAddress ) ; return origAddress ; } }
Rewrite the provided address according to the current server configuration and always using the specified uriScheme .
38,258
protected Map < String , String > attributesByBeanRef ( String beanRef ) { Map < String , String > result = null ; for ( Entry < String , String > e : map . entrySet ( ) ) { final String k = e . getKey ( ) ; if ( k . startsWith ( beanRef ) && k . startsWith ( DOT , beanRef . length ( ) ) ) { if ( result == null ) { result = new HashMap < String , String > ( ) ; } result . put ( k . substring ( beanRef . length ( ) + DOT . length ( ) ) , e . getValue ( ) ) ; } } if ( result == null ) { return Collections . emptyMap ( ) ; } else { return result ; } }
Return an attribute name to attribute value map
38,259
static String getSystemProperty ( final String name , final String defaultValue ) { PrivilegedAction < String > action = new PrivilegedAction < String > ( ) { public String run ( ) { return System . getProperty ( name , defaultValue ) ; } } ; return AccessController . doPrivileged ( action ) ; }
Return the current value of the specified system property
38,260
static Class < ? > loadClass ( final ClassLoader cl , final String name ) throws PrivilegedActionException , ClassNotFoundException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm == null ) { return cl . loadClass ( name ) ; } else { return AccessController . doPrivileged ( new PrivilegedExceptionAction < Class < ? > > ( ) { public Class < ? > run ( ) throws PrivilegedActionException { try { return cl . loadClass ( name ) ; } catch ( Exception e ) { throw new PrivilegedActionException ( e ) ; } } } ) ; } }
Load a class using the provided classloader
38,261
public Object invoke ( Exchange exchange , Object o ) { BindingOperationInfo bop = exchange . getBindingOperationInfo ( ) ; MethodDispatcher md = ( MethodDispatcher ) exchange . getService ( ) . get ( MethodDispatcher . class . getName ( ) ) ; List < Object > params = null ; if ( o instanceof List ) { params = CastUtils . cast ( ( List < ? > ) o ) ; } else if ( o != null ) { params = new MessageContentsList ( o ) ; } final Object tb = ( factory == null ) ? targetBean : this . getServiceObject ( exchange ) ; final Method method = ( bop == null ) ? null : md . getMethod ( bop ) ; if ( method == null ) { throw Messages . MESSAGES . missingBindingOpeartionAndDispatchedMethod ( ) ; } final Method fm = checkForUseAsyncMethod ? adjustMethodAndParams ( md . getMethod ( bop ) , exchange , params , tb . getClass ( ) ) : method ; return invoke ( exchange , tb , fm , params ) ; }
This overrides org . apache . cxf . jaxws . AbstractInvoker in order for using the JBoss AS target bean and simplifying the business method matching
38,262
protected Object performInvocation ( Exchange exchange , final Object serviceObject , Method m , Object [ ] paramArray ) throws Exception { Endpoint ep = exchange . get ( Endpoint . class ) ; final InvocationHandler invHandler = ep . getInvocationHandler ( ) ; final Invocation inv = createInvocation ( invHandler , serviceObject , ep , m , paramArray ) ; if ( factory != null ) { inv . getInvocationContext ( ) . setProperty ( "forceTargetBean" , true ) ; } Bus threadBus = BusFactory . getThreadDefaultBus ( false ) ; BusFactory . setThreadDefaultBus ( disableDepUserDefThreadBus ? null : ep . getAttachment ( Bus . class ) ) ; setNamespaceContextSelector ( exchange ) ; ClassLoader cl = SecurityActions . getContextClassLoader ( ) ; SecurityActions . setContextClassLoader ( serviceObject . getClass ( ) . getClassLoader ( ) ) ; try { invHandler . invoke ( ep , inv ) ; return inv . getReturnValue ( ) ; } finally { SecurityActions . setContextClassLoader ( cl ) ; BusFactory . setThreadDefaultBus ( threadBus ) ; clearNamespaceContextSelector ( exchange ) ; } }
This overrides org . apache . cxf . jaxws . AbstractInvoker in order for using the JBossWS integration logic to invoke the JBoss AS target bean .
38,263
private static String getTypeNamespace ( String packageName ) { StringBuilder sb = new StringBuilder ( "http://" ) ; StringTokenizer st = new StringTokenizer ( packageName , "." ) ; Stack < String > stk = new Stack < String > ( ) ; while ( st != null && st . hasMoreTokens ( ) ) { stk . push ( st . nextToken ( ) ) ; } String next ; while ( ! stk . isEmpty ( ) && ( next = stk . pop ( ) ) != null ) { if ( sb . toString ( ) . equals ( "http://" ) == false ) sb . append ( '.' ) ; sb . append ( next ) ; } sb . append ( '/' ) ; return sb . toString ( ) ; }
Extracts the typeNS given the package name Algorithm is based on the one specified in JAXWS v2 . 0 spec
38,264
protected void publishContractToFilesystem ( ) { if ( wsdlPublisher != null ) { Endpoint endpoint = getServer ( ) . getEndpoint ( ) ; Service service = endpoint . getService ( ) ; try { String wsdlLocation = getWsdlLocation ( ) ; if ( wsdlLocation == null ) { JaxWsImplementorInfo info = new JaxWsImplementorInfo ( getImplementorClass ( ) ) ; wsdlLocation = info . getWsdlLocation ( ) ; } updateSoapAddress ( ) ; wsdlPublisher . publishWsdlFiles ( service . getName ( ) , wsdlLocation , this . getBus ( ) , service . getServiceInfos ( ) ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } } else { Loggers . DEPLOYMENT_LOGGER . unableToPublishContractDueToMissingPublisher ( getImplementorClass ( ) ) ; } }
Publish the contract to a file using the configured wsdl publisher
38,265
private void updateSoapAddress ( ) { final SOAPAddressRewriteMetadata metadata = getSOAPAddressRewriteMetadata ( ) ; if ( metadata . isModifySOAPAddress ( ) ) { List < ServiceInfo > sevInfos = getServer ( ) . getEndpoint ( ) . getService ( ) . getServiceInfos ( ) ; for ( ServiceInfo si : sevInfos ) { Collection < EndpointInfo > epInfos = si . getEndpoints ( ) ; for ( EndpointInfo ei : epInfos ) { String publishedEndpointUrl = ( String ) ei . getProperty ( WSDLGetUtils . PUBLISHED_ENDPOINT_URL ) ; if ( publishedEndpointUrl != null ) { ei . setAddress ( publishedEndpointUrl ) ; } else { if ( ei . getAddress ( ) . contains ( ServerConfig . UNDEFINED_HOSTNAME ) ) { String epurl = SoapAddressRewriteHelper . getRewrittenPublishedEndpointUrl ( ei . getAddress ( ) , metadata ) ; ei . setAddress ( epurl ) ; } } } } } }
For both code - first and wsdl - first scenarios reset the endpoint address so that it is written to the generated wsdl file .
38,266
private AbstractHTTPDestination findDestination ( HttpServletRequest req , Bus bus ) throws ServletException { String requestURI = req . getRequestURI ( ) ; DestinationRegistry destRegistry = getDestinationRegistryFromBus ( bus ) ; if ( destRegistry == null ) { throw Messages . MESSAGES . cannotObtainRegistry ( DestinationRegistry . class . getName ( ) ) ; } requestURI = pathPattern . matcher ( requestURI ) . replaceAll ( "/" ) ; final AbstractHTTPDestination dest = destRegistry . getDestinationForPath ( requestURI , true ) ; if ( dest != null ) { return dest ; } Collection < AbstractHTTPDestination > destinations = destRegistry . getDestinations ( ) ; AbstractHTTPDestination returnValue = null ; for ( AbstractHTTPDestination destination : destinations ) { String path = destination . getEndpointInfo ( ) . getAddress ( ) ; try { path = new URL ( path ) . getPath ( ) ; } catch ( MalformedURLException ex ) { Logger . getLogger ( RequestHandlerImpl . class ) . trace ( ex ) ; } if ( path != null && requestURI . startsWith ( path ) ) { returnValue = destination ; } } if ( returnValue == null ) throw Messages . MESSAGES . cannotObtainDestinationFor ( requestURI ) ; return returnValue ; }
Finds destination based on request URI
38,267
private static String getRegexp ( SedArguments args ) { if ( args . isRegexpSet ( ) ) { return args . getRegexp ( ) ; } if ( args . isString1Set ( ) ) { return args . getString1 ( ) ; } return "" ; }
Returns the regexp operand from args either called regexp or string1 . If none of the two is set an empty string is returned .
38,268
private static String getReplacement ( SedArguments args ) { if ( args . isReplacementSet ( ) ) { return args . getReplacement ( ) ; } if ( args . isString2Set ( ) ) { return args . getString2 ( ) ; } return "" ; }
Returns the replacement operand from args either called replacement or string2 . If none of the two is set an empty string is returned .
38,269
private static int findStartTrimWhitespace ( CharSequence s ) { final int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ! Character . isWhitespace ( s . charAt ( i ) ) ) { return i ; } } return len ; }
Finds and returns the start of the given sequence after trimming whitespace characters from the left .
38,270
private static int findWhitespace ( CharSequence s , int start ) { final int len = s . length ( ) ; for ( int i = start ; i < len ; i ++ ) { if ( Character . isWhitespace ( s . charAt ( i ) ) ) { return i ; } } return len ; }
Finds and returns the first whitespace character in the given sequence at or after start . Returns the length of the string if no whitespace is found .
38,271
public static Bus getClassLoaderDefaultBus ( final ClassLoader classloader , final ClientBusSelector clientBusSelector ) { Bus classLoaderBus ; synchronized ( classLoaderBusses ) { classLoaderBus = classLoaderBusses . get ( classloader ) ; if ( classLoaderBus == null ) { classLoaderBus = clientBusSelector . createNewBus ( ) ; BusLifeCycleListener listener = new ClassLoaderDefaultBusLifeCycleListener ( classLoaderBus ) ; classLoaderBus . getExtension ( BusLifeCycleManager . class ) . registerLifeCycleListener ( listener ) ; classLoaderBusses . put ( classloader , classLoaderBus ) ; } } return classLoaderBus ; }
Gets the default bus for the given classloader ; if a new Bus is needed the creation is delegated to the specified ClientBusSelector instance .
38,272
public static Bus getClassLoaderDefaultBus ( final ClassLoader classloader ) { Bus classLoaderBus ; synchronized ( classLoaderBusses ) { classLoaderBus = classLoaderBusses . get ( classloader ) ; if ( classLoaderBus == null ) { classLoaderBus = new JBossWSBusFactory ( ) . createBus ( ) ; BusLifeCycleListener listener = new ClassLoaderDefaultBusLifeCycleListener ( classLoaderBus ) ; classLoaderBus . getExtension ( BusLifeCycleManager . class ) . registerLifeCycleListener ( listener ) ; classLoaderBusses . put ( classloader , classLoaderBus ) ; } } return classLoaderBus ; }
Gets the default bus for the given classloader
38,273
public static void clearDefaultBusForAnyClassLoader ( final Bus bus ) { synchronized ( classLoaderBusses ) { for ( final Iterator < Bus > iterator = classLoaderBusses . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { Bus itBus = iterator . next ( ) ; if ( bus == null || itBus == null || bus . equals ( itBus ) ) { iterator . remove ( ) ; } } } }
Removes a bus from being the default bus for any classloader
38,274
static boolean checkAndFixContextClassLoader ( ClassLoader origClassLoader ) { try { origClassLoader . loadClass ( ProviderImpl . class . getName ( ) ) ; } catch ( Exception e ) { ClassLoader clientClassLoader = ProviderImpl . class . getClassLoader ( ) ; if ( BusFactory . getDefaultBus ( false ) == null ) { JBossWSBusFactory . getDefaultBus ( clientClassLoader ) ; } setContextClassLoader ( createDelegateClassLoader ( clientClassLoader , origClassLoader ) ) ; return true ; } return false ; }
Ensure the current context classloader can load this ProviderImpl class .
38,275
public boolean compileFiles ( String [ ] files ) { JavaCompiler compiler = ToolProvider . getSystemJavaCompiler ( ) ; if ( compiler == null ) { throw new IllegalStateException ( "No compiler detected, make sure you are running on top of a JDK instead of a JRE." ) ; } StandardJavaFileManager fileManager = compiler . getStandardFileManager ( null , null , null ) ; Iterable < ? extends JavaFileObject > fileList = fileManager . getJavaFileObjectsFromStrings ( Arrays . asList ( files ) ) ; return internalCompile ( compiler , wrapJavaFileManager ( fileManager ) , setupDiagnosticListener ( ) , fileList ) ; }
unix file separator
38,276
public String getTrimmedPath ( String path ) { if ( path == null ) { return "/" ; } if ( ! path . startsWith ( "/" ) ) { try { path = new URL ( path ) . getPath ( ) ; } catch ( MalformedURLException ex ) { Logger . getLogger ( JBossWSDestinationRegistryImpl . class ) . trace ( ex ) ; } if ( ! path . startsWith ( "/" ) ) { path = "/" + path ; } } return path ; }
Return a real path value removing the protocol host and port if specified .
38,277
@ Resource ( name = "cxf" ) public final void setBus ( Bus bus ) { assert this . bus == null || this . bus == bus ; this . bus = bus ; if ( bus != null ) { bus . setExtension ( this , UndertowServerEngineFactory . class ) ; lifeCycleManager = bus . getExtension ( BusLifeCycleManager . class ) ; if ( null != lifeCycleManager ) { lifeCycleManager . registerLifeCycleListener ( this ) ; } } }
This call is used to set the bus . It should only be called once .
38,278
public synchronized UndertowServerEngine retrieveHttpServerEngine ( int port ) { UndertowServerEngine engine = null ; synchronized ( portMap ) { engine = portMap . get ( port ) ; } return engine ; }
Retrieve a previously configured HttpServerEngine for the given port . If none exists this call returns null .
38,279
public synchronized void destroyForPort ( int port ) { synchronized ( portMap ) { UndertowServerEngine ref = portMap . remove ( port ) ; if ( ref != null ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Stopping HttpServer Engine on port " + port + "." ) ; } try { ref . stop ( ) ; } catch ( Exception e ) { LOG . warn ( "" , e ) ; } } } }
This method removes the Server Engine from the port map and stops it .
38,280
public synchronized void shutdown ( ) { if ( factory != null && handlerCount == 0 ) { factory . destroyForPort ( port ) ; } else { LOG . warnv ( "Failed to shutdown Undertow server on port {0,number,####0} because it is still in use" , port ) ; } }
This method will shut down the server engine and remove it from the factory s cache .
38,281
protected void configureEndpointFactory ( AbstractWSDLBasedEndpointFactory factory ) { if ( customization != null ) { ReflectionServiceFactoryBean serviceFactory = factory . getServiceFactory ( ) ; serviceFactory . reset ( ) ; DataBinding serviceFactoryDataBinding = serviceFactory . getDataBinding ( true ) ; configureBindingCustomization ( serviceFactoryDataBinding , customization ) ; serviceFactory . setDataBinding ( serviceFactoryDataBinding ) ; if ( factory . getDataBinding ( ) == null ) { factory . setDataBinding ( serviceFactoryDataBinding ) ; } else { configureBindingCustomization ( factory . getDataBinding ( ) , customization ) ; } } }
Configure the endpoint factory
38,282
public MAP inboundMap ( Map < String , Object > ctx ) { AddressingProperties implementation = ( AddressingProperties ) ctx . get ( CXFMAPConstants . SERVER_ADDRESSING_PROPERTIES_INBOUND ) ; return newMap ( implementation ) ; }
retrieve the inbound server message address properties attached to a message context
38,283
public MAP outboundMap ( Map < String , Object > ctx ) { AddressingProperties implementation = ( AddressingProperties ) ctx . get ( CXFMAPConstants . CLIENT_ADDRESSING_PROPERTIES_OUTBOUND ) ; if ( implementation == null ) { implementation = new AddressingProperties ( ) ; ctx . put ( CXFMAPConstants . CLIENT_ADDRESSING_PROPERTIES , implementation ) ; ctx . put ( CXFMAPConstants . CLIENT_ADDRESSING_PROPERTIES_OUTBOUND , implementation ) ; } return newMap ( implementation ) ; }
retrieve the outbound client message address properties attached to a message request map
38,284
public void publishWsdlFiles ( QName serviceName , String wsdlLocation , Bus bus , List < ServiceInfo > serviceInfos ) throws IOException { String deploymentName = dep . getCanonicalName ( ) ; File wsdlFile = getPublishLocation ( serviceName . getLocalPart ( ) , deploymentName , wsdlLocation ) ; if ( wsdlFile == null ) return ; createParentDir ( wsdlFile ) ; try { ServiceWSDLBuilder builder = new ServiceWSDLBuilder ( bus , serviceInfos ) ; Definition def = builder . build ( ) ; Document doc = getWsdlDocument ( bus , def ) ; writeDocument ( doc , wsdlFile ) ; URL wsdlPublishURL = new URL ( URLDecoder . decode ( wsdlFile . toURI ( ) . toURL ( ) . toExternalForm ( ) , "UTF-8" ) ) ; Loggers . DEPLOYMENT_LOGGER . wsdlFilePublished ( wsdlPublishURL ) ; if ( def != null ) { List < String > published = new LinkedList < String > ( ) ; String expLocation = getExpLocation ( wsdlLocation ) ; publishWsdlImports ( wsdlPublishURL , def , published , expLocation ) ; publishSchemaImports ( wsdlPublishURL , doc . getDocumentElement ( ) , published , expLocation ) ; dep . addAttachment ( WSDLFilePublisher . class , this ) ; } else { throw Messages . MESSAGES . wsdl20NotSupported ( ) ; } } catch ( RuntimeException rte ) { throw rte ; } catch ( Exception e ) { throw Messages . MESSAGES . cannotPublishWSDLTo ( serviceName , wsdlFile , e ) ; } }
Publish the deployed wsdl file to the data directory
38,285
private File getPublishLocation ( String serviceName , String archiveName , String wsdlLocation ) throws IOException { if ( wsdlLocation == null && serviceName == null ) { Loggers . DEPLOYMENT_LOGGER . cannotGetWsdlPublishLocation ( ) ; return null ; } if ( archiveName . startsWith ( "http://" ) ) { archiveName = archiveName . replace ( "http://" , "http-" ) ; } File locationFile = new File ( serverConfig . getServerDataDir ( ) . getCanonicalPath ( ) + "/wsdl/" + archiveName ) ; if ( wsdlLocation != null && wsdlLocation . indexOf ( expLocation ) >= 0 ) { wsdlLocation = wsdlLocation . substring ( wsdlLocation . indexOf ( expLocation ) + expLocation . length ( ) ) ; return new File ( locationFile + "/" + wsdlLocation ) ; } else if ( wsdlLocation != null && ! wsdlLocation . startsWith ( "vfs:" ) ) { for ( String wsdlLocationPrefix : wsdlLocationPrefixes ) { if ( wsdlLocation . startsWith ( wsdlLocationPrefix ) ) { return new File ( locationFile , encodeLocation ( wsdlLocation . substring ( wsdlLocationPrefix . length ( ) , wsdlLocation . lastIndexOf ( "/" ) + 1 ) ) ) ; } } return new File ( locationFile , encodeLocation ( wsdlLocation ) ) ; } else { return new File ( locationFile + "/" + serviceName + ".wsdl" ) ; } }
Get the file publish location
38,286
public MessageBroker processAfterStartup ( MessageBroker broker ) { Service service = broker . getServiceByType ( getServiceClassName ( ) ) ; Assert . notNull ( service , "The MessageBroker with id '" + broker . getId ( ) + "' does not have a service of type " + getServiceClassName ( ) + " configured." ) ; Assert . isTrue ( service . isStarted ( ) , "The Service with id '" + service . getId ( ) + "' of MessageBroker with id '" + broker . getId ( ) + "' was not started as expected." ) ; return broker ; }
Error checking is done on the started MessageBroker to ensure configuration was successful .
38,287
public MessageBroker processBeforeStartup ( MessageBroker broker ) { Service service = broker . getServiceByType ( getServiceClassName ( ) ) ; if ( service == null ) { service = broker . createService ( getServiceId ( ) , getServiceClassName ( ) ) ; if ( getServiceAdapterId ( ) . equals ( this . defaultAdapterId ) ) { service . registerAdapter ( getServiceAdapterId ( ) , getServiceAdapterClassName ( ) ) ; } else { Assert . isAssignable ( ServiceAdapter . class , this . beanFactory . getType ( this . defaultAdapterId ) , "A custom default adapter id must refer to a valid Spring bean that " + "is a subclass of " + ServiceAdapter . class . getName ( ) + ". " ) ; service . registerAdapter ( this . defaultAdapterId , CustomSpringAdapter . class . getName ( ) ) ; } service . setDefaultAdapter ( this . defaultAdapterId ) ; if ( ! ObjectUtils . isEmpty ( this . defaultChannels ) ) { addDefaultChannels ( broker , service ) ; } else { findDefaultChannel ( broker , service ) ; } } return broker ; }
The MessageBroker is checked to see if the Service has already been configured via the BlazeDS XML config . If no existing Service is found one will be installed using the defined configuration properties of this class .
38,288
@ SuppressWarnings ( "rawtypes" ) protected String extractPassword ( Object credentials ) { String password = null ; if ( credentials instanceof String ) { password = ( String ) credentials ; } else if ( credentials instanceof Map ) { password = ( String ) ( ( Map ) credentials ) . get ( MessageIOConstants . SECURITY_CREDENTIALS ) ; } return password ; }
Extracts the password from the Flex client credentials
38,289
void handleMessage ( Message flexMessage ) { flexMessage . setDestination ( this . getDestination ( ) . getId ( ) ) ; MessageService messageService = ( MessageService ) getDestination ( ) . getService ( ) ; messageService . pushMessageToClients ( flexMessage , true ) ; messageService . sendPushMessageFromPeer ( flexMessage , true ) ; }
Invoked when a Message is received from a JMS client .
38,290
public void findDefaultChannel ( MessageBroker broker , Service service ) { if ( ! CollectionUtils . isEmpty ( broker . getDefaultChannels ( ) ) ) { return ; } Iterator < String > channels = broker . getChannelIds ( ) . iterator ( ) ; while ( channels . hasNext ( ) ) { Endpoint endpoint = broker . getEndpoint ( channels . next ( ) ) ; if ( endpoint instanceof AMFEndpoint && isPollingEnabled ( endpoint ) ) { service . addDefaultChannel ( endpoint . getId ( ) ) ; return ; } } log . warn ( "No appropriate default channels were detected for the MessageService. " + "The channels must be explicitly set on any exported service." ) ; }
Tries to find a sensible default AMF channel for the default MessageService
38,291
protected void configureAdapter ( Destination destination ) { String adapterId = StringUtils . hasText ( this . serviceAdapter ) ? this . serviceAdapter : getTargetService ( this . broker ) . getDefaultAdapter ( ) ; if ( this . beanFactory . containsBean ( adapterId ) ) { ServiceAdapter adapter = ( ServiceAdapter ) this . beanFactory . getBean ( adapterId , ServiceAdapter . class ) ; destination . setAdapter ( adapter ) ; } else if ( destination . getAdapter ( ) == null ) { destination . createAdapter ( adapterId ) ; } }
Configure the service adapter for the destination .
38,292
@ SuppressWarnings ( "unchecked" ) public MessagingConfiguration getMessagingConfiguration ( ServletConfig servletConfig ) { Assert . isTrue ( JdkVersion . getMajorJavaVersion ( ) >= JdkVersion . JAVA_15 , "Spring BlazeDS Integration requires a minimum of Java 1.5" ) ; Assert . notNull ( servletConfig , "FlexConfigurationManager requires a non-null ServletConfig - " + "Is it being used outside a WebApplicationContext?" ) ; MessagingConfiguration configuration = new MessagingConfiguration ( ) ; configuration . getSecuritySettings ( ) . setServerInfo ( servletConfig . getServletContext ( ) . getServerInfo ( ) ) ; if ( CollectionUtils . isEmpty ( configuration . getSecuritySettings ( ) . getLoginCommands ( ) ) ) { LoginCommandSettings settings = new LoginCommandSettings ( ) ; settings . setClassName ( NoOpLoginCommand . class . getName ( ) ) ; configuration . getSecuritySettings ( ) . getLoginCommands ( ) . put ( LoginCommandSettings . SERVER_MATCH_OVERRIDE , settings ) ; } if ( this . parser == null ) { this . parser = getDefaultConfigurationParser ( ) ; } Assert . notNull ( this . parser , "Unable to create a parser to load Flex messaging configuration." ) ; this . parser . parse ( this . configurationPath , new ResourceResolverAdapter ( this . resourceLoader ) , configuration ) ; return configuration ; }
Parses the BlazeDS config files and returns a populated MessagingConfiguration
38,293
public static SpringPropertyProxy proxyFor ( Class < ? > beanType , boolean useDirectFieldAccess , ConversionService conversionService ) { if ( PropertyProxyUtils . hasAmfCreator ( beanType ) ) { SpringPropertyProxy proxy = new DelayedWriteSpringPropertyProxy ( beanType , useDirectFieldAccess , conversionService ) ; return proxy ; } else { Assert . isTrue ( beanType . isEnum ( ) || ClassUtils . hasConstructor ( beanType ) , "Failed to create SpringPropertyProxy for " + beanType . getName ( ) + " - Classes mapped " + "for deserialization from AMF must have either a no-arg default constructor, " + "or a constructor annotated with " + AmfCreator . class . getName ( ) ) ; SpringPropertyProxy proxy = new SpringPropertyProxy ( beanType , useDirectFieldAccess , conversionService ) ; try { Object instance = BeanUtils . instantiate ( beanType ) ; proxy . setPropertyNames ( PropertyProxyUtils . findPropertyNames ( conversionService , useDirectFieldAccess , instance ) ) ; } catch ( BeanInstantiationException ex ) { } return proxy ; } }
Factory method for creating correctly configured Spring property proxy instances .
38,294
public void handleMessage ( Message < ? > message ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "received Integration Message: " + message ) ; } AsyncMessage flexMessage = new AsyncMessage ( ) ; flexMessage . setBody ( message . getPayload ( ) ) ; MessageHeaders headers = message . getHeaders ( ) ; flexMessage . setMessageId ( headers . containsKey ( FlexHeaders . MESSAGE_ID ) ? headers . get ( FlexHeaders . MESSAGE_ID , String . class ) : headers . getId ( ) . toString ( ) ) ; Long timestamp = headers . containsKey ( FlexHeaders . TIMESTAMP ) ? Long . parseLong ( headers . get ( FlexHeaders . TIMESTAMP , String . class ) ) : headers . getTimestamp ( ) ; flexMessage . setTimestamp ( timestamp ) ; Long expirationDate = headers . getExpirationDate ( ) ; if ( expirationDate != null ) { flexMessage . setTimeToLive ( expirationDate - timestamp ) ; } if ( headers . containsKey ( FlexHeaders . MESSAGE_CLIENT_ID ) ) { flexMessage . setClientId ( headers . get ( FlexHeaders . MESSAGE_CLIENT_ID ) ) ; } for ( Map . Entry < String , Object > header : headers . entrySet ( ) ) { String key = header . getKey ( ) ; if ( ! filteredHeaders . contains ( key ) ) { flexMessage . setHeader ( key , header . getValue ( ) ) ; } } flexMessage . setDestination ( this . getDestination ( ) . getId ( ) ) ; MessageService messageService = ( MessageService ) getDestination ( ) . getService ( ) ; if ( filterSender && headers . containsKey ( FlexHeaders . FLEX_CLIENT_ID ) ) { Set < Object > subscribers = new HashSet < Object > ( this . subscriberIds ) ; FlexClient flexClient = messageService . getMessageBroker ( ) . getFlexClientManager ( ) . getFlexClient ( headers . get ( FlexHeaders . FLEX_CLIENT_ID ) . toString ( ) ) ; for ( Object subscriberId : this . subscriberIds ) { if ( flexClient . getMessageClient ( subscriberId . toString ( ) ) != null ) { subscribers . remove ( subscriberId ) ; } } messageService . pushMessageToClients ( subscribers , flexMessage , true ) ; } else { messageService . pushMessageToClients ( flexMessage , true ) ; } messageService . sendPushMessageFromPeer ( flexMessage , true ) ; }
Invoked when a Message is received from the Spring Integration channel .
38,295
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public Object invoke ( flex . messaging . messages . Message flexMessage ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "received Flex Message: " + flexMessage ) ; } Message < ? > message = null ; if ( this . extractPayload ) { Map headers = flexMessage . getHeaders ( ) ; headers . put ( FlexHeaders . MESSAGE_CLIENT_ID , flexMessage . getClientId ( ) ) ; headers . put ( FlexHeaders . DESTINATION_ID , flexMessage . getDestination ( ) ) ; headers . put ( FlexHeaders . MESSAGE_ID , flexMessage . getMessageId ( ) ) ; headers . put ( FlexHeaders . TIMESTAMP , String . valueOf ( flexMessage . getTimestamp ( ) ) ) ; if ( FlexContext . getFlexClient ( ) != null ) { headers . put ( FlexHeaders . FLEX_CLIENT_ID , FlexContext . getFlexClient ( ) . getId ( ) ) ; } long timestamp = flexMessage . getTimestamp ( ) ; message = MessageBuilder . withPayload ( flexMessage . getBody ( ) ) . copyHeaders ( headers ) . setExpirationDate ( timestamp + flexMessage . getTimeToLive ( ) ) . build ( ) ; } else { message = new GenericMessage < flex . messaging . messages . Message > ( flexMessage ) ; } this . messageChannel . send ( message ) ; return null ; }
Invoked when a Message is received from a Flex client .
38,296
public void send ( String destination , Object body ) { AsyncMessage message = this . defaultMessageCreator . createMessage ( ) ; message . setDestination ( destination ) ; message . setBody ( body ) ; getMessageBroker ( ) . routeMessageToService ( message , null ) ; }
Sends a message with the specified body to the specified destination
38,297
public void afterThrowing ( Throwable original ) throws Throwable { Class < ? > candidateType = original . getClass ( ) ; Throwable candidate = original ; if ( ClassUtils . isAssignable ( MessageException . class , candidateType ) ) { MessageException me = ( MessageException ) candidate ; if ( SERVER_PROCESSING_CODE . equals ( me . getCode ( ) ) && me . getRootCause ( ) != null ) { candidateType = me . getRootCause ( ) . getClass ( ) ; candidate = me . getRootCause ( ) ; } } for ( ExceptionTranslator translator : this . exceptionTranslators ) { if ( translator . handles ( candidateType ) ) { MessageException result = translator . translate ( candidate ) ; if ( result != null ) { exceptionLogger . log ( result ) ; throw result ; } } } exceptionLogger . log ( original ) ; throw original ; }
Apply translation to the thrown exception .
38,298
public String getQualifiedName ( ) { if ( this . module == null || this . module . getName ( ) == null ) { return name ; } if ( this . module . getName ( ) . equals ( "core" ) || this . module . getName ( ) . equals ( "filters" ) || this . module . getName ( ) . equals ( "elements" ) ) { return "kurento." + name ; } else { return this . module . getName ( ) + "." + name ; } }
Get qualified name mixing In the format module . name
38,299
public boolean satisfies ( String expr ) { Parser < Expression > parser = ExpressionParser . newInstance ( ) ; return parser . parse ( expr ) . interpret ( this ) ; }
Checks if this version satisfies the specified SemVer Expression .