[java-identity-provider COMMIT] in /trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl: WebFlowMess...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 6 15:43:54 EDT 2016
Author: scantor
Date: Thu Oct 6 15:43:54 2016
New Revision: 8472
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8472&view=rev
Log:
Add timer/counter hooks to adaptor classes pending OpenSAML adoption.
Modified:
trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowMessageHandlerAdaptor.java
trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowProfileActionAdaptor.java
Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowMessageHandlerAdaptor.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowMessageHandlerAdaptor.java?rev=8472&r1=8471&r2=8472&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowMessageHandlerAdaptor.java (original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowMessageHandlerAdaptor.java Thu Oct 6 15:43:54 2016
@@ -21,6 +21,7 @@
import javax.annotation.Nullable;
import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.context.MetricContext;
import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
@@ -139,15 +140,32 @@
}
/** {@inheritDoc} */
-//CheckStyle: ReturnCount OFF
- @Override public void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ @Override
+ protected boolean doPreExecute(
+ @Nonnull final ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext) {
+ if (!super.doPreExecute(profileRequestContext)) {
+ return false;
+ }
+
if (handler == null) {
handler = handlerLookupStrategy.apply(profileRequestContext);
if (handler == null) {
log.debug("{} No message handler returned by lookup function, nothing to do", getLogPrefix());
- return;
+ return false;
}
}
+
+ final MetricContext metricCtx = profileRequestContext.getSubcontext(MetricContext.class);
+ if (metricCtx != null) {
+ metricCtx.start(handler.getClass().getSimpleName());
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+//CheckStyle: ReturnCount OFF
+ @Override public void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
MessageContext target = null;
switch (direction) {
@@ -191,4 +209,19 @@
}
//CheckStyle: ReturnCount ON
+ /** {@inheritDoc} */
+ @Override
+ protected void doPostExecute(
+ @Nonnull final ProfileRequestContext<InboundMessageType,OutboundMessageType> profileRequestContext) {
+
+ final MetricContext metricCtx = profileRequestContext.getSubcontext(MetricContext.class);
+ if (metricCtx != null) {
+ final String name = handler.getClass().getSimpleName();
+ metricCtx.stop(name);
+ metricCtx.inc(name);
+ }
+
+ super.doPostExecute(profileRequestContext);
+ }
+
}
Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowProfileActionAdaptor.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowProfileActionAdaptor.java?rev=8472&r1=8471&r2=8472&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowProfileActionAdaptor.java (original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/WebFlowProfileActionAdaptor.java Thu Oct 6 15:43:54 2016
@@ -21,6 +21,7 @@
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.context.MetricContext;
import net.shibboleth.utilities.java.support.logic.Constraint;
import org.opensaml.profile.action.ProfileAction;
@@ -55,7 +56,22 @@
@Nonnull public void execute(
@Nonnull final ProfileRequestContext<InboundMessageType, OutboundMessageType> profileRequestContext) {
- action.execute(profileRequestContext);
+ // The doPre/doPost hooks on the base class don't run for wrapped actions, so we do this inline.
+ // This can go away if we move the metric support down into the OpenSAML action base class.
+ final MetricContext metricCtx = profileRequestContext.getSubcontext(MetricContext.class);
+ if (metricCtx != null) {
+ metricCtx.start(action.getClass().getSimpleName());
+ }
+
+ try {
+ action.execute(profileRequestContext);
+ } finally {
+ if (metricCtx != null) {
[... 10 lines stripped ...]
More information about the commits
mailing list