/** * This code might be executed in the context of the bootstrap class loader. That's why we have to make sure we only * call code which is visible. For example, we can't use slf4j or directly reference stagemonitor classes */ @Advice.OnMethodEnter private static void addHandlers(@Advice.Argument(value = 0, readOnly = false) List<Handler> handlerChain, @Advice.This Binding binding) { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger("org.stagemonitor.tracing.soap.SoapHandlerTransformer"); final List<Handler<?>> stagemonitorHandlers = Dispatcher.get("org.stagemonitor.tracing.soap.SoapHandlerTransformer"); if (stagemonitorHandlers != null) { logger.fine("Adding SOAPHandlers " + stagemonitorHandlers + " to handlerChain for Binding " + binding); if (handlerChain == null) { handlerChain = Collections.emptyList(); } // creating a new list as we don't know if handlerChain is immutable or not handlerChain = new ArrayList<Handler>(handlerChain); for (Handler<?> stagemonitorHandler : stagemonitorHandlers) { if (!handlerChain.contains(stagemonitorHandler) && // makes sure we only add the handler to the correct application Dispatcher.isVisibleToCurrentContextClassLoader(stagemonitorHandler)) { handlerChain.add(stagemonitorHandler); } } logger.fine("Handler Chain: " + handlerChain); } else { logger.fine("No SOAPHandlers found in Dispatcher for Binding " + binding); } }
/** * {@inheritDoc} */ public OffsetMapping make(ParameterDescription.InDefinedShape target, AnnotationDescription.Loadable<Argument> annotation, AdviceType adviceType) { if (adviceType.isDelegation() && !annotation.loadSilent().readOnly()) { throw new IllegalStateException("Cannot define writable field access for " + target + " when using delegation"); } else { return new ForArgument.Unresolved(target.getType(), annotation.loadSilent()); } } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL statement string * @param keyspace query's keyspace * @param prepared prepared statement * @param forThrift is it a Thrift statement * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) String keyspace, @Advice.Argument(2) ParsedStatement.Prepared prepared, @Advice.Argument(3) boolean forThrift, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .storePrepared(queryString, keyspace, forThrift, prepared, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param statement CQL statement to be executed * @param queryState query state information * @param options query options * @param result intercepted method's execution result * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) CQLStatement statement, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .processPrepared(statement, queryState, options, startTime, result, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL statement string * @param keyspace query's keyspace * @param prepared prepared statement * @param forThrift is it a Thrift statement * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) String keyspace, @Advice.Argument(2) ParsedStatement.Prepared prepared, @Advice.Argument(3) boolean forThrift, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .storePrepared(queryString, keyspace, forThrift, prepared, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param statement CQL statement to be executed * @param queryState query state information * @param options query options * @param result intercepted method's execution result * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) CQLStatement statement, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .processPrepared(statement, queryState, options, startTime, result, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL statement string * @param keyspace query's keyspace * @param prepared prepared statement * @param forThrift is it a Thrift statement * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) String keyspace, @Advice.Argument(2) ParsedStatement.Prepared prepared, @Advice.Argument(3) boolean forThrift, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .storePrepared(queryString, keyspace, forThrift, prepared, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param statement CQL statement to be executed * @param queryState query state information * @param options query options * @param result intercepted method's execution result * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) CQLStatement statement, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .processPrepared(statement, queryState, options, startTime, result, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL query string * @param queryState query state information * @param options query options * @param result intercepted method's execution result */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result) { ConnectorImpl.queryProcessorWrapper() .process(queryString, queryState, options, startTime, result); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL statement string * @param keyspace query's keyspace * @param prepared prepared statement * @param forThrift is it a Thrift statement * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) String keyspace, @Advice.Argument(2) ParsedStatement.Prepared prepared, @Advice.Argument(3) boolean forThrift, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .storePrepared(queryString, keyspace, forThrift, prepared, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL query string * @param queryState query state information * @param options query options * @param result intercepted method's execution result */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result) { ConnectorImpl.queryProcessorWrapper() .process(queryString, queryState, options, startTime, result); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param statement CQL statement to be executed * @param queryState query state information * @param options query options * @param result intercepted method's execution result * @param preparedStatements QueryProcessor's internal list of prepared statements */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) CQLStatement statement, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result, @Advice.FieldValue(value = "preparedStatements") ConcurrentLinkedHashMap<MD5Digest, ParsedStatement.Prepared> preparedStatements) { ConnectorImpl.queryProcessorWrapper() .processPrepared(statement, queryState, options, startTime, result, preparedStatements); } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL query string * @param queryState query state information * @param options query options * @param result intercepted method's execution result */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result) { ConnectorImpl.queryProcessorWrapper() .process(queryString, queryState, options, startTime, result); } }
@Advice.OnMethodExit static void $$_hibernate_clearDirtyCollectionNames( @FieldName String fieldName, @FieldValue Collection<?> collection, @Advice.Argument(value = 0, readOnly = false) LazyAttributeLoadingInterceptor lazyInterceptor, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( lazyInterceptor == null || lazyInterceptor.isAttributeLoaded( fieldName ) ) { if ( collection == null ) { $$_hibernate_collectionTracker.add( fieldName, -1 ); } else { $$_hibernate_collectionTracker.add( fieldName, collection.size() ); } } } }
@Advice.OnMethodExit static void $$_hibernate_areCollectionFieldsDirty( @FieldName String fieldName, @FieldValue Collection<?> collection, @Advice.Argument(0) DirtyTracker tracker, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( $$_hibernate_collectionTracker != null ) { if ( collection == null && $$_hibernate_collectionTracker.getSize( fieldName ) != -1 ) { tracker.add( fieldName ); } else if ( collection != null && $$_hibernate_collectionTracker.getSize( fieldName ) != collection.size() ) { tracker.add( fieldName ); } } } }
/** * Code executed after the intercepted method. * * @param startTime execution start time recorded by the enter method. * @param queryString CQL query string * @param queryState query state information * @param options query options * @param result intercepted method's execution result */ @Advice.OnMethodExit public static void exit(@Advice.Enter long startTime, @Advice.Argument(0) String queryString, @Advice.Argument(1) QueryState queryState, @Advice.Argument(2) QueryOptions options, @Advice.Return ResultMessage result) { ConnectorImpl.queryProcessorWrapper() .process(queryString, queryState, options, startTime, result); } }
@Advice.OnMethodExit static void $$_hibernate_clearDirtyCollectionNames( @FieldName String fieldName, @FieldValue Map<?, ?> map, @Advice.Argument(value = 0, readOnly = false) LazyAttributeLoadingInterceptor lazyInterceptor, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( lazyInterceptor == null || lazyInterceptor.isAttributeLoaded( fieldName ) ) { if ( map == null ) { $$_hibernate_collectionTracker.add( fieldName, -1 ); } else { $$_hibernate_collectionTracker.add( fieldName, map.size() ); } } } }
@Advice.OnMethodExit static void $$_hibernate_areCollectionFieldsDirty( @FieldName String fieldName, @FieldValue Map<?, ?> map, @Advice.Argument(0) DirtyTracker tracker, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( $$_hibernate_collectionTracker != null ) { if ( map == null && $$_hibernate_collectionTracker.getSize( fieldName ) != -1 ) { tracker.add( fieldName ); } else if ( map != null && $$_hibernate_collectionTracker.getSize( fieldName ) != map.size() ) { tracker.add( fieldName ); } } } }
@Advice.OnMethodExit static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) { Object[] array = argument.toArray(); for ( int i = 0; i < array.length; i++ ) { if ( Hibernate.isPropertyInitialized( array[i], mappedBy ) ) { Collection<Object> c = getter( array[i] ); if ( c != self && c != null ) { c.add( self ); } } } } }
@Advice.OnMethodEnter(inline = false) public static void onBeforeEvaluate(@Advice.Argument(0) Environment env, @Advice.This Expression dot) { Profiler.start(env.getCurrentTemplate().getName() + ':' + dot.getBeginLine() + '#' + dot.toString()); }