Application server WebSocket processing method and device

By storing WebSocket annotation classes and creating WebSocket engine registrations, the problem of repeated addition of message processors caused by mixed use of WebSocket components is solved, standardized development is achieved, server compatibility and ease of operation and maintenance are improved, and system efficiency is improved.

CN120610757APending Publication Date: 2025-09-09SHANDONG CVICSE MIDDLEWARE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510768031.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-09

AI Technical Summary

Technical Problem

Mixing WebSocket implementations leads to duplicate message processor addition errors, increasing development complexity and operation and maintenance difficulty, especially in multi-version and multi-application scenarios, where maintenance and debugging costs are high.

Method used

Use collection objects to store classes annotated with WebSocket annotations, create a WebSocket engine and register each class. After deployment is complete, add a message handler to the WebSocket session class to ensure successful operation.

Benefits of technology

This solves the problem of duplicate addition of message processors when WebSocket components mix annotations and inherit endpoint classes, improves server compatibility and availability, simplifies operation and maintenance, and improves system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120610757A_ABST
    Figure CN120610757A_ABST
Patent Text Reader

Abstract

The invention provides an application server WebSocket processing method and device, and relates to the technical field of Web development. Obtaining a to-be-deployed application, wherein the to-be-deployed application comprises a mixed annotation and a WebSocket component inheriting the endpoint class implementation mode; deploying the to-be-deployed application into an application server, and storing a plurality of classes marked with WebSocket annotations in the to-be-deployed application through a set object; creating a WebSocket engine to register each class, and determining that the deployment of the to-be-deployed application is completed; and accessing the application, and if the connection opening method of the application class is executed and the message processor is successfully added in the WebSocket session class, determining that the application runs normally. The problem that the message processor is repeatedly added when the Web application mixes annotations and inherits endpoint class implementation modes is solved, development according to standard specifications is facilitated, and implementation mode conflicts are avoided; the compatibility and availability of the server are improved, and the system efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Web development, and in particular to a method and device for processing WebSocket of an application server. Background Art

[0002] With the rapid development of web applications, WebSocket, a full-duplex communication protocol based on TCP, has been widely used in fields such as real-time chat, gaming, and financial monitoring, providing efficient, low-latency communication. However, differences in the implementation of WebSocket components among different vendors have led developers to adopt a variety of implementation methods, including inheriting from endpoint classes or using annotations. Because WebSocket implementations are not yet standardized, mixing inherited endpoint classes and annotations can cause potential problems, especially in message handler management, which can lead to "message handler already added" errors, affecting application operation.

[0003] Typically, message handlers for WebSocket session classes can only be added by inheriting from endpoint classes. However, when annotations and inherited endpoint classes are mixed, the application server first parses and registers the annotated endpoint class. Then, when adding a message handler to the session, attempting to add it again will trigger a "message handler already added" error, causing the application to malfunction.

[0004] The downside of this approach is that developers must completely rewrite their applications to inherit from endpoint classes, which not only increases development complexity but may also require refactoring existing code. Forcing a unified implementation also increases operational complexity, especially given the compatibility requirements of different environments and versions. This significantly increases maintenance and debugging costs, especially in multi-version and multi-application scenarios. Summary of the Invention

[0005] In view of this, an embodiment of the present invention provides a method and apparatus for processing WebSocket of an application server to solve the problems of difficult application development, difficult operation and maintenance, and high cost.

[0006] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0007] A first aspect of the present invention discloses a method for processing a WebSocket in an application server, the method comprising:

[0008] Obtaining an application to be deployed, the application to be deployed including a WebSocket component, the WebSocket component using a mix of annotations and inherited endpoint class implementations, and adding a message handler via a WebSocket session class in a connection open method of an application class of the WebSocket component;

[0009] Deploy the application to be deployed to an application server, and store multiple classes in the application to be deployed marked with WebSocket annotations through a collection object;

[0010] Creating a WebSocket engine and registering each of the classes in the collection object, and determining that the deployment of the application to be deployed is complete;

[0011] The deployed application to be deployed is accessed. If the connection opening method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

