summaryrefslogtreecommitdiff
path: root/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2015-03-03 17:30:50 -0500
committerJoe George <joe@zeroc.com>2015-05-12 11:41:55 -0400
commitd35bb9f5c19e34aee31f83d445695a8186ef675e (patch)
treed5324eaf44f5f9776495537c51653f50a66a7237 /cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp
downloadice-d35bb9f5c19e34aee31f83d445695a8186ef675e.tar.bz2
ice-d35bb9f5c19e34aee31f83d445695a8186ef675e.tar.xz
ice-d35bb9f5c19e34aee31f83d445695a8186ef675e.zip
Ice 3.4.2 Source Distributionv3.4.2
Diffstat (limited to 'cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp')
-rw-r--r--cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp
new file mode 100644
index 00000000000..24c415cd030
--- /dev/null
+++ b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp
@@ -0,0 +1,80 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <OCCIServantLocator.h>
+#include <EmpI.h>
+#include <DeptI.h>
+#include <DbTypes.h>
+#include <Util.h>
+#include <occi.h>
+
+using namespace std;
+using namespace oracle::occi;
+
+OCCIServantLocator::OCCIServantLocator(const DeptFactoryIPtr& factory) :
+ _factory(factory)
+{}
+
+
+Ice::ObjectPtr
+OCCIServantLocator::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie)
+{
+ ConnectionHolderPtr con = new ConnectionHolder(_factory->getConnectionPool());
+ RefAny ref = decodeRef(current.id.name, _factory->getEnv(), con->connection());
+
+ try
+ {
+ //
+ // Extract SQL type from target object
+ //
+ string sqlType = Ref<PObject>(ref)->getSQLTypeName();
+
+ //
+ // Create and return the servant, used only for this one operation
+ //
+ if(sqlType.find("EMP_T") != string::npos)
+ {
+ return new EmpI(ref, con, _factory);
+ }
+ else if(sqlType.find("DEPT_T") != string::npos)
+ {
+ return new DeptI(ref, con, _factory);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch(const SQLException& sqle)
+ {
+ if(sqle.getErrorCode() == 21700)
+ {
+ return 0;
+ }
+ else
+ {
+ throw;
+ }
+ }
+}
+
+void
+OCCIServantLocator::finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&)
+{
+ //
+ // Nothing to do: if the connection was not yet released, it is released (and the tx rolled back)
+ // when the servant's last refcount goes away
+ //
+}
+
+void
+OCCIServantLocator::deactivate(const string&)
+{
+}
+