A singleton object loading method and device, a storage medium and an electronic device

By asynchronously loading the page routing configuration table and dynamically managing singleton objects when the target application is launched on the terminal device, the resource waste and performance overhead problems in the traditional singleton object creation method are solved, realizing on-demand loading and efficient resource utilization, and improving system performance and flexibility.

CN119201276BActive Publication Date: 2026-01-02HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411298787.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2026-01-02
Estimated Expiration
2044-09-14

AI Technical Summary

Technical Problem

Traditional methods of creating singleton objects initialize all singleton objects during program startup, leading to resource waste and performance overhead. This is especially true in large applications where many singleton objects are not accessed, resulting in wasted memory and computing resources. Furthermore, existing on-demand loading methods lack flexibility.

Method used

When the target application is launched on the terminal device, the page routing configuration table is loaded asynchronously, the singleton objects are dynamically managed, the corresponding singleton objects are loaded only when the business function is enabled, and the created singleton objects are stored through a preset object pool to avoid duplicate creation.

Benefits of technology

It improved system resource utilization efficiency and startup performance, enhanced the system's adaptability to business needs, and reduced resource waste and performance overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201276B_ABST
    Figure CN119201276B_ABST
Patent Text Reader

Abstract

The application provides a singleton object loading method and device, a storage medium and electronic equipment, and is applied to the technical field of computers. The method comprises the following steps: when a terminal device starts a target application, firstly, asynchronously loading a page route configuration table of the application. The table comprises a plurality of page route definitions, corresponding page singleton service information and a service function enabling state thereof. When a user accesses a page, checking the page route configuration table to confirm whether the corresponding page route definition exists. If the corresponding page route definition exists, identifying the singleton service information related to the page route definition. For the singleton service which has been enabled, searching for the corresponding singleton object in a preset object pool. If the corresponding singleton object is found, the object is loaded, and a plurality of singleton objects which are configured in advance are stored in the preset object pool. The application realizes dynamic on-demand loading of the singleton object through the page route configuration table, can reasonably utilize computer resources to manage the creation and loading of the singleton object, and thus effectively improves the system resource utilization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer technology, and in particular to a singleton object loading method and device, a storage medium and an electronic device. BACKGROUND

[0002] In modern software development, the singleton pattern is a common design pattern that aims to ensure that only one instance of a class exists and provides a global access point. This pattern is widely used in many applications, especially in scenarios that require shared state or resource management. However, traditional singleton object creation methods often face a series of problems, affecting the performance and resource utilization efficiency of the application.

[0003] However, existing singleton object creation methods usually require all singleton objects to be initialized during the program startup phase. Although this approach can ensure the availability of singleton objects to some extent, it also causes significant resource waste and performance overhead. Especially in large-scale applications, many singleton objects may not be accessed or needed during the actual use of the user, which leads to waste of memory and computing resources.

[0004] Therefore, how to create and manage singleton objects on demand and achieve dynamic loading of singleton objects has become a technical problem that needs to be solved by those skilled in the art. SUMMARY

[0005] In view of the above problems, the present application provides a singleton object loading method, device, storage medium and electronic device that overcome the above problems or at least partially solve the above problems, and the technical solutions are as follows:

[0006] A singleton object loading method, comprising:

[0007] In the case of starting a target application on a terminal device, asynchronously loading a page routing configuration table of the target application, wherein the page routing configuration table includes page singleton object information of the target application, and the page singleton object information includes page routing definition information of each page in the target application, at least one page singleton service information that has a mapping relationship with the page routing definition information, and a business function enable state corresponding to the page singleton service information;

[0008] In the case of opening a target page of the target application, querying whether there is target page routing definition information of the target page in the page routing configuration table, and if so, confirming each target page singleton service information that has a mapping relationship with the target page routing definition information;

[0009] For the target page singleton service information with the business function enable state being enabled, it is inquired in a preset object pool whether there is a target page singleton object corresponding to the target page singleton service information, and if yes, the target page singleton object is loaded, wherein the preset object pool stores a plurality of singleton objects configured in advance.

[0010] Optionally, the method further comprises:

[0011] In a case where it is inquired in the preset object pool that there is no target page singleton object corresponding to the target page singleton service information, the target page singleton object is created by using the target page singleton service information;

[0012] After the target page singleton object is created, the target page singleton object is loaded, and the target page singleton object is added to the preset object pool.

[0013] Optionally, before the page route configuration table of the target application is asynchronously loaded, the method further comprises:

[0014] The page route definition information of each page in the target application is obtained;

[0015] A mapping relationship between each page route definition information and at least one page singleton service information is respectively constructed, and a business function enable state corresponding to the page singleton service information is set, so as to generate the page singleton object information of the target application;

[0016] At least the page route configuration table of the target application is created by using the page singleton object information.

[0017] Optionally, the method further comprises:

[0018] A singleton object destruction attribute corresponding to the page singleton service information is set;

[0019] In a case where the target page is exited, the target page singleton object with the singleton object destruction attribute being destroyed is destroyed.

[0020] Optionally, before the page route configuration table of the target application is asynchronously loaded, the method further comprises:

[0021] At least one global singleton service information of the target application is obtained;

[0022] A business function enable state corresponding to each global singleton service information is respectively set, so as to generate global singleton object information of the target application;

[0023] The creating the page route configuration table of the target application by using at least the page singleton object information comprises:

[0024] The page route configuration table of the target application is constructed by using the page singleton object information and the global singleton object information.

[0025] Optionally, the method further comprises:

[0026] In the case that the target page of the target application is opened, each global singleton service information in the global singleton object information is obtained from the page route configuration table;

[0027] For the global singleton service information whose business function enabling state is enabled, it is inquired whether the target global singleton object corresponding to the global singleton service information exists in the preset object pool, if yes, the target global singleton object is loaded, if not, the target global singleton object is created by using the global singleton service information, and the target global singleton object is added to the preset object pool.

[0028] Optionally, the page route definition information comprises a page path and a page class name of a page of the target application, and the inquiring whether the target page route definition information of the target page exists in the page route configuration table in the case that the target page of the target application is opened comprises:

[0029] In the case that the target page of the target application is accessed by a user through a routing mechanism, the page path of the target page is obtained; the page path is taken as a query condition to inquire whether the page route definition information matching the page path exists in the page route configuration table, if yes, the page route definition information is confirmed as the target page route definition information of the target page;

[0030] In the case that the target page accessed by the user is a hard-coded page, the page class name of the target page is obtained; the page class name is taken as a query condition to inquire whether the page route definition information matching the page class name exists in the page route configuration table, if yes, the page route definition information is confirmed as the target page route definition information of the target page.

[0031] A singleton object loading device comprises a page route configuration table loading unit, a page route definition information query unit, a page singleton service information confirmation unit, a page singleton object query unit and a page singleton object loading unit,

[0032] The page route configuration table loading unit is configured to load a page route configuration table of a target application asynchronously when the terminal device starts the target application, wherein the page route configuration table comprises page singleton object information of the target application, and the page singleton object information comprises page route definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page route definition information, and a business function enablement state corresponding to the page singleton service information.

[0033] The page route definition information query unit is configured to query whether target page route definition information of a target page exists in the page route configuration table when the target page of the target application is opened, and trigger the page singleton service information confirmation unit if the target page route definition information exists.

[0034] The page singleton service information confirmation unit is configured to confirm each target page singleton service information in a mapping relationship with the target page route definition information.

[0035] The page singleton object query unit is configured to query whether a target page singleton object corresponding to the target page singleton service information exists in a preset object pool for the target page singleton service information with the business function enablement state being enabled, and trigger the page singleton object loading unit if the target page singleton object exists.

[0036] The page singleton object loading unit is configured to load the target page singleton object.

[0037] The preset object pool stores a plurality of singleton objects configured in advance.

[0038] A computer readable storage medium having a program stored thereon, the program being executed by a processor to implement the singleton object loading method of any one of the preceding embodiments.

[0039] An electronic device, comprising at least one processor, at least one memory connected to the processor, and a bus; wherein the processor, the memory and the bus complete mutual communication; the processor is configured to call program instructions in the memory to execute the singleton object loading method of any one of the preceding embodiments.

[0040] By the technical scheme, the application provides a singleton object loading method, device, storage medium and electronic equipment, the method comprises: in the case that the terminal device starts a target application, asynchronously loading a page route configuration table of the target application, wherein the page route configuration table comprises page singleton object information of the target application, the page singleton object information comprises page route definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page route definition information, and a business function enabling state corresponding to the page singleton service information; in the case that a target page of the target application is opened, querying whether there is target page route definition information of the target page in the page route configuration table, if yes, confirming each target page singleton service information in a mapping relationship with the target page route definition information; for the target page singleton service information with the business function enabling state being enabled, querying whether there is a target page singleton object corresponding to the target page singleton service information in a preset object pool, if yes, loading the target page singleton object, wherein the preset object pool stores a plurality of singleton objects configured in advance. The application realizes dynamic on-demand loading of singleton objects through the page route configuration table, can reasonably utilize computer resources to manage the creation and loading of singleton objects, and thus effectively improves the system resource utilization efficiency and startup performance.

[0041] The above description is only a summary of the technical scheme of the application, in order to more clearly understand the technical means of the application, the specific embodiments of the application can be implemented according to the content of the description, and in order to make the above and other purposes, characteristics and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS

[0042] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not meant to limit the present application. Furthermore, the same reference numerals are used throughout the several drawings to refer to same or like parts. In the drawings:

[0043] Figure 1 A flowchart of an embodiment of the singleton object loading method provided by the application is shown;

[0044] Figure 2 A flowchart of another embodiment of the singleton object loading method provided by the application is shown;

[0045] Figure 3 A flowchart of another embodiment of the singleton object loading method provided by the application is shown;

[0046] Figure 4 An example diagram of the page route configuration table provided by the application is shown;

[0047] Figure 5 Fig. 1 shows a structural schematic diagram of a singleton loading device according to an embodiment of the present application;

[0048] Figure 6 Fig. 2 shows a structural schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0049] Exemplary embodiments of the present application will be described herein below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it is understood that the present application can be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.

[0050] In modern software development, singleton pattern is a design pattern that aims to ensure that a class has only one instance and provides a global access point. While this pattern is very common in scenarios that require sharing state or managing resources, traditional singleton object creation methods often have problems of performance and resource utilization efficiency. Generally, existing methods require all singleton objects to be initialized in the program startup phase, which, while ensuring the availability of objects, also leads to resource waste and performance overhead. Especially in large applications, many singleton objects may not be accessed or needed during actual use, resulting in unnecessary consumption of memory and computing resources.

[0051] To solve this problem, the industry has proposed some on-demand loading strategies. A common approach is to hardcode the singleton object creation logic into the page to achieve on-demand loading of singletons. However, this method has obvious shortcomings. First, the hardcoding approach creates singleton objects according to fixed logic every time the page is loaded, even if these objects are not necessarily needed in the current user's context. Such an approach not only reduces the flexibility of the system, but also increases the complexity of maintenance. In the case of changes in business requirements or different user contexts, it is difficult to effectively adjust the hard-coded logic, making it difficult for the system to adapt to real-time changing requirements.

[0052] In summary, the resource waste and performance overhead caused by the traditional method of loading singleton objects in bulk at program startup, and the lack of flexibility in existing technologies through hardcoding to achieve on-demand loading of singletons, both indicate that the current singleton management strategy needs to be improved.

[0053] Based on this, in the embodiments of the present application, a singleton object loading method is provided. When a terminal device starts a target application, the page routing configuration table of the application is first loaded asynchronously. The table contains multiple page routing definitions, corresponding page singleton service information, and the business function enablement status thereof. When a user accesses a page, the page routing configuration table is checked to confirm whether there is a corresponding page routing definition. If there is, the singleton service information related thereto is identified. For singleton services that have been enabled, the corresponding singleton object is searched in a preset object pool. If found, the object is loaded, and the preset object pool stores multiple singleton objects configured in advance. It can be seen that the present application optimizes the creation and management mode of singleton objects through the page routing configuration table, which not only improves the performance of the system, but also enhances the adaptability of the system to business demands, and realizes more efficient resource utilization.

