IWG - Interface Wrapper Generator

IWG is a tool for generating wrapper classes. The wrapper implements an interface, and takes an object implementing this interface as constructor parameter.
Each implemented method of the wrapper then calls the corresponding method of this original object.
IWG is especially useful if you want to inherit from a class which cannot be inherited (e.g. a singleton or a final class, or EJBs which you want to enhance for new functionalities).
Then you can create a new class, implementing the same interface, and redirecting all but some overwritten methods to the old class.
Additionally, you can change the wrapped object without re-creating a new wrapper object. This allows dynamic changed behaviour, or class-reloading of singletons.
IWG is able to implement many interfaces at once.

For an example, see below.

Current files

sources only
binary files only

Change History

version 0.5.1 ( bin / src )

  • now handling relative pathnames for sourcepath correctly
  • sorting fields, methods and imports
  • generating missing brackets for constructor

version 0.5 ( bin / src )

  • initial release


You want to inherit from a class my.package.DatabaseManager, to add connection pooling. But this class is a singleton (and therefore has a private constructor), so you cannot do this. But you can create a wrapper, which then looks like:

import java.sql.Connection;
import my.package.IDatabaseManager;

public class NewDataManager implements IDatabaseManager // IDatabaseManager is the base interface
    private IDatabaseManager _origDatabaseManager=null;

    public NewDatabaseManager(IDatabaseManager aDatabaseManager)

    public Connection getConnection()
        // owerwritten method here

    public void shutdown()

    public boolean isOpen()
        return _origDatabaseManager.isOpen();

    public void openDatabase(String name)

all method calls except for the overwritten one are redirected to the orginal manager.