Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: demo/chapters/ichi/jnippExample/SimpleProxy.java


1   package demo.chapters.ichi.jnippExample;
2   
3   import demo.chapters.ichi.jnippExample.Simple;
4   
5   public class SimpleProxy
6     implements Simple
7   {
8     private long peerPtr = 0;
9   
10    private static native void init();
11    private native void releasePeer();
12  
13    protected void finalize()
14      throws Throwable
15    {
16      releasePeer();
17    }
18  
19    // methods
20    public native String getData();
21    public native void loadByID(String p0);
22  
23  
24    static
25    {
26      System.loadLibrary( "Simple" );
27      init();
28    }
29  
30    public static void main(String[] args)
31    {
32      try
33      {
34        SimpleProxy s1 = new SimpleProxy();
35        SimpleProxy s2 = new SimpleProxy();
36        s1.loadByID( "s1ID" );
37        s2.loadByID( "s2ID" );
38        System.out.println( "s1.getData() == \"" + s1.getData() + "\"" );
39        System.out.println( "s2.getData() == \"" + s2.getData() + "\"" );
40        s1.loadByID( null );
41      }
42      catch(Exception ex)
43      {
44        System.out.println( "Caught exception:" );
45        ex.printStackTrace();
46      }
47    }
48  }