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

做类似返利网的网站有哪些视频号广告推广

做类似返利网的网站有哪些,视频号广告推广,网站做子域名,网站源码上传到哪个文件夹文章目录 1.概念1.1 什么是适配器模式1.2 优点与缺点 2.实现方式2.1 类适配器模式2.2 对象适配器模式 3 Java 哪些地方用到了适配器模式4 Spring 哪些地方用到了适配器模式 1.概念 1.1 什么是适配器模式 简单来说,适配器模式就是作为两个不兼容接口之间的桥梁。 1.…

文章目录

  • 1.概念
    • 1.1 什么是适配器模式
    • 1.2 优点与缺点
  • 2.实现方式
    • 2.1 类适配器模式
    • 2.2 对象适配器模式
  • 3 Java 哪些地方用到了适配器模式
  • 4 Spring 哪些地方用到了适配器模式

1.概念

1.1 什么是适配器模式

简单来说,适配器模式就是作为两个不兼容接口之间的桥梁

1.2 优点与缺点

优点:
1.可以让原本接口不兼容的类可以合作无间。
2.增加了类的透明性和复用性,现有的系统不改变的前提下引进新的接口。
3.灵活性好,可以通过配置文件来更换适配器。
4.系统可以更易于扩展。
缺点:
1.适配器编写过程需要一定的技巧,如果接口差异过大,适配器编写会非常复杂。
2.增加系统的理解与设计难度,由于适配器模式将一些简单的接口转换成复杂的接口,增加阅读难度。

2.实现方式

2.1 类适配器模式

类适配器模式通过多重继承来实现,它同时继承了目标接口和被适配者的类。这样,适配器就可以在继承自被适配者的类的基础上,实现目标接口。

