Rem
Rem $Header: initrepapi.sql 26-oct-99.10:26:35 arrajara Exp $
Rem
Rem initrepapi.sql
Rem
Rem  Copyright (c) Oracle Corporation 1999. All Rights Reserved.
Rem
Rem    NAME
Rem      initrepapi.sql - load RepAPI server classes and publish 'repapi' obj
Rem
Rem    DESCRIPTION
Rem      Loading this file is required for Java RepAPI to work. 
Rem      $ORACLE_HOME/rdbms/jlib/repapi_s.jar is loaded to the database.
Rem      RServer.class and  its helper class are published in /etc  
Rem      namespace.
Rem
Rem    NOTES
Rem      Executed as part of 8i database creation.
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem    arrajara   10/22/99 -  Created
Rem


--### Load the RepAPI server classes into the database

call sys.dbms_java.loadjava ('-force -resolve rdbms/jlib/repapi_s.jar');
call sys.dbms_java.loadjava ('-verbose -synonym -grant public rdbms/jlib/repapi_s.jar');


--### Publish the 'repapi' CORBA object in /etc namespace

DECLARE
  rootinode   NUMBER;
  etcinode    NUMBER;
  objectinode NUMBER;
  object_type NUMBER;
  pub         NUMBER;
  sys         NUMBER;
  read        NUMBER;
  write       NUMBER;
  exec        NUMBER;
  objectname  VARCHAR2 (256); -- name of the object
  objectclass VARCHAR2 (256); -- class of the object
  classhelper VARCHAR2 (256); -- helper class

BEGIN
  objectname   := 'repapi';
  objectclass  := 'oracle.repapi.server.RServer';
  classhelper  := 'oracle.repapi.serverstub.RSHelper';

  rootinode    := 1;
  object_type  := 0;
  pub          := 1;
  read         := 0;
  write        := 1;
  exec         := 2;
  sys          := 0;

  SELECT child INTO etcinode FROM sys.aurora$sns$bindings$
    WHERE parent = 1 and id = 'etc';

  objectinode :=
    dbms_orb_context.mkobject (sys, sys, objectclass, classhelper);
  dbms_orb_context.ADDperm (objectinode, read, pub);
  dbms_orb_context.ADDperm (objectinode, write, sys);
  dbms_orb_context.ADDperm (objectinode, exec, pub);

  -- exe is in etc
  dbms_orb_context.link (etcinode, objectinode, objectname, '.', object_type);
  COMMIT;

 EXCEPTION WHEN OTHERS THEN
  dbms_output.put_line('initrepapi.sql : Exception in publish of /etc/repapi');
  RAISE;
END;
/
