contents   index   previous   next



interface: SEPrepareContext

 

public void sePrepareContextFunc(SEContext se);

 

After seCreateContext has finished preparing a new context, it invokes the sePrepareContextFunc. You can do any final setup on your context here, such as adding your application specific wrapper tables (see Chapter VII). If you do the final preparation here instead of in your code after calling seCreateContext, then all calls to seCreateContext will do that same preparation. This is useful if you are using utility libraries that create new contexts with seCreateContext. It ensures those contexts are properly set up for your application. Nombas has no utility routines that use seCreateContext. However, some may be created in the future.

 

Here is an example of using the ScriptEase Context Parameter Interfaces to create a context:

 

class MyParams implements SEContextParams, SEErrorHandler

{

   private int myOptions;

 

   MyParams(int options)

   {

      this.myOptions = options;

   }

 

   public int seGetOptions()

   {

      return myOptions;

   }

 

   public void seSetOptions(int newOptions)

   {

      this.myOptions = newOptions;

   }

 

   public void sePrintErrorFunc(SEContext se, String text)

   {

      System.err.println("Error encountered: " + text);

   }

}

 

public class MyApplication

{

   public static final void main(String[] argv)

   {

      SEContext se;

      MyParams params;

 

      SE.seInitialize();

 

      params = new MyParams(SE.DEFAULT);

 

      se = SE.seCreateContext(params, "");

 

      /* your application, including scripting using 'se'

       * as the scripting context.

       */

 

      se.seDestroyContext();

 

      SE.seTerminate();

   }

}