Esempio n. 1
0
 /// <summary>
 /// Create a proxy for an interface of implementations of that interface using
 /// the given
 /// <see cref="FailoverProxyProvider{T}"/>
 /// and the same retry policy for each
 /// method in the interface.
 /// </summary>
 /// <param name="iface">the interface that the retry will implement</param>
 /// <param name="proxyProvider">provides implementation instances whose methods should be retried
 ///     </param>
 /// <param name="retryPolicy">the policy for retrying or failing over method call failures
 ///     </param>
 /// <returns>the retry proxy</returns>
 public static object Create <T>(FailoverProxyProvider <T> proxyProvider, RetryPolicy
                                 retryPolicy)
 {
     System.Type iface = typeof(T);
     return(Proxy.NewProxyInstance(proxyProvider.GetInterface().GetClassLoader(), new
                                   Type[] { iface }, new RetryInvocationHandler <T>(proxyProvider, retryPolicy)));
 }
Esempio n. 2
0
 /// <summary>
 /// Create a proxy for an interface of implementations of that interface using
 /// the given
 /// <see cref="FailoverProxyProvider{T}"/>
 /// and the a set of retry policies
 /// specified by method name. If no retry policy is defined for a method then a
 /// default of
 /// <see cref="RetryPolicies.TryOnceThenFail"/>
 /// is used.
 /// </summary>
 /// <param name="iface">the interface that the retry will implement</param>
 /// <param name="proxyProvider">provides implementation instances whose methods should be retried
 ///     </param>
 /// <param name="methodNameToPolicyMapa">map of method names to retry policies</param>
 /// <returns>the retry proxy</returns>
 public static object Create <T>(FailoverProxyProvider <T> proxyProvider, IDictionary
                                 <string, RetryPolicy> methodNameToPolicyMap, RetryPolicy defaultPolicy)
 {
     System.Type iface = typeof(T);
     return(Proxy.NewProxyInstance(proxyProvider.GetInterface().GetClassLoader(), new
                                   Type[] { iface }, new RetryInvocationHandler <T>(proxyProvider, defaultPolicy, methodNameToPolicyMap
                                                                                    )));
 }
 protected internal RetryInvocationHandler(FailoverProxyProvider <T> proxyProvider,
                                           RetryPolicy defaultPolicy, IDictionary <string, RetryPolicy> methodNameToPolicyMap
                                           )
 {
     this.proxyProvider         = proxyProvider;
     this.defaultPolicy         = defaultPolicy;
     this.methodNameToPolicyMap = methodNameToPolicyMap;
     this.currentProxy          = proxyProvider.GetProxy();
 }
 public LossyRetryInvocationHandler(int numToDrop, FailoverProxyProvider <T> proxyProvider
                                    , RetryPolicy retryPolicy)
     : base(proxyProvider, retryPolicy)
 {
     this.numToDrop = numToDrop;
 }
 protected internal RetryInvocationHandler(FailoverProxyProvider <T> proxyProvider,
                                           RetryPolicy retryPolicy)
     : this(proxyProvider, retryPolicy, Collections.EmptyMap <string, RetryPolicy
                                                              >())
 {
 }