O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a Remote Object Factory

Distributed object systems often use a design pattern called the factory pattern, which is also used in a number of Java APIs, such as XML, security, and JDBC (the JDBC DriverManager class is a factory). The idea is that instead of calling a constructor to create an object, you use a separate factory class. In the case of the Java APIs, you use the factory to hide the actual implementation. You can use different XML parser implementations—the factory chooses one. For different JDBC URLs, you might need a different JDBC driver—the DriverManager picks one.

The reason you need a factory in some Java APIs is that a constructor can't pick a different implementation class. In other words, the Driver class constructor ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required