wu-sheng commented on code in PR #560: URL: https://github.com/apache/skywalking-java/pull/560#discussion_r1236755311
########## apm-sniffer/apm-sdk-plugin/websphere-liberty-23.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/websphereliberty/v23/define/JakartaFilterManagerInstrumentation.java: ########## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.websphereliberty.v23.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * for websphere liberty WebAppFilterManager enhance + */ +public class JakartaFilterManagerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "com.ibm.ws.webcontainer.filter.WebAppFilterManager"; + + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.websphereliberty.v23.JakartaFilterManagerInvokeInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return null; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher<MethodDescription> getMethodsMatcher() { + return named("invokeFilters") + .and(takesArgument(0, named("jakarta.servlet.ServletRequest"))) + .and(takesArgument(1, named("jakarta.servlet.ServletResponse"))); Review Comment: > Yes, it is different version of websphere. WebSphere liberty use jakarta and webSphere traditional use javax. > > Currnetly WebSphere Liberty 23.x plugin compatible for webSphere liberty and webSphere traditional. > > You means I should create another plugin 'websphere-traditional-xx-plugin'? @weixiang1862 How do you make sure these two kinds of APIs are compiled in one plugin? Just because they have different package names? But how do you test? I think @xu1009 's point is `witness` class is always recommended to do a version differentiation. Your way works too but a little tricky and implicit. `witness` + 2 plugins or 2 package names should be better. Also, you should mention this on the plugin docs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