[0012] Preferably, the step of deploying the application to be deployed to an application server and storing multiple classes in the application to be deployed that are annotated with WebSocket annotations through a collection object includes:

[0013] Deploy the application to be deployed to the application server;

[0014] Scanning the WebSocket annotations in the application to be deployed by the application server;

[0015] Store classes annotated with WebSocket annotations in the collection object.

[0016] Preferably, the step of creating a WebSocket engine and registering each of the classes in the collection object, and determining that the deployment of the application to be deployed is complete, includes:

[0017] Create a WebSocket engine and obtain the collection object;

[0018] Execute the Start method of the WebSocket engine to register each of the classes in the collection object;

[0019] When the registration of each of the classes in the collection object is completed, it is determined that the deployment of the application to be deployed is completed.

[0020] Preferably, executing the Start method of the WebSocket engine to register each of the classes in the collection object includes:

[0021] Execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each of the classes in the collection object;

[0022] The registration method of the WebSocket engine is called to register each of the classes in the collection object.

[0023] Preferably, calling the registration method of the WebSocket engine to register each of the classes in the collection object includes:

[0024] Calling the creation method of the annotation endpoint class through the WebSocket engine to create a corresponding annotation endpoint object for each class;

[0025] Determine the parent class type of each class using a while loop method of a Java Development Kit JDK;

[0026] For each of the classes, if the value of the JDK Boolean type variable corresponding to the parent class type of the class is true, then a new WebSocket endpoint wrapper class object is created based on the new keyword and the class;

[0027] If the value of the JDK Boolean type variable corresponding to the parent class type of the class is false, a new WebSocket endpoint wrapper class object is created based on the new keyword and the annotation endpoint object corresponding to the class;

[0028] After the new WebSocket endpoint wrapper class object is created, it is determined that the class registration is complete.

[0029] Preferably, determining the parent class type of each class by using a while loop method of a Java Development Kit JDK includes:

[0030] By using the while loop method of the Java Development Kit JDK, a JDK Boolean type variable is defined for each of the classes;

[0031] Obtain the parent class type of each class, and determine whether the parent class type is a WebSocket abstract endpoint class;

[0032] If so, set the value of the Boolean type variable of the class to true;

[0033] If not, the value of the Boolean type variable of the class is set to false.

[0034] A second aspect of the present invention discloses a device for processing WebSocket of an application server, the device comprising:

[0035] An acquisition unit is configured to acquire an application to be deployed, wherein the application to be deployed includes a WebSocket component, the WebSocket component uses a mixed annotation and inherited endpoint class implementation, and a message handler is added through a WebSocket session class in a connection opening method of an application class of the WebSocket component;

[0036] A storage unit, configured to deploy the application to be deployed to an application server, and store multiple classes in the application to be deployed marked with WebSocket annotations through a collection object;

[0037] A registration unit, configured to create a WebSocket engine and register each of the classes in the collection object, and determine that deployment of the application to be deployed is complete;

[0038] The access unit is used to access the deployed application to be deployed. If the connection opening method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

[0039] Preferably, the storage unit includes:

[0040] A deployment module, configured to deploy the application to be deployed to an application server;

[0041] A scanning module, configured to scan the WebSocket annotations in the application to be deployed through the application server;

[0042] The storage module is used to store classes annotated with WebSocket annotations into a collection object.

[0043] Preferably, the registration unit includes:

[0044] Create a module for creating a WebSocket engine and obtaining the collection object;

[0045] A registration module, configured to execute the Start method of the WebSocket engine and register each of the classes in the collection object;

[0046] The determination module is configured to determine that the deployment of the application to be deployed is completed when the registration of each of the classes in the collection object is completed.

[0047] Preferably, the registration module includes:

[0048] A traversal submodule, configured to execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each of the classes in the collection object;

[0049] The registration submodule is used to call the registration method of the WebSocket engine to register each of the classes in the collection object.

