Accessing Application Context Listing
Total Page:16
File Type:pdf, Size:1020Kb
19_1936_index.qxd 7/11/07 12:14 AM Page 503 INDEX A Ant BSF Support Example Accessing Application Context listing listing (7.12), 314 (10.2), 463 Ant task, Groovy, 132-133 Active File Example listing (8.20), 376 Ant Task That Compiles All Scripts Inside Active File Generator listing (8.22), 380 the Project listing (8.10), 357 active file pattern, 375 AntBuilder Example listing (7.14), 317 consequences, 375 any( ) method, Groovy, 175-177 problem, 375 any( ) Method listing (4.30), 175 sample code, 376-380 Apache Web servers, 62 solution, 375 BSF (Bean Scripting Framework), 94 Active File Template listing (8.21), 379 APIs (application programming ADD keyword, 5 interfaces), 49 addClassPath( ) method, 324 Java, 80-82 administration append( ) method, Groovy, 181-182 scripting, 328-334 append( ) Method listing (4.39), 182 scripting languages, 55-58 application scope, Web environments, 449 Administration Script Example application variable (Groovlet), 215 listing (7.17), 329 applications Advanced Ant BSF Support Example BSF (Bean Scripting Framework), 275 listing (7.13), 315 JSP (JavaServer Pages), 275-280 Advanced AntBuilder Example Xalan-J (XSLT), 280-287 listing (7.15), 320 Java, 79 Advanced Binding Example—Java web applications, 59, 61-67 Application listing (9.13), 408 ASP (Active Server Pages), 64 Advanced Groovy Programming Example games, 68-69 listing (5.22), 225 JavaScript, 65-67 AJAX (Asynchronous JavaScript And Perl, 61-62 XML), 66 PHP, 62-64 Ant build tools, 309-322 UNIX, 68 19_1936_index.qxd 7/11/07 12:14 AM Page 504 504 INDEX apply( ) method, 263-264 BeanShell, 80, 83-98, 126 architecture commands, 91 BSF (Bean Scripting Framework), downloading, 83 248-249 GUI (graphical user interface), 84 compilers, 9 Java, embedding with, 94-98 hybrid compiler-interpreters, 11 manual, 98 interpreters, 10 methods, 91-92 Java, 80-82 modes, 84 Scripting API, 391 objects, 92 Web Scripting Framework, 448, running, 84 482-488 scripting context, 448-449 autoboxing, 89-90 interaction, 451-453 basic syntax, 86-87 servlet, 449-451 for loop, 88-89 arguments, command-line arguments, interface implementation, 93-94 Groovy, 136 JavaBeans, 88 Ascher, David, 29 loosely typed syntax, 87 ASP (Active Server Pages), 64 switch-case statement, 90 assembly languages, 5 Workspace Editor, 85 assertArrayEquals( ) method, 298 “Best Tool for the Job, The”, 36 assertContains( ) method, 299 Bezroukov, Nikolai, 68 assertEquals( ) method, 294 binding, 186 assertion methods, unit testing, 297-300 dynamic binding, 442 assertLength( ) method, 298 programmatic binding, 442 assertScript( ) method, 299 Scripting API, 404-411 assertToString( ) method, 299 dynamic binding, 442-444 attributes, script context, 419-423 engine scope, 405-411 autoboxing global scope, 411-416 BeanShell, 89-90 script context, 416-428 Groovy, 140 Binding Example listing (9.11), 406 Autoboxing listing (4.7), 140 Binding listing (4.44), 186 AutoCAD, 50 bindings, Web Scripting Framework, 462 application, 462-464 B request handling, 464-467 basic syntax response, 468 BeanShell, 86-87 servlet, 468-469 Python, 101-103 bootstrap class loaders (JVM), 81 Bean Scripting Framework (BSF). See BSF Broadcasters Example listing (8.17), 367 (Bean Scripting Framework) broadcasters pattern, 359 beans, BSF (Bean Scripting Framework) consequences, 362 declaring, 268-270 problem, 359-360 registering, 265-268 related patterns, 369 19_1936_index.qxd 7/11/07 12:14 AM Page 505 INDEX 505 sample code, 362-369 changed( ) method, 347 solution, 360-362 class files, Java, 80 BSF (Bean Scripting Framework), 94, class loaders (JVM), 81 245-246 bootstrap class loaders, 81 Ant scripting, 313-316 user-defined class loaders, 82 applications, 275 classes, 14 JSP (JavaServer Pages), 275-280 Groovy, 159-161 Xalan-J (XSLT), 280-287 JavaAdapter class, 114 architecture, 248-249 Classes listing (4.17), 159 beans classpaths, Groovy, setting, 131-132 declaring, 268-270 closures registering, 265-268 Groovy, 168-177 compilation, 270-275 curly braces, 172 data binding, 264-270 resource handling, 176-177 downloading, 247 method closure, 92 engine initialization, 252 methods, curly braces, 172 exception handling, 255 scripting language, 20 functions, 259-264 Closures listing (4.23), 170 manager initialization, 252 code. See also listings; scripts methods, 259-264 active file pattern, 376-380 origins of, 247 as data, 19-23 script files, executing, 257-259 bytecode, 7 Scripting API, compared, 445 development speed, 28-29 scripting language registration, 249-252 extension point pattern, 371-374 scripts, 253-257 mediator scripting pattern, 345-354 BSF Exception Handling listing (6.2), 256 observer pattern, 362-369 BSF JSP Example listing (6.20), 279 operation code, 4 BSFEngine.apply( ) Method Example runtime performance, 26-28 listing (6.7), 263 script object factory pattern, 356-359 BSFEngine.eval( ) Method Example scripted components pattern, 340-341 listing (6.1), 254 source code, production environment, BSFEngine.exec( ) Method Example 12-13 listing (6.3), 256 code generation, Scripting API, 428 BuilderSupport, Groovy, 235-236 method call syntax, 429-431 building tools, Ant scripting, 309-322 output statement, 429 built-in functions, 19 programs, 431-432 bytecode, 7 collect( ) method, Groovy, 173 collect( ) Method listing (4.25), 173 C collections, Groovy, 148 C++, Java, compared, 78 lists, 149-151 call( ) method, 169, 260 maps, 152-153 Cascading Style Sheets (CSS), 66 ranges, 151-152 CBD (component-based development), 40 19_1936_index.qxd 7/11/07 12:14 AM Page 506 506 INDEX command-line arguments, Groovy, 136 context, Web Scripting Framework commands, 19 architecture, 448-449 BeanShell, 91 Creating an Sql Object with DataSource compatibility, Java and Groovy, 137 listing (5.6), 202 Compilable interface, 437-440 Creating Documents with DomBuilder Compilable listing (9.35), 438 listing (5.28), 233 compilation, BSF (Bean Scripting cross-platform portability, Java, 77 Framework), 270-275 CSS (Cascading Style Sheets), 66 compilation languages, 52 curly braces, closures, methods, 172 Compile Example listing (6.13), 271 currentThread( ) method, 444 Compile Example—Result listing (6.14), 271 Custom Application Context compile( ) method, 275 listing (9.26), 424 Compiled Script Usage Example Custom BuilderSupport Implementation listing (6.18), 274 (BuilderSupport.java) listing (5.30), 235 compileExpr( ) method, 272 Custom Engine Writer Example compilers, 6 listing (9.28), 427 architecture, 9 custom namespaces, 423-427 hybrid compiler-interpreters, 11 Customized compileExpr( ) Method interpreters, compared, 8-12 listing (6.15), 272 compiling scripts, Groovy, 130-133 Cygwin, 323 Compiling Groovy Scripts with Ant listing (4.2), 132 D component-based development (CBD), 40 DAO (Database Access Object) design components pattern (scripting), 337 paradigm, 196 consequences, 339 data binding, BSF (Bean Scripting problem, 337-338 Framework), 264-270 related patterns, 341 data structures, scripting languages, 17-19 sample code, 340-341 Database Access Object (DAO) design solution, 338-339 paradigm, 196 composite types, programming database queries, GroovySQL, 202-205 languages, 14 databases, transactions, GroovySQL, computer programs, 5 208-209 configuration datasets, GroovySQL, 209-212 Groovy, 492 Davidson, James Duncan, 52, 311 Web Scripting Framework, 456-462 debugging, interactive debugging, consequences 304-309 active file pattern, 375 Declare Bean Example—Java Application extension point pattern, 370 listing (6.11), 269 mediator scripting pattern, 345 Declare Bean Example—Script observer pattern, 362 listing (6.12), 270 script object factory pattern, 356 declareBean( ) method, 268-269 scripted components pattern, 339 declaring beans, BSF (Bean Scripting Framework), 268-270 19_1936_index.qxd 7/11/07 12:14 AM Page 507 INDEX 507 Defining a Custom Namespace dynamic linking, Java, 78 listing (9.25), 424 dynamic typing, 15-16 dependencies, Groovy, 131 Groovy, 139-140 design patterns, scripting, 335-337 Dynamic Typing and Polymorphism active file pattern, 375-380 listing (4.6), 139 extension point pattern, 369-374 mediator pattern, 341-354 E observer pattern, 359-369 each( ) method, GroovySQL, 171-172, 211 script object factory pattern, 354-359 each( ) Method listing (4.24), 172 scripted components pattern, 337-341 each( ) Method listing (5.15), 211 Design Patterns, 336 eachByte( ) method, Groovy, 180-181 Determining the Attribute’s Scope eachByte( ) Method listing (4.36), 181 listing (9.21), 420 eachFile( ) method, Groovy, 182 development, CBD (component-based eachFile( ) Method listing (4.40), 182 development), 40 eachFileRecurse( ) method, Groovy, 182 development speed, code, 28-29 eachFileRecurse( ) Method DHTML (Dynamic Hypertext Markup listing (4.41), 182 Language), 66 eachLine( ) method, Groovy, 179 Dickerson, Chad, 56 eachLine( ) Method listing (4.33), 179 disabling scripting, Web Scripting eachRow( ) method, GroovySQL, 202-203 Framework, 456-457 eachRow( ) Method and GString Query discovery mechanism, Scripting API, Parameters listing (5.7), 202 391-393 eachRow( ) Method and List Query Discovery Mechanism listing (9.1), 393 Parameters listing (5.8), 203 DomBuilder, Groovy, 232-233 Eckel, Bruce, 30 doSomeAction( ) method, 374 Eclipse IDE, 130 downloading embedding BeanShell, 83 BeanShell with Java, 94-98 BSF (Bean Scripting Framework), 247 Groovy, 184-190 Groovy, 491 Pyhton with Java, 108-109 Jython, 98 Rhino with Java, 114-120 Rhino, 110 scripting languages, 70 dynamic binding, 442, Scripting API, engine initialization, BSF (Bean Scripting 442-444 Framework),