Specific embodiment
In the following description, in order to make the reader understand this application better, many technical details are proposed.But this
The those of ordinary skill in field is appreciated that even if without these technical details and many variations based on the following respective embodiments
And modification, the application technical solution claimed also may be implemented.
The explanation of part concept:
SOA: i.e. Enterprise SOA, is a component model, it (referred to as takes the different function units of application program
Business) by these service between define good interface and contract connects.
Event: in majority decision system, decision is all to be triggered by event, for example market rate drop 10% is exactly
One event.
In addition, heat load is identical as the meaning of dynamically load, and the dynamic class of JAVA adds in each embodiment of the application
It carries and the meaning of the heat load of Spring is also identical, the meaning of Spring container and IoC container is also identical.
Fig. 1 is the schematic diagram of service registration discovery mechanism under SOA system.Service registration discovery procedure includes three steps altogether: the 1st
Walk service registration, step 2 service discovery and step 3 service call.Wherein, step 1 service registration and step 3 service call use
The mode of frame script.The application aims to solve the problem that the development efficiency problem of step 2 service discovery part.
It is described in further detail below in conjunction with embodiment of the attached drawing to this specification.
The first embodiment of this specification is related to the event production method under a kind of SOA system, process such as Fig. 2 institute
Show, method includes the following steps:
In step 202, by the hot load mechanism of Spring, jar file and Groovy dynamic script are loaded into
In Spring container.
Here, it should be further noted that
Service, such as RPC (Remote Procedure Call, remote procedure call) service are relied on external clothes
Business requires the Client JAR of upload service provider offer using external service, generally passes through under traditional mode
Maven mode static state introduces, and is to dynamically introduce JAR in the application.
Groovy dynamic script is used primarily in event instance structurally for dynamic implement to the function of data mart modeling,
Groovy dynamic script is in the construction process of example, it is possible to the service for calling JAR to introduce.
Service user using service before, it is first of all clear that know service provider provide service specification be assorted
, servicing a big chunk content in specification is exactly to be described by way of java class.So firstly, service user
Need to introduce the JAR of service provider service specification.Under traditional mode, JAR is introduced by way of maven.And this
Application dynamically introduces JAR first with the Dynamic Class Loading mechanism of JAVA.
The dynamically load of Java: dynamically load jar file is realized by Classloader ClassLoader, when a class quilt
When load, all classes cited in this class can be also loaded.Java Dynamic Class Loading is not primarily to change main program generation
Code can operate different objects by modification configuration file and execute different functions, be very beneficial for the extension of system, example
Such as change a function when desired, it is only necessary to do a class, then write corresponding function, can use by configuration file
New function, from anywhere in not needing modification system, it is only necessary to add a class, adequately achieve loose under SOA system
Coupling.
SOA system will necessarily maintain all chartered in the presence of one " service register center " application or module
Service.In step 202, after dynamically load JAR, after getting corresponding service by configuration center, clothes can be used
Business.In XML file, system is initialised in IoC container when starting for traditional service reference configuration.In the present invention, will lead to
The hot load mechanism for crossing Spring, Groovy dynamic script is loaded into IoC container, realizes that final system is called.To
So that research staff may not need modification code, the service flexibly provided according to service provider is provided and completes service group
It closes.
Then into step 204, event Schema is fished for.
Here, it should be further noted that
Event generally refers to financial risks event, in other words, as a risk data carrier, such as a stream
Dynamic property risk case includes: several attributes such as main body, mobility rate of filled vacancy.
Schema, i.e. XML Schema, it is indicated that how form describes the element of XML document.
Further, it is preferable to ground, before the step 204, further includes:
Receive user-defined event Schema.
That is, before the step 204, user needs to define event Schema first.
Event generation is the propulsion in order to drive business, then different events just has different processing methods.In order to unite
The processing of one event, it is necessary first to define the Schema of event.
In the present embodiment, it is preferable that event Schema includes: event code, event name and state-event.
After having received user-defined event Schema, according to the event Schema, when fishing for the triggering of event
Between rule, and calculate the next triggered time of event.
And further determine whether the next triggered time of arrival event.
If the next triggered time of the also non-arrival event of current time continues waiting for not to the triggered time.
If current time arrived the next triggered time of event, 204 are thened follow the steps.
Corresponding dynamic script function is obtained according to the definition of the Schema then into step 206.
For example for, by taking capital adequacy ratio event as an example,
Event Schema is defined as follows:
Wherein, calCapitalAdequacyRatio is that the Groovy dynamic script of calculating amply supported with funds is loaded into
Corresponding dynamic script function name (name) in Spring container.Date is the Groovy dynamic script quilt for returning to current time
The corresponding dynamic script function name (name) being loaded into Spring container, for example, #date (" -1d ") is indicated upper one day, #
Date (" -1m ") indicates last month, and #date (" -1d ", " yyyyMMdd ") indicates to return upper one day, and format is yyyyMMdd etc..
Then into step 208, the dynamic script function is called, calculates event attribute value.
Equally by taking above-mentioned capital adequacy ratio event as an example, calCapitalAdequacyRatio function is called, to calculate
The attribute value of capital adequacy ratio event.
In the present embodiment, it is based on dynamic script dynamic data service, so that the production of event attribute value is more flexible.
In addition, according to the calculation formula of capital adequacy ratio:
Need to inquire the information such as capital, weighted assets again it is found that calculating in the Groovy dynamic script of amply supported with funds, because
This, needs to rely on other service.That is, it is also necessary to the other service for calling JAR to introduce.
The assembling of event is completed according to the event attribute value then into step 210.
In the present embodiment, it is preferable that event attribute includes: event code, event attribute code, event attribute name, event
Attribute value, event attribute Value Types and event production trigger etc..
Event and event attribute are the relationships of 1:N, also particularly important for the design of event attribute value, are that event can be marked
The key point of standardization.Wherein, event attribute value is either a fixed value, also can be used above-mentioned dynamic script dynamic
The mode of aggregated service flexibly calculates.
Different event, not only content is different, production cycle also different from.For example partial event is daily every 1
Hour generates once, has plenty of and 5 generated once every 10 minutes weekly.It is configured, can flexibly be controlled by flexible time rule
The generation frequency of event.
Further, it is preferable to ground, after step 210, further includes:
Event consumer side is sent by the event being completed.
Event consumer side here, such as can be the decision center etc. for needing to make decisions according to event.
Further, it is preferable to which ground can also include: after step 210
The next triggered time of update event.
By above description as can be seen that in the present embodiment, being based on Spring JAR and Groovy scripting language
Dynamically load mechanism is changed without code, it is only necessary to which new demand servicing introducing can be realized in a small amount of configuration, can be flexibly according to event week
Phase assembles various types of events, significantly reduces the development cost of event, under SOA system, solves service user
The low problem of efficiency of research and development.
In order to more fully understand the technical solution of this specification, said below with reference to a specific example
Bright, the details enumerated in the example is primarily to be easy to understand, not as the limitation to the application protection scope.
One, dynamically load JAR
Service user using service before, it is first of all clear that know service provider provide service specification be assorted
, servicing a big chunk content in specification is exactly to be described by way of java class.So firstly, service user
Need to introduce the JAR of service provider service specification.Under traditional mode, introduced by way of maven.The application benefit
JAR is introduced with the Dynamic Class Loading mechanism of JAVA.
For JAR, traditional mode is stored by the warehouse maven (abbreviation Mvn), and database is used in the application
The mode of+distributed storage device carries out.Maintain the relevant basic information of JAR in database first, including name, version,
Safeguard people etc..It is as shown in table 1 below:
Table 1
Field |
Field description |
group_id |
Mvn coordinate groupId |
artified_id |
Mvn coordinate artifiedId |
version |
Mvn coordinate version |
status |
JAR state |
file_path |
The path JAR |
User upload information safeguarded by upper table 1, the specific content of JAR can by distributed file system come
Storage.System on startup, after loading bean defined in Spring XML by BeanFactory first, then passes through
JAR information table is read, the JAR that state is online state, Mobile state of going forward side by side load are obtained.Here, the mistake of Spring dynamically load
Cheng Buzai description, can refer to JAVA relevant knowledge document.
Two, dynamic script
SOA system will necessarily maintain all chartered in the presence of one " service register center " application or module
Service.After previous step dynamically load JAR, after getting corresponding service by configuration center, service can be used.Above
It mentions, in XML file, system is initialised in IoC container when starting for traditional service reference configuration.In the present invention, will
By the hot load mechanism of Spring, the mode of Groovy dynamic script is loaded into IoC container, realizes final system tune
With.So that research staff may not need modification code, the service flexibly provided according to service provider is provided and is completed
Services Composition.Fig. 3 is a kind of Groovy dynamic script load timing diagram.
Three, event assembles
Event generation is the propulsion in order to drive business, then different events just has different processing methods.In order to unite
The processing of one event, it is necessary first to define the Schema of event.As shown in the following table 2 and table 3:
2 event schema table of table
event_code |
Event code |
event_name |
Event name |
status |
State-event |
3 event attribute table of table
event_code |
Event code |
event_property_code |
Event attribute code |
event_property_name |
Event attribute name |
event_property_value |
Event attribute value |
event_property_value_type |
Event attribute Value Types |
Event and event attribute are the relationships of 1:N, also particularly important for the design of event attribute value, are that event can be marked
The key point of standardization.Above-mentioned dynamic foot also can be used either a fixed value in event_property_value
The mode of this dynamic aggregation service flexibly calculates.
Four, event produces trigger
Not only content is different for different event, production cycle also different from.For example partial event is small every 1 daily
When generate it is primary, have plenty of weekly 5 generated every 10 minutes it is primary.
The pseudocode for so calculating the next triggered time is as follows:
Five, complete event generation process
The timing diagram of complete event generation process is as shown in Figure 4.
In conclusion the application embodiment devises the event dynamic producing method under a kind of SOA system, pass through utilization
Dynamic Service addressing in the Dynamic Class Loading mechanism and SOA Development Framework of Java is realized that a set of code that is not necessarily to changes, need to only be lacked
The scheme that new demand servicing introduced, carried out flexible event configuration and production can be realized in amount configuration, to improve efficiency of research and development, adapts to interconnection
The rhythm of net high speed development.
Specifically, compared with prior art, having following technical effect that
(1) in such a way that dynamic script assembles, so that obtaining service, the research and development cost for calculating data is substantially reduced.
(2) it is based on dynamic script dynamic data service, so that the production of event attribute value is more flexible.
(3) it is configured by flexible time rule, can flexibly control the generation frequency of event.
The second embodiment of this specification is related to the event process units under a kind of SOA system, structure such as Fig. 5 institute
Show, the event process units under the SOA system includes:
Jar file and Groovy dynamic script are loaded by loading unit for passing through the hot load mechanism of Spring
In Spring container;
Unit is fished for, for fishing for event Schema;
Acquiring unit obtains corresponding dynamic script function for the definition according to the Schema;
First computing unit calculates event attribute value for calling the dynamic script function;
Assembling unit, for completing the assembling of event according to the event attribute value.
In the present embodiment, it is preferable that further include:
Receiving unit receives user-defined event Schema.
Second computing unit calculates the next triggered time of event for the triggered time rule for the event of fishing for.
Judging unit, for judging whether the next triggered time of arrival event.
Transmission unit, for sending event consumer side for the event being completed.
Updating unit, for complete event assembling after, the next triggered time of update event.
Wherein, the event Schema includes: event code, event name and state-event.
The event attribute includes: event code, event attribute code, event attribute name, event attribute value, event attribute value class
Type and event produce trigger.
In conclusion under SOA architectural framework, using the hot load mechanism of Java and the dynamic characteristic of scripting language, in conjunction with
The service management at service configuration center in SOA provides flexible configuration service, and the time of using flexible for the production of event
Rule flexibly generates event, and the development cost of event can be greatly reduced.
First embodiment is method implementation corresponding with present embodiment, and the technology in first embodiment is thin
Section can be applied to present embodiment, and the technical detail in present embodiment also can be applied to first embodiment.
It should be noted that it will be appreciated by those skilled in the art that the implementation of the event process units under above-mentioned SOA system
The realization function of each unit module shown in mode can refer to the associated description of the event production method under aforementioned SOA system and
Understand.The function of each unit module shown in the embodiment of event process units under above-mentioned SOA system can pass through operation
It realizes, can also be realized by specific logic circuit in the program (executable instruction) on processor.This specification is implemented
If the event process units under the above-mentioned SOA system of example is realized in the form of software function module and is sold as independent product
Or it in use, also can store in a computer readable storage medium.Based on this understanding, this specification embodiment
Technical solution substantially the part that contributes to existing technology can be embodied in the form of software products in other words, should
Computer software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be
Personal computer, server or network equipment etc.) execute each embodiment the method for this specification all or part.
And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read Only Memory), magnetic disk or light
The various media that can store program code such as disk.In this way, this specification embodiment is not limited to any specific hardware and soft
Part combines.
Correspondingly, this specification embodiment also provides a kind of computer readable storage medium, wherein being stored with computer
Executable instruction, the computer executable instructions realize each method embodiment of this specification when being executed by processor.It calculates
Machine readable storage medium storing program for executing include permanent and non-permanent, removable and non-removable media can by any method or technique Lai
Realize information storage.Information can be computer readable instructions, data structure, the module of program or other data.Computer
The example of storage medium includes but is not limited to that phase change memory (PRAM), static random access memory (SRAM), dynamic random are deposited
Access to memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electrically erasable are only
Read memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM), the more function of number
Can CD (DVD) other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices or it is any its
His non-transmission medium, can be used for storing and can be accessed by a computing device information.As defined in this article, computer-readable to deposit
Storage media does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
In addition, this specification embodiment also provides the event production equipment under a kind of SOA system, including for depositing
The memory of computer executable instructions is stored up, and, processor;The processor is used for can in the computer executed in the memory
The step in above-mentioned each method embodiment is realized when executing instruction.Wherein, which can be central processing unit
(Central Processing Unit, referred to as " CPU "), can also be other general processors, digital signal processor
(Digital Signal Processor, referred to as " DSP "), specific integrated circuit (Application
SpecificIntegrated Circuit, referred to as " ASIC ") etc..Memory above-mentioned can be read-only memory (read-
Only memory, referred to as " ROM "), random access memory (random access memory, referred to as " RAM "), flash memory
Reservoir (Flash), hard disk or solid state hard disk etc..The step of method disclosed in each embodiment of the present invention, can directly embody
Execute completion for hardware processor, or in processor hardware and software module combination execute completion.
It should be noted that relational terms such as first and second and the like are only in the application documents of this patent
For distinguishing one entity or operation from another entity or operation, without necessarily requiring or implying these entities
Or there are any actual relationship or orders between operation.Moreover, the terms "include", "comprise" or its any other
Variant is intended to non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only
It including those elements, but also including other elements that are not explicitly listed, or further include for this process, method, object
Product or the intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence " including one ", not
There is also other identical elements in the process, method, article or apparatus that includes the element for exclusion.The application of this patent
In file, if it is mentioned that certain behavior is executed according to certain element, then refers to the meaning for executing the behavior according at least to the element, wherein
Include two kinds of situations: executing the behavior according only to the element and the behavior is executed according to the element and other elements.Multiple,
Repeatedly, the expression such as a variety of include 2,2 times, 2 kinds and 2 or more, 2 times or more, two or more.
It is included in the disclosure of the specification with being considered as globality in all documents that this specification refers to,
To can be used as the foundation of modification if necessary.In addition, it should also be understood that, the foregoing is merely the preferred embodiment of this specification and
, it is not intended to limit the protection scope of this specification.It is all this specification one or more embodiment spirit and principle it
Interior, any modification, equivalent replacement, improvement and so on should be included in the protection model of this specification one or more embodiment
Within enclosing.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the movement recorded in detail in the claims or step can be come according to the sequence being different from embodiment
It executes and desired result still may be implemented.In addition, process depicted in the drawing not necessarily require show it is specific suitable
Sequence or consecutive order are just able to achieve desired result.In some embodiments, multitasking and parallel processing be also can
With or may be advantageous.