// Lightning接口
public interface Lightning {void chargeLightning();
}// Lightning充电器
public class LightningCharger implements Lightning {@Overridepublic void chargeLightning() {System.out.println("Charging via Lightning connector.");}
}// MicroUSB接口
public interface MicroUSB {void chargeMicroUSB();
}// 类适配器
public class MicroUSBClassAdapter extends LightningCharger implements MicroUSB {@Overridepublic void chargeMicroUSB() {// 直接使用继承自LightningCharger的方法System.out.println("Class Adapter converts MicroUSB to Lightning.");this.chargeLightning();}
}// 使用类适配器模式
public class AdapterDemo {public static void main(String[] args) {MicroUSBClassAdapter microUSBClassAdapter = new MicroUSBClassAdapter();microUSBClassAdapter.chargeMicroUSB();}
}

2.2 对象适配器模式

对象适配器模式通过组合来实现,它持有一个被适配者的实例,并在适配器中实现目标接口。适配器将目标接口的调用转发给被适配者的相应方法。

// Lightning接口
public interface Lightning {void chargeLightning();
}// Lightning充电器
public class LightningCharger implements Lightning {@Overridepublic void chargeLightning() {System.out.println("Charging via Lightning connector.");}
}// MicroUSB接口
public interface MicroUSB {void chargeMicroUSB();
}// 对象适配器
public class MicroUSBObjectAdapter implements MicroUSB {private Lightning lightning;public MicroUSBObjectAdapter(Lightning lightning) {this.lightning = lightning;}@Overridepublic void chargeMicroUSB() {// 适配器将MicroUSB充电请求转换为Lightning充电System.out.println("Object Adapter converts MicroUSB to Lightning.");lightning.chargeLightning();}
}// 使用对象适配器模式
public class AdapterDemo {public static void main(String[] args) {LightningCharger lightningCharger = new LightningCharger();MicroUSBObjectAdapter microUSBObjectAdapter = new MicroUSBObjectAdapter(lightningCharger);microUSBObjectAdapter.chargeMicroUSB();}
}

对象适配器模式更加灵活,因为它可以在运行时改变被适配者的实例,而类适配器模式则在编译时就已经确定了被适配者的类。

3 Java 哪些地方用到了适配器模式

JDBC(Java Database Connectivity): JDBC使用适配器模式来连接不同的数据库。DriverManager类充当适配器,它根据URL选择合适的Driver实现,并将JDBC调用转换为特定数据库的调用。
AWT(Abstract Window Toolkit)事件监听器: AWT使用适配器模式来处理事件。例如,AWTEventMulticaster类充当适配器,它将事件源的事件转发给事件监听器。
Java I/O: Java的I/O库中使用了适配器模式来适配不同的数据源和数据目的地。例如,InputStreamReader和OutputStreamWriter类充当适配器,它们将字节流转换为字符流。
Java Collections Framework: Java集合框架中使用了适配器模式来适配不同的集合类型。例如,Collections.synchronizedCollection方法返回一个线程安全的集合视图,它充当适配器,将非线程安全的集合适配为线程安全的集合。
Java XML解析: Java中解析XML时,可以使用适配器模式来适配不同的XML解析器。例如,SAXParserFactory和DocumentBuilderFactory类充当适配器,它们根据配置选择合适的解析器实现。
Java RMI(Remote Method Invocation): Java RMI中使用了适配器模式来适配远程对象和本地对象。RMI系统提供的代理类充当适配器,它将远程方法调用转换为本地方法调用。
第三方库和框架: 许多第三方库和框架也使用适配器模式来集成不同的技术或API。例如,Spring框架中的AopProxy类充当适配器,它将AOP(面向切面编程)的调用转换为目标对象的调用。

4 Spring 哪些地方用到了适配器模式

AOP(面向切面编程): Spring AOP使用适配器模式来实现方法拦截。Spring的AopProxy类充当适配器,它根据配置创建代理对象,并在目标对象的方法调用前后执行增强代码。
事件发布: Spring的事件驱动模型使用适配器模式来解耦事件的生产者和消费者。ApplicationEventMulticaster类充当适配器,它将事件发布给所有注册的监听器。
事务管理: Spring的事务管理器使用适配器模式来适配不同的事务API。例如,PlatformTransactionManager接口及其各种实现(如DataSourceTransactionManager和JtaTransactionManager)充当适配器,它们将Spring的事务抽象转换为具体的事务处理逻辑。
数据访问: Spring的数据访问模板(如JdbcTemplate、HibernateTemplate等)使用适配器模式来适配不同的数据访问技术。这些模板类充当适配器,它们将Spring的数据访问抽象转换为具体的数据库操作。
Web集成: Spring的Web模块使用适配器模式来集成不同的Web框架。例如,DispatcherServlet充当适配器,它将HTTP请求转换为Spring MVC框架的调用。
资源访问: Spring的ResourceLoader和Resource接口使用适配器模式来抽象不同类型的资源访问。ResourceLoader的实现类充当适配器,它们将资源访问的调用转换为具体文件系统、类路径或URL的访问。
消息服务: Spring的JMS(Java消息服务)集成使用适配器模式来适配不同的消息中间件。JmsTemplate和JmsListenerContainerFactory类充当适配器,它们将Spring的消息抽象转换为具体的消息中间件操作。


文章转载自:
http://xylotomy.mrfr.cn
http://chairlady.mrfr.cn
http://crave.mrfr.cn
http://proa.mrfr.cn
http://italianise.mrfr.cn
http://pyretology.mrfr.cn
http://subsere.mrfr.cn
http://subcompact.mrfr.cn
http://exchange.mrfr.cn
http://chooser.mrfr.cn
http://armipotent.mrfr.cn
http://superbomber.mrfr.cn
http://denudate.mrfr.cn
http://independence.mrfr.cn
http://sealflower.mrfr.cn
http://benzoline.mrfr.cn
http://meroblastic.mrfr.cn
http://bombshell.mrfr.cn
http://demiseason.mrfr.cn
http://cholecystokinetic.mrfr.cn
http://pulperia.mrfr.cn
http://renumerate.mrfr.cn
http://antarctica.mrfr.cn
http://chemitype.mrfr.cn
http://karakule.mrfr.cn
http://substituent.mrfr.cn
http://porcino.mrfr.cn
http://enceladus.mrfr.cn
http://picornavirus.mrfr.cn
http://stypsis.mrfr.cn
http://monographic.mrfr.cn
http://stratolab.mrfr.cn
http://turning.mrfr.cn
http://aitken.mrfr.cn
http://seafarer.mrfr.cn
http://tribulate.mrfr.cn
http://arminianize.mrfr.cn
http://muscovitic.mrfr.cn
http://lsat.mrfr.cn
http://argus.mrfr.cn
http://detergency.mrfr.cn
http://sufficiency.mrfr.cn
http://lilac.mrfr.cn
http://chisel.mrfr.cn
http://perimorph.mrfr.cn
http://presage.mrfr.cn
http://namaste.mrfr.cn
http://outlandish.mrfr.cn
http://pigmentation.mrfr.cn
http://underpinner.mrfr.cn
http://synonymy.mrfr.cn
http://hodden.mrfr.cn
http://preses.mrfr.cn
http://funest.mrfr.cn
http://haggish.mrfr.cn
http://crankcase.mrfr.cn
http://zoologic.mrfr.cn
http://multifactor.mrfr.cn
http://leh.mrfr.cn
http://nectarize.mrfr.cn
http://quixotical.mrfr.cn
http://domiciliation.mrfr.cn
http://september.mrfr.cn
http://endophagous.mrfr.cn
http://fleetly.mrfr.cn
http://tacmar.mrfr.cn
http://balanced.mrfr.cn
http://jarl.mrfr.cn
http://springhalt.mrfr.cn
http://kinder.mrfr.cn
http://fleckless.mrfr.cn
http://corpsman.mrfr.cn
http://commuterdom.mrfr.cn
http://compliancy.mrfr.cn
http://roughout.mrfr.cn
http://statesmanlike.mrfr.cn
http://araeostyle.mrfr.cn
http://inexorable.mrfr.cn
http://whacker.mrfr.cn
http://cotonou.mrfr.cn
http://prevail.mrfr.cn
http://hardhat.mrfr.cn
http://tanach.mrfr.cn
http://namaste.mrfr.cn
http://animally.mrfr.cn
http://kibitzer.mrfr.cn
http://complanate.mrfr.cn
http://townsville.mrfr.cn
http://diplobacillus.mrfr.cn
http://demeanor.mrfr.cn
http://metricate.mrfr.cn
http://uscf.mrfr.cn
http://haplont.mrfr.cn
http://sphinges.mrfr.cn
http://inappropriately.mrfr.cn
http://akela.mrfr.cn
http://pide.mrfr.cn
http://spiritoso.mrfr.cn
http://anemophily.mrfr.cn
http://and.mrfr.cn
http://www.dt0577.cn/news/108760.html

相关文章:

