Wednesday, May 31, 2006
Smells to refactorings cheat sheet
Smells to Refactorings Cheat Sheet is freely available -- see the top item on the industriallogic site.
Tuesday, May 23, 2006
WebLogic Server and Oracle RAC
Oracle Real Application Clusters (RAC) is a software component you can add to a high-availabitlity solution that enables users on multiple machines to access a single database with increased performance. RAC comprises of two or more Oracle databases instances running on tow or more clustered machines and accessing a shared storage device via cluster technology. Oracle RAC offers the following features to applications on WebLogic Server:
BEA supports several configuration options for using Oracle RAC with WebLogic Server:
- Scalability: A RAC appears lika a single Oracle database and is maintained using the same tools and practices. All nodes in the cluster execute transactions against the same database. RAC coordinates access to the shared data to ensure consistency, and integrity. Nodes can be added to the cluster without partitioning data (Horizontal scaling).
- Availability: Depending on the configuration, when a RAC node fails, in-flight transactions are redirected to another node in the cluster either by WebLogic Server or Oracle Thin driver. The fail-over is not for failed connections. Fail-over is only for transactions, which will be driven to completion, based on the time of failure.
- Load Balancing: BEA supports load balancing capability with Oracle RAC servers, through multi-data sources
- Failover: BEA recommends using WebLogic JDBC multi data sources to handle failover. Transparent Application Failover is not supported with WebLogic Server due to the requirement of Oracle OCI driver which is not supported by BEA.
BEA supports several configuration options for using Oracle RAC with WebLogic Server:
- Multiple RAC instances with Global Transactions: BEA recommends the use of transaction-aware WebLogic JDBC multi data sources, which support failover and load balancing, to connect to RAC nodes.
- Multiple RAC instances without XA transactions: BEA recommends the use of (non-transaction-aware_ multi data sources to connect to the RAC nodes. Use the standard multi data source configuration, which supports failover and load balancing.
- Multiple RAC nodes when multi data sources are not an option: Use Oracle RAC with connect-time failover. Load balancing is not supported in this configuration.
- Since Oracle requires that a Global Transaction must be initiated, prepared, and concluded in the same instance of the RAC cluster, and since Oracle Thin driver cannot guarantee that a transaction is initiated and concluded on the same RAC instance when when the driver is configured for load balancing, you cannot use connect-time load balancing wihen using XA with Oracle RAC.
- There is a potential for Inconsistent Transaction Completion
- Potential for Data Deadlocks in Some Failure scenarios
- Potential for Transactions Completed out of sequence.
Sunday, May 21, 2006
Java Petstore 2.0
The Java Pet Store 2.0 is the reference application for building AJAX web applications on Java EE 5. It contains blueprints for building AJAX-enabled JSF component libraries, using Java Persistence APIs, applying MVC and other design patterns in an AJAX web application, using Mashups such as Google Maps service for location specific searches using an RSS feed as a data source. You can download the Java Petstore Demo and try out the features from the petstore site.
Here are the features:
Here are the features:
- Using AJAX for single-page interactive Web applications: The application is designed to be a single-page application where the user never leaves the page. Different sections of the page are dynamically loaded based on the user actions. These sections are loaded asynchronously to avoid any browser refreshes, and to give a richer interactive user-experience.
- Mash-ups with Google maps: The petstore uses a mashup with Google's Map service, alongwith Yahoo's Geo-coder service to allow users to see the available pets in a neighborhood.
- Community-created content: The application allows a user to add a pet for sale or adoption on the Website. The seller uploads
- Using Captchas to discourage spam in the community created content: Whenever a website allows its users to add content, it needs to build mechanisms to discourage placement of spurious content on its Website through automated mechanisms. We demonstrate how captchas can be used for this purpose.
- Community rated content: Each item in the petstore website can be rated by the users
- Payments through PayPal: The application provides a meeting ground for buyers and sellers of pets. The application uses the PayPal service to allow sellers to accept payments.
- Integration of an RSS feed: The website integrates an RSS feed of news items coming out the Java BluePrints website. The
- Integration of a search engine: The application integrates Apache Lucene search engine to handle all website searches.
- JavaServer Faces: Many of the AJAX features are implemented as reusable JavaServer Faces components.
- Java Persistence API: The application uses Java Persistence APIs to create an object/relational mapping layer.
- Dependency Injection: The application uses dependency injection instead of deployment descriptors.
Wednesday, May 10, 2006
Double dispatch in Java
Some programming languages provide the feature of dispatching a funtion call to different concrete functions depending on the runtime types of multiple objects involved in the call (including parameters). In Java dynamic method dispatch, the actual method call depends on the dynamic type of a single object (the object/interface on which the method is invoked), hence it is called single dispatch.
In the following piece of code (A java version of the original wikipedia example), you can see that, although an ExplodingAsteroid collidedWith a GiantSpaceShip, the output shows only a SpaceShip.
This problem can be solved by re-writing the above code as follows:
In the following piece of code (A java version of the original wikipedia example), you can see that, although an ExplodingAsteroid collidedWith a GiantSpaceShip, the output shows only a SpaceShip.
This is due to the fact that, though Java can recognize the runtime type of the Asteroid, it ignores the runtime type of the SpaceShip which is sent as an argument.
class SpaceShip {}
class GiantSpaceShip extends SpaceShip {}
class Asteroid {
public void collideWith(SpaceShip sp) {
System.out.println("Asteroid hit a SpaceShip");
}
public void collideWith(GiantSpaceShip gsp) {
System.out.println("Asteroid hit a GiantSpaceShip");
}
}
class ExplodingAsteroid extends Asteroid {
public void collideWith(SpaceShip sp) {
System.out.println("ExplodingAsteroid hit a SpaceShip");
}
public void collideWith(GiantSpaceShip gsp) {
System.out.println("ExplodingAsteroid hit a GiantSpaceShip");
}
}
public class DoubleDispatchTest { public static void main(String args[]) {
Asteroid ast = new Asteroid();
Asteroid ast1 = new ExplodingAsteroid();
SpaceShip sp = new SpaceShip();
SpaceShip sp1 = new GiantSpaceShip();
ast.collideWith(sp);
ast.collideWith(sp1);
ast1.collideWith(sp);
ast1.collideWith(sp1);
}
}
Output:
Asteroid hit a SpaceShip
Asteroid hit a SpaceShip
ExplodingAsteroid hit a SpaceShip
ExplodingAsteroid hit a SpaceShip
This problem can be solved by re-writing the above code as follows:
In this case, we are still using the runtime type of just one object with each call, but we have an additional call embedded within the called method, which invokes another of the second object (Asteroid), thus achieving double dispatch. The same effect can be achieved by using a couple of if-else statements within the code, but the code starts to look ugly once more types of spaceships/asteroids are introduced.
class SpaceShip {
public void collideWith(Asteroid inAsteroid) {
inAsteroid.collideWith(this);
}
}
class GiantSpaceShip extends SpaceShip {
public void collideWith(Asteroid inAsteroid) {
inAsteroid.collideWith(this);
}
}
class Asteroid {
public void collideWith(SpaceShip sp) {
System.out.println("Asteroid hit a SpaceShip");
}
public void collideWith(GiantSpaceShip gsp) {
System.out.println("Asteroid hit a GiantSpaceShip");
}
}
class ExplodingAsteroid extends Asteroid {
public void collideWith(SpaceShip sp) {
System.out.println("ExplodingAsteroid hit a SpaceShip");
}
public void collideWith(GiantSpaceShip gsp) {
System.out.println("ExplodingAsteroid hit a GiantSpaceShip");
}
}
public class DoubleDispatchJava {
public static void main(String args[]) {
Asteroid ast = new Asteroid();
Asteroid ast1 = new ExplodingAsteroid();
SpaceShip sp = new SpaceShip();
SpaceShip sp1 = new GiantSpaceShip();
sp.collideWith(ast);
sp.collideWith (ast1);
sp1.collideWith(ast);
sp1.collideWith(ast1);
}
}
Output:
Asteroid hit a SpaceShip
ExplodingAsteroid hit a SpaceShip
Asteroid hit a GiantSpaceShip
ExplodingAsteroid hit a GiantSpaceShip
Wednesday, May 03, 2006
Java Enterprise Edition 5
Java EE 5 specification passed yesterday. The specifications under JEE 5 include Java Authorization Contract for Containers (JACC), JSF 1.2, JSP 2.1, Servlet 2.5, EJB 3.0, JAX-WS 2.0. No implementations of the Java EE 5 specification have been announced yet (except for Glassfish). Here is a list of tutorials/articles for the new specifications.
- Java EE 5 Tutorial, Sun Microsystems
- Java EE 5 Blueprints, Sun Microsystems
- Design enterprise applications with the EJB 3.0 Java Persistence API, Borys Burnayev
- Introducing the Java EE 5 Platform, John Stearns et al.
- Introducing the Java EE SDK Preview (Screencast), Sun Microsystems
- Java EE 5 Step by Step, Filippo Diotalevi
- Pavel Buzek's Weblog, Pavel Buzek
- EJB 3.0 Trailblazer, JBoss
- Dependency Injection with Java EE 5, Debu Panda
- Simplifying EJB Development with EJB 3.0, Debu Panda
- Web Tier to go With Java EE 5 : Summary of New Features in JavaServer Faces 1.2, Jennifer Ball and Ed Burns
- Web Tier to go With Java EE 5 : Summary of New Features in JSP 2.1, Pierre Delisle and Jennifer Ball
- Web Tier to go With Java EE 5 : Summary of New Features in JSTL 1.2, Pierre Delisle and Jennifer Ball
- Using Ajax with non-HTML Markup in JavaServer Faces, Roger Kitain
- Java EE 5 WebServices (List)
Subscribe to:
Posts (Atom)
Popular Posts
-
In a previous post, I described how to use Quartz scheduler for scheduling . In this post, I describe the configuration changes required for...
-
JUnit 4 introduces a completely different API to the older versions. JUnit 4 uses Java 5 annotations to describe tests instead of using in...
-
This post will describe how to create and deploy a Java Web Application war to Heroku using Heroku CLI. You will need a basic understanding ...
-
The previous post described how to implement a JMS messaging client using Spring JMS . This post will describe how to implement the Message ...
-
The example here demonstrates the use of an anonymous PL/SQL block to return data to a calling Java program. It also shows how to use nested...
-
In this post we will see a way to merge multiple PDF files while adding page numbers at the bottom of each page in the format Page 1 of 10 ....
-
JFreeChart is a free Java chart library that can be used to display charts from Java applications. It features: A wide range of chart types ...
-
Recently I was attempting to deploy to weblogic from a Jenkins installed on a Red Hat Enterprise Linux Server release 7.3 , to a remote Webl...
-
This is an example code for a simple PDF merge using iText 5. We use three InputStream s in a List as input and merged file is written to th...
-
The Visitor design pattern provides a way to separate algorithms from the object structure. A consequence of this separation is the ability ...