Explore groovy mop nine interceptor 1
In recent years, AOP (Aspect-Oriented Programming) has been widely used. We have applied it to various aspects such as printing logs and permission control. When Implementing AOP, we generally use tools such as Spring AOP.
Of course, tools are generally used to implement system-level AOP. Such implementations are generally implemented through configuration documents.
When we need to implement a small range of AO
1. Inline syntax?? The rules demonstrate as follows, and the weights and the parties must specify specific parameters. Also, variables that use inline syntax must start with an uppercase letter.model.add ( ' Dogs ') Likes (B, ' Dogs ')) >> Friends (A, B), 5.0, True);?? Because the inline syntax must be a subset of the groovy syntax, the following operator variants are not supported:
||-!
?? Note that the variants are supported b
The groovy language has a lot of seemingly obscure gadgets, but after use, we often marvel at its enormous energy, and gstring is one of them.
The Java string object is our most common object, but it is also the most criticized object. In a word, string is very inconvenient to use. Gstring is not only easy to use, but also the basis of the dynamic nature of groovy language.
The so-called gstring refers to
In a keynote speech with Martin Fowler, he provided an astute observation:
Java's legacy is platform, not language.
The original Java Technology engineer made a terrific decision to detach the language from the runtime, eventually enabling more than 200 languages to run on the Java platform. The infrastructure is critical to the long-term viability of the platform, because the computer programming language is usually short-lived. The JVM language summit, hosted by Oracle every year since 2008,
Groovy supports two types of strings: A generic Java string, an instance of java.lang.String, and Gstrings, which is an instance of groovy.lang.GString, and allows the text to contain placeholders. Gstrings is not a subclass of string because the string class is the final class (final Class) that cannot be inherited. However, Gstring is the same as a generic string, because groovy can transform gstrings int
that the language can be composed entirely of expressions, ignoring results when not interested in the results. In fact, all functional languages can completely eliminate this distinction, using only expressions.
Groovy's if and?:
In the Java next-generation language, the separation between traditional imperative language (Groovy) and functional languages (Clojure and Scala) shows evolution to expressions. Groo
The groovy language does a lot of good work on the input parameters of the method, some of which can improve the readability of the code, and some can provide easy and agile coding. In the previous text, we have introduced some, such as the Groovy Discovery map and DSL. In this series, we will introduce some of them that have not been mentioned before.
First, it is about the use of parentheses when invokin
xml| syntax Groovy's team leader--Guillaume Laforge says that MOP (Meta Object Protocol) is his favorite groovy feature.
Using mop can simply intercept and interpret properties and methods, and intercept has become familiar with AOP. In groovy, by overloading the Groovyobject Get/setproperty () function and the InvokeMethod () function, you can add your own hooks and behavior, More simple than Java to impl
Make sure you understand Ngrinder's groovy scripting structure: Ngrinder's Groovy Scripting Usage Guide (groovy scripting structure)
When you create a Groovy script on Ngrinder, it automatically generates a basic script that lets us split the description
Import Httpclient.cookie Import httpclient.cookiemodule import ht
Label:Groovy has a database-enabled class library:Search for SQL Groovy in Bing, find sql (groovy 2.4.3)and click to open this URL:Http://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.htmlWith Groovy's class SQL, you can connect to the database and make the data more and more censored, referred to as crudCRUD means:create, Retrieve, Update, DeleteGroovy
If you want to retrieve variables from a complex nested data structure, velocity is used, but groovy is recommended because it is more convenient for computation, and gave me a general framework, which is still being explored ...... Put parameters in Map
Public object executescript (string script, Map
Groovy tip 35 Regular Expression 4
We know that in regular expressions, some strings are used to express some special purposes. For example, "." represents all characters; "^" represents non-; and so on. When we see these usage, we can ask in turn, if "." represents all the characters, then what will be used to match "." In the string?
To solve this problem, you must add "/" to the regular expression to match the original string. The following is a
Groovy exploration-adding constructors and static methods during the mop six Runtime
Constructor is a method that we like to overload, because we encounter various situations when instantiating a class, such as in some situations, instances of a series of classes may have attributes with the same value. At this time, when instantiating an object, we do not want to inject these identical values into each object separately, this is a tedious task.
A
The returned results may need to be verified during case construction. You can use the groovy script to complete this function. The specific steps are as follows:
(1) Use the groovyutils provided by soapui to retrieve the returned XML message xmlholder
Def policyutils = new COM. eviware. soapui. Support. policyutils (context)
Def holder = policyutils. getxmlholder ("balancequery # response ")
(2) Use XPath in xmlholder to obtain the returned f
Basic Input and Output
5.1 Basic output
Print XXX // same row output
Println XXX // line feed output
Output string:
Def message = "My name is Michael"
Println ("here is:" + $ {message })
Output list and ing
Def numbers = [11,12, 13,14]
Println "numbers :$ {numbers}" // traverses the list
5.2 format the output
Simple output
Prinf ("My name is Michael", [])
Format output
Prinf (format, values) // % d integer output % F Floating Point Output
Def A = 3 B = 5
P
Array:def x = new String[5]x[0] = "India" x[1] = "USA" x[2] = "Korea" x[3] = "Japan" x[4] = "China" log.info "Size of list is" + X.S Ize () Log.info "The first item in list is:" +x[0]for (String item:x) {Log.info Item}Result:Tue June 14:50:08 CST 2015:info:size of list is 5Tue June 14:50:08 CST 2015:info:the first item in list Is:indiaTue June 14:50:08 CST 2015:info:indiaTue June 14:50:08 CST 2015:info:usaTue June 14:50:08 CST 2015:info:koreaTue June 14:50:08 CST 2015:info:japanTue June 14:50:08
Lisp is a simple and powerful language with a very simple syntax:(+ 1 2)The above meaning is: + is a method or function, 1, 2 is a parameter, fn=1+2, that is, the sum is evaluated, the result is: 3Double brackets are used to remind the interpreter to start and end.Previously wrote an article in Iteye to briefly explain how to write Lisp's interpreter:http://gyc567.iteye.com/blog/2242960It also draws a sketch to illustrate:Because Lexer ( lexical analyzer ) is the main job is to convert the progr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.