[0050] A method and device for processing WebSocket in an application server provided based on the above-mentioned embodiment of the present invention relates to the field of Web development technology. Obtain the application to be deployed, which includes a WebSocket component that mixes annotations and inherited endpoint class implementations; deploy the application to be deployed to the application server, and store multiple classes in the application to be deployed that are marked with WebSocket annotations through a collection object; create a WebSocket engine to register each class to determine that the deployment of the application to be deployed is complete; access the application, and if the connection open method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the application is running normally. This solves the problem of repeated addition of message processors when Web applications mix annotations and inherited endpoint class implementations, helps to develop in accordance with standard specifications, and avoids conflicts in implementation methods; improves server compatibility and availability, simplifies operation and maintenance, and improves system efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0052] Figure 1 A flowchart of a method for processing WebSocket in an application server provided by an embodiment of the present invention;

[0053] Figure 2 A flowchart of a registration class based on a WebSocket engine registration method provided by an embodiment of the present invention;

[0054] Figure 3 This is a structural block diagram of a WebSocket processing device for an application server provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0056] In this application, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0057] As we know from the background, message handlers for WebSocket session classes are typically added by inheriting from endpoint classes. However, mixing annotations and inherited endpoint classes can result in "message handler already added" errors, causing application anomalies. This requires developers to use a unified inheritance approach, increasing development complexity and potentially requiring refactoring of existing code. Forcing a unified implementation also increases operational complexity, particularly in multi-version and multi-application scenarios, significantly increasing maintenance and debugging costs.

[0058] Therefore, an embodiment of the present invention provides a method and device for processing WebSockets in an application server. The method comprises obtaining an application to be deployed, wherein the application to be deployed includes a WebSocket component that mixes annotations and inherited endpoint class implementations; deploying the application to be deployed to the application server, storing multiple classes in the application to be deployed that are annotated with WebSocket annotations through a collection object; creating a WebSocket engine to register each class and confirming that the deployment of the application to be deployed is complete; accessing the application, and if the connection open method of the application class is executed and a message handler is successfully added to the WebSocket session class, the application is determined to be operating normally. By optimizing the WebSocket processing mechanism of the application server, the problem of duplicate message handler addition when a Web application mixes annotations and inherited endpoint class implementations is resolved, which helps to develop in accordance with standard specifications and avoid implementation conflicts. The method also improves server compatibility and availability, simplifies operation and maintenance, and enhances system efficiency.

[0059] See also Figure 1 , which shows a flow chart of a method for processing a WebSocket in an application server according to an embodiment of the present invention. This method can be applied to various application server software. The method includes:

[0060] Step S101: Obtain the application to be deployed.

[0061] It is understandable that the application to be deployed includes a WebSocket component.

[0062] It should be noted that the WebSocket component specifically mixes annotation and inherited endpoint class implementation methods (i.e., inherited endpoint class implementation method and annotation implementation method), and in the connection opening method of the WebSocket component application class, a message processor is added through the WebSocket session class.

[0063] In the specific implementation of step S101 , preparation work is performed to obtain the application to be deployed (specifically, a Web application) that needs to be deployed in the application server.

[0064] Step S102: deploy the application to be deployed to the application server, and store multiple classes in the application to be deployed that are annotated with the WebSocket annotation through a collection object.

[0065] In the specific implementation of step S102 , the application to be deployed is deployed to the application server; the application server scans the WebSocket annotations in the application to be deployed; and then the classes annotated with the WebSocket annotations are stored in the collection object.

[0066] As you can see, by scanning the deployed application for WebSocket annotations and storing classes annotated with these annotations in a collection, we can achieve automated registration, flexible management, and loose coupling, improving code maintainability. Centralized management of all WebSocket endpoint classes simplifies registration and lifecycle management, and supports efficient performance optimization. This approach also improves application scalability, facilitates dynamic loading and configuration management, and enables intelligent registration based on conditions. Classes in a collection facilitate debugging, monitoring, and logging, thereby improving system observability and operability.

[0067] Step S103: Create a WebSocket engine and register each class in the collection object to determine whether the deployment of the application to be deployed is complete.

[0068] In the specific implementation of step S103, a WebSocket engine is created, the collection object is passed to the WebSocket engine, and each class in the collection object is registered. When all classes in the collection object are registered, it is determined that the deployment of the application to be deployed is completed.

