Embodiment
, should be appreciated that following illustrated preferred embodiment only is used for description and interpretation the present invention, and be not used in qualification the present invention a preferred embodiment of the present invention will be described in detail below in conjunction with accompanying drawing.
Fig. 1 has shown that plug-in unit provided by the invention is disposed and the flow process signal of loading method, as shown in Figure 1:
Step S101 divides into groups plug-in unit to be loaded.
Before this, need card i/f is defined: the basic extension point interface of creation facilities program (CFP) and the plug-in unit of this basis extension point interface basis extension point interface instance function; Foundation is derived from the plug-in unit of the derivation interface of this basis extension point and this derivation interface and is derived from the interface instance function; The description file format of definition plug-in unit: definition plug-in unit ID, card i/f type and plugin library title.
As the plug-in unit product being divided into product bound cell PPU by product function, PPU is the top layer group, a plurality of plug-in managements unit PMU is arranged under the PPU, a plurality of pin function group PMUFunction are arranged under the PMU, a plurality of plug-in units or data file are arranged under the pin function group, and these pin function groups can have the plug-in unit of intersection and data file.
Step S102 sets up the plug-in unit deployment file, the plug-in unit group after the grouping that deployment process will load in this document, and a process has a plurality of deployment files, and process is by the union loading of plug-in of these files.
Step S103, the deployment file analysis module calculates plug-in unit group dependent tree according to the dependence of plug-in unit deployment file and plug-in unit group.
Step S104, the program entry module is by analyzing the process name that the order line function obtains process, startup process.
In addition, the program entry module needs to create earlier the plug-in unit factor interface, creates context interface again, resolves plug-in unit deployment file, attribute data file and plug-in unit group dependent tree then.
Before this, need set up the attribute data file, this document is some name-value pairs that the definition process needs in startup or operational process, and these property files are layerings, can define multilayer as required.
Step S105, the plug-in unit load-on module is pressed the process loading of plug-in according to plug-in unit group dependent tree.Loading of plug-in has dual mode: load in some plug-in unit or the operational process loading of plug-in as required in the process initiation process.
Fig. 2 is the structural representation of plug-in unit deployment provided by the invention and charger, as shown in Figure 2, this device comprises plug-in unit definition module, plug-in unit grouping module, plug-in unit deployment module, deployment file analysis module, program entry module, attribute data module and plug-in unit load-on module.
Wherein, the plug-in unit definition module comprises that plug-in unit basis extension point definition unit, plug-in unit derive from interface definition unit and plug-in description file definition unit.
The example function of plug-in unit basis extension point definition unit creation facilities program (CFP) basis extension point interface and this basis extension point interface.
Plug-in unit derives from the foundation of interface definition unit and derives from the derivation interface of basic extension point interface and the example function of this derivation interface.
The description file format of plug-in description file definition unit definition plug-in unit comprises: the type of plug-in unit ID, card i/f and plugin library title.
The plug-in unit grouping module is divided into plug-in unit to be loaded the plug-in unit group that is suitable for by the process loading.
The plug-in unit deployment module is set up the plug-in unit deployment file that deployment process is wanted the loading of plug-in group.
The deployment file analysis module calculates plug-in unit group dependent tree according to the dependence of plug-in unit deployment file and plug-in unit group.
The program entry module is obtained the process name of described process, the startup process, and set up the plug-in unit factor interface of management plug-in unit basis extension point interface instance function and plug-in unit derivation interface instance function and set up the context interface of describing running environment, and resolve plug-in unit deployment file, attribute data file and plug-in unit group dependent tree.
The attribute data file of attribute data module definition process initiation and the required name-value pair of operation.
The plug-in unit load-on module is pressed the process loading of plug-in according to plug-in unit group dependent tree.
Fig. 3 has shown the webmaster plug-in unit grouping signal that the embodiment of the invention provides, as shown in Figure 3, top layer has bn.ppu, two PPU of uca.ppu, wherein under the bn.ppu bn-core-c.pmu is arranged, many PMU of bn-necommon-c.pmu and bn-res.pmu, a plurality of pin function group PMUFunction under each PMU, as wherein under the bn-res.pmu two function group osf and emf being arranged, respectively include some catalogues, and there is common catalogue common, with be some data files under the catalogue of common peer, plug-in unit and description document wherein are common dynamic base among the Tong Ji dll.
Fig. 4 has shown the process initiation process that the embodiment of the invention provides and has analyzed the signal that order line is obtained the process title, as shown in Figure 4, the program entry module is at first created the plug-in unit factor interface, create context interface again, create local system interface ILocalSystem in contextual initialization plug-in unit function, the local system interface is responsible for analyzing and is disposed and load the startup plug-in unit.Must there be an example in plug-in unit factor interface IExtensionService, context interface IContext and ILocalSystem for each process.
Fig. 5 has shown the software issue bibliographic structure that the embodiment of the invention provides, as shown in Figure 5, under procs, be program and data files, it under works the catalogue of some process correspondences, some sub-directories are arranged under the catalogue of process correspondence, be used for depositing the daily record that produces in the operational process as the log catalogue, and be used for depositing plug-in unit deployment file and attribute data file under the deploy.
Below in conjunction with Fig. 1~Fig. 3 the demand of united net management is described.
(1) requirement source
In united net management, the equipment of various product lines need be managed in a webmaster, each product line has polytype equipment, the differing greatly of each equipment.The equipment of a plurality of product lines of management is not only saved resource but also be convenient to unified management in a webmaster, under the huge situation of number of devices, needs distributed management.
(2) development platform
Adaptive communication environ ACE (ADAPTIVE Communication Environment), compiler vc7 or gcc support a plurality of operating systems such as win32, solaris and linux.
(3) realization of plug-in type exploitation
1, defines basic extension point.
class?IExtension {
public:
IExtension(const?char*version=″V?1.0″);
virtual~IExtension(){}
virtual?int?Init(int?argc,char*argv[]);
virtual?int?Finish();
virtual?void?SetVersion(const?char*version);
virtual?const?char*GetVersion();
virtual?void?ProcessDebugCommand(std::string&cmd,::StringList¶s,std::ostream&os);
private:
_STD_string?m_strVersion;
};
Init is according to process initiation parameter initialization plug-in unit.Finish is used for doing cleaning work before extension point is destroyed, as closes handle and releasing memory etc.GetVersion and SetVersion are used to be provided with plug-in version.ProcessDebugCommand is a method of supporting that order line is adjusted, and similar basic function can add function as required.
Plug-in unit basis extension point example is created function IExtension*Create_Extension (const char*path, CProperties*properties) be that the plug-in unit dynamic base is to unique derivative function, create the example of this plug-in unit basis extension point, path is the directory path at plug-in unit place, properties is the name-value pair of this plug-in unit attribute, and function returns the extension point pointer.
The title of plug-in unit '. ' separating character string, represent a plug-in unit id as ican.context.localservice.log, ican.context.localservice represents it is the plug-in unit of an ILocalService correspondence, represent its subboard by the mode that plug-in unit id is added expansion, the subboard of representing ican.context.localservice as ican.context.localservice.log.xxplg, this id is a bit long, can adopt the another name mode to simplify plug-in unit id, can be used as the another name of ican.context.localservice.log as log.
Plug-in description file xml document definition defines the title of plug-in unit ID, version, corresponding dll etc. in the file, also can arrange certain type must be loaded by his father's plug-in unit by subboard.
2, the Local or Remote of definition local service Provider Interface ILocalService, service interface IServant and IServant is acted on behalf of the IService interface, these interfaces derive from from IExtension, these plug-in units have been realized the concrete function of webmaster, therefore these plug-in units quantitatively have a lot, can also define some other card i/fs if desired.Provided the main method of these three interfaces below:
2.1ILocalService provide service to this process module:
virtual?void?PreInit(IContext*ctx)
virtual?IDefaultContext*GetCtx(void)
Wherein, PreInit is used to be provided with context, and GetCtx is used to obtain context.
2.2IServant provide service to this process or remote process, service provides mainly and realizes by Get, Set:
virtual?void?PreInit(IContext*ctx)
virtual?CMsg*Get(CMsg&msgbuf,CMsgHead&headinfo)
virtual?void?Set(CMsg&msgbuf,CMsgHead&headinfo)
PreInit is used to be provided with context, and Get has response message to handle function, and CMsg represents message, and headinfo represents heading information such as command code and user, and Set is that the no response message is handled function.
2.3 the client realizes can judging that by IContext::HasServant whether servant is in this locality to the Get of IServant and calling of Set by IService.
virtual?void?PreInit(IContext*ctx,const?char*servantName)
virtual?void?SetServant(IIcanServant*servant)
virtual?CMsg*Get(CMsg&msgbuf,CMsgHead&headinfo)
virtual?void?Set(CMsg&msgbuf,CMsgHead&headinfo)
PreInit is used to be provided with the title servantName of context and corresponding IServant, and SetServant is used to be provided with the title of corresponding IServant, and Get has response message to handle function, and Set is that the no response message is handled function.
3, the grouping of definition plug-in unit is divided into a plurality of PPU by product function, and PPU is the top layer group, under the PPU a plurality of PMU is arranged, and under the PMU a plurality of PMUFunction is arranged.The corresponding catalogue of PPU, and a sub-directory under the corresponding PPU of PMU, a pin function group can contain a plurality of catalogues of PMU, and a plurality of plug-in units or data file are arranged under each catalogue, and these pin function groups have the intersection catalogue.Also defined dependence among the PMUFunction to other function group.
4, definition procedure deployment is disposed definition in the file of process working directory, this document can have a plurality of, disposes defined file and is used to define which PMUFunction of this procedure deployment.
5, definition IContext and IExtensionService interface, these interfaces can derive from from IExtension.
5.1 the method for definition IExtensionService:
virtual?IExtension*CreateExtension(const?char*extName,bool?isSingleton);
virtual?void?DestroyExtension(IExtension*pcExtension)=0;
virtual?StringList?GetExtensions(const?char*pcSubject)=0;
CreateExtension is according to whether creating the basic extension point example that is called extName in single routine mode.DestroyExtension destroys extension point.GetExtensions obtains all subboards of main body pcSubject, promptly uses the part prefix of the plug-in unit ID that '. ' cut apart.
5.2IContext in certain process, create and move the contextual method of plug-in unit:
virtual?void?PreInit(IExtensionService*)
virtual?ILocalService*GetLocalService(const?char*extName,const?char*strpmufunc);
virtual?IServant*GetServant(const?char*extName,const?char*strpmufunc);
virtual?IService*GetService(const?char*extName,const?char*strpmufunc);
virtual?IExtensionService*GetExtService();
virtual?bool?HasServant(const?char*extName,const?char*strpmufunc);
PreInit is used to be provided with plug-in unit factory.GetLocalService obtains the ILocalService of the extName by name under the pin function group strpmufunc, and strpmufunc is NULL, and wherein, seek scope is all PMU of this process.GetServant obtains the IServant of the extName by name under the pin function group strpmufunc.GetService obtains the IService of the extName by name under the pin function group strpmufunc.HasServant judges whether this process pin function group strpmufunc exists the IServant of extName by name.GetExtService obtains plug-in unit factory.
6, ILocalSystem derives from ILocalService, be that this procedure deployment is analyzed and plug-in unit group analysis module, read the name-value pair in this Process Attributes data file, analyze which plug-in unit group of this procedure deployment and plug-in unit group dependent tree, dispose which function group PmuFunction and their dependent tree as long as analyze in the present embodiment, leaf node has dependence to father node in the dependent tree, divide course leaf node loading of plug-in from the tree root node then, the plug-in unit under the same PMUFunction can be by catalogue or plug-in unit name definition priority loading sequence.Arrange certain principle and load some type plug-in when program start, some type plug-in loads as required, loads the plug-in unit with IServant extension point when starting in the present embodiment.
7, realize top each interface function or plug-in unit, releasing software.Plug-in unit and dll are placed under the Procs catalogue by PPU, PMU sectional lists, contain those catalogues and plug-in unit among the PMUFunction, the corresponding xml description document of each function group, in Procs same level definition works catalogue, under the works catalogue some process catalogues, deposit some data files relevant, as procedure deployment file and attribute data file etc. with process.
8, the order line of program entry module by program specified the process title, knows the working directory of process by the process title, and the process inlet module can load different processes like this.Create IContext and IExtensionService, transmit the process working directory and give ILocalSystem, ILocalSystem is responsible for loading the plug-in unit that needs when starting by disposing, and directly calls IContext loading of plug-in as required during operation.
In addition, can make various possible changes or replacement according to the explanation and the embodiment of technical scheme of the present invention, merge as IContext and IExtensionService, description document does not adopt the xml form, basis extension point interface adds or reduces certain methods, or just realizes interface with the structure and the function pointer of procedural language.