diff --git a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java index e358cbb9db..87b374eae3 100644 --- a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java +++ b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java @@ -53,7 +53,7 @@ public class AxisBindingMessage extends AxisDescription { private boolean fault = false; private volatile Policy effectivePolicy = null; - private volatile Date lastPolicyCalculatedTime = null; + private volatile OpaqueInstant lastPolicyCalculatedTime = null; public boolean isFault() { return fault; @@ -225,7 +225,7 @@ public Policy getEffectivePolicy() { synchronized (this) { if (lastPolicyCalculatedTime == null || isPolicyUpdated()) { effectivePolicy = calculateEffectivePolicy(); - lastPolicyCalculatedTime = new Date(); + lastPolicyCalculatedTime = new OpaqueInstant(); } } } diff --git a/modules/kernel/src/org/apache/axis2/description/AxisMessage.java b/modules/kernel/src/org/apache/axis2/description/AxisMessage.java index f7a1d072a1..eb8d85c056 100644 --- a/modules/kernel/src/org/apache/axis2/description/AxisMessage.java +++ b/modules/kernel/src/org/apache/axis2/description/AxisMessage.java @@ -37,7 +37,6 @@ import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.List; @@ -67,7 +66,7 @@ public class AxisMessage extends AxisDescription { private boolean wrapped = true; private volatile Policy effectivePolicy = null; - private volatile Date lastPolicyCalculatedTime = null; + private volatile OpaqueInstant lastPolicyCalculatedTime = null; public String getMessagePartName() { return messagePartName; @@ -241,7 +240,7 @@ public Policy getEffectivePolicy() { synchronized (this) { if (lastPolicyCalculatedTime == null || isPolicyUpdated()) { effectivePolicy = calculateEffectivePolicy(); - lastPolicyCalculatedTime = new Date(); + lastPolicyCalculatedTime = new OpaqueInstant(); } } } diff --git a/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java b/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java new file mode 100644 index 0000000000..b28e02462c --- /dev/null +++ b/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java @@ -0,0 +1,35 @@ +/* + * 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. + */ +package org.apache.axis2.description; + +import java.util.concurrent.atomic.AtomicInteger; + +public final class OpaqueInstant { + private static final AtomicInteger nextSequence = new AtomicInteger(); + + private final int sequence; + + public OpaqueInstant() { + sequence = nextSequence.getAndIncrement(); + } + + public boolean after(OpaqueInstant when) { + return sequence > when.sequence; + } +} diff --git a/modules/kernel/src/org/apache/axis2/description/PolicySubject.java b/modules/kernel/src/org/apache/axis2/description/PolicySubject.java index 49e0b59969..3bcaab0230 100644 --- a/modules/kernel/src/org/apache/axis2/description/PolicySubject.java +++ b/modules/kernel/src/org/apache/axis2/description/PolicySubject.java @@ -25,13 +25,12 @@ import org.apache.neethi.PolicyReference; import java.util.Collection; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class PolicySubject { - private Date lastUpdatedTime = new Date(); + private OpaqueInstant lastUpdatedTime = new OpaqueInstant(); private ConcurrentHashMap attachedPolicyComponents = new ConcurrentHashMap(); @@ -49,7 +48,7 @@ public void attachPolicy(Policy policy) { public void attachPolicyReference(PolicyReference reference) { attachedPolicyComponents.put(reference.getURI(), reference); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void attachPolicyComponents(List policyComponents) { @@ -74,7 +73,7 @@ public void attachPolicyComponent(PolicyComponent policyComponent) { public void attachPolicyComponent(String key, PolicyComponent policyComponent) { attachedPolicyComponents.put(key, policyComponent); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public PolicyComponent getAttachedPolicyComponent(String key) { @@ -94,24 +93,24 @@ public void updatePolicy(Policy policy) { "policy doesn't have a name or an id "); } attachedPolicyComponents.put(key, policy); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void detachPolicyComponent(String key) { attachedPolicyComponents.remove(key); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void clear() { attachedPolicyComponents.clear(); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } - public Date getLastUpdatedTime() { + public OpaqueInstant getLastUpdatedTime() { return lastUpdatedTime; } - public void setLastUpdatedTime(Date lastUpdatedTime) { + public void setLastUpdatedTime(OpaqueInstant lastUpdatedTime) { this.lastUpdatedTime = lastUpdatedTime; } }