[0069] As you can see, passing a collection object to the WebSocket engine and registering each class in the collection enables centralized management and batch registration, simplifying the WebSocket endpoint registration process. This decouples the WebSocket endpoint class from the engine, improving system flexibility and scalability, and facilitating the dynamic addition and removal of endpoint classes. The automated registration mechanism improves performance, avoids duplicate scans, and increases efficiency. Furthermore, centralized management makes lifecycle management, monitoring, and debugging more efficient, enhancing system maintainability.

[0070] Specifically, first, a WebSocket engine is created and a collection object is obtained; secondly, the Start method of the WebSocket engine is executed to register each class in the collection object; when each class in the collection object is registered, it is determined that the deployment of the application to be deployed is completed.

[0071] The process of registering each class in the collection object includes (process A1 to process A2):

[0072] Process A1: Execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each class in the collection object.

[0073] It can be understood that after the WebSocket engine obtains the collection objects of all classes annotated with the WebSocket annotation in the application to be deployed, it executes the Start method of the WebSocket engine to start the WebSocket engine.

[0074] In the specific implementation process A1, the JDK for loop traversal method in the Start method of the WebSocket engine is executed to traverse each class annotated with the WebSocket annotation in the collection object.

[0075] Process A2: Call the registration method of the WebSocket engine to register each class in the collection object.

[0076] It should be noted that the specific registration process is as follows Figure 2 Shown, including:

[0077] Step S201: calling the creation method of the annotation endpoint class through the WebSocket engine to create a corresponding annotation endpoint object for each class.

[0078] In the specific implementation of step S201, the creation method of the annotation endpoint class is called by the WebSocket engine. The WebSocket engine automatically creates the annotation endpoint object corresponding to each class according to the annotation defined on the endpoint class.

[0079] That is, the WebSocket engine will identify classes with specific annotations (such as WebSocket annotations) through reflection or other mechanisms, and call the corresponding construction methods to instantiate these classes.

[0080] It is understandable that calling the creation method of the annotation endpoint class through the WebSocket engine can improve the automation, scalability and maintainability of the system, while simplifying configuration and improving development efficiency.

[0081] Step S202: Determine the parent class type of each class through the while loop method of the Java Development Kit JDK.

[0082] In the specific implementation of step S202 , the parent class type (ie, the type of the inherited class) of each class is judged by using the while loop method of the Java Development Kit JDK to determine the parent class type of each class.

[0083] Specifically, the determination process includes (process B1 to process B4):

[0084] Process B1: Use the while loop method of the Java Development Kit JDK to define a JDK Boolean type variable for each class.

[0085] It should be noted that a JDK Boolean variable is defined for each class, with a default value of false. For each class, the Boolean variable is used to determine whether the class type is a WebSocket abstract endpoint type.

[0086] Process B2: Get the parent class type of each class and determine whether the parent class type is a WebSocket abstract endpoint class.

[0087] In the specific implementation of process B2, the parent class type of each class is obtained by calling the element method. The comparison method is then called to determine whether the parent class type is a WebSocket abstract endpoint class. If the parent class type is a WebSocket abstract endpoint class, process B3 is executed; if not, process B4 is executed.

[0088] Process B3: If so, set the value of the Boolean type variable of the class to true.

[0089] In the specific implementation process B3, if the parent class type is the WebSocket abstract endpoint class, the value of the Boolean type variable of the class is set to true.

[0090] Process B4: If not, set the value of the Boolean type variable of the class to false.

[0091] In the specific implementation process B4, if the parent class type is not the WebSocket abstract endpoint class, the value of the Boolean type variable of the class is set to false, that is, the default value false is kept unchanged.

[0092] It's understandable that by determining whether the parent class type is a WebSocket abstract endpoint class and setting a Boolean variable to true or false based on the result, the code's type safety can be enhanced, avoiding type mismatch errors. This approach also improves code maintainability, making the system structure clearer and easier to modify and expand. When the system needs to handle different types of endpoints, Boolean variables can simplify conditional logic, reduce redundant operations, and improve performance. This approach also improves system reliability and flexibility, ensuring that the system can perform appropriate operations based on different class types without requiring frequent core code modifications, thereby enhancing scalability and system stability.

