diff --git a/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java b/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java index 64f9a0a7e1..01c148bd62 100644 --- a/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java +++ b/functional_test/src/test/java/com/newrelic/agent/instrumentation/ClassTransformerTest.java @@ -21,8 +21,6 @@ import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringDispatcherPointCut; import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut; import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut; -import com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionConfigMatcherPointCut; -import com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut; import com.newrelic.agent.service.ServiceFactory; import org.junit.Assert; import org.junit.Test; @@ -54,9 +52,6 @@ public void test() { } List manual = Arrays.asList( - // struts - new StrutsActionPointCut(classTransformer), - new StrutsActionConfigMatcherPointCut(classTransformer), // Spring new SpringPointCut(classTransformer), // new SpringWildcardPathPointCut(classTransformer), diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java deleted file mode 100644 index 45191b3518..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionInvocation.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import com.newrelic.agent.instrumentation.pointcuts.InterfaceMixin; - -@InterfaceMixin(originalClassName = "com/opensymphony/xwork2/ActionInvocation") -public interface ActionInvocation { - Object getAction(); -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java deleted file mode 100644 index b2eb4d2953..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/ActionProxy.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import com.newrelic.agent.instrumentation.pointcuts.InterfaceMixin; - -@InterfaceMixin(originalClassName = "com/opensymphony/xwork2/ActionProxy") -public interface ActionProxy { - String getActionName(); -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java deleted file mode 100644 index 85d95be430..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionConfigMatcherPointCut.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import java.text.MessageFormat; -import java.util.logging.Level; - -import com.newrelic.agent.Agent; -import com.newrelic.agent.Transaction; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.agent.instrumentation.PointCutClassTransformer; -import com.newrelic.agent.instrumentation.TracerFactoryPointCut; -import com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher; -import com.newrelic.agent.instrumentation.pointcuts.PointCut; -import com.newrelic.agent.tracers.ClassMethodSignature; -import com.newrelic.agent.tracers.MethodExitTracer; -import com.newrelic.agent.tracers.Tracer; -import com.newrelic.agent.transaction.TransactionNamingPolicy; -import com.newrelic.agent.util.Invoker; - -@PointCut -public class StrutsActionConfigMatcherPointCut extends TracerFactoryPointCut { - private static final String STRUTS = "Struts"; - private static final String ACTION_CONFIG_MATCHER_CLASS = "org/apache/struts/config/ActionConfigMatcher"; - private static final String GET_PATH = "getPath"; - - public StrutsActionConfigMatcherPointCut(PointCutClassTransformer classTransformer) { - super( - StrutsActionConfigMatcherPointCut.class, - new ExactClassMatcher(ACTION_CONFIG_MATCHER_CLASS), - createExactMethodMatcher("convertActionConfig", - "(Ljava/lang/String;Lorg/apache/struts/config/ActionConfig;Ljava/util/Map;)Lorg/apache/struts/config/ActionConfig;")); - } - - @Override - public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object matcher, Object[] args) { - return new StrutsActionConfigMatcherTracer(transaction, sig, matcher, args); - } - - private static class StrutsActionConfigMatcherTracer extends MethodExitTracer { - public StrutsActionConfigMatcherTracer(Transaction transaction, ClassMethodSignature sig, Object matcher, - Object[] args) { - super(sig, transaction); - try { - Object actionConfig = args[1]; - String wildcardPath = (String) Invoker.invoke(actionConfig, actionConfig.getClass(), GET_PATH); - Agent.LOG.finer("Normalizing path using Struts wildcard"); - setTransactionName(transaction, wildcardPath); - } catch (Exception e) { - String msg = MessageFormat.format("Exception in {0} handling {1}: {2}", - StrutsActionConfigMatcherPointCut.class.getSimpleName(), sig, e); - if (Agent.LOG.isLoggable(Level.FINEST)) { - Agent.LOG.log(Level.FINEST, msg, e); - } else { - Agent.LOG.finer(msg); - } - } - } - - private void setTransactionName(Transaction transaction, String wildcardPath) { - if (!transaction.isTransactionNamingEnabled()) { - return; - } - TransactionNamingPolicy policy = TransactionNamingPolicy.getHigherPriorityTransactionNamingPolicy(); - if (Agent.LOG.isLoggable(Level.FINER)) { - if (policy.canSetTransactionName(transaction, TransactionNamePriority.FRAMEWORK)) { - String msg = MessageFormat.format("Setting transaction name to \"{0}\" using Struts wildcard", - wildcardPath); - Agent.LOG.finer(msg); - } - } - policy.setTransactionName(transaction, wildcardPath, STRUTS, TransactionNamePriority.FRAMEWORK); - } - - @Override - protected void doFinish(int opcode, Object returnValue) { - // no op - } - - } -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java b/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java deleted file mode 100644 index 6bcd190188..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/instrumentation/pointcuts/frameworks/struts/StrutsActionPointCut.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * * Copyright 2020 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ - -package com.newrelic.agent.instrumentation.pointcuts.frameworks.struts; - -import java.text.MessageFormat; -import java.util.logging.Level; - -import com.newrelic.agent.Agent; -import com.newrelic.agent.MetricNames; -import com.newrelic.agent.Transaction; -import com.newrelic.agent.bridge.TransactionNamePriority; -import com.newrelic.agent.instrumentation.PointCutClassTransformer; -import com.newrelic.agent.instrumentation.TracerFactoryPointCut; -import com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher; -import com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher; -import com.newrelic.agent.instrumentation.pointcuts.PointCut; -import com.newrelic.agent.tracers.ClassMethodSignature; -import com.newrelic.agent.tracers.DefaultTracer; -import com.newrelic.agent.tracers.Tracer; -import com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat; -import com.newrelic.agent.transaction.TransactionNamingPolicy; - -/** - * Instruments the execute method of Struts actions. - */ -@PointCut -public class StrutsActionPointCut extends TracerFactoryPointCut { - public static final String STRUTS_ACTION_CLASS = "org/apache/struts/action/Action"; - private static final MethodMatcher METHOD_MATCHER = createExactMethodMatcher( - "execute", - "(Lorg/apache/struts/action/ActionMapping;Lorg/apache/struts/action/ActionForm;Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)Lorg/apache/struts/action/ActionForward;", - "(Lorg/apache/struts/action/ActionMapping;Lorg/apache/struts/action/ActionForm;Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lorg/apache/struts/action/ActionForward;"); - - public StrutsActionPointCut(PointCutClassTransformer classTransformer) { - super(StrutsActionPointCut.class, new ChildClassMatcher(STRUTS_ACTION_CLASS), METHOD_MATCHER); - } - - @Override - public Tracer doGetTracer(Transaction transaction, ClassMethodSignature sig, Object action, Object[] args) { - return new StrutsActionTracer(transaction, sig, action, args); - } - - private static class StrutsActionTracer extends DefaultTracer { - private final String actionClassName; - - public StrutsActionTracer(Transaction transaction, ClassMethodSignature sig, Object action, Object[] args) { - super(transaction, sig, action); - actionClassName = action.getClass().getName(); - setTransactionName(transaction, actionClassName); - setMetricNameFormat(new SimpleMetricNameFormat("StrutsAction/" + actionClassName)); - } - - private void setTransactionName(Transaction tx, String action) { - if (!tx.isTransactionNamingEnabled()) { - return; - } - TransactionNamingPolicy policy = TransactionNamingPolicy.getHigherPriorityTransactionNamingPolicy(); - if (Agent.LOG.isLoggable(Level.FINER)) { - if (policy.canSetTransactionName(tx, TransactionNamePriority.FRAMEWORK)) { - String msg = MessageFormat.format("Setting transaction name to \"{0}\" using Struts action", action); - Agent.LOG.finer(msg); - } - } - policy.setTransactionName(tx, action, MetricNames.STRUTS_ACTION, TransactionNamePriority.FRAMEWORK); - } - - } - -}