TAILIEUCHUNG - Bắt đầu với IBM Websphere smash - p 34

312 Chapter 13 PHP in WebSphere sMash Listing import import import import Common Template for PHP Extension Classes ; ; ; ; @XAPIExtension("MyExtensionClass") public class MyExtensionClass extends ExtensionBaseImpl { @XAPIArguments(MandatoryArguments = 1, PassSemantics = { }) @XAPIFunction("myFunction") public void myFunction(RuntimeContext ctx) { //-- Extract arguments from context String arg1 = (0).getString(); //-- Do something here String something = someFunction( arg1 ); //-- Optionally Set return value ( something ); } //. remaining code removed . } A couple items are worthy of mention in this template sample. First, notice how the class and function have their own XAPI annotations. Although in this template, the annotation. | 312 Chapter 13 PHP in WebSphere sMash Listing Common Template for PHP Extension Classes import import import import @XAPIExtension MyExtensionClass public class MyExtensionClass extends ExtensionBaselmpl @XAPIArguments MandatoryArguments 1 PassSemantics @XAPIFunction myFunction public void myFunction RuntimeContext ctx -- Extract arguments from context String argl 0 .getString -- Do something here String something someFunction argl -- Optionally Set return value something . remaining code removed . A couple items are worthy of mention in this template sample. First notice how the class and function have their own XAPI annotations. Although in this template the annotation and the class function names match they do not need to. You can choose to have a public PHP function name and a private Java name. For example the PHP annotation of the function could be called my_function whereas the actual Java function name could remain myfunction. The second thing of note is how we obtain the function arguments from the RuntimeContext. The context has several getXxxArgument functions based on the type of object you are attempting to access. RuntimeContext arguments are zero-based. The last item of interest in this template is the optional XAPiArguments annotation. This is useful when you want to explicitly require a set number of arguments by a function. The default behavior of the PHP extension s argument handling is to pass all arguments by value meaning Download from Extending PHP 313 that the source PHP variable cannot be altered by the extension functions. If you want to enable the extension function to modify the argument source values the XAPiArguments- Pass Semantics value needs to be set to as .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.