KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > distribution > ConsistencyAC


1 /*
2   Copyright (C) 2001-2002 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser Generaly Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.distribution;
19
20 import org.objectweb.jac.core.*;
21 import org.objectweb.jac.aspects.distribution.consistency.*;
22
23 /**
24  * This aspect component provides some consistency protocols that can
25  * be settled on a set of replicas.
26  *
27  * @see ConsistencyConf
28  * @author Renaud Pawlak
29  */

30
31 public class ConsistencyAC extends AspectComponent {
32
33    /**
34     * Adds a strong-push consistency protocol on a set of replicas
35     * called <code>wrappeeName</code>.
36     *
37     * <p>The classical use of this consistency protocol is that any
38     * replica forwards all the writing calls to all the replicas
39     * located on the hosts defined by the consistency.
40     *
41     * <p>It is called "push" since the replica pushes the data to the
42     * other replicas. Despite this strategy is the most curently used,
43     * other strong or weak consistency strategies can be implemented by
44     * other consistency protocols.
45     *
46     * @param wrappeeName the name of the object to be consistent
47     * @param methods a pointcut expression that defines the methods
48     * that will be pushed to the other replicas (generally the state
49     * modifiers -- use the MODIFIERS keyword in your expression)
50     * @param hosts the location of the replicas as a pointcut
51     * expression */

52
53    public void addStrongPushConsistency(String JavaDoc wrappeeName,
54                                         String JavaDoc methods,
55                                         String JavaDoc hosts) {
56       pointcut(wrappeeName, ".*", methods,
57                new StrongPushConsistencyWrapper(this,hosts),
58                hosts, null);
59    }
60
61    /**
62     * Adds a strong-pull consistency protocol on a set of replicas
63     * called <code>wrappeeName</code>.
64     *
65     * <p>On contrary to the push consistency, this protocol pulls the
66     * data from the other replicas. Indeed, each time a data is read
67     * and is not locally available, it is fetched from the known
68     * replicas.
69     *
70     * @param wrappeeName the name of the object to be consistent
71     * @param methods a pointcut expression that defines the methods
72     * that will be pulled from the other replicas (generally the state
73     * readers -- use the keyword ACCESSORS in your expression)
74     * @param hosts the location of the replicas as a pointcut
75     * expression */

76
77    public void addStrongPullConsistency(String JavaDoc wrappeeName,
78                                         String JavaDoc methods,
79                                         String JavaDoc hosts) {
80       pointcut(wrappeeName, ".*", methods,
81                new StrongPullConsistencyWrapper(this,hosts),
82                hosts, null);
83    }
84
85 }
86
Popular Tags