Saturday, September 25, 2010

SA118 translation (8)


Chapter VIII of the user data archive
Translation: hfzheng
hfzheng@sohu.com
Please keep this information reproduced
Archive command overview
In order to file and directory security, they need to archive a copy to removable media such as tape. You also need to archive the tapes to recover lost, deleted, or have been destroyed documents.
System which can use the command can easily store, locate and restore or archive tape device file. Available commands are:
tar: create a file to a tape device or the archive file, a tape device or solution files in the archive
compress and uncompress: a file compression and decompression
zcat: view a compressed file
gzcat: Extract the files at the same time view the file. Under the command line unzip files, and to extract data displayed on the screen.
Zip and unzip: compress and decompress files
Gzip and gunzip: compress and decompress files
Jar: compression packing multiple files into one archive
Cpio: from the archive file or tape device in a paper copy of reconciliation
Note: When the archive, we should use relative paths
Tar archive file using the command
tar command tar file from a file called archive files, or solved. A tar file is typically a tape device, but not limited to this, can any files.
Command format
tar functions archive_name / tape_device filenames
functions
The following is tar used a detailed list of functions:
Function defined
c Create a new tar file
t list the contents of tar file
x from the tar file in the Solution of a specified file
f specify archive or tape device name, the default tape device is / dev/rmt/0
v details of the contents of tar file
Create the tape device, view, restore a directory ribbon device
User1 directory to create a tape archive, use the default tape device, perform the following command:
$ / Export / home
$ Tar cv user1
View copy to tape the contents of the directory, execute the following command:
$ Tar t
If the user1 directory is accidentally deleted or damaged, you can execute the following command from the tape archive solution out to restore the contents of the directory are the directory:
$ Cd / export / home
$ Tar xv user1
Normally, system administrators usually at night on the home directory for archiving, but in normal times, but you also archive the contents of your home directory, so that if a file is deleted accidentally, you can quickly resume.
Create the archive file, in the view from the archive and restore files
tar command can also create an archive disk, you can share the files with other users, or add the file as an e-mail message.
$ Cd
$ Tar cvf files.tar file1 file2 file3
The above example, the file file1, file2 and file3 saved to a file called files.tar. Need to view the contents of the file, execute the following command:
$ Tar tf files.tar
The following example shows how to solve for the archive file to the current directory:
$ Tar xvf files.tar
Compressed files using the compress command
compress command is used to compress files to reduce the file size. And is very useful when dealing with large files, you can save hard disk space, when transmitted through the network transmission time can be reduced.
Compression ratio can be different according to the different file types, for a text document, usually 60-80% compression. When a file is compressed, the file will be a band. Z file extension instead of, attention, file owner and modification time is not changed, although the contents of the file has been completely changed.
Command format
compress filename
Compress a file
The following example is used to compress a file named files.tar:
$ Compress-v files.tar
The newly created zip file, will be used to replace the original file files.tar.Z file. With extension naming tradition is to remind the user that the file has been compressed. In the absence of extract can view and print before.
Note: Compressed files an already compressed file will become larger.
Extract the files using the uncompress command
uncompress command is used to restore a compressed file to its original state.
Command format
uncompress-c filename
The following example is used to extract a file named files.tar.Z:
$ Uncompress files.tar.Z
View the contents of a compressed file
Use with-c parameter uncompress command can display the contents of a compressed file to the screen, rather than extract. Z files.
$ Uncompress-c files.tar.Z | more
View files using the zcat command
zcat command can also view a file created by the compress command, zcat command translation compressed data, and to compress content of the document between the display on the screen, in the run zcat command, the contents of compressed files is not changed, still compressed stored on the hard disk.
Command format
zcayt-c filename
View the contents of a compressed file
To view the contents of a compressed file, execute the following command:
$ Zcat file.tar.Z | tar xvf -
Compressed files using the jar command
jar command and the tar command is similar, but the same steps in the compressed file, the command can copy and compress multiple files into one archive file, Zip application can read the jar file.
Note: the first is for the java programmers to use, to download multiple files at once, not each separate file in the next, jar command is the standard Solaris operating environment commands, in any other installed java virtual machine system can be used.
Command format
jar format and command syntax is almost the same tar command:
jar options output_file filenames / directorys
options:
jar command options:
Options defined
M does not create list
C to create a new jar file
Jar files are listed in the contents of T
X solved from the jar file, the file specified
F specify the jar file
V show details of implementation
Other tools
A more efficient compression tool is the zip and gzip, they can create a higher compression ratio of compressed file.
Use the zip command
zip and jar commands similar to the command are used to compress the file name, the difference is that zip is a unix tool, jar is a java application tools.
When using the zip command compressed file, the file name with extension. Zip.
Note: You can type in the command line zip and unzip to list all the options for each command.
Command format:
zip filename filename
For example:
$ Zip filename1 filename2 filename3 filename4
Using the gzip command
When using the command gzip compressed file, the file name with extension. Gz.
Command format:
gzip filename filename filename
For example:
$ Gzip filename1 filename2 filename3 filename4
Restoration of a gzip file
Gzip command to restore a compressed file, use the gunzip command:
$ Gunzip filename.gz
Use the cpio command
cpio command to archive files to tape or archive, or from the tape and archive solutions of the file.
Cpio command of advantages:
1, the compressed data to tape, and effective than the tar
2, the recovery file to skip out bad tape
3, can be written in different header file format to facilitate migration between the different systems
4, you can create multi-volume tape
5, you can archive and does not change the file access time
Command format
cpio options filenames
options:
Listed below can be used in the cpio command options:
Command definitions
o Create a file for the archive, copy the path name to the list of files or tape devices
I tape from the archive file or files solved
C in ASCII mode to read header information to be used for transplantation
T lists the contents of the file
V ls-l command to use and the format is similar to print out the file name list
M message to the media when the media and the needs of the end of the work has been completed, send a message
P reads the tape device or file to get the path name
A re-set when the copied file access time
I filename from the file filename as input file to read the content
O filename send the output of the cpio command file filename
Note: The cpio command line, you must specify o, I, p one of them.
Create the file file
The following example shows the combination of find and cpio commands to the current contents of the directory to create a file and copy it to the dir.list file.
$ Find. | Cpio-o dir.list
But the combination you find and cpio commands to those in the last week, is modified to create an archive file and copy it to the modify.list file.
$ Find.-Mtime -7 | cpio-ocv modify.list
The following example shows how to create a list archive for more than just the contents of the document:
$ Cpio-ivt-I dir.list
$ Cpio-ivt-I modify.list
Copy a directory of all files to tape
The following example describes how to use the cpio command copies files and directories to tape
$ Cd / export/home/usr1
$ Ls | cpio-oc-O / dev/rmt/0
List the contents of a tape, perform the following command:
$ Cpio-civt-I / dev/rmt/0
Table lists the contents of each file tape contains information on the eight parts, the first part of the octal mode with given access to the second part of the owner of the document is given, the third part of the given file number of bytes, the fourth, fifth, sixth part of the given file was last modified month, date, time. Last part gives the name of the file.
Restore files from tape
Need to recover files from the tape, first you have to put the location into the file and then execute the following command:
$ Cpio-icv-I / dev/rmt/0
Volume Management features
In order to store and restore the files in the floppy or CDROM, Solaris operating environment provides volume management features.
Volume Management for ordinary users to handle data in the floppy and CDROM provides a standard method. Using volume management features, you can automatically access your floppy and CDROM.
Note: If the volume management system does not start, only the super user can access the floppy and CDROM.
Volume management services from a daemon called named vold. Super users can start or stop any system in the process, by default, always start volume management services, so for the average user, can automatically manage access to the floppy and CDROM.
Detection of removable media devices
When we insert the floppy disk drive, floppy disk or CD to the CDROM in place, the volume manager need to test new equipment in order to provide access to the equipment.
CDROM Volume Management automatically detected, but the floppy disk, the Volume Manager does not automatically detect the new disk into the need to insert the disk every time you notice the volume manager.
Note: Automatic detection of extra disk read operations, this will soon wear damage to the floppy disk drive.
Volume Manager informed that you have inserted a new disk using the volcheck command.
Command format
volcheck options device_pathname
For example, to notify the Volume Manager to check your floppy drive inserted in the new media, execute the following command:
$ Volcheck-v / dev / disk
volcheck order feedback of the following messages:
1, if the disk into the drive, volcheck command displays the message: / dev / disk has media
2, if there is no disk drive, volcheck command displays the message: / dev / disk has no media
Access to removable media devices
The next section describes how to access removable media devices
CDROM and volume management
When the Volume Manager automatically detects the CDROM in CD exist, automatically place the CDROM directory tree called / cdrom standard directory.
You can use the cd command to enter to the directory, you can immediately access all the files in CD-ROM.
Access to local CDROM drive in the file:
1, in the drive into the CD-ROM (labeled side up), Volume Manager automatically put it on the directory / cdrom under;
2, in a terminal window, type the command cd / cdrom/cdrom0 and press Enter;
3, type the ls command and press Enter, the display / cdrom/cdrom0 all files.
NOTE: If you are running CDE File Manager, it will pop up a new File Manager window to display the contents of CDROM, you can window mode or the command line to access the data.
Floppy disk and volume management
Volume Manager does not automatically detect whether the floppy drive into a disk, you must use volcheck command to notify the Volume Manager to test drive. If the disk exists, the volume manager will put the disk in a directory tree called / floppy standard directory. You can use the cd command to enter to the directory, you can immediately access all the files on disk.
Access disk files:
1, placed in the drive has been formatted disk (labeled side up);
2, type volcheck and press Enter, the volume manager will put the disk directory / floppy under;
3, type cd / floppy and press Enter;
4, type ls carriage return, will show the disk name;
5, type cd disk_name carriage return;
6, type ls Enter to show all files on the disk name, you can use the cp command to copy the files on the disk.
Notes:
1, if there is no disk in the drive, volcheck will display an error message.
2, from the command line you can access files on the disk, or from the File Manager window File menu, choose Open Disk to access files on the disk.
Pop-up removable media devices
Once the completed CDROM and disk operations, you can use the eject command to remove the CD-ROM and floppy disk.
Pop CDROM
Eject the disc from the drive:
1, the CDROM File Manager window, click File, and select eject (eject) option;
Or:
1, close the CDROM File Manager window;
2, type the command exit cd / cdrom directory;
3, type eject cdrom Enter a few seconds later, CD-ROM drive will pop up.
Pop-up floppy disk
To eject a floppy disk:
1, in the Disk File Manager window, click File, and select eject (eject) option;
Or:
1, close the Disk File Manager window;
2, type the cd command exit / floppy directory;
3, type eject floppy Enter a few seconds, the disk from the drive or display a pop-up window, telling you can manually eject the disk.
Device busy information:
If the CDROM or disk does not eject from the drive and display a "device busy" message, you may still work CDROM or disk directory.
When you are in CDROm or working directory when the disk can not eject CDROM and disk.
To see you is in / cdrom and / floppy directory, you can use the pwd command, if you are in the directory, use the cd command to exit the directory.





Recommended links:



BOE Holdings East TPV regulators have not yet Ratified Difficult



How to short-term Consultants into your team



Simple Icon TOOLS



Northern Rock's instant messaging



The Problem Is With Chinese Characters - Five-stroke Input



MKV To VOB



Modify the TCP / IP AFTER so fast you do not believe



AVI To IPod



News about Project Management



3GP to MPEG



Shop Music Composers



Hot hot behind



How To Draw Background Image CAknGrid



Linux Study Notes Scan



Tuesday, September 14, 2010

Longhorn can be run on some old computer


Reply: This is good news. Although Microsoft recommends a computer to run very trendy the next version of the Windows operating system, but also be able to run Longhorn in a considerable number of old machines.

The bad news is, Longhorn running on those old machines will look quite a bit different. For example, with 3GHz processor and 512MB of memory the computer will play a special performance, including the beautiful graphics and ability to handle multiple video streams.

According to Microsoft's recent testing, only 128MB of memory of the old computer to run Longhorn, but its performance can not, as in a powerful new computer on the same. Many of these older machines running Longhorn there will be "has the same XP as the operation of" feeling, a Microsoft Windows operating system kernel developers said Richard Russell.

The new Windows has at least four different levels of graphics. One, Aero and Aero Glass graphics using the new composite interface, with a high-end Glass layer to add more transparency and 3D effects. Another graphical effect is called "To Go", is a popular portable computer and a new machine design, it has many of the same with the Aero color scheme, but did not practice with the ultimate graphics performance. The last one is the traditional model, it looks like XP or even Windows 2000 as. However, there will be differences in performance, more device configuration allows the new operating system to play better. It shows Microsoft's a big change in the concept.

Previous Windows versions, including Windows XP, operating system, the typical practice is the performance of a machine or all of its glory, or can not run altogether. "XP is XP," Russell said, "Longhorn is completely different, it will be re-defined." Formation of such a big change on the software giant's many challenges. First, it let the business community and consumers understand that the ability to run Longhorn does not mean that full advantage of all of its features. This, Microsoft is planning to design a new mark in the personal computer to identify, respectively, were: the machine is optimized for the Longhorn or just be able to load the operating system. Microsoft also operates a program is to allow computer manufacturers to specify which computer is "for Longhorn".

The second challenge, Microsoft said it was ready to proceed, is dependent on software for existing machines measure out what type of configuration is most appropriate. Russell said, Microsoft guarantee that when people upgrade to Longhorn, some settings are optimized according to their machines, though users still maintain the ability to change these settings. "We do not want to allow users to effortlessly proved wondering whether they can run (Aero) Glass", Russell said.
Similarly, computer manufacturers are encouraging the use of machine performance relative to their default settings, although customers can still change those settings. Microsoft Research analyst Michael Cherry said that Microsoft needs a feature for which the guidance which the hardware was too vague. Cherry said that while Microsoft needs of the processor and memory provides some detailed instructions, businesses may still not have enough information to understand a new computer should be installed on any kind of graphics card. He claims that he has not worked out for Microsoft "for Longhorn" specific indicators to guide business customers and that they now buy Diannao Shipishiyu new Caozuoxitong disappointed. "I do not understand why, so far they have not yet ready to give us one for Longhorn's hardware specifications." He said.








Recommended links:



Green Dam How UNFORTUNATE?



windows media player vob



Seasonal - Screen Savers comments



Light: Cold Chain Dancer



e-cology in the Pan Micro Series 27



psp mp4 converter



Big Rabbit - Yuan Colombia



EASY to use Music Composers



Dvd To Mp4 Converter



Feature library to create instance of IDS Intrusion Analysis (2)



In Section North Soft, Direct Plug In For The "wings"!



Homes To Enjoy Digital Medical



realplayer H.264



Wednesday, July 28, 2010

About Groovy and Grails



Summary

Java Web Application Framework is the enterprise Java is one important reason for success. People wonder if there is no Apache Struts framework for Java EE could be so successful. Although the underlying programming language is important, however, the framework is usually to make the programming language into the center of attention. If you frequently visit the discussion forum, you'll notice that Ruby language and Ruby On Rails framework is also the case between. Ruby has been there 10 years, but only popular in the Ruby On Rails framework, the developers began to notice Ruby language.

Such as Ruby, PHP and Python scripting languages like more and more popular in recent years, therefore, need to develop a Java scripting language, and similar alternative Rails framework against Java environment. Groovy is the scripting language, and Grails is the framework.

In this article I will discuss Groovy's Web development features, and then continue to discuss the Grails framework. I will develop a sample Grails Web application, and discuss the various features of this framework.

What is Groovy?

Groovy is a language, its syntax is similar to Java, but simpler than Java. It is often regarded as the script / flexible / dynamic language, but I do not like this type of adjective, because I think they will only cause confusion. If Java is a wise middle-aged man, then Groovy is his teenage son. Groovy has many characteristics of his father, but more wild and more fun. They could also very well together.

Groovy far fewer rules than Java. For example, to get the standard Java "Hello World" output, you need to write a class, a main method with appropriate parameters, and so on. But in Groovy, if you do not want to write all the boilerplate code, you can put aside the class definition and the main method, you can only write one line of code prints out "Hello World".

The following is a document to print Hello World Hello.groovy content:

println "Hello World"

Java byte code platform is concerned only to be implemented. Similarly, the platform does not force you to use the Java language. Provide a byte code as long as the work will be conducted. Groovy code will be compiled to byte code, but for the Java platform, the byte code from Java code or Groovy code generated no difference.

The following is a Groovy example, it shows 浜?Groovy on the list, map and extent of De built-in support, and prove the simplicity of its use Groovy, Java, Jiang Tai Neng Li features:



/ / Print Date

def mydate = new java.util.Date ()

println mydate

/ / Iterate through a map

def numbersMAP = [''1'':'' ONE'',''2'':'' TWO'']

for (entry in numbersMAP) (

println "$ = $"

)

/ / Introducing the range

def range =''a''..'' d''

/ / Lists

def numberlist = [1, 2, 3, 4, 5, 6, 7, 8]

println numberlist;

println "Maximum value: $"



Please note that the above code to be used directly java.util.Date, built-in support of the collection to reduce the use of lists, map and extent of the required code. Groovy There are many other interesting features, such as closure and simplified XML processing. You can find a detailed list of groovy.codehaus.org.

Let us now discuss how to Groovy for Web development.

For Web development using Groovy

Most Java EE servlet tutorial is a basic example from the beginning. The Groovy Web development is, you will groovlet (the groovy concept in the corresponding servlet) started. If you are in out of the servlet class and doXX () method declaration, then the rest of the content on and groovlet like a. The following is an example of named Login.groovy of groovlet, you need to place it the most advanced Web application directory:



def username = request.getParameter ("username")

def password = request.getParameter ("password")

if (username == "java" & & password == "developer") (

response.sendRedirect ("home.jsp")

session = request.getSession (true);

session.setAttribute ("name", username)

)

else (

println "" "



Login Invalid



Your IP has been logged> $

"" "

paramMap = request.getParameterMap ()

println "

You Submitted:

"

for (entry in paramMap) (

println "$ = $

"

)

)



You can just create a simple HTML form, then this form of behavior attributes sent to the action = "Login.groovy". Then add the following tag to web.xml:





Groovy

groovy.servlet.GroovyServlet





Groovy

*. Groovy





Now simply add the required Groovy jar files to the WEB-INF/lib directory of your Groovy Web applications on any Java EE application ready to run the server.

You should have noticed the code is not a semicolon, and the use of implicit variables, such as request and response. Other implicit variables context, application, session, out, sout, and html.

GSP is the corresponding JSP in the groovy concept. You do not need to use println generate HTML; Simply Groovy code embedded in HTML pages. Examples of this article will be referred to the use of Grails GSP.

Please note that because all the code will eventually be converted to byte code, so groovlet and GSP can easily collaborate with the servlet and JSP. So you do not distinguish groovlet and the GSP or the servlet and JSP.

Let us now discuss the promising Grails framework. If successful, Grails can significantly change the development of Java Web applications that way. Ruby Ruby on Rails on the impact, Grails Groovy can also achieve.

Grails features and architecture

Ruby On Rails Grails attempts to use the "statute of programming" (coding by convention) to reduce sample configuration files and other boilerplate code requirements. Use the "Statute of the programming", if the file name itself can explain the purpose of this document, then you do not need another statement in the configuration file such content. This framework will see the file name and file their own clear purpose. By using the "Statute of the programming", Grails will automatically generate Web applications that need many of the content. By using Grails, you will be able in a short period of time, to minimize the complexity of the Web application ready. See the following example.

Grails based on open source technologies such as Spring, Hibernate and SiteMesh. If you already good at these technologies, this is a good thing; but for some reason if you do not like these technologies, or if you think that not only need to learn Grails, also need to learn the other three frames, this is not a good thing. Although the implementation of these technologies can help Grails better, but for most people to learn the four framework is a very high threshold. Grails documentation is currently focused on it with Spring, Hibernate, and other processes of integration, but I think it needs to adopt the opposite approach, implemented as a simple Grails rapid Web application development framework. Developers need to consider the underlying fear or what happened.

Fortunately, once you start using Grails, you will find these frameworks Grails hides most of the underlying complexity. If you forget to run in the bottom of the Spring, Hibernate and other procedures, then things will become simpler.

By the view and controller layer composed of Web

By a domain consisting of business logic classes and services

From the domain classes and data resources in the persistence layer

Most frameworks have dozens of properties, which only a small few have been widely used. For Grails, this key feature is the "rule programming" (coding by convention) the automatic generation of examples and components.

Other features include Grails Ajax, validation, unit testing and functional testing of the built-in support. It uses a free open-source Canoo WebTest project to implement Web application functional testing. Grails also provides integration with the Quartz Scheduler.

It is time to install the Grails framework and write your first application.

Grails Installation

Installation process is very simple. The following is Grails download page: http://grails.org/Download. You can http://dist.codehaus.org/grails/grails-bin-0.2.1.zip download version 0.2.1. Note that the Grails source code and documentation provided as a separate download. Download zip file, simply extract the contents to a directory can be, in my case, this directory is C: groovygrails-0.2.1.

Create a new environment variable called GRAILS_HOME and set its value to C: groovygrails-0.2.1. Next will be added to the PATH environment variable GRAILS_HOMEbin. This installation is complete. Interface through the command prompt to run grails command you can check the installation was successful. You should get usage information for this command.

Now that you have a running Grails installation, then you have to create a Grails Web application ready.

Grails Application Development: Application Structure

Over the years I have been planning to develop clothing that can help me manage the application - the application should be able to tell me my favorite T-shirt on where it washed, ironed it, and so on. Someday I'll earn on the sale of the application of millions, but now I will use it as an example Grails.

The first step is to create a Grails project directory structure. In this step I will be C: groovygrailsapps create a new directory, and on this level to open a command prompt window. In this window, execute the command grails create-app. Asked to enter your application name. Enter ClothesMgt. Grails will show it to you to create all the directories and files. Figure 1 shows the structure of the last received command.



Figure 1: Grails project directory structure

This command will create about 800 KB size of the files and directories. The idea here is to follow this framework has been established Web application development practices, so it creates files and directories in most Web applications is useful. Although some people may not like the idea of mandatory use of a structure, but the practice of automatically generated based on the RAD features of Grails is based.

If you look more carefully these directories, you will find that there is for such as controllers, views, testing, configuration files and things like tag library directory. You'll also find some basic JavaScript and CSS files. So now the basic structure of the application has been made. You only need to do to fill in the blank, the application can be ready.

Please note that auto-generated directories and file with the command is optional. You can manually create all the files and directories. If you are familiar with Apache Ant, so you can even open GRAILS_HOME directory srcgrailsbuild.xml file to carefully review the use of each Grails command.

Database

In this case I will use a running on localhost called Clothes_Grails the MySQL database. Built a Grails HSQL database, which is a simple test application that is useful or just try Grails. If you are using HSQL DB, so no need to perform the following steps. I will use MySQL to prove that you can very easily use a database other than HSQL.

Download MySQL from http://www.mysql.com/products/connector/j/ drive, and mysql-connector-java - stable-bin.jar file placed in the ClothesMgtlib directory. Next you need to edit ClothesMgtgrails-appconfApplicationDataSource.groovy file.

Now the contents of this file should be similar to the following:



class ApplicationDataSource (

boolean pooling = true

String dbCreate = "create-drop"

String url = "jdbc: mysql: / / localhost / Clothes_Grails"

String driverClassName = "com.mysql.jdbc.Driver"

String username = "grails"

String password = "groovy"

)



Now let's look at how to use this database and object-relational mapping.

Field class

Grails Object-Relational Mapping (GORM) function for internal use Hibernate 3, but you do not understand or change any Hibernate settings. Grails is called "domain class" thing, these domain classes are mapped to the database object. You can use the relationships to link domain classes, they also provide for CRUD (create / read / update / delete) operations very powerful dynamic method.

In this case, we will create three domain classes, their names are Shirt, Trouser, and Cabinet. To create a domain class, just run the command grails create-domain-class. Please remember in your project directory (not its parent directory) within the run this command. This is a common mistake, although I have to remind you that you still guilty of at least one such error.

You must provide to the create-domain-class command only input is the class name. Run this command three times, the Shirt, Trouser, and Cabinet as the name of the three domain classes. Grails will now be in the directory grails-app/domain / create the domain class. They will only have two properties id and version. I will add the properties of these classes in order to make them more representative of the shirt, pants and wardrobe.

Listing 1: Cabinet.groovy

class Cabinet (

Long id

Long version

String name

String location

def relatesToMany = [shirts: Shirt, trousers: Trouser]

Set shirts = new HashSet ()

Set trousers = new HashSet ()



String toString () ("$: $ id")



boolean equals (other) (

if (other?. is (this)) return true

if (! (other instanceof Cabinet)) return false

if (! id | |! other?. id | | id! = other?. id) return false

return true

)



int hashCode () (

int hashCode = 0

hashCode = 29 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 28 29 3 30 31 32 4 5 6 7 8 9 (hashCode + (! id 1 2 3 4 5 6 7 8 9 0: id ^ (id>>> 32)))

)

)



Listing 2: Trouser.groovy



class Trouser (

Long id

Long version

String name

String color

Cabinet cabinet

def belongsTo = Cabinet

String toString () ("$: $ id")



boolean equals (other) (

if (other?. is (this)) return true

if (! (other instanceof Trouser)) return false

if (! id | |! other?. id | | id! = other?. id) return false

return true

)



int hashCode () (

int hashCode = 0

hashCode = 29 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 28 29 3 30 31 32 4 5 6 7 8 9 (hashCode + (! id 1 2 3 4 5 6 7 8 9 0: id ^ (id>>> 32)))

)

)



Listing 3: Shirt.groovy



class Shirt (

Long id

Long version

String name

String color

Cabinet cabinet

def belongsTo = Cabinet



String toString () ("$: $ id")



boolean equals (other) (

if (other?. is (this)) return true

if (! (other instanceof Shirt)) return false

if (! id | |! other?. id | | id! = other?. id) return false

return true

)



int hashCode () (

int hashCode = 0

hashCode = 29 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 28 29 3 30 31 32 4 5 6 7 8 9 (hashCode + (! id 1 2 3 4 5 6 7 8 9 0: id ^ (id>>> 32)))

)

)



I add only a few lines of a statement of the field names and colors, and then declare the Cabinet, Shirt and Trouser relationship. Each Shirt and Trouser belong to Cabinet, the Cabinet has the shirt and trouser set. belongsTo attribute is optional in this case, because one to many relationship, Grails will be "one" side as the owner. So you do not need to explicitly declared. Here, I explicitly declared only to make this relationship more evident.

Next we will discuss the Grails application, controller and view part.

Controller and view

Since the domain classes are ready, let's use the generate-all command automatically generates basic CRUD Web application. Grails generate-all command run three times, when classes are asked to provide domain name. The purpose of generate-all command is generated for each domain controller and view classes, but because of bug-245, Grails 0.2.1 can not generate the controller. You must manually generate the controller, the method is used for each domain class generate-controller command.

You should now be in the grails-appcontrollers directory see three controllers. The controller is responsible for Web application requests for a particular domain class. Therefore ShirtController.groovy Web applications will handle the domain class associated with the Shirt CRUD request, and so on. Now the controller has multiple closure, each closure is mapped to a URI. Language Groovy closure is a good feature, but get used to it or take some time. Listing 4 shows an excerpt Shirtcontroller.groovy.

Listing 4: ShirtController.groovy extract



class ShirtController (

def index = (redirect (action: list, params: params))

def list = (

[ShirtList: Shirt.list (params)]

)

def show = (

[Shirt: Shirt.get (params.id)]

)

def delete = (

def shirt = Shirt.get (params.id)

if (shirt) (

shirt.delete ()

flash.message = "Shirt $ deleted."

redirect (action: list)

)

else (

flash.message = "Shirt not found with id $"

redirect (action: list)

)

)

/ / ...

)



In this case, ShirtController closure of the list will be dealing with URI is / shirt / list of requests, and so on. You can use your controller used in the Java Web applications using things such as request, session and servletContext.

Please note: the value of the closure will be as explicit return statement, or as a closure body in the last statement of the value returned. Do not Grails does not return the generated code rather confused.

Once the controller to complete the processing of the request, it must be entrusted to the appropriate view. Grails uses custom mechanisms to achieve this. The list, therefore ShirtController closure will be entrusted to view / grails-app/views/shirt/list.gsp or / grails-app/views/shirt/list.jsp. While you are using Grails, all views can be JSP files instead of GSP. I almost did not write any code, but I'm ready for a Web application.

Let us try to deploy and run our application.

In the Java EE Server to deploy and run Grails

Grails has a built-in Resin server, you can use the grails run-app command to run the application. This command will deploy to the Resin application server and start the server. Http://localhost:8080/ClothesMgt so you can now access this application. You can also easily deployed to any JavaEE application server. I try to deploy it to Tomcat. To achieve this, I need to do is to run the grails war command to generate the war file to Tomcat's webapps directory in!

In this case, the resulting war file name is ClothesMgt.war. Once deployed to Tomcat, you should be able to access it in http://localhost:8080/ClothesMgt/ and see the screen shown in Figure 2.



Figure 2: Grails application

Through this application, access Shirt, Trouser, and Cabinet of all the CRUD functionality. Can display all the data closet to the wardrobe to add a new shirt and pants, edit and delete records of their value - to achieve all these operations without writing any business logic, view, or data access code. Only a few minutes you'll be better deployed in the JavaEE server, a proper Web application. Cool? !

Let us further customize Grails.

Create a custom controller

I will add new features and pages to the Web application, while reusing existing domain classes. shirt / list and trouser / list will display shirts and pants were a list, let us add a new display to simultaneously display a list of shirts and pants. To create a new display, you need a new controller and view.

Use generate-controller and generate-views command, you can easily use the fields automatically generated view and controller classes. However, in this case I want to create a class not directly associated with the domain controller. I will use the grails create-controller command. When prompted for the controller name, declare Display. Grails will grails-app/controllers / directory to create a controller called DisplayController.groovy in grails-tests directory to create a test suite. Edit controller as shown in Listing 5.

Listing 5: DisplayController.groovy

class DisplayController (

def index =

def list = (

params [''max''] = 10

return [shirtList: Shirt.list (params),

trouserList: Trouser.list (params)]

)

)

index redirect the request to the closure list. Closure in the list I will be the largest parameter set to 10, and then use the dynamic method Shirt.list and Trouser.list. Then return Groovy Map, it has two lists - the list of shirts and trousers list.

As a Java developer, when you see the Shirt.list () will naturally think that is the domain class in the list Shirt methods. However, if you open Shirt.groovy, will find that this method does not. For Java developers, do not know the characteristics of Groovy on Grails is not only confusing to use, and is a dead end. Grails dynamic method is a special feature, which is built on the Groovy language features a very special meta object protocol (MOP) above. So that you can use the dynamic method to query the domain class. Therefore, the controller, you will notice that the domain class called the method seems the domain class does not exist. Here you can read on the use of dynamic methods of inquiry for more information. Can be found here on the Grails controller and the domain class dynamic methods available in reference.

Since the controller can process the request, obtain and forward the list to the view, I need to create the appropriate view.

Create a custom view

When you create a controller, Grails also grails-appviews directory created a new show directory, and add the following to the web.xml file maps.



grails

/ Display / *

Grails currently has a generate-views command, this command can generate domain classes based on the view, however, does not automatically generate the view create-view command. See the example in Figure 3.



Figure 3: The default view of a display Trousers

I want to create an independent view of the domain class, so let us create a view file manually. Grails-appviewsdisplay in the directory, create a file named list.gsp, as shown in Listing 6.

Listing 6: list.gsp



Shirt List

Id Cabinet Color Name

$ $ $ $



Trouser List

Id Cabinet Color Name

$ $ $ $

And similar to the way I used before, you can now use the run-app command to run applications, or create a war file and deploy it to Tomcat. You should see the new view under http://localhost:8080/ClothesMgt/display/ shown in Figure 4.



Figure 4: The new shirts and pants to create the list view list

Now let's quickly discuss the Grails services.

Service

If you want to know how to separate the business logic and business logic of the position to place the answer in Grails service. Services to SomeNameService.groovy format name, and is placed in / grails-app/services / directory. Service dependency injection features available, you can easily call these services from the controller.

Let's look at an example of using the service. First, use create-service command to create new services. Run this command and naming services Order. Grails will create two files --grails-app/services/OrderService.groovy and grails-tests/OrderTests.groovy.

Now edit OrderService.groovy, as shown in Listing 7. When introducing new orderGoods () method will automatically generate serviceMethod ().

Listing 7: OrderService.groovy

class OrderService (

boolean transactional = true

def serviceMethod () (

/ / TODO

)

def orderGoods () (

return "Order Placed - New shirts and trousers

will be sent shortly. "

)

)

Now edit DisplayController, as shown in Listing 8. Rearrangement of the introduction of the use OrderService closure. Please note that service will be injected into Groovy.

Listing 8: DisplayController.groovy

class DisplayController (

OrderService orderService

def index =

def list = (

params [''max''] = 10

return [shirtList: Shirt.list (params)

, TrouserList: Trouser.list (params)]

)



def reorder = (

render (orderService.orderGoods ())

)



)



Now when you visit the URL http://localhost:8080/ClothesMgt/display/reorder, the rearrangement of the closure will be called OrderService, response will be sent back to the browser. You can be in a similar manner to all the business logic moved to service, and then use the injection of Grails feature is easy to use them.

Dynamic methods and properties

As previously mentioned, the domain class is not able to obtain data from the database, or update / delete the existing data in any way, such as find (), findAll () or save (). In the controller you do not write like redirect () or render () method like. But the domain classes and controllers have their aim of the project, and allow all the requested operation. The reason is Grails dynamic methods and properties exist. Dynamic method is dynamically added to the class, just like function is the same as compiled in the program.

These are the available methods and properties, without writing. These methods cover the most dynamic Web application development will face a common situation. For domain classes, the existence of such as find (), findAll (), list (), executeQuery (), save () and delete () method like dynamic.鎺у埗鍣ㄥ叿鏈夎濡俿ession銆乺equest鍜宺esponse涔嬬被鐨勫姩鎬佸睘鎬э紝浠ュ強璇稿chain()銆乺ender()鍜?redirect()涔嬬被鐨勬柟娉曘?瑕佺湡姝e埄鐢℅rails鐨勫己澶у姛鑳斤紝鎮ㄩ渶瑕佷簡瑙f墍鏈夎繖浜涘姩鎬佹柟娉曞拰灞炴?鐨勫姛鑳姐?

銆??椤轰究浠嬬粛涓?笅锛氳嚜鍔ㄩ噸杞藉拰@Property

銆??Grails鐨勪竴涓噸瑕佺壒鎬ф槸鑳藉鍦ㄥ紑鍙戣繃绋嬩腑杩涜浜嗘洿鏀规椂鑷姩閲嶈浇鏂囦欢銆傚洜姝ゅ彧闇?紪杈戝拰淇濆瓨gsp鏂囦欢锛屽氨浼氳嚜鍔ㄩ噸杞芥柊鏂囦欢銆傜劧鑰岃繖閲屽垱寤虹殑绫讳技OrderService 鐨勪簨鍔℃湇鍔′笉浼氳閲嶈浇銆傛偍浼氬湪鏈嶅姟鍣ㄦ帶鍒跺彴鐪嬪埌浠ヤ笅娑堟伅"[groovy] Cannot reload class [class OrderService] reloading of transactional service classes is not currently possible. Set class to non-transactional first. "銆?br />
銆??Grails鐨勮嚜鍔ㄩ噸杞藉姛鑳戒細涓烘偍鑺傜渷璁稿鏃堕棿锛屾偍灏辨棤闇?氮璐规椂闂存潵閲嶅惎鏈嶅姟鍣ㄤ簡銆傛垜纰板埌杩囦竴浜汫rails涓嶈兘鑷姩閲嶈浇鐨勬渚嬶紝渚嬪灏嗕竴涓猨sp鏂囦欢閲嶅懡鍚嶅埌gsp銆傜劧鑰岋紝Grails鐨勮繖椤瑰姛鑳芥湁鏈涘湪鏈潵鐗堟湰涓緱鍒拌繘涓?鏀硅繘銆?br />
銆??鍦℅roovy JSR 06 鐨勪箣鍓嶇増鏈腑锛屾偍蹇呴』浣跨敤@Property 鏉ュ畾涔塆roovy涓殑鏂板睘鎬с?鍥犳鎮ㄤ細鍦ㄧ嚎鐪嬪埌璁稿浣跨敤@Property鐨勬棫鐨凣roovy渚嬪瓙銆傜劧鑰岃娉ㄦ剰锛孈Property宸茬粡浠嶨roovy JSR 06涓Щ闄わ紝鍦℅rails 0.2鍜屼箣鍚庣殑鐗堟湰涓篃涓嶄細鍐嶉渶瑕佸畠銆傝鍙傞槄@Property 寤鸿鏉ヨ幏寰楁洿澶氱粏鑺傘?

Conclusion

銆??鍦ㄦ湰鏂囦腑锛屾垜浠嬬粛浜咷rails妗嗘灦鐨勫熀鏈壒鎬э紝骞朵娇鐢℅rails鍒涘缓浜嗕竴涓簲鐢ㄧ▼搴忋?Groovy鍜孏rails鏈?ぇ鐨勫ソ澶勬槸涓?垏閮借繍琛屽湪浼樼鐨勬棫Java鍜孞ava EE涓娾?鈥斿洜姝ゆ偍鑳藉浣跨敤Groovy鍜孏rails鐨凴AD鐗规?蹇?寮?彂搴旂敤绋嬪簭锛岀劧鍚庡皢搴旂敤绋嬪簭閮ㄧ讲鍒板彲闈犵殑Java EE鏈嶅姟鍣ㄤ笂銆傝?铏戝埌鍏充簬Ruby鍜孯ails鐨勫浼犲櫔闊筹紝鏄剧劧闇?涓?釜Java澶囬?鏂规銆侴roovy鍜孏rails鐪嬭捣鏉ラ潪甯搁?鍚堣繖涓鑹层?







相关链接:



mkv converter free



Got hit by Baidu PPC



Tomato Garden, charged by: the United States has a lot of piracy



.m4v file



Visual Studio08 now open to MSDN users



Nine ways to recruit Good staff



Report Audio Video Tools



download flv TO mp3 converter



Mr. Chen will be back in the more terrible



In The Title Bar Of An Art Form



Music TV infringement trial basis HAVE a special levy to the views of the community



Guide GAMES Sports



Tianjin Merlin Gerin Co., Ltd.



Comment E-Mail Clients



News About Astronomy



HP Quality doors lead into the VICTIMS of collective action



Video Format For Blackberry



Sunday, July 25, 2010

CG production process (1)




1. The first is to use the scanner with a pencil a good pre-draft swept into the computer, using PHOTOSHOP4.0 some smooth curved lines, or amendment is not over.



2. Open a new layer Layer1, where all the skin with a magic wand (W) all elected, and then Layer1 on the pre-selected skin color within the selection of stuffing (Alt + 鈫?.



3. For the skin colored shadow, I personally like the four colors.



4. Found that the angle of the right hand a little bit bad, so the angle of the handle to change a bit.




[Next]





5. Then there was the hair, skin, way to keep up to the same large, but also new layer Layer2, hair color fill in..





6. With a path function (P) to sketch out the level of the hair, repeatedly, until, as hair up. Results came out.



7. Clothes, like layering, coloring.






相关链接:



Download Converter Mp4 To 3gp



Summer good companion video offline Download ASUS two routing recommendation (3)



e-cology in The Pan Micro Series 67



How to clear to break through the active defense of the new Trojan



HP and Novell reach a New exclusive alliance agreement



New Web Development



Easy to use Graphic CAD



Good efficacy is the Man Manao out



Text Or Document Editors Catalogs



New worm VBS / VBSWG.an @ MM small files



converting avi to Wmv



Premier Games Action



Windows Media Center



CSS EXAMPLES: horizontal style input boxes



Nwz-e443



Thursday, July 22, 2010

Three steps teach you to set up a separate page header and footer



Home of the header and footer, usually with the body of the different methods by the following individual settings.

鈶?Click the "Header and Footer" toolbar "Page Setup" button to open the page settings dialog box, in the "Layout" tab, select the "Home of different" item, once determined to return.

鈶?Then on page 1 the document header and footer areas of text you become a "home page header" and "First Footer" character, in its editorial content will be inside the header and footer is not the same as the other.

鈶?most of the book's home page is no header and footer, and then can be home all the contents of header and footer in the clear.

Tip: In the Page Setup dialog box, select "different odd and even page" entry, document headers and footers are automatically divided into odd and even header and footer, were set on it.







相关链接:



Swf To Flv



Liu: a play from the acting to the private equity fund non-plague



Explosion Flash to iPod



Ever MP3 CDA RA to M3U EDITOR



Foxconn another sudden death, police said the two employees were excluded homicide



ts format



Youtube to TREO Deluxe



Hot Dial Up AND Connection Tools



Mp4 to avi



Converting .mov to .wmv



Xu Xiangchun: Long And Short Term Iron Ore Negotiations, And Worry



Characteristics of indicators



Good INVESTMENT Tools



Tuesday, June 29, 2010

Perpetually MPG to FLV



Perpetually MPG to FLV is a All-in-One powerful tool. Convert all popular video and audio formats to Youtube video, swf or flv to video, such as avi, mpeg, 3gp, mp4, mov, it offers the solutions to problems that many other flash to video converting tools cannot solve, such as video and audio asynchronization, loss of frames, audio distortion, the process of alpha channel, and the process of both internal and external Flash video(flv). With the leading audio and video codec, Perpetually MPG to FLV lets you easily and fully enjoy the original effects of your Flash files on your PC, iPod, PSP, Zune, iPhone, DVD players and Youtube Video, Google video, Myspace Video. In conclusion, with easy-to-use interface, fast converting speed, powerful functions.



Recommand Link:



Alcsoft Video Converter



Youtube Video To Cell Phone Gold



For you Science - Screen Savers



Explosion Blackberry Converter



Eztoo IPHONE Video Converter



Easy to use File Sharing Or Peer TO Peer



Top Telnet Servers



How-to DVD Editor



Swift VOB Editing



vob to MKV



RM MP2 Plus



WorldCup MPEG to AVI



WorldCup DVD Burner



Blue Cat''s Gain Suite



MovieSaver 2.0



Friday, June 25, 2010

Ever Audio M4P to MPC Creator

Ever Audio M4P to MPC Creator - Register 3 programs for the price of one (this one, mp3 Frame Remover, and mp3 List Maker De Luhe)! Edit your mp3's without having to decode them and then encode to mp3 again (loss of quality). Edit (copy, paste, delete, etc), volume/balance change, fade in/out, and insert silence functions. One of the most featured function of this Audio Converter is to convert MP4 to MP3, M4A to MP3 and AAC to MP3. The audio converter supports ID3 tag, all ID3 tags in the original files will be reserved after the audio converting processes. In addition, the audio converter also allows you convert video files including AVI, MPEG, MP4, WMV, ASF etc to popular audio files, e.g. convert MP4 to MP3, CD, CDA, CD-R, DVD-Audio, AAC, AC3, ID3, M3U, M4A, M4P, MP3 ID3 Tag, OGG, RA, WAV, WMA, MP2, APE, VQF, MPC, AMR, Midi, WAVE, and RM.



Recommand Link:



Youtube to H264 Utility



Youtube to EPOC Home



Directory Server Applications



DVD to SONY NWZ-X1050



Youtube FLV Save + Player Platinum



Adventure And Roleplay Wizard



How do I convert DVD to Sony NWZ-E436FPNK



Youtube Movie to MPG Ultra



Perpetually MPEG to PSP iPhone Wii



Comparison Genealogy



Vacations SWF Converter



m4v



AllRipper VOB Converter



Christmasgift AVI to iPod



Clone2Go DVD to Pocket PC Converter