[0093] Step S203: For each class, if the value of the JDK Boolean type variable corresponding to the parent class type of the class is true, a new WebSocket endpoint wrapper class object is created based on the new keyword and the class.

[0094] In the specific implementation of step S203 , for each class, if the value of the JDK Boolean type variable corresponding to the parent class type of the class is true, a new WebSocket endpoint wrapper class object is created based on the new keyword and the class.

[0095] That is to say, when creating a WebSocket endpoint wrapper class object, the parameter used is the application class currently annotated with the WebSocket annotation.

[0096] It can be understood that by using the new keyword and the application class annotated with the WebSocket annotation to create the endpoint wrapper class object, object management is simplified, repeated creation logic is reduced, and code maintainability is enhanced.

[0097] Step S204: If the value of the JDK Boolean type variable corresponding to the parent class type of the class is false, a new WebSocket endpoint wrapper class object is created based on the new keyword and the annotation endpoint object corresponding to the class.

[0098] In the specific implementation of step S204 , if the value of the JDK Boolean type variable corresponding to the parent class type of the class is false, a new WebSocket endpoint wrapper class object is created based on the new keyword and the annotation endpoint object corresponding to the class.

[0099] It can be understood that creating a WebSocket endpoint wrapper class object based on the new keyword and the annotated endpoint object corresponding to the class provides dynamism, simplifies instance management, improves maintainability and scalability, and contributes to the decoupling and flexible configuration of the system.

[0100] Step S205: After the creation of the new WebSocket endpoint wrapper class object is completed, it is determined that the class registration is completed.

[0101] In the specific implementation of step S205 , when the WebSocket endpoint wrapper class object of the class is newly created, it is determined that the class registration is completed.

[0102] After all classes in the collection object are registered according to the above process, it is determined that the application to be deployed is deployed in the application server.

[0103] It's important to note that this judgment mechanism allows the system to select the appropriate method for creating a WebSocket endpoint wrapper class object based on the class type. Because the deployed application uses both inherited and annotation-based endpoint class implementations, inheriting from the endpoint class ensures clearer control and behavior management, rather than relying on automatic annotations. This is because inheriting from the WebSocket endpoint class generally provides more control, allowing you to directly override parent class methods to define behavior, and provides a clearer class structure and functionality. Furthermore, when using annotations, the framework automatically handles the WebSocket endpoint configuration based on the annotations, resulting in more concise code.

[0104] This solves the error problem when adding message processors when the two implementation methods are mixed.

[0105] Step S104: accessing the deployed application to be deployed. If the connection opening method of the application class is executed and the message handler is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

[0106] In the specific implementation of step S104, the deployed application to be deployed is accessed, and the connection opening method of the application class is executed. If the message handler is successfully added to the WebSocket session class, it is determined that the application is accessed successfully, that is, the deployed application to be deployed is running normally.

[0107] In this embodiment, by optimizing the application server's WebSocket processing mechanism, the problem of duplicate message handler additions when a web application uses both inherited endpoint classes and annotation implementations is resolved. This allows developers to develop according to standard specifications, avoiding implementation conflicts. Application server compatibility is enhanced, ensuring stable program operation. Server availability is improved, making WebSocket communication more stable. Operations and maintenance become simpler and easier, reducing the workload for operators and improving overall system stability and efficiency.

[0108] Corresponding to the processing method of the application server WebSocket provided in the above embodiment of the present invention, see Figure 3 , shows a structural block diagram of a processing device for an application server WebSocket provided by an embodiment of the present invention.

[0109] The device includes: an acquisition unit 301 , a storage unit 302 , a registration unit 303 and an access unit 304 .

[0110] The acquisition unit 301 is used to acquire the application to be deployed, which includes a WebSocket component. The WebSocket component mixes annotations and inherited endpoint class implementations, and in the connection opening method of the WebSocket component application class, a message processor is added through the WebSocket session class.

[0111] The storage unit 302 is used to deploy the application to be deployed to the application server, and store multiple classes marked with WebSocket annotations in the application to be deployed through a collection object.

