Servlet NewJavaServlet Test



Yüklə 11,16 Mb.
Pdf görüntüsü
səhifə4/97
tarix07.11.2018
ölçüsü11,16 Mb.
#78896
1   2   3   4   5   6   7   8   9   ...   97


 CONTENTS  
 
viii 
Summary ....................................................................................................................................... 112

■ 
Chapter 6: Object-Oriented Jython .............................................................................................113 
Basic Syntax .................................................................................................................................. 113

Object Attribute Lookups ................................................................................................................ 117

Inheritance and Overloading........................................................................................................... 119

Underscore Methods ...................................................................................................................... 121

Protocols........................................................................................................................................ 123

Default Arguments ......................................................................................................................... 127

Runtime Binding of Methods .......................................................................................................... 128

Caching Attribute Access ............................................................................................................... 128

Summary ....................................................................................................................................... 131

■ 
Chapter 7: Exception Handling and Debugging..........................................................................133 
Exception Handling Syntax and Differences with Java .................................................................... 133

Catching Exceptions................................................................................................................... 134

Raising Exceptions..................................................................................................................... 142

Defining Your Own Exceptions........................................................................................................ 143

Issuing Warnings ........................................................................................................................... 143

Assertions and Debugging.............................................................................................................. 148

Context Managers.......................................................................................................................... 148

Summary ....................................................................................................................................... 150

■ 
Chapter 8: Modules and Packages for Code Reuse ...................................................................151 
Imports for Reuse .......................................................................................................................... 151

Import Basics............................................................................................................................. 151

breakfast.py........................................................................................................................... 151

The Import Statement ................................................................................................................ 153

An Example Program...................................................................................................................... 153

greetings.py........................................................................................................................... 154

greet/__init__.py................................................................................................................... 154

greet/hello.py......................................................................................................................... 154

greet/people.py...................................................................................................................... 154

Trying Out the Example Code ..................................................................................................... 154

Types of Import Statements ........................................................................................................... 155

From Import Statements ............................................................................................................ 155

Relative Import Statements ........................................................................................................ 156

www.it-ebooks.info



 CONTENTS  
 
 
 
ix 
Aliasing Import Statements ........................................................................................................ 156

Hiding Module Names ................................................................................................................ 157

Module Search Path, Compilation, and Loading.............................................................................. 157

Java Import Example ................................................................................................................. 157

Module Search Path and Loading............................................................................................... 158

Java Package Scanning ................................................................................................................. 158

How Jython Finds the Jars and Classes to Scan ......................................................................... 159

Compilation ............................................................................................................................... 160

Python Modules and Packages versus Java Packages.................................................................... 160

sys.path..................................................................................................................................... 160

Naming Python Modules and Packages...................................................................................... 160

Proper Python Naming ............................................................................................................... 161

Advanced Import Manipulation ....................................................................................................... 161

Import Hooks ............................................................................................................................. 161

sys.path_hooks.......................................................................................................................... 161

sys.meta_path ........................................................................................................................... 162

Summary ....................................................................................................................................... 162

Part II: Using the Language .............................................................................................................163 
■ 
Chapter 9: Scripting With Jython................................................................................................165 
Getting the Arguments Passed to a Script ...................................................................................... 165

Searching for a File ........................................................................................................................ 166

Manipulating Files.......................................................................................................................... 167

Making a Script a Module .............................................................................................................. 168

Parsing Commandline Options ....................................................................................................... 169

Compiling Java Source................................................................................................................... 170

Example Script: Builder.py ............................................................................................................. 170

HelloWorld.java .............................................................................................................................. 172

Summary ....................................................................................................................................... 173

■ 
Chapter 10: Jython and Java Integration ...................................................................................175 
Using Java Within Jython Applications ........................................................................................... 175

Using Jython Within Java Applications ........................................................................................... 178

Object Factories......................................................................................................................... 179

One-to-One Jython Object Factories ...................................................................................... 179

Summary of One-to-One Object Factory................................................................................. 182

www.it-ebooks.info


Yüklə 11,16 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   97




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə