Автор работы: Пользователь скрыл имя, 04 Января 2011 в 13:55, курсовая работа
The experts working in the field of IT, know, that in modern, fast varying and putting forward all new requirements world of electronic commerce and information technologies, corporate applications should be projected, formed and should take root for smaller sums of money, with greater speed and smaller expenses of resources, than it was early.
For decreasing of the cost and increasing in speed of design and development of the corporate application platform J2EE offers the component approach to designing, development, assembly and implantation of corporate applications.
INTRODUCTION 4
ENGINEERING ENVIRONMENT FOR CREATION OF THE DISTRIBUTED APPLICATIONS AND SOFTWARE ENGINEERING METHODOLOGY 5
1.1. Software engineering methodologies 5
1.1.1. Extreme Programming. 5
1.1.2. Rational Unified Process. 6
1.2. Distributed applications and multi-tier architecture 9
1.2.1. Multi-tier applications. 9
1.2.2. Distributed systems. 10
1.3. J2EE platform 11
1.3.1. The Choice of Java technology. 11
1.3.2. Contents of J2EE technology. 11
1.3.3. Technologies of J2EE platform. 12
1.3.4. EJB. 12
1.3.5. J2EE and multi-tier architecture. 13
1.4. Development of real application 14
1.4.1. Tools overview and environment setup. 14
1.4.2. Using Hibernate. 15
SUMMARY 20
BIBLIOGRAPHY 21
Base model EJB consists of following main components:
The simplified scheme presented in a picture 1.4.5.1, shows how platform J2EE realizes the multilevel architecture of the corporate application.
Picture 1.4.5.1 – Multi-tier architecture in J2EE
Certainly, development of a real application includes enough difficult stages. Within the limits of the report will be examined the stage of preparation for development of the application and the process of work with special technology "Hibernate".
Platfotm Eclipse is a cross-platform implementation with the open initial code and expanded built in IDE, using Java language. In essence, platform Eclipse is the environment giving a set of services which other additions can use. Each addition is developed for the same platform which unites them in a set of highly integrated tools. Eclipse extends free of charge and does not demand installation - it is enough to copy files of Eclipse on a hard disk of a computer.
Apache Ant – java-utility stands for automation of process of assembly of software product. Ant is completely independent from a platform if on applied system, at least, is installed Java working environment – JRE. Handle happens by means of the XML-script also named a build-file. First of all this file contains definition of the project consisting of the separate purposes (targets). The purposes could be compared with procedures in programming languages also contain calls of commands-tasks (tasks). Task is an indivisible, atomic command. The script is made in format XML, accordingly, signs of line feed and the blanks applied in various platforms do not influence execution of operations. Besides Ant has precisely certain interfaces for creation of own tasks in the form of Java-programs.
JUnit environment represents the test environment of execution Java with the open initial code, standard for check of code modules Java. It can be downloaded from a web-site junit.org; this site gives not only the instruction for installation, but also articles on check of units and set of advices on development of pre-checks.
Besides,many other software products and technologies also participate in development of the application (Spring, Struts, JSF, Apache Tomcat, JBoss, DBMS MySQL, etc.) on which we will not stop in detail.
Hibernate has recently won popularity in the world of development of applications of Java databases. Though such products as Toplink and others, are on the market for many years, Hibernate has implementation with the open source and, therefore, it is free-of-charge. It is stable, mature, well proved and concerning a simple product for learning: some of the reasons of its popularity. Hibernate has been released several years ago, but recently has been gained by JBoss group. The fault-tolerant environment of execution Hibernate can work with relational databases, using Java. It is so also for usage JDBC or Entity Beans.
During usage of Hibernate we will need to make additional operations on binding, but it is covinient because our code becomes more reliable and easier, but also, necessity for objects of data access (DAO) which are usually used for purely saving will pass. Data transfer objects (DTO) which are used for an encapsulation business-data and their movings between layers of the application also will not be necessary to us.
Hibernate
has supported following databases: DB2, HSQLDB, Microsoft SQL Server,
MySQL, Oracle, PostgreSQL, SAP DB, Sybase, TimesTen. Support of databases
in Hibernate is carried out with classes of dialect SQL, such as org.hibernate.dialect.
To show concepts and terminology of Hibernate, we shall create three types of files: configuration file Hibernate, appropriate Java classes, and also files of tables of binding. It is a recommended practice, in documentation of Hibernate and examples. For files of binding the following agreement about naming is usually used: to Java class name the suffix .hbm.xml, for example Timesheet.hbm.xml is added.
First we shall create a file under the name hibernate.cfg.xml. This file will contain definition of application (SessionFactory) and the link to our first file of binding, Department.hbm.xml. We shall examine some of the most interesting lines of this file.
Following lines show the customization linked with HSQLDB:
<property
name=”connection.driver_class”
org.hsqldb.
</property>
<property name=”connection.url”>
jdbc:hsqldb:hsql://
</property>
<property name=”connection.username”>
sa
</property>
Brought below line of a file hibernate.cfg.xml show links to files of binding:
<mapping resource=”Department.hbm.xml” />
<mapping resource=”Employee.hbm.xml” />
<mapping resource=”Timesheet.hbm.xml” />
Using the completed file hibernate.cfg.xml, we can create Hibernate SessionFactory.
Let's examine our first file of binding Department.hbm.xml in detail.
The following line of a code will link our Java class to the table of databases:
<class
name=”com.visualpatterns.
The following line of a code will place the identifier{ID} departmentCode as an object identifier and as a primary key of a database, and also will link them together:
<id name=”departmentCode” column=”departmentCode”>
Value generator class=”assigned”, shown below, notifies Hibernate that we shall carry out installation of value of this object in Java class and Hibernate should not undertake any special operations similar to obtaining of following value of sequence from a column auto-increment (as, for example, for data type HSQLDB identity):
<generator class=”assigned" />
These lines link other fields of table Department, i.e. a column name to property name in a file of class Department.java:
<property name=”name” column=”name” />
File Department.java contains simple class JavaBean, which gives methods for reading (get or getter) and records (set or setter) for value of two following variables:
String departmentCode;
String name;
Now we shall write some simple code, carrying out two tasks: check of installation of Hibernate, and also showing example of usage of Hibernate. We shall place this code in file HibernateTest.java.
Some first lines of a code show, as we receive class Hibernate SessionFactory and we extract one record from table Department about value "IT" from a column departmentCode:
SessionFactory sessionFactory = new Configuration()
.configure().
Session session
= sessionFactory.
Transaction tx = session.beginTransaction();
Department department;
Department = (Department) session.get(Department.class, “IT”);
System.out.printl(“Name for IT = ” + department
.getName());
Following lines show how to receive and handle java.util. List object of table Department.
List departmentList = session
.createQuery(“from Department”).list();
for (int i = 0; i < departmentList.size(); i++)
{
department = (Department) departmentList.get(i);
System.out.println(“Row ” + (i + 1) + “> ” + department.getName() + “ (”
+ department.getDepartmentCode() + “)”);
}
The last examined line closes class SessionFactory.
SessionFactory.close();
It is necessary to pay attention that file HibernateTest.java represents a simple example of usage of Hibernate when all code concentrates in one (main) method. There are also better ways of creation of class SessionFactory and the subsequent obtaining of its Session object. However the code containing in this class quite can be used in development of the real application with usage of Hibernate.
Hibernate is possible to find at <http: // www.hibernate.org>. Following the instruction given on this site, it is possible to load and install Hibernate. After installation it is required to copy all libraries recommended by documentation of Hibernate (for example, hibernate3.jar and antlr.jar) in the appropriate directory of the application.
To other additional possibilities of Hibernate which has been not described here, but capable to be useful, concern the following:
SUMMARY
During the creation of this article the structure, the organization of technological process, and also the normative documentation used during development of applications have been studied. Base knowledge of syntax of programming Java language, received during studying on 1-5 courses have been fixed, expanded and profound. Have been studied modern methodology of engineering process of the software; special technologies (Spring, Struts, Java Server Faces, Java Server Pages, Hibernate), widely applied now in a combination to language of highest level Java; the main way of creation of the program system; technology of designing and development of the distributed applications with multilevel architecture (J2EE).
During the creation of the article the experience, which was received independently during the development of the real project, which result was the finite distributed application created about usage of special technologies, patterns of designing and programming Java language was actively used.
In the article have been examined engineering processes of the software, and also possibility and the functions given by program platform J2EE, the examples containing the initial code which can be used by development of real corporate solutions are brought.
BIBLIOGRAPHY