[0112] The registration unit 303 is used to create a WebSocket engine and register each class in the collection object to determine whether the deployment of the application to be deployed is completed.

[0113] The access unit 304 is used to access the deployed application to be deployed. If the connection opening method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

[0114] In this embodiment, by optimizing the application server's WebSocket processing mechanism, the problem of duplicate message handler additions when a web application uses both inherited endpoint classes and annotation implementations is resolved. This allows developers to develop according to standard specifications, avoiding implementation conflicts. Application server compatibility is enhanced, ensuring stable program operation. Server availability is improved, making WebSocket communication more stable. Operations and maintenance become simpler and easier, reducing the workload for operators and improving overall system stability and efficiency.

[0115] Combine Figure 3 The content shown, the storage unit 302, includes: a deployment module, a scanning module and a storage module.

[0116] The deployment module is used to deploy the application to be deployed to the application server.

[0117] The scanning module is used to scan WebSocket annotations in the application to be deployed through the application server.

[0118] The storage module is used to store classes annotated with WebSocket annotations into a collection object.

[0119] Combine Figure 3 The content shown, the registration unit 303, includes: a creation module, a registration module and a determination module.

[0120] Create a module to create a WebSocket engine and obtain a collection object.

[0121] The registration module is used to execute the Start method of the WebSocket engine and register each class in the collection object.

[0122] The determination module is used to determine that the deployment of the application to be deployed is completed when each class in the collection object is registered.

[0123] Combine Figure 3 The content shown, the registration module, includes: a traversal submodule and a registration submodule.

[0124] The traversal submodule is used to execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each class in the collection object.

[0125] The registration submodule is used to call the registration method of the WebSocket engine to register each class in the collection object.

[0126] Combine Figure 3 The content shown, the registration submodule, includes: a creation submodule, a first determination submodule, a first new creation submodule, a second new creation submodule and a second determination submodule.

[0127] Create a submodule to call the creation method of the annotation endpoint class through the WebSocket engine and create a corresponding annotation endpoint object for each class.

[0128] The first determination submodule is used to determine the parent class type of each class through the while loop method of the Java Development Kit JDK.

[0129] The first new submodule is used to create a new WebSocket endpoint wrapper class object based on the new keyword and class for each class if the value of the JDK Boolean type variable corresponding to the parent class type of the class is true.

[0130] The second new submodule is used to create a new WebSocket endpoint wrapper class object based on the new keyword and the annotation endpoint object corresponding to the class if the value of the JDK Boolean type variable corresponding to the parent class type of the class is false.

[0131] The second determining submodule is used to determine whether the class registration is completed after the new WebSocket endpoint wrapper class object is completed.

[0132] Combine Figure 3 The content shown, the first determination submodule, includes:

[0133] Define a submodule for defining a JDK Boolean type variable for each class through the while loop method of the Java Development Kit JDK;

[0134] The judgment submodule is used to obtain the parent class type of each class and determine whether the parent class type is a WebSocket abstract endpoint class. If the parent class type is a WebSocket abstract endpoint class, the first setting submodule is executed; if the parent class type is not a WebSocket abstract endpoint class, the second setting submodule is executed.

[0135] The first setting submodule is used to set the value of the Boolean type variable of the class to true.

[0136] The second setting submodule is used to set the value of the Boolean type variable of the class to false if it is not.

[0137] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.

[0138] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.

[0139] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing WebSocket in an application server, characterized in that: The method comprises: Obtaining an application to be deployed, the application to be deployed including a WebSocket component, the WebSocket component using a mix of annotations and inherited endpoint class implementations, and adding a message handler via a WebSocket session class in a connection open method of an application class of the WebSocket component; Deploy the application to be deployed to an application server, and store multiple classes in the application to be deployed marked with WebSocket annotations through a collection object; Creating a WebSocket engine and registering each of the classes in the collection object, and determining that the deployment of the application to be deployed is complete; The deployed application to be deployed is accessed. If the connection opening method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

