method

反射与动态代理的关系

陌路散爱 提交于 2020-03-12 02:29:56
先展示下mybatis的动态代理是怎样的 结合上一篇文章实践的 String resource = "mybatis.xml" ; InputStream resourceAsStream = Resources . getResourceAsStream ( resource ) ; SqlSessionFactory factory = new SqlSessionFactoryBuilder ( ) . build ( resourceAsStream ) ; SqlSession sqlSession = factory . openSession ( ) ; // 不使用动态代理的情况下 try { List < User > userList = sqlSession . selectList ( "com.wyl.mybatis.dao.UserDao.getUserList" ) ; System . out . println ( "**********" + JSON . toJSON ( userList ) ) ; } finally { sqlSession . close ( ) ; } // 使用动态代理的情况下 try { UserDao userDao = sqlSession . getMapper ( UserDao . class ) ;

聊聊skywalking的http-async-client-plugin

拈花ヽ惹草 提交于 2020-03-10 23:12:53
序 本文主要研究一下skywalking的http-async-client-plugin skywalking-plugin.def skywalking-6.6.0/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/main/resources/skywalking-plugin.def httpasyncclient-4.x=org.apache.skywalking.apm.plugin.httpasyncclient.v4.define.HttpAsyncClientInstrumentation httpasyncclient-4.x=org.apache.skywalking.apm.plugin.httpasyncclient.v4.define.SessionRequestInstrumentation httpasyncclient-4.x=org.apache.skywalking.apm.plugin.httpasyncclient.v4.define.HttpAsyncRequestExecutorInstrumentation skywalking的http-async-client-plugin定义了三个增强,分别是HttpAsyncClientInstrumentation

Spring AOP

非 Y 不嫁゛ 提交于 2020-03-09 17:51:35
Spring AOP 手动配置通知类 前置通知 import java.lang.reflect.Method; import org.springframework.aop.BeforeAdvice; public class GreetingBeforAdvice implements MethodBeforeAdvice { @Override public void before(Method method,Object []params,Object obj) throws Throwable{ String name=String.valueOf(params[0]); System.out.println("###前置通知:参数," + name ); } } 后置通知 import java.lang.reflect.Method; import org.springframework.aop.AfterReturningAdvice; public class GreetingAfterAdvice implements AfterReturningAdvice { @Override public void afterReturning(Object obj, Method method, Object[] params,Object arg3) throws

java动态代理cglib基于子类代码增强案例

可紊 提交于 2020-03-09 15:39:33
相对于Proxy不同的是,Proxy是基于接口的动态代理,而cglib是子类的 第一步导入cglib的jar包 < dependencies > < dependency > < groupId > cglib < / groupId > < artifactId > cglib < / artifactId > < version > 3.2 .12 < / version > < / dependency > < / dependencies > 普通类 public class Producer { /** * 销售 * @param money */ public void saleProduct ( float money ) { System . out . println ( "销售产品:并拿到钱" + money ) ; } /** * 售后 * @param money */ public void afterService ( float money ) { System . out . println ( "提供售后,并拿到钱" + money ) ; } } 测试类 /** * 模拟一个消费者 * @author DELL */ public class Client { public static void main ( String [ ] args )

有关方法的学习和总结(二)

北城余情 提交于 2020-03-08 18:11:13
1方法的重载 我们假设要在程序中实现一个对数字求和的方法,由于参与求和数字的个数和类型都不确定,因此要针对不同的情况去设计不同的方法。接下来通过一个案例来实现对两个整数相加、对三个整数相加以及对两个小数相加的功能,具体实现如下所示。MethodDemo02.java public class MethodDemo02 { public static void main(String[] args) { // 下面是针对 求和方法的调用 int sum1 = add01 (1, 2); int sum2 = add02 (1, 2, 3); double sum3 = add03 (1.2, 2.3); // 下面的代码是打印求和的结果 System. out .println( "sum1=" + sum1); System. out .println( "sum2=" + sum2); System. out .println( "sum3=" + sum3); } // 下面的方法实现了两个整数相加 public static int add01( int x, int y) { return x + y; } // 下面的方法实现了三个整数相加 public static int add02( int x, int y, int z) { return x + y + z;

android Unable to instantiate application

与世无争的帅哥 提交于 2020-03-07 14:29:22
最近一段时间在做项目时候遇到一个错误老是解决不了,log如下: FATAL EXCEPTION: main 12-11 09:08:53.922 E/AndroidRuntime( 1227): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for org.yh.crm; is package not installed? 12-11 09:08:53.922 E/AndroidRuntime( 1227): at android.app.LoadedApk.makeApplication(LoadedApk.java:509) 12-11 09:08:53.922 E/AndroidRuntime( 1227): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4417) 12-11 09:08:53.922 E/AndroidRuntime( 1227): at android.app.ActivityThread.access$1300

实现 classmethod装饰器

萝らか妹 提交于 2020-03-07 10:46:10
实现 classmethod装饰器 from functools import wraps, partial class Classmethod: def __init__(self, method): wraps(method)(self) def __get__(self, instance, cls): return partial(self.__wrapped__, cls) class C: @Classmethod def method(cls): print(cls) @Classmethod def method2(cls, x): print(cls) print(x) c =C() c.method() c.method2(1) 来源: 51CTO 作者: pythoner小智 链接: https://blog.51cto.com/14730644/2476069

聊聊skywalking的spring-cloud-gateway-plugin

假如想象 提交于 2020-03-07 10:33:09
序 本文主要研究一下skywalking的spring-cloud-gateway-plugin NettyRoutingFilterInstrumentation skywalking-6.6.0/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; } @Override public InstanceMethodsInterceptPoint[]

SAP OO ALV实现TOP-OF-PAGE页眉显示

不打扰是莪最后的温柔 提交于 2020-03-05 23:19:57
*&---------------------------------------------------------------------* *& Report YTEST_OOALV1_DEMO *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT YTEST_OOALV1_DEMO MESSAGE-ID ZZ . DATA: IT_FLIGHT TYPE TABLE OF SFLIGHT. DATA: OK_CODE LIKE SY-UCOMM, SAVE_OK LIKE SY-UCOMM. DATA: G_CONTAINER TYPE SCRFNAME VALUE 'CONTROL', O_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT, O_SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER, O_PARENT_GRID TYPE REF TO CL_GUI_CONTAINER, O_PARENT_TOP TYPE REF TO CL

调用远程Webservice出现java.lang.IllegalStateException: Unable to create schema compiler异常

廉价感情. 提交于 2020-03-04 21:53:14
今天在调试远程的Webservice的短信网关发送短信功能过程中出现了点异常,异常信息如下: ```java java.lang.IllegalStateException: Unable to create schema compiler at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:744) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createSchemaCompiler(DynamicClientFactory.java:445) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:325) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:243) at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient