Author: dkulp
Date: Mon Sep 28 15:43:55 2009
New Revision: 819598
URL: http://svn.apache.org/viewvc?rev=819598&view=rev
Log:
[CXF-2036] Add a RetryStrategy
Patch from Dennis Kieselhorst applied
Added:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
(with props)
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java?rev=819598&r1=819597&r2=819598&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
Mon Sep 28 15:43:55 2009
@@ -49,6 +49,17 @@
* @return a List of alternate endpoints if available
*/
public List<Endpoint> getAlternateEndpoints(Exchange exchange) {
+ return getEndpoints(exchange, false);
+ }
+
+ /**
+ * Get the endpoints for this invocation.
+ *
+ * @param exchange the current Exchange
+ * @param acceptCandidatesWithSameAddress true to accept candidates with
the same address
+ * @return a List of alternate endpoints if available
+ */
+ protected List<Endpoint> getEndpoints(Exchange exchange, boolean
acceptCandidatesWithSameAddress) {
Endpoint endpoint = exchange.get(Endpoint.class);
Collection<ServiceInfo> services =
endpoint.getService().getServiceInfos();
QName currentBinding =
endpoint.getBinding().getBindingInfo().getName();
@@ -58,7 +69,7 @@
for (EndpointInfo candidate : candidates) {
QName candidateBinding = candidate.getBinding().getName();
if (candidateBinding.equals(currentBinding)) {
- if (!candidate.getAddress().equals(
+ if (acceptCandidatesWithSameAddress ||
!candidate.getAddress().equals(
endpoint.getEndpointInfo().getAddress())) {
Endpoint alternate =
endpoint.getService().getEndpoints().get(candidate.getName());
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java?rev=819598&r1=819597&r2=819598&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
Mon Sep 28 15:43:55 2009
@@ -195,7 +195,7 @@
* Check if the exchange is suitable for a failover.
*
* @param exchange the current Exchange
- * @return boolean true iff a failover should be attempted
+ * @return boolean true if a failover should be attempted
*/
private boolean requiresFailover(Exchange exchange) {
Message outMessage = exchange.getOutMessage();
@@ -249,7 +249,7 @@
requestContext.put(Message.ENDPOINT_ADDRESS,
getEndpoint().getEndpointInfo().getAddress());
requestContext.put("javax.xml.ws.service.endpoint.address",
- getEndpoint().getEndpointInfo().getAddress());
+ getEndpoint().getEndpointInfo().getAddress());
}
}
Added:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java?rev=819598&view=auto
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
(added)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
Mon Sep 28 15:43:55 2009
@@ -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.
+ */
+
+package org.apache.cxf.clustering;
+
+import java.util.List;
+
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+
+/**
+ * This strategy simply retries the invocation using the same Endpoint
(CXF-2036).
+ *
+ * @author Dennis Kieselhorst
+ *
+ */
+public class RetryStrategy extends SequentialStrategy {
+
+ /* (non-Javadoc)
+ * @see
org.apache.cxf.clustering.AbstractStaticFailoverStrategy#getAlternateEndpoints(
+ * org.apache.cxf.message.Exchange)
+ */
+ @Override
+ public List<Endpoint> getAlternateEndpoints(Exchange exchange) {
+ return getEndpoints(exchange, true);
+ }
+
+}
\ No newline at end of file
Propchange:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date