2. The method according to claim 1, characterized in that The step of deploying the application to be deployed to an application server and storing multiple classes in the application to be deployed marked with WebSocket annotations through a collection object includes: Deploy the application to be deployed to the application server; Scanning the WebSocket annotations in the application to be deployed by the application server; Store classes annotated with WebSocket annotations in the collection object.

3. The method according to claim 1, characterized in that The step of creating a WebSocket engine and registering each of the classes in the collection object, and determining that the deployment of the application to be deployed is complete, includes: Create a WebSocket engine and obtain the collection object; Execute the Start method of the WebSocket engine to register each of the classes in the collection object; When the registration of each of the classes in the collection object is completed, it is determined that the deployment of the application to be deployed is completed.

4. The method according to claim 3, characterized in that The executing the Start method of the WebSocket engine to register each of the classes in the collection object includes: Execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each of the classes in the collection object; The registration method of the WebSocket engine is called to register each of the classes in the collection object.

5. The method according to claim 4, characterized in that The calling of the registration method of the WebSocket engine to register each of the classes in the collection object includes: Calling the creation method of the annotation endpoint class through the WebSocket engine to create a corresponding annotation endpoint object for each class; Determine the parent class type of each class using a while loop method of a Java Development Kit JDK; For each of the classes, if the value of the JDK Boolean type variable corresponding to the parent class type of the class is true, then a new WebSocket endpoint wrapper class object is created based on the new keyword and the class; If the value of the JDK Boolean type variable corresponding to the parent class type of the class is false, a new WebSocket endpoint wrapper class object is created based on the new keyword and the annotation endpoint object corresponding to the class; After the new WebSocket endpoint wrapper class object is created, it is determined that the class registration is complete.

6. The method according to claim 5, characterized in that The method of determining the parent class type of each class by using the while loop method of the Java Development Kit JDK includes: By using the while loop method of the Java Development Kit JDK, a JDK Boolean type variable is defined for each of the classes; Obtain the parent class type of each class, and determine whether the parent class type is a WebSocket abstract endpoint class; If so, set the value of the Boolean type variable of the class to true; If not, the value of the Boolean type variable of the class is set to false.

7. A WebSocket processing device for an application server, characterized in that: The device comprises: An acquisition unit is configured to acquire an application to be deployed, wherein the application to be deployed includes a WebSocket component, the WebSocket component uses a mixed annotation and inherited endpoint class implementation, and a message handler is added through a WebSocket session class in a connection opening method of an application class of the WebSocket component; A storage unit, configured to deploy the application to be deployed to an application server, and store multiple classes in the application to be deployed marked with WebSocket annotations through a collection object; A registration unit, configured to create a WebSocket engine and register each of the classes in the collection object, and determine that deployment of the application to be deployed is complete; The access unit is used to access the deployed application to be deployed. If the connection opening method of the application class is executed and the message processor is successfully added to the WebSocket session class, it is determined that the deployed application to be deployed is running normally.

8. The device according to claim 7, characterized in that The storage unit includes: A deployment module, configured to deploy the application to be deployed to an application server; A scanning module, configured to scan the WebSocket annotations in the application to be deployed through the application server; The storage module is used to store classes annotated with WebSocket annotations into a collection object.

9. The device according to claim 7, characterized in that The registration unit includes: Create a module for creating a WebSocket engine and obtaining the collection object; A registration module, configured to execute the Start method of the WebSocket engine and register each of the classes in the collection object; The determination module is configured to determine that the deployment of the application to be deployed is completed when the registration of each of the classes in the collection object is completed.

10. The device according to claim 9, characterized in that The registration module includes: A traversal submodule, configured to execute the JDK for loop traversal method in the Start method of the WebSocket engine to traverse each of the classes in the collection object; The registration submodule is used to call the registration method of the WebSocket engine to register each of the classes in the collection object.

Citation Information

Patent Citations

  • Online / offline service hybrid deployment method, cluster system and electronic equipment

    CN113176941A

  • Program detection method and device, electronic equipment and computer readable storage medium

    CN118839334A

  • JAVA API for programming web real-time communication applications

    US20140222957A1

  • Method for componentization of enterprise applications using plugins

    US20210382731A1

  • Secure deployment of an application across deployment locations

    US9398087B1