[0054] As Figure 1 shown, the flowchart of an embodiment of the singleton object loading method provided by the embodiments of the present application, the method can include:

[0055] S100, in the case of starting a target application in a terminal device, the page routing configuration table of the target application is loaded asynchronously, wherein the page routing configuration table includes the page singleton object information of the target application, the page singleton object information includes the page routing definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page routing definition information, and the business function enablement status corresponding to the page singleton service information.

[0056] Wherein, the terminal device refers to the hardware device used by the user, such as smart phone, tablet computer, personal computer, etc. The terminal device can run application program, process user input and display content.

[0057] Wherein, the target application refers to the specific software or program started by the user on the terminal device, such as social media application, e-commerce platform, game or other functional application. The target application provides specific functions and interfaces to meet the needs of users.

[0058] Wherein, asynchronous loading is a programming technique that allows an application to perform certain operations in the background without blocking the main thread or user interface.

[0059] Wherein, the page routing configuration table is a data structure containing the routing information of each page in the target application. The page routing configuration table records all the pages of the application and their corresponding access paths (routes), as well as the service and function status related to these pages.

[0060] The page singleton object information refers to the detailed information of the singleton object associated with a page in the application. A singleton object is an object that will only have one instance created during the application's runtime. Singleton objects usually contain the state and behavior of a page, ensuring that they can be efficiently used and accessed in different contexts.

[0061] The page route definition information refers to a specific entry in the page route configuration table, describing the unique identifier or access path of a certain page. Page route definition information defines how a user navigates to the corresponding page and usually includes a URL or a specific path string.

[0062] The page singleton service information refers to the service information associated with a specific page route definition information. These services are usually components that handle the business logic of the page and can include data acquisition, state management, etc. Page singleton services exist in singleton mode, ensuring that only one instance handles specific page logic throughout the application's lifecycle.

[0063] The business function enablement status refers to whether the function related to the page singleton service information is enabled in the current application environment. It is usually represented by a Boolean value (such as "enabled" or "disabled"). The business function enablement status determines whether a specific function can be used when a user accesses the relevant page, affecting the behavior of the page and the user experience.

[0064] Specifically, when the user starts the target application on a mobile device, the embodiment of the application can use a library that handles network requests (such as URLSession (iOS) or OkHttp (Android)) to perform asynchronous HTTP requests and handle server responses through callback functions to asynchronously obtain the latest page route configuration table of the target application from the server.

[0065] Optionally, in the case of network fluctuations or server failures causing the page route configuration table acquisition request to fail, the embodiment of the application can automatically retry the page route configuration table acquisition request. After retrying a preset number of times, if the acquisition request still fails, switch to the page route configuration table in the local cache of the last successful request to ensure that the application can run smoothly and provide a good user experience.

[0066] S110, in the case of opening the target page of the target application, query whether the target page route definition information of the target page exists in the page route configuration table, if so, execute step S120.

[0067] Specifically, when a user opens a target page of a target application, the embodiment of the application queries a page routing configuration table to determine whether there is page routing definition information of the target page. If the corresponding page routing definition information is found, it means that the target page is supported and can be loaded, and then the next step is executed.

[0068] Optionally, the embodiment of the application can normally load the target page in the case where the page routing configuration table query does not find the target page routing definition information of the target page, that is, the target page does not involve singleton creation logic. The embodiment of the application provides normal page loading logic for the scenario where the target page does not involve singleton creation logic, and can ensure that the user normally experiences the target page.

[0069] S120, confirming each target page singleton service information that has a mapping relationship with the target page routing definition information.

[0070] Specifically, the embodiment of the application confirms all singleton service information related to the target page routing definition information, that is, the singleton service associated with the current page, to identify the page service component that needs to be loaded.

[0071] S130, for the target page singleton service information whose business function enablement state is enabled, querying whether there is a target page singleton object corresponding to the target page singleton service information in a preset object pool, and if so, performing step S140.

[0072] The preset object pool stores a plurality of singleton objects that have been configured.

[0073] Specifically, the embodiment of the application finds whether there is a page singleton object corresponding to the service in a preset object pool for the page singleton service whose business function enablement state is enabled. If the page singleton object is found in the object pool, the page singleton object does not need to be re-created and can be directly used. The embodiment of the application maintains a pool of created singleton objects to ensure that each singleton object is created only once, thereby avoiding resource waste caused by repeated creation of the same singleton object.

[0074] S140, loading the target page singleton object.

[0075] Specifically, the embodiment of the application can load the page singleton object found in the preset object pool for the target page to be used for operation of the target page. The embodiment of the application loads the singleton object only when the routing has been configured and the business function is in an activated state, thereby effectively avoiding application performance degradation and invalid resource consumption.

[0076] In actual applications, due to business logic reasons (such as AB testing or function offline, etc.), some singleton objects do not need to be created, and the corresponding target page singleton service information can be set to the disabled state of the business function to indicate that the corresponding singleton object does not need to be created.

[0077] The scenario of the business function being set to the disabled state can include product testing phase, certain user groups not opening some functions, or temporary function offline, etc. The purpose of setting the "enable switch" is to flexibly control the release and disablement of functions, thereby avoiding unnecessary resource occupation and user experience confusion, and ensuring reasonable and efficient management of singleton objects in the application. For example, during the audit of the application program, if a certain business function cannot pass the audit due to some reasons, the business function enable state can be configured as "disabled", thereby prohibiting the creation of related singleton objects and achieving service disablement.

[0078] It can be understood that the page routing definition information can have a mapping relationship with a plurality of page singleton service information, and in these page singleton service information, the application embodiment can skip the creation of the page singleton object whose business function enable state is disabled, and continue to load the page singleton object whose business function enable state is enabled. For the uncreated page singleton object, the application embodiment can hide the content or prompt related to the function of the page singleton object in the loaded target page, and ensure the normal operation of the functions of other created page singleton objects.

