CN106095508B - A kind of method and device of strategy load and injection - Google Patents

A kind of method and device of strategy load and injection Download PDF

Info

Publication number
CN106095508B
CN106095508B CN201610439123.4A CN201610439123A CN106095508B CN 106095508 B CN106095508 B CN 106095508B CN 201610439123 A CN201610439123 A CN 201610439123A CN 106095508 B CN106095508 B CN 106095508B
Authority
CN
China
Prior art keywords
adapter
injection
strategy
load
injected
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610439123.4A
Other languages
Chinese (zh)
Other versions
CN106095508A (en
Inventor
孔德勇
邹舟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Fortune Man Network Inc
Original Assignee
Hangzhou Fortune Man Network Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Fortune Man Network Inc filed Critical Hangzhou Fortune Man Network Inc
Priority to CN201610439123.4A priority Critical patent/CN106095508B/en
Publication of CN106095508A publication Critical patent/CN106095508A/en
Application granted granted Critical
Publication of CN106095508B publication Critical patent/CN106095508B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses the method and devices of a kind of strategy load and injection, this method comprises: receiving the instruction of web container starting, on-demand loading adapter profile is simultaneously loaded into adapter context;Program is loaded, and the strategy injection factory of initialization response;The strategy injection factory is called to realize that class is addressed to sort to the adapter in configuration range;The adapter that selection meets preset condition from adapter is initialized and is injected.The method and device of strategy load and injection provided by the present invention, can start respective modules as needed, and at runtime by tactful load operating, to support the individual business demand of different clients.The application can real Uniform Product version, atomization various businesses implementation pattern.

Description

A kind of method and device of strategy load and injection
Technical field
The present invention relates to web program personalization technology field, a kind of method more particularly to strategy load and injection and Device.
Background technique
With the development of science and technology, web program individual demand is more and more, and otherness is also increasing, web journey The configuration of sequence commercialization bring individual character or version are various, and programmed logic is complicated, difficult in maintenance, and project-based exploitation and maintenance is brought Biggish manpower costs.
Maven provides a series of plug-in unit of dynamic releases such as war, assembly, on the basis of product modular exploitation, It can need to realize that different module assembly is issued according to different.OSGi can dynamically pacify loading, unloading, start and stop application Disparate modules in program;For a certain particular module in application program, container can run multiple versions of the module simultaneously This.
Maven dynamic release can satisfy independently giving out a contract for a project for individual demand, but cause product released version excessive.OSGi It needs to develop and follows new specification, learning cost is higher, and has to operate in new container.Therefore, both the above scheme is all It can only accomplish the division of module level, and the operation for more sub-layers time, load strategy can not be supported.
Summary of the invention
The object of the present invention is to provide the method and devices of a kind of strategy load and injection, it is therefore intended that solves web program The configuration of commercialization bring individual character or version are various, and programmed logic is complicated, difficult in maintenance, the higher problem of human cost.
In order to solve the above technical problems, the present invention provides the method for a kind of strategy load and injection, comprising:
The instruction of web container starting is received, on-demand loading adapter profile is simultaneously loaded into adapter context;
Program is loaded, and the strategy injection factory of initialization response;
The strategy injection factory is called to realize that class is addressed to sort to the adapter in configuration range;
The adapter that selection meets preset condition from adapter is initialized and is injected.
Optionally, strategy injection factory is the addressing defined according to disparate modules and adapter level definition rule Algorithm, the adapter for meeting the preset condition excellent are first injected into.
Optionally, the adapter that selection meets preset condition from adapter, which initialize with injection, includes:
Distance is initialized and injected by the adapter in the injection nearest path service.
Optionally, the adapter that selection meets preset condition from adapter, which initialize with injection, includes:
The adapter of highest priority is initialized and injected according to priority orders.
Optionally, it is described to program carry out load include:
Lazy load is carried out to program by the lazyload of spring.
The present invention also provides the devices of a kind of strategy load and injection, comprising:
Command reception module, for receiving the instruction of web container starting, on-demand loading adapter profile is simultaneously loaded into suitable Orchestration context;
Program loading module, for being loaded to program, and the strategy injection factory of initialization response;
Sorting module is addressed, for calling the strategy injection factory to realize that class is sought to the adapter in configuration range Location sequence;
Injection module is initialized and is injected for the adapter that selection meets preset condition from adapter.
Optionally, strategy injection factory is the addressing defined according to disparate modules and adapter level definition rule Algorithm, the adapter for meeting the preset condition excellent are first injected into.
Optionally, the injection module is specifically used for:
Distance is initialized and injected by the adapter in the injection nearest path service.
Optionally, the injection module is specifically used for:
The highest adapter of priority is initialized and injected according to priority orders.
Optionally, described program loading module is specifically used for:
Lazy load is carried out to program by the lazyload of spring.
The method and device of strategy load and injection provided by the present invention is pressed by receiving the instruction of web container starting Adapter profile need to be loaded and be loaded into adapter context;Program is loaded, and the strategy injection of initialization response Factory;Regulative strategy injects factory and realizes that class is addressed to sort to the adapter in configuration range;It is selected from adapter full The adapter of sufficient preset condition is initialized and is injected.The method and device of strategy load and injection provided by the present invention, Respective modules can be started as needed, and at runtime by tactful load operating, to support the personalization of different clients Business demand.The application can real Uniform Product version, atomization various businesses implementation pattern.
Detailed description of the invention
It, below will be to embodiment or existing for the clearer technical solution for illustrating the embodiment of the present invention or the prior art Attached drawing needed in technical description is briefly described, it should be apparent that, the accompanying drawings in the following description is only this hair Bright some embodiments for those of ordinary skill in the art without creative efforts, can be with root Other attached drawings are obtained according to these attached drawings.
Fig. 1 is the flow chart of strategy load and a kind of specific embodiment of the method for injection provided by the present invention;
Fig. 2 is the flow chart of strategy load and another specific embodiment of the method for injection provided by the present invention;
Fig. 3 sheet is to invent provided module design schematic diagram;
Fig. 4 is the structural block diagram of strategy load and the device of injection provided in an embodiment of the present invention.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, with reference to the accompanying drawings and detailed description The present invention is described in further detail.Obviously, described embodiments are only a part of the embodiments of the present invention, rather than Whole embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not making creative work premise Under every other embodiment obtained, shall fall within the protection scope of the present invention.
Flow chart such as Fig. 1 institute of strategy load and a kind of specific embodiment of the method for injection provided by the present invention Show, this method comprises:
Step S101: receiving the instruction of web container starting, and on-demand loading adapter profile is simultaneously loaded into adapter or more Text;
Step S102: loading program, and the strategy injection factory of initialization response;
Step S103: the strategy injection factory is called to realize that class is addressed to sort to the adapter in configuration range;
Step S104: the adapter that selection meets preset condition from adapter is initialized and is injected.
The method and device of strategy load and injection provided by the present invention is pressed by receiving the instruction of web container starting Adapter profile need to be loaded and be loaded into adapter context;Program is loaded, and the strategy injection of initialization response Factory;Regulative strategy injects factory and realizes that class is addressed to sort to the adapter in configuration range;It is selected from adapter full The adapter of sufficient preset condition is initialized and is injected.The method and device of strategy load and injection provided by the present invention, Respective modules can be started as needed, and at runtime by tactful load operating, to support the personalization of different clients Business demand.The application can real Uniform Product version, atomization various businesses implementation pattern.The application is that client voluntarily expands Exhibition provides space, and client can carry out certain incremental expansion to product according to the special requirement of oneself.
It should be pointed out that it is provided by the present invention strategy load with injection method in, strategy injection factory be according to The addressing algorithm that disparate modules and adapter level definition rule define, the adapter for meeting the preset condition are preferentially infused Enter.
Specifically, nearest injecting strategy can be used in the present embodiment, according to company module and adapter level definition rule Addressing algorithm is then defined, distance realizes excellent be first injected by the adapter in the injection nearest path service.
Flow chart such as Fig. 2 institute of strategy load and another specific embodiment of the method for injection provided by the present invention Show, this method comprises:
Step S201: receiving the instruction of web container starting, and on-demand loading adapter profile is simultaneously loaded into adapter or more Text;
Step S202: loading program, and the strategy injection factory of initialization response;
Step S203: the strategy injection factory is called to realize that class is addressed to sort to the adapter in configuration range;
Step S204: distance is initialized and is injected by the adapter in the injection nearest path service.
The injecting strategy realized in the present embodiment is injection nearby, and certainly, the present invention is also the realization of other injecting strategies Reserved extension is provided, can realize the injecting strategy of other rules according to actual needs.It such as can will be excellent according to priority orders The first highest adapter of grade is initialized and is injected.
Based on any of the above embodiments, in the method for strategy load and injection provided by the present invention, to program The process loaded can be with specifically:
Lazy load is carried out to program by the lazyload of spring.It is of course also possible to use the mode being loaded directly into, this Realization of the invention is not influenced.
The specific implementation process of strategy load provided by the present invention and the method for injection is carried out below further detailed It illustrates.
As shown in Fig. 3 module design schematic diagram provided by the present invention, module design personnel need according to business function, fixed The business module function and sales counter adaptable interface of justice response.Developer's adapter different according to different sales counter producer writes It realizes class, and each realization is completely independent during realization, is not required to be concerned about cooperation, the competitive relation of sales counter manufacturer completely.
When function is realized, developer directly uses spring primary sound to explain@Autowired and carries out interface injection.
In the present embodiment, strategy injection factory uses nearest injecting strategy, i.e., fixed according to company module and adapter level Adopted rule defines addressing algorithm, and distance realizes excellent be first injected by the adapter in the injection nearest path service.
Wherein, adapter range is configured by assembly, only includes the adapter in assembly configuration Module just will do it the sequence of strategy injection nearby.
During realization, program carries out lazy load by the lazyload of spring, in web container starting, on demand Load adapter profile is simultaneously loaded into adapter context, the tactful factory of initialization response.
When program accesses for the first time, needs are injected according to@Autowired, call injecting strategy factory in configuration range Adapter realize that class is addressed to sort, and the adapter of minimum distance is initialized and is injected, complete function services.
The device of strategy load provided in an embodiment of the present invention and injection is introduced below, strategy described below adds Reference can be corresponded to each other with above-described strategy load with the method for injection with the device of injection by carrying.
Fig. 4 is the structural block diagram of strategy load and the device of injection provided in an embodiment of the present invention, is loaded referring to Fig. 4 strategy Device with injection may include:
Command reception module 100, for receiving the instruction of web container starting, on-demand loading adapter profile is simultaneously carried Enter adapter context;
Program loading module 200, for being loaded to program, and the strategy injection factory of initialization response;
Address sorting module 300, for call it is described strategy injection factory to configuration range in adapter realize class into Row addressing sequence;
Injection module 400 is initialized and is injected for the adapter that selection meets preset condition from adapter.
Wherein, above-mentioned strategy injection factory is that the addressing defined according to disparate modules and adapter level definition rule is calculated Method, the adapter for meeting the preset condition excellent are first injected into.
As a kind of specific embodiment, strategy load provided by the present invention can be with injection module in the device of injection It is specifically used for:
Distance is initialized and injected by the adapter in the injection nearest path service.
As a kind of specific embodiment, strategy load provided by the present invention and injection module in the device of injection are specific For:
The highest adapter of priority is initialized and injected according to priority orders.
On the basis of any of the above-described embodiment, strategy load provided by the present invention loads mould with program in the device of injection Block can be specifically used for:
Lazy load is carried out to program by the lazyload of spring.
The method and device of strategy load and injection provided by the present invention is pressed by receiving the instruction of web container starting Adapter profile need to be loaded and be loaded into adapter context;Program is loaded, and the strategy injection of initialization response Factory;Regulative strategy injects factory and realizes that class is addressed to sort to the adapter in configuration range;It is selected from adapter full The adapter of sufficient preset condition is initialized and is injected.
The method and device of strategy load provided by the present invention and injection passes through plan in service-oriented web product The mode slightly injected realizes that web product unifies version;And the customized expansion of product is supported by the strategy that extension preferentially covers Exhibition.
Compared with prior art, the application has following technological merit:
(1) it is extended on existing springmvc frame, does not bring new learning cost, to operation container without dependence;
(2) really unify version, all clients issue identical program bag, reduce maintenance and management cost;
(3) differentiated demand bring configuration parameter is greatly decreased, reduces operation management cost;
(4) load injecting strategy can carry out different extensions, situation when being applicable in various operations as needed.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with it is other The difference of embodiment, same or similar part may refer to each other between each embodiment.For being filled disclosed in embodiment For setting, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part Explanation.
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These Function is implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Profession Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered Think beyond the scope of this invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can directly be held with hardware, processor The combination of capable software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only deposit Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology In any other form of storage medium well known in field.
The method and device of strategy load provided by the present invention and injection are described in detail above.Herein Apply that a specific example illustrates the principle and implementation of the invention, the explanation of above example is only intended to help Understand method and its core concept of the invention.It should be pointed out that for those skilled in the art, not taking off , can be with several improvements and modifications are made to the present invention under the premise of from the principle of the invention, these improvement and modification also fall into this In invention scope of protection of the claims.

Claims (8)

1. a kind of method of strategy load and injection characterized by comprising
The instruction of web container starting is received, on-demand loading adapter profile is simultaneously loaded into adapter context;
Program is loaded, and the strategy injection factory of initialization response;
The strategy injection factory is called to realize that class is addressed to sort to the adapter in configuration range;
The adapter that selection meets preset condition from adapter is initialized and is injected;
Strategy injection factory is the addressing algorithm defined according to disparate modules and adapter level definition rule, meets institute The adapter for stating preset condition excellent is first injected into.
2. the method for strategy load and injection as described in claim 1, which is characterized in that described to select to meet from adapter The adapter of preset condition carries out initialization with injection
Distance is initialized and injected by the adapter in the injection nearest path service.
3. the method for strategy load and injection as described in claim 1, which is characterized in that described to select to meet from adapter The adapter of preset condition carries out initialization with injection
The adapter of highest priority is initialized and injected according to priority orders.
4. it is as described in any one of claims 1 to 3 strategy load with injection method, which is characterized in that it is described to program into Row loads
Lazy load is carried out to program by the lazyload of spring.
5. a kind of device of strategy load and injection characterized by comprising
Command reception module, for receiving the instruction of web container starting, on-demand loading adapter profile is simultaneously loaded into adapter Context;
Program loading module, for being loaded to program, and the strategy injection factory of initialization response;
Sorting module is addressed, for calling the strategy injection factory to realize that class is addressed to arrange to the adapter in configuration range Sequence;
Injection module is initialized and is injected for the adapter that selection meets preset condition from adapter;
Strategy injection factory is the addressing algorithm defined according to disparate modules and adapter level definition rule, meets institute The adapter for stating preset condition excellent is first injected into.
6. the device of strategy load and injection as claimed in claim 5, which is characterized in that the injection module is specifically used for:
Distance is initialized and injected by the adapter in the injection nearest path service.
7. the device of strategy load and injection as claimed in claim 5, which is characterized in that the injection module is specifically used for:
The highest adapter of priority is initialized and injected according to priority orders.
8. such as the device of claim 5 to 7 described in any item strategy loads and injection, which is characterized in that described program load Module is specifically used for:
Lazy load is carried out to program by the lazyload of spring.
CN201610439123.4A 2016-06-17 2016-06-17 A kind of method and device of strategy load and injection Active CN106095508B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610439123.4A CN106095508B (en) 2016-06-17 2016-06-17 A kind of method and device of strategy load and injection

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610439123.4A CN106095508B (en) 2016-06-17 2016-06-17 A kind of method and device of strategy load and injection

Publications (2)

Publication Number Publication Date
CN106095508A CN106095508A (en) 2016-11-09
CN106095508B true CN106095508B (en) 2019-01-25

Family

ID=57236385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610439123.4A Active CN106095508B (en) 2016-06-17 2016-06-17 A kind of method and device of strategy load and injection

Country Status (1)

Country Link
CN (1) CN106095508B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111381833B (en) * 2020-03-05 2023-05-12 山东汇贸电子口岸有限公司 Initialization method for containerized opentack data
CN112286619B (en) * 2020-12-28 2021-05-07 南京智闪萤科技有限公司 Method, electronic device, and storage medium for data-driven interface presentation

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102130965A (en) * 2011-04-13 2011-07-20 北京邮电大学 Method and system for dynamically combining services based on rule engine
CN102316163A (en) * 2011-09-07 2012-01-11 山东中创软件工程股份有限公司 Method for realizing Web container expansion and Web container
CN102566992A (en) * 2010-12-17 2012-07-11 卓望数码技术(深圳)有限公司 Dependency injection method and dependency injection device based on system running
CN102609255A (en) * 2012-01-19 2012-07-25 中国科学院计算机网络信息中心 Generation method for Spring IOC (Inversion of Control) configuration file
CN104270403A (en) * 2014-09-01 2015-01-07 江苏西贝电子网络有限公司 Cloud platform information web monitoring system based on struts2 framework

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8060858B2 (en) * 2006-12-29 2011-11-15 Sap Ag Injection library

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102566992A (en) * 2010-12-17 2012-07-11 卓望数码技术(深圳)有限公司 Dependency injection method and dependency injection device based on system running
CN102130965A (en) * 2011-04-13 2011-07-20 北京邮电大学 Method and system for dynamically combining services based on rule engine
CN102316163A (en) * 2011-09-07 2012-01-11 山东中创软件工程股份有限公司 Method for realizing Web container expansion and Web container
CN102609255A (en) * 2012-01-19 2012-07-25 中国科学院计算机网络信息中心 Generation method for Spring IOC (Inversion of Control) configuration file
CN104270403A (en) * 2014-09-01 2015-01-07 江苏西贝电子网络有限公司 Cloud platform information web monitoring system based on struts2 framework

Also Published As

Publication number Publication date
CN106095508A (en) 2016-11-09

Similar Documents

Publication Publication Date Title
US8434060B2 (en) Component load procedure for setting up systems
CN107147704A (en) A kind of generic service middleware system towards block chain
CN109117169A (en) Method and apparatus for repairing kernel loophole
CN103186466A (en) Information interaction device and method based on automatic generation of associated test cases
EP1857946A2 (en) Systems and methods for migrating data
CN109492017A (en) Business information inquiry processing method, system, computer equipment and storage medium
CN106415489A (en) Application suggestion features
CN105897805A (en) Method and device for cross-layer scheduling of resources of data center with multi-layer architecture
CN106406768A (en) Android system user data partitioning adjustment method and device
CN105515872A (en) Method, apparatus and system for updating configuration information
CN110147281A (en) Optimize method, apparatus, the electronic equipment that snowflake algorithm is applied in financial business
CN104731622B (en) The loading method of a kind of application program, device and mobile terminal
CN106095508B (en) A kind of method and device of strategy load and injection
CN106034247A (en) Configuration method and apparatus for smart television application
CN101346693A (en) Methods of generating, linking, and updating component-based software and information storage medium having such software recorded thereon
CN109933338A (en) Block chain dispositions method, device, computer equipment and storage medium
CN111427631A (en) Dynamic configuration method of diversified mobile application function module
CN114615340A (en) Request processing method and device, computer equipment and storage device
CN105607916A (en) Mobile application rapid generation method based on configuration
CN103109284A (en) Parameter value binding for mobile business objects
Stollberg et al. Service customization by variability modeling
CN110471786A (en) Online hot restorative procedure, device, equipment and computer readable storage medium
CN102184105A (en) Data processing method based on modularity and data center system
CN110502251A (en) Using installation method and device
CN101533345A (en) Device for configuring information based on extensible markup language (XML) and method thereof.

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Strategy loading and injection method and device

Effective date of registration: 20190828

Granted publication date: 20190125

Pledgee: Bank of Hangzhou Limited by Share Ltd science and Technology Branch

Pledgor: Hangzhou fortune man Network Inc

Registration number: Y2019330000039

PE01 Entry into force of the registration of the contract for pledge of patent right