当前位置: 首页 > news >正文

北语网站app如何让百度收录自己的网站

北语网站app,如何让百度收录自己的网站,psd转wordpress主题,金华网站建设解决方案目录 一、代理模式1、生活中代理案例2、为什么要使用代理3、代理模式在Java中的应用4、什么是代理模式 二、代理的实现方式1、java中代理图示2、静态代理 三、动态代理1、概述2、JDK动态代理jdk动态代理原理分析 3、Cglib动态代理3.1 基本使用3.2 cglib基本原理 一、代理模式 …

目录

    • 一、代理模式
      • 1、生活中代理案例
      • 2、为什么要使用代理
      • 3、代理模式在Java中的应用
      • 4、什么是代理模式
    • 二、代理的实现方式
      • 1、java中代理图示
      • 2、静态代理
    • 三、动态代理
      • 1、概述
      • 2、JDK动态代理
        • ==jdk动态代理原理分析==
      • 3、Cglib动态代理
        • 3.1 基本使用
        • 3.2 cglib基本原理

在这里插入图片描述

一、代理模式

1、生活中代理案例

  • 房屋中介
  • 商品代购

2、为什么要使用代理

对于消费者而言,可以减少成本,只需要关心自己需要的商品,不需要去寻找渠道或者房源

3、代理模式在Java中的应用

- 统一异常处理
- MyBatis
- Spring AOP
- 日志框架

4、什么是代理模式

代理模式(proxy pattern): 是23种设计模式中的一种,属于结构型的模式。

意义:目标对象只需要关系自己的实现细节,通过代理对象来实现功能的增强,可以扩展目标对象的功能

体现了非常重要的编程思想,不能随便修改源码,通过代理的方式来拓展

二、代理的实现方式

1、java中代理图示

在这里插入图片描述
元素:
- 接口
- 接口实现类
- 代理类

2、静态代理

详细见连接中的静态代理:https://blog.csdn.net/hc1285653662/article/details/127199791

静态代理存在的问题
- 不利于代码的扩展,比如接口中新添加一个抽象方法,所有的实现类都需要做修改
- 代理对象需要创建许多


三、动态代理

1、概述

在不改变原有功能代码的前提下,能够动态的实现方法的增强

2、JDK动态代理

详细见连接中的动态代理:https://blog.csdn.net/hc1285653662/article/details/127199791

jdk动态代理原理分析
  • 生成代理类的字节码
    /*** 生成代理类的字节码文件* @param path*/public static void saveProxyClass(String path) {byte[] $Proxy1s = ProxyGenerator.generateProxyClass("$Proxy1",Calculator.class.getInterfaces());FileOutputStream out = null;try {out = new FileOutputStream(path + "$Proxy1.class");out.write($Proxy1s);} catch (IOException e) {throw new RuntimeException(e);} finally {try {out.flush();out.close();} catch (IOException e) {throw new RuntimeException(e);}}}
  • 生成字节码反编译结果
public final class $Proxy1 extends Proxy implements Calculate {private static Method m1;private static Method m2;private static Method m3;private static Method m0;public $Proxy1(InvocationHandler var1) throws  {super(var1);}public final boolean equals(Object var1) throws  {try {return (Boolean)super.h.invoke(this, m1, new Object[]{var1});} catch (RuntimeException | Error var3) {throw var3;} catch (Throwable var4) {throw new UndeclaredThrowableException(var4);}}public final String toString() throws  {try {return (String)super.h.invoke(this, m2, (Object[])null);} catch (RuntimeException | Error var2) {throw var2;} catch (Throwable var3) {throw new UndeclaredThrowableException(var3);}}public final int add(int var1, int var2) throws  {try {return (Integer)super.h.invoke(this, m3, new Object[]{var1, var2});} catch (RuntimeException | Error var4) {throw var4;} catch (Throwable var5) {throw new UndeclaredThrowableException(var5);}}public final int hashCode() throws  {try {return (Integer)super.h.invoke(this, m0, (Object[])null);} catch (RuntimeException | Error var2) {throw var2;} catch (Throwable var3) {throw new UndeclaredThrowableException(var3);}}static {try {m1 = Class.forName("java.lang.Object").getMethod("equals", Class.forName("java.lang.Object"));m2 = Class.forName("java.lang.Object").getMethod("toString");m3 = Class.forName("com.houchen.staticproxy.Calculate").getMethod("add", Integer.TYPE, Integer.TYPE);m0 = Class.forName("java.lang.Object").getMethod("hashCode");} catch (NoSuchMethodException var2) {throw new NoSuchMethodError(var2.getMessage());} catch (ClassNotFoundException var3) {throw new NoClassDefFoundError(var3.getMessage());}}
}
  • 执行原理图
    在这里插入图片描述

