You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2012/08/02 16:36:40 UTC

svn commit: r1368489 - in /incubator/etch/trunk/binding-cpp/runtime: include/common/ include/support/ include/transport/ src/main/ src/main/support/ src/main/transport/

Author: fitzner
Date: Thu Aug  2 14:36:39 2012
New Revision: 1368489

URL: http://svn.apache.org/viewvc?rev=1368489&view=rev
Log:
ETCH-213: Implementation of EtchServerFactories

First implementation

Change-Id: Id5d13aca235a1940ed2479614b9775f98864b3e7

Added:
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
    incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
Modified:
    incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h
    incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h
    incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp

Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h?rev=1368489&r1=1368488&r2=1368489&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchError.h Thu Aug  2 14:36:39 2012
@@ -45,7 +45,8 @@ enum {
 
   //RANGE BETWEEN 0X10000 TO OXFFFFFFF ARE ERROR CODES FOR ONLY ETCH
     ETCH_UNWANTED_MESSAGE = 0X10000,
-    ETCH_UKNOWN_OP
+    ETCH_UKNOWN_OP,
+    ETCH_UNSUPP_OP
 };
 
 #endif

Added: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h?rev=1368489&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h Thu Aug  2 14:36:39 2012
@@ -0,0 +1,88 @@
+
+/* $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.
+ */
+
+#ifndef __ETCHDEFAULTSERVERFACTORY_H__
+#define __ETCHDEFAULTSERVERFACTORY_H__
+
+
+#include "EtchServerFactory.h"
+
+/**
+ * Default implementation of ServerFactory. Used by Etch generated Helper files
+ * to provide listeners with backstop implementations of Session methods which
+ * forward to user's implementation factory.
+ */
+class EtchDefaultServerFactory : public EtchServerFactory
+{
+public:
+  /**
+   * Constructs the DefaultServerFactory.
+   * @param listener
+   * @param implFactory
+   */
+  EtchDefaultServerFactory( EtchTransport<EtchServerFactory>* listener, EtchSession* implFactory );
+
+  /**
+   * @see EtchSession
+   */
+  virtual status_t sessionQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result );
+
+  /**
+   * @see EtchSession
+   */
+  virtual status_t sessionControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value );
+
+  /**
+   * @see EtchSession
+   */
+  virtual status_t sessionNotify(capu::SmartPointer<EtchObject> event );
+
+  /**
+   * @see EtchTransport<EtchSession>
+   */
+  virtual EtchSession* getSession();
+
+  /**
+   * @see EtchTransport<EtchSession>
+   */
+  virtual void setSession( EtchSession* session );
+
+  /**
+   * @see EtchTransport<EtchSession>
+   */
+  virtual status_t transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value);
+
+  /**
+   * @see EtchTransport<EtchSession>
+   */
+  virtual status_t transportNotify(capu::SmartPointer<EtchObject> event);
+
+  /**
+   * @see EtchTransport<EtchSession>
+   */
+  virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+
+private:
+  EtchSession* mSession;
+  EtchTransport<EtchServerFactory>* mListener;
+};
+
+#endif /* __ETCHDEFAULTSERVERFACTORY_H__*/

Added: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h?rev=1368489&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchServerFactory.h Thu Aug  2 14:36:39 2012
@@ -0,0 +1,52 @@
+/* $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.
+ */
+
+#ifndef __ETCHSERVERFACTORY_H__
+#define __ETCHSERVERFACTORY_H__
+
+#include "util/EtchResources.h"
+#include "transport/EtchSession.h"
+#include "transport/EtchTransport.h"
+#include "transport/EtchTransportMessage.h"
+
+/**
+ * Interface to use for constructing new server instances by
+ * TransportHelper.
+ */
+class EtchServerFactory : public EtchSession, public EtchTransport<EtchSession>
+{
+public:
+  /**
+   * @param transport the TransportMessage to use with the new server instance.
+   * @param uri the uri to use to configure the new server instance.
+   * @param resources the resources to use for the new server instance.
+   * @throws Exception
+   */
+  virtual status_t newServer( EtchTransportMessage* transport, EtchString* uri,
+    EtchResources* resources ) = 0;
+
+  /**
+   * @param uri the uri to use to configure the new value factory.
+   * @return a new instance of value factory for this connection.
+   */
+  virtual status_t newValueFactory(EtchString* uri, EtchValueFactory *&vf) = 0;
+};
+
+#endif /* __ETCHSERVERFACTORY_H__ */

Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h?rev=1368489&r1=1368488&r2=1368489&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h Thu Aug  2 14:36:39 2012
@@ -37,7 +37,6 @@ public:
    * Destructor
    */
   virtual ~EtchTransport() {
-
   }
 
   /**
@@ -99,7 +98,7 @@ public:
   /**
    * Name of value factory in resources.
    */
