001    /*
002      Copyright (C) 2001-2002 Renaud Pawlak <renaud@aopsys.com>
003    
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser Generaly Public License
015      along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
017    
018    package org.objectweb.jac.aspects.distribution;
019    
020    import org.objectweb.jac.core.*;
021    import org.objectweb.jac.aspects.distribution.consistency.*;
022    
023    /**
024     * This aspect component provides some consistency protocols that can
025     * be settled on a set of replicas.
026     *
027     * @see ConsistencyConf
028     * @author Renaud Pawlak
029     */
030    
031    public class ConsistencyAC extends AspectComponent {
032    
033       /**
034        * Adds a strong-push consistency protocol on a set of replicas
035        * called <code>wrappeeName</code>.
036        *
037        * <p>The classical use of this consistency protocol is that any
038        * replica forwards all the writing calls to all the replicas
039        * located on the hosts defined by the consistency.
040        *
041        * <p>It is called "push" since the replica pushes the data to the
042        * other replicas. Despite this strategy is the most curently used,
043        * other strong or weak consistency strategies can be implemented by
044        * other consistency protocols.
045        *
046        * @param wrappeeName the name of the object to be consistent
047        * @param methods a pointcut expression that defines the methods
048        * that will be pushed to the other replicas (generally the state
049        * modifiers -- use the MODIFIERS keyword in your expression)
050        * @param hosts the location of the replicas as a pointcut
051        * expression */
052    
053       public void addStrongPushConsistency(String wrappeeName,
054                                            String methods,
055                                            String hosts) {
056          pointcut(wrappeeName, ".*", methods,
057                   new StrongPushConsistencyWrapper(this,hosts),
058                   hosts, null);
059       }
060    
061       /**
062        * Adds a strong-pull consistency protocol on a set of replicas
063        * called <code>wrappeeName</code>.
064        *
065        * <p>On contrary to the push consistency, this protocol pulls the
066        * data from the other replicas. Indeed, each time a data is read
067        * and is not locally available, it is fetched from the known
068        * replicas.
069        *
070        * @param wrappeeName the name of the object to be consistent
071        * @param methods a pointcut expression that defines the methods
072        * that will be pulled from the other replicas (generally the state
073        * readers -- use the keyword ACCESSORS in your expression)
074        * @param hosts the location of the replicas as a pointcut
075        * expression */
076    
077       public void addStrongPullConsistency(String wrappeeName,
078                                            String methods,
079                                            String hosts) {
080          pointcut(wrappeeName, ".*", methods,
081                   new StrongPullConsistencyWrapper(this,hosts),
082                   hosts, null);
083       }
084    
085    }