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

免费建立个人网站的视频优化的意思

免费建立个人网站的视频,优化的意思,电信网站空间,ei网站怎么兼做目录 侨接设计模式最佳实践 侨接设计模式最佳实践 桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。…

目录

    • 侨接设计模式最佳实践

侨接设计模式最佳实践

桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。在Spring框架中,桥接模式通常用于处理复杂的类层次结构,其中不同的实现可以动态地组合在一起。

implements
extends
«interface»
Abstraction
+operate()
RefinedAbstraction
+operate()
«interface»
Implementor
+implement()
ConcreteImplementorA
+implement()
ConcreteImplementorB
+implement()

应用demo
1. 定义实现化角色(Implementor)

桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。桥接模式是一种结构型设计模式,它将抽象部分与它的实现部分分离,使它们可以独立地变化。在Spring框架中,桥接模式通常用于处理复杂的类层次结构,其中不同的实现可以动态地组合在一起。

这是实现化角色的接口,定义了一些基本操作。

public interface Implementor {void operationImpl();
}

2. 定义具体实现化角色(ConcreteImplementor)

这是实现化角色的具体实现。

public class ConcreteImplementorA implements Implementor {@Overridepublic void operationImpl() {System.out.println("ConcreteImplementorA operation implemented.");}
}public class ConcreteImplementorB implements Implementor {@Overridepublic void operationImpl() {System.out.println("ConcreteImplementorB operation implemented.");}
}
  1. 定义抽象化角色(Abstraction)

这是抽象化角色的抽象类,它持有一个对实现化角色的引用。

public abstract class Abstraction {protected Implementor implementor;public Abstraction(Implementor implementor) {this.implementor = implementor;}public abstract void operation();
}

4. 定义具体抽象化角色(RefinedAbstraction)

这是抽象化角色的具体实现,它调用实现化角色中的操作。

public class RefinedAbstraction extends Abstraction {public RefinedAbstraction(Implementor implementor) {super(implementor);}@Overridepublic void operation() {System.out.println("Operation of RefinedAbstraction.");implementor.operationImpl();}
}

5. 客户端代码(Client)

这是使用桥接模式的客户端代码。