-  static const EtchString VALUE_FACTORY;
+  const static EtchString VALUE_FACTORY;
 
   ///////////////////////////////////////////////
   // Well-known queries, controls, and events. //

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=1368489&r1=1368488&r2=1368489&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  2 14:36:39 2012
@@ -107,6 +107,7 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/transport/EtchMessagizer.h
     ${PROJECT_SOURCE_DIR}/include/transport/EtchFormat.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchAsyncResultBase.h
+    ${PROJECT_SOURCE_DIR}/include/support/EtchDefaultServerFactory.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchDeliveryService.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchFreePool.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchMailbox.h
@@ -114,6 +115,7 @@ SET(MAIN_INCLUDES
     ${PROJECT_SOURCE_DIR}/include/support/EtchPool.h
     ${PROJECT_SOURCE_DIR}/include/support/EtchPoolRunnable.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  
     ${PROJECT_SOURCE_DIR}/include/support/EtchTransportHelper.h
@@ -185,6 +187,7 @@ SET(MAIN_SOURCES
     serialization/EtchBinaryTaggedDataInput.cpp
     serialization/EtchBinaryTaggedDataOutput.cpp
     support/EtchFreePool.cpp
+    support/EtchDefaultServerFactory.cpp
     support/EtchStubBase.cpp
     support/EtchRemoteBase.cpp
     support/EtchTransportHelper.cpp

Added: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp?rev=1368489&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp Thu Aug  2 14:36:39 2012
@@ -0,0 +1,88 @@
+
+/* $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/EtchDefaultServerFactory.h"
+
+/**
+* Constructs the DefaultServerFactory.
+* @param listener
+* @param implFactory
+*/
+EtchDefaultServerFactory::EtchDefaultServerFactory( EtchTransport<EtchServerFactory>* listener, EtchSession* implFactory )
+  : mListener(listener) {
+    if(implFactory != NULL) {
+      setSession( implFactory );
+    }
+    if(listener != NULL) {
+      listener->setSession(this);
+    }
+}
+
+status_t EtchDefaultServerFactory::sessionQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result ) {
+  if(mSession != NULL) {
+    return mSession->sessionQuery(query, result);
+  }
+  return ETCH_UNSUPP_OP;
+}
+
+status_t EtchDefaultServerFactory::sessionControl( capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value ) {
+  if(mSession != NULL) {
+    return mSession->sessionControl( control, value );
+  }
+  return ETCH_UNSUPP_OP;
+}
+
+status_t EtchDefaultServerFactory::sessionNotify( capu::SmartPointer<EtchObject> event ) {
+  if(mSession != NULL) {
+    return mSession->sessionNotify( event );
+  }
+  return ETCH_OK;
+}
+
+EtchSession* EtchDefaultServerFactory::getSession() {
+  return mSession;
+}
+
+void EtchDefaultServerFactory::setSession( EtchSession* session ) {
+  mSession = session;
+}
+
+status_t EtchDefaultServerFactory::transportControl( capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value ) {
+  if(mListener == NULL) {
+    return ETCH_ERANGE;
+  }
+  return mListener->transportControl( control, value );;
+}
+
+status_t EtchDefaultServerFactory::transportNotify( capu::SmartPointer<EtchObject> event ) {
+  if(mListener == NULL) {
+    return ETCH_ERANGE;
+  }
+  return mListener->transportNotify( event );
+}
+
+status_t EtchDefaultServerFactory::transportQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result ) {
+  if(mListener == NULL) {
+    return ETCH_ERANGE;
+  }
+  return mListener->transportQuery(query, result);
+}

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=1368489&r1=1368488&r2=1368489&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  2 14:36:39 2012
@@ -234,4 +234,4 @@ status_t EtchPacketizer::processHeader(E
 
 EtchTransportData* EtchPacketizer::getTransport() {
   return mTransport;
-}
\ No newline at end of file
+}