You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/05/01 00:39:06 UTC

svn commit: r939856 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ decaf/io/ decaf/net/ decaf/net/ssl/

Author: tabish
Date: Fri Apr 30 22:39:05 2010
New Revision: 939856

URL: http://svn.apache.org/viewvc?rev=939856&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-140

Adds the FileDescriptor class to decaf::io and adds some initial SSL classes.  Update the Socket class definition to make some of the methods virtual that weren't so the SSLSocket can override them as needed.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=939856&r1=939855&r2=939856&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Fri Apr 30 22:39:05 2010
@@ -523,6 +523,7 @@ cc_sources = \
     decaf/io/ByteArrayOutputStream.cpp \
     decaf/io/DataInputStream.cpp \
     decaf/io/DataOutputStream.cpp \
+    decaf/io/FileDescriptor.cpp \
     decaf/io/FilterInputStream.cpp \
     decaf/io/FilterOutputStream.cpp \
     decaf/io/InputStream.cpp \
@@ -560,6 +561,8 @@ cc_sources = \
     decaf/net/URL.cpp \
     decaf/net/URLDecoder.cpp \
     decaf/net/URLEncoder.cpp \
+    decaf/net/ssl/SSLContent.cpp \
+    decaf/net/ssl/SSLSocket.cpp \
     decaf/net/ssl/SSLSocketFactory.cpp \
     decaf/nio/Buffer.cpp \
     decaf/nio/ByteBuffer.cpp \
@@ -1192,6 +1195,7 @@ h_sources = \
     decaf/io/DataOutput.h \
     decaf/io/DataOutputStream.h \
     decaf/io/EOFException.h \
+    decaf/io/FileDescriptor.h \
     decaf/io/FilterInputStream.h \
     decaf/io/FilterOutputStream.h \
     decaf/io/Flushable.h \
@@ -1273,6 +1277,8 @@ h_sources = \
     decaf/net/URLEncoder.h \
     decaf/net/UnknownHostException.h \
     decaf/net/UnknownServiceException.h \
+    decaf/net/ssl/SSLContent.h \
+    decaf/net/ssl/SSLSocket.h \
     decaf/net/ssl/SSLSocketFactory.h \
     decaf/nio/Buffer.h \
     decaf/nio/BufferOverflowException.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp Fri Apr 30 22:39:05 2010
