DB2 Universal Database - Systemverwaltung


Einsatz-Szenario

Der Code im folgenden Beispiel wird folgende Aktionen durchführen:

  1. Aktualisieren der Aktionen der Beispieldatenbank (siehe "MySample.java")
  2. Aktualisieren der Aktionen aller Datenbankobjekte (siehe "MyDatabaseActions.java")
  3. Hinzufügen eines neuen Exemplarobjekts (siehe "MyInstance.java")
  4. Aktualisieren der Aktionen des DB-Exemplars (siehe "MyDB2.java")
  5. Aktualisieren der Aktionen des Datenbankordners (siehe "MyDatabases.java")
  6. Aktualisieren der Aktionen der Tabelle SYSIBM.SYSPLAN (siehe "MySYSPLAN.java")
  7. Hinzufügen eines neuen Tabellenobjekts (siehe "MyTable.java")
  8. Aktualisieren der Aktionen des Objekts DB_User unter dem Anwendungsobjekt (siehe "MyDBUser.java")
  9. Hinzufügen eines Knopfs zur Menüleiste der Steuerzentrale (siehe "MyToolbarAction.java").

Die Haupterweiterungsdatei ist MyExtension.java. Alle Klassendateien werden mit dem folgenden Befehl im Plug-In-Verzeichnis gespeichert und komprimiert:

   zip -r0 db2plug.zip plugin

Die entstandene Datei "db2plug.zip" wird dann in das Verzeichnis, auf das die Umgebungsvariable CLASSPATH verweist, oder in das codebase-Verzeichnis (Codebasis) gesetzt, je nachdem, ob die Steuerzentrale als Anwendung oder Applet ausgeführt wird.

MyExtension.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyExtension implements CCExtension
{
   public CCObject[] getObjects()
   {
      CCObject[] objs = new CCObject[10];
      objs[0] = new MySample();
      objs[1] = new MyDatabaseActions();
      objs[2] = new MyInstance();
      objs[3] = new MyDB2();
      objs[4] = new MyDatabases();
      objs[5] = new MySYSPLAN();
      objs[6] = new MyTable();
      objs[7] = new MyDBUser();
      return objs;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] actions = new CCAction[1];
      actions[0] = new MyToolbarAction();
      return actions;
   }
}

MySample.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MySample implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE";
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyDatabaseActions.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDatabaseActions implements CCObject
{
   public String getName()
   {
      return null;
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyDropAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyInstance.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyInstance implements CCObject
{
   public String getName()
   {
      return "LOCAL - MyInstance";
   }
 
   public int getType()
   {
      return INSTANCE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return true;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return null;
   }
 
}

MyDB2.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDB2 implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2";
   }
 
   public int getType()
   {
      return INSTANCE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[3];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      acts[2] = new MyCascadeAction();
      return acts;
   }
}

MyDatabases.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDatabases implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - Databases";
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[1];
      acts[0] = new MyCreateAction();
      return acts;
   }
 
}

MySYSPLAN.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MySYSPLAN implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE - SYSIBM - SYSPLAN";
   }
 
   public int getType()
   {
      return TABLE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyTable.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyTable implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE - SYSIBM - MyTable";
   }
 
   public int getType()
   {
      return TABLE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return true;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyDBUser.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDBUser implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - TEST-DB Users";
   }
 
   public int getType()
   {
      return DB_USER;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyToolbarAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
import javax.swing.*;
 
public class MyToolbarAction extends CCAction
{
   public MyToolbarAction()
   {
      super("MyToolbarAction");
   }
 
   public ImageIcon getIcon()
   {
      return <Your icon>;
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My action performed, object name = " +
                          objectName );
      return true;
   }
}

MyAlterAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyAlterAction extends CCAction
{
   public MyAlterAction()
   {
      super(0);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My alter action performed, object name = " +
                          objectName );
      return true;
   }
}

MyAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyAction extends CCAction
{
   public MyAction()
   {
      super("MyAction");
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My action performed, object name = " +
                          objectName );
      return true;
   }
}

MyDropAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDropAction extends CCAction
{
   public MyDropAction()
   {
      super(1);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My drop action performed, object name = " +
                          objectName );
      return true;
   }
}

MyCascadeAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyCascadeAction extends CCAction
{
   public MyCascadeAction()
   {
      super(11,2);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My cascade action performed, object name = " +
                          objectName );
      return true;
   }
}

MyCreateAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyCreateAction extends CCAction
{
   public MyCreateAction()
   {
      super(0);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My create action performed, object name = " +
                          objectName );
      return true;
   }
}


[ Seitenanfang | Vorherige Seite | Nächste Seite | Inhaltsverzeichnis | Index ]