activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r479374 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp: ./ src/main/ src/main/activemq/util/ src/test/ src/test/activemq/util/
Date Sun, 26 Nov 2006 16:27:09 GMT
Author: nmittler
Date: Sun Nov 26 08:27:08 2006
New Revision: 479374

URL: http://svn.apache.org/viewvc?view=rev&rev=479374
Log:
[AMQCPP-14] Adding activemq::util::Date class to support proper handling of CMS Expiration

Added:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.h
Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac?view=diff&rev=479374&r1=479373&r2=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Sun Nov 26 08:27:08 2006
@@ -77,6 +77,10 @@
 AC_CHECK_HEADERS([sys/filio.h])
 AC_CHECK_HEADERS([sys/ioctl.h])
 AC_CHECK_HEADERS([sys/select.h])
+AC_CHECK_HEADERS([sys/time.h])
+AC_CHECK_HEADERS([sys/timeb.h])
+
+AC_CHECK_FUNCS([ioctl select gettimeofday time ftime])
 
 AM_PATH_CPPUNIT(1.10.2, cppunit=yes, cppunit=no; AC_MSG_RESULT([no. Unit and Integration
tests disabled])) 
 AM_CONDITIONAL(BUILD_CPPUNIT_TESTS, test x$cppunit = xyes)
@@ -103,7 +107,6 @@
     
   *) ## Unix configuration
 
-    AC_CHECK_FUNCS([ioctl select])
     AC_CHECK_LIB(pthread, pthread_create,[have_pthread="yes"],
                 AC_MSG_ERROR([libpthread not found!]))
 

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?view=diff&rev=479374&r1=479373&r2=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Sun Nov 26 08:27:08
2006
@@ -66,6 +66,7 @@
     activemq/transport/TcpTransportFactory.cpp \
     activemq/util/StringTokenizer.cpp \
     activemq/util/Guid.cpp \
+    activemq/util/Date.cpp \
     activemq/util/Math.cpp
 
 h_sources = \
@@ -222,6 +223,7 @@
     activemq/util/Boolean.h \
     activemq/util/StringTokenizer.h \
     activemq/util/Queue.h \
+    activemq/util/Date.h \
     activemq/util/Math.h \
     cms/DeliveryMode.h \
     cms/TemporaryQueue.h \

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h?view=diff&rev=479374&r1=479373&r2=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h Sun
Nov 26 08:27:08 2006
@@ -25,7 +25,7 @@
 #if defined(HAVE_CONFIG_H) 
 
 	// config.h is generated by the ./configure script and it only 
-	// used by unix like systems (includeing cygwin)
+	// used by unix like systems (including cygwin)
 	#include <config.h>
 
 
@@ -40,6 +40,8 @@
 		#define HAVE_RPCDCE_H
 		#define HAVE_WINSOCK2_H
         #define HAVE_STRUCT_ADDRINFO
