You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2010/04/02 00:33:10 UTC
svn commit: r930116 - in
/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context:
AbstractExecutionContext.java ExecutionContext.java ThreadContext.java
Author: adrianc
Date: Thu Apr 1 22:33:10 2010
New Revision: 930116
URL: http://svn.apache.org/viewvc?rev=930116&view=rev
Log:
Small change to ExecutionContext API - get/set a Currency instance instead of a currency code.
Modified:
ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/AbstractExecutionContext.java
ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
Modified: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/AbstractExecutionContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/AbstractExecutionContext.java?rev=930116&r1=930115&r2=930116&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/AbstractExecutionContext.java (original)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/AbstractExecutionContext.java Thu Apr 1 22:33:10 2010
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.api.context;
+import java.util.Currency;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@@ -34,7 +35,7 @@ public abstract class AbstractExecutionC
public static final String module = AbstractExecutionContext.class.getName();
protected final FastList<ExecutionArtifact> artifactStack = FastList.newInstance();
- protected String currencyUom = null;
+ protected Currency currency = null;
protected Locale locale = Locale.getDefault();
protected TimeZone timeZone = TimeZone.getDefault();
protected final Map<String, Object> properties;
@@ -61,8 +62,16 @@ public abstract class AbstractExecutionC
super.finalize();
}
- public String getCurrencyUom() {
- return this.currencyUom;
+ public Currency getCurrency() {
+ if (this.currency == null) {
+ this.currency = getDefaultCurrency();
+ }
+ return this.currency;
+ }
+
+ protected Currency getDefaultCurrency() {
+ String currencyCode = UtilProperties.getPropertyValue("general", "currency.uom.id.default");
+ return Currency.getInstance(currencyCode);
}
public ArtifactPath getExecutionPath() {
@@ -141,15 +150,15 @@ public abstract class AbstractExecutionC
Debug.logInfo("Resetting ExecutionContext", module);
}
this.artifactStack.clear();
- this.currencyUom = "";
+ this.currency = getDefaultCurrency();
this.locale = Locale.getDefault();
this.properties.clear();
this.timeZone = TimeZone.getDefault();
}
- public void setCurrencyUom(String currencyUom) {
- if (currencyUom != null) {
- this.currencyUom = currencyUom;
+ public void setCurrency(Currency currency) {
+ if (currency != null) {
+ this.currency = currency;
}
}
Modified: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java?rev=930116&r1=930115&r2=930116&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java (original)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java Thu Apr 1 22:33:10 2010
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.api.context;
+import java.util.Currency;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@@ -58,11 +59,11 @@ public interface ExecutionContext {
*/
AccessController getAccessController();
- /** Returns the currency unit of measure.
+ /** Returns the current currency.
*
- * @return The ISO currency code
+ * @return The current currency
*/
- String getCurrencyUom();
+ Currency getCurrency();
/** Returns the current execution path.
*
@@ -146,11 +147,11 @@ public interface ExecutionContext {
*/
void runUnprotected();
- /** Sets the currency unit of measure.
+ /** Sets the current currency.
*
- * @param currencyUom The ISO currency code
+ * @param currency The current currency
*/
- void setCurrencyUom(String currencyUom);
+ void setCurrency(Currency currency);
/** Sets the current <code>Locale</code>.
*
Modified: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java?rev=930116&r1=930115&r2=930116&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java (original)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java Thu Apr 1 22:33:10 2010
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.api.context;
+import java.util.Currency;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -51,8 +52,8 @@ public class ThreadContext {
return executionContext.get().getAccessController();
}
- public static String getCurrencyUom() {
- return executionContext.get().getCurrencyUom();
+ public static Currency getCurrency() {
+ return executionContext.get().getCurrency();
}
public static ArtifactPath getExecutionPath() {
@@ -119,8 +120,8 @@ public class ThreadContext {
executionContext.get().runUnprotected();
}
- public static void setCurrencyUom(String currencyUom) {
- executionContext.get().setCurrencyUom(currencyUom);
+ public static void setCurrency(Currency currency) {
+ executionContext.get().setCurrency(currency);
}
public static void setLocale(Locale locale) {