[0079] Optionally, in the case where the business function enable state of any page singleton service information of the target application is disabled, the application embodiment can guide the user to view a preset error page or a preset default page, or prompt the user to perform application check and update, so as to ensure that the user experience is not affected. Under the dynamic on-demand loading mechanism, the application embodiment provides a corresponding bottom strategy for a plurality of singleton object creation scenarios that do not need to be created, can maintain the robustness of the underlying code, and guarantee the service experience of the user.

[0080] The application provides a singleton object loading method, which comprises the following steps: in the case that a terminal device starts a target application, asynchronously loading a page route configuration table of the target application, wherein the page route configuration table comprises a plurality of page route definition information, at least one page singleton service information in a mapping relationship with the page route definition information, and a business function enabling state corresponding to the page singleton service information; in the case that a target page of the target application is opened, querying whether there is target page route definition information of the target page in the page route configuration table, and if yes, confirming each target page singleton service information in a mapping relationship with the target page route definition information; for the target page singleton service information with the business function enabling state being enabled, querying whether there is a target page singleton object corresponding to the target page singleton service information in a preset object pool, and if yes, loading the target page singleton object, wherein the preset object pool stores a plurality of singleton objects configured in advance. The application realizes dynamic on-demand loading of singleton objects through the page route configuration table, can reasonably utilize computer resources to manage the creation and loading of singleton objects, and thus effectively improves the system resource utilization efficiency and the starting performance.

[0081] Optionally, in the above Figure 1 Based on one or more embodiments, another optional embodiment provided by the application comprises the following steps:

[0082] In the case that it is queried that there is no target page singleton object corresponding to the target page singleton service information in the preset object pool, the target page singleton object is created by using the target page singleton service information; after the target page singleton object is created, the target page singleton object is loaded, and the target page singleton object is added to the preset object pool.

[0083] In the case that it is queried that there is no target page singleton object corresponding to the target page singleton service information in the preset object pool, the target page singleton object is created by using the target page singleton service information; after the target page singleton object is created, the target page singleton object is loaded, and the target page singleton object is added to the preset object pool.

[0084] Specifically, the singleton service information for a page typically includes configuration information, dependencies, and initialization parameters required for the page's business logic. This embodiment of the invention reads this information and initializes the singleton object according to a predetermined creation process. This creation process may include: First, obtaining the initial configuration required by the target page from the singleton service information, such as specific business rules, database connections, and external dependent services. Second, initializing other resources or objects that the singleton object depends on, such as configuration loading and service calls, based on the description in the singleton service information. Finally, using the initial configuration and dependencies, calling the constructor or factory method of the target singleton object to instantiate it.

[0085] In this embodiment of the invention, after the singleton object is created, it is loaded into memory, ready for use by the target page. Simultaneously, to avoid duplicate creation, the singleton object is stored in a preset object pool so that subsequent requests for the same page can reuse the singleton object.

[0086] This invention, through page route definition information in the page route configuration table, can dynamically create and load singleton objects when needed, thereby avoiding the pre-allocation of unnecessary resources during application startup. Simultaneously, it maintains a pool of created singleton objects, ensuring that each singleton object is created only once, thus avoiding resource waste caused by duplicate creation.

[0087] For example, taking the MGTV APP as an example, its homepage tab contains multiple channel pages. Using the singleton object loading method provided in this embodiment of the invention, recommendation algorithm singletons related to each page can be dynamically loaded according to the page routing configuration table. When a user visits the "Homepage," only the recommendation algorithm singleton corresponding to the homepage is created and loaded; while when the user switches to the "TV Series" channel, the singleton corresponding to that channel is created and loaded, thus effectively avoiding the preloading of useless singletons and improving the application's efficiency and response speed.

[0088] In traditional on-demand loading methods, failure to create a singleton object can lead to business errors or UI chaos. However, in scenarios where singletons are dynamically created based on page routes, the code already fully considers the possibility of the singleton not being enabled. Therefore, even if singleton object creation fails, a fallback strategy can be implemented by referencing an interface where the singleton is not enabled. This can be done by skipping the creation of the singleton object, guiding the user to view a preset error page or default page, or prompting the user to check for application updates, thus ensuring that the user experience is not affected.

[0089] Optional, based on Figure 1 The method shown is as follows: Figure 2As shown, the flowchart of another embodiment of the singleton object loading method provided by the embodiment of the application is shown, and before loading the page route configuration table of the target application asynchronously, the method can further include:

[0090] S200, obtaining page route definition information of each page in the target application.

[0091] Specifically, the embodiment of the application can collect and organize the URL path, page class name and other key information of all pages in the target application, so as to obtain the page route definition information of each page in the target application.

[0092] S210, respectively constructing a mapping relationship between the page route definition information and the at least one page singleton service information, and setting a business function enablement state corresponding to the page singleton service information, so as to generate page singleton object information of the target application.

[0093] Specifically, the embodiment of the application can determine the singleton object (service or component) required by each page, and set the enablement state of the singleton object according to the business requirement. By constructing the mapping relationship between the page route definition information and the page singleton service information, the singleton object required by each page at runtime is determined, and the corresponding page singleton object information is generated.

[0094] S220, creating a page route configuration table of the target application by using at least the page singleton object information.

[0095] Specifically, the embodiment of the application can use the generated page singleton object information to construct the page route configuration table of the target application, so as to summarize the route information of each page, the corresponding singleton object and the enablement state thereof.

[0096] The embodiment of the application can dynamically manage the relationship between the application page and the singleton object by creating the page route configuration table of the target application, so as to facilitate the creation of the singleton object on demand, so as to improve the resource utilization efficiency and adapt to the change of the business requirement.

[0097] Optionally, in the above Figure 2 Based on one or more embodiments corresponding thereto, another optional embodiment provided by the embodiment of the application can further include:

[0098] Setting a singleton object destruction attribute corresponding to the page singleton service information. In the case of exiting the target page, destroying the singleton object destruction attribute of the target page singleton object.

[0099] The singleton object destruction attribute refers to an attribute for indicating whether a certain singleton object should be destroyed or release its resource under the condition of exiting the target page.

[0100] In particular, the embodiment of the present application defines a singleton object destroy attribute for each page singleton service information. The singleton object destroy attribute is usually a Boolean value, and can be named "destroyOnExit" or similar identifiers.

[0101] When the user exits from the target page or navigates to other pages, the embodiment of the present application can determine the singleton object destroy attribute of the singleton object used in the current page. If the singleton object destroy attribute is set to a true value (for example, true), the singleton object is destroyed to release the resources occupied by the singleton object, thereby avoiding unnecessary memory occupation.

[0102] The embodiment of the present application can effectively manage the life cycle of the singleton object by setting the singleton object destroy attribute, so that the application can maintain high efficiency and performance while reasonably using system resources.

[0103] Optionally, based on the method shown in FIG. 2, the embodiment of the present application provides another embodiment of a singleton object loading method, and a flowchart of the method is shown in FIG. 3. Before asynchronously loading the page routing configuration table of the target application, the method can further include: Figure 2 Figure 3 The embodiment of the present application provides another embodiment of a singleton object loading method, and a flowchart of the method is shown in FIG. 3. Before asynchronously loading the page routing configuration table of the target application, the method can further include:

[0104] S300, obtaining at least one global singleton service information of a target application.

[0105] The global singleton service information refers to instance service or object information defined by the target application in the entire application range. The global singleton service information includes some core functions or states of the target application, so that each part of the entire application can be accessed and used.

[0106] In particular, the embodiment of the present application can obtain the global singleton service information of the target application from the configuration file, the service registry center or other sources of the target application.

[0107] S310, respectively setting the business function enable states corresponding to each global singleton service information to generate global singleton object information of the target application.

[0108] The global singleton object information refers to detailed information of a specific instance or object associated with the global singleton service information.

[0109] In particular, the embodiment of the present application sets the business function enable state corresponding to the global singleton service information after obtaining the global singleton service information, and determines the global singleton object required by the application at runtime, thereby generating the corresponding global singleton object information.

[0110] Step S220 can be specifically step S320. ​

[0111] S320, constructing a page routing configuration table of the target application by using the page singleton object information and the global singleton object information.

[0112] The page routing configuration table constructed by the page singleton object information and the global singleton object information can be as shown in the following table. Figure 4 The page routing configuration table is requested from the server only at the cold start of the application, and therefore the page routing configuration table does not change during the running of the application. This means that the state of the singleton object is not affected by the configuration change during the running of the application. If the page routing configuration table is changed after the cold start, the changes will take effect at the next cold start. Therefore, the runtime does not need to handle the "expiration" problem of the singleton object. The singleton object is only recreated or initialized according to the new page routing configuration table at the cold start, thereby ensuring the stability of the system and the effective use of resources.

[0113] The instance structure pseudo code of the page routing configuration table can be as follows.

[0114]

[0115] The embodiments of the application uniformly manage the page singleton object information and the global singleton object information of the application pages by the page routing configuration table, which is beneficial to flexibly adjusting the creation and loading of the singleton objects related to the application pages, thereby helping to adapt to the real-time changes of the business requirements.

[0116] Optionally, on the basis of one or more embodiments described above, Figure 3 According to another optional embodiment of the application, the method further comprises the following steps:

[0117] In the case of opening the target page of the target application, each global singleton service information in the global singleton object information is obtained from the page routing configuration table. For the global singleton service information whose business function enablement state is enabled, it is queried whether the target global singleton object corresponding to the global singleton service information exists in the preset object pool. If yes, the target global singleton object is loaded, and if no, the target global singleton object is created by using the global singleton service information, and the target global singleton object is added to the preset object pool.

[0118] Specifically, when the user opens the target page of the target application, the embodiments of the application query the page routing configuration table to obtain each global singleton service information in the global singleton object information of the target application, i.e., the global singleton service associated with the target application, so as to identify the global service component that needs to be loaded.

[0119] Specifically, the embodiment of the present application finds whether the global singleton object corresponding to the service exists in the preset object pool for the service function enabled state being enabled. If the global singleton object is found in the object pool, the global singleton object is directly used without re-creation. The embodiment of the present application ensures that each singleton object is only created once by maintaining the pool of created singleton objects, thereby avoiding the resource waste caused by repeated creation of the same singleton object.

[0120] Specifically, the embodiment of the present application can load the global singleton object for the operation of the target page after finding the global singleton object of the target application in the preset object pool. The embodiment of the present application loads the singleton object only when the global service is configured and the business function is in the activated state, thereby effectively avoiding the application performance decline and invalid resource consumption.

[0121] It can be understood that, similar to the page singleton service information, for the global singleton service information, the embodiment of the present application can skip the global singleton object creation with the business function enabled state being disabled, and continue to load the global singleton object with the business function enabled state being enabled. The embodiment of the present application can hide the content or prompt related to the function of the global singleton object in the target page to be loaded, and ensure the normal operation of the function of other created global singleton objects.

[0122] The embodiment of the present application manages the global singleton object through the preset object pool, and loads or creates the global singleton object only when needed, which can avoid the overhead of repeated object creation, reduce resource consumption, thereby improving the response speed of the application and enhancing the overall performance of the application.

[0123] Optionally, in the above Figure 1 Based on one or more embodiments, in another optional embodiment of the present application, the page route definition information includes the page path and the page class name of the target application, and in the case of opening the target page of the target application, it is queried whether the target page route definition information of the target page exists in the page route configuration table, which can specifically include:

[0124] In the case that the user accesses the target page of the target application through the routing mechanism, the page path of the target page is obtained; the page path is used as a query condition to query whether the page route definition information matched with the page path exists in the page route configuration table, and if yes, the page route definition information is confirmed as the target page route definition information of the target page.

[0125] The page path refers to the URL path required by the user when accessing the page in the application. For example, “ / home”, “ / about” and “ / products” and the like.

[0126] Specifically, the user can navigate to the target page in the target application through clicking a link, bookmarking, or manually entering a URL, etc. The embodiment of the application uses the obtained page path as a condition to query the page routing configuration table in response to the user's request for the complete page path, and checks whether there is page routing definition information matching the path. If the query result contains a matching page path, the corresponding page routing definition information is confirmed as the target page routing definition information of the target page. This means that the application successfully found the page logic corresponding to the user's request path.

[0127] In the case where the target page accessed by the user is a hard-coded page, the page class name of the target page is obtained; the page class name is used as a query condition to query whether there is page routing definition information matching the page class name in the page routing configuration table, and if so, the page routing definition information is confirmed as the target page routing definition information of the target page.

[0128] Among them, the page class name refers to the class name corresponding to the page logic, which is usually a class defined in JavaScript or other languages, used to render and manage the logic of the page. For example: "HomePage" and "AboutPage" and the like.

[0129] In some cases, the page may not be generated by dynamic routing, but is hard-coded (for example: a page defined directly in the code). For this case, the embodiment of the application can obtain the corresponding page class name from the accessed page, and use the obtained page class name as a query condition to query the page routing configuration table, and check whether there is page routing definition information matching the page class name. If a matching page class name is found, the corresponding routing definition information is confirmed as the target page routing definition information of the target page.

[0130] The embodiment of the application confirms the routing definition information of the target page requested by the user through the page path and the page class name, so that the target application can flexibly handle different types of page access requests, which is conducive to supporting multiple access methods (path and class name) and adapting to diversified application requirements, thereby helping to improve the maintainability and user experience of the application.

[0131] To facilitate understanding of the overall process of singleton object management of the singleton object loading method provided by the embodiments of the present application, the following is described by way of example: first, initialize the singleton pool. When the application is cold started, the global singleton pool is initialized according to the globalSingletons configuration item in the page routing configuration table, and all global singleton objects such as LoggerService and DatabaseService are created and stored for shared use during application running. When processing page loading, the required singleton objects are created and managed according to the corresponding configuration matched according to different scenarios.

[0132] For a routing scenario: when a user accesses a certain page through a routing mechanism (such as UniversalLink of iPhone), a matching item is found in the path field in the configuration table according to the request path (for example: / home). The path field in the configuration table is searched for a matching request path. If a matching item is found, the corresponding page and the singleton objects required by the page are loaded. For example: a user accesses the / home route through myapp: / / home, the HomePage page is found according to the path field, and it is checked whether the UserService singleton object needs to be loaded. If the UserService does not exist in the singleton pool, the system creates and adds it to the pool.

[0133] For a non-routing scenario: for a page instantiated by a hardcoding method (for example: directly using the new keyword), the page class name (such as HomePage) is matched with the page field in the configuration table. The page class name is matched with the page field in the configuration table to determine whether the corresponding singleton object needs to be created and loaded. For example: when the HomePage is instantiated in the code, the corresponding page configuration is found according to the page field, and it is checked whether the UserService singleton object needs to be created. If the UserService does not exist in the singleton pool, the object is created and initialized.

[0134] When the page disappears, it is determined whether to destroy the singleton object according to the destroyOnExit attribute of the singleton object. If the destroyOnExit attribute is true, the singleton object is destroyed and removed from the preset object pool. If the destroyOnExit attribute is false, the singleton object is retained for subsequent use by other pages. For example: when the / profile page is accessed, if the destroyOnExit attribute of the ProfileService is true, the ProfileService instance is destroyed and removed from the object pool after the page disappears.

[0135] The embodiment of the present application avoids the situation that the singleton object occupies the memory for a long time in the prior art by dynamically loading on demand, and in particular, the resource waste is reduced by automatic destruction when the object is no longer needed. Meanwhile, the resource utilization efficiency is improved and the complexity of manual management is reduced by intelligently managing the life cycle of the singleton object.

[0136] The singleton object loading method provided by the embodiment of the present application adopts the singleton mode with flexible configuration, and in principle, is not limited by specific businesses, and is particularly suitable for large multifunctional application scenarios requiring global resource sharing and complex business logic management, and can ensure efficient and stable use of resources and improve user experience.

[0137] Although each operation is described in a particular order, this should not be understood as requiring the operations to be performed in the particular order shown or in a sequential order. In certain circumstances, multitasking and parallel processing can be advantageous.

[0138] It should be understood that each step described in the method embodiment of the present application can be performed in a different order and / or in parallel. In addition, the method embodiment can include additional steps and / or omit the execution of the steps shown. The scope of the present application is not limited in this respect.

[0139] Corresponding to the above method embodiment, the embodiment of the present application also provides a singleton object loading device, the structure of which is as shown in Figure 5 The device can include a page route configuration table loading unit 10, a page route definition information query unit 20, a page singleton service information confirmation unit 30, a page singleton object query unit 40, and a page singleton object loading unit 50.

[0140] The page route configuration table loading unit 10 is configured to load the page route configuration table of the target application asynchronously when the terminal device starts the target application, wherein the page route configuration table includes the page singleton object information of the target application, and the page singleton object information includes the page route definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page route definition information, and a business function enable state corresponding to the page singleton service information.

[0141] The page route definition information query unit 20 is configured to query whether the target page route definition information of the target page exists in the page route configuration table when the target page of the target application is opened, and if so, trigger the page singleton service information confirmation unit 30.

[0142] The page singleton service information confirmation unit 30 is configured to confirm each target page singleton service information in a mapping relationship with the target page route definition information.

[0143] The page singleton object querying unit 40 is configured to, for the target page singleton service information of which the business function enable state is enabled, query whether the target page singleton object corresponding to the target page singleton service information exists in the preset object pool, and if so, trigger the page singleton object loading unit 50.

[0144] The page singleton object loading unit 50 is configured to load the target page singleton object.

[0145] The preset object pool stores a plurality of configured singleton objects.

[0146] Optionally, the singleton object loading apparatus can further include a page singleton object creating unit and a page singleton object storing unit.

[0147] The page singleton object creating unit is configured to, in a case where it is queried that the target page singleton object corresponding to the target page singleton service information does not exist in the preset object pool, create the target page singleton object by using the target page singleton service information, trigger the page singleton object loading unit 50 to load the target page singleton object after the target page singleton object is created, and trigger the page singleton object storing unit to add the target page singleton object to the preset object pool.

