JavaBeans Activation Framework

Introduction

In computer programming, JavaBeans Activation Framework, or JAF, enables developers to:[1]

  • determine the type of an arbitrary piece of data,
  • encapsulate access to it,
  • discover the operations available on it and
  • to instantiate the appropriate bean to perform the operation(s).

It also enables you to dynamically register types of arbitrary data and actions associated with particular kinds of data. Additionally, it enables a program to dynamically provide or retrieve JavaBeans that implement actions associated with some kind of data.

Datasource Interface

DataContentHandler interface

CommandMap class

CommandObject interface

Example: Compose an e-mail with attachment

import javax.activation.DataHandler;

import javax.activation.FileDataSource;

import javax.mail.internet.*;

import javax.mail.*;

...

// Create a message.

MimeMessage message = new MimeMessage(session);

...

// Create the Multipart to be added the parts to

Multipart multipart= new MimeMultipart();

// Create and fill the first text message part

MimeBodyPart mbp = new MimeBodyPart();

mbp.setText(Body);

multipart.addBodyPart(mbp);

// Create a file attachment and fill as second message part

MimeBodyPart mbp = new MimeBodyPart();

FileDataSource fds = new FileDataSource(“C:attachment.zip”);

mbp.setDataHandler(new DataHandler(fds));

mbp.setFileName(fds.getName());

multipart.addBodyPart(mbp);

// Add the multipart to the message

message.setContent(multipart);

...

JAF in use

External links

References

  1. JavaBeans Activation Framework. Retrieved 2013-08-11.