@@ -0,0 +1,51 @@
+/*
+ * 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 "FileDescriptor.h"
+
+using namespace decaf;
+using namespace decaf::io;
+
+////////////////////////////////////////////////////////////////////////////////
+FileDescriptor FileDescriptor::in( 0, true );
+FileDescriptor FileDescriptor::out( 1, false );
+FileDescriptor FileDescriptor::err( 2, false );
+
+////////////////////////////////////////////////////////////////////////////////
+FileDescriptor::FileDescriptor() : descriptor( -1 ), readonly( false ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+FileDescriptor::FileDescriptor( long value, bool readonly ) : descriptor( value ), readonly( readonly ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+FileDescriptor::~FileDescriptor() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void FileDescriptor::sync() {
+
+    if( !this->readonly ) {
+        // TODO - Implement a Sync method for each OS.
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool FileDescriptor::valid() {
+    return this->descriptor != -1 ? true : false;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h Fri Apr 30 22:39:05 2010
@@ -0,0 +1,89 @@
+/*
+ * 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 _DECAF_IO_FILEDESCRIPTOR_H_
+#define _DECAF_IO_FILEDESCRIPTOR_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf {
+namespace io {
+
+    /**
+     * This class servers as an opaque wrapper around an underlying OS level resource that can
+     * be used as a source / sink for byte level data such as sockets and files.
+     *
+     * @since 1.0
+     */
+    class DECAF_API FileDescriptor {
+    public:
+
+        /**
+         * A handle to the standard input stream. Usually, this file descriptor is not used
+         * directly, but rather via the input stream known as System::in.
+         */
+        static FileDescriptor in;
+
+        /**
+         * A handle to the standard output stream. Usually, this file descriptor is not used
+         * directly, but rather via the output stream known as System::out.
+         */
+        static FileDescriptor out;
+
+        /**
+         * A handle to the standard error stream. Usually, this file descriptor is not used
+         * directly, but rather via the output stream known as System::err.
+         */
+        static FileDescriptor err;
+
+    protected:
+
+        long descriptor;
+        bool readonly;
+
+    protected:
+
+        FileDescriptor( long value, bool readonly );
+
+    public:
+
+        FileDescriptor();
+
+        virtual ~FileDescriptor();
+
+        /**
+         * Force any/all buffered data for this FileDescriptor to be flushed to the underlying device.
+         *
+         * This method blocks until all data is flushed to the underlying device and is used to place
+         * the device into a known state.  In the case of data that is buffered at a higher level such
+         * as a BufferedOutputStream the stream must first be flushed before this method can force
+         * the data to be sent to the output device.
+         */
+        void sync();
+
+        /**
+         * Indicates whether the File Descriptor is valid.
+         *
+         * @return true for a valid descriptor such as open socket or file, false otherwise.
+         */
+        bool valid();
+
+    };
+
+}}
+
+#endif /* _DECAF_IO_FILEDESCRIPTOR_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/io/FileDescriptor.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp?rev=939856&r1=939855&r2=939856&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp Fri Apr 30 22:39:05 2010
@@ -682,3 +682,13 @@ void Socket::accepted() {
     this->bound = true;
     this->connected = true;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Socket::toString() const {
+
+    if( !isConnected() ) {
+        return "Socket[unconnected]";
+    }
+
+    return impl->toString();
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h?rev=939856&r1=939855&r2=939856&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h Fri Apr 30 22:39:05 2010
@@ -282,7 +282,7 @@ namespace net{
          *
          * @throws IOException if an I/O error occurs while performing this operation.
          */
-        void shutdownInput() throw( decaf::io::IOException );
+        virtual void shutdownInput() throw( decaf::io::IOException );
 
         /**
          * Shuts down the OutputStream for this socket, any data already written to the socket will
@@ -290,7 +290,7 @@ namespace net{
          *
          * @throws IOException if an I/O error occurs while performing this operation.
          */
-        void shutdownOutput() throw( decaf::io::IOException );
+        virtual void shutdownOutput() throw( decaf::io::IOException );
 
         /**
          * Gets the linger time for the socket, SO_LINGER.  A return value of -1 indicates that
@@ -478,7 +478,7 @@ namespace net{
          *
          * @throws SocketException if an error is encountered while performing this operation.
          */
-        bool getOOBInline() const throw( SocketException );
+        virtual bool getOOBInline() const throw( SocketException );
 
         /**
          * Sets the value of the OOBINLINE for this socket, by default this option is disabled.  If
@@ -488,7 +488,7 @@ namespace net{
          *
          * @throws SocketException if an error is encountered while performing this operation.
          */
-        void setOOBInline( bool value ) throw( SocketException );
+        virtual void setOOBInline( bool value ) throw( SocketException );
 
         /**
          * Sends on byte of urgent data to the Socket.
@@ -498,12 +498,12 @@ namespace net{
          *
          * @throws IOException if an I/O error occurs while performing this operation.
          */
-        void sendUrgentData( int data ) throw( decaf::io::IOException );
+        virtual void sendUrgentData( int data ) throw( decaf::io::IOException );
 
         /**
          * @returns a string representing this Socket.
          */
-        std::string toString() const;
+        virtual std::string toString() const;
 
     public:
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp Fri Apr 30 22:39:05 2010
@@ -0,0 +1,31 @@
+/*
+ * 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 "SSLContent.h"
+
+using namespace decaf;
+using namespace decaf::net;
+using namespace decaf::net::ssl;
+
+////////////////////////////////////////////////////////////////////////////////
+SSLContent::SSLContent() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SSLContent::~SSLContent() {
+}
+

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h Fri Apr 30 22:39:05 2010
@@ -0,0 +1,42 @@
+/*
+ * 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 _DECAF_NET_SSL_SSLCONTENT_H_
+#define _DECAF_NET_SSL_SSLCONTENT_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf {
+namespace net {
+namespace ssl {
+
+    /**
+     *
+     * @since 1.0
+     */
+    class DECAF_API SSLContent {
+    public:
+
+        SSLContent();
+
+        virtual ~SSLContent();
+
+    };
+
+}}}
+
+#endif /* _DECAF_NET_SSL_SSLCONTENT_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLContent.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp Fri Apr 30 22:39:05 2010
@@ -0,0 +1,30 @@
+/*
+ * 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 "SSLSocket.h"
+
+using namespace decaf;
+using namespace decaf::net;
+using namespace decaf::net::ssl;
+
+////////////////////////////////////////////////////////////////////////////////
+SSLSocket::SSLSocket() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SSLSocket::~SSLSocket() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h?rev=939856&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h Fri Apr 30 22:39:05 2010
@@ -0,0 +1,44 @@
+/*
+ * 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 _DECAF_NET_SSL_SSLSOCKET_H_
+#define _DECAF_NET_SSL_SSLSOCKET_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/net/Socket.h>
+
+namespace decaf {
+namespace net {
+namespace ssl {
+
+    /**
+     *
+     * @since 1.0
+     */
+    class DECAF_API SSLSocket : public Socket {
+    public:
+
+        SSLSocket();
+
+        virtual ~SSLSocket();
+
+    };
+
+}}}
+
+#endif /* _DECAF_NET_SSL_SSLSOCKET_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLSocket.h
------------------------------------------------------------------------------
    svn:eol-style = native