Chapter 17.  Factories and the Activation Framework

In Chapter 14 and Chapter 15, we discussed how to build a better naming service, one that has a great deal more flexibility than the RMI registry and enables easier lookup of specific servers. However, applications that could potentially have millions of servers still require more infrastructure to help them deal with resource management. In this chapter, we’ll discuss the most common way of achieving this, the factory pattern, and how it is supported in RMI. To do this, we’ll implement a basic factory directly, and then implement similar functionality using RMI’s activation framework.

Resource Management

Our bank example has so far been a small-scale application. While Account is a fairly flexible interface, and you may think you can support millions of accounts using our new naming service and one of the implementations of Account that we’ve discussed, the fact of the matter is that more infrastructure is required.

To see why, consider the Bank of America advertisement quoted in Chapter 5:

When traveling, take advantage of more than 13,000 Bank of America ATMs coast to coast. We’re in 30 states and the District of Columbia. As a Bank of America Check Card or ATM cardholder, there’s no ATM fee when you use an ATM displaying a Bank of America sign...

—Bank of America advertisement

That’s 13,000 dedicated client machines. Plus, there are the client applications running inside each branch of the bank, the central reporting and analysis ...

Get Java RMI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.