Monday Jul 16, 2012

Introducing Groovy

Oracle developer Jim Driscoll has a new article up on otn/java, titled “Introducing Groovy,” that shows readers how to master the basics of Groovy, a general-purpose scripting language that runs on the Java Virtual Machine (JVM) – and, as Driscoll emphasizes -- one that can largely be viewed as a superset of Java.

He presents a “Hello World” program that can be understood as either a Java or Groovy program and will compile and run in either environment. Driscoll takes readers through the intricate connections and disconnects between Java and Groovy. For example, Groovy is public by default and “Groovy deals with String objects using double quotation marks with strings” which “allows for variable substitution”. And, “there are also strings with single quotation marks.”

Driscoll illustrates his points with copious code that illustrates how Java developers can tweak their own knowledge of Java to take advantage of Groovy’s strengths, so that, by the end of the article, the (Java-informed) reader more or less understands Groovy.

Check out the article here.

Thursday Feb 02, 2012

Java Champion Dick Wall on Genetics, the Java Posse, and Alternative Languages (Part One)

In Part One of a two-part interview, titled “Java Champion Dick Wall on Genetics, the Java Posse, and Alternative Languages (Part One),” Java Champion and Java Posse member Dick Wall explores the potential of genetic analysis to enhance human health, shares observations about alternative languages for the Java Virtual Machine (JVM), and reveals inside dope on the Java Posse. Wall admits to learning from Brian Goetz, Java language architect at Oracle, that pretty much everything he thought he knew about optimizing for the JVM was wrong, and discusses not only his current work using Scala to enhance our capacity to gain knowledge of our genetic vulnerabilities, but shares what he has learned about his own genetic challenges. In addition, he recounts some adventures with the Java Posse.

From the interview:

“…when I started working in Scala, I was worried that lots of extra immutable objects, which are created when you use immutable data often, would result in a lot more work for the garbage collector. After talking with Brian about it, I realized that, in fact, the opposite is often or usually true. Short-lived, immutable objects usually exist in a special part of the JVM’s memory referred to as Eden. Releasing the memory back to the pool from there is almost without cost. It is only longer-lived objects that get promoted to the JVM main heap that are expensive to garbage collect. So lots of small, short-lived objects can actually help the garbage collector out. There are other ways immutability can help or hurt performance, but ultimately, I decided to code for style and correctness first and worry about performance if and when it becomes an issue.”

Read the interview here.

Friday Dec 16, 2011

Spring to Java EE Migration, Part 2 (technical article)

In part two of a four-part article series on otn/java, “Spring to Java EE Migration, Part 2,” CTO and Java EE expert David Heffelfinger elaborates further on how easy it is to develop the data layer of an application using Java EE, JPA, and the NetBeans IDE instead of the Spring Framework.

Part 1 began with a Java EE rewrite of Spring's Pet Clinic sample application and developed the persistence layer of the application using Java Persistence API (JPA) 2.0, using NetBeans to generate most of the persistence layer from an existing database schema. Heffelfinger analyzed the generated code, which employed advanced JPA features.

In part 2, he continues this process by developing Enterprise JavaBeans (EJB) 3.1 session beans that act as Data Access Objects (DAOs), as well as JavaServer Faces (JSF) 2.0 managed beans and pages. Readers get to see the generated code in action and are given a look under the hood to see what’s going on.

Heffelfinger concludes Part 2 with a look ahead to Part 3:

“In the next installment of this series, we will modify the generated code to make it a bit more user friendly and we will compare the Java EE and Spring versions of the Pet Clinic application.”

Read the complete article here.

Wednesday Nov 02, 2011

Spring to Java EE Migration

In a new article up on otn/java, the first of a series, titled “Spring to Java EE Migration, Part 1,” CTO and Java EE expert David Heffelfinger demonstrates how easy it is to develop the data layer of an application using Java EE, JPA, and the NetBeans IDE instead of the Spring Framework.

Heffelfinger observes that, “Every time I work on a Spring project, I start mumbling under my breath. I know I will have to go through long and convoluted XML files to determine what is going on with the project. I also know that my project will have approximately 10,000 dependencies and that the generated WAR file is going to be a monster.”

He contrasts this with Java EE, where most of the needed services are required by the application server, reducing the number of required dependencies, and typically Java EE provides configuration by exception, meaning there is little configuration necessary. When configuration is needed, it is usually done through annotations, which allows the developers to get the whole picture from the source code. Also, with Java EE, the advanced tooling from NetBeans is available.

Again, from the article itself:

“In this series of articles, we will rewrite the sample Pet Clinic application provided with Spring using Java EE. In this first article, I illustrate how we can quickly develop an application that has equivalent functionality to the Spring version by taking advantage of the excellent Java EE tooling provided by NetBeans. The Java EE version employs JavaServer Faces (JSF) for the user interface, Data Access Objects (DAOs) are implemented using Enterprise JavaBeans (EJB) 3.1 session beans, and data access is provided by Java Persistence API (JPA) 2.0.”

Read the article in full here.

Thursday Sep 22, 2011

Integration Testing for Java EE

A new article by Java Champion Adam Bien, now up on otn/java, titled “Integration Testing for Java EE,” explores the intricacies of integration testing, which is done after a successful execution of unit tests, which however, will often fail. According to Bien, unit tests are fast and fine-grained while integration tests are slow and coarse-grained.

From the article:

“Testing everything inside an embedded container is convenient but unproductive. Java EE 6 components are annotated Plain Old Java Objects (POJOs) and can be easily unit tested and mocked out (see my previous article, “Unit Testing for Java EE.") with Java SE tools such as JUnit, TestNG, or Mockito. Using an embedded container to test your business logic is not only unproductive, but it is also conceptually wrong. Unit tests should validate your business logic, not the container behavior. Also, the majority of integration tests could be easily performed with a local EntityManager (see Listing 1) or a mocked-out container infrastructure. Only a fraction of all integration tests can be beneficially implemented with embeddable containers or test frameworks such as Arquillian.”

Read the complete article here.

About

Insider News from the Java Team at Oracle!

duke
javeone logo
Links


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
5
6
7
12
13
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today