1 17 18 package org.objectweb.jac.aspects.distribution; 19 20 import java.io.Serializable ; 21 22 import org.objectweb.jac.core.*; 23 import org.objectweb.jac.core.dist.*; 24 import gnu.regexp.*; 25 import java.util.*; 26 27 44 45 public class DeploymentRule implements Serializable { 46 47 48 String type = ""; 49 50 52 RE nameRegexp; 53 54 56 RE contRegexp; 57 58 boolean state=false; 59 60 61 int knowledgeStyle; 62 63 64 String [] knowledgeGraph; 65 66 67 transient Hashtable treated = new Hashtable(); 68 69 AspectComponent ac; 70 71 83 84 public DeploymentRule (AspectComponent ac, 85 String type, 86 String nameRegexp, 87 String contRegexp, 88 boolean state ) { 89 this.ac = ac; 90 this.type = type; 91 try { 92 this.nameRegexp = new RE(nameRegexp); 93 this.contRegexp = new RE(contRegexp); 94 } catch (REException e) { 95 System.out.println("Regexp construction failed : "+e); 96 } 97 this.state = state; 98 } 99 100 106 107 public boolean isApplicableTo( Object candidate ) { 108 String name = NameRepository.get().getName( candidate ); 109 if ( name == null ) return false; 110 if ( nameRegexp.isMatch(name) ) { 111 return true; 112 } 113 return false; 114 } 115 116 121 122 public boolean isAppliedTo( Object object ) { 123 if (treated == null) treated = new Hashtable(); 124 if (treated.get( object ) != null) return true; 125 if( type.equals( "dynamic client-server" ) ) { 126 return true; 127 } 128 133 return false; 134 } 135 136 141 142 public void applyTo( Object object ) { 143 if (treated == null) treated = new Hashtable(); 144 treated.put( object, "" ); 145 Topology topology = Topology.getPartialTopology( contRegexp ); 146 147 Deployment dep = new Deployment(ac,topology); 148 149 if( state ) { 150 dep.replicate( object ); 151 } else { 152 dep.replicateStruct( object ); 153 } 154 } 155 156 161 162 public String getType() { 163 return type; 164 } 165 166 } 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | Popular Tags |