+        #define HAVE_SYS_TIMEB_H
+        #define HAVE_FTIME
 	#elif defined( unix )
 		#define HAVE_UUID_UUID_H
 	#else

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.cpp?view=auto&rev=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.cpp Sun
Nov 26 08:27:08 2006
@@ -0,0 +1,55 @@
+/*
+ * 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 "Date.h"
+#include "Config.h"
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_SYS_TIMEB_H
+#include <sys/timeb.h>
+#endif
+
+#include <activemq/exceptions/UnsupportedOperationException.h>
+
+using namespace activemq::util;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+long long Date::getCurrentTimeMilliseconds(){
+    
+#if defined (HAVE_GETTIMEOFDAY)
+    timeval tv;
+    gettimeofday (&tv, NULL);
+    return (tv.tv_sec * 1000LL) + (tv.tv_usec / 1000LL);
+#elif defined (HAVE_TIME)
+    return time (NULL) * 1000LL;
+#elif defined (HAVE_FTIME)
+    struct timeb t;
+    ftime (&t);
+    return (t.time * 1000LL) + t.millitm;
+#else
+
+    // This platform doesn't support any of the standard time methods
+    // ... should never get here.
+    #error "No current time function available on the local platform";
+    
+#endif
+}
+

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.h?view=auto&rev=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Date.h Sun Nov
26 08:27:08 2006
@@ -0,0 +1,128 @@
+/*
+ * 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 ACTIVEMQ_UTIL_DATE_H_
+#define ACTIVEMQ_UTIL_DATE_H_
+
+namespace activemq{
+namespace util{
+    
+    /**
+     * Wrapper class around a time value in milliseconds.  This
+     * class is comparable to Java's java.util.Date class.
+     */
+    class Date
+    {
+    private:
+    
+        /**
+         * The underlying time value in millisecondsĀ§
+         */
+        long long time;
+        
+    public:
+    
+        /**
+         * Default constructor - sets time to now.
+         */
+    	Date(){
+            time = getCurrentTimeMilliseconds();
+        }
+        
+        /**
+         * Constructs the date with a given time value.
+         * @param milliseconds The time in milliseconds;
+         */
+        Date( long long milliseconds ){
+            this->time = milliseconds;
+        }
+        
+        /**
+         * Copy constructor.
+         */
+        Date( const Date& source ){
+            (*this) = source;
+        }
+        
+    	virtual ~Date(){}
+        
+        /**
+         * Gets the underlying time.
+         * @return The underlying time value in milliseconds.
+         */
+        long long getTime() const{
+            return time;
+        }
+        
+        /**
+         * Sets the underlying time.
+         * @param milliseconds The underlying time value in
+         * milliseconds.
+         */
+        void setTime( long long milliseconds ){
+            this->time = milliseconds;
+        }
+        
+        /**
+         * Determines wether or not this date falls after the
+         * specified time.
+         * @param when The date to compare
+         * @return true if this date falls after when.
+         */
+        bool after( Date& when ) const{
+            return time > when.time;
+        }
+        
+        /**
+         * Determines wether or not this date falls before the
+         * specified time.
+         * @param when The date to compare
+         * @return true if this date falls before when.
+         */
+        bool before( Date& when ) const{
+            return time < when.time;
+        }
+        
+        /**
+         * Determines wether or not this date is equal to the
+         * specified time.
+         * @param when The date to compare
+         * @return true if this date is equal to when.
+         */
+        bool equals( Date& when ) const{
+            return time == when.time;
+        }
+        
+        /**
+         * Assignment operator.
+         */
+        Date& operator =( const Date& source ){
+            this->time = source.time;
+            return *this;
+        }
+        
+        /**
+         * Returns the current time in milliseconds.  Comparable
+         * to Java's System.currentTimeMillis method.
+         * @return The current time in milliseconds.
+         */
+        static long long getCurrentTimeMilliseconds();        
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_UTIL_DATE_H_*/

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?view=diff&rev=479374&r1=479373&r2=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Sun Nov 26 08:27:08
2006
@@ -64,6 +64,7 @@
   activemq/transport/TransportFactoryMapRegistrarTest.cpp \
   activemq/transport/TransportFactoryMapTest.cpp \
   activemq/util/BooleanTest.cpp \
+  activemq/util/DateTest.cpp \
   activemq/util/GuidTest.cpp \
   activemq/util/IntegerTest.cpp \
   activemq/util/LongTest.cpp \

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.cpp?view=auto&rev=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.cpp
(added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.cpp
Sun Nov 26 08:27:08 2006
@@ -0,0 +1,20 @@
+/*
+ * 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 "DateTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::DateTest );

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.h?view=auto&rev=479374
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/DateTest.h Sun
Nov 26 08:27:08 2006
@@ -0,0 +1,59 @@
+/*
+ * 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 _ACTIVEMQ_UTIL_DATETEST_H_
+#define _ACTIVEMQ_UTIL_DATETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/Date.h>
+#include <activemq/concurrent/Thread.h>
+
+namespace activemq{
+namespace util{
+    
+    class DateTest : public CppUnit::TestFixture 
+    {
+        CPPUNIT_TEST_SUITE( DateTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+     
+    public:
+    	DateTest(){};
+    	virtual ~DateTest(){};
+        
+        void test(){
+            
+            Date date1;
+            CPPUNIT_ASSERT( date1.getTime() != 0 );
+            
+            activemq::concurrent::Thread::sleep(10);
+            
+            Date date2;
+            CPPUNIT_ASSERT( date1.before(date2) == true );
+            CPPUNIT_ASSERT( date1.after(date2) == false );
+            
+            Date date3 = date1;
+            CPPUNIT_ASSERT( date1.equals( date3 ) == true );
+        }
+        
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_DATETEST_H_*/



Mime
View raw message