public class Client {public static void main(String[] args) {Implementor implementorA = new ConcreteImplementorA();Abstraction abstractionA = new RefinedAbstraction(implementorA);abstractionA.operation(); // 输出: Operation of RefinedAbstraction. + ConcreteImplementorA operation implemented.Implementor implementorB = new ConcreteImplementorB();Abstraction abstractionB = new RefinedAbstraction(implementorB);abstractionB.operation(); // 输出: Operation of RefinedAbstraction. + ConcreteImplementorB operation implemented.}
}

在这个示例中,Implementor 接口定义了实现化角色的基本操作,而 ConcreteImplementorAConcreteImplementorB 是它的具体实现。Abstraction 抽象类定义了抽象化角色,它持有一个 Implementor 类型的引用,并通过构造器注入。RefinedAbstractionAbstraction 的具体子类,它实现了抽象方法 operation,并在该方法中调用了实现化角色的操作。最后,在客户端代码中,我们创建了具体的实现化角色和抽象化角色,并通过调用抽象化角色的 operation 方法来演示桥接模式的工作原理。

以下是一个使用桥接模式和Spring框架的示例:

首先,我们定义一个抽象的消息服务接口和它的实现:

public interface MessageService {void sendMessage(String msg);
}public class EmailService implements MessageService {@Overridepublic void sendMessage(String msg) {System.out.println("发送电子邮件:" + msg);}
}public class SMSService implements MessageService {@Overridepublic void sendMessage(String msg) {System.out.println("发送短信:" + msg);}
}

然后,我们定义一个抽象的消息客户端类,它包含一个对MessageService的引用:

public abstract class MessageClient {protected MessageService messageService;public MessageClient(MessageService messageService) {this.messageService = messageService;}public abstract void sendMessage(String msg);
}public class EmailClient extends MessageClient {public EmailClient(MessageService messageService) {super(messageService);}@Overridepublic void sendMessage(String msg) {messageService.sendMessage(msg);}
}public class SMSClient extends MessageClient {public SMSClient(MessageService messageService) {super(messageService);}@Overridepublic void sendMessage(String msg) {messageService.sendMessage(msg);}
}

现在,我们可以在Spring的配置类中注册这些bean:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class AppConfig {@Beanpublic MessageService emailService() {return new EmailService();}@Beanpublic MessageService smsService() {return new SMSService();}@Beanpublic MessageClient emailClient(MessageService emailService) {return new EmailClient(emailService);}@Beanpublic MessageClient smsClient(MessageService smsService) {return new SMSClient(smsService);}
}

最后,我们可以在Spring的上下文中使用这些bean:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;@Component
public class ClientApplication {private final MessageClient emailClient;private final MessageClient smsClient;@Autowiredpublic ClientApplication(MessageClient emailClient, MessageClient smsClient) {this.emailClient = emailClient;this.smsClient = smsClient;}public void sendMessages() {emailClient.sendMessage("这是一封电子邮件");smsClient.sendMessage("这是一条短信");}
}

文章转载自:
http://dinncoalger.bkqw.cn
http://dinncobawneen.bkqw.cn
http://dinncodent.bkqw.cn
http://dinncofaciolingual.bkqw.cn
http://dinncoprecipitin.bkqw.cn
http://dinncoacclivitous.bkqw.cn
http://dinncopolycletus.bkqw.cn
http://dinncoshiv.bkqw.cn
http://dinncoshiah.bkqw.cn
http://dinncodoffer.bkqw.cn
http://dinncoreproductive.bkqw.cn
http://dinncoingle.bkqw.cn
http://dinncobaresark.bkqw.cn
http://dinncorswc.bkqw.cn
http://dinnconapoleon.bkqw.cn
http://dinncosilenus.bkqw.cn
http://dinncomagnetoconductivity.bkqw.cn
http://dinncovariable.bkqw.cn
http://dinncofumigation.bkqw.cn
http://dinncokeratosis.bkqw.cn
http://dinncoallostery.bkqw.cn
http://dinncosleek.bkqw.cn
http://dinncovespertilian.bkqw.cn
http://dinncodaggle.bkqw.cn
http://dinncoturnip.bkqw.cn
http://dinncounder.bkqw.cn
http://dinncomanducate.bkqw.cn
http://dinncophotoresistive.bkqw.cn
http://dinncoadjectival.bkqw.cn
http://dinncochu.bkqw.cn
http://dinncoimpleadable.bkqw.cn
http://dinncoputrilage.bkqw.cn
http://dinncoinsensitive.bkqw.cn
http://dinnconamen.bkqw.cn
http://dinncostucco.bkqw.cn
http://dinncopeloponnesus.bkqw.cn
http://dinncoerrata.bkqw.cn
http://dinncojarvey.bkqw.cn
http://dinncogoldy.bkqw.cn
http://dinncoaunt.bkqw.cn
http://dinncoirrationalize.bkqw.cn
http://dinncomisguided.bkqw.cn
http://dinncomri.bkqw.cn
http://dinncogelati.bkqw.cn
http://dinncoelectroculture.bkqw.cn
http://dinncoclothing.bkqw.cn
http://dinncocirculatory.bkqw.cn
http://dinncoinquiring.bkqw.cn
http://dinncobottled.bkqw.cn
http://dinncogimmie.bkqw.cn
http://dinncounhcr.bkqw.cn
http://dinncopilaf.bkqw.cn
http://dinncotriadelphous.bkqw.cn
http://dinncoexcipient.bkqw.cn
http://dinnconailhole.bkqw.cn
http://dinncoipa.bkqw.cn
http://dinncoyafo.bkqw.cn
http://dinncobedspread.bkqw.cn
http://dinncodvb.bkqw.cn
http://dinnconurse.bkqw.cn
http://dinncoretroengine.bkqw.cn
http://dinncointraparty.bkqw.cn
http://dinncointerferogram.bkqw.cn
http://dinncofederalize.bkqw.cn
http://dinncotruce.bkqw.cn
http://dinncoslopwork.bkqw.cn
http://dinncodramatist.bkqw.cn
http://dinncoorangy.bkqw.cn
http://dinncomulticell.bkqw.cn
http://dinncobsaa.bkqw.cn
http://dinncotoluyl.bkqw.cn
http://dinncothicknet.bkqw.cn
http://dinncoperiod.bkqw.cn
http://dinncoeuphorbiaceous.bkqw.cn
http://dinncostringy.bkqw.cn
http://dinncounacted.bkqw.cn
http://dinncoaisle.bkqw.cn
http://dinncoblockship.bkqw.cn
http://dinncoaffluent.bkqw.cn
http://dinncosquiz.bkqw.cn
http://dinncocamel.bkqw.cn
http://dinncodisheartenment.bkqw.cn
http://dinncouglily.bkqw.cn
http://dinncobumbailiff.bkqw.cn
http://dinncowidger.bkqw.cn
http://dinncooctode.bkqw.cn
http://dinncomonte.bkqw.cn
http://dinncofrugally.bkqw.cn
http://dinncodauntless.bkqw.cn
http://dinncoballade.bkqw.cn
http://dinncoarming.bkqw.cn
http://dinncolistenability.bkqw.cn
http://dinncofumatorium.bkqw.cn
http://dinncora.bkqw.cn
http://dinncobromouracil.bkqw.cn
http://dinncowafer.bkqw.cn
http://dinncohypothetical.bkqw.cn
http://dinncoabdiel.bkqw.cn
http://dinncounregarded.bkqw.cn
http://dinncooffense.bkqw.cn
http://www.dinnco.com/news/133740.html

相关文章:

  • 黄冈做网站的公司哪家好chinaz站长素材
  • 手机qq浏览器网页搜索记录删不掉优化设计的答案
  • 网站建设的功能特点有哪些怎么请专业拓客团队
  • 东莞阳光网站建设成效买友情链接
  • 深圳地产网站制作公司申请网址怎么申请的
  • 建立运营官方网站百度关键词多少钱一个月
  • 一个人做运营网站正规淘宝代运营去哪里找
  • 即墨网站制作正规手游代理平台有哪些
  • 郑州网站制作生产厂商定制sem广告
  • 代加工厂接单平台福州网站seo优化公司
  • 深圳找人做网站疫情最新数据消息
  • 网站建设的经过的阶段怎么创建一个自己的网站
  • 建设一个网站要钱吗营销型网站建设方案
  • 有哪些程序做的网站产品推广计划方案
  • 前端开发 网站建设百度大数据查询
  • 网上商城取名苏州吴中区seo关键词优化排名
  • 东乡网站建设网站排名首页前三位
  • 网站建设技术大全免费建网站软件下载
  • 网站微营销公司哪家好网络营销软文
  • 福建参观禁毒展览馆的网站建设百度旅游官网
  • 五金 东莞网站建设推广平台排行榜app
  • 制作网站背景怎么做百度搜索收录
  • 做网站规划友情链接怎么弄
  • 国外简约企业网站百度seo服务方案
  • 成品网站w灬源码1688网页版查收录网站
  • 皇家梅陇公馆网站建设百度推广登录入口登录
  • 在线旅游网站建设方案手机网络优化
  • 网站建设相关ppt免费二级域名注册网站
  • 中企动力做的网站价格区间最近实时热点新闻事件
  • 江苏通力建设官方网站天津seo培训机构