[0148] Optionally, the singleton object loading apparatus can further include a page route definition information obtaining unit, a page singleton object information generating unit and a page route configuration table creating unit.

[0149] The page route definition information obtaining unit is configured to obtain the page route definition information of each page in the target application before the page route configuration table loading unit 10 asynchronously loads the page route configuration table of the target application.

[0150] The page singleton object information generating unit is configured to respectively construct a mapping relationship between each page route definition information and at least one page singleton service information, and set the business function enable state corresponding to the page singleton service information, so as to generate the page singleton object information of the target application.

[0151] The page route configuration table creating unit is configured to create the page route configuration table of the target application by using at least the page singleton object information.

[0152] Optionally, the singleton object loading apparatus can further include a singleton object destruction attribute setting unit and a page singleton object destroying unit.

[0153] The singleton object destruction attribute setting unit is configured to set the singleton object destruction attribute corresponding to the page singleton service information.

[0154] The page singleton object destroying unit is configured to destroy the singleton object corresponding to the target page to be exited.

[0155] Optionally, the singleton object loading apparatus further comprises a global singleton service information obtaining unit and a global singleton object information generating unit.

[0156] The global singleton service information obtaining unit is configured to obtain at least one global singleton service information of the target application.

[0157] The global singleton object information generating unit is configured to set a business function enabling state corresponding to each global singleton service information respectively, so as to generate global singleton object information of the target application.

[0158] The page route configuration table creating unit is configured to construct a page route configuration table of the target application by using the page singleton object information and the global singleton object information.

[0159] Optionally, the singleton object loading apparatus further comprises a global singleton service information obtaining unit, a global singleton object querying unit, a global singleton object loading unit, a global singleton object creating unit and a global singleton object storing unit.

[0160] The global singleton service information obtaining unit is configured to obtain each global singleton service information in the global singleton object information from the page route configuration table when a target page of the target application is opened.

[0161] The global singleton object querying unit is configured to, for the global singleton service information whose business function enabling state is enabled, query whether a target global singleton object corresponding to the global singleton service information exists in a preset object pool, and if so, trigger the global singleton object loading unit, and if not, trigger the global singleton object creating unit.

[0162] The global singleton object loading unit is configured to load the target global singleton object.

[0163] The global singleton object creating unit is configured to create the target global singleton object by using the global singleton service information.

[0164] The global singleton object storing unit is configured to add the target global singleton object to the preset object pool.

[0165] Optionally, the page route definition information comprises a page path and a page class name of a page of the target application.

[0166] Optionally, the page route definition information querying unit 20 can comprise a route access scenario matching subunit and a non-route scenario matching subunit.

[0167] The route access scenario matching subunit is configured to, in the case that the user accesses a target page of a target application through a routing mechanism, obtain a page path of the target page; and query, taking the page path as a query condition, the page routing configuration table to determine whether there is page routing definition information matching the page path, and if so, confirm the page routing definition information as target page routing definition information of the target page.

[0168] The non-routing scenario matching subunit is configured to, in the case that the target page accessed by the user is a hard-coded page, obtain a page class name of the target page; and query, taking the page class name as a query condition, the page routing configuration table to determine whether there is page routing definition information matching the page class name, and if so, confirm the page routing definition information as target page routing definition information of the target page.

[0169] The application provides a singleton object loading device, which is used in the case that a terminal device starts a target application, to asynchronously load a page routing configuration table of the target application, wherein the page routing configuration table comprises page singleton object information of the target application, the page singleton object information comprises page routing definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page routing definition information, and a business function enabling state corresponding to the page singleton service information; in the case that a target page of the target application is opened, the page routing configuration table is queried to determine whether there is target page routing definition information of the target page, and if so, each target page singleton service information in a mapping relationship with the target page routing definition information is confirmed; for the target page singleton service information with the business function enabling state being enabled, the preset object pool is queried to determine whether there is a target page singleton object corresponding to the target page singleton service information, and if so, the target page singleton object is loaded, wherein the preset object pool stores a plurality of singleton objects configured in advance. The application realizes dynamic on-demand loading of singleton objects through the page routing configuration table, can reasonably utilize computer resources to manage the creation and loading of singleton objects, and thus effectively improves the system resource utilization efficiency and the starting performance.

[0170] As to the device in the above embodiment, the specific manner in which each unit performs an operation has been described in detail in the embodiment related to the method, and thus will not be described in detail here.

[0171] The singleton object loading device comprises a processor and a memory, and the above page routing configuration table loading unit 10, page routing definition information querying unit 20, page singleton service information confirming unit 30, page singleton object querying unit 40 and page singleton object loading unit 50 are all stored in the memory as program units, and the corresponding functions are realized by the processor executing the above program units stored in the memory.

[0172] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, the page routing configuration table can be used to dynamically load singleton objects on demand, effectively utilizing computer resources to manage the creation and loading of singleton objects, thereby significantly improving system resource utilization efficiency.

[0173] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements the singleton object loading method.

[0174] This invention provides a processor for running a program, wherein the program executes the singleton object loading method during runtime.

[0175] like Figure 6 As shown, this embodiment of the invention provides an electronic device 1000, which includes at least one processor 1001, at least one memory 1002 connected to the processor 1001, and a bus 1003. The processor 1001 and the memory 1002 communicate with each other via the bus 1003. The processor 1001 is used to call program instructions in the memory 1002 to execute the aforementioned singleton object loading method. The electronic device in this document can be a server, PC, PAD, mobile phone, etc.

[0176] The present invention also provides a computer program product that, when executed on an electronic device, is suitable for executing a program with initialization steps for loading a singleton object.

[0177] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, electronic devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0178] In a typical configuration, an electronic device includes one or more processors (CPUs), memory, and a bus. The electronic device may also include input / output interfaces, network interfaces, etc.

[0179] The memory can include non-persistent memory in the computer readable medium, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory, including at least one memory chip. The memory is an example of computer readable media.

