public Object apply ( ContextLoggerConfiguration contextLoggerConfiguration , Object instanceToWrap ) { // check for implicit context if ( IsImplicitContextEnumValuePredicate . getInstance ( ) . apply ( instanceToWrap ) ) { return createInstance ( ( Class ) contextLoggerConfiguration . getImplicitContextProviderClass ( ( ImplicitContext ) instanceToWrap ) ) ; } // now try to find instance type in known wrapper types map Class matchingWrapperType = contextLoggerConfiguration . getContextProviderClass ( instanceToWrap . getClass ( ) ) ; if ( matchingWrapperType == null ) { // now try to find instance type in TypeToWrapper List for ( TypeToWrapper wrapper : contextLoggerConfiguration . getWrapperList ( ) ) { if ( wrapper . getWrappedInstanceType ( ) . isAssignableFrom ( instanceToWrap . getClass ( ) ) ) { matchingWrapperType = wrapper . getWrapperType ( ) ; break ; } } } if ( matchingWrapperType != null ) { // now create wrapper instance try { WrappedContextData wrapperInstance = ( WrappedContextData ) createInstance ( matchingWrapperType ) ; wrapperInstance . setContextData ( instanceToWrap ) ; return wrapperInstance ; } catch ( Exception e ) { // continue } } return instanceToWrap ; }
Wraps the passed instance inside a matching tracee context logging provider instance . Will return the passed instance if no matching tracee context logging provider exists .