Script application programe framework
Background
The technician is known like computer realm, and programming language or computerese are a kind of Standardization Communication instruments, be used for to the computer expression instruction, thereby computing machine can be carried out this instruction to accomplish specific action.Programming language has various patterns.Some are program languages, such as C.Some are OO, such as C++ and Java.Some are functionalities, such as Haskell.It is a kind of for ease of programming and carry out specific or restriction task and the simple programming language that designs that script tends to.For example, now, JavaScript is generally used for for web application additional functionality and/or interactivity being provided.Visual Basic Script, Perl and TCL are other examples of script.Generally speaking, script has simpler sentence structure and programming constructs still less compared with the traditional programming language such as C, C++ or Java.In addition, script does not need compiling, though and can when operation, explain, can be carried out immediately.
Script is to use script to create one group of instruction and accomplishes the process of specific function to use script.Different with the traditional programming language that uses each process of operating computer such as C, C++ or Java, script tends to comprise one group of quick and littler simple instruction.Script tends to realize a specific purpose, such as control one computing machine is connected to the process of another computing machine via modulator-demodular unit, and perhaps how control imports the change web page contents according to the user.On the WWW, script is used to be created as the Web page and web application customization or adds the script of interactivity.For example, in the time of in being inserted into the Web page, script can be controlled each element of the Web page, such as user interface, pattern and the HTML mark of the Web page.
As time goes by, traditional programming being attached in the programming language such as abstract notion with encapsulation, and has produced the programming language of the pattern and the structure that provide predetermined, such as C++.On the other hand, the script that has specially kept the fallibility code that does not relate to pattern or structure and cause through regular meeting being difficult to safeguard.For example, the script environment lacks the application framework layer usually.So, script be programmed in have no abstract with hidden different functionalities complicacy and propose to carry out under the situation of generic script pattern.
Though described the specified disadvantages of existing system in this background parts, those skilled in the art and other staff will recognize that, require the theme of protection to be not limited to solve in the said shortcoming any or whole any specific implementation at this.
General introduction
This general introduction is provided so that introduce the selected of notion with reduced form, these notions will be further described in following detailed description.This general introduction is not intended to identify the key feature of the theme that requires protection, is not intended to be used to help definite scope that requires the theme of protection yet.
Each side of the present invention provides a kind of script application programe framework of being convenient to the script exploitation.Script application programe framework is encapsulated into the script logic in the assembly, and script object models is provided, and binds the character and the method for different scripting objects, and the life-span of Manage Scripts object etc.This script application programe framework can be applicable to any script environment.
According to an aspect of the present invention, this script application programe framework can provide the application class (Application class) of encapsulation general functional for script application programe.Script application programe can comprise a plurality of scripting objects.Application class can comprise and is used for managing the functional of these a plurality of scripting objects.
Component class (Component class) can be provided, be used to define the behavior and at least one object properties that are associated with scripting object.These object properties can be the character of this scripting object, are used for the method for this scripting object, or the incident of this scripting object.Preferably, type specification symbol type (TypeDescriptor class) is provided, is used to describe the object model of this scripting object.
According to a further aspect in the invention, scripting object can be through communicating with one another such as mechanism such as binding and actions.Binding type (Binding class) provides through the object properties that data are sent to second scripting object from the object properties of first scripting object and connects the functional of first scripting object and second scripting object.Preferably, transducer class (Transformer class) is used for when needed the data type conversion of the object properties of first scripting object is become the type of the object properties of second scripting object.
Simultaneously, action type (an Action class) can be used in and calls specific action when in scripting object, particular event taking place.Specific action can be a method of for example calling another scripting object, perhaps disposes the character of another scripting object.Event class (Event class) can be used for safeguarding the generation of the incident of one or more button.onreleases and the relevant scripting object of signaling.In addition, condition class (Condition class) can be used for providing specified criteria to decide when particular event takes place, whether carrying out specific action.
In addition, script application programe framework also comprises IDispose (I setting) interface, can realize that this interface is used to be provided with the relation of scripting object and/or removing and other scripting objects.
Description of drawings
When below combining referenced drawings, describing in detail, can understand above-mentioned aspect of the present invention and many attendant advantages more comprehensible and better, in the accompanying drawing:
Fig. 1 shows the block diagram of an exemplary script application framework.
Describe in detail
Hereinafter illustrates and has described illustrative embodiments of the present invention.Yet, it will be recognized by those of ordinary skills and can make various changes and not deviate from the spirit and scope of the present invention it.
Fig. 1 shows exemplary script application programe framework 100 and each example components thereof.In embodiments of the present invention, script application programe framework 100 can comprise than more or less assembly shown in Figure 1.
As shown in Figure 1, shown in script application programe framework 100 comprise 102 types of application programs.102 types of application programs are that all component of script application programe framework 100 is gathered item layer type together, and carry out the life-span of each scripting object in management and application program and provide the task the visit of service to this application program different piece.In an exemplary environments of the present invention, the Web page comprises an instance of 102 types of application programs separately.Following pseudo-code shows 102 types of exemplary application:
// application program
·?Web._Application=function(){
this.get_type=function();
this.load=new?Web.Event(this);
this.unload=new?Web.Event(this);
this.findObject=function(id);
this.getService=function(serviceType);
this.registerDisposableObject=function(object);
this.unregisterDisposableObject=function(object);
}
·?Type.registerSealedClass(′Web._Application′,null,Web.IDisposable,
Web.ITypeDescriptorProvider,Web.ICustomTypeDescriptor);
·?Web.Application=new?Web._Application();
//
Assembly is the base class of relevant all script components for 104 types.Assembly is the mechanism of one group of particular functionality of the relevant script component of encapsulation for 104 types, and wherein this script component can be used by Application developer or other script components.In illustrative embodiments of the present invention, assembly 104 class descriptions behavior and the attribute of object model of scripting object, such as character, method and incident.104 types of management that can also let a scripting object participate in each scripting object life-span in the application programs of assembly when this Properties of Objects change, send Notification of Changes, and management are to each incident of this scripting object.Following pseudo-code shows an exemplary realization of 104 types of assemblies:
// assembly
·?Web.Component=function(registerAsDisposable){
this.get_bindings=function();
this.get_dataContext=function();
this.set_dataContext=function(value);
this.get_id=function();
this.set_id=function(value);
this.get_isInitialized=function();
this.get_isUpdating=function();
this.createEvent=function(autoInvoke);
this.propertyChanged=this.createEvent();
this.beginUpdate=function();
this.dispose=function();
this.endUpdate=function();
this.getDescriptor=function();
this.initialize=function();
this.raisePropertyChanged=function(propertyName);
this.updated=function();
}
·?Type.registerAbstractClass(′Web.Component′,null,Web.IDisposable,
Web.ITypeDescriptorProvider,Web.ISupportBatchedUpdates,
Web.INotifyPropertyChanged);
//
The type specification symbol allows scripting object to describe its object model for 106 types, and this comprises character (together with type and relating attribute), incident and method (together with relevant parameter).For example, the type specification symbol object that is used for TIMER (timer) scripting object can comprise Interval (at interval) character of numeric type and Enabled (launching) character, Tick (ticktock) incident and the method such as Start () and Stop () of Boolean type.For example, the type specification symbol object that is used for Array (array) scripting object can provide in this array to as if the information of what type.Hereinafter shows an exemplary realization of 106 types of type specification symbols:
// type specification symbol
·?Web.TypeDescriptor=function(){}
·?Web.TypeDescriptor.prototype.addAttribute=function(attributeName,
attributeValue);
·?Web.TypeDescriptor.prototype.addEvent=function(eventName,
supportsActions);
·?Web.TypeDescriptor.prototype.addMethod=function(methodName,
associatedParameters);
·?Web.TypeDescriptor.prototype.addProperty=function(propertyName,
propertyType,readOnly);
·?Web.TypeDescriptor.addType=function(tagPrefix,tagName,type);
·?Web.TypeDescriptor.createParameter=function(parameterName,
parameterType);
·?Web.TypeDescriptor.getType=function(tagPrefix,tagName);
·?Web.TypeDescriptor.getTypeDescriptor=function(instance);
·?Web.TypeDescriptor.getProperty=function(instance,propertyName,
key);
·?Web.TypeDescriptor.setProperty=function(instance,propertyName,
value,key);
·?Web.TypeDescriptor.invokeMethod=function(instance,methodName,
parameters);
·?Web.TypeDescriptor.getPropertyType=function(instance,propertyName,
key);
·?Web.ICustomTypeDescriptor=function(){
this.getProperty=Function.abstractMethod;
this.setProperty=Function.abstractMethod;
this.invokeMethod=Function.abstractMethod;}
·?Type.registerInterface(′Web.ICustomTypeDescriptor′);
·?Web.ITypeDescriptorProvider=function(){
this.getDescriptor=Function.abstractMethod;}
·?Type.registerInterface(′Web.ITypeDescriptorProvider′);
//
Each embodiment of the present invention provides scripting object one or more mechanism connected to one another.Fig. 1 shows two kinds of such mechanism: bind 108 types with the action 112 types.Bind 108 types and can be used for data are sent to another object property from an object property, vice versa.For example, another scripting object Label (label) has Text (text) character if a scripting object Counter (counter) has Value (value) character.An instance binding 108 types can be tied to Label.Text with Counter.Value.As a result, the scripting object label can show Counter.Value.In illustrative embodiments of the present invention, an instance binding 108 types can be with any character path but not the special properties name be associated.For example, Label.Text can be bound to Foo.Bar.Baz, promptly as the expression formula of the scripting object of quoting of the data source of Label.Text.In illustrative embodiments of the present invention, can allow data only are conveyed into a character, only be sent to another character from a character, perhaps both all can, promptly send out and be conveyed into a character.
In embodiments of the present invention, binding 108 types is associated for 110 types with transducer with the type of type conversion to another character of an attributes.For example, exemplary Counter.Value is a numeric type, and exemplary L abel.Text is a character string type.Therefore, when take place binding between these two kinds of character, the instance that transducer is 110 types will be implicitly converts Counter.Value to the type of Label.Text, i.e. character string type from numeric type.
Following pseudo-code shows an exemplary realization of binding 108 types:
// bind
·Web.BindingDirection=Web.Enum.create(′In′,′Out′,′InOut′);
·Web.BindingEventArgs=function(value,direction,targetPropertyType,
transformerArgument){
this.get_direction=function();
this.get_targetPropertyType=function();
this.get_transformerArgument=function();
this.get_value=function();
this.set_value=function(value);
}
·Type.registerSealedClass(′Web.BindingEventArgs′,Web.CancelEventArgs);
·Web.Binding=function(){
this.get_automatic=function();
this.set_automatic=function(value);
this.get_dataContext=function();
this.set_dataContext=function(value);
this.get_dataPath=function();
this.set_dataPath=function(value);
this.get_direction=function();
this.set_direction=function(value);
this.get_property=function();
this.set_property=function(value);
this.get_propertyKey=function();
this.set_propertyKey=function(value);
this.get_trahsformerArgument=function();
this.set_trahsformerArgument=function(value);
this.transform=new?Web.Event(null);
this.dispose=function();
this.evaluate=function(direction);
this.evaluateIn=function();
this.evaluateOut=function();
this.initialize=function(component);
}
·Type.registerSealedClass(′Web.Binding′,null,Web.IDisposable,
Web.ITypeDescriptorProvider);
//
Each embodiment of the present invention also provides 116 types of incidents, in order to the tabulation of maintenance event handling procedure and when incident takes place signaling.Hereinafter shows an exemplary realization of 116 types of incidents:
// incident
·Web.Event=function(owner,autoInvoke){
this.get_autoInvoke=function();
this.isActive=function();
this.get_isInvoked=function();
this.dispose=function();
}
·Type.registerSealedClass(′Web.Event′,null,Web.IDisposable);
·Web.Event.prototype.add=function(handler);
·Web.Event.prototype.addAction=function(action);
·Web.Event.prototype.remove=function(handler);
·Web.Event.prototype.removeAction=function(action);
·Web.Event.prototype.invoke=function(sender,eventArgs);
·Web.EventArgs=function(){
this.getDescriptor=function();
}
·Type.registerClass(′Web.EventArgs′,null,Web.ITypeDescriptorProvider);
·Web.EventArgs.Empty=new?Web.EventArgs();
·Web.CancelEventArgs=function(){
this.get_canceled=function();
this.set_canceled=function(value);
}
·Type.registerClass(′Web.CancelEventArgs′,Web.EventArgs);
//
Another exemplary binding mechanism is provided for 112 types by action, and specific action is called in the 112 types of permissions of moving when particular event takes place.For example, scripting object Timer can comprise Counter character and Tick incident.In the exemplary realization of scripting object Timer, as long as the Tick incident takes place, 112 types the instance of moving just increases progressively the value of Counter character.This move can be described as InvokeMethod (call method) action.Illustrative embodiments of the present invention provides multiple type of action.For example, can provide the character of SetProperty (character is set) action scripting object to be set to an occurrence.In illustrative embodiments of the present invention, move 112 types can further be associated for 114 types with condition, make decision whether carry out an action even this condition can be used in situation about having taken place at allocate event for 114 types.Hereinafter shows an exemplary realization of IAction interface and 112 types of actions:
// action
·Web.IAction=function(){
this.get_sequence=Function.abstractMethod;
this.execute=Function.abstractMethod;
this.setOwner=Function.abstractMethod;
}
·Type.registerInterface(′Web.IAction′);
·Web.Action=function(){
this.get_eventArgs=function();
this.get_result=function();
this.get_sequence=function();
this.set_sequence=function(value);
this.get_sender=function();
this.get_target=function();
this.set_target=function(value);
this.execute=function(sender,eventArgs);
this.performAction=Function.abstractMethod;
this.setOwner=function(eventSource);
}
·Type.registerAbstractClass(′Web.Action′,Web.Component,Web.IAction);
·Web.InvokeMethodAction=function(){
this.get_method=function();
this.set_method=function(value);
this.get_parameters=function();
}
·Type.registerSealedClass(′Web.InvokeMethodAction′,Web.Action);
·Web.SetPropertyAction=function(){
this.get_property=function();
this.set_property=function(value);
this.get_propertyKey=function();
this.set_propertyKey=function(value);
this.get_value=function();
this.set_value=function(value);
}
·Type.registerSealedClass(′Web.SetPropertyAction′,Web.Action);
//
In embodiments of the present invention, the service that is provided by an instance binding 108 types (for example, data transmit) need be in response to Notification of Changes by explicitly or triggering automatically.Notification of Changes can be the character Notification of Changes or gather Notification of Changes.For example; When the exemplary Counter.Value that is associated with scripting object Timer changes; One character Notification of Changes is issued to the instance of 108 types of corresponding bindings, and the instance that this binding subsequently is 108 types just upgrades Label.Text with current Counter.Value.The set Notification of Changes occurs when change takes place the set scripting object such as DataSource (data source).The set scripting object comprises the set of data.DataSource can be a database for example.Data source can have Data (data) character.Repeater (transponder) scripting object also can have Data character.Suppose that Repeater.Data and DataSource.Data bind.When adding new data recording to DataSource.Data, gathering the instance that Notification of Changes is issued to 108 types of corresponding bindings, this instance correspondingly upgrades Repeater.Data subsequently.For example, the instance of binding 108 types can be filled the Repeater table with new data.Following pseudo-code shows the functional exemplary realization of Notification of Changes:
// Notification of Changes
·Web.INotifyPropertyChanged=function(){
this.propertyChanged=null;
}
·Type.registerInterface(′Web.INotifyPropertyChanged′);
·Web.INotifyCollectionChanged=function(){this.collectionChanged=null;}
·Type.registerInterface(′Web.INotifyCollectionChanged′);
·Web.PropertyChangedEventArgs=function(propertyName){
this.get_propertyName=function();
}
·Type.registerSealedClass(′Web.PropertyChangedEventArgs′,Web.EventArgs);
·Web.NotifyCollectionChangedAction=Web.Enum.create(′Add′,′Remove′,
′Reset′);
·Web.CollectionChangedEventArgs=function(action,changedItem){
this.get_action=function();
this.get_changedItem=function();
}
·Type.registerSealedClass(′Web.CollectionChangedEventArgs′,
Web.EventArgs);
//
In case scripting object is such as quote through each instance of binding 108 types each other, they have just created circular reference.So IDisposable (I can be provided with) 118 interfaces realize can be used for breaking circular reference.IDisposable118 realizes comprising and is used to be provided with and to remove scripting object and to the logic of quoting and the mechanism of other scripting objects.Following pseudo-code shows an exemplary realization of IDisposable 118 interfaces:
//Web.IDisposable
·Web.IDisposable=function(){
this.dispose=Function.abstractMethod;
}
·Type.registerInterface(′Web.IDisposable′);
//
In a word, script application programe framework 100 is encapsulated into the generic script logic in each assembly, and the definition of each scripting object is provided, and lets each scripting object communicate with one another through the mechanism such as binding and moving.So script application programe framework 100 just provides a kind of structure for traditional ad hoc script.
Should be appreciated that the theme that in accompanying claims, defines there is no need to be limited to above-mentioned special characteristic or realization.On the contrary, above-mentioned concrete characteristic discloses as the exemplary forms that realizes claim with realizing.