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 2007/08/13 00:59:29 UTC
svn commit: r565194 - in
/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang: System.cpp
System.h
Author: tabish
Date: Sun Aug 12 15:59:28 2007
New Revision: 565194
URL: http://svn.apache.org/viewvc?view=rev&rev=565194
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Adding a System class
Modified:
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.cpp
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.h
Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.cpp?view=diff&rev=565194&r1=565193&r2=565194
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.cpp Sun Aug 12 15:59:28 2007
@@ -18,11 +18,13 @@
#include "System.h"
#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/util/Date.h>
#include <apr_errno.h>
#include <apr_env.h>
using namespace decaf;
using namespace decaf::lang;
+using namespace decaf::util;
using namespace decaf::internal;
using namespace decaf::lang::exceptions;
@@ -61,4 +63,30 @@
aprPool.cleanup();
return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void System::setenv( const std::string& name, const std::string& value )
+ throw ( lang::Exception ) {
+
+ apr_status_t result = APR_SUCCESS;
+
+ // Write the value, errors are thrown out as an exception
+ result = apr_env_set( name.c_str(), value.c_str(), aprPool.getAprPool() );
+ aprPool.cleanup();
+
+ if( result != APR_SUCCESS ) {
+
+ char buffer[256] = {0};
+
+ throw NullPointerException(
+ __FILE__, __LINE__,
+ "System::getenv - ",
+ apr_strerror( result, buffer, 255 ) );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long System::currentTimeMillis() {
+ return Date::getCurrentTimeMilliseconds();
}
Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.h?view=diff&rev=565194&r1=565193&r2=565194
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/System.h Sun Aug 12 15:59:28 2007
@@ -48,6 +48,20 @@
static std::string getenv( const std::string& name )
throw ( lang::Exception );
+ /**
+ * Sets the specified system property to the value given
+ * @param name - name of the env val to set
+ * @param value - value to assign to name
+ * @throws an Exception if an error occurs
+ */
+ static void setenv( const std::string& name, const std::string& value )
+ throw ( lang::Exception );
+
+ /**
+ * @returns the current system time in Milliseconds
+ */
+ static long long currentTimeMillis();
+
};
}}