@Advice.OnMethodExit private static void addReflectiveMonitorMethodCall(@Advice.This Object dataSource, @Advice.Return(readOnly = false) Connection connection, @Advice.Enter long startTime) { try { Object[] connectionMonitor = (Object[]) ((ThreadLocal) Dispatcher.getValues().get("org.stagemonitor.jdbc.ConnectionMonitor")).get(); if (connectionMonitor != null) { final Method connectionMonitorMethod = (Method) connectionMonitor[1]; final long duration = System.nanoTime() - startTime; // In JBoss, this method is executed in the context of the module class loader which loads the DataSource // The connectionMonitor is not accessible from this class loader. That's why we have to use reflection. connection = (Connection) connectionMonitorMethod.invoke(connectionMonitor[0], connection, dataSource, duration); } } catch (Exception e) { e.printStackTrace(); } }
@SuppressWarnings({"unused", "UnusedAssignment"}) @Advice.OnMethodExit private static void exit(@Advice.Return(readOnly = false, typing = Assigner.Typing.DYNAMIC) Object returned, @Advice.Enter Callable<?> mocked) throws Throwable { if (mocked != null) { returned = mocked.call(); } }
@SuppressWarnings({"unused", "UnusedAssignment"}) @Advice.OnMethodExit private static void enter(@Advice.This Object self, @Advice.Return(readOnly = false) int hashCode, @Advice.Enter boolean skipped) { if (skipped) { hashCode = System.identityHashCode(self); } } }
@Advice.OnMethodExit static void $$_hibernate_getCollectionTracker( @Advice.Return(readOnly = false) CollectionTracker returned) { returned = NoopCollectionTracker.INSTANCE; } }
@Advice.OnMethodExit public static void addDirectMonitorMethodCall(@Advice.This Object dataSource, @Advice.Return(readOnly = false) Connection connection, @Advice.Enter long startTime) { connection = monitorGetConnection(dataSource, connection, startTime); }
@OnMethodExit private static void exit(@Advice.Return(readOnly = false, typing = DYNAMIC) Object returned, @Advice.Enter Callable<?> mocked) throws Throwable { if (mocked != null) { returned = mocked.call(); } }
@OnMethodExit private static void exit(@Advice.Return(readOnly = false, typing = DYNAMIC) Object returned, @This Object self, @Origin final Method method, @Advice.Enter Callable<?> mocked) throws Throwable { if (mocked != null) { returned = mocked.call(); } } }
@OnMethodExit private static void exit(@Advice.Return(readOnly = false, typing = DYNAMIC) Object returned, @Advice.Enter Callable<?> mocked) throws Throwable { if (mocked != null) { returned = mocked.call(); } }
@OnMethodExit private static void exit(@Return(readOnly = false, typing = DYNAMIC) Object returned, @Enter Callable<?> mocked) throws Throwable { if (mocked != null) { returned = mocked.call(); } }
@Advice.OnMethodExit static void $$_hibernate_getDirtyAttributes( @Advice.This ExtendedSelfDirtinessTracker self, @Advice.Return(readOnly = false) String[] returned, @Advice.FieldValue(value = EnhancerConstants.TRACKER_FIELD_NAME, readOnly = false) DirtyTracker $$_hibernate_tracker, @Advice.FieldValue(value = EnhancerConstants.TRACKER_COLLECTION_NAME, readOnly = false) CollectionTracker $$_hibernate_collectionTracker) { if ( $$_hibernate_collectionTracker == null ) { returned = ( $$_hibernate_tracker == null ) ? new String[0] : $$_hibernate_tracker.get(); } else { if ( $$_hibernate_tracker == null ) { $$_hibernate_tracker = new SimpleFieldTracker(); } self.$$_hibernate_getCollectionFieldDirtyNames( $$_hibernate_tracker ); returned = $$_hibernate_tracker.get(); } } }
@Advice.OnMethodExit public static void afterGetHandler(@Advice.Return Object handler) { SpringMvcRequestNameDeterminerTransformer.setRequestNameByHandler(handler); }
@Advice.OnMethodExit static void $$_hibernate_areCollectionFieldsDirty( @Advice.Return(readOnly = false) boolean returned, @FieldName String fieldName, @FieldValue Map<?, ?> map, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( !returned && $$_hibernate_collectionTracker != null ) { if ( map == null && $$_hibernate_collectionTracker.getSize( fieldName ) != -1 ) { returned = true; } else if ( map != null && $$_hibernate_collectionTracker.getSize( fieldName ) != map.size() ) { returned = true; } } } }
@Advice.OnMethodExit private static void setHandlerChain(@Advice.Return Object portOrDispatch) { if (portOrDispatch instanceof BindingProvider) { final Binding binding = ((BindingProvider) portOrDispatch).getBinding(); final List<Handler> handlerChain = binding.getHandlerChain(); if (handlerChain != null) { binding.setHandlerChain(handlerChain); } else { binding.setHandlerChain(new ArrayList<Handler>()); } } }
@Advice.OnMethodExit public static void addDirectMonitorMethodCall(@Advice.This Object dataSource, @Advice.Return(readOnly = false) Connection connection, @Advice.Enter long startTime) { connection = monitorGetConnection(dataSource, connection, startTime); }
@Advice.OnMethodExit static void $$_hibernate_areCollectionFieldsDirty( @Advice.Return(readOnly = false) boolean returned, @FieldName String fieldName, @FieldValue Collection<?> collection, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) CollectionTracker $$_hibernate_collectionTracker) { if ( !returned && $$_hibernate_collectionTracker != null ) { if ( collection == null && $$_hibernate_collectionTracker.getSize( fieldName ) != -1 ) { returned = true; } else if ( collection != null && $$_hibernate_collectionTracker.getSize( fieldName ) != collection.size() ) { returned = true; } } } }
@Advice.OnMethodExit static void $$_hibernate_hasDirtyAttributes( @Advice.This ExtendedSelfDirtinessTracker self, @Advice.Return(readOnly = false) boolean returned, @Advice.FieldValue(value = EnhancerConstants.TRACKER_FIELD_NAME, readOnly = false) DirtyTracker $$_hibernate_tracker) { returned = ( $$_hibernate_tracker != null && !$$_hibernate_tracker.isEmpty() ) || self.$$_hibernate_areCollectionFieldsDirty(); } }
@Advice.OnMethodExit static void $$_hibernate_getDirtyAttributes( @Advice.Return(readOnly = false) String[] returned, @Advice.FieldValue(value = EnhancerConstants.TRACKER_FIELD_NAME) DirtyTracker $$_hibernate_tracker) { returned = $$_hibernate_tracker == null ? new String[0] : $$_hibernate_tracker.get(); } }
@Advice.OnMethodExit static void $$_hibernate_getCollectionTracker( @Advice.Return(readOnly = false) CollectionTracker returned) { returned = NoopCollectionTracker.INSTANCE; } }
@Advice.OnMethodExit static void $$_hibernate_hasDirtyAttributes( @Advice.Return(readOnly = false) boolean returned, @Advice.FieldValue(value = EnhancerConstants.TRACKER_FIELD_NAME) DirtyTracker $$_hibernate_tracker) { returned = $$_hibernate_tracker != null && !$$_hibernate_tracker.isEmpty(); } }
@SuppressWarnings({"unused", "UnusedAssignment"}) @Advice.OnMethodExit private static void enter(@Advice.This Object self, @Advice.Argument(0) Object other, @Advice.Return(readOnly = false) boolean equals, @Advice.Enter boolean skipped) { if (skipped) { equals = self == other; } } }