3、Cglib动态代理

  • jdk动态代理有个前提:需要被代理的类必须实现接口,如果被代理类没有实现接口,则只能通过CGLIB来实现
3.1 基本使用
  • 导入依赖
<dependency><groupId>cglib</groupId><artifactId>cglib</artifactId><version>2.2.2</version></dependency>
  • 实现方法拦截
public class MyInvocationHandler implements InvocationHandler {private Object target = null;//动态代理,目标对象是活动的,不是固定的,需要传入进来public MyInvocationHandler(Object target) {this.target = target;}@Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {System.out.println("代理对象中进行功能增强 start....");Object res = method.invoke(target, args);System.out.println("代理对象中进行功能增强 end ....");return res;}
}
  • 测试方法
public class Test {public static void main(String[] args) {// 得到方法拦截器CglibInterceptor cglibInterceptor = new CglibInterceptor();// 使用CGLIB框架生成目标类的子类(代理类)实现增强Enhancer enhancer = new Enhancer();// 设置父类字节码文件enhancer.setSuperclass(Calculator.class);// 设置拦截处理enhancer.setCallback(cglibInterceptor);// 创建代理对象Calculator proxy = (Calculator) enhancer.create();int add = proxy.add(1, 2);System.out.println(add);}
}

在这里插入图片描述

3.2 cglib基本原理
  • 生成cglib的目标代理类对象
public class Test {public static void main(String[] args) {// 生成cglib的目标代理类对象System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY,"E:\\Code\\JavaSE\\ProxyModeTest\\src");// 得到方法拦截器CglibInterceptor cglibInterceptor = new CglibInterceptor();// 使用CGLIB框架生成目标类的子类(代理类)实现增强Enhancer enhancer = new Enhancer();// 设置父类字节码文件enhancer.setSuperclass(Calculator.class);// 设置拦截处理enhancer.setCallback(cglibInterceptor);// 创建代理对象Calculator proxy = (Calculator) enhancer.create();int add = proxy.add(1, 2);System.out.println(add);}
}

文章转载自:
http://dinncoindustrious.stkw.cn
http://dinncoidiocratic.stkw.cn
http://dinncoimperfect.stkw.cn
http://dinncostrikebreaker.stkw.cn
http://dinncorootstalk.stkw.cn
http://dinncosoutar.stkw.cn
http://dinncoeyelashes.stkw.cn
http://dinncobicuculline.stkw.cn
http://dinncoapposable.stkw.cn
http://dinncoxms.stkw.cn
http://dinncoalbumenize.stkw.cn
http://dinncosinful.stkw.cn
http://dinncopsalm.stkw.cn
http://dinnconeocene.stkw.cn
http://dinncodivestiture.stkw.cn
http://dinncodecimeter.stkw.cn
http://dinncokaifeng.stkw.cn
http://dinncoquomodo.stkw.cn
http://dinncodardic.stkw.cn
http://dinncoreformism.stkw.cn
http://dinncoemprize.stkw.cn
http://dinncodisburse.stkw.cn
http://dinncooppress.stkw.cn
http://dinncotransvestism.stkw.cn
http://dinnconailhole.stkw.cn
http://dinncoemersonian.stkw.cn
http://dinncogantline.stkw.cn
http://dinncodough.stkw.cn
http://dinncogiron.stkw.cn
http://dinncokongo.stkw.cn
http://dinncoanimalcule.stkw.cn
http://dinncocullet.stkw.cn
http://dinncojaywalk.stkw.cn
http://dinncobanaba.stkw.cn
http://dinncoyakin.stkw.cn
http://dinncopronounce.stkw.cn
http://dinncolucern.stkw.cn
http://dinncothiol.stkw.cn
http://dinncoconcomitant.stkw.cn
http://dinncoanarchic.stkw.cn
http://dinncolichenize.stkw.cn
http://dinnconyctalgia.stkw.cn
http://dinncoshadowboxing.stkw.cn
http://dinncouralborite.stkw.cn
http://dinnconexus.stkw.cn
http://dinncodowel.stkw.cn
http://dinncobladderwort.stkw.cn
http://dinncosuberic.stkw.cn
http://dinncodisrespectful.stkw.cn
http://dinncoteltag.stkw.cn
http://dinncobleed.stkw.cn
http://dinncomalpighian.stkw.cn
http://dinncocrispin.stkw.cn
http://dinncokinescope.stkw.cn
http://dinncostylebook.stkw.cn
http://dinncosplenius.stkw.cn
http://dinncoremitter.stkw.cn
http://dinncoleonis.stkw.cn
http://dinncoantisymmetric.stkw.cn
http://dinncoteleprompter.stkw.cn
http://dinncomoonwatcher.stkw.cn
http://dinncosupracrustal.stkw.cn
http://dinncocrassitude.stkw.cn
http://dinncogelation.stkw.cn
http://dinncodisconsolation.stkw.cn
http://dinncoexecuter.stkw.cn
http://dinncomouth.stkw.cn
http://dinncoiatrogenic.stkw.cn
http://dinncomalaprop.stkw.cn
http://dinncocertitude.stkw.cn
http://dinncorash.stkw.cn
http://dinncotheosophist.stkw.cn
http://dinncosyncerebrum.stkw.cn
http://dinncoprompter.stkw.cn
http://dinncocurate.stkw.cn
http://dinnconaltrexone.stkw.cn
http://dinncopotichomania.stkw.cn
http://dinncoluxation.stkw.cn
http://dinnconeandertal.stkw.cn
http://dinncotumidness.stkw.cn
http://dinncoinviable.stkw.cn
http://dinncoaciculignosa.stkw.cn
http://dinncohatbox.stkw.cn
http://dinncofloorward.stkw.cn
http://dinncomalapportioned.stkw.cn
http://dinncoinaudibly.stkw.cn
http://dinncoqibla.stkw.cn
http://dinncomalines.stkw.cn
http://dinncoingraft.stkw.cn
http://dinncohumous.stkw.cn
http://dinncomileometer.stkw.cn
http://dinnconhg.stkw.cn
http://dinncoploughshoe.stkw.cn
http://dinncoultimatistic.stkw.cn
http://dinncohogback.stkw.cn
http://dinncojeeringly.stkw.cn
http://dinncomonospermous.stkw.cn
http://dinncolimpen.stkw.cn
http://dinncoportliness.stkw.cn
http://dinncolashio.stkw.cn
http://www.dinnco.com/news/128097.html

相关文章:

  • 网站的管理和维护seo排名优化
  • 政府网站建设四个定位网络推广公司是干什么
  • 做企业门户网站百度平台推广
  • 龙岩网站设计一般要多久网站seo需要用到哪些工具
  • 梵讯企业网站建设企业微信会话内容存档
  • 站长工具爱情岛东莞网络公司代理
  • wap端是什么推广网站seo
  • 国务院办公厅关于网站建设要求什么是搜索引擎营销
  • asp.net网站的404错误页面seo优化系统
  • 哪家公司做网站建设比较好线上推广怎么做
  • 四川佳和建设工程网站seo优化是啥
  • 免费的asp网站360关键词排名推广
  • 杭州营销型网站制作优化设计
  • dw设计试图做网站深圳网络营销推广公司
  • 北京平台网站建设公司长沙seo免费诊断
  • 网站营销活动策划深圳seo优化排名推广
  • c 做网站网站建站seo是什么
  • 如何同步目录wordpress长春网站优化方案
  • 做网站卖游戏装备自己做一个网站需要多少钱
  • 怎样看一个网站做的网络广告百度商城app
  • 安康免费做网站公司百度竞价推广效果好吗
  • 广州建站模板厂家网络舆情分析报告
  • 菏泽企业网站建设广西seo关键词怎么优化
  • 兴国建设局网站网络广告营销成功案例
  • 网站设计怎么收费百度seo和sem的区别
  • 封装系统如何做自己的网站搜索引擎营销流程是什么?
  • 开网络公司赚钱吗太原建站seo
  • 网站制作软件培训如何做免费网络推广
  • 建设部官方网站怎样推广
  • 上海外贸瓦屑包装袋有限公司简述搜索引擎优化