[0180] Computer readable media includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, computer readable media does not include transitory media such as modulated data signals and carriers.

[0181] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0182] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the type of personal information involved in the present disclosure, the use range, the use scene, etc. should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.

[0183] In the description of the present application, it should be understood that if the terms "upper", "lower", "front", "rear", "left" and "right" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the position or element must have a specific orientation, be constructed and operated in a specific orientation, therefore it cannot be understood as a limitation of the present application.

[0184] It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. It is to be understood that where the application is specifically recited as including certain features, embodiments of the application also include embodiments that exclude such features. The terms "a" or "an", as used herein, mean "one or more" unless otherwise explicitly provided. The term "another", as used herein, means "at least a second" or "at least one", and not necessarily "two" or "more than one". The terms "including", "comprising" or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element preceded by "comprises a" or "comprising" does not, without more constraints, foreclose the existence of additional identical elements.

[0185] Those skilled in the art will appreciate that embodiments of the present application can be devised for a method, a system, or a computer program product. Accordingly, the present application can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.

[0186] The embodiments of the present application are only illustrative and are not intended to limit the present application. The present application can be variously changed and various changes and modifications can be made by those skilled in the art. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application are intended to be included in the scope of the claims of the present application.

Claims

1. A method of loading a singleton object, characterized by, Comprise: In the case of starting a target application in a terminal device, asynchronously load the page routing configuration table of the target application, wherein the page routing configuration table comprises page singleton object information of the target application, the page singleton object information comprises page routing definition information of each page in the target application, at least one page singleton service information in a mapping relationship with the page routing definition information, and a business function enable state corresponding to the page singleton service information; In the case of opening a target page of the target application, query whether there is target page routing definition information of the target page in the page routing configuration table, if yes, confirm each target page singleton service information in a mapping relationship with the target page routing definition information; For the target page singleton service information with the business function enable state enabled, query whether there is a target page singleton object corresponding to the target page singleton service information in a preset object pool, if yes, load the target page singleton object, wherein the preset object pool stores a plurality of singleton objects configured.

2. The method of claim 1, wherein, Also include: In the case of querying that there is no target page singleton object corresponding to the target page singleton service information in the preset object pool, create the target page singleton object by using the target page singleton service information; After the target page singleton object is created, load the target page singleton object and add the target page singleton object to the preset object pool.

3. The method of claim 1, wherein, Before the page routing configuration table of the target application is asynchronously loaded, the method further comprises: Obtain the page routing definition information of each page in the target application; Respectively build the mapping relationship between each page routing definition information and at least one page singleton service information, and set the business function enable state corresponding to the page singleton service information, to generate the page singleton object information of the target application; At least use the page singleton object information to create the page routing configuration table of the target application.

4. The method of claim 3, wherein, Also include: Set the singleton object destruction attribute corresponding to the page singleton service information; In the case of exiting the target page, destroy the target page singleton object with the singleton object destruction attribute set to destroyed.

5. The method of claim 3, wherein, Before the page routing configuration table of the target application is asynchronously loaded, the method further comprises: Obtain at least one global singleton service information of the target application; Respectively set the business function enable state corresponding to each global singleton service information, to generate global singleton object information of the target application; The at least use the page singleton object information to create the page routing configuration table of the target application, comprising: Use the page singleton object information and the global singleton object information to build the page routing configuration table of the target application.

6. The method of claim 5, wherein, Also include: In the case of opening the target page of the target application, obtain each global singleton service information in the global singleton object information in the page routing configuration table; For the global singleton service information with the business function enablement state being enabled, it is queried in the preset object pool whether there is a target global singleton object corresponding to the global singleton service information, if yes, the target global singleton object is loaded, if not, the target global singleton object is created by using the global singleton service information, and the target global singleton object is added to the preset object pool.

7. The method of claim 1, wherein, The page route definition information includes a page path and a page class name of a page of the target application, and the target page route definition information of the target page of the target application is queried in the page route configuration table, including: In the case that the user accesses the target page of the target application through a routing mechanism, the page path of the target page is obtained; the page path is used as a query condition to query in the page route configuration table whether the page route definition information matching the page path exists, if yes, the page route definition information is confirmed as the target page route definition information of the target page; In the case that the target page accessed by the user is a hard-coded page, the page class name of the target page is obtained; the page class name is used as a query condition to query in the page route configuration table whether the page route definition information matching the page class name exists, if yes, the page route definition information is confirmed as the target page route definition information of the target page.

8. A singleton object loading apparatus, characterized by comprising: Including: a page route configuration table loading unit, a page route definition information query unit, a page singleton service information confirmation unit, a page singleton object query unit and a page singleton object loading unit, The page route configuration table loading unit is configured to load a page route configuration table of a target application asynchronously in the case that the terminal device starts the target application, wherein the page route configuration table includes page singleton object information of the target application, the page singleton object information includes page route definition information of each page of the target application, at least one page singleton service information in a mapping relationship with the page route definition information, and a business function enablement state corresponding to the page singleton service information; The page route definition information query unit is configured to query in the page route configuration table whether target page route definition information of a target page of the target application exists in the case that the target page of the target application is opened, if yes, triggering the page singleton service information confirmation unit; The page singleton service information confirmation unit is configured to confirm each target page singleton service information in a mapping relationship with the target page route definition information; The page singleton object query unit is configured to query in a preset object pool whether a target page singleton object corresponding to the target page singleton service information exists in the case that the business function enablement state of the target page singleton service information is enabled, if yes, triggering the page singleton object loading unit; The page singleton object loading unit is configured to load the target page singleton object; The preset object pool stores a plurality of configured singleton objects.

9. A computer-readable storage medium having stored thereon a program, characterized in that, The program is executed by the processor to implement the singleton object loading method in any one of claims 1 to 7.

10. An electronic device, comprising: The electronic device includes at least one processor, at least one memory connected with the processor, and a bus; wherein the processor, the memory and the bus complete mutual communication; the processor is used to call program instructions in the memory to execute the singleton object loading method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method of persistently loading page

    CN107679108A

  • Single-example object creation method, system and device

    CN109284094A