Changes for page Release Notes for XWiki Enterprise 4.1
Last modified by Thomas Mortagne on 2017/03/24
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -115,6 +115,48 @@ 115 115 116 116 * New diff/merge module has been added to make easier to deal with diff and merge both from component and scripts. See [[Diff module >>extensions:Extension.Diff Module]] for details. 117 117 118 +== Easy variable sharing between scripts == 119 +It's now much easier to share variable between languages. 120 +You can now create a variable in a Groovy script and use it in a Velocity script. 121 + 122 +For example:((( 123 +{{code language="none"}} 124 +{{groovy}} 125 +var = "toto" 126 +{{/groovy}} 127 + 128 +{{velocity}} 129 +$var 130 +{{/velocity}} 131 +{{/code}} 132 +))) 133 + 134 +== Script access to Component Manager == 135 +With the [[new Component Access Script Service>>platform:DevGuide.Scripting||anchor="HXWikiComponentAccess"]] privileged scripts can now easily load components from the Component Manager (XWiki's dependency injection system). This is not available in Velocity because of it's limited capability to load classes. 136 + 137 +For example:((( 138 +{{code}} 139 +{{groovy}} 140 +def myComponent = services.component.getInstance(MyComponentRole.class) 141 +{{/groovy}} 142 +{{/code}} 143 +))) 144 + 145 +== Velocity interprets Strings in function calls == 146 +With the [[new Velocity uberspector>>doc:extensions:Extension.Velocity Module||anchor="HMethodArgumentsUberspector"]], Velocity will convert method arguments in string form to formal parameter types when the passed arguments don't match the method signature. 147 + 148 +For example:((( 149 +{{code}} 150 +$obj.someMethod('VALUE') 151 +// will forward to 152 +obj.someMethod(SomeEnum.VALUE) 153 +// if obj has a method with signature someMethod(SomeEnum) and not someMethod(String) 154 +{{/code}} 155 + 156 +But this is not limited to enums. The conversion is done using the [[Properties Module>>doc:extensions:Extension.Properties Module]] which means you can create and register custom converters for data types specific to your application domain. 157 +))) 158 + 159 + 118 118 == Taming of Groovy scripts == 119 119 120 120 Since traditionally, Groovy scripts can enter into unstoppable infinite loops, use reflection to violate security assumptions, access server resources, or even crash the virtual machine, they have been off limits to non-administrators.