Quick Guide


This page lists the steps to create and run your first application using DJBinder. You can get more detailed information in the DJBinder general description.

  1. Download the djbinder.jar file.
  2. Grant all the security authorizations to the djbinder.jar file or install it as an extension of the Java virtual machine.
  3. Create a normal Java class. Let's call it X. By the sake of simplicity let's assume that this is the only class of your application.
  4. Optionally create a DA_X class to dynamically authorize DI_X__* classes to access some of the protected and private members of the X class. The most important specifications of the DA_X class are :
    • it must belong to the same package of X.
    • it must be abstract.
    • all its members must be public.
    • all its methods must be abstract.
    • members of the X class with exactly the same signature become accessible from the DI_X__* classes.
    • example :

      abstract class DA_X
      {

      public int xPrivateField ;
      public abstract int xPrivateMethod(int a, String b) ;
      }

  5. Create a DI_X__I class to dynamically implement the I interface for the X class. The most important specifications of the DI_X__I class are :
    • it must belong to the same package of X.
    • it must be public, abstract and implement the I interface.
    • it can extend another class or implement other interfaces.
    • it can have a public init method to initialize its member fields.
    • it can access the public and package members of the main object by casting the this reference into X. You should use a middle cast into java.lang.Object because Java forbids to directly cast DI_X__I into X.
    • it can access the protected and private members of the main object by casting the this reference into DA_X. You should use a middle cast into java.lang.Object because Java forbids to directly cast DI_X__I into DA_X.
    • example :

      public abstract class DI_X__I implements I
      {

      public void init (Object reserved)
      {
      this.myfield1 = ((X)(Object)this).xPublicField ;
      this.myfield2 = ((DA_X)(Object)this).xPrivateField ;
      }
      // methods of the I interface
      }

  6. If the package of X is sealed you must create the DA_X and DI_X__I classes into a djbinder subpackage. For example if the X class belongs to the a.b.c package, then the DA_X and DI_X__I classes must belong to the a.b.c.djbinder package.
  7. Compile the X, DA_X and DI_X__I classes and the I interface using your favorite JDK 1.2 compatible Java compiler.
  8. Run the application using your favorite JDK 1.2 compatible Java virtual machine. Instead of running the main class of your application you run the amslib.djbinder.Start class. The first argument of amslib.djbinder.Start class is the application's main class, the second argument is the application's first argument and so on. For example :

    c:\jdk1.2\bin\java amslib.djbinder.Start X FirstArg SecondArg


DJBinder downloads tutorials consulting contact us links Amslib