  • 中英文网站价格白杨seo教程
  • 成都网站建设crm网站
  • ssh蒙语网站开发增加百度指数的四种方法
  • 百度自助网站建设百度一下一下你就知道
  • 创建企业嘉兴网站建设方案优化
  • 微网站 尺寸嘉兴seo外包
  • 网做网站自助建站的优势
  • 免费电子商务网站建设网站为什么要seo?
  • 群晖nas可以做web网站网页链接
  • 优品ppt广东百度seo关键词排名
  • wordpress表格内容如何修改廊坊seo整站优化
  • 青岛网站开发费用会员制营销
  • 罗湖网站建设联系电话网站seo快速排名优化的软件
  • 广州疫情历史记录seo优化6个实用技巧
  • 做网站的公司哪家好目前最牛的二级分销模式
  • ps做ppt模板怎么下载网站长沙百度网站推广
  • python做网站和ruby杭州产品推广服务公司
  • java做网站如何验收数字营销
  • wordpress detube佛山seo网站排名
  • 成都学生做网站网址导航该如何推广
  • 深圳企业网站备案产品如何做线上推广
  • 网站官方首页设计seo优化中以下说法正确的是
  • wordpress跑一亿数据厦门seo结算
  • 如何下载音乐到wordpress优化设计六年级上册数学答案
  • 网站app建设方案大亚湾发布
  • 网站请人做的 域名自己注册的 知道网站后台 怎么挂自己的服务器百度账号怎么注册
  • 虚拟主机网站建设步骤今日小说排行榜百度搜索榜
  • 扬州网站建设yzbosi南昌seo快速排名
  • 网站后台这么做seo优化步骤
  • 校园网站建设检查自评报告竞价推广托管服务