#

## Chapter 1

### An Introduction to Castanet

Greetings! Welcome to the Official Marimba Guide to Castanet and to the Castanet technology. We'll start out in this chapter with a general overview of Castanet: what it's used for, why it's a good idea, its various parts and how they interact. Regardless of how you intend to use Castanet—if you're just interested in what it's all about, if you're going to use it in your own organization, or if you're planning on developing software for use with Castanet—this is a good place to start.

#### What is Castanet?

Castanet is, most simply, a mechanism for the distribution of software—that is, to make it easier and faster for individuals and organizations to get software from one place to another. Castanet takes advantage of the power and flexibility of the Internet and of Sun's Java language to create a framework that revolutionizes how traditional applications are distributed and makes it possible to create entirely new kinds of applications as well.

Whereas most software distribution is based on a publishing metaphor—the developer creates and publishes a piece of software, which is purchased, installed, and used by some number of individuals—the Castanet model is based more closely on a broadcasting metaphor. Consider the production of a television show. Television producers create their product (the show), and when it's complete, they broadcast that product to the audience over satellite, cable or regular TV airwaves. The audience, in turn, uses their television sets to receive that product.

Castanet works in a similar way. Organizations create software channels—applications and their data—and make them available on the Internet using a transmitter. Users who are interested in that channel then use a tuner to locate various Castanet transmitters on the Internet and download and use channels contained on those transmitters. Figure 1.1 shows how this works.

> ####

> Note:

> Although Castanet uses the broadcasting metaphor, it doesn't actually "push" data over the net the way Pointcast and similar "netcasting" technologies do. The language and the metaphor is the same, but the technology is different. You'll learn more about this as the book progresses.

Figure 1.1. Subscribing to channels using the tuner and the transmitter.

A channel is usually a Java application and its data. Because channels are written in Java, Castanet can take advantage of the strengths of the Java language, including

- Java programs are platform-independent; the same executable file can run on many different platforms. This means that you need to write a Java channel only once, and that channel can be available on any platform on which the tuner runs.
- Channels written in Java run without complicated installation procedures. To run a Java channel, you just download it and it runs. There is no need to run a setup script or wizard to make sure everything is installed and updated and registered, nor do you have to reinstall it every time there's a new version.
- Channels take advantage of the Java applet security model, which Web browsers use to make sure Java applets do not harm a user's system. Channels have most of the same restrictions as applets do in this respect.

The Castanet model builds on the strengths of Java and of applets, but also adds several other new features that make Castanet channels more flexible and powerfully than simple applets. Those new features and advantages are described in the next section.

> ####

> Note:

> For this first release, Castanet only supports applications written in Java. In future releases, there will be mechanisms in place for using platform-specific applications (written in C, C++, or some other native language) as channels with Castanet.

On the client side, you use the Castanet Tuner, a Java application that runs in the background on your desktop machine. (Figure 1.2 shows a tuner window with several channels subscribed.) From the tuner, you can subscribe to, download, and launch channels—and views lists of channels on transmitters. (Subscribing to a channel is similar to bookmarking a Web page; it means you're interesting in running that channel and getting updates when that channel has changed. More about this later.) The Castanet Tuner is available for Windows 95, Windows NT, and Solaris, and is contained on the CD that comes with this book. It is free for personal use; contact Marimba if you're interested in using it inside a company. Chapters 2 and 3 of this book describe how to install and use the tuner.

> ####

> Note:

> Marimba can be reached at `http://www.marimba.com/`.

Figure 1.2. The Castanet Tuner.

On the server side is the Castanet Transmitter, which broadcasts software channels. (Broadcasts isn't exactly the right term here, as the transmitter does not send any data out without a request from a tuner; makes channels available would be a better expression.) The transmitter, like a Web server, can be configured in different ways to prevent overloading the machine on which it runs or for remote administration. The Castanet Transmitter is also available for Windows 95, Windows NT and Solaris. A trial version which allows a limited number of connections is available on the CD for this book. You can purchase a more flexible Castanet Transmitter from Marimba.

In addition to the tuner and the transmitter, Castanet also offers the Castanet Proxy and the Castanet Repeater, which allow more efficient tuner connections through a firewall and easy mirroring of a transmitter's channels, respectively. The section titled "Castanet Repeaters and Proxies" discusses more about these products.

#### Castanet's Advantages

Despite the broadcast-influenced, tuner-transmitter-channel metaphor, the Castanet model might seem very similar to that of the World Wide Web—and in many ways, it is. Like surfing the Web with a browser and downloading Web pages with embedded Java applets, users use tuners to visit transmitters, and to download Java channels. And, in fact, the protocol that the tuner and the transmitter use to communicate is based on and compatible with the HTTP protocol. There are, however, several significant differences between the Web model and the Castanet model that make Castanet more generally useful than either the Web or traditional software publishing:

- Persistence
- Automatic updates
- Less reliance on network speed and bandwidth
- The capability to save state or properties on the local system
- Channels are actual applications

#### Channels Are Persistent

When you visit a Web site with a Web browser, the data on that Web site (HTML, images, Java applets, and so on) is downloaded to your local system and displayed. That information is stored temporarily on your local disk in the browser's cache. Depending on how large your cache is and how often you browse the Web, that information might be deleted in a matter of hours. So the next time you visit that same Web site, the browser often has to go through the process of redownloading everything. For complete Web sites or Java applets, this process can be very tedious, particularly on slower connections. You're always guaranteed to get the latest and greatest updated information—but if it takes too long to download, it might not be worth it.

With Castanet channels, after you've used the tuner to subscribe to a channel, that information remains on your local system until you explicitly remove it. Also, you can run or view that channel as often as you want to, much in the same way you would an application you installed from a floppy or from a file you downloaded from the Web. The channel's data will never be deleted to make room for other channels, as might happen with a browser cache.

Although Castanet channels are usually Java programs, you can also create channels that are made up of HTML pages, images, and other typical Web page content; in other words, you can create a channel that contains the entire contents of a Web site. Because all the data for that channel is downloaded at once and stored on the local disk, it's quick to display, quick to read, and can be accessed again and again without the need to reload.

Channels Are Automatically Updated

Probably the most significant difference between a Castanet channel and either a Java applet or a program downloaded and installed in the more traditional manner is that a software channel also has the capability to update itself on a regular basis. Each channel that you subscribe to using the tuner has a preferred update schedule—some channels might need to be more frequently updated than others—and each time a channel comes due for updating, the tuner will recontact the transmitter and see if new information is available. If there is indeed an update to be made, the tuner will download and install that new data into the channel on the local disk.

An update to a channel can involve changes to an application or simply new information that the channel might need to know. (For HTML channels, for example, that might include updated files or new pages.) Updates are small and incremental, so they occur quickly, often in the background. Updates can be made to channels that are running and active on the user's system, without the need to quit the application or reboot the machine. And, in cases where there's a network problem or some other unforeseen difficulty with the updating process, the channel will revert to its original state—it's impossible for an aborted update to leave a channel in a state where it doesn't run.

What automatic updating means is that once you've subscribed to the channel, the version of the channel you have is guaranteed to always be the latest version. For HTML channels, that means you always have the most current version of the Web site on your local disk. You don't have to install anything. You don't have to worry about which version of a program you have. Updates happen on the fly, quietly, in the background.

If you're administering the software for a large organization, automatic updates mean that you don't have to worry about making sure that all your users are running the same version of a particular software package—or that it'll take enormous amounts of time and resources to try and upgrade the organization.

If you're a software developer, automatic channel updates mean that all your users will always have the most recent version of your software; there's no need to support older versions. It means that you can get bug fixes and new features out to customers faster than ever before.

In addition to the basic version control aspects of channels, updates also allow you to create channels that rely on frequently-changing data. Because updates can happen as frequently as every few minutes, you could create, for example, news channels that update to include breaking stories, a weather channel to give you the current weather forecast for your area, calendar channels that give you the cartoon of the day, or puzzles that change on a frequent enough basis to remain interesting. Automatic updates change the concept of what an application looks like and open up entirely new ways of

Channels Rely Less on the Network

One of the major stumbling blocks of creating complex Web sites and Java applets is the typical speed of a user's network connection. Most people on the Internet at large do not have very fast network connections at all (usually modem connections at speeds of 28.8 or slower), and even in organizations where the internal network is heavily used, it's easy to become impatient with the amount of time it takes to download the program or information that you need.

Castanet uses several techniques to reduce the amount of downloading time and the bandwidth a channel needs. When you initially subscribe to a channel, it might take some time for that channel to download, depending on the size of the channel and the speed of the connection. But after it's downloaded, it's stored persistently on the local disk so you can reuse it over and over, or run it even when you're not connected to the network.

Each update to a channel does require another network connection. But updates involve only the channel information that has changed from the old version to the new version—which makes updates much smaller, and therefore much more quickly downloaded, than the original channel.

The channel structure itself can also help with reducing downloading time. With Web pages and Java applets, the Web browser makes separate network connections for each Web page, each image on the Web page, each Java applet, and each supporting class and file the Applet needs. For very complex Web pages or applets, this can mean dozens or even hundred of individual network connections. And because each network connection takes a few seconds just to start up, that's not a very efficient way for the browser to behave. Channels, in comparison, are a collection of files. A single channel (or update to a channel) can contain hundreds of files, but the tuner makes only one network connection for each channel or update. Also, channel files and libraries are shared between channels. So, for example, if you create multiple channels that all use the same library (to, say draw graphics), the tuner will only need to download one copy of that library. All the other channels will automatically use the one copy of the library and not download extra copies each time.

Finally, the tuner can be configured to allow updates only at a certain time or to prevent updates from being made too often (or at all). You could, for example, make updates only at night when you aren't working on your system, or make updates once a day in one feel swoop as opposed to whenever they need to be made. You can even turn off automatic updating altogether—and only update channels manually when you're dialed into your ISP and have some time to kill. The Castanet Tuner can be configured at what time and frequency updates are to occur.

Channels Can Save State

Java applets that run in Web browsers are constrained by a set of security restrictions that prevent those applets from unauthorized use or damage to the local system on which they run. In particular, applets are not allowed to run any local programs, to link to any native libraries (DLLs), or to connect to systems on the Internet other than the Web server where they came from. In addition, applets are not permitted to read or write files to the local system in any way, which prevents an applet from, say, deleting files or sending private information back to the applet's author. This last restriction has been the most debated amongst applet developers, because it prevents an applet from saving any kind of state whatsoever—for example, a user's position in a game, or files they might have created inside an applet for a spreadsheet, a drawing program, or a word processor. Workarounds exist—state can be saved to the applet's server, instead, and the applet or the page could be written to uniquely identify a user—but for the most part, the inability to save state has limited the overall usefulness of applets.

Channels use much of the same security restrictions as applets do, with the restriction on reading and writing local files somewhat eased—when you subscribe to a channel, that channel is given a special data directory on your local disk, and it is allowed to read files from and write files to that one directory (but nowhere else on the system). Channels can only access their own directories; they cannot touch other files for other channels. This simple change in the security policy opens up a whole new realm of options to channel developers.

> ####

> Note:

> In addition to easing the basic applet security restrictions, future versions of Castanet will offer the ability for channels to be authenticated (require a password) or digitally signed (or both). This will not only allow channels to have a greater variety of features, but will allow channels to be written in languages other than Java. Stay tuned!

Channels Are Real Applications

Unlike Java applets, which run inside a Web page and are constrained by the Web browser, Castanet channels run as real applications, on the desktop, the same way other applications do. This means channels don't need a heavyweight Web browser to run the same time they're running. It also gives channels more flexibility for interface design; channels run in their own windows, which can have menu bars and dialogs.

### Developing Channels

If you're a software developer or a Webmaster and you've read this far, your next question is most likely, "How do I create my own channels?" You have several options in this realm; in this section I'll summarize those options. Part 3 of this book, "Developing Castanet Channels," describes more about all aspects of channel development.

Castanet supports four basic kinds of channels: HTML, applet, application, and presentation channels. For each of these channels, you develop the content and then "publish" the channel on a transmitter. The publishing process is managed by a tool called Castanet Publish.

Easiest to create are HTML and applet channels. For each of these kinds of channels, you don't need to modify the original source in any way. All you need to so is set a few parameters using a configuration file or Castanet Publish itself, and then publish the channel. The Castanet Transmitter handles everything else.

Application channels are written in Java using your favorite Java development tools. In order to take advantage of live updates and other Castanet features, your channel classes must implement several Marimba interfaces. If you have a basic understanding of Java and of Java's AWT (the Abstract Windowing Toolkit), you should not have any difficulties learning how to develop channels. See Part III of this book for more.

The final kind of channel is called a presentation. Presentations are a special kind of channel developed using a Marimba tool called Bongo. Bongo is a sort of user-interface builder for Java; you can use it to position and link together various user-interface elements (called widgets) as well as create your own elements. Bongo presentations can then be used alone as channels or together with Java classes to form channels.

You'll get a quick taste of Bongo in Chapter 9, "Creating Presentations and Channels with Bongo." A companion to this book, The Official Marimba Guide to Bongo, by Danny Goodman, describes Bongo in lurid detail if you're interested in learning more.

### Castanet Repeaters and Proxies

The primary components of the Castanet Technology are the Castanet Tuner (for subscribing to, downloading, and updating channels) and the Castanet Transmitter (for making channels available on the Net to tuners). For special purposes such as firewall installations and very popular or high-load transmitters, Marimba also provides Castanet Repeaters and Proxies.

Repeaters

For especially large sites or popular transmitters, Castanet offers transmitter repeaters.

Repeaters are used to mirror a channel across multiple transmitters. As with extremely popular Web or FTP sites, it is possible for a channel to become so popular that its transmitter becomes overloaded with connections. Creating mirror sites—copying the contents of one site to a different machine on the network, and accepting connections at any of those sites—distributes the load on the one transmitter to multiple systems, offering scalability of a single transmitter as high as you need it to be and reducing the load on any single transmitter. (Figure 1.3 shows a general model for how mirrors work.) In addition, if mirrors are located in different geographical locations, they can provide better performance for those users at those locations. For example, a Japanese user of a channel in the United States could instead tune into a repeater transmitter in Japan, making the connection times faster and reducing the amount of traffic across intercontinental networks.

Figure 1.3. Mirror sites.

Currently, the problems of mirroring a Web or FTP site are similar to that of keeping software up to date at a number of sites; you have to coordinate the contents of the primary site with those on the mirror, which can involve administrative nightmares (keeping track of which files are now or have changed, and updating only those files), or routinely bundling up the entire server and shipping it to the mirror (involving long download times). You'll also, of course, need administrators on each mirror to oversee the update process. This can result in the mirrors being not quite as up to date or robust as the primary server, which reduces the usefulness of the mirror site.

This is obviously a task for which the Castanet model for channels and updates is ideal. Castanet Repeaters make it easy to distribute channels to multiple sites and to keep the data coordinated between the primary transmitter and the repeater. A repeater is effectively both a tuner and a transmitter at the same time. The repeater subscribes to channels on a primary transmitter, so that all the data in the channel on the repeater's site is up to date at all times. The repeater also then transmits its channels to other tuners, and those tuners subscribe to and download channels from the repeater as if they were the primary transmitter. (See Figure 1.4.)

Figure 1.4. How repeaters work.

In addition to simply mirroring a channel's content, repeaters also allow automatic redirection of incoming connections from one transmitter to an available repeater. When a tuner makes a connection to a transmitter, therefore, the transmitter can pass on that connection automatically to a less-loaded repeater or to one closer to the original tuner. If the new repeater becomes unavailable or is itself overloaded with connections, the tuner can recontact the original transmitter for another repeater. All this is transparent to the user with the tuner, and it provides a seamless mechanism for transmitting channels to one user or to millions.

The Castanet repeater is an add-on to existing transmitters; the repeater simply provides the capability for two transmitters to talk to each other. You will have to purchase each transmitter (the primary and each mirror) independently. The Castanet Repeater is not yet available, so I won't cover it in this book; Contact Marimba or visit `http://www.marimba.com/` for more details about purchasing and using the Castanet Repeater.

Proxies

The final part of the overall Castanet system I'll mention in this chapter is the Castanet Proxy. A proxy server is, generically, a program that acts as a network liaison between one set of systems and another, typically on organizations that have firewalls. For the World Wide Web, for example, a browser running on an internal network would make HTTP requests to an HTTP proxy server, which would in turn pass those requests out to the Internet at large and then pass the data back to the internal network. This allows the network administrator to control access to the Internet from inside a network, and, in turn, to control access to the network from the Internet.

Figure 1.5 shows how this works: The systems in the lower half of the figure are on an internal network (intranet)—for example, for a corporation or a university, and include computers running Web browsers or computers running Castanet Tuners. Whenever a connection is made from one of those systems to a system on the Internet (the systems in the upper half of the figure, which include Web servers or Castanet Transmitters), the request is routed through the proxy server (in the middle). The proxy server also passes the data back from the Internet systems back to the systems on the internal network.

Figure 1.5. Proxy servers and firewalls.

The problem with proxy servers is that because all connections between an internal and external network must run through the proxy server, that tends to create a bottleneck in that proxy. To reduce the bottleneck, an additional feature of proxy servers is the capability to cache popular data on the proxy server itself. If, for example, multiple requests are made for a single popular page on a Web site from inside a firewall, the proxy server keeps a local copy of that page in the local cache to reduce the number of connections outside the firewall. The proxy would, of course, have to occasionally check the original server to make sure the page hadn't changed and update things accordingly.

Castanet Proxies provide both these features for channels: The capability to use tuners to access transmitters through a firewall and to store channels on a local system to reduce network traffic through the firewall. Although you could use a standard HTTP server for accessing transmitters (as the Marimba connection protocol is compatible with HTTP), you would not get the caching effect that the Castanet Proxy provides. If your organization uses a firewall and you expect many of your users to take advantage of the Castanet technology, you should look into installing a Castanet proxy.

As with the Castanet Repeater, Castanet proxy servers are not yet shipping, so I won't cover their use in this book. Contact Marimba or visit `http://www.marimba.com/` for more details.

#### Where Castanet Is Now

At the time I write this, the 1.0 versions of Castanet and Bongo are about to be released. Although this book was written and tested on earlier beta versions of Castanet and Bongo, it has been reviewed for completeness by the Marimba team and should reflect the final versions with only minor differences.

Currently, the 1.0 version of Castanet supports a basic framework for developing and using channels written primarily in Java. Future versions of Castanet will build on that framework and extend it to channels written in any language, to include security mechanisms for authenticated channels, to allow channels to be digitally signed, and to provide billing for channels or for updates. In addition, the current version of Castanet works with the 1.02 JDK (Java Developer's Kit); future versions will include support for the newly released 1.1 JDK and for its many features.

I'll point out where new features of Castanet are planned or where changes will most likely occur throughout this book.

### Summary

Castanet was created to solve the problems of traditional software distribution, installation, and maintenance. Traditionally, a software developer publishes a product on floppies or CD-ROM, and users have to install that product on their own systems before they can use it. Each new version of the product has to be independently installed. Shipping software as a downloadable file from an FTP or Web site makes it faster for products to reach the hands of customers, but it still requires the user to actually take the time to install the product.

Java applets solve the installation problem; you just download the applet and run it. But applets have their own limitations, the most obvious being that they're not stored on the local disk except for a temporary cache.

Castanet provides the next step in software distribution: a transparent system by which software is distributed in the form of channels, and users automatically receive that software (have it downloaded and installed) by subscribing to it over a network. After a channel has been subscribed to, users continue to receive updates to that channel over the Internet quietly in the background, guaranteeing that they have the latest version of the channel at all times. Channels have all the advantages of Java applets—being up to date all the time, can run in multiple environments, and have built-in security to prevent malicious behaviors—while retaining the persistence and the capability to write local files of the conventional application.

In this chapter, you got a basic overview of how Castanet works and why it's useful. Throughout this book, you'll learn how to install and use the Castanet Tuner and Castanet Transmitter to use and publish channels. In the last part of this book you'll learn about developing your own channels for use with tuners and transmitters. Read on to learn more!