OSS report system training notes
Training company: Zhongke Tiandi (Wang Haige, teacher is super good)
Edited by Hen Egg, Michelangelo
2005-2-21
8:00
JasperReport spending
OO application server
Java open source database
J2EE demand analysis
Grade:
Classroom performance
project
project:
l Java platform
(1) (Programming Language) Development Environment (Compiler)
(2) Deploying the environment (Application Server) (JDK provides software running server and basic operating conditions, the development needs to be configured on this) The purpose is to reuse (related tool classes)
(3) Operation environment (operating system)
--JVM virtual machine is an operating system, that is, the operating environment
--Java package file
- garbage collection memory management
- Virtual CPU (advantage)
- thread
(1) (2) (3) Unified environment simple development
l java language
1. OO (most important feature) - a large system
2. Portable JVM (not important)
3. Distributed JVM AppServer - cross-platform system
Make full use of network resources cross-regional cross-border
4. safety
UNIX: Strong security
JVM built-in strong security> UNIX
Key business
1. Life
Medical examination public security heavy-duty industrial aviation
2. Money
bank
summary:
JVM is an operating system
Java is object-oriented, distributed, secure language
PS: The above red-grade bold part is a key technology of Java
l Java virtual machine
1. Garbage collection
2. Distributed Support Various Agreements
3. Multithreading thread management
4. safety
concept
Simulated a computer
Features
1. Garbage recycling:
(In memory) NEW objects are loaded into the object stack
A = new air;
New an object
Call the constructor, allocated in the object heap
Return a reference
Reference counter
When the counter is reduced to 0, the variable becomes garbage, removed from the list.
Waste collection: memory leak, empty pointer
Garbage collection mechanism:
Backstage Elf Thread: When the CPU is idle, call the thread (priority) requires the CPU to be idle (with Java first CPU re-memory again NIC)
2. Provide runtime environment
The function of the operating system, responsible for transferring code, supervising code, help programs do input, providing a series of support to the program
Provide CPU register network read and write file system security
Class Loader loading
Byte Code Verifier File Format Grammatical Architecture Crossing
Check 4 times
Interpreter: Intermediate Code
JIT instantly compiled (fast) (compiled cost code)
Install JDK
Configure environment variables
Java_Home C: / J2SDK
PATH;% java_home% / bin
Classpath.;% Java_home% / lib
(PS: DOS window cannot be automatically refreshed, remember to remember after changing environment variables)
14:00
class:
customize
abstract
package:
Package
Combine together with a similar class
Package is a relative path, equivalent to folders in Windows
IMPORT has introduced a namespace
IMPORT is not equal to include include
If you don't write, the system defaults a package.
Java code three parts
1) Package com.project.src
2) Import java.io. *;
3)
There are multiple classes in a file, but there is only one public class.
EG1
STATIC void main (string [] args)
Main Method Is Not PUBLIC
2. Public void main (String [] ARGS)
Exception in thread "main" java.lang.nosuchmethoderror: main
Main is the entrance to the entire program, cannot be used in New because it is a STATIC method, so it is directly executed when it is loaded, but main is not a keyword.
3. Public static main (String [] ARGS)
TesthelloWorld.java: 4: Invalid method Declaration; Return Type Required
Public static main (String [] ARGS)
Java specifies a range of range, without return values must be defined as Void. But the constructor is not allowed to have a return type.
4. Public static void main (String [] args) == static public void main (string [] args
Any access control and modifier position. But habits to put access control strokes
5. But the return type cannot be placed in front of both.
Testhelloworld.java: 4:
void static public main (string [] args)
^
TesthelloWorld.java: 8: '(' expected // return value must close the method name
}
^
2 Errors
MAIN is not a keyword, but you don't use it.
6. String [] ARGS
Starting from Arg [0]
Note:
Used
//
/ * * /
Javadoc comment
/ **
* /
Change the document with javadoc
Javadoc HelloWorld.java -d Doc
Java Keyword & Identifier & Reserve Words
The beginning of the identifier: letters (_, $)
Coding Standards:
1) meaningful words consisting, the first word first letter lowercase, other words first letters
2) The variable name and method name are equally handled.
3) The constant consists of meaningful words, all words are all written, and the words are separated from the underside.
4) Class name first letter capitalization
Java data type
1. Basic data type (not object)
8 kinds:
Int, Long, Short, Byte, Float, Double, CHAR, BOOL.
2. Reference type
Objects can only be accessed by reference
In fact, a safe pointer
Array is a reference type (because he is a pointer type in the C language)
default:
Char '/ u
0000 '
Bool false
NULL
Array NULL
Expression and process control
Don't use -, it is easy to cause misconduct in addition to the circulation
= ===: == can only be used for basic types, do not use the reference type. Equals
Short-circuit operator: if (Lasting! = NULL) &&, || Put the highest probability in front, save the time execution
Type conversion
High-level rotation, must be mandatory transformation, SHORT and CHAR conversion
Transfer and pass value
Basic type pass value
Reference type transmission reference
Biography of variables
Control flow, cycle
It is best not to use Switch (destroy the package, consume performance, damage process)
Branch try to use if else
Cycling to use for for
While (True) in the server, doing dead cycles
Don't use Do-while
Exercise 1
Mandatory type conversion
Exercise 2
Pass
2005-2-22
8:00
l Java OO
The earliest object-oriented SmallTalk, later C , Java, Phyon, .NET
SmallTalk pure Java is not pure (basic type, etc.)
Java is an implementation of object-oriented objects
Object -> Data <- Operation
The relationship between objects -> News
OO: Analyze the design in accordance with the logic of conforming thinking habits, forming a model, an object-oriented system.
note:
1. Do not inherit the class with code. Class of code, use the combination of objects.
2. Inherit the abstract base or interface (n). The interface is designed and cannot be reduced and modified.
3. Multiple inheritance itself is right, it is essential, but to limit multiple or single inheritance, destroy encapsulation.
Polymorphism:
Technical realization:
1. Compile: SRC inspection form type (declaration)
2. Running: JVM Check the actual type
Overload:
(Compilation)
Handling the same method name, different parameter list
Use method signatures in the compiler. (Method Signature, consisting of method name parameter list)
Do not use operator overload
14:00
Class (practical class):
1. Class head
Only public and default, no private class
2. Attributes
STATIC only retains a copy. Save together with class code
Structure of static properties: static {} block.
Non-static
3. Method
4. Construction method (not the basic structure of the class)
5. STATIC block
L-class definition
[Permissions] [Modification] Class class name [EXTENDS Parent Class Name] [IMPLEMENTS Interface List]
{
Specifier;
}
Permissions: Public - public class
No public - same packages
Modification: Abstract Abstract class can only be inherited (if there is an abstract method in a class, this class must be an abstract class. Conversely, abstract classes do not necessarily include abstract methods) cannot be instantiated
Final ultimate class, perfect class, cannot be inherited. Only instantiate
PS:
1: General static variables are defined into constant
2: Use static methods to access instance variables, Static
3: Native calls local C code in Java
4: Structure: Select Native (Advanced)
5: The interface is used as a reference type, and any instance that implements the interface can exist in the variable of the interface type.
Data member:
[Permissions] [Modified] type variable name [= initial value];
Modification: static has - class variable (class name points)
Static no - instance variable (object name points)
Final for modifying constants
Static final int N = 5; (90% or more), add Final to constant into constants. Optical STATIC Destroying Packaging Methods:
[Permissions] [Modified] Return Value Type Method Name (Line Platform List) (passing the value does not pass)
{
Method body;
}
Modification: static (static method can not access instance objects)
Final (not overloaded) (can not be used)
Abstract (This class must declare an abstract class)
Native local method. You can call local code, such as calling C code.
Member privilege
PUBLIC> Protected> PRIVATE
DEFAULT
Protected with package subclass
The method in the interface is default: public abstract
Construction method: (only to initialize non-static properties, static methods can not operate non-statically attributes, and vice versa)
Method name = class name
General is not public access
Can't have any modifications
No return value type
If a constructor is not provided, the system provides a non-arranging construction method. However, there are any own written construction methods, and the default construction method is immediately invalid.
When the class is inherited, the construction method is not inherited.
Initialize the parent class Super (). If the parent class is an abstract base class, it will not be added.
Super ()
this ()
Interface definition
[Permissions] Interface interface name [Extends interface list]
{
Interface;
}
Multiple interfaces can be inherited. Assembly, called interface
Interface is generally declared as public
The interface is used as a reference type. Through these variables, all methods that implement the interface can be accessed.
Exercise:
1. MOD02 / EXERCISE3
The public method of the class is called a class interface.
Write an Account class in Banking
Test with TestBanking
2. Add class Customer to Banking.
3. Modify TestBanking. Use Customer to operate Account.
2005-2-23
8:00
1. Demand analysis (TOP N)
concept
business
Business Process
2. Model (correction)
Example: Bank Account Account and Customer Customer Relationship
1) Customer has one or more accounts
2) Accounts are associated with a customer (exception: joint account)
3) Customer private, control account
demand analysis
Overall design
detailed design
Example: Bank and customers, accounting relationship
Bank has several customers
Customers can choose from multiple banks (cross borders)
There can only be one bank in the system (system boundary)
Bank should preserve customer information
Bank has a ruling right
Interior of the bank class (bank class fully created control account)
Claim:
Create a customer
User submission: last name, name, initial quota, ID number, six password
Create an account
submit:
ID card number, initial balance
business:
identification number
account number
password
Business selection (parameter): access payment balance
Meet the standard
Summary design
1. Demand (10 ~ 15 minutes)
Hand writing sketch
2. Sustbe a sketch
Modify sketch
3. Submit a modified sketch
4. Merge modification sketch
5. Classification: Each class two people
6. Assembled to a machine, compile operation 10: 43--17: 30
Banking project
2005-2-24
8:00
Project general review
Detail problem:
1. Only there is a Bank, design method:
Sington design mode:
The construction method is private, then he cannot create him from the outside world.
Save it with the static constant of this class.
Static Final Bank Bookintance = New Bank ();
Bank class is loaded into memory
New has a Bank instance and there is a static area
Private bank ()
{
Customers = New Customer [MAX];
Customernumber = 0;
}
Private static final bank Bankinstance = new bank ();
Public static bank getBankInstance () {
Return BankInstance;
}
or:
Private static final bank Bankinstance = NULL;
Public static bank getBankInstance () {
IF (BankInstance = NULL)
Bankinstance = new bank ();
Return BankInstance;
}
In Test.java
Bank ABANK = Bank.getBankInstance ();
3. Array
The reference array is the pointer of the pointer, so it is necessary to determine
Vector, List, ArrayList (only type of objects can also be done), but also
4. The password management method cannot use getPassword (). Use verify ().
Class content:
abnormal
Abnormalities in Java
60% of the code for processing exceptions
Any exception is packaged into an abnormal object
When there is an abnormal time, throw an abnormal object to give JVM. JVM to check the stack
Production of abnormal code does not process exception
benefit
1) Treatment of abnormalities with objects
2) Use the virtual machine as an abnormal object transfer
3) Normal code and processing exception code is completely separated
Try
{
Unsafe;
} catch (exception class E)
{
Abnormal treatment;
}
Method declaration is throws, when the method is practical, it must be placed in TRY, CATCH structure
Public void f (int score) throws myexception
{
IF (score <0 || score> 100)
Throw new myexceptino ("");
}
When inheriting, you cannot throw an exception exceeding the parent class.
TIPS:
The interface is used to lead the class, classified
Class is a tool for implementing interface, instantiation interface
I / O stream
Enter flow, output flow is control the same stream
Character, byte type
Category, STREAM, is both byte stream, reader is a character stream.
InputStreamReader converts the word throne to a character stream
// Translate System.IN into a buffered character stream
BufferedReader IN = New BufferedReader (NEW INPUTSTREADER (System.in))
in.readline ()
The internet
Add to
Client end, server end, protocol interpreter
Socket connection
Agreement
Agreement parser
New Serversocket
accept ()
New Socket
Example:
SERVER
1. NEW a serversockettry {
S = New Serversocket (5432);
} catch (ioexception e) {}
2. Build a dead cycle
While (True)
{
Try {
Socket S1 = S.Accept ();
} catch (ioexception e) {}
}
3. Communication with ordinary Socket
OutputStream S1out = S1.GetOutputStream ();
DataOutputStream DOS = New DataOutputStream (S1out);
dos.writeutf (input);
dos.close ();
S1.Close ();
Client
1. Built a normal socket
SOCKET S1 = New Socket ("127.0.
0.1 ", 5432)
2. Socket communication
InputStream IS = S1.GETInputStream ();
DataInputStream DIS = New DataInputStream (IS);
System.out.println (Dis.ReaduTf ());
Dis.close ();
S1.Close ();
operation:
1. Use examples and processes
2. Design class library, Server structure
2005-2-25
8:00
Multithreading
Business needs concurrent visit
Technical demand multi-process, multi-thread
I / O flow blocks the current process
technology
Model one
1. Create thread thread
2. The code running in the thread is the code of the object
Define a class that implements the runnable interface, implementing his Run () method, and then the instance of this class as the parameter of the Thread constructor. Create an instance of the Thread class.
In the server
New Thread (Object); // Object Tool Class, save all parameters. (Including business code)
.start.
Construct this class
Class BusinessClass Implements Runnable
{
Public void Run ()
{
Code; // call other objects to complete the business and interaction.
}
}
See Exercise / MOD15 / EXERCISE1
Internal class
when
External-> internal code (function)
Inside -> External non-public
Need practical internal classes
summary:
1. New thread (class)
2. Define this class, IMPLEMENTS RUNNABLE
C / S Bank project
11:00 ~
2005-2-26 17:40
2005-3-7
8:00
review:
Object-oriented: clear, package, abstraction (for interface programming), multiplexed (IO class, collection class)
C / S -> B / S
the difference:
C / S is a development model based on an operating system (JVM) and a basic class library (JDK).
B / S is based on the development model of the "container".
B / S Advantages: Shielding the underlying
1. Bringing convenience, re-use basic code and services to commercial systems (transaction security)
2. Can be used to prove effective (rate) software architecture (J2EE core mode MVC)
3. Business technical support (third party)
C / S Advantages:
1. Fully control the structure of the Client, Server end, using custom communication / business protocol
2. Define the underlying service to reduce redundancy and error 3. All development code is transparent, there is no black box
use
B / S is used in comparison, business systems for end users (finance, personnel, logistics, e-commerce, workflow)
C / S is used in a variety of software systems (for secondary development), or software products; special-specific commercial systems (bank, Ministry of Defense)
C / S is the foundation of B / S. The techniques used by the former can be used, and it is not true.
B / S Several popular architecture
Both is a development model, realizing technology changes
1. J2EE (development model is not a development technology)
2. .NET
3. PHP
4. CGI (Perl, C)
J2EE development mode structure:
System Function Client Web Layer Control Layer Service Layer Data Operating Layer Container Browser Web Server, JSP / Servlet Container JSP / Servlet Container, EJB Container EJB Container, Servlet Container EJB Container, Servlet Container Technology HTML, CSS, XML, JavaScript, AppleTHTTP , JSP, Servlet, HTMLJSP / Servlet, EJB, Javabenejb, JavaBean, Servletejb (Entity), DAO, JDO, R / O Mapping Assisted Technology, Flash Resource File (International), MVC Resource File (International), MVC. For the container itself, JNDIJMS, JTA
TIPS:
JAVA Directory Service (Java Naming and Directory Interface)
JMS: Java Message Service
JTA: Java Transaction Service
EJB strong invasive container, is not recommended.
EJB-based two technologies: RMI and serialization
Important:
To learn, important: HTML, XML format, HTTP, JSP, Servlet, Javabean
Key: HTML, JavaScript, DAO, MVC (both are two architectures)
Look at: EJB, JNDI, JMS, JTA
10:00
HTML / JSP
HTML form
JSP Calculation -> Server
痩 client
Client Server
Browser brower ---------------- à jsp
| Compile
Servlet -------------------------- à backstage call
| Run
HTML
process
1) Send the request HTTP protocol
2) Generate two objects, REQUEST, RESPONSE
3) Compiling servlet
4) Display part hard coding
5) Back to the customer
HTML:
Xml