- API and Design-

This section only applies to JFileUpload Enterprise and Premium packages (API is not available for JFileUpload Pro release). It targets Java developers or designers. It requires Java, HTTP, FTP and Swing UI skills. It allows to understand how JFileUpload products work and interact. It's a good starting point to extend JFileUpload features or modify its behavior.

Design

JFileUpload is designed to support any transport implementation, any upload preprocessing and any front-end:

  • Transport implementation such as HTTP and FTP extend AbstractTransferController class. init(), begin() and cancel() methods have to be implemented and handle threading. Transport implementation is loaded at runtime through "mode" parameter.
  • Processing before upload is available with TransferFilter interface. It comes with three methods init(...), execute(...) and clean(). init(controller) is called on applet loading with transfer controller instance matching to transport. execute(object) is called just before transfer with reference to file to upload. clean() is called just after upload.
  • Front-end is loaded at runtime with fully qualified classname defined in "transferui" parameter. This class must implement TransferUI interface which includes three methods: init(...), start() and stop(). init(parent, conf, controller) is called on applet loading with parent container reference, access to JFileUpload configuration, I18N resources and transfer controller instance matching to transport. start() is called just before displaying and stop() just before UI finalization. Calling controller.begin() will trigger upload. Transfer events such as upload started, completed, cancelled, failed and more are available by implementing TransferListener interface.

It means that you don't need full source code to extend JFileUpload until you plan to create (from scratch) new UI, new preprocessing filter or transport implementation only. However, if you need to modify behavior inside JFileUpload (or its add-ons) then you need full source code (Premium package).

API

upload.client includes MApplication and MApplet. MApplication extends JFrame for standalone or WebStart usage. MApplet extends JApplet for applet in browser usage. transfer.client package includes core, http, ftp, util and mdesign packages. core package includes all interfaces and abstract classes of JFileUpload API. http package is the HTTP upload implementation. ftp package is the FTP upload implementation. mdesign package includes basic front-end component (progress bar, cancel button, menu and textarea). util package includes Conf class allowing to load parameters/resources and instanciates transfer implementation, transferui. and uihelper.

[Browse JFileUpload Javadoc]

Build from sources (Premium package only)

JFileUpload Premium package comes with an ANT (1.7 or higher) build script. ANT is a free tool allowing to build any Java application without IDE. The build script includes tasks to compile sources, build JAR files, generate Javadoc and sign JAR files. To run the build script, you have to:

  1. Edit setenv.bat to update JAVA_HOME and ANT_HOME variables.
  2. Copy your keystore* in the same directory as setenv.bat
  3. Edit build.xml to update your keystore filename, alias and password.
  4. Open a command line window or terminal.
  5. Execute "setenv.bat".
  6. Execute "ant all". It will compile sources, build JARs and generate Javadoc.
  7. Execute "ant sign". It will sign the generated JARs with key/certificate in keystore.
  8. Ready-to-use binaries (JARs) are under dist/ directory.

* A keystore includes private keys + certificates. It is required to sign Java binaries. Premium package doesn't include such keystore because it is related to your company. If you don't have one then you can generate it with a self-signed certificate thanks to Java keytool available in JDK. If you already have a trusted certificate (from Verisign or Thawte) then keytool allows to import it in the keystore too. Note that many developers are not familiar with code signing certificate and process to get one. Such help is included in Premium package support so feel free to contact support team for any question.

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
All other company and/or product names are the property of their respective owners.