Display apparatus and instance creation method
By using target naming rules in object-oriented programming to determine implicit mapping between type parameters and implementation classes, the coding complexity and low development efficiency when creating objects of different implementation classes is solved, and a simpler and more efficient instance creation process is achieved.
Patent Information
- Application Number
- CN202410905711.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2025-03-04
AI Technical Summary
In object-oriented programming, when creating objects of different implementation classes of the same interface, it is necessary to maintain the mapping relationship between type parameters and implementation classes, resulting in increased coding complexity and reduced development efficiency.
By receiving an instance creation request, call the creation instance function according to the target naming rules, determine the target class name of the target implementation class based on the target type parameters and the identification of the target interface, and create an instance of the target implementation class through the reflection mechanism to avoid using mapping tables.
It reduces the difficulty of maintaining the mapping relationship between type parameters and implementation classes, reduces the coding complexity, and improves development efficiency.
Smart Images

Figure CN119556890A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to object programming technology, and more specifically, to a display device and an instance creation method. Background Art
[0002] In object-oriented programming practice, it is often necessary to create objects with different implementations of the same interface in one method. The creation process usually determines the specific implementation class based on the type parameter, and then creates the object of the implementation class through reflection. The mapping relationship between the type parameter and the implementation class needs to be maintained by a mapping table. The mapping table can be automatically collected using annotations at compile time, or it can be directly written into the source code through coding. However, no matter which of the above methods is based on the mapping table to maintain the mapping relationship between type parameters and implementation classes, it increases the coding complexity and reduces the development efficiency. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, an embodiment of the present application provides a display device and an instance creation method.
[0004] In a first aspect, an embodiment of the present application provides a display device, comprising: a controller, configured to: receive an instance creation request, the instance creation request being used to request the creation of an instance of a target implementation class corresponding to a target interface, the instance creation request carrying a target type parameter, the target type parameter being used to indicate the target implementation class; call an instance creation function to determine the target class name of the target implementation class according to a target naming rule, based on the target type parameter and an identifier of the target interface, the instance creation function being used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class including the target implementation class, the target naming rule being used to indicate a naming rule of at least one second implementation class corresponding to the target type parameter, the at least one second implementation class including the target implementation class; based on the target class name, call the constructor of the target implementation class through a reflection mechanism to create an instance of the target implementation class.
[0005] In a second aspect, an embodiment of the present application provides an instance creation method, comprising: receiving an instance creation request, the instance creation request being used to request the creation of an instance of a target implementation class corresponding to a target interface, the instance creation request carrying a target type parameter, the target type parameter being used to indicate the target implementation class; calling an instance creation function to determine the target class name of the target implementation class according to a target naming rule, based on the target type parameter and an identifier of the target interface, the instance creation function being used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class including the target implementation class, the target naming rule being used to indicate a naming rule of at least one second implementation class corresponding to the target type parameter, the at least one second implementation class including the target implementation class; based on the target class name, calling the constructor of the target implementation class through a reflection mechanism to create an instance of the target implementation class.
[0006] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, including: a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the instance creation method shown in the second aspect is implemented.
[0007] In a fourth aspect, an embodiment of the present application provides a computer program product, comprising: when the computer program product is run on a computer, the computer implements the instance creation method shown in the second aspect.
[0008] The technical solution provided by the embodiment of the present application has the following advantages over the prior art: in the embodiment of the present application, an instance creation request is received, the instance creation request is used to request the creation of an instance of a target implementation class corresponding to a target interface, the instance creation request carries a target type parameter, and the target type parameter is used to indicate the target implementation class; a create instance function is called to determine the target class name of the target implementation class according to the target naming rule, based on the target type parameter and the identifier of the target interface, the create instance function is used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class includes the target implementation class, the target naming rule is used to indicate the naming rule of at least one second implementation class corresponding to the target type parameter, and the at least one second implementation class includes the target implementation class; based on the target class name, the constructor of the target implementation class is called through a reflection mechanism to create an instance of the target implementation class. Thus, in the embodiment of the present application, a mapping table is not used to maintain the mapping relationship between type parameters and implementation classes. Instead, a target naming rule is used to implement an implicit mapping between type parameters and implementation classes. Appropriate target naming rules are set in the coding stage, and the target class name of the target implementation class is quickly determined based on the target naming rules, target type parameters, and target interface identifiers during runtime, thereby reducing the difficulty of maintaining the mapping relationship between type parameters and implementation classes, reducing coding complexity, and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0010] Figure 1 An operation scenario between a display device and a control device according to some embodiments is shown;
[0011] Figure 2 shows a hardware configuration block diagram of a control device 100 according to some embodiments;
[0012] Figure 3 shows a hardware configuration block diagram of a display device 200 according to some embodiments;
[0013] Figure 4 shows a software configuration diagram in a display device 200 according to some embodiments;
[0014] Figure 5 One of the flowcharts of the instance creation method according to some embodiments is shown;
[0015] Figure 6 A second flowchart of an example creation method according to some embodiments is shown;
[0016] Figure 7 A third flowchart of an example creation method according to some embodiments is shown;
[0017] Figure 8 A fourth flowchart of an example creation method according to some embodiments is shown;
[0018] Fig. 9 A fifth flowchart of an example creation method according to some embodiments is shown;
[0019] Fig.10 A sixth flowchart of an example creation method according to some embodiments is shown. DETAILED DESCRIPTION
[0020] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0021] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0022] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0023] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0024] The display device provided in the embodiments of the present application may have various implementation forms, for example, it may be a television, a smart television, a laser projection device, a monitor, an electronic bulletin board, an electronic table, a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, etc.
[0025] Figure 1 FIG. 1 is a schematic diagram of an operation scenario between a display device and a control device according to an embodiment, wherein the control device includes an intelligent device or a control apparatus. Figure 1 As shown, the user can operate the display device 200 through the smart device 300 or the control apparatus 100 .
[0026] In some embodiments, the control device 100 may be a remote controller, and the communication between the remote controller and the display device includes infrared protocol communication or Bluetooth protocol communication, and other short-range communication methods, and the display device 200 is controlled wirelessly or wired. The user may control the display device 200 by inputting user commands through buttons on the remote controller, voice input, control panel input, etc.
[0027] In some embodiments, a smart device 300 (such as a mobile terminal, a tablet computer, a computer, a laptop computer, etc.) may also be used to control the display device 200. For example, the display device 200 is controlled using an application running on the smart device.
[0028] In some embodiments, the display device may not use the above-mentioned smart device or control device to receive instructions, but may receive user control through touch or gestures.
[0029] In some embodiments, the display device 200 can also be controlled in a manner other than the control device 100 and the smart device 300. For example, the user's voice command control can be directly received through a module for obtaining voice commands configured inside the display device 200, or the user's voice command control can be received through a voice control device set outside the display device 200.
[0030] In some embodiments, the display device 200 also communicates data with the server 400. The display device 200 may be allowed to communicate via a local area network (LAN), a wireless local area network (WLAN), and other networks. The server 400 may provide various content and interactions to the display device 200. The server 400 may be one cluster or multiple clusters, and may include one or more types of servers.
[0031] Figure 2 Schematically shows a block diagram of a configuration of the control device 100 according to an exemplary embodiment. Figure 2 As shown, the control device 100 includes a controller 110, a communication interface 130, a user input / output interface 140, an external memory, and a power supply. The control device 100 can receive an input operation instruction from a user, and convert the operation instruction into an instruction that can be recognized and responded to by the display device 200, playing the role of an interactive intermediary between the user and the display device 200.
[0032] like Figure 3 The display device 200 includes at least one of a tuner and demodulator 210, a communicator 220, a detector 230, an external device interface 240, a controller 250, a display 260, an audio output interface 270, a user interface 280, an external memory, and a power supply.
[0033] In some embodiments, the controller includes a processor, a video processor, an audio processor, a graphics processor, a RAM, a ROM, and a first interface to an nth interface for input / output.
[0034] The display 260 includes a display screen component for presenting images, and a driving component for driving image display, which is used to receive image signals output from the controller, and display video content, image content, and menu control interface components and user control UI interface.
[0035] The display 260 may be a liquid crystal display, an OLED display, or a projection display, and may also be a projection device and a projection screen.
[0036] The communicator 220 is a component for communicating with an external device or server according to various communication protocol types. For example, the communicator may include at least one of a Wifi module, a Bluetooth module, a wired Ethernet module, and other network communication protocol chips or near field communication protocol chips, and an infrared receiver. The display device 200 can establish transmission and reception of control signals and data signals with the external control device 100 or the server 400 through the communicator 220.
[0037] The user interface 280 can be used to receive control signals from the control device 100 (such as an infrared remote controller, etc.) It can also be used to directly receive user input operation instructions and convert the operation instructions into instructions that the display device 200 can recognize and respond to, which can be called a user input interface.
[0038] The detector 230 is used to collect signals from the external environment or the external interaction. For example, the detector 230 includes a light receiver, a sensor for collecting the intensity of ambient light; or, the detector 230 includes an image collector, such as a camera, which can be used to collect external environment scenes, user attributes or user interaction gestures; or, the detector 230 includes a sound collector, such as a microphone, etc., for receiving external sounds.
[0039] The external device interface 240 may include, but is not limited to, any one or more of the following interfaces: a high-definition multimedia interface (HDMI), an analog or digital high-definition component input interface (component), a composite video input interface (CVBS), a USB input interface (USB), an RGB port, etc. It may also be a composite input / output interface formed by the above multiple interfaces.
[0040] The tuner-demodulator 210 receives broadcast television signals via wired or wireless reception, and demodulates audio and video signals, such as EPG data signals, from a plurality of wireless or wired broadcast television signals.
[0041] In some embodiments, the controller 250 and the tuner-demodulator 210 may be located in different separate devices, that is, the tuner-demodulator 210 may also be located in an external device of the main device where the controller 250 is located, such as an external set-top box.
[0042] The controller 250 controls the operation of the display device and responds to user operations through various software control programs stored in the memory (internal memory or external memory). The controller 250 controls the overall operation of the display device 200. For example, in response to receiving a user command for selecting a UI object to be displayed on the display 260, the controller 250 can perform operations related to the object selected by the user command.
[0043] In some embodiments, the controller includes a central processing unit (CPU), a video processor, an audio processor, a graphics processing unit (GPU), and at least one of a random access memory (RAM), a read-only memory (ROM), a first interface to an nth interface for input / output, a communication bus, etc.
[0044] Among them, RAM, also called main memory, is an internal memory that directly exchanges data with the controller. It can be read and written at any time (except when refreshed), and it is very fast. It is usually used as a temporary data storage medium for operating systems or other running programs. The biggest difference between it and ROM is the volatility of data, that is, once the power is cut off, the stored data will be lost. RAM is used in computers and digital systems to temporarily store programs, data and intermediate results. ROM works in a non-destructive read-out mode and can only read but not write information. Once the information is written, it is fixed, and even if the power is cut off, the information will not be lost, so it is also called fixed memory.
[0045] The user may input a user command through a graphical user interface (GUI) displayed on the display 260, and the user input interface receives the user input command through the graphical user interface (GUI). Alternatively, the user may input a user command through a specific sound or gesture, and the user input interface recognizes the sound or gesture through a sensor to receive the user input command.
[0046] "User interface" is the medium interface for interaction and information exchange between applications or operating systems and users. It realizes the conversion between the internal form of information and the form acceptable to users. The commonly used form of user interface is the Graphical User Interface (GUI), which refers to the user interface related to computer operation displayed in a graphical way. It can be an icon, window, control or other interface element displayed on the display screen of a display device, where the control can include icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets and other visual interface elements.
[0047] The current technology for dynamically creating instances generally requires automatically collecting class information of related implementation classes through annotations at compile time, and creating instances of implementation classes through reflection at runtime; or manually collecting and maintaining class information of implementation classes, and creating instances of implementation classes through reflection at runtime. The first method requires a special annotation generator with extremely complex logic; the second method requires manual maintenance of the information table, which needs to be updated when adding or deleting related classes. Therefore, the current related technology uses a mapping table to maintain the mapping relationship between type parameters and implementation classes, which makes the coding process complex and the development efficiency low.
[0048] The present application embodiment provides a display device and an instance creation method, wherein the display device can implement the instance creation method provided in the present application embodiment or the functional module or functional entity in the display device can implement the instance creation method provided in the present application embodiment. The display device includes: a controller corresponding to the above Figure 3 Controller 250 in.
[0049] In some embodiments of the present application, a controller is configured to: receive an instance creation request, the instance creation request is used to request the creation of an instance of a target implementation class corresponding to a target interface, the instance creation request carries a target type parameter, and the target type parameter is used to indicate the target implementation class; call an instance creation function to determine the target class name of the target implementation class according to a target naming rule, based on the target type parameter and an identifier of the target interface, the instance creation function is used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class includes the target implementation class, the target naming rule is used to indicate a naming rule of at least one second implementation class corresponding to the target type parameter, the at least one second implementation class includes the target implementation class; based on the target class name, call the constructor of the target implementation class through a reflection mechanism to create an instance of the target implementation class.
[0050] Among them, the instance creation request refers to the request to create the object instance issued to the system when an object instance of a specific class is needed to perform related operations or complete specific tasks during the program running process. Instance creation requests are usually triggered in the following situations: executing a specific business logic, when the business process needs to use the function of a class, a request to create an instance of the class will be requested; responding to external inputs or events, such as user operations, receiving network requests, etc., triggering the creation of instances of related classes to process these inputs or events; data processing and conversion, when specific processing or conversion of data is required, an instance of the corresponding processing class is created; dependency injection, in the dependency injection architecture, when a component needs to rely on an instance of another component, a creation request will be triggered; resource allocation and management, such as creating instances of resource management classes such as database connections and file read and write objects. The specific scenario in which the instance creation request is triggered is not limited in the embodiments of this application.
[0051] The instance creation function is used to create an instance of the implementation class of the interface and return the created instance. The constructor is the constructor of the instance of the implementation class.
[0052] The interface defines a set of specifications and method declarations, which stipulates the functions that the implementation class should have. The implementation class specifically implements the methods defined in the interface, thereby providing a specific implementation for the interface. An instance is obtained by creating an object of the implementation class, which represents an entity with a specific state and behavior that actually exists when the program is running. The interface sets standards and contracts for the implementation class, and the implementation class must follow the provisions of the interface. The instance is the specific manifestation of the implementation class at runtime, and the functions provided by the implementation class can be used by operating the instance.
[0053] Among them, an interface can correspond to one or more implementation classes, and the one or more implementation classes can implement the specifications and method declarations defined by the interface.
[0054] Among them, at least one first implementation class corresponding to the target interface can implement the specifications and method declarations defined by the target interface. At least one implementation class can be the implementation class corresponding to each of the target interfaces called by multiple applications. For example, a "player" interface is defined, and multiple player applications correspond to different implementation classes for the "player" interface. At least one implementation class can also be a different implementation class of the target interface called by an application. For example, in an online shopping application, a "payment method" interface is defined, and then there are different implementation classes such as "aaa payment", "bbb payment", and "ccc payment". When processing payment, the application calls the method defined by the interface without caring about which specific payment method implementation class is working.
[0055] Among them, at least one second implementation class is an implementation class corresponding to different interfaces in the same application.
[0056] The target naming rule may be used to determine the naming of the implementation class of an interface of an application, or may be used to determine the naming of the implementation classes of interfaces of multiple applications. The specific naming rule may be determined based on actual conditions and is not limited here.
[0057] Exemplarily, application A includes implementation class 1 corresponding to interface 1, implementation class 2 corresponding to interface 2, and implementation class 3 corresponding to interface 3; application B includes implementation class 4 corresponding to interface 1, implementation class 5 corresponding to interface 2, and implementation class 6 corresponding to interface 4; application C includes implementation class 7 corresponding to interface 2, implementation class 8 corresponding to interface 3, and implementation class 9 corresponding to interface 5. If the target interface is interface 2 and the target application is application C, then at least one first implementation class includes implementation class 2, implementation class 5, and implementation class 7; at least one second implementation class includes implementation class 7 corresponding to interface 2, implementation class 8 corresponding to interface 3, and implementation class 9 corresponding to interface 5, and the target implementation class is implementation class 7.
[0058] In the embodiment of the present application, a mapping table is not used to maintain the mapping relationship between type parameters and implementation classes. Instead, a target naming rule is used to implement an implicit mapping between type parameters and implementation classes. Appropriate target naming rules are set during the coding stage, and the target class name of the target implementation class is quickly determined based on the target naming rules, target type parameters, and target interface identifiers during runtime, thereby reducing the difficulty of maintaining the mapping relationship between type parameters and implementation classes, reducing coding complexity, and improving development efficiency.
[0059] In some embodiments of the present application, the controller is specifically configured to: call the create instance function through the target factory class according to the target naming rule, determine the target class name of the target implementation class according to the target type parameter and the identifier of the target interface, and the target factory class is used to manage the at least one second implementation class.
[0060] The role of the factory class is to create instances of the implementation class. It encapsulates the object creation process so that external code does not need to directly care about the details of instance creation. The factory class makes the instance creation process more flexible and manageable, and can create different implementation class instances according to different conditions and requirements.
[0061] There is a close relationship between interfaces, implementation classes, instances, and factory classes, which together constitute important concepts in object-oriented programming. These four work together to implement the principles of encapsulation, polymorphism, and decoupling in object-oriented programming, and improve the maintainability, scalability, and reusability of the code.
[0062] In the embodiment of the present application, a factory class is introduced in the process of creating an instance of an implementation class, so that plug-in can be implemented to facilitate the management of instances of the implementation class.
[0063] In some embodiments of the present application, the naming of the target factory class is determined according to the target naming rule based on the target type parameter and the identifier of the target factory class; the controller is specifically configured to: call the create instance function through the target factory class to replace the identifier of the target factory class in the naming of the target factory class with the identifier of the target interface, and determine the target class name.
[0064] It can be understood that the target class name implemented by the target can be obtained according to the name of the factory (including type parameters) - factory + the identifier of the target interface. For example, the type parameter is "xxx", the identifier of the target interface is "yyy", and the factory is named com.iii.jjj.kkkk.xxxfactory, then the target class name is "com.iii.jjj.kkkk.xxxyyy".
[0065] In the embodiment of the present application, the target naming rule and the factory naming are bound, so that the target class name of the target implementation class can be quickly determined.
[0066] In some embodiments of the present application, the naming of the target factory class is determined according to the target naming rule based on the identifier of the target factory class; the controller is specifically configured to: call the create instance function through the target factory class to replace the identifier of the target factory class in the naming of the target factory class with the target type parameter and the identifier of the target interface, and determine the target class name.
[0067] It can be understood that the target class name implemented by the target can be obtained according to the name of the factory (excluding type parameters) - factory + type parameter + interface identifier. For example, the type parameter is "xxx", the identifier of the target interface is "yyy", and the factory is named com.iii.jjj.kkkk.factory, then the target class name is "com.iii.jjj.kkkk.xxxyyy".
[0068] In the embodiment of the present application, the naming of the factory is determined according to the target naming rule, so the package name of the factory and the implementation class of other interfaces are the same, which facilitates plug-in management and code decoupling.
[0069] In some embodiments of the present application, the naming of the factory class includes a package name and a class name, and the package name includes the target type parameter.
[0070] For example, the factory is named com.iii.jjj.kkkk.XXX.xxxfactory, where "com.iii.jjj.kkkk.XXX." is the package name, "xxxfactory" is the class name, and "XXX" and "xxx" are the uppercase and lowercase forms of the target type parameter. Including the target type parameter (ie, "XXX") in the package name facilitates the sub-package management of the implementation classes of different types of parameters, which can improve management efficiency.
[0071] In some embodiments of the present application, the target naming rule includes a first slot corresponding to a type parameter and a second slot corresponding to an interface identifier; the controller is specifically configured to: determine the target class name by calling the create instance function to fill the target type parameter and the identifier of the target interface into the first slot and the second slot of the target naming rule respectively.
[0072] In the embodiment of the present application, the specific form of the target naming rule is not limited. It is only necessary to limit the target naming rule to include a first slot corresponding to a type parameter and a second slot corresponding to an interface identifier. Then, when determining the class name of the target implementation class, it is only necessary to fill the target type parameter and the identifier of the target interface into the first slot and the second slot of the target naming rule respectively to determine the target class name.
[0073] In some embodiments of the present application, the first slot is located in the area where the package name in the target naming rule is located, or the first slot is located in the area where the class name in the target naming rule is located; the second slot is located in the area where the class name in the target naming rule is located.
[0074] The first slot is located in the area where the package name in the target naming rule is located, which can facilitate the distinction between the package names of implementation classes of different applications. The first slot is located in the area where the class name in the target naming rule is located, which can facilitate the distinction between the class names of implementation classes of different applications.
[0075] Exemplarily, the target naming rule is: com.iii.(1).kkkk.zzz(2), where "com.iii.(1).kkkk." is the package name, "(1)" is the first slot, "zzz(2)" is the class name, and "(2)" is the second slot.
[0076] Exemplarily, the target naming rule is: com.iii.jjj.kkkk.(1)mmm(2), where "com.iii.jjj.kkkk." is the package name, "(1)mmm(2)" is the class name, "(1)" is the first slot, and "(2)" is the second slot.
[0077] In some embodiments of the present application, the controller is further configured to: before receiving an instance creation request, generate a resource acquisition request for the target resource in response to a user's triggering operation on the target resource; generate the instance creation request based on the resource acquisition request; and after creating an instance of the target implementation class, return the target resource based on the instance of the target implementation class.
[0078] In an embodiment of the present application, an instance creation request is generated in response to a user's triggering operation on a target resource, and then the target resource is returned to the user based on an instance of the target implementation class corresponding to the instance creation request, thereby quickly generating an instance of the target implementation class corresponding to the target resource and quickly returning the target resource to the user.
[0079] In an embodiment of the present application, during the coding stage, a target naming rule for the implementation class is set, which has simple logic and flexible expansion. When adding or deleting implementation classes, there is no need to specially maintain a mapping table between the implementation class and the type parameters. Therefore, the coding complexity can be reduced and the coding efficiency can be improved.
[0080] The target naming rule method provided in the embodiment of the present application is used to implement implicit mapping between type parameters and implementation classes. The same naming rule can be set for different interfaces of the same application, or the same naming rule can be set for different interfaces of different applications. This can effectively reduce the complexity of coding and improve development efficiency.
[0081] See also Figure 4 In some embodiments, the system is divided into four layers, from top to bottom, namely, the application layer (Applications) layer (referred to as "application layer"), the application framework layer (Application Framework) layer (referred to as "framework layer"), the Android runtime (Android runtime) and system library layer (referred to as "system runtime library layer"), and the kernel layer.
[0082] In some embodiments, at least one application is running in the application layer, and these applications can be window programs, system settings programs, clock programs, etc. provided by the operating system, or applications developed by third-party developers. In specific implementations, the application packages in the application layer are not limited to the above examples.
[0083] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications. The application framework layer includes some predefined functions. The application framework layer is equivalent to a processing center that determines the actions that applications in the application layer take. Through the API interface, applications can access system resources and obtain system services during execution.
[0084] like Figure 4 As shown, in the embodiment of the present application, the application framework layer includes managers, content providers, etc., wherein the manager includes at least one of the following modules: an activity manager (ActivityManager) is used to interact with all activities running in the system; a location manager (Location Manager) is used to provide system services or applications with access to system location services; a package manager (Package Manager) is used to retrieve various information related to the application package currently installed on the device; a notification manager (NotificationManager) is used to control the display and clearing of notification messages; a window manager (Window Manager) is used to manage icons, windows, toolbars, wallpapers, and desktop components on the user interface.
[0085] In some embodiments, the activity manager is used to manage the life cycle of each application and the common navigation back function, such as controlling the exit, opening, and back of the application. The window manager is used to manage all window programs, such as obtaining the display screen size, determining whether there is a status bar, locking the screen, capturing the screen, and controlling the display window changes (for example, reducing the display window, shaking the display, distorting the display, etc.).
[0086] In some embodiments, the system runtime layer provides support for the upper layer, namely the framework layer. When the framework layer is used, the Android operating system will run the C / C++ library contained in the system runtime layer to implement the functions to be implemented by the framework layer.
[0087] In some embodiments, the kernel layer is a layer between hardware and software. Figure 4 As shown, the kernel layer includes at least one of the following drivers: audio driver, display driver, Bluetooth driver, camera driver, WIFI driver, USB driver, HDMI driver, sensor driver (such as fingerprint sensor, temperature sensor, pressure sensor, etc.), and power driver, etc.
[0088] In order to explain this scheme in more detail, the following will be combined in an exemplary manner Figures 5 to 10 To explain, it is understandable that Figures 5 to 10The steps involved may include more steps or fewer steps in actual implementation, and the order of these steps may also be different, subject to the ability to implement the instance creation method provided in the embodiment of the present application. The instance creation method is applied to a display device controlled by a control device, and the execution subject of the instance creation method may be a display device, or a functional module or functional entity in the display device that can implement the instance creation method, which is not limited here. Moreover, the specific description of the instance creation method provided in the embodiment of the present application can refer to the relevant description of the above-mentioned display device, and the same or similar technical effects can be achieved, which will not be repeated here.
[0089] Figure 5 To provide a flowchart of the steps of implementing an instance creation method according to one or more embodiments of the present application, the instance creation method may include the following S501 to S503.
[0090] S501: Receive an instance creation request, where the instance creation request is used to request creation of an instance of a target implementation class corresponding to a target interface.
[0091] The instance creation request carries a target type parameter, and the target type parameter is used to indicate a target implementation class.
[0092] S502: Calling a create instance function determines the target class name of the target implementation class according to the target type parameter and the identifier of the target interface in accordance with the target naming rule.
[0093] Among them, the instance creation function is used to create an instance of at least one first implementation class corresponding to the target interface, and the at least one first implementation class includes the target implementation class. The target naming rule is used to indicate the naming rule of at least one second implementation class corresponding to the target type parameter, and the at least one second implementation class includes the target implementation class.
[0094] S503: Based on the target class name, the constructor of the target implementation class is called through a reflection mechanism to create an instance of the target implementation class.
[0095] In some embodiments of the present application, Figure 5 ,like Figure 6 As shown, the above step S502 can be specifically implemented through the following S502a.
[0096] S502a, calling the create instance function through the target factory class, according to the target naming rule, according to the target type parameter and the identifier of the target interface, to determine the target class name of the target implementation class.
[0097] The target factory class is used to manage the at least one second implementation class.
[0098] In some embodiments of the present application, the naming of the target factory class is determined according to the target naming rule based on the target type parameter and the identifier of the target factory class; Figure 6 ,like Figure 7 As shown, the above step S502a can be specifically implemented through the following S502a1.
[0099] S502a1, calling the create instance function through the target factory class to replace the identifier of the target factory class in the naming of the target factory class with the identifier of the target interface, and determine the target class name.
[0100] In some embodiments of the present application, the naming of the target factory class is determined according to the target naming rule based on the identifier of the target factory class; Figure 6 ,like Figure 8 As shown, the above step S502a can be specifically implemented by the following S502a2.
[0101] S502a2: The target factory class calls the create instance function to replace the identifier of the target factory class in the naming of the target factory class with the target type parameter and the identifier of the target interface, thereby determining the target class name.
[0102] In some embodiments of the present application, the naming of the factory class includes a package name and a class name, and the package name includes the target type parameter.
[0103] In some embodiments of the present application, the target naming rule includes a first slot corresponding to the type parameter and a second slot corresponding to the interface identifier; combined Figure 5 ,like Fig. 9 As shown, the above step S502 can be specifically implemented through the following S502b.
[0104] S502b, by calling the create instance function, filling the target type parameter and the identifier of the target interface into the first slot and the second slot of the target naming rule respectively, to determine the target class name.
[0105] In some embodiments of the present application, the first slot is located in the area where the package name in the target naming rule is located, or the first slot is located in the area where the class name in the target naming rule is located;
[0106] The second slot is in the area where the class name in the target naming rule is located.
[0107] In some embodiments of the present application, Figure 5 ,like Fig.10 As shown, before the above S501, the instance creation method provided in the embodiment of the present application may further include the following S504 and S505, and after the above S503, the instance creation method provided in the embodiment of the present application may further include the following S506.
[0108] S504: In response to the user's triggering operation on the target resource, a resource acquisition request for the target resource is generated.
[0109] S505: Generate the instance creation request according to the resource acquisition request.
[0110] S506: After creating the instance of the target implementation class, return the target resource based on the instance of the target implementation class.
[0111] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the various processes of the above-mentioned instance creation method and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0112] The computer readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0113] The present invention provides a computer program product, comprising: when the computer program product is run on a computer, the computer is enabled to implement the above instance creation method.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0115] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
Claims
1. A display device, characterized in that: include: The controller is configured to: receive an instance creation request, the instance creation request is used to request to create an instance of a target implementation class corresponding to a target interface, the instance creation request carries a target type parameter, and the target type parameter is used to indicate the target implementation class; Calling a create instance function to determine the target class name of the target implementation class according to the target type parameter and the identifier of the target interface in accordance with the target naming rule, the create instance function is used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class includes the target implementation class, the target naming rule is used to indicate the naming rule of at least one second implementation class corresponding to the target type parameter, the at least one second implementation class includes the target implementation class; Based on the target class name, the constructor of the target implementation class is called through a reflection mechanism to create an instance of the target implementation class.
2. The display device according to claim 1, characterized in that The controller is specifically configured as follows: The target factory class calls the create instance function according to the target naming rule, determines the target class name of the target implementation class according to the target type parameter and the identifier of the target interface, and the target factory class is used to manage the at least one second implementation class.
3. The display device according to claim 2, characterized in that The naming of the target factory class is determined according to the target naming rule based on the target type parameter and the identifier of the target factory class; the controller is specifically configured as follows: The target factory class calls the create instance function to replace the identifier of the target factory class in the naming of the target factory class with the identifier of the target interface, thereby determining the target class name.
4. The display device according to claim 2, characterized in that The naming of the target factory class is determined according to the target naming rule based on the identifier of the target factory class; the controller is specifically configured as follows: The target factory class calls the create instance function to replace the identifier of the target factory class in the naming of the target factory class with the target type parameter and the identifier of the target interface, thereby determining the target class name.
5. The display device according to claim 3 or 4, characterized in that: The naming of the factory class includes a package name and a class name, and the package name includes the target type parameter.
6. The display device according to claim 1 or 2, characterized in that: The target naming rule includes a first slot corresponding to a type parameter and a second slot corresponding to an interface identifier; the controller is specifically configured as follows: The target class name is determined by calling the create instance function to fill the target type parameter and the identifier of the target interface into the first slot and the second slot of the target naming rule respectively.
7. The display device according to claim 6, characterized in that The first slot is located in the area where the package name in the target naming rule is located, or the first slot is located in the area where the class name in the target naming rule is located; The second slot is located in the area where the class name in the target naming rule is located.
8. The display device according to any one of claims 1 to 4, characterized in that: The controller is further configured to: before receiving the instance creation request, generate a resource acquisition request for the target resource in response to a trigger operation of the target resource by a user; Generate the instance creation request according to the resource acquisition request; After creating the instance of the target implementation class, the target resource is returned based on the instance of the target implementation class.
9. An instance creation method, characterized in that: Applied to display devices, including: Receive an instance creation request, the instance creation request is used to request the creation of an instance of a target implementation class corresponding to a target interface, the instance creation request carries a target type parameter, and the target type parameter is used to indicate the target implementation class; Calling a create instance function to determine the target class name of the target implementation class according to the target type parameter and the identifier of the target interface in accordance with the target naming rule, the create instance function is used to create an instance of at least one first implementation class corresponding to the target interface, the at least one first implementation class includes the target implementation class, the target naming rule is used to indicate the naming rule of at least one second implementation class corresponding to the target type parameter, the at least one second implementation class includes the target implementation class; Based on the target class name, the constructor of the target implementation class is called through a reflection mechanism to create an instance of the target implementation class.
10. A computer-readable storage medium, characterized in that: include: A computer program is stored on a computer-readable storage medium, and when the computer program is executed by a processor, the instance creation method according to claim 9 is implemented.