Changeset 656 for raptor-client


Ignore:
Timestamp:
04/07/11 23:27:17 (9 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/Endpoint.java

    r650 r656  
    3232 
    3333    private String serviceEndpoint; 
    34     private PushPolicy pushPolicy; 
     34    private List<PushPolicy> pushPolicies; 
    3535    private AttributeFilterPolicy attributeFilterPolicy; 
    3636 
     
    4343    } 
    4444 
    45     public void setPushPolicy(PushPolicy pushPolicy) { 
    46         this.pushPolicy = pushPolicy; 
    47     } 
    48  
    49     public PushPolicy getPushPolicy() { 
    50         return pushPolicy; 
    51     } 
    52  
    5345    public void setAttributeFilterPolicy(AttributeFilterPolicy attributeFilterPolicy) { 
    5446        this.attributeFilterPolicy = attributeFilterPolicy; 
     
    5951    } 
    6052 
    61      
     53        public void setPushPolicies(List<PushPolicy> pushPolicies) { 
     54                this.pushPolicies = pushPolicies; 
     55        } 
    6256 
    63  
     57        public List<PushPolicy> getPushPolicies() { 
     58                return pushPolicies; 
     59        } 
    6460 
    6561} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/EventReleaseEngine.java

    r654 r656  
    2424import java.util.Set; 
    2525 
     26import uk.ac.cardiff.raptor.attribute.filtering.AttributeFilterPolicy; 
    2627import uk.ac.cardiff.raptor.attribute.filtering.AttrributeFilterEngine; 
    2728import uk.ac.cardiff.raptor.remoting.client.sei.ServiceEndpointClient; 
     29import uk.ac.cardiff.raptor.remoting.policy.PushPolicy; 
    2830 
    2931import org.slf4j.Logger; 
     
    5961                int releaseCount = 0; 
    6062                for (Endpoint endpoint : endpointRegistry.getEndpoints()) { 
    61                         boolean shouldRelease = (endpoint.getPushPolicy().getPushOnOrAfterNoEntries() <= events.size()); 
     63                        boolean shouldRelease = shouldRelease(endpoint,events);//(endpoint.getPushPolicy().getPushOnOrAfterNoEntries() <= events.size()); 
    6264                        log.debug("Endpoint {}, should release {}", endpoint.getServiceEndpoint(), shouldRelease); 
    6365                        List<Event> filteredEntries = filterAttributes(endpoint, events); 
     
    8183                return releasedtoAll; 
    8284 
     85        } 
     86         
     87        /** 
     88         * Iterates through all push policies attached to the <code>endpoint</code> parameter 
     89         * to determine if events should be released to this endpoint 
     90         *  
     91         * @param endpoint the endpoint to evaluate the policy on 
     92         * @param events the events ready to be released. 
     93         * @return true iff at least one push policy evaluates to true, false otherwise 
     94         */ 
     95        private boolean shouldRelease(Endpoint endpoint, List<Event> events){ 
     96                boolean shouldRelease = false; 
     97                for (PushPolicy policy : endpoint.getPushPolicies()){ 
     98                        if (policy.evaluatePolicy(events)) 
     99                                shouldRelease = true; 
     100                }                
     101                return shouldRelease; 
    83102        } 
    84103 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/client/sei/impl/CxfServiceEndpointClient.java

    r654 r656  
    107107        } catch (SoapFault e) { 
    108108            log.error("Could not send events to endpoint [{}] -> {}", new Object[] { endpoint.getServiceEndpoint(), e.getMessage() }); 
    109             e.printStackTrace(); 
     109            //e.printStackTrace(); 
    110110            return false; 
    111111        } catch (Exception e) { 
    112112            log.error("Could not send events to endpoint [{}] -> {}", new Object[] { endpoint.getServiceEndpoint(), e.getMessage() }); 
    113             e.printStackTrace(); 
     113            //e.printStackTrace(); 
    114114            return false; 
    115115        } 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/policy/PushPolicy.java

    r595 r656  
    1919package uk.ac.cardiff.raptor.remoting.policy; 
    2020 
     21import java.util.List; 
     22 
     23import uk.ac.cardiff.model.event.Event; 
     24import uk.ac.cardiff.raptor.registry.Endpoint; 
     25 
    2126/** 
    2227 * @author philsmart 
    2328 * 
    2429 */ 
    25 public class PushPolicy { 
     30public abstract class PushPolicy { 
    2631 
    27     private int pushOnOrAfterNoEntries; 
    28  
    29     public void setPushOnOrAfterNoEntries(int pushOnOrAfterNoEntries) { 
    30         this.pushOnOrAfterNoEntries = pushOnOrAfterNoEntries; 
    31     } 
    32  
    33     public int getPushOnOrAfterNoEntries() { 
    34         return pushOnOrAfterNoEntries; 
    35     } 
     32    public abstract boolean evaluatePolicy(List<Event> events); 
    3633 
    3734 
Note: See TracChangeset for help on using the changeset viewer.