J2EE模式

embedded/2024/9/22 11:09:28/

系列文章目录

J2EE模式特别关注表示层,这些模式是由 Sun Java Center 鉴定的,
包括:

1、 MVC模式(MVCPattern);
2、 业务代表模式(BusinessDelegatePattern);
3、 组合实体模式(CompositeEntityPattern);
4、 数据访问对象模式(DataAccessObjectPattern);
5、 前端控制器模式(FrontControllerPattern);
6、 拦截过滤器模式(InterceptingFilterPattern);
7、 服务定位器模式(ServiceLocatorPattern);
8、 传输对象模式(TransferObjectPattern);

J2EE模式

  • 系列文章目录
  • MVC 模式
  • 业务代表模式(Business Delegate Pattern)
  • 组合实体模式 (Composite Entity Pattern)
  • 数据访问对象模式 ( Data Access Object )
  • 前端控制器模式(Front Controller Pattern)
  • 拦截过滤器模式 ( Intercepting Filter )
  • 服务定位器模式 (Service Locator Pattern)
  • 传输对象模式 ( Transfer Object Pattern )

MVC 模式

MVC模式代表 Model-View-Controller(模型-视图-控制器) 模式

MVC模式用于应用程序的分层开发

java">Model(模型) - 模型代表一个存取数据的对象或 JAVA POJO 它也可以带有逻辑,在数据变化时更新控制器
View(视图) - 视图代表模型包含的数据的可视化
Controller(控制器) - 控制器作用于模型和视图上。它控制数据流向模型对象,并在数据变化时更新视图。它使视图与模型分离开

实现
1、 定义一个作为模型的Student对象;
2、 StudentView是一个把学生详细信息输出到控制台的视图类;
3、 StudentController是负责存储数据到Student对象中的控制器类,并相应地更新视图StudentView;
4、 最后类MVCPatternDemo使用StudentController来演示MVC模式的用法;

范例

  1. 定义模型
    Student.java
java">public class Student {private String rollNo;private String name;public String getRollNo() {return rollNo;}public void setRollNo(String rollNo) {this.rollNo = rollNo;}public String getName() {return name;}public void setName(String name) {this.name = name;}
}
  1. 定义视图
    StudentView.java
java">public class StudentView {public void printStudentDetails(String studentName, String studentRollNo){System.out.println("Student: ");System.out.println("Name: " + studentName);System.out.println("Roll No: " + studentRollNo);}
}
  1. 定义控制器
    StudentController.java
java">public class StudentController {private Student model;private StudentView view;public StudentController(Student model, StudentView view){this.model = model;this.view = view;}public void setStudentName(String name){model.setName(name);      }public String getStudentName(){return model.getName();       }public void setStudentRollNo(String rollNo){model.setRollNo(rollNo);      }public String getStudentRollNo(){return model.getRollNo();     }public void updateView(){                view.printStudentDetails(model.getName(), model.getRollNo());}    
}
  1. 使用 StudentController 方法来演示 MVC 设计模式的用法
    MVCPatternDemo.java
java">public class MVCPatternDemo {public static void main(String[] args) {//从数据可获取学生记录Student model  = retriveStudentFromDatabase();//创建一个视图:把学生详细信息输出到控制台StudentView view = new StudentView();StudentController controller = new StudentController(model, view);controller.updateView();//更新模型数据controller.setStudentName("John");controller.updateView();}private static Student retriveStudentFromDatabase(){Student student = new Student();student.setName("Robert");student.setRollNo("10");return student;}
}

编译运行以上 Java 范例,输出结果如下

java">Student: 
Name: Robert
Roll No: 10
Student: 
Name: John
Roll No: 10

业务代表模式(Business Delegate Pattern)

业务代表模式(Business Delegate Pattern)用于对表示层和业务层解耦

业务代表模式用来减少通信或对表示层代码中的业务层代码的远程查询功能

在业务层中我们有以下实体:

java">客户端(Client- 表示层代码可以是 JSP、servlet 或 UI java 代码
业务代表(Business Delegate- 一个为客户端实体提供的入口类,它提供了对业务服务方法的访问
查询服务(LookUp Service- 查找服务对象负责获取相关的业务实现,并提供业务对象对业务代表对象的访问
业务服务(Business Service- 业务服务接口。实现了该业务服务的实体类,提供了实际的业务实现逻辑

实现
1、 创建Client、BusinessDelegate、BusinessService、LookUpService、JMSService和EJBService来表示业务代表模式中的各种实体;
2、 定义类BusinessDelegatePatternDemo使用BusinessDelegate和Client来演示业务代表模式的用法;

范例

  1. 创建 BusinessService 接口
    BusinessService.java
java">public interface BusinessService {public void doProcessing();
}
  1. 创建实体服务类
    EJBService.java
java">public class EJBService implements BusinessService {@Overridepublic void doProcessing() {System.out.println("Processing task by invoking EJB Service");}
}

JMSService.java

java">public class JMSService implements BusinessService {@Overridepublic void doProcessing() {System.out.println("Processing task by invoking JMS Service");}
}
  1. 创建业务查询服务
    BusinessLookUp.java
java">public class BusinessLookUp {public BusinessService getBusinessService(String serviceType){if(serviceType.equalsIgnoreCase("EJB")){return new EJBService();}else {return new JMSService();}}
}
  1. 创建业务代表
    BusinessDelegate.java
java">public class BusinessDelegate {private BusinessLookUp lookupService = new BusinessLookUp();private BusinessService businessService;private String serviceType;public void setServiceType(String serviceType){this.serviceType = serviceType;}public void doTask(){businessService = lookupService.getBusinessService(serviceType);businessService.doProcessing();       }
}
  1. 创建客户端
    Client.java
java">public class Client {BusinessDelegate businessService;public Client(BusinessDelegate businessService){this.businessService  = businessService;}public void doTask(){        businessService.doTask();}
}
  1. 使用 BusinessDelegate 和 Client 类来演示业务代表模式
    BusinessDelegatePatternDemo.java
java">public class BusinessDelegatePatternDemo {public static void main(String[] args) {BusinessDelegate businessDelegate = new BusinessDelegate();businessDelegate.setServiceType("EJB");Client client = new Client(businessDelegate);client.doTask();businessDelegate.setServiceType("JMS");client.doTask();}
}

编译运行以上 Java 范例,输出结果如下

java">Processing task by invoking EJB Service
Processing task by invoking JMS Service

组合实体模式 (Composite Entity Pattern)

组合实体模式(Composite Entity Pattern)用在 EJB 持久化机制中

一个组合实体是一个 EJB 实体 bean,代表了对象的图解

当更新一个组合实体时,内部依赖对象 beans 会自动更新,因为它们是由 EJB 实体 bean 管理的

以下是组合实体 bean 的参与者:

java">组合实体(Composite Entity- 它是主要的实体 bean。它可以是粗粒的,或者可以包含一个粗粒度对象,用于持续生命周期
粗粒度对象(Coarse-Grained Object- 该对象包含依赖对象。它有自己的生命周期,也能管理依赖对象的生命周期
依赖对象(Dependent Object- 依赖对象是一个持续生命周期依赖于粗粒度对象的对象
策略(Strategies- 策略表示如何实现组合实体

实现
1、 定义作为组合实体的CompositeEntity对象;
2、 定义CoarseGrainedObject是一个包含依赖对象的类;
3、 定义类CompositeEntityPatternDemo使用Client类来演示组合实体模式的用法;

范例

  1. 创建依赖对象
    DependentObject1.java
java">public class DependentObject1 {private String data;public void setData(String data){this.data = data; } public String getData(){return data;}
}

DependentObject2.java

java">public class DependentObject2 {private String data;public void setData(String data){this.data = data; } public String getData(){return data;}
}
  1. 创建粗粒度对象
    CoarseGrainedObject.java
java">public class CoarseGrainedObject {DependentObject1 do1 = new DependentObject1();DependentObject2 do2 = new DependentObject2();public void setData(String data1, String data2){do1.setData(data1);do2.setData(data2);}public String[] getData(){return new String[] {do1.getData(),do2.getData()};}
}
  1. 创建组合实体
    CompositeEntity.java
