You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/08/23 18:48:18 UTC
svn commit: r1376588 [1/2] - in /incubator/etch/trunk:
binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/
binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/
binding-cpp/runtime/include/common/ binding-...
Author: veithm
Date: Thu Aug 23 16:48:16 2012
New Revision: 1376588
URL: http://svn.apache.org/viewvc?rev=1376588&view=rev
Log:
ETCH-198 Changes in helper and valuefactory
Refactoring of life cycle and memory management
Change-Id: If74bb9e43e0712fb8dca8cf52d364efa3d5d12a3
Added:
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h (contents, props changed)
- copied, changed from r1376587, incubator/etch/trunk/binding-cpp/runtime/include/support/EtchClientStack.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h (contents, props changed)
- copied, changed from r1376587, incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerStack.h
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp (with props)
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp (contents, props changed)
- copied, changed from r1376587, incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp (contents, props changed)
- copied, changed from r1376587, incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchServerStack.cpp
Removed:
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchClientStack.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerStack.h
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchServerStack.cpp
Modified:
incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_h.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_h.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_cpp.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_h.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStack.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStubBase.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchConnection.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/arch/Windows/ServerSocket.inc
incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchAuthenticationExceptionSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDateSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchHashTableSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchRuntimeExceptionSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchSetSerializer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchClass2TypeMapTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchComboValidatorTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchTypeMapTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp
incubator/etch/trunk/examples/helloworld/cpp/CMakeLists.txt
incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp
incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldListener.cpp
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java Thu Aug 23 16:48:16 2012
@@ -1186,7 +1186,7 @@ public class Compiler extends Backend {
Token t = type.type();
switch (t.kind) {
case EtchGrammarConstants.BOOLEAN:
- return "EtchBool";
+ return "Bool";
case EtchGrammarConstants.BYTE:
return "Byte";
case EtchGrammarConstants.SHORT:
@@ -1202,7 +1202,7 @@ public class Compiler extends Backend {
case EtchGrammarConstants.STRING:
return "String";
case EtchGrammarConstants.OBJECT:
- return "";
+ return "Object";
default: {
// we have to use a fully qualified name here.
// find the actual type...
@@ -1258,7 +1258,11 @@ public class Compiler extends Backend {
// TODO Auto-generated method stub
if(pointer)
return "EtchNativeArray" + this.getNativeArrayTypeName( type ) + "Ptr";
- return "EtchNativeArray" + this.getNativeArrayTypeName( type ) + "Obj";
+ if (type.type().kind == EtchGrammarConstants.BYTE) {
+ return "EtchNativeArray<" + this.getNativeTypeName( type, true ) + "> ";
+ } else {
+ return "EtchNativeArray<" + this.getNativeTypeName( type, true ) + "Ptr> ";
+ }
}
public String getNativeTypeName(TypeRef type, boolean etch_type) {
@@ -1269,7 +1273,7 @@ public class Compiler extends Backend {
case EtchGrammarConstants.BOOLEAN:
return (etch_type ? "EtchBool" : "capu::bool_t");
case EtchGrammarConstants.BYTE:
- return (etch_type ? "EtchByte" : "capu::int8_t");
+ return (etch_type ? "capu::int8_t" : "capu::int8_t");
case EtchGrammarConstants.SHORT:
return (etch_type ? "EtchShort" : "capu::int16_t");
case EtchGrammarConstants.INT:
@@ -1295,7 +1299,10 @@ public class Compiler extends Backend {
if (n.isBuiltin()) {
Builtin b = (Builtin) n;
if (n.efqname(this).equals("EtchDate")) return b.className();
- return b.className() + "Obj";
+ if (n.efqname(this).equals("EtchHashTable")) return b.className()+"<EtchObjectPtr, EtchObjectPtr> ";
+ if (n.efqname(this).equals("EtchHashSet")) return b.className()+"<EtchObjectPtr> ";
+ throw new IllegalArgumentException(String.format(
+ "unable to find correct Etch data type for type at line %d: %s", t.beginLine, n.efqname(this)));
}
if (n.isEnumx()) {
return n.efqname(this);
@@ -1494,8 +1501,13 @@ public class Compiler extends Backend {
Builtin b = (Builtin) n;
String cn = b.className();
- if (!n.efqname(this).equals("EtchDate"))
- cn += "Obj";
+ if (n.efqname(this).equals("EtchHashTable")) {
+ cn += "<EtchObjectPtr, EtchObjectPtr>";
+ }
+ if (n.efqname(this).equals("EtchHashSet")) {
+ cn += "<EtchObjectPtr>";
+ }
+
/*
* int i = cn.indexOf( '<' ); if (i >= 0) cn = cn.substring( 0, i );
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_cpp.vm Thu Aug 23 16:48:16 2012
@@ -35,12 +35,8 @@
#end
\#include "support/EtchRuntime.h"
-#if($helper.isServer($mc) || $helper.isBoth($mc))
-\#include "support/EtchServerStack.h"
-#end
-#if($helper.isClient($mc) || $helper.isBoth($mc))
-\#include "support/EtchClientStack.h"
-#end
+\#include "support/EtchStackClient.h"
+\#include "support/EtchStackServer.h"
\#include "support/EtchPool.h"
\#include "transport/EtchPlainMailboxManager.h"
\#include "transport/EtchDefaultDeliveryService.h"
@@ -61,6 +57,10 @@ $clname::Listener${i}Server::~Listener${
status_t $clname::Listener${i}Server::newServer(EtchRuntime* runtime, EtchTransportMessage* transport, const EtchString& uri, EtchResources* resources)
{
+ //get stack instance
+ EtchStackServer* stack = NULL;
+ resources->get(EtchStack::STACK(), (EtchObject*&)stack );
+
//get value factory
EtchObject* obj;
resources->get( EtchTransport<EtchValueFactory*>::VALUE_FACTORY(), obj );
@@ -68,8 +68,11 @@ status_t $clname::Listener${i}Server::ne
//create stack layers
EtchMailboxManager* mbm = new EtchPlainMailboxManager(transport, uri, resources);
+ stack->setMailboxManager(mbm);
EtchDeliveryService* dvs = new EtchDefaultDeliveryService(mbm, uri);
- Remote${i}Client* client = new Remote${i}Client(runtime, dvs, vf);
+ stack->setDeliveryService(dvs);
+ Remote${i}Client* client = new Remote${i}Client(runtime, dvs, vf, stack);
+ stack->setRemote(client);
${i}Server* server = mFactory->new${i}Server(client);
//get thread pools
@@ -81,7 +84,9 @@ status_t $clname::Listener${i}Server::ne
//create stub
Stub${i}Server* tmp${i}Server = new Stub${i}Server(dvs, server, qp, fp);
- EtchStack* stack = new EtchServerStack(client, tmp${i}Server, resources, vf);
+ stack->setStub(tmp${i}Server);
+
+ //start remote client
client->start();
return ETCH_OK;
}
@@ -117,7 +122,7 @@ status_t $clname::newListener(EtchRuntim
status_t status = ETCH_OK;
//static initialization of value factory
- ValueFactory${i}::__INIT(runtime);
+ ValueFactory${i}::InitValueFactory(runtime);
//init resources
EtchResources *res;
@@ -159,8 +164,10 @@ status_t $clname::newListener(EtchRuntim
{
status_t status = ETCH_OK;
+ EtchStackClient* stack = new EtchStackClient();
+
//static initialization of value factory
- ValueFactory${i}::__INIT(runtime);
+ ValueFactory${i}::InitValueFactory(runtime);
//init resources
EtchResources* res;
@@ -169,6 +176,10 @@ status_t $clname::newListener(EtchRuntim
return status;
}
+ EtchObject* tmp = NULL;
+ res->put(EtchStack::STACK(),stack, tmp);
+ stack->mStaticResources = res;
+
//create valuefactory instance
ValueFactory${i}* vf = new ValueFactory${i}(uri);
EtchObject* vfobj = (EtchObject*) vf;
@@ -180,8 +191,10 @@ status_t $clname::newListener(EtchRuntim
EtchTransportMessage* m;
EtchTransportFactory::getTransport(runtime, uri, res, m);
EtchMailboxManager* mbm = new EtchPlainMailboxManager(m, uri, res);
+ stack->setMailboxManager(mbm);
EtchDeliveryService* dvs = new EtchDefaultDeliveryService(mbm, uri);
- Remote${i}Server* _server = new Remote${i}Server(runtime, dvs, vf);
+ stack->setDeliveryService(dvs);
+ Remote${i}Server* _server = new Remote${i}Server(runtime, dvs, vf, stack);
${i}Client* client = implFactory.new${i}Client( server );
//get pools
@@ -193,7 +206,7 @@ status_t $clname::newListener(EtchRuntim
//init stub
Stub${i}Client* tmpStub${i}Client = new Stub${i}Client(dvs, client, qp, fp);
- EtchStack* stack = new EtchClientStack(server, tmpStub${i}Client, res, vf);
+ stack->setStub(tmpStub${i}Client);
//return server
server = _server;
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_h.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/helper_h.vm Thu Aug 23 16:48:16 2012
@@ -147,7 +147,7 @@ private:
#end
#if($helper.isClient($mc) || $helper.isBoth($mc))
- static status_t newServer(EtchRuntime* runtime, EtchString uri, EtchResources* resources, ${i}ClientFactory& implFactory, RemoteHelloWorldServer*& server);
+ static status_t newServer(EtchRuntime* runtime, EtchString uri, EtchResources* resources, ${i}ClientFactory& implFactory, Remote${i}Server*& server);
#end
};
}
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_h.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_h.vm Thu Aug 23 16:48:16 2012
@@ -98,7 +98,7 @@ namespace $namespace {
* $s
#end
*/
- $i.name()#if($enumHelper < $count),#end
+ $n.name()_$i.name()#if($enumHelper < $count),#end
#end
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_cpp.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_cpp.vm Thu Aug 23 16:48:16 2012
@@ -70,7 +70,7 @@ status_t $clname::$n.name()AsyncResultRe
return ETCH_OK;
}
-$intfname::$n.name()AsyncResultPtr $clname::$n.name()AsyncResultRemote::Begin($clname* base, #set($sep = "")#foreach($p in $n.iterator())$sep$helper.getEtchTypeName($p.type(), true) $p.name()#set($sep = ", ")#end) {
+$intfname::$n.name()AsyncResultPtr $clname::$n.name()AsyncResultRemote::Begin($clname* base#set($sep = ", ")#foreach($p in $n.iterator())$sep$helper.getEtchTypeName($p.type(), true) $p.name()#end) {
status_t status;
capu::SmartPointer<EtchMessage> msg;
@@ -108,11 +108,11 @@ $intfname::$n.name()AsyncResultPtr $clna
* @param vf
*/
#if($hasBaseClass)
-$clname::$clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf )
- : Remote${i}(runtime, svc, vf) {
+$clname::$clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf, EtchStack* stack )
+ : Remote${i}(runtime, svc, vf, stack) {
#else
-$clname::$clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf )
- : EtchRemoteBase(svc, vf), mRuntime(runtime) {
+$clname::$clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf, EtchStack* stack )
+ : EtchRemoteBase(svc, vf, stack), mRuntime(runtime) {
#end
}
@@ -131,7 +131,7 @@ $intfname::$n.name()AsyncResultPtr $clna
}
#else
$intfname::$n.name()AsyncResultPtr $clname::$n.name()(#set( $sep = "" )#foreach( $p in $n.iterator() )$sep$helper.getEtchTypeName( $p.type(), true ) $p.name() #set( $sep = ", " )#end) {
- $n.name()AsyncResultPtr result = $clname::$n.name()AsyncResultRemote::Begin(this, #set($sep = "")#foreach($p in $n.iterator())$p.name() #set( $sep = ", ")#end);
+ $n.name()AsyncResultPtr result = $clname::$n.name()AsyncResultRemote::Begin(this#set( $sep = ", ")#foreach($p in $n.iterator())$sep$p.name()#end);
return result;
}
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_h.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/remote_h.vm Thu Aug 23 16:48:16 2012
@@ -33,7 +33,7 @@
#if(!$hasBaseClass)
\#include "support/EtchRemoteBase.h"
#else
-\#include "ValueFactoryHelloWorld.h"
+\#include "${vfname}.h"
\#include "$inc"
\#include "Remote${i}.h"
#end
@@ -79,7 +79,7 @@ namespace $namespace {
/**
* Create a new instance from $clname class
*/
- static $n.name()AsyncResultPtr Begin($clname* base, #set($sep = "")#foreach($p in $n.iterator())$sep$helper.getEtchTypeName($p.type(), true) $p.name()#set($sep = ", ")#end);
+ static $n.name()AsyncResultPtr Begin($clname* base#set($sep = ", ")#foreach($p in $n.iterator())$sep$helper.getEtchTypeName($p.type(), true) $p.name()#end);
private:
$clname* mBase;
@@ -94,8 +94,9 @@ namespace $namespace {
*
* @param svc
* @param vf
+ * @param stack
*/
- $clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf );
+ $clname(EtchRuntime* runtime, EtchDeliveryService* svc, EtchValueFactory* vf, EtchStack* stack );
/**
* Destructor
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm Thu Aug 23 16:48:16 2012
@@ -143,33 +143,33 @@ namespace $namespace {
{
}
virtual ~Stub$i$suffix() {}
- static void init()
- {
- // nothing to do.
- }
-
+
##if($notEmpty)
- /*
- * Static Initialization-Helper
- */
+
private:
friend class ValueFactory${i};
- static void __INIT()
+
+ /**
+ * Static Initialization-Helper
+ */
+ static status_t Init()
{
-#foreach( $mthd in $intf.iterator() )
-#if ($mthd.isMsgDir($mc))
-#if (!$mthd.isHidden())
- ValueFactory$i::${mthd.vname( $helper )}->setStubHelper(new Run${mthd.vname($helper)}());
-#end
-#end
-#if( $n.isMixin() )
-#set( $m = $n.getModule() )
-#set( $z = $m.iterator().next() )
- ${m.name()}::Stub${z.name()}${suffix}::init();
-#end
-#end
+ #foreach( $mthd in $intf.iterator() )
+ #if ($mthd.isMsgDir($mc))
+ #if (!$mthd.isHidden())
+ ValueFactory$i::${mthd.vname( $helper )}->setStubHelper(new Run${mthd.vname($helper)}());
+ #end
+ #end
+ #if( $n.isMixin() )
+ #set( $m = $n.getModule() )
+ #set( $z = $m.iterator().next() )
+ ${m.name()}::Stub${z.name()}${suffix}::Init();
+ #end
+ #end
+ return ETCH_OK;
}
+
##end
};
}
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm Thu Aug 23 16:48:16 2012
@@ -26,17 +26,37 @@
#set( $vf = "ValueFactory$intf.name()" )
\#include "$inc"
+\#include "${intf.name()}.h"
+\#include "Stub${i}Server.h"
+\#include "Stub${i}Client.h"
\#include "common/EtchError.h"
\#include "serialization/EtchField.h"
\#include "serialization/EtchAsyncMode.h"
\#include "serialization/EtchDirection.h"
-\#include "${intf.name()}.h"
\#include "serialization/EtchValidators.h"
-\#include "Stub${i}Server.h"
-\#include "Stub${i}Client.h"
using namespace $namespace;
+status_t $vf::Etch${intf.name()}RuntimeListener::onRuntimeChanged(EtchRuntime* runtime) {
+ capu::int_t index = $vf::SRuntimes.find(runtime->getId());
+ if (index == -1) {
+ return ETCH_ERROR;
+ }
+ if (runtime->isClosed()) {
+ //the runtime is closed and is removed
+ $vf::SRuntimes.removeAt(index);
+ }
+ if ($vf::SRuntimes.isEmpty()) {
+ //clean up all static members
+ $vf::DestroyValueFactory();
+ }
+ return ETCH_OK;
+}
+
+capu::Mutex $vf::SRuntimesMutex;
+capu::List<capu::uint64_t> $vf::SRuntimes;
+$vf::Etch${intf.name()}RuntimeListener $vf::S${intf.name()}RuntimeListener;
+
##--------------------------------------------------------------
## Classes that represent anonym creation in java
##--------------------------------------------------------------
@@ -90,7 +110,7 @@ class ImportExportHelper$n.vname( $helpe
switch (v->Value)
{
#foreach ($p in $n.iterator())
- case $tname::$p.name(): _struct->put($vf::$p.vname($helper)(), new EtchBool(true) ); break;
+ case $tname::${tname}_$p.name(): _struct->put($vf::$p.vname($helper)(), new EtchBool(true) ); break;
#end
}
result = _struct;
@@ -105,11 +125,14 @@ class ImportExportHelper$n.vname( $helpe
return ETCH_EINVAL;
// there should only be a single key, so take the first one
- EtchField key = value->getFirstField();
+ EtchHashTable<EtchField, capu::SmartPointer<EtchObject> >::Iterator it = value->begin();
+ EtchHashTable<EtchField, capu::SmartPointer<EtchObject> >::Pair pair;
+ it.next(&pair);
+ EtchField key = pair.first;
#foreach ($p in $n.iterator())
if (key.equals(&$vf::$p.vname($helper)()))
{
- result = new ${tname}(${tname}::$p.name());
+ result = new ${tname}(${tname}::${tname}_$p.name());
return ETCH_OK;
}
#end
@@ -170,16 +193,17 @@ ${vf}::${vf}( EtchString uri ) : EtchDef
#end
}
-void ${vf}::initTypes()
+status_t ${vf}::InitTypes()
{
#foreach ( $n in $intf.iterator() )
#if ($n.isEnumx() || $n.isStruct() || $n.isExtern() || $n.isExcept() || $n.isMessage())
types()->get(EtchString("$n.fqname()"), ${vf}::${n.vname( $helper )});
#end
#end
+ return ETCH_OK;
}
-void ${vf}::initResults()
+status_t ${vf}::InitResults()
{
//AF: TO-REVIEW: finde die Verwendung von Anonymer Enum bei EchtDirection und bei EtchAsyncMode unschoen
@@ -202,10 +226,11 @@ void ${vf}::initResults()
#end
#end
#end
+ return ETCH_OK;
}
## ----------------------------- import / export -----------------------------
-void ${vf}::initImportExport()
+status_t ${vf}::InitImportExport()
{
#foreach ( $n in $intf.iterator() )
#if ($n.isStruct() || $n.isExcept())
@@ -225,11 +250,13 @@ void ${vf}::initImportExport()
$vf::${n.vname( $helper )}->setImportExportHelper(new ImportExportHelper$n.vname($helper)());
#end
#end
+
+ return ETCH_OK;
}
## ----------------------------- fields -----------------------------
-void ${vf}::initFields()
+status_t ${vf}::InitFields()
{
#set( $x = $params.clear() )
## standard params from DefaultValueFactory
@@ -245,24 +272,17 @@ void ${vf}::initFields()
#end
#end
#end
+ return ETCH_OK;
}
#set( $ctr = 0 )
-void $vf::initParams()
+status_t $vf::InitParams()
{
capu::SmartPointer<EtchValidator> tmpValue;
#foreach( $n in $intf.iterator() )
#if ($n.isEnumx() || $n.isStruct() || $n.isExcept() || $n.isMessage())
-#if ($ctr > 0 && $ctr % 100 == 0)
- initParams${ctr}();
-}
-
-void $vf::initParams${ctr}()
-{
- capu::SmartPointer<EtchValidator> tmpValue;
-#end
#set( $ctr = $ctr + 1 )
// params for $n.name()
#if ($n.isStruct() || $n.isExcept())
@@ -270,14 +290,14 @@ void $vf::initParams${ctr}()
$helper.getValidator($param);
$vf::${n.vname( $helper )}->putValidator($vf::$param.vname($helper)(), tmpValue);
-#end
+#end ## -- foreach --
#else
#foreach( $param in $n.iterator() )
$helper.getValidator($param);
$vf::${n.vname( $helper )}->putValidator($vf::$param.vname($helper)(), tmpValue);
-#end
-#end
+#end ## -- foreach --
+#end ## -- else --
#if ($n.isMessage())
EtchValidatorLong::Get(0, tmpValue);
${n.vname( $helper )}->putValidator($vf::_mf__messageId(), tmpValue);
@@ -289,52 +309,104 @@ void $vf::initParams${ctr}()
$helper.getValidator($t)
$vf::${n.vname( $helper )}->putValidator($vf::$param.vname($helper)(), tmpValue); // thrown $t.name()
-#end
+#end ## -- foreach --
EtchValidatorRuntimeException::Get(tmpValue);
$vf::${n.vname( $helper )}->putValidator($vf::$param.vname($helper)(), tmpValue); // thrown RuntimeException
EtchValidatorLong::Get(0, tmpValue);
$vf::${n.vname( $helper )}->putValidator($vf::_mf__inReplyTo(), tmpValue);
+#end ## -- isHidden --
+#end ## -- isMessage --
+#end ## -- $n.isEnumx() || $n.isStruct() || $n.isExcept() || $n.isMessage() --
+#end ## -- foreach --
-#end
-#end
-#end
-#end
+ return ETCH_OK;
}
-void $vf::__ShutDown()
+status_t $vf::InitValueFactory(EtchRuntime* runtime)
{
- $vf::types()->clear();
- delete $vf::types();
- delete $vf::class2type();
-}
+ status_t status;
+ SRuntimesMutex.lock();
+ if (SRuntimes.find(runtime->getId()) != -1) {
+ //runtime is already in list
+ return ETCH_OK;
+ }
-/**
- * Static Initialization-Helper
- */
-bool $vf::INIT = false;
-void $vf::__INIT(EtchRuntime* runtime)
-{
- if(INIT)
- return;
- INIT = true;
- $vf::Init( types(), class2type() );
- $vf::initTypes();
- $vf::initResults();
- $vf::initFields();
+ status = SRuntimes.add(runtime->getId());
+ runtime->registerListener(&S${i}RuntimeListener);
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ if (SRuntimes.size() > 1) {
+ //Valuefactory is already initialized
+ SRuntimesMutex.unlock();
+ return ETCH_OK;
+ }
+ SRuntimesMutex.unlock();
+
+ status = $vf::Init( types(), class2type() );
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = $vf::InitTypes();
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = $vf::InitResults();
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = $vf::InitFields();
+ if (status != ETCH_OK) {
+ return status;
+ }
#foreach( $n in $intf.iterator() )
#if ($n.isExtern())
- ${n.sname( $helper )}.init( ${n.vname($helper)}(), class2type );
+ status = ${n.sname( $helper )}.Init( ${n.vname($helper)}(), class2type );
+ if (status != ETCH_OK) {
+ return status;
+ }
#end
#end
- $vf::initParams();
- $vf::initImportExport();
+ status = $vf::InitParams();
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = $vf::InitImportExport();
+ if (status != ETCH_OK) {
+ return status;
+ }
- Stub${i}<void>::__INIT();
- Stub${i}Server::__INIT();
- Stub${i}Client::__INIT();
+ status = Stub${i}<void>::Init();
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = Stub${i}Server::Init();
+ if (status != ETCH_OK) {
+ return status;
+ }
+
+ status = Stub${i}Client::Init();
+ if (status != ETCH_OK) {
+ return status;
+ }
// done updating types, and class2type: lock them.
types()->lock();
class2type()->lock();
+
+ return ETCH_OK;
+}
+status_t $vf::DestroyValueFactory()
+{
+ $vf::types()->clear();
+ delete $vf::types();
+ delete $vf::class2type();
+ return ETCH_OK;
}
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_h.vm Thu Aug 23 16:48:16 2012
@@ -26,6 +26,8 @@
#ifndef __$helper.getVfName($intf).toUpperCase()_H__
\#define __$helper.getVfName($intf).toUpperCase()_H__
+\#include "capu/os/Mutex.h"
+\#include "capu/container/List.h"
\#include "common/EtchTypes.h"
\#include "serialization/EtchDefaultValueFactory.h"
\#include "support/EtchRuntime.h"
@@ -74,29 +76,44 @@ namespace $namespace {
static EtchTypeMap* types();
static EtchClass2TypeMap* class2type();
- static void initTypes();
- static void initResults();
- static void initFields();
- static void initParams();
+ static status_t InitTypes();
+ static status_t InitResults();
+ static status_t InitFields();
+ static status_t InitParams();
#set( $ctr = 0 )
#foreach( $n in $intf.iterator() )
#if ($n.isEnumx() || $n.isStruct() || $n.isExcept() || $n.isMessage())
#if ($ctr > 0 && $ctr % 100 == 0)
- static void initParams${ctr}();
+ static status_t InitParams${ctr}();
#end
#set( $ctr = $ctr + 1 )
#end
#end
- static void initImportExport();
+ static status_t InitImportExport();
/**
* Static Initialization-Helper
*/
private:
+ /**
+ * Listener which reacts to changes in runtime
+ * Destroys the statically initialized members if the last runtime has been deleted
+ */
+ class Etch${i}RuntimeListener : public EtchRuntimeListener {
+ /**
+ * @see EtchRuntime
+ */
+ status_t onRuntimeChanged(EtchRuntime* runtime);
+ };
+
friend class ${i}Helper;
- static void __ShutDown();
- static bool INIT;
- static void __INIT(EtchRuntime* runtime);
+ friend class Etch${i}RuntimeListener;
+ static status_t InitValueFactory(EtchRuntime* runtime);
+ static status_t DestroyValueFactory();
+ static capu::Mutex SRuntimesMutex;
+ static capu::List<capu::uint64_t> SRuntimes;
+ static Etch${i}RuntimeListener S${i}RuntimeListener;
+
};
}
#endif
Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h Thu Aug 23 16:48:16 2012
@@ -71,6 +71,9 @@ enum EtchObjectTypeIds {
EOTID_STUBHELPER,
EOTID_VALIDATOR_CUSTOM,
EOTID_VALIDATOR_CUSTOM_KEY,
+ EOTID_STACK,
+ EOTID_STACK_CLIENT,
+ EOTID_STACK_SERVER,
EOTID_DYNAMIC_START
};
Modified: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchDefaultValueFactory.h Thu Aug 23 16:48:16 2012
@@ -98,7 +98,7 @@ protected:
public:
- static void Init(EtchTypeMap* types, EtchClass2TypeMap* class2type);
+ static status_t Init(EtchTypeMap* types, EtchClass2TypeMap* class2type);
/**
* The msg field of the standard unchecked exception.
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h Thu Aug 23 16:48:16 2012
@@ -24,6 +24,7 @@
#include "common/EtchTypes.h"
#include "support/EtchDeliveryService.h"
+#include "support/EtchStack.h"
#include "serialization/EtchValueFactory.h"
class EtchRuntime;
@@ -39,7 +40,7 @@ public:
* @param svc the delivery service used to send messages.
* @param vf the value factory used to create messages and encode/decode types.
*/
- EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf);
+ EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf, EtchStack* stack);
/**
* Destructor
@@ -189,6 +190,7 @@ public:
private:
EtchRuntime* mRuntime;
EtchDeliveryService * mSvc;
+ EtchStack* mStack;
EtchValueFactory* mVf;
};
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStack.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStack.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStack.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStack.h Thu Aug 23 16:48:16 2012
@@ -16,11 +16,133 @@
*/
#ifndef ETCHSTACK_H
-#define ETCHSTACK_H
+#define ETCHSTACK_H
-class EtchStack {
+#include "support/EtchStubBase.h"
+#include "transport/EtchTransportData.h"
+#include "transport/EtchTransportPacket.h"
+#include "transport/EtchTransportMessage.h"
+#include "transport/EtchPlainMailboxManager.h"
+#include "transport/EtchDefaultDeliveryService.h"
+#include "serialization/EtchValueFactory.h"
+#include "util/EtchResources.h"
+
+/* *
+ * This class serves as a container for all layers created during the setup of a new stack (connection, packetizer, messagizer, ...).
+ */
+class EtchStack : public EtchObject{
public:
- virtual ~EtchStack() {}
+
+ /**
+ * EtchObjectType for EtchStack.
+ */
+ static const EtchObjectType* TYPE();
+
+ /**
+ * Resource identifier
+ */
+ const static EtchString& STACK();
+
+ /**
+ * Default Constructor
+ */
+ EtchStack();
+
+ /**
+ * Destructor which cleans the whole stack
+ */
+ virtual ~EtchStack();
+
+ /**
+ * sets the transport interface
+ */
+ void setTransportData(EtchTransportData* transportData);
+
+ /**
+ * sets the packet interface
+ */
+ void setTransportPacket(EtchTransportPacket* transportPacket);
+
+ /**
+ * sets the message interface
+ */
+ void setTransportMessage(EtchTransportMessage* transportMessage);
+
+ /**
+ * sets the resources
+ */
+ void setResources(EtchResources* resources);
+
+ /**
+ * sets the value factory
+ */
+ void setValueFactory(EtchValueFactory* valuefactory);
+
+ /**
+ * sets the mailbox manager
+ */
+ void setMailboxManager(EtchMailboxManager* mailboxmanager);
+
+ /**
+ * sets the delivery service
+ */
+ void setDeliveryService(EtchDeliveryService* deliveryservice);
+
+ /**
+ * sets the stub implemenation
+ */
+ void setStub(EtchSessionMessage* stub);
+
+ /**
+ * returns the transport interface
+ */
+ EtchTransportData* getTransportData();
+
+ /**
+ * returns the packet interface
+ */
+ EtchTransportPacket* getTransportPacket();
+
+ /**
+ * returns the message interface
+ */
+ EtchTransportMessage* getTransportMessage();
+
+ /**
+ * returns the resources
+ */
+ EtchResources* getResources();
+
+ /**
+ * returns the value factory
+ */
+ EtchValueFactory* getValueFactory();
+
+ /**
+ * returns the mailbox manager
+ */
+ EtchMailboxManager* getMailboxManager();
+
+ /**
+ * returns the delivery service
+ */
+ EtchDeliveryService* getDeliveryService();
+
+ /**
+ * returns the stub implemenatation
+ */
+ EtchSessionMessage* getStub();
+
+private:
+ EtchTransportData* mTransportData;
+ EtchTransportPacket* mTransportPacket;
+ EtchTransportMessage* mTransportMessage;
+ EtchResources* mResources;
+ EtchValueFactory* mValueFactory;
+ EtchMailboxManager* mMailboxManager;
+ EtchDeliveryService* mDeliveryService;
+ EtchSessionMessage* mStub;
+
};
#endif /* ETCHSTACK_H */
Copied: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h (from r1376587, incubator/etch/trunk/binding-cpp/runtime/include/support/EtchClientStack.h)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h?p2=incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h&p1=incubator/etch/trunk/binding-cpp/runtime/include/support/EtchClientStack.h&r1=1376587&r2=1376588&rev=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchClientStack.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h Thu Aug 23 16:48:16 2012
@@ -15,36 +15,37 @@
* limitations under the License.
*/
-
-#ifndef __ETCHCLIENTSTACK_H__
-#define __ETCHCLIENTSTACK_H__
+#ifndef __ETCHSTACKCLIENT_H__
+#define __ETCHSTACKCLIENT_H__
#include "support/EtchStack.h"
-#include "support/EtchRemoteBase.h"
-#include "transport/EtchSessionMessage.h"
-#include "support/EtchTransportHelper.h"
-
-// TODO: Refactoring of stack lifecycle ETCH-240
+#include "util/EtchResources.h"
-//Entry for EtchRuntime
-class EtchClientStack : public EtchStack {
+/* *
+ * This class serves as a container for all layers created during the setup of a new stack (connection, packetizer, messagizer, ...).
+ */
+class EtchStackClient : public EtchStack {
public:
/**
- * Constructs the EtchClientStack.
+ * EtchObjectType for EtchStackClient.
*/
- EtchClientStack(EtchRemoteBase* rb, EtchSessionMessage *helper, EtchResources *res, EtchValueFactory* vf);
+ static const EtchObjectType* TYPE();
/**
- * Destructor
+ * Default Constructor
*/
- virtual ~EtchClientStack();
+ EtchStackClient();
+
+ /**
+ * Destructor which cleans the whole stack
+ */
+ virtual ~EtchStackClient();
+
+public:
+ EtchResources* mStaticResources;
+
-private:
- EtchValueFactory *mVf;
- EtchRemoteBase *mRemoteBase;
- EtchSessionMessage *mStubHelper;
- EtchResources *mResources;
};
-#endif /* ETCHCLIENTSTACK_H */
+#endif /* __ETCHSTACKCLIENT_H__ */
Propchange: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackClient.h
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h (from r1376587, incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerStack.h)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h?p2=incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h&p1=incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerStack.h&r1=1376587&r2=1376588&rev=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerStack.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h Thu Aug 23 16:48:16 2012
@@ -15,35 +15,48 @@
* limitations under the License.
*/
-#ifndef __ETCHSERVERSTACK_H__
-#define __ETCHSERVERSTACK_H__
+#ifndef __ETCHSTACKSERVER_H__
+#define __ETCHSTACKSERVER_H__
-#include "support/EtchStack.h"
#include "support/EtchRemoteBase.h"
-#include "transport/EtchSessionMessage.h"
-#include "support/EtchTransportHelper.h"
-// TODO: Refactoring of stack lifecycle ETCH-240
-
-//Entry for EtchRuntime
-class EtchServerStack : public EtchStack {
+/* *
+ * This class serves as a container for all layers created during the setup of a new stack (connection, packetizer, messagizer, ...).
+ */
+class EtchStackServer : public EtchStack{
public:
/**
- * Constructs the EtchClientStack.
+ * EtchObjectType for EtchStackServer.
+ */
+ static const EtchObjectType* TYPE();
+
+ /**
+ * Default Constructor
*/
- EtchServerStack(EtchRemoteBase* rb, EtchSessionMessage *helper, EtchResources *res, EtchValueFactory* vf);
+ EtchStackServer();
/**
- * Destructor
+ * Destructor which cleans the whole stack
*/
- virtual ~EtchServerStack();
+ virtual ~EtchStackServer();
+
+
+ /**
+ * sets the remote implementation
+ */
+ void setRemote(EtchRemoteBase* remote);
+
+ /**
+ * returns the remote implementation
+ */
+ EtchRemoteBase* getRemote();
private:
- EtchValueFactory *mVf;
- EtchRemoteBase *mRemoteBase;
- EtchSessionMessage *mStubHelper;
- EtchResources *mResources;
+ EtchRemoteBase* mRemote;
+
+
+
};
-#endif /* ETCHSERVERSTACK_H */
+#endif /* __ETCHSTACKSERVER_H__ */
Propchange: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStackServer.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStubBase.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStubBase.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStubBase.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchStubBase.h Thu Aug 23 16:48:16 2012
@@ -34,7 +34,7 @@
template<typename T>
class EtchStubBase : public EtchSessionMessage {
public:
- template <typename Class>
+ template <typename U>
friend class EtchStubPoolRunnable;
/**
@@ -84,7 +84,7 @@ protected:
T* mObj;
};
-template<typename T>
+template<typename U>
class EtchStubPoolRunnable : public EtchPoolRunnable {
public:
@@ -97,7 +97,7 @@ public:
* @param msg the message.
* @param helper the StubHelper which will dispatch the message.
*/
- EtchStubPoolRunnable(EtchStubBase<T>* stub, capu::SmartPointer<EtchWho> sender, capu::SmartPointer<EtchMessage> msg, EtchStubHelper<T>* helper)
+ EtchStubPoolRunnable(EtchStubBase<U>* stub, capu::SmartPointer<EtchWho> sender, capu::SmartPointer<EtchMessage> msg, EtchStubHelper<U>* helper)
: mStub(stub)
, mSender(sender)
, mMsg(msg)
@@ -118,10 +118,10 @@ public:
}
private:
- EtchStubBase<T>* mStub;
+ EtchStubBase<U>* mStub;
capu::SmartPointer<EtchWho> mSender;
capu::SmartPointer<EtchMessage> mMsg;
- EtchStubHelper<T>* mHelper;
+ EtchStubHelper<U>* mHelper;
};
template<typename T>
@@ -133,7 +133,6 @@ EtchStubBase<T>::EtchStubBase(EtchDelive
template<typename T>
EtchStubBase<T>::~EtchStubBase() {
delete mObj;
- delete mSvc;
}
template<typename T>
@@ -190,4 +189,4 @@ status_t EtchStubBase<T>::sessionQuery(c
return ETCH_EUNIMPL;
}
-#endif
+#endif /* __ETCHSTUBBASE_H__ */
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchConnection.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchConnection.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchConnection.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchConnection.h Thu Aug 23 16:48:16 2012
@@ -168,7 +168,7 @@ status_t EtchConnection<S>::fireUp() {
if (mSession != NULL) {
//TODO: run this in seperate thread
- mMutex.unlock();
+ mMutex.unlock();
return mSession->sessionNotify(new EtchString(EtchSession::UP()));
}
mMutex.unlock();
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h Thu Aug 23 16:48:16 2012
@@ -103,13 +103,6 @@ protected:
*/
virtual status_t readSocket();
-private:
- EtchRuntime* mRuntime;
- EtchServerSocket* mSocket;
- capu::uint16_t mPort;
- capu::uint8_t mBackLog;
-
-
public:
/**
* Query term for URI to specify backlog value to ServerSocket. The value
@@ -122,6 +115,40 @@ public:
* @see #TcpListener(String, Resources)
*/
const static EtchString& BACKLOG();
+
+ const static EtchString& CONNECTION_CHECK();
+
+private:
+ class ConnectionChecker : public capu::Runnable {
+ public:
+ /**
+ * Constructor
+ * @param instance of TcpListener
+ */
+ ConnectionChecker(EtchTcpListener* listener);
+
+ /**
+ * Destructor
+ */
+ virtual ~ConnectionChecker();
+
+ /**
+ * @see Runnable
+ */
+ void run();
+ private:
+ EtchTcpListener *mListener;
+ };
+
+ friend class ConnectionChecker;
+
+ EtchRuntime* mRuntime;
+ EtchServerSocket* mSocket;
+ capu::uint16_t mPort;
+ capu::uint8_t mBackLog;
+ capu::Thread* mConnectionCheckerThread;
+ ConnectionChecker* mConnectionChecker;
+
};
#endif /* ETCHTCPLISTENER_H */
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h Thu Aug 23 16:48:16 2012
@@ -23,6 +23,7 @@
#include "common/EtchString.h"
#include "common/EtchConfig.h"
#include "support/EtchServerFactory.h"
+#include "support/EtchStack.h"
#include "transport/EtchTransportMessage.h"
#include "transport/EtchTransportData.h"
#include "transport/EtchTcpConnection.h"
@@ -38,6 +39,7 @@ class EtchTcpTransportFactory
: public EtchTransportFactory {
public:
+ friend class MySessionListener;
/**
* Constructor
* @param runtime
@@ -81,7 +83,7 @@ private:
* @param uri
* @param resources
*/
- MySessionListener(EtchRuntime* runtime, EtchTransport<EtchSessionListener<EtchSocket> > *transport,
+ MySessionListener(EtchRuntime* runtime, EtchTcpTransportFactory* factory, EtchTransport<EtchSessionListener<EtchSocket> > *transport,
EtchString uri, EtchResources* resources, capu::bool_t secure);
/**
@@ -141,6 +143,8 @@ private:
EtchServerFactory* mSession;
EtchRuntime* mRuntime;
capu::bool_t mIsSecure;
+ capu::List<EtchStack*>* mConnectionStacks;
+ EtchTcpTransportFactory* mFactory;
};
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/arch/Windows/ServerSocket.inc
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/arch/Windows/ServerSocket.inc?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/arch/Windows/ServerSocket.inc (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/arch/Windows/ServerSocket.inc Thu Aug 23 16:48:16 2012
@@ -60,7 +60,11 @@ inline ServerSocket::~ServerSocket()
inline Socket* ServerSocket::accept()
{
- Socket *clientSocket = new Socket(::accept(mServerSocket, NULL, NULL));
+ SOCKET handle = ::accept(mServerSocket, NULL, NULL);
+ if (handle == INVALID_SOCKET) {
+ return NULL;
+ }
+ Socket *clientSocket = new Socket(handle);
return clientSocket;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt Thu Aug 23 16:48:16 2012
@@ -58,7 +58,7 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/transport/EtchTransportData.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTransportMessage.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTransportPacket.h
- ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportFactory.h
+ ${PROJECT_SOURCE_DIR}/include/transport/EtchTransportFactory.h
${PROJECT_SOURCE_DIR}/include/transport/EtchMessagizer.h
${PROJECT_SOURCE_DIR}/include/transport/EtchFormat.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTcpTransportFactory.h
@@ -127,7 +127,7 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/support/EtchPoolRunnable.h
${PROJECT_SOURCE_DIR}/include/support/EtchFreePool.h
${PROJECT_SOURCE_DIR}/include/support/EtchQueuedPool.h
- ${PROJECT_SOURCE_DIR}/include/support/EtchRemoteBase.h
+ ${PROJECT_SOURCE_DIR}/include/support/EtchRemoteBase.h
${PROJECT_SOURCE_DIR}/include/support/EtchServerFactory.h
${PROJECT_SOURCE_DIR}/include/support/EtchStubHelper.h
${PROJECT_SOURCE_DIR}/include/support/EtchStubBase.h
@@ -135,9 +135,9 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/support/EtchPlainMailbox.h
${PROJECT_SOURCE_DIR}/include/support/EtchMonitor.h
${PROJECT_SOURCE_DIR}/include/support/EtchStack.h
+ ${PROJECT_SOURCE_DIR}/include/support/EtchStackClient.h
+ ${PROJECT_SOURCE_DIR}/include/support/EtchStackServer.h
${PROJECT_SOURCE_DIR}/include/support/EtchRuntime.h
- ${PROJECT_SOURCE_DIR}/include/support/EtchServerStack.h
- ${PROJECT_SOURCE_DIR}/include/support/EtchClientStack.h
${PROJECT_SOURCE_DIR}/include/util/EtchUtil.h
${PROJECT_SOURCE_DIR}/include/util/EtchCircularQueue.h
${PROJECT_SOURCE_DIR}/include/util/EtchIdGenerator.h
@@ -223,8 +223,9 @@ SET(MAIN_SOURCES
support/EtchTransportHelper.cpp
support/EtchMonitor.cpp
support/EtchRuntime.cpp
- support/EtchServerStack.cpp
- support/EtchClientStack.cpp
+ support/EtchStack.cpp
+ support/EtchStackClient.cpp
+ support/EtchStackServer.cpp
support/EtchAsyncResultNone.cpp
util/EtchCircularQueue.cpp
util/EtchUtil.cpp
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchAuthenticationExceptionSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchAuthenticationExceptionSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchAuthenticationExceptionSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchAuthenticationExceptionSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -71,21 +71,34 @@ status_t EtchAuthenticationExceptionSeri
EtchRuntime* runtime = EtchRuntime::getRuntime();
status_t result;
- EtchField field_ptr;
- result = type->getField(FIELD_NAME(), &field_ptr);
- if (result != ETCH_OK)
+
+ EtchField field;
+ result = type->getField(FIELD_NAME(), &field);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
+ result = class2type->put(EtchAuthenticationException::TYPE(), type);
+ if (result != ETCH_OK) {
return result;
- class2type->put(EtchAuthenticationException::TYPE(), type);
+ }
+
type->setComponentType(EtchAuthenticationException::TYPE());
+
//set the import export helper
- type->setImportExportHelper(new EtchAuthenticationExceptionSerializer(type, &field_ptr));
+ type->setImportExportHelper(new EtchAuthenticationExceptionSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> tmp;
result = EtchValidatorString::Get(0, tmp);
- if (result != ETCH_OK)
+ if (result != ETCH_OK) {
return result;
- result = type->putValidator(field_ptr, tmp);
- if (result != ETCH_OK)
+ }
+ result = type->putValidator(field, tmp);
+ if (result != ETCH_OK) {
return result;
+ }
+
type->lock();
CAPU_LOG_TRACE(runtime->getLogger(), TAG, "EtchAuthenticationExceptionSerializer has been initialized");
return ETCH_OK;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchClass2TypeMap.cpp Thu Aug 23 16:48:16 2012
@@ -39,9 +39,6 @@ status_t EtchClass2TypeMap::put(const Et
EtchType* tmp = NULL;
if (mC2T.get(classType, &tmp) == ETCH_OK) {
- if (!tmp->equals(type)) {
- return ETCH_ERANGE;
- }
return ETCH_OK;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDateSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDateSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDateSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDateSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -72,22 +72,34 @@ status_t EtchDateSerializer::Init(EtchTy
EtchRuntime* runtime = EtchRuntime::getRuntime();
status_t result;
- EtchField field_ptr;
- result = type->getField(FIELD_NAME(), &field_ptr);
- if (result != ETCH_OK)
+
+ EtchField field;
+ result = type->getField(FIELD_NAME(), &field);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
+ result = class2type->put(EtchDate::TYPE(), type);
+ if (result != ETCH_OK) {
return result;
- class2type->put(EtchDate::TYPE(), type);
+ }
+
type->setComponentType(EtchDate::TYPE());
//set the import export helper
- type->setImportExportHelper(new EtchDateSerializer(type, &field_ptr));
+ type->setImportExportHelper(new EtchDateSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> val;
result = EtchValidatorLong::Get(0, val);
- if (result != ETCH_OK)
+ if (result != ETCH_OK) {
return result;
- result = type->putValidator(field_ptr, val);
- if (result != ETCH_OK)
+ }
+ result = type->putValidator(field, val);
+ if (result != ETCH_OK) {
return result;
+ }
+
type->lock();
CAPU_LOG_TRACE(runtime->getLogger(), TAG, "EtchDateSerializer has been initialized");
return ETCH_OK;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp Thu Aug 23 16:48:16 2012
@@ -131,36 +131,39 @@ EtchDefaultValueFactory::~EtchDefaultVal
delete mDynamicTypes;
}
-void EtchDefaultValueFactory::Init(EtchTypeMap* types, EtchClass2TypeMap* class2type) {
+status_t EtchDefaultValueFactory::Init(EtchTypeMap* types, EtchClass2TypeMap* class2type) {
+ status_t result;
EtchType *type;
- types->get(ETCH_RUNTIME_EXCEPTION_TYPE_NAME(), type);
- EtchRuntimeExceptionSerializer::Init(type, class2type);
+ result = types->get(ETCH_RUNTIME_EXCEPTION_TYPE_NAME(), type);
+ result = EtchRuntimeExceptionSerializer::Init(type, class2type);
- types->get(ETCH_LIST_TYPE_NAME(), type);
- EtchListSerializer::Init(type, class2type);
+ result = types->get(ETCH_LIST_TYPE_NAME(), type);
+ result = EtchListSerializer::Init(type, class2type);
- types->get(ETCH_MAP_TYPE_NAME(), type);
- EtchHashTableSerializer::Init(type, class2type);
+ result = types->get(ETCH_MAP_TYPE_NAME(), type);
+ result = EtchHashTableSerializer::Init(type, class2type);
- types->get(ETCH_SET_TYPE_NAME(), type);
- EtchSetSerializer::Init(type, class2type);
+ result = types->get(ETCH_SET_TYPE_NAME(), type);
+ result = EtchSetSerializer::Init(type, class2type);
- types->get(ETCH_DATETIME_TYPE_NAME(), type);
- EtchDateSerializer::Init(type, class2type);
+ result = types->get(ETCH_DATETIME_TYPE_NAME(), type);
+ result = EtchDateSerializer::Init(type, class2type);
- types->get(ETCH_AUTH_EXCEPTION_TYPE_NAME(), type);
- EtchAuthenticationExceptionSerializer::Init(type, class2type);
+ result = types->get(ETCH_AUTH_EXCEPTION_TYPE_NAME(), type);
+ result = EtchAuthenticationExceptionSerializer::Init(type, class2type);
{
- types->get(ETCH_EXCEPTION_MESSAGE_NAME(), type);
+ result = types->get(ETCH_EXCEPTION_MESSAGE_NAME(), type);
capu::SmartPointer<EtchValidator> val;
EtchValidatorRuntimeException::Get(val);
- type->putValidator(_mf_result(), val);
+ result = type->putValidator(_mf_result(), val);
EtchValidatorLong::Get(0, val);
- type->putValidator(_mf__messageId(), val);
- type->putValidator(_mf__inReplyTo(), val);
+ result = type->putValidator(_mf__messageId(), val);
+ result = type->putValidator(_mf__inReplyTo(), val);
}
+
+ return ETCH_OK;
}
const EtchType * EtchDefaultValueFactory::get_mt__Etch_RuntimeException() {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchHashTableSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchHashTableSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchHashTableSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchHashTableSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -103,21 +103,34 @@ status_t EtchHashTableSerializer::Init(E
EtchRuntime* runtime = EtchRuntime::getRuntime();
status_t result;
- EtchField field_ptr;
- result = type->getField(FIELD_NAME(), &field_ptr);
- if (result != ETCH_OK)
+
+ EtchField field;
+ result = type->getField(FIELD_NAME(), &field);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
+ result = class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ if (result != ETCH_OK) {
return result;
- class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ }
+
type->setComponentType(EtchHashTable<capu::SmartPointer<EtchObject>, capu::SmartPointer<EtchObject> >::TYPE());
+
//set the import export helper
- type->setImportExportHelper(new EtchHashTableSerializer(type, &field_ptr));
+ type->setImportExportHelper(new EtchHashTableSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> tmp;
result = EtchValidatorObject::Get(1, tmp);
- if (result != ETCH_OK)
+ if (result != ETCH_OK) {
return result;
- result = type->putValidator(field_ptr, tmp);
- if (result != ETCH_OK)
+ }
+ result = type->putValidator(field, tmp);
+ if (result != ETCH_OK) {
return result;
+ }
+
type->lock();
CAPU_LOG_TRACE(runtime->getLogger(), TAG, "EtchHashTableSerializer has been initialized");
return ETCH_OK;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchListSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -104,11 +104,18 @@ status_t EtchListSerializer::Init(EtchTy
return result;
}
- class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ result = class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
type->setComponentType(EtchList<capu::SmartPointer<EtchObject> >::TYPE());
+
//set the import export helper
// TODO memory EtchField
type->setImportExportHelper(new EtchListSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> validator;
result = EtchValidatorObject::Get(1, validator);
if (result != ETCH_OK) {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchRuntimeExceptionSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchRuntimeExceptionSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchRuntimeExceptionSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchRuntimeExceptionSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -76,21 +76,35 @@ status_t EtchRuntimeExceptionSerializer:
EtchRuntime* runtime = EtchRuntime::getRuntime();
status_t result;
- EtchField field_ptr;
- result = type->getField(FIELD_NAME(), &field_ptr);
- if (result != ETCH_OK)
+
+ EtchField field;
+ result = type->getField(FIELD_NAME(), &field);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
+ result = class2type->put(EtchRuntimeException::TYPE(), type);
+ if (result != ETCH_OK) {
return result;
- class2type->put(EtchRuntimeException::TYPE(), type);
+ }
+
type->setComponentType(EtchRuntimeException::TYPE());
+
//set the import export helper
- type->setImportExportHelper(new EtchRuntimeExceptionSerializer(type, &field_ptr));
+ type->setImportExportHelper(new EtchRuntimeExceptionSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> tmp;
result = EtchValidatorString::Get(0, tmp);
- if (result != ETCH_OK)
+ if (result != ETCH_OK) {
return result;
- result = type->putValidator(field_ptr, tmp);
- if (result != ETCH_OK)
+ }
+ result = type->putValidator(field, tmp);
+ if (result != ETCH_OK) {
return result;
+ }
+
+ //lock type
type->lock();
CAPU_LOG_TRACE(runtime->getLogger(), TAG, "EtchRuntimeExceptionSerializer has been initialized");
return ETCH_OK;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchSetSerializer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchSetSerializer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchSetSerializer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchSetSerializer.cpp Thu Aug 23 16:48:16 2012
@@ -94,21 +94,34 @@ status_t EtchSetSerializer::Init(EtchTyp
EtchRuntime* runtime = EtchRuntime::getRuntime();
status_t result;
- EtchField field_ptr;
- result = type->getField(FIELD_NAME(), &field_ptr);
- if (result != ETCH_OK)
+
+ EtchField field;
+ result = type->getField(FIELD_NAME(), &field);
+ if (result != ETCH_OK) {
+ return result;
+ }
+
+ result = class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ if (result != ETCH_OK) {
return result;
- class2type->put(EtchNativeArray<capu::SmartPointer<EtchObject> >::TYPE(), type);
+ }
+
type->setComponentType(EtchHashSet<capu::SmartPointer<EtchObject> >::TYPE());
+
//set the import export helper
- type->setImportExportHelper(new EtchSetSerializer(type, &field_ptr));
+ type->setImportExportHelper(new EtchSetSerializer(type, &field));
+
+ //get validator
capu::SmartPointer<EtchValidator> tmp;
result = EtchValidatorObject::Get(1, tmp);
- if (result != ETCH_OK)
+ if (result != ETCH_OK) {
return result;
- result = type->putValidator(field_ptr, tmp);
- if (result != ETCH_OK)
+ }
+ result = type->putValidator(field, tmp);
+ if (result != ETCH_OK) {
return result;
+ }
+
type->lock();
CAPU_LOG_TRACE(runtime->getLogger(), TAG, "EtchSetSerializer has been initialized");
return ETCH_OK;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchTypeMap.cpp Thu Aug 23 16:48:16 2012
@@ -24,6 +24,14 @@ EtchTypeMap::EtchTypeMap()
}
EtchTypeMap::~EtchTypeMap() {
+ EtchHashTable<capu::int32_t, EtchType*, capu::Hash, capu::Comparator >::Iterator it = mById.begin();
+ while (it.hasNext()) {
+ capu::Pair<capu::int32_t, EtchType*> pair;
+ it.next(&pair);
+ delete pair.second;
+ }
+ mById.clear();
+ mByName.clear();
}
status_t EtchTypeMap::add(EtchType *type) {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp Thu Aug 23 16:48:16 2012
@@ -20,16 +20,22 @@
#include "transport/EtchTransportData.h"
#include "support/EtchRuntime.h"
#include "util/EtchLogger.h"
+#include "support/EtchStackClient.h"
static char* TAG = "EtchRemoteBase";
-EtchRemoteBase::EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf)
- : mSvc(svc), mVf(vf) {
+EtchRemoteBase::EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf, EtchStack* stack)
+ : mSvc(svc), mVf(vf), mStack(stack) {
//TODO refactor this
mRuntime = EtchRuntime::getRuntime();
}
EtchRemoteBase::~EtchRemoteBase() {
+ if (mStack != NULL) {
+ if (mStack->isInstanceOf(EtchStackClient::TYPE())) {
+ delete mStack;
+ }
+ }
}
status_t EtchRemoteBase::newMessage( EtchType* type, capu::SmartPointer<EtchMessage> *message) {
Added: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp?rev=1376588&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp Thu Aug 23 16:48:16 2012
@@ -0,0 +1,134 @@
+/* $Id$
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "support/EtchStack.h"
+#include "support/EtchTransportHelper.h"
+
+const EtchObjectType* EtchStack::TYPE() {
+ const static EtchObjectType TYPE(EOTID_STACK, NULL);
+ return &TYPE;
+}
+
+const EtchString& EtchStack::STACK() {
+ static const EtchString cmd("STACK");
+ return cmd;
+}
+
+EtchStack::EtchStack() : EtchObject()
+ , mTransportData(NULL)
+ , mTransportPacket(NULL)
+ , mTransportMessage(NULL)
+ , mResources(NULL)
+ , mMailboxManager(NULL)
+ , mDeliveryService(NULL)
+ , mStub(NULL)
+ {
+ EtchObject::addObjectType(EtchStack::TYPE());
+}
+
+EtchStack::~EtchStack() {
+ if (mTransportMessage != NULL) {
+ delete mTransportMessage;
+ }
+ if (mTransportPacket != NULL) {
+ delete mTransportPacket;
+ }
+ if (mTransportData != NULL) {
+ delete mTransportData;
+ }
+ if (mResources != NULL) {
+ delete mResources;
+ }
+ if (mValueFactory != NULL) {
+ delete mValueFactory;
+ }
+ if (mMailboxManager != NULL) {
+ delete mMailboxManager;
+ }
+ if (mDeliveryService != NULL) {
+ delete mDeliveryService;
+ }
+
+ if (mStub != NULL) {
+ delete mStub;
+ }
+}
+
+void EtchStack::setTransportData(EtchTransportData* transportData) {
+ mTransportData = transportData;
+}
+
+void EtchStack::setTransportPacket(EtchTransportPacket* transportPacket) {
+ mTransportPacket = transportPacket;
+}
+
+void EtchStack::setTransportMessage(EtchTransportMessage* transportMessage) {
+ mTransportMessage = transportMessage;
+}
+
+void EtchStack::setResources(EtchResources* resources) {
+ mResources = resources;
+}
+
+void EtchStack::setValueFactory(EtchValueFactory* valuefactory) {
+ mValueFactory = valuefactory;
+}
+
+void EtchStack::setMailboxManager(EtchMailboxManager* mailboxmanager) {
+ mMailboxManager = mailboxmanager;
+}
+
+void EtchStack::setDeliveryService(EtchDeliveryService* deliveryservice) {
+ mDeliveryService = deliveryservice;
+}
+
+void EtchStack::setStub(EtchSessionMessage* stub) {
+ mStub = stub;
+}
+
+EtchTransportData* EtchStack::getTransportData() {
+ return mTransportData;
+}
+
+EtchTransportPacket* EtchStack::getTransportPacket() {
+ return mTransportPacket;
+}
+
+EtchTransportMessage* EtchStack::getTransportMessage() {
+ return mTransportMessage;
+}
+
+EtchResources* EtchStack::getResources() {
+ return mResources;
+}
+
+EtchValueFactory* EtchStack::getValueFactory() {
+ return mValueFactory;
+}
+
+EtchMailboxManager* EtchStack::getMailboxManager() {
+ return mMailboxManager;
+}
+
+EtchDeliveryService* EtchStack::getDeliveryService() {
+ return mDeliveryService;
+}
+
+EtchSessionMessage* EtchStack::getStub() {
+ return mStub;
+}
+
Propchange: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStack.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp (from r1376587, incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp?p2=incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp&p1=incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp&r1=1376587&r2=1376588&rev=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchClientStack.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp Thu Aug 23 16:48:16 2012
@@ -15,22 +15,22 @@
* limitations under the License.
*/
-#include "support/EtchClientStack.h"
+#include "support/EtchStackClient.h"
+#include "support/EtchTransportHelper.h"
-EtchClientStack::EtchClientStack(EtchRemoteBase* rb, EtchSessionMessage *helper, EtchResources *res, EtchValueFactory* vf)
-: mRemoteBase(rb), mStubHelper(helper),mResources(res), mVf(vf) {
+const EtchObjectType* EtchStackClient::TYPE() {
+ const static EtchObjectType TYPE(EOTID_STACK_CLIENT, NULL);
+ return &TYPE;
}
-EtchClientStack::~EtchClientStack() {
- status_t status;
- status = EtchTransportHelper::DestroyResources(mResources);
- if(status != ETCH_OK) {
- // Log error
- }
- if(mStubHelper != NULL) {
- delete mStubHelper;
- }
- if(mVf != NULL) {
- delete mVf;
+EtchStackClient::EtchStackClient() : EtchStack(), mStaticResources(NULL) {
+ EtchObject::addObjectType(EtchStackClient::TYPE());
+ EtchObject::setObjectType(EtchStackClient::TYPE());
+}
+
+EtchStackClient::~EtchStackClient() {
+ if (mStaticResources != NULL) {
+ EtchTransportHelper::DestroyResources(mStaticResources);
}
}
+
Propchange: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackClient.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Copied: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp (from r1376587, incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchServerStack.cpp)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp?p2=incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp&p1=incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchServerStack.cpp&r1=1376587&r2=1376588&rev=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchServerStack.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp Thu Aug 23 16:48:16 2012
@@ -15,15 +15,31 @@
* limitations under the License.
*/
-#include "support/EtchServerStack.h"
+#include "support/EtchStackServer.h"
-EtchServerStack::EtchServerStack(EtchRemoteBase* rb, EtchSessionMessage *helper, EtchResources *res, EtchValueFactory* vf)
-: mRemoteBase(rb), mStubHelper(helper),mResources(res), mVf(vf) {
+const EtchObjectType* EtchStackServer::TYPE() {
+ const static EtchObjectType TYPE(EOTID_STACK_SERVER, NULL);
+ return &TYPE;
}
-EtchServerStack::~EtchServerStack() {
- delete mResources;
- delete mRemoteBase;
- delete mStubHelper;
- delete mVf;
+EtchStackServer::EtchStackServer()
+: EtchStack()
+ , mRemote(NULL)
+{
+ EtchObject::addObjectType(EtchStackServer::TYPE());
+ EtchObject::setObjectType(EtchStackServer::TYPE());
+}
+
+EtchStackServer::~EtchStackServer() {
+ if (mRemote != NULL) {
+ delete mRemote;
+ }
+}
+
+void EtchStackServer::setRemote(EtchRemoteBase* remote) {
+ mRemote = remote;
+}
+
+EtchRemoteBase* EtchStackServer::getRemote() {
+ return mRemote;
}
Propchange: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchStackServer.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp Thu Aug 23 16:48:16 2012
@@ -67,9 +67,7 @@ void EtchDefaultDeliveryService::init(Et
}
EtchDefaultDeliveryService::~EtchDefaultDeliveryService() {
- if(mTransport != NULL) {
- delete mTransport;
- }
+
}
const EtchMailboxManager* EtchDefaultDeliveryService::getTransport() {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp Thu Aug 23 16:48:16 2012
@@ -51,8 +51,6 @@ EtchMessagizer::EtchMessagizer(EtchTrans
}
EtchMessagizer::~EtchMessagizer() {
- if(mTransport != NULL)
- delete mTransport;
if (mTdi != NULL)
delete mTdi;
if (mTdo != NULL)
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp Thu Aug 23 16:48:16 2012
@@ -85,8 +85,7 @@ EtchPacketizer::EtchPacketizer(EtchTrans
}
EtchPacketizer::~EtchPacketizer() {
- if (mTransport != NULL)
- delete mTransport;
+
}
capu::int32_t EtchPacketizer::getHeaderSize() {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp Thu Aug 23 16:48:16 2012
@@ -36,7 +36,6 @@ EtchPlainMailboxManager::~EtchPlainMailb
p.second->closeDelivery();
delete p.second;
}
- delete mTransport;
}
EtchTransportMessage* EtchPlainMailboxManager::getTransport() {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp Thu Aug 23 16:48:16 2012
@@ -122,7 +122,9 @@ status_t EtchTcpConnection::openSocket(c
}
}
// try to open a socket.
- mSocket = new EtchSocket();
+ if (mSocket == NULL) {
+ mSocket = new EtchSocket();
+ }
if (mSocket->connect((unsigned char *) mHost.c_str(), mPort) == ETCH_OK) {
mMutexConnection.unlock();
CAPU_LOG_TRACE(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Connection established", mHost.c_str(), mPort);
@@ -131,6 +133,7 @@ status_t EtchTcpConnection::openSocket(c
mSocket->close();
delete mSocket;
mSocket = NULL;
+ first = false;
}
CAPU_LOG_WARN(mRuntime->getLogger(), "EtchTcpConnection", "%s : %d => Connection could not be established for stack %d", mHost.c_str(), mPort);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp Thu Aug 23 16:48:16 2012
@@ -21,11 +21,33 @@
+EtchTcpListener::ConnectionChecker::ConnectionChecker(EtchTcpListener* listener) : mListener(listener){ }
+
+EtchTcpListener::ConnectionChecker::~ConnectionChecker() {}
+
+void EtchTcpListener::ConnectionChecker::run() {
+ status_t result;
+ while (mListener->mIsStarted) {
+ if (mListener->mSession != NULL) {
+ result = mListener->mSession->sessionNotify(new EtchString(EtchTcpListener::CONNECTION_CHECK()));
+ if (result != ETCH_OK) {
+ //TODO handle error
+ }
+ capu::Thread::Sleep(1000);
+ }
+ }
+}
+
const EtchString& EtchTcpListener::BACKLOG() {
static const EtchString name("TcpTransportFactory.socket");
return name;
}
+const EtchString& EtchTcpListener::CONNECTION_CHECK() {
+ static const EtchString name("connection.check");
+ return name;
+}
+
EtchTcpListener::EtchTcpListener(EtchURL *url)
: mPort(url->getPort()) {
//TODO rafactor this
@@ -45,6 +67,8 @@ EtchTcpListener::EtchTcpListener(EtchURL
mIsStarted = false;
mThread = NULL;
mSocket = NULL;
+ mConnectionCheckerThread = NULL;
+ mConnectionChecker = NULL;
}
EtchTcpListener::~EtchTcpListener() {
@@ -52,12 +76,18 @@ EtchTcpListener::~EtchTcpListener() {
mThread->join();
delete mThread;
}
+ if (mConnectionCheckerThread != NULL) {
+ mConnectionCheckerThread->join();
+ delete mConnectionCheckerThread;
+ }
if (mSocket != NULL) {
mSocket->close();
delete mSocket;
mSocket = NULL;
}
+ delete mConnectionChecker;
+
}
capu::bool_t EtchTcpListener::isStarted() {
@@ -65,8 +95,9 @@ capu::bool_t EtchTcpListener::isStarted(
}
status_t EtchTcpListener::close() {
- if (mSocket != NULL)
+ if (mSocket != NULL) {
return mSocket->close();
+ }
return ETCH_ERROR;
}
@@ -74,18 +105,19 @@ status_t EtchTcpListener::openSocket(cap
// if a one time connection from a server socket listener, just
// return the existing socket.
mMutexConnection.lock();
- if (!reconnect && (mSocket != NULL)) {
+ if (reconnect && (mSocket != NULL)) {
mMutexConnection.unlock();
return ETCH_OK;
}
- while (isStarted()) {
+ while (mIsStarted) {
// if reconnect is false and first is true, this is our
// very first attempt to connect. otherwise, we are trying
// to reconnect a broken link or establish a link where we
// have already failed at least once.
// try to open a socket.
-
- mSocket = new EtchServerSocket();
+ if (mSocket == NULL) {
+ mSocket = new EtchServerSocket();
+ }
if (mSocket->bind(mPort) == ETCH_OK) {
if (mSocket->listen(mBackLog) == ETCH_OK) {
mMutexConnection.unlock();
@@ -97,7 +129,6 @@ status_t EtchTcpListener::openSocket(cap
CAPU_LOG_ERROR(mRuntime->getLogger(), "EtchTcpListener", "Listening on specified port has failed");
}
} else {
- mSocket->close();
delete mSocket;
mSocket = NULL;
CAPU_LOG_ERROR(mRuntime->getLogger(), "EtchTcpListener", "Binding to specified port has failed");
@@ -110,7 +141,7 @@ status_t EtchTcpListener::openSocket(cap
status_t EtchTcpListener::readSocket() {
EtchSocket* s = NULL;
- while (isStarted()) {
+ while (mIsStarted) {
s = mSocket->accept();
if (s == NULL)
break;
@@ -136,8 +167,11 @@ status_t EtchTcpListener::transportContr
mIsStarted = true;
mMutex.unlock();
mThread = new capu::Thread(this);
+ mConnectionChecker = new ConnectionChecker(this);
+ mConnectionCheckerThread = new capu::Thread(mConnectionChecker);
mThread->start();
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpListener", "Start command received and EtchTcpListener starts listening on port %d", mPort);
+ mConnectionCheckerThread->start();
return ETCH_OK;
}
@@ -150,8 +184,11 @@ status_t EtchTcpListener::transportContr
mIsStarted = true;
mMutex.unlock();
mThread = new capu::Thread(this);
+ mConnectionChecker = new ConnectionChecker(this);
+ mConnectionCheckerThread = new capu::Thread(mConnectionChecker);
mThread->start();
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpListener", "Start and wait up command received and EtchTcpListener starts listening on port %d", mPort);
+ mConnectionCheckerThread->start();
return waitUp(((EtchInt32*) value.get())->get());
}
@@ -175,10 +212,9 @@ status_t EtchTcpListener::transportContr
mMutex.lock();
mIsStarted = false;
mMutex.unlock();
- status_t ret = waitDown(((EtchInt32*) value.get())->get());
close();
CAPU_LOG_DEBUG(mRuntime->getLogger(), "EtchTcpListener", "Stop and wait command received and EtchTcpListener sets the stop flag");
- //TODO: Wait handling in one of the next releases
+ status_t ret = waitDown(((EtchInt32*) value.get())->get());
return ret;
}
@@ -223,7 +259,7 @@ void EtchTcpListener::run() {
while (mIsStarted) {
- if (openSocket(!first) != ETCH_OK) {
+ if (openSocket(first) != ETCH_OK) {
CAPU_LOG_ERROR(mRuntime->getLogger(), "EtchTcpListener", "Socket has not been created");
break;
}