Use Apache Geronimo and Lift in combination

Source: Internet
Author: User
Tags requires versions java web advantage

Create a WEB application with Lift and deploy to Geronimo

The Lift WEB application framework requires Scala, and Scala relies on Java Development kit, so you also need to install Java Development Kit. The following is the software used to write this article.

Java Development Toolkit Scala requires JDK V1.5 or later versions. I use the Java v1.5.0_13. You can also use IBM Java 2 Platform. Scala I use Scala V2.6.1. According to the Scala Web site, the Scala software release is best installed on Unix® or Windows® systems and requires Java 2 Runtime environment (such as JR for Sun Microsystems or IBM® E) V1.4 or later versions. Apache Maven Lift relies on Apache maven to set up projects, test code, and so on. Need Apache Maven V2.0.7 or later, this article uses V2.0.9. Apache Geronimo Lift is best used with Jetty, so I use Apache Geronimo V2.1.1 with Jetty. A database by default, Lift uses the embedded Apache Derby database, but you can also use MySQL or Postgres.

Lift is written in Scala, but this article does not ask you to familiarize yourself with Scala. Need to be familiar with the Java language and Java Web programming. Familiarity with Maven can help, because Lift uses MAVEN in many ways.

Why to use Lift

Before discussing how to download libraries and execute scripts, you should first talk about why you should use Lift. After all, there are many other Web frameworks, some of which can also be used in Geronimo. This article discusses important Lift structures, including fragments and models, to illustrate how easy it is to create and test Web applications with Lift.

Java Web programmers have a number of web frameworks to choose from. Some people even think that the current WEB framework is too much, confusing. So, in many Web frameworks, where is Lift? Lift is written in Scala, not Java. Although Scala compiles to Java bytecode, unlike many dynamic languages running on the JVM, it is not a wrapper code. Scala is a static type of language that runs as a fast "native" Java. This should not be surprising, because Scala's creator has written a Java compiler. As a result, Scala is a much more expressive language than Java, but it runs on the JVM and runs as fast as Java. These properties make it ideal for implementing WEB frameworks-a powerful language that allows us to write less code while maintaining excellent performance.

Scala is very good, so what about Lift? Lift took advantage of Scala's advantages. It can run in any Java Web container because it uses standard Java servlet and servlet filters. Lift's fragments and models take full advantage of the flexible Scala syntax. By using Scala's actor concurrency system, Lift is also able to perform Comet-style Ajax brilliantly. Don't you believe it? Let's see how easy it is to create a WEB application with Lift.

Creating Lift Applications

Any WEB application framework needs to be downloaded first, right? Lift is not like that. Lift uses Maven to do all the work, and the initial settings are not different. However, be sure to set the SCALA_HOME environment variable before you start using Maven. Then execute the following command.

Listing 1. Creating a new Lift application

$ mvn archetype:generate-u-darchetypegroupid=net.liftweb
-darchetypeartifactid=lift-archetype-basic-darchetypeversion=0.8
-dremoterepositories=http://scala-tools.org/repo-releases
-dgroupid=org.developerworks.lift-dartifactid=quepasa
[INFO] Scanning for projects ...
[INFO] Searching repository for plugin with prefix: ' Archetype '.
[INFO] org.apache.maven.plugins:checking for updates from
[INFO] org.codehaus.mojo:checking for updates from
[INFO] Artifact org.apache.maven.plugins:maven-archetype-plugin:checking for
Updates from the
[INFO]------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] Task-segment: [Archetype:generate] (Aggregator-style)
[INFO]------------------------------------------------------------------------
[INFO] Preparing Archetype:generate
[INFO] No goals needed for project-skipping
[INFO] Setting Property:classpath.resource.loader.class =>
' Org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader '.
[INFO] Setting property:velocimacro.messages.on => ' false '.
[INFO] Setting property:resource.loader => ' classpath '.
[INFO] Setting property:resource.manager.logwhenfound => ' false '.
[INFO] [Archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from
[net.liftweb:lift-archetype-basic:0.6-> http://scala-tools.org/repo-releases]
Found in catalog internal
Define value for Version:1.0-snapshot:: 0.1
Confirm Properties Configuration:
GroupId:org.developerworks.lift
Artifactid:quepasa
version:0.1
Package:org.developerworks.lift
Y:: Y
[INFO]----------------------------------------------------------------------------
[INFO] Using following parameters for creating oldarchetype:lift-archetype-basic:0.8
[INFO]----------------------------------------------------------------------------
[INFO] Parameter:groupid, Value:org.developerworks.lift
[INFO] Parameter:packagename, Value:org.developerworks.lift
[INFO] Parameter:basedir, Value:/users/michael/code/lift
[INFO] Parameter:package, Value:org.developerworks.lift
[INFO] Parameter:version, value:0.1
[INFO] Parameter:artifactid, Value:quepasa
[INFO] ********************* end of the debug INFO from a generated POM
***********************
[INFO] Oldarchetype created in dir:/users/michael/code/lift/quepasa
[INFO]------------------------------------------------------------------------
[INFO] Build successful
[INFO]------------------------------------------------------------------------
[INFO] Total Time:8 seconds
[INFO] Finished at:wed may 21:49:56 PDT 2008
[INFO] Final memory:8m/14m
[INFO]------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.