java">public class CompositeEntity {private CoarseGrainedObject cgo = new CoarseGrainedObject();public void setData(String data1, String data2){cgo.setData(data1, data2);}public String[] getData(){return cgo.getData();}
}
  1. 创建使用组合实体的客户端类
    Client.java
java">public class Client {private CompositeEntity compositeEntity = new CompositeEntity();public void printData(){for (int i = 0; i < compositeEntity.getData().length; i++) {System.out.println("Data: " + compositeEntity.getData()[i]);}}public void setData(String data1, String data2){compositeEntity.setData(data1, data2);}
}
  1. 使用 Client 来演示组合实体设计模式的用法
    CompositeEntityPatternDemo.java
java">public class CompositeEntityPatternDemo {public static void main(String[] args) {Client client = new Client();client.setData("Test", "Data");client.printData();client.setData("Second Test", "Data1");client.printData();}
}

编译运行以上 Java 范例,输出结果如下

java">Data: Test
Data: Data
Data: Second Test
Data: Data1

数据访问对象模式 ( Data Access Object )

数据访问对象模式(Data Access Object Pattern)或 DAO 模式用于把低级的数据访问 API 或操作从高级的业务服务中分离出来

数据访问模式涉及到的参与者有:

java">数据访问对象接口(Data Access Object Interface- 该接口定义了在一个模型对象上要执行的标准操作
数据访问对象实体类(Data Access Object concrete class- 该类实现了上述的接口。该类负责从数据源获取数据,数据源可以是数据库,也可以是 xml,或者是其他的存储机制
模型对象/数值对象(Model Object/Value Object- 该对象是简单的 POJO,包含了 get/set 方法来存储通过使用 DAO 类检索到的数据

实现
1、 创建一个作为模型对象或数值对象的Student对象;
2、 定义StudentDao作为数据访问对象接口;
3、 定义StudentDaoImpl实现了数据访问对象接口的实体类;
4、 定义DaoPatternDemo使用StudentDao来演示数据访问对象模式的用法;

范例

  1. 创建数值对象
    Student.java
java">public class Student {private String name;private int rollNo;Student(String name, int rollNo){this.name = name;this.rollNo = rollNo;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getRollNo() {return rollNo;}public void setRollNo(int rollNo) {this.rollNo = rollNo;}
}
  1. 创建数据访问对象接口
    StudentDao.java
java">public interface StudentDao {public List<Student> getAllStudents();public Student getStudent(int rollNo);public void updateStudent(Student student);public void deleteStudent(Student student);
}
  1. 创建实现了上述接口的实体类
    StudentDaoImpl.java
java">public class StudentDaoImpl implements StudentDao {//列表是当作一个数据库List<Student> students;public StudentDaoImpl(){students = new ArrayList<Student>();Student student1 = new Student("Robert",0);Student student2 = new Student("John",1);students.add(student1);students.add(student2);       }@Overridepublic void deleteStudent(Student student) {students.remove(student.getRollNo());System.out.println("Student: Roll No " + student.getRollNo() +", deleted from database");}//从数据库中检索学生名单@Overridepublic List<Student> getAllStudents() {return students;}@Overridepublic Student getStudent(int rollNo) {return students.get(rollNo);}@Overridepublic void updateStudent(Student student) {students.get(student.getRollNo()).setName(student.getName());System.out.println("Student: Roll No " + student.getRollNo() +", updated in the database");}
}
  1. 使用 StudentDao 来演示数据访问对象模式的用法
    CompositeEntityPatternDemo.java
java">public class DaoPatternDemo {public static void main(String[] args) {StudentDao studentDao = new StudentDaoImpl();//输出所有的学生for (Student student : studentDao.getAllStudents()) {System.out.println("Student: [RollNo : "+student.getRollNo()+", Name : "+student.getName()+" ]");}//更新学生Student student =studentDao.getAllStudents().get(0);student.setName("Michael");studentDao.updateStudent(student);//获取学生studentDao.getStudent(0);System.out.println("Student: [RollNo : "+student.getRollNo()+", Name : "+student.getName()+" ]");      }
}

编译运行以上范例,输出结果如下

java">Student: [RollNo : 0, Name : Robert ]
Student: [RollNo : 1, Name : John ]
Student: Roll No 0, updated in the database
Student: [RollNo : 0, Name : Michael ]

前端控制器模式(Front Controller Pattern)

前端控制器模式(Front Controller Pattern)是用来提供一个集中的请求处理机制,所有的请求都将由一个单一的处理程序处理

该处理程序可以做认证/授权/记录日志,或者跟踪请求,然后把请求传给相应的处理程序

前端控制器模式涉及以下实体

java">前端控制器(Front Controller- 处理应用程序所有类型请求的单个处理程序,应用程序可以是基于 web 的应用程序,也可以是基于桌面的应用程序。
调度器(Dispatcher- 前端控制器可能使用一个调度器对象来调度请求到相应的具体处理程序。
视图(View- 视图是为请求而创建的对象。

实现
1、 定义类FrontController、Dispatcher分别当作前端控制器和调度器;
2、 定义类HomeView和StudentView表示作为前端控制器接收到的请求而创建的视图;
3、 定义类FrontControllerPatternDemo使用FrontController演示前端控制器设计模式;

范例

  1. 创建视图
    HomeView.java
java">public class HomeView {public void show(){System.out.println("Displaying Home Page");}
}

StudentView.java

java">public class StudentView {public void show(){System.out.println("Displaying Student Page");}
}
  1. 创建调度器 Dispatcher
    Dispatcher.java
java">public class Dispatcher {private StudentView studentView;private HomeView homeView;public Dispatcher(){studentView = new StudentView();homeView = new HomeView();}public void dispatch(String request){if(request.equalsIgnoreCase("STUDENT")){studentView.show();}else{homeView.show();} }
}
  1. 创建前端控制器 FrontController
    Context.java
java">public class FrontController {private Dispatcher dispatcher;public FrontController(){dispatcher = new Dispatcher();}private boolean isAuthenticUser(){System.out.println("User is authenticated successfully.");return true;}private void trackRequest(String request){System.out.println("Page requested: " + request);}public void dispatchRequest(String request){//记录每一个请求trackRequest(request);//对用户进行身份验证if(isAuthenticUser()){dispatcher.dispatch(request);} }
}
  1. 使用 FrontController 来演示前端控制器设计模式
    FrontControllerPatternDemo.java
java">public class FrontControllerPatternDemo {public static void main(String[] args) {FrontController frontController = new FrontController();frontController.dispatchRequest("HOME");frontController.dispatchRequest("STUDENT");}
}

编译运行以上 Java 范例,输出结果如下

java">Page requested: HOME
User is authenticated successfully.
Displaying Home Page
Page requested: STUDENT
User is authenticated successfully.
Displaying Student Page

拦截过滤器模式 ( Intercepting Filter )

拦截过滤器模式(Intercepting Filter Pattern)用于对应用程序的请求或响应做一些预处理/后处理

定义过滤器,并在把请求传给实际目标应用程序之前应用在请求上

过滤器可以做认证/授权/记录日志,或者跟踪请求,然后把请求传给相应的处理程序

拦截过滤器模式涉及以下实体:

java">过滤器(Filter- 过滤器在请求处理程序执行请求之前或之后,执行某些任务。
过滤器链(Filter Chain- 过滤器链带有多个过滤器,并在 Target 上按照定义的顺序执行这些过滤器。
Target - Target 对象是请求处理程序。
过滤管理器(Filter Manager- 过滤管理器管理过滤器和过滤器链。
客户端(Client- Client 是向 Target 对象发送请求的对象。

实现
1、 定义类FilterChain、FilterManager、Target、Client作为表示实体的各种对象;
2、 定义类AuthenticationFilter和DebugFilter表示实体过滤器;
3、 定义类InterceptingFilterDemo使用Client来演示拦截过滤器设计模式;

范例

  1. 创建过滤器接口 Filter
    Filter.java
java">public interface Filter {public void execute(String request);
}
  1. 创建实体过滤器
    AuthenticationFilter.java
java">public class AuthenticationFilter implements Filter {public void execute(String request){System.out.println("Authenticating request: " + request);}
}

DebugFilter.java

java">public class DebugFilter implements Filter {public void execute(String request){System.out.println("request log: " + request);}
}
  1. 创建 Target
    Target.java
java">public class Target {public void execute(String request){System.out.println("Executing request: " + request);}
}
  1. 创建过滤器链
    FilterChain.java
java">public class FilterChain {private List<Filter> filters = new ArrayList<Filter>();private Target target;public void addFilter(Filter filter){filters.add(filter);}public void execute(String request){for (Filter filter : filters) {filter.execute(request);}target.execute(request);}public void setTarget(Target target){this.target = target;}
}
  1. 创建过滤管理器
    FilterManager.java
java">public class FilterManager {FilterChain filterChain;public FilterManager(Target target){filterChain = new FilterChain();filterChain.setTarget(target);}public void setFilter(Filter filter){filterChain.addFilter(filter);}public void filterRequest(String request){filterChain.execute(request);}
}
  1. 创建客户端 Client
    Client.java
java">public class Client {FilterManager filterManager;public void setFilterManager(FilterManager filterManager){this.filterManager = filterManager;}public void sendRequest(String request){filterManager.filterRequest(request);}
}
  1. 使用 Client 来演示拦截过滤器设计模式
    FrontControllerPatternDemo.java
java">public class InterceptingFilterDemo {public static void main(String[] args) {FilterManager filterManager = new FilterManager(new Target());filterManager.setFilter(new AuthenticationFilter());filterManager.setFilter(new DebugFilter());Client client = new Client();client.setFilterManager(filterManager);client.sendRequest("HOME");}
}

编译运行以上 Java 范例,输出结果如下

java">Authenticating request: HOME
request log: HOME
Executing request: HOME

服务定位器模式 (Service Locator Pattern)

服务定位器模式(Service Locator Pattern)用于想使用 JNDI 查询定位各种服务的时候

考虑到为某个服务查找 JNDI 的代价很高,服务定位器模式充分利用了缓存技术

在首次请求某个服务时,服务定位器在 JNDI 中查找服务,并缓存该服务对象

当再次请求相同的服务时,服务定位器会在它的缓存中查找,这样可以在很大程度上提高应用程序的性能

以下是这种设计模式的实体

java">服务(Service- 实际处理请求的服务。对这种服务的引用可以在 JNDI 服务器中查找到
Context / 初始的 Context - JNDI Context 带有对要查找的服务的引用
服务定位器(Service Locator- 服务定位器是通过 JNDI 查找和缓存服务来获取服务的单点接触
缓存(Cache- 缓存存储服务的引用,以便复用它们
客户端(Client- Client 是通过 ServiceLocator 调用服务的对象

实现
创建 ServiceLocator 、 InitialContext 、 Cache 、 Service 作为表示实体的各种对象

Service1 和 Service2 表示实体服务

ServiceLocatorPatternDemo ,我们的演示类在这里是作为一个客户端,将使用 ServiceLocator 来演示服务定位器设计模式
范例

  1. 创建服务接口 Service
java">public interface Service
{public String getName();public void execute();
}
  1. 创建实体服务
    Service1
java">public class Service1 implements Service {public void execute(){System.out.println("Executing Service1");}@Overridepublic String getName() {return "Service1";}
}

Service2

java">public class Service2 implements Service {public void execute(){System.out.println("Executing Service2");}@Overridepublic String getName() {return "Service2";}
}
  1. 为 JNDI 查询创建 InitialContext
java">public class InitialContext
{public Object lookup(String jndiName){if(jndiName.equalsIgnoreCase("SERVICE1")){System.out.println("Looking up and creating a new Service1 object");return new Service1();}else if (jndiName.equalsIgnoreCase("SERVICE2")){System.out.println("Looking up and creating a new Service2 object");return new Service2();}return null;      }
}
  1. 创建缓存 Cache
java">public class Cache {private List<Service> services;public Cache(){services = new ArrayList<Service>();}public Service getService(String serviceName){for (Service service : services) {if(service.getName().equalsIgnoreCase(serviceName)){System.out.println("Returning cached  "+serviceName+" object");return service;}}return null;}public void addService(Service newService){boolean exists = false;for (Service service : services) {if(service.getName().equalsIgnoreCase(newService.getName())){exists = true;}}if(!exists){services.add(newService);}}
}
  1. 创建服务定位器 ServiceLocator
java">public class ServiceLocator {private static Cache cache;static {cache = new Cache();      }public static Service getService(String jndiName){Service service = cache.getService(jndiName);if(service != null){return service;}InitialContext context = new InitialContext();Service service1 = (Service)context.lookup(jndiName);cache.addService(service1);return service1;}
}
  1. 使用 ServiceLocator 来演示服务定位器设计模式
java">public class ServiceLocatorPatternDemo
{public static void main(String[] args) {Service service = ServiceLocator.getService("Service1");service.execute();service = ServiceLocator.getService("Service2");service.execute();service = ServiceLocator.getService("Service1");service.execute();service = ServiceLocator.getService("Service2");service.execute();        }
}

编译运行以上 Java 范例,输出结果如下

java">Looking up and creating a new Service1 object
Executing Service1
Looking up and creating a new Service2 object
Executing Service2
Returning cached  Service1 object
Executing Service1
Returning cached  Service2 object
Executing Service2

传输对象模式 ( Transfer Object Pattern )

传输对象模式(Transfer Object Pattern)用于从客户端向服务器一次性传递带有多个属性的数据

传输对象也被称为数值对象,没有任何行为

传输对象是一个具有 getter/setter 方法的简单的 POJO 类,它是可序列化的,所以它可以通过网络传输

服务器端的业务类通常从数据库读取数据,然后填充 POJO,并把它发送到客户端或按值传递它

对于客户端,传输对象是只读的

客户端可以创建自己的传输对象,并把它传递给服务器,以便一次性更新数据库中的数值

以下是这种设计模式的实体:

java">业务对象(Business Object- 为传输对象填充数据的业务服务
传输对象(Transfer Object- 简单的 POJO,只有设置/获取属性的方法
客户端(Client- 客户端可以发送请求或者发送传输对象到业务对象

实现
创建一个作为业务对象的 StudentBO 和作为传输对象的 StudentVO ,它们都代表了我们的实体

TransferObjectPatternDemo ,我们的演示类在这里是作为一个客户端,将使用 StudentBO 和 Student 来演示传输对象设计模式
范例

  1. 创建传输对象 StudentVO
java">public class StudentVO
{private String name;private int rollNo;StudentVO(String name, int rollNo){this.name = name;this.rollNo = rollNo;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getRollNo() {return rollNo;}public void setRollNo(int rollNo) {this.rollNo = rollNo;}
}
  1. 创建业务对象 StudentBO
java">public class StudentBO {//列表是当作一个数据库List<StudentVO> students;public StudentBO(){students = new ArrayList<StudentVO>();StudentVO student1 = new StudentVO("Robert",0);StudentVO student2 = new StudentVO("John",1);students.add(student1);students.add(student2);       }public void deleteStudent(StudentVO student) {students.remove(student.getRollNo());System.out.println("Student: Roll No " + student.getRollNo() +", deleted from database");}//从数据库中检索学生名单public List<StudentVO> getAllStudents() {return students;}public StudentVO getStudent(int rollNo) {return students.get(rollNo);}public void updateStudent(StudentVO student) {students.get(student.getRollNo()).setName(student.getName());System.out.println("Student: Roll No " + student.getRollNo() +", updated in the database");}
}
  1. 使用 StudentBO 来演示传输对象设计模式
java">public class TransferObjectPatternDemo {public static void main(String[] args) {StudentBO studentBusinessObject = new StudentBO();//输出所有的学生for (StudentVO student : studentBusinessObject.getAllStudents()) {System.out.println("Student: [RollNo : "+student.getRollNo()+", Name : "+student.getName()+" ]");}//更新学生StudentVO student =studentBusinessObject.getAllStudents().get(0);student.setName("Michael");studentBusinessObject.updateStudent(student);//获取学生studentBusinessObject.getStudent(0);System.out.println("Student: [RollNo : "+student.getRollNo()+", Name : "+student.getName()+" ]");}
}

编译运行以上 Java 范例,输出结果如下

java">Student: [RollNo : 0, Name : Robert ]
Student: [RollNo : 1, Name : John ]
Student: Roll No 0, updated in the database
Student: [RollNo : 0, Name : Michael ]

http://www.ppmy.cn/embedded/29836.html

相关文章

启程Python机器学习之旅:从JupyterLab到神经网络初探

引言 在数据科学和人工智能的浪潮中&#xff0c;Python已经成为最受欢迎的编程语言之一。其简洁的语法和强大的库支持&#xff0c;使得从科研到商业的各个领域都能见到Python的身影。今天&#xff0c;我们将通过JupyterLab——一个交互式的开发环境&#xff0c;开始我们的Pyth…

selenium自动化,Chrome 启动参数

常用参数 常用参数请参考下表。 序号参数说明1--allow-outdated-plugins不停用过期的插件。2--allow-running-insecure-content默认情况下&#xff0c;https 页面不允许从 http 链接引用 javascript/css/plug-ins。添加这一参数会放行这些内容。3--allow-scripting-gallery允许…

解码Starknet Verifier:深入逆向工程之旅

1. 引言 Sandstorm为&#xff1a; 能提交独立proof给StarkWare的Ethereum Verifier&#xff0c;的首个开源的STARK prover。 开源代码见&#xff1a; https://github.com/andrewmilson/sandstorm&#xff08;Rust&#xff09; L2Beat 提供了以太坊上Starknet的合约架构图&…

使用 ORPO 微调 Llama 3

原文地址&#xff1a;https://towardsdatascience.com/fine-tune-llama-3-with-orpo-56cfab2f9ada 更便宜、更快的统一微调技术 2024 年 4 月 19 日 ORPO 是一种新的令人兴奋的微调技术&#xff0c;它将传统的监督微调和偏好校准阶段合并为一个过程。这减少了训练所需的计算…

web server apache tomcat11-30-The Tomcat JDBC Connection Pool

前言 整理这个官方翻译的系列&#xff0c;原因是网上大部分的 tomcat 版本比较旧&#xff0c;此版本为 v11 最新的版本。 开源项目 从零手写实现 tomcat minicat 别称【嗅虎】心有猛虎&#xff0c;轻嗅蔷薇。 系列文章 web server apache tomcat11-01-官方文档入门介绍 web…

Vue3+Nuxt3 从0到1搭建官网项目(SEO搜索、中英文切换、图片懒加载)

Vue2Nuxt2 从 0 到1 搭建官网~ Vue3Nuxt3 从0到1搭建官网项目 安装 Nuxt3&#xff0c;创建项目初始化的 package.json项目结构初始化项目pages 文件下创建index.vue引入sass修改 app.vue 文件查看效果 配置公共的css、metaassets下的cssreset.scss 重置文件common.scss 配置nux…

python关键字(pass)

5、pass 在Python编程中&#xff0c;pass 是一个特殊的空操作关键字&#xff0c;用于表示一个语句的存在&#xff0c;但它不执行任何操作。pass 关键字在语法上需要一条语句但又不希望有任何实际操作的场景下非常有用。无论是Python的基础学习者还是经验丰富的开发者&#xff…

JAVA面试专题-框架篇(Spring+Mybatis)

Spring Spring框架中的单例bean是线程安全的吗&#xff1f; bean上面可以加入注解Scope&#xff0c;如果是singleton&#xff08;默认&#xff09;&#xff0c;意味着bean在每个spring IOC容器中只有一个实例&#xff1b;如果是prototype&#xff0c;说明一个bean定义可以有多…