Adam Bien's Weblog
Java EE and How to Specify The Unconventional With Convention Over Configuration [Free Article]
The free (registration is required) Java Magazine article Convention Over Configuration in Java EE 6 focuses on the implementation of project and stage dependent configuration with JSF, EJB, JMX, JAX-RS and CDI.
Executable Maven 3 project is included and checked-in. Feedback is, as always, highly appreciated!
Posted at 06:39AM May 16, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[0] | Views/Hits: 704
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Summer Java EE Workshops
- 23.05, Amsterdam Airport Java EE Hacking, Without Airport. The dutch version of Airport Hacking. Seems like sold out.
- 26.06-27.06, Munich Java EE Summit. I will give sessions about testing, patterns, anti-patterns and a "Productivity with Joy" workshop. Last year it was sold out.
- 09.07-10.07, Airport Munich Java EE Bootstrap and Effective Java EE workshops. At the first day I will focus on principles and essentials needed to bootstrap a Java EE project. The second day is all about tools, approaches and tricks for effective Java EE Development. The first edition of this workshop was sold out weeks before. After scaling the venue, there are still some seats available.
Conclusion: Everything Java EE related is sold out :-)
Posted at 06:39PM May 10, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[0] | Views/Hits: 754
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Great Simplification With EJB [ Screencast ]
Esoteric and home grown transaction handling, as well as, manual JPA management can be replaced with a single @Stateless annotation:
In Java EE 7 you could replace a @Stateless with the ubiquitous @Transactional annotation. However, you will have to type 4 more characters for this purpose :-)
See also other screencasts at http://www.youtube.com/user/bienadam
Posted at 09:17AM May 04, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[2] | Views/Hits: 1766
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Java SE Development Kit 7 (JDK)--Released For Mac OS X
Oracle releases Java SE Development Kit 7 (JDK 1.7u4) for Mac OS X. It is the first official Oracle release for Mac OS X. See Release Notes.
JAVA_HOME can be set by putting the following line into the ~/.profile file:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home"
NetBeans 7.1.2 was simultaneously released as well. Also Java FX 2.1 is available for Mac and Windows to download.
Posted at 11:06AM Apr 27, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[2] | Views/Hits: 1732
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Are Servlets Thread Safe and What Is The SingleThreadModel?
The Servlet Specification JSR-315 clearly defines the web container behavior in the service (and doGet, doPost, doPut etc.) methods (2.3.3.1 Multithreading Issues, Page 9):
"A servlet container may send concurrent requests through the service method of the servlet. To handle the requests, the Servlet Developer must make adequate provisions for concurrent processing with multiple threads in the service method.
Although it is not recommended, an alternative for the Developer is to implement the
SingleThreadModelinterface which requires the container to guarantee that there is only one request thread at a time in the service method. A servlet container may satisfy this requirement by serializing requests on a servlet, or by maintaining a pool of servlet instances. If the servlet is part of a Web application that has been marked as distributable, the container may maintain a pool of servlet instances in each JVM that the application is distributed across.For servlets not implementing the
SingleThreadModelinterface, if the service method (or methods such as doGet or doPost which are dispatched to the service method of the HttpServlet abstract class) has been defined with the synchronized keyword, the servlet container cannot use the instance pool approach, but must serialize requests through it. It is strongly recommended that Developers not synchronize the service method (or methods dispatched to it) in these circumstances because of detrimental effects on performance".
Servlets are not thread safe and you have to synchronize your code manually what usually leads to esoteric implementations.
Posted at 03:01PM Apr 25, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[3] | Views/Hits: 1641
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
A Great Set of Java EE Examples For Tomcat On Steroids (aka TomEE)
A great set of Java EE examples (REST, EntityManager, EJB, CDI, Web Services, JMS, Transactions, Security ...), created by the Tomcat EE guys
If you need more, just request an example.
Thanks Jon for the hint!
Posted at 10:38AM Apr 23, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[0] | Views/Hits: 2298
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Transparent Windows (Stage) With Java FX 2
To make the main Java FX window completely transparent, you only have to set the StageStyle.TRANSPARENT and the Scene#setFill(null):
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TransparentStage extends Application {
@Override
public void start(Stage stage) {
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Transparent!");
text.setFont(new Font(40));
VBox box = new VBox();
box.getChildren().add(text);
final Scene scene = new Scene(box,300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Checkout the TransparentStage sample (source code).
Posted at 02:31PM Apr 18, 2012 by Adam Bien in RIA / Java FX | Comments[0] | Views/Hits: 2157
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
…And The Programming Language #1 is not Java, but...
C. So if you want to be a "programming cool kid", learn C. Unfortunately Java lost its #1 rank, now it is #2.
What is wrong with tiobe? It served us so well in the recent years :-).…and I almost forgot about C and all the exciting pointers and mallocs…
Posted at 11:05PM Apr 16, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[1] | Views/Hits: 2503
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Arquillian Configuration For Embedded GlassFish 3.1.2 and Maven 3
Maven 3 dependencies for Arquillian integration tests with GlassFish 3.1.2 require the declaration of a few dependencies:
<project>
<modelVersion></modelVersion>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<packaging>war</packaging>
<name>alienfish</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The missing Maven 3 parts can be easily created from CLI.
Enjoy integration testing with the Alien and the Fish :-).
[x-ray's configuration and logging subsystems were tested with Arquillian. You will also find the integration tests in the git repo (project x-ray-services, class eg. ConfigurationIT), See also page 115 "Injection and Infrastructure Testing with Aliens" in Real World Java EE Night Hacks--Dissecting the Business Tier.]
Posted at 10:02AM Apr 12, 2012 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[0] | Views/Hits: 1920
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien
Building Java FX 2 Libraries From Source With Maven 3
- Get the sources:
hg clone http://hg.openjdk.java.net/openjfx/2.2/master/rt. For subsequent updates use:hg pull -u - Create a JavaFX profile with a pointer to the javafx 2.2. SDK. Hence not all sources are open yet, this is a necessary step:
<profile> <id>javafx</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <fx.home>[PATH TO JAVAFX INSTALLATION]/javafx-sdk2.2.0-beta/</fx.home> </properties> </profile> - Execute:
mvn -Pjavafx clean install - You should see the following output:
[INFO] javafx ............................................ SUCCESS [0.740s] [INFO] test-stub-toolkit ................................. SUCCESS [2.676s] [INFO] javafx-beans-dt ................................... SUCCESS [1.080s] [INFO] javafx-concurrent ................................. SUCCESS [1.385s] [INFO] javafx-ui-controls ................................ SUCCESS [9.607s] [INFO] javafx-designtime ................................. SUCCESS [0.479s] [INFO] javafx-ui-common .................................. SUCCESS [8.973s] [INFO] javafx-rt ......................................... SUCCESS [2.241s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 27.337s - Pick your own fx-runtime library from:
javafx-ueber-jar/target/jfxrt.jar - Run tests, file bugs: Java FX Jira :-)
Posted at 10:24AM Apr 10, 2012 by Adam Bien in RIA / Java FX | Comments[3] | Views/Hits: 2228
*NEW* Workshop: "Effective Java EE 6/7", July 10th, Airport Munich Tweet Follow @AdamBien


