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 [2/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-...
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp Thu Aug 23 16:48:16 2012
@@ -15,6 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "support/EtchTransportHelper.h"
+#include "support/EtchStackServer.h"
#include "transport/EtchTcpTransportFactory.h"
static const char* TAG = "EtchTcpTransportFactory";
@@ -39,9 +41,20 @@ EtchTcpTransportFactory::~EtchTcpTranspo
}
status_t EtchTcpTransportFactory::newTransport(EtchString uri, EtchResources* resources, EtchTransportMessage*& result) {
+ status_t status;
+
+ if (resources == NULL) {
+ return ETCH_ERROR;
+ }
+
+ EtchStack* stack = NULL;
+ status = resources->get(EtchStack::STACK(), (EtchObject*&)stack);
+ if (status != ETCH_OK) {
+ return status;
+ }
+
EtchURL u(uri);
- status_t status;
EtchObject* socket = NULL;
status = resources->get(SOCKET(), socket);
@@ -54,22 +67,20 @@ status_t EtchTcpTransportFactory::newTra
// TODO add runtime
c = new EtchTcpConnection(NULL, (EtchSocket*) socket, &u);
}
+ stack->setTransportData(c);
EtchTransportPacket* p = new EtchPacketizer(c, &u);
+ stack->setTransportPacket(p);
EtchTransportMessage* m = new EtchMessagizer(p, &u, resources);
+ stack->setTransportMessage(m);
//TODO: ADD FILTERS HERE
EtchObject* obj = NULL;
if (resources->get(EtchTransport<EtchSocket>::VALUE_FACTORY(), obj) != ETCH_OK) {
- c->setSession(NULL);
- p->setSession(NULL);
- m->setSession(NULL);
- delete c;
- delete p;
- delete m;
+ delete stack;
return ETCH_ENOT_EXIST;
}
EtchValueFactory *vf = (EtchValueFactory*) obj;
@@ -90,18 +101,19 @@ status_t EtchTcpTransportFactory::newLis
l = new EtchTcpListener(&u);
}
- result = new MySessionListener(mRuntime, l, uri, resources, mIsSecure);
+ result = new MySessionListener(mRuntime, this, l, uri, resources, mIsSecure);
if (result == NULL) {
return ETCH_ERROR;
}
return ETCH_OK;
}
-EtchTcpTransportFactory::MySessionListener::MySessionListener(EtchRuntime* runtime, EtchTransport<EtchSessionListener<EtchSocket> > *transport, EtchString uri, EtchResources* resources, capu::bool_t secure)
-: mRuntime(runtime), mTransport(transport), mUri(uri), mResources(resources), mIsSecure(secure) {
+EtchTcpTransportFactory::MySessionListener::MySessionListener(EtchRuntime* runtime, EtchTcpTransportFactory* factory, EtchTransport<EtchSessionListener<EtchSocket> > *transport, EtchString uri, EtchResources* resources, capu::bool_t secure)
+: mRuntime(runtime), mFactory(factory), mTransport(transport), mUri(uri), mResources(resources), mIsSecure(secure) {
if (mTransport != NULL) {
mTransport->setSession(this);
}
+ mConnectionStacks = new capu::List<EtchStack*>();
}
EtchServerFactory* EtchTcpTransportFactory::MySessionListener::getSession() {
@@ -112,6 +124,22 @@ EtchTcpTransportFactory::MySessionListen
if(mTransport != NULL) {
delete mTransport;
}
+ if(mFactory != NULL) {
+ delete mFactory;
+ }
+ if (mResources != NULL) {
+ EtchTransportHelper::DestroyResources(mResources);
+ }
+
+ capu::List<EtchStack*>::Iterator it = mConnectionStacks->begin();
+ while (it.hasNext()) {
+ EtchStack* st = NULL;
+ it.next(&st);
+ if (st != NULL) {
+ delete st;
+ }
+ }
+ delete mConnectionStacks;
}
void EtchTcpTransportFactory::MySessionListener::setSession(EtchServerFactory* session) {
@@ -139,7 +167,30 @@ status_t EtchTcpTransportFactory::MySess
}
status_t EtchTcpTransportFactory::MySessionListener::sessionNotify(capu::SmartPointer<EtchObject> event) {
+ if (event->equals(&EtchTcpListener::CONNECTION_CHECK())) {
+ //go through the list of connection and check if the connection is still dead and we have to clean the stack up
+ capu::List<EtchStack*>::Iterator it = mConnectionStacks->begin();
+ while (it.hasNext()) {
+ EtchStack* stack = NULL;
+ status_t res = it.current(&stack);
+ if (res == ETCH_OK) {
+ EtchTcpConnection* con = (EtchTcpConnection*) stack->getTransportData();
+ if (con != NULL) {
+ if (!con->isStarted()) {
+ //delete all instances for this stack
+ delete stack;
+ //remote stack from list
+ mConnectionStacks->removeAt(it);
+ }
+ }
+ }
+ it.next();
+ }
+ return ETCH_OK;
+ }
+
return mSession->sessionNotify(event);
+
}
status_t EtchTcpTransportFactory::MySessionListener::sessionAccepted(EtchSocket* connection) {
@@ -147,60 +198,56 @@ status_t EtchTcpTransportFactory::MySess
return ETCH_ERROR;
}
+ status_t status;
+
+ EtchStackServer *stack = new EtchStackServer();
+
EtchResources *res = new EtchResources(mResources);
+ stack->setResources(res);
// put socket to the resources
EtchObject *obj = NULL;
- if (res->put(SOCKET(), connection, obj) != ETCH_OK) {
- delete res;
+ status = res->put(SOCKET(), connection, obj);
+ if (status != ETCH_OK) {
+ delete stack;
return ETCH_ERROR;
}
// create value vatory and put it to the resources
EtchValueFactory* vf = NULL;
- if(mSession->newValueFactory(mUri, vf) != ETCH_OK) {
- delete res;
+ status = mSession->newValueFactory(mUri, vf);
+ if(status != ETCH_OK) {
+ delete stack;
return ETCH_ERROR;
}
- if(res->put(EtchTransport<EtchSocket>::VALUE_FACTORY(), vf, obj) != ETCH_OK)
- {
- delete vf;
- delete res;
+ stack->setValueFactory(vf);
+
+ status = res->put(EtchTransport<EtchSocket>::VALUE_FACTORY(), vf, obj);
+ if(status != ETCH_OK) {
+ delete stack;
return ETCH_ERROR;
}
- EtchURL u = EtchURL(mUri);
-
- EtchObject* socket = NULL;
- if (res->get(SOCKET(), socket) != ETCH_OK) {
- return ETCH_ENOT_EXIST;
+ EtchObject* old = NULL;
+ status = res->put(EtchStack::STACK(), stack, old);
+ if (status != ETCH_OK) {
+ delete stack;
+ return ETCH_ERROR;
}
- // TODO check if we should register a new stack to the runtime
-
- EtchTransportData *c = NULL;
- if (mIsSecure) {
- //TODO : secure communication via ssl sockets
- return ETCH_EUNIMPL;
- } else {
- c = new EtchTcpConnection(mRuntime, (EtchSocket*) socket, &u);
+ if (old != NULL) {
+ delete old;
}
- EtchTransportPacket* p = new EtchPacketizer(c, &u);
+ //add stack container to list
+ mConnectionStacks->add(stack);
- EtchTransportMessage* m = new EtchMessagizer(p, &u, res);
-
- //TODO: ADD FILTERS HERE
-
- if (res->get(EtchTransport<EtchSocket>::VALUE_FACTORY(), obj) != ETCH_OK) {
- c->setSession(NULL);
- p->setSession(NULL);
- m->setSession(NULL);
- delete c;
- delete p;
- delete m;
- return ETCH_ENOT_EXIST;
+ EtchTransportMessage *m = NULL;
+ status = mFactory->newTransport(mUri, res, m);
+ if (status != ETCH_OK) {
+ delete stack;
+ return status;
}
- vf->lockDynamicTypes();
CAPU_LOG_DEBUG(mRuntime->getLogger(), TAG, "New stack for the accepted connection has been created");
+
return mSession->newServer(mRuntime, m, mUri, res);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTransportFactory.cpp Thu Aug 23 16:48:16 2012
@@ -61,7 +61,7 @@ status_t EtchTransportFactory::getListen
}
status_t ret = f->newListener(uri, resources, result);
- delete f;
+
return ret;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchClass2TypeMapTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchClass2TypeMapTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchClass2TypeMapTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchClass2TypeMapTest.cpp Thu Aug 23 16:48:16 2012
@@ -68,17 +68,12 @@ TEST(EtchClass2TypeMapTest, putTest) {
//Try to add existing field
EXPECT_EQ(ETCH_OK, test->put(EtchString::TYPE(), type));
- //Try to add a new field
- EtchType* type2 = new EtchType(EtchString("string2"));
- EXPECT_EQ(ETCH_ERANGE, test->put(EtchString::TYPE(), type2));
-
//lock the collection
test->lock();
//try to add new field
EXPECT_EQ(ETCH_EINVAL, test->put(EtchString::TYPE(), type));
delete test;
delete type;
- delete type2;
}
TEST(EtchClass2TypeMapTest, lockTest) {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchComboValidatorTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchComboValidatorTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchComboValidatorTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchComboValidatorTest.cpp Thu Aug 23 16:48:16 2012
@@ -20,7 +20,29 @@
#include "serialization/EtchValidatorString.h"
#include "serialization/EtchValidatorInt.h"
-TEST(EtchComboValidatorTest, createTest) {
+class EtchComboValidatorTest
+ : public ::testing::Test {
+protected:
+ virtual void SetUp() {
+ mRuntime = new EtchRuntime();
+ mRuntime->setLogger(new EtchLogger());
+ mRuntime->start();
+ }
+
+ virtual void TearDown() {
+ mRuntime->shutdown();
+ EtchLogger* logger = mRuntime->getLogger();
+ if(logger != NULL) {
+ delete logger;
+ }
+ delete mRuntime;
+ mRuntime = NULL;
+ }
+
+ EtchRuntime* mRuntime;
+};
+
+TEST_F(EtchComboValidatorTest, createTest) {
capu::SmartPointer<EtchValidator> ptr;
capu::SmartPointer<EtchValidator> ptr2;
@@ -32,7 +54,7 @@ TEST(EtchComboValidatorTest, createTest)
delete combo;
}
-TEST(EtchComboValidatorTest, validateTest) {
+TEST_F(EtchComboValidatorTest, validateTest) {
capu::SmartPointer<EtchObject> byte = NULL;
capu::SmartPointer<EtchObject> integer = new EtchInt32(capu::NumericLimitMin<capu::int32_t>());
@@ -92,7 +114,7 @@ TEST(EtchComboValidatorTest, validateTes
delete ptr;
}
-TEST(EtchComboValidatorTest, validateValueTest) {
+TEST_F(EtchComboValidatorTest, validateValueTest) {
capu::SmartPointer<EtchObject> byte = NULL;
capu::SmartPointer<EtchObject> result = NULL;
@@ -127,7 +149,7 @@ TEST(EtchComboValidatorTest, validateVal
delete ptr;
}
-TEST(EtchComboValidatorTest, elementValidatorTest) {
+TEST_F(EtchComboValidatorTest, elementValidatorTest) {
//create combo validator
EtchComboValidator *ptr = NULL;
capu::SmartPointer<EtchValidator> ptr1;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchTypeMapTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchTypeMapTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchTypeMapTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/serialization/EtchTypeMapTest.cpp Thu Aug 23 16:48:16 2012
@@ -41,7 +41,6 @@ TEST(EtchTypeMapTest, addTest) {
test->lock();
//try to add new type
EXPECT_EQ(ETCH_EINVAL, test->add(type));
- delete type;
delete test;
}
@@ -81,8 +80,6 @@ TEST(EtchTypeMapTest, getTest) {
EXPECT_EQ(ETCH_OK, test->get("testtype2", tmp1));
delete test;
- delete type;
- delete tmp1;
}
TEST(EtchTypeMapTest, sizeTest) {
@@ -101,7 +98,6 @@ TEST(EtchTypeMapTest, sizeTest) {
//check size
EXPECT_EQ(1, test->size());
delete test;
- delete type;
}
TEST(EtchTypeMapTest, lockTest) {
@@ -122,7 +118,6 @@ TEST(EtchTypeMapTest, lockTest) {
//check size again
EXPECT_EQ(1, test->size());
delete test;
- delete type;
}
TEST(EtchTypeMapTest, getAllTest) {
@@ -149,5 +144,4 @@ TEST(EtchTypeMapTest, getAllTest) {
}
delete test;
- delete type;
}
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp Thu Aug 23 16:48:16 2012
@@ -129,13 +129,15 @@ TEST_F(EtchRemoteBaseTest, constructorTe
EtchDeliveryService * service = NULL;
service = new EtchDefaultDeliveryService(manager, &u);
EtchRemoteBase * remote = NULL;
- remote = new EtchRemoteBase(service, factory->factory);
+ remote = new EtchRemoteBase(service, factory->factory, NULL);
EXPECT_TRUE(remote != NULL);
manager->setSession(service);
service->setSession(&session);
delete remote;
+ delete transport;
+ delete manager;
delete service;
delete factory;
}
@@ -154,7 +156,7 @@ TEST_F(EtchRemoteBaseTest, newMessageTes
EtchDeliveryService * service = NULL;
service = new EtchDefaultDeliveryService(manager, &u);
EtchRemoteBase * remote = NULL;
- remote = new EtchRemoteBase(service, factory->factory);
+ remote = new EtchRemoteBase(service, factory->factory, NULL);
EXPECT_TRUE(remote != NULL);
manager->setSession(service);
@@ -173,7 +175,9 @@ TEST_F(EtchRemoteBaseTest, newMessageTes
//check the assigned factory
EXPECT_TRUE(factory->factory == msg->getValueFactory());
+ delete transport;
delete remote;
+ delete manager;
delete service;
delete factory;
}
@@ -192,7 +196,7 @@ TEST_F(EtchRemoteBaseTest, sendTest) {
EtchDeliveryService * service = NULL;
service = new EtchDefaultDeliveryService(manager, &u);
EtchRemoteBase * remote = NULL;
- remote = new EtchRemoteBase(service, factory->factory);
+ remote = new EtchRemoteBase(service, factory->factory, NULL);
EXPECT_TRUE(remote != NULL);
manager->setSession(service);
@@ -215,7 +219,10 @@ TEST_F(EtchRemoteBaseTest, sendTest) {
EXPECT_TRUE(remote->send(msg) == ETCH_OK);
factory->types.clear();
+
+ delete transport;
delete remote;
+ delete manager;
delete service;
delete factory;
}
@@ -234,7 +241,7 @@ TEST_F(EtchRemoteBaseTest, beginCallTest
EtchDeliveryService * service = NULL;
service = new EtchDefaultDeliveryService(manager, &u);
EtchRemoteBase * remote = NULL;
- remote = new EtchRemoteBase(service, factory->factory);
+ remote = new EtchRemoteBase(service, factory->factory, NULL);
EXPECT_TRUE(remote != NULL);
manager->setSession(service);
@@ -262,7 +269,10 @@ TEST_F(EtchRemoteBaseTest, beginCallTest
EXPECT_TRUE(mail != NULL);
factory->types.clear();
+
+ delete transport;
delete remote;
+ delete manager;
delete service;
delete factory;
}
@@ -281,7 +291,7 @@ TEST_F(EtchRemoteBaseTest, endCallTest)
EtchDeliveryService * service = NULL;
service = new EtchDefaultDeliveryService(manager, &u);
EtchRemoteBase * remote = NULL;
- remote = new EtchRemoteBase(service, factory->factory);
+ remote = new EtchRemoteBase(service, factory->factory, NULL);
EXPECT_TRUE(remote != NULL);
manager->setSession(service);
@@ -331,8 +341,11 @@ TEST_F(EtchRemoteBaseTest, endCallTest)
EXPECT_TRUE(result == data);
factory->types.clear();
+
+ delete transport;
delete mail;
delete remote;
+ delete manager;
delete service;
delete factory;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp Thu Aug 23 16:48:16 2012
@@ -142,6 +142,8 @@ TEST_F(EtchDefaultDeliveryServiceTest, c
// create mock layer for session
MockSession1* session = new MockSession1(deliveryService);
+ delete transport;
+ delete mailboxManager;
delete session;
}
@@ -190,6 +192,8 @@ TEST_F(EtchDefaultDeliveryServiceTest, b
//put the stack down
mailboxManager->sessionNotify(new EtchString(EtchSession::DOWN()));
+ delete transport;
+ delete mailboxManager;
delete session;
delete factory;
}
@@ -264,6 +268,8 @@ TEST_F(EtchDefaultDeliveryServiceTest, e
//check the result
EXPECT_TRUE(result->equals(data.get()));
+ delete transport;
+ delete mailboxManager;
delete session;
delete factory;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchMessagizerTest.cpp Thu Aug 23 16:48:16 2012
@@ -1,35 +1,35 @@
-/* $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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include "serialization/EtchDefaultValueFactory.h"
-#include "serialization/EtchBinaryTaggedData.h"
-#include "serialization/EtchBinaryTaggedDataInput.h"
-#include "serialization/EtchValidatorShort.h"
-#include "transport/EtchMessagizer.h"
-#include "transport/EtchTcpConnection.h"
-#include "transport/EtchPacketizer.h"
-#include "transport/EtchSessionListener.h"
-#include "transport/EtchTcpListener.h"
-
-
-class MockListener11 : public virtual EtchSessionListener<EtchSocket> {
-public:
-
+/* $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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include "serialization/EtchDefaultValueFactory.h"
+#include "serialization/EtchBinaryTaggedData.h"
+#include "serialization/EtchBinaryTaggedDataInput.h"
+#include "serialization/EtchValidatorShort.h"
+#include "transport/EtchMessagizer.h"
+#include "transport/EtchTcpConnection.h"
+#include "transport/EtchPacketizer.h"
+#include "transport/EtchSessionListener.h"
+#include "transport/EtchTcpListener.h"
+
+
+class MockListener11 : public virtual EtchSessionListener<EtchSocket> {
+public:
+
MockListener11(EtchTransport<EtchSessionListener<EtchSocket> >* transport)
: mTransport(transport) {
if(mTransport != NULL) {
@@ -42,38 +42,38 @@ public:
delete mTransport;
}
}
-
+
//This method is called
- status_t sessionAccepted(EtchSocket* connection) {
- delete connection;
- return ETCH_OK;
- }
-
- MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
-
- MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
-
+ status_t sessionAccepted(EtchSocket* connection) {
+ delete connection;
+ return ETCH_OK;
+ }
+
+ MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
+
+ MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
+
status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
return ETCH_OK;
}
private:
EtchTransport<EtchSessionListener<EtchSocket> >* mTransport;
-};
-
-class MockMailboxManager : public EtchSessionMessage {
-public:
-
- status_t sessionMessage(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchMessage> buf) {
- EXPECT_TRUE(buf->count() == 1);
+};
+
+class MockMailboxManager : public EtchSessionMessage {
+public:
+
+ status_t sessionMessage(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchMessage> buf) {
+ EXPECT_TRUE(buf->count() == 1);
buf->clear();
- return ETCH_OK;
- }
-
- MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
-
- MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
-
+ return ETCH_OK;
+ }
+
+ MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
+
+ MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
+
status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
return ETCH_OK;
}
@@ -116,43 +116,48 @@ TEST_F(EtchMessagizerTest, constructorTe
EtchTransportData* conn = new EtchTcpConnection(mRuntime, NULL, &u);
EtchTransportPacket* pac = new EtchPacketizer(conn, &u);
EtchSessionPacket* mes = new EtchMessagizer(pac, &u, &r);
- //Created stack
- delete mes;
+
+ //Delete created stack
+ delete conn;
+ delete mes;
+ delete pac;
delete factory;
types.clear();
}
-TEST_F(EtchMessagizerTest, TransportControlTest) {
- EtchTypeMap types;
- EtchClass2TypeMap class2type;
- EtchDefaultValueFactory * factory;
+TEST_F(EtchMessagizerTest, TransportControlTest) {
+ EtchTypeMap types;
+ EtchClass2TypeMap class2type;
+ EtchDefaultValueFactory * factory;
MockMailboxManager manager;
- EtchDefaultValueFactory::Init(&types, &class2type);
- EtchString uri("tcp://127.0.0.1:4001");
- factory = new EtchDefaultValueFactory(uri, &types, &class2type);
- //created value factory
- EtchURL u("tcp://127.0.0.1:4001");
- EtchResources r;
- EtchObject *out;
+ EtchDefaultValueFactory::Init(&types, &class2type);
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new EtchDefaultValueFactory(uri, &types, &class2type);
+ //created value factory
+ EtchURL u("tcp://127.0.0.1:4001");
+ EtchResources r;
+ EtchObject *out;
r.put(EtchTransport<EtchSessionMessage>::VALUE_FACTORY(), factory, out);
EtchTransportData* conn = new EtchTcpConnection(mRuntime, NULL, &u);
EtchPacketizer* pac = new EtchPacketizer(conn, &u);
EtchMessagizer* mess = new EtchMessagizer(pac, &u, &r);
mess->setSession(&manager);
-
+
EtchTcpListener* transport = new EtchTcpListener(&u);
EtchSessionListener<EtchSocket>* mSessionListener = new MockListener11(transport);
transport->transportControl(new EtchString(EtchTcpListener::START_AND_WAIT_UP()), new EtchInt32(1000));
mess->transportControl(new EtchString(EtchPacketizer::START_AND_WAIT_UP()), new EtchInt32(1000));
- //test transport commands
+ //test transport commands
mess->transportControl(new EtchString(EtchPacketizer::STOP_AND_WAIT_DOWN()), new EtchInt32(1000));
transport->transportControl(new EtchString(EtchTcpListener::STOP_AND_WAIT_DOWN()), new EtchInt32(1000));
- delete mSessionListener;
- delete mess;
+ delete conn;
+ delete mSessionListener;
+ delete pac;
+ delete mess;
delete factory;
types.clear();
}
@@ -162,34 +167,36 @@ TEST_F(EtchMessagizerTest, TransportMess
EtchClass2TypeMap class2type;
EtchDefaultValueFactory * factory;
MockMailboxManager manager;
- EtchDefaultValueFactory::Init(&types, &class2type);
- EtchString uri("tcp://127.0.0.1:4001");
- factory = new EtchDefaultValueFactory(uri, &types, &class2type);
- //default value factory
- EtchURL u("tcp://127.0.0.1:4001");
- EtchResources r;
- EtchObject *out;
- //add to the resource
+ EtchDefaultValueFactory::Init(&types, &class2type);
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new EtchDefaultValueFactory(uri, &types, &class2type);
+ //default value factory
+ EtchURL u("tcp://127.0.0.1:4001");
+ EtchResources r;
+ EtchObject *out;
+ //add to the resource
r.put(EtchTransport<EtchSessionMessage>::VALUE_FACTORY(), factory, out);
EtchTransportData* conn = new EtchTcpConnection(mRuntime, NULL, &u);
EtchPacketizer* pac = new EtchPacketizer(conn, &u);
EtchMessagizer* mess = new EtchMessagizer(pac, &u, &r);
mess->setSession(&manager);
- //creation of example message which will be serialized
- EtchType *mt_foo = NULL;
- EtchField mf_x("x");
- EtchString str("foo");
- factory->getType(str, mt_foo);
- capu::SmartPointer<EtchValidator> v;
- EtchValidatorShort::Get(0, v);
- mt_foo->putValidator(mf_x, v);
- capu::SmartPointer<EtchShort> data = new EtchShort(10000);
- capu::SmartPointer<EtchMessage> msg = new EtchMessage(mt_foo, factory);
- msg->put(mf_x, data);
-
+ //creation of example message which will be serialized
+ EtchType *mt_foo = NULL;
+ EtchField mf_x("x");
+ EtchString str("foo");
+ factory->getType(str, mt_foo);
+ capu::SmartPointer<EtchValidator> v;
+ EtchValidatorShort::Get(0, v);
+ mt_foo->putValidator(mf_x, v);
+ capu::SmartPointer<EtchShort> data = new EtchShort(10000);
+ capu::SmartPointer<EtchMessage> msg = new EtchMessage(mt_foo, factory);
+ msg->put(mf_x, data);
+
EXPECT_TRUE(mess->transportMessage(NULL, msg) == ETCH_ERROR);
- delete mess;
+ delete conn;
+ delete mess;
+ delete pac;
delete factory;
types.clear();
}
@@ -248,7 +255,9 @@ TEST_F(EtchMessagizerTest, SessionDataTe
mess->setSession(NULL);
types.clear();
- delete mMailboxManager;
- delete mess;
+ delete conn;
+ delete mMailboxManager;
+ delete pac;
+ delete mess;
delete factory;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPacketizerTest.cpp Thu Aug 23 16:48:16 2012
@@ -1,36 +1,36 @@
-/* $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 <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include "transport/EtchPacketizer.h"
-#include "common/EtchString.h"
-#include "common/EtchError.h"
-#include "util/EtchURL.h"
-#include "transport/EtchTcpConnection.h"
-#include "capu/util/SmartPointer.h"
-#include "common/EtchSocket.h"
-#include "transport/EtchSessionListener.h"
-#include "transport/EtchTcpListener.h"
-#include "transport/EtchSessionPacket.h"
-#include "transport/EtchFlexBuffer.h"
-
-class MockListener3 : public virtual EtchSessionListener<EtchSocket> {
-public:
-
+/* $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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include "transport/EtchPacketizer.h"
+#include "common/EtchString.h"
+#include "common/EtchError.h"
+#include "util/EtchURL.h"
+#include "transport/EtchTcpConnection.h"
+#include "capu/util/SmartPointer.h"
+#include "common/EtchSocket.h"
+#include "transport/EtchSessionListener.h"
+#include "transport/EtchTcpListener.h"
+#include "transport/EtchSessionPacket.h"
+#include "transport/EtchFlexBuffer.h"
+
+class MockListener3 : public virtual EtchSessionListener<EtchSocket> {
+public:
+
MockListener3(EtchTransport<EtchSessionListener<EtchSocket> >* transport) :
mTransport(transport) {
if(mTransport != NULL) {
@@ -43,34 +43,34 @@ public:
delete mTransport;
}
}
-
+
//This method is called
- status_t sessionAccepted(EtchSocket* connection) {
- delete connection;
- return ETCH_OK;
- }
-
- MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
-
- MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
-
+ status_t sessionAccepted(EtchSocket* connection) {
+ delete connection;
+ return ETCH_OK;
+ }
+
+ MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
+
+ MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
+
status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
return ETCH_OK;
}
private:
EtchTransport<EtchSessionListener<EtchSocket> >* mTransport;
-};
-
-class MockMessagizer : public EtchSessionPacket {
-public:
-
- MOCK_METHOD2(sessionPacket, status_t(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchFlexBuffer> buf));
-
- MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
-
- MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
-
+};
+
+class MockMessagizer : public EtchSessionPacket {
+public:
+
+ MOCK_METHOD2(sessionPacket, status_t(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchFlexBuffer> buf));
+
+ MOCK_METHOD2(sessionQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
+
+ MOCK_METHOD2(sessionControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
+
status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
return ETCH_OK;
}
@@ -102,7 +102,10 @@ TEST_F(EtchPacketizerTest, constructorTe
EtchURL u("tcp://127.0.0.1:4001");
EtchTransportData* conn = new EtchTcpConnection(mRuntime, NULL, &u);
EtchSessionData* packetizer = new EtchPacketizer(conn, &u);
- delete packetizer;
+
+ delete conn;
+ delete packetizer;
+
}
TEST_F(EtchPacketizerTest, TransportControlTest) {
@@ -112,18 +115,18 @@ TEST_F(EtchPacketizerTest, TransportCont
MockMessagizer mes;
packetizer->setSession(&mes);
-
EtchTcpListener* transport = new EtchTcpListener(&u);
EtchSessionListener<EtchSocket>* listener = new MockListener3(transport);
- //Start the mock listener
+ //Start the mock listener
transport->transportControl(new EtchString(EtchTcpListener::START_AND_WAIT_UP()), new EtchInt32(1000));
-
+
packetizer->transportControl(new EtchString(EtchPacketizer::START_AND_WAIT_UP()), new EtchInt32(1000));
packetizer->transportControl(new EtchString(EtchPacketizer::STOP_AND_WAIT_DOWN()), new EtchInt32(1000));
-
+
transport->transportControl(new EtchString(EtchTcpListener::STOP_AND_WAIT_DOWN()), new EtchInt32(1000));
-
+
+ delete conn;
delete packetizer;
delete listener;
}
@@ -142,6 +145,8 @@ TEST_F(EtchPacketizerTest, TransportPack
buffer->setIndex(0);
EXPECT_TRUE(packetizer->transportPacket(NULL, buffer) == ETCH_ERROR);
+
+ delete conn;
delete packetizer;
}
@@ -151,21 +156,22 @@ TEST_F(EtchPacketizerTest, SessionDataTe
EtchPacketizer* packetizer = new EtchPacketizer(conn, &u);
capu::SmartPointer<EtchFlexBuffer> buffer = new EtchFlexBuffer();
//A packet is created
- capu::int32_t pktsize = 4;
+ capu::int32_t pktsize = 4;
buffer->putInt(packetizer->SIG());
buffer->putInt(pktsize);
- buffer->put((capu::int8_t *)"test", pktsize);
- buffer->setIndex(0);
- EXPECT_TRUE(buffer->getLength() == 12);
-
- EtchSessionPacket* mSessionPacker = new MockMessagizer();
- packetizer->setSession(mSessionPacker);
-
- MockMessagizer * mock = (MockMessagizer*) mSessionPacker;
- EXPECT_CALL(*mock, sessionPacket(capu::SmartPointer<EtchWho > (NULL), buffer));
- EXPECT_TRUE(packetizer->sessionData(NULL, buffer) == ETCH_OK);
-
- packetizer->setSession(NULL);
- delete mSessionPacker;
- delete packetizer;
+ buffer->put((capu::int8_t *)"test", pktsize);
+ buffer->setIndex(0);
+ EXPECT_TRUE(buffer->getLength() == 12);
+
+ EtchSessionPacket* mSessionPacker = new MockMessagizer();
+ packetizer->setSession(mSessionPacker);
+
+ MockMessagizer * mock = (MockMessagizer*) mSessionPacker;
+ EXPECT_CALL(*mock, sessionPacket(capu::SmartPointer<EtchWho > (NULL), buffer));
+ EXPECT_TRUE(packetizer->sessionData(NULL, buffer) == ETCH_OK);
+
+ packetizer->setSession(NULL);
+ delete mSessionPacker;
+ delete packetizer;
+ delete conn;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp Thu Aug 23 16:48:16 2012
@@ -126,6 +126,7 @@ TEST_F(EtchPlainMailboxManagerTest, cons
EXPECT_TRUE(manager != NULL);
manager->setSession(&session);
+ delete transport;
delete manager;
delete factory;
}
@@ -165,6 +166,8 @@ TEST_F(EtchPlainMailboxManagerTest, tran
EXPECT_TRUE(ETCH_OK != manager->getMailbox(id, mail));
message->clear();
+
+ delete transport;
delete manager;
delete factory;
}
@@ -207,6 +210,8 @@ TEST_F(EtchPlainMailboxManagerTest, tran
EXPECT_TRUE(ETCH_OK != manager->getMailbox(id, mail));
message->clear();
+
+ delete transport;
delete manager;
delete factory;
}
@@ -248,6 +253,8 @@ TEST_F(EtchPlainMailboxManagerTest, tran
EXPECT_TRUE(ETCH_OK == manager->getMailbox(id, mail));
message->clear();
+
+ delete transport;
delete manager;
delete factory;
}
@@ -293,6 +300,8 @@ TEST_F(EtchPlainMailboxManagerTest, repl
EXPECT_TRUE(ETCH_OK != manager->getMailbox(id, mail));
message->clear();
+
+ delete transport;
delete manager;
delete factory;
}
@@ -354,6 +363,7 @@ TEST_F(EtchPlainMailboxManagerTest, sess
//deallocations
delete x;
+ delete transport;
delete manager;
delete factory;
}
Modified: incubator/etch/trunk/examples/helloworld/cpp/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/cpp/CMakeLists.txt?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/cpp/CMakeLists.txt (original)
+++ incubator/etch/trunk/examples/helloworld/cpp/CMakeLists.txt Thu Aug 23 16:48:16 2012
@@ -21,6 +21,9 @@
cmake_minimum_required (VERSION 2.8)
project (etch-cpp-helloworld)
+IF (EXISTS "${CMAKE_SOURCE_DIR}/CMakeLists_local.txt")
+ INCLUDE ("${CMAKE_SOURCE_DIR}/CMakeLists_local.txt" OPTIONAL)
+ENDIF()
IF(UNIX)
add_definitions("-DOS_LINUX")
@@ -116,6 +119,12 @@ target_link_libraries(etch-cpp-helloworl
set_target_properties(etch-cpp-helloworld-server PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
ELSEIF(WIN32)
target_link_libraries(etch-cpp-helloworld-server ${ETCH_LIBRARY} ${CAPU_LIBRARY})
+IF (BUILD_CHECK_MEMORY)
+ file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ target_link_libraries (etch-cpp-helloworld-server ${VLD}/lib/vld.lib)
+ENDIF (BUILD_CHECK_MEMORY)
ENDIF ()
set_target_properties(etch-cpp-helloworld-server PROPERTIES OUTPUT_NAME "helloworld-server")
@@ -147,6 +156,12 @@ target_link_libraries(etch-cpp-helloworl
set_target_properties(etch-cpp-helloworld-client PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
ELSEIF(WIN32)
target_link_libraries(etch-cpp-helloworld-client ${ETCH_LIBRARY} ${CAPU_LIBRARY})
+IF (BUILD_CHECK_MEMORY)
+ file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+ target_link_libraries (etch-cpp-helloworld-client ${VLD}/lib/vld.lib)
+ENDIF (BUILD_CHECK_MEMORY)
ENDIF ()
set_target_properties(etch-cpp-helloworld-client PROPERTIES OUTPUT_NAME "helloworld-client")
Modified: incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp (original)
+++ incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp Thu Aug 23 16:48:16 2012
@@ -12,7 +12,9 @@
#include "MainHelloWorldClient.h"
#include "ImplHelloWorldClient.h"
#include "transport/EtchTransportData.h"
-
+#ifdef BUILD_CHECK_MEMORY
+#include "vld.h"
+#endif
using namespace org_apache_etch_examples_helloworld_HelloWorld;
@@ -64,6 +66,9 @@ capu::int32_t main(int argc, const char*
// Disconnect from the service
remote->transportControl(new EtchString(EtchTransportData::STOP_AND_WAIT_DOWN()), new EtchInt32(4000));
+ //delete remote
+ delete remote;
+
//delete runtime
result = runtime->shutdown();
if (result != ETCH_OK) {
Modified: incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldListener.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldListener.cpp?rev=1376588&r1=1376587&r2=1376588&view=diff
==============================================================================
--- incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldListener.cpp (original)
+++ incubator/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldListener.cpp Thu Aug 23 16:48:16 2012
@@ -6,16 +6,18 @@
// overwritten once it exists! Please edit this file as necessary to implement
// your service logic.
+#include "MainHelloWorldListener.h"
+#include "ImplHelloWorldServer.h"
+#include "RemoteHelloWorldClient.h"
+
#include "capu/os/Thread.h"
#include "common/EtchTypes.h"
#include "support/EtchRuntime.h"
-#include "RemoteHelloWorldClient.h"
-#include "MainHelloWorldListener.h"
-#include "ImplHelloWorldServer.h"
#include "transport/EtchTransportData.h"
-#include "util/EtchLogger.h"
-
+#ifdef BUILD_CHECK_MEMORY
+#include "vld.h"
+#endif
using namespace org_apache_etch_examples_helloworld_HelloWorld;
@@ -36,13 +38,6 @@ int main(int argc, const char* argv[])
EtchRuntime* runtime = new EtchRuntime();
status = runtime->start();
- EtchLogger* logger = new EtchLogger();
- EtchAppender* appender = new EtchConsoleAppender();
- appender->setLoggingLevel(capu::CLL_TRACE);
- logger->setAppender(appender);
- EtchRuntime::setLogger(logger);
-
-
// TODO Change to correct URI
EtchString uri("tcp://0.0.0.0:4001");
@@ -52,21 +47,29 @@ int main(int argc, const char* argv[])
status = HelloWorldHelper::newListener(runtime, uri, NULL, &mainHelloWorldlistener, listener);
- // Start the Listener
+ //start the Listener
status = listener->transportControl(new EtchString(EtchTransportData::START_AND_WAIT_UP()), new EtchInt32(4000));
+ if (status == ETCH_OK) {
+ printf("Hello World Server started successfully. Listening on port 4001\n\n");
+ } else {
+ printf("Error while starting Hello World Server. Errorcode %d \n\n", status);
+ return -1;
+ }
+
+ //waiting
+ printf("press any key to stop server\n");
+ getchar();
- //Wait for finish...
- capu::Thread::Sleep(200000);
-
- //Stop the Listener
+ //stop the Listener
listener->transportControl(new EtchString(EtchTransportData::STOP_AND_WAIT_DOWN()), new EtchInt32(4000));
+ //delete listener
+ delete listener;
+
//delete runtime
status = runtime->shutdown();
-
+
delete runtime;
- delete logger;
- delete appender;
return 0;
}