Updating and addign files...
authorMarc G. Fournier
Thu, 19 Nov 1998 02:39:51 +0000 (02:39 +0000)
committerMarc G. Fournier
Thu, 19 Nov 1998 02:39:51 +0000 (02:39 +0000)
src/corba/pgsql.idl
src/corba/pgsql_int.idl [new file with mode: 0644]
src/corba/server.cc [new file with mode: 0644]

index 63a593b2f377591ee55c838454d65be3f75c0760..760108404a2e3310eca35e4d14866696ac5478c0 100644 (file)
@@ -1,79 +1,96 @@
-#ifndef pgsql_idl\r
-#define pgsql_idl\r
-\r
-#ifndef CosQuery_idl\r
-#include "CosQuery.idl"\r
-#endif\r
-\r
-#ifndef CosQueryCollection_idl\r
-#include "CosQueryCollection.idl"\r
-#endif\r
-\r
-module PostgreSQL {\r
-   \r
-   // Built-in types\r
-   \r
-   module Types {\r
-       // Arrays in network order\r
-       typedef short int2;\r
-       typedef long int4;\r
-       typedef long int8[2];\r
-   };\r
-   \r
-   \r
-   // NULL support\r
-   \r
-   typedef boolean Null;\r
-   \r
-   union Value switch (Null) {\r
-     case false: any value;\r
-   };\r
-   \r
-   \r
-   // Row definition\r
-   \r
-   typedef sequence Row;\r
-   \r
-   // \r
-   // More about the application of COSS:\r
-   // \r
-   // A Table will be a QueryableCollection of Rows\r
-   // A Database will be a QueryableCollection of Tables\r
-   // (Currently Tables are not exported... maybe later.)\r
-   // Both will be queryable via the Query Service\r
-   // \r
-   // Other relations will be representable using the Relationship Service\r
-   // This includes primary/foreign keys and anything else :)\r
-   // \r
-   // GRANT/REVOKE can be supplied via the Security Service\r
-   // \r
-   // See a pattern here? The whole of SQL can be implemented by these services!\r
-   // The statements go through a parser. Queries and subqueries are passed to the\r
-   // database for processing. Returned items are handled appropriately:\r
-   // \r
-   // SELECT: return the items to the caller\r
-   // UPDATE: modify the items (direct)\r
-   // DELETE: call delete() on each Row (direct)\r
-   // GRANT/REVOKE: modify ACLs (via Security Service)\r
-   // ALTER: modify the items (direct) and/or the relations (via Relationship Service)\r
-   // etc.\r
-   // \r
-   // I'm not sure yet about LOCK and UNLOCK.\r
-   // \r
-   \r
-   \r
-   // Connected database object\r
-   \r
-   interface Database : CosQuery::QueryableCollection {\r
-       void disconnect();\r
-   };\r
-   \r
-   \r
-   // Server object (stateless)\r
-   \r
-   interface Server {\r
-       Database connect(in string db, in string user, in string password);\r
-   };\r
-};\r
-\r
-#endif // pgsql_idl\r
+#ifndef pgsql_idl
+#define pgsql_idl
+
+#ifndef CosQuery_idl
+#include "CosQuery.idl"
+#endif
+
+#ifndef CosQueryCollection_idl
+#include "CosQueryCollection.idl"
+#endif
+
+#pragma prefix ""
+
+module PostgreSQL {
+   
+   // Built-in types
+   
+   module Types {
+       // Arrays in network order
+       typedef short int2;
+       typedef long int4;
+       typedef long int8[2];
+   };
+   
+   
+   // NULL support
+   
+   typedef boolean Null;
+   
+   union Value switch (Null) {
+     case FALSE: any value;
+   };
+   
+   
+   // Row definition
+   
+   typedef sequence Row;
+   
+   // 
+   // More about the application of COSS:
+   // 
+   // A Table will be a QueryableCollection of Rows
+   // A Database will be a QueryableCollection of Tables
+   // (Currently Tables are not exported... maybe later.)
+   // Both will be queryable via the Query Service
+   // 
+   // Other relations will be representable using the Relationship Service
+   // This includes primary/foreign keys and anything else :)
+   // 
+   // GRANT/REVOKE can be supplied via the Security Service
+   // 
+   // See a pattern here? The whole of SQL can be implemented by these services!
+   // The statements go through a parser. Queries and subqueries are passed to the
+   // database for processing. Returned items are handled appropriately:
+   // 
+   // SELECT: return the items to the caller
+   // UPDATE: modify the items (direct)
+   // DELETE: call delete() on each Row (direct)
+   // GRANT/REVOKE: modify ACLs (via Security Service)
+   // ALTER: modify the items (direct) and/or the relations (via Relationship Service)
+   // etc.
+   // 
+   // I'm not sure yet about LOCK and UNLOCK.
+   // 
+   
+   // Expirable object
+   
+   interface Expirable {
+       /* oneway? */ void keepalive();
+       void remove();
+   };
+   
+   
+   // Upcall object
+   
+   interface Upcall {
+       void notice(in string message);
+       void abort();
+   };
+   
+       
+   // Connected database object
+   
+   interface Database : CosQuery::QueryableCollection, Expirable {
+       void setupcall(in Upcall obj);
+   };
+   
+   
+   // Server object (stateless)
+   
+   interface Server {
+       Database connect(in string db, in string user, in string password);
+   };
+};
+
+#endif // pgsql_idl
diff --git a/src/corba/pgsql_int.idl b/src/corba/pgsql_int.idl
new file mode 100644 (file)
index 0000000..8cfebc0
--- /dev/null
@@ -0,0 +1,7 @@
+// Internal interfaces
+
+#include "pgsql.idl"
+
+module PostgreSQL {
+   interface QueryResult : CosQueryCollection::Collection, Expirable {};
+};
diff --git a/src/corba/server.cc b/src/corba/server.cc
new file mode 100644 (file)
index 0000000..dff1328
--- /dev/null
@@ -0,0 +1,59 @@
+#include \r
+#include "pgsql_int.h"\r
+\r
+bool terminate = false;\r
+\r
+int main(int argc, char *argv)\r
+{\r
+   CORBA::ORB_var orb = CORBA::ORB_init(argc,argv,"");\r
+   PortableManager::POA_var poa = PortableServer::POA::_narrow(orb->resolve_initial_references("RootPOA"));\r
+   PortableManager::POAManager_var mgr = poa->the_POAManager();\r
+   \r
+   Server_impl *server = new Server_impl;\r
+   poa->activate_object(server);\r
+   \r
+   CosNaming::NamingContext_var ctx = CosNaming::NamingContext::_narrow(orb->resolve_initial_references("NamingService"));\r
+   CosNaming::Name_var n = new CosNaming::Name(1);\r
+   n[0].id("PostgreSQL");\r
+   n[0].name("service");\r
+   bool bindok = false;\r
+   \r
+   if (!CORBA::Object::is_nil(ctx)) {\r
+       try {\r
+           CosNaming::NamingContext_var myctx = ctx->bind_new_context(n);\r
+           CosNaming::Name_var n2 = new CosNaming::Name(1);\r
+           n2[0].id("Server");\r
+           n2[0].name("Server");\r
+           myctx->bind(n2,server->_this());\r
+           bindok = true;\r
+       } catch (CORBA::Exception &e) {\r
+           cerr << "Warning: Naming Service bind failed" << endl;\r
+           bindok = false;\r
+       }\r
+   } else {\r
+       cerr << "Warning: Naming Service not found" << endl;\r
+   }\r
+   \r
+   mgr->activate();\r
+   while (!terminate) {\r
+       if (orb->work_pending())\r
+           orb->perform_work();\r
+       if (expiry_needed())\r
+           expire_now();\r
+   }\r
+   \r
+   if (!CORBA::Object::is_nil(ctx) && bindok) {\r
+       try {\r
+           CosNaming::NamingContext myctx = ctx->resolve(n);\r
+           ctx->unbind(n);\r
+           myctx->destroy();\r
+       } catch (CORBA::Exception &e) {\r
+           cerr << "Warning: Naming Service unbind failed" << endl;\r
+       }\r
+   }\r
+   \r
+   orb->shutdown(true);\r
+   \r
+   delete server;\r
+   return 0;\r
+}\r