[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Problems with generic aspects

Hi,

Are you sure it's a bug? 

Is there any possibility of being something something else in my code?

Best regards,

Nuno


Look below

Concrete:

package section3.raytracer;

public aspect ReplicateConcrete extends Replicate<JGFRayTracerBench> {


protected pointcut broadcast(JGFRayTracerBench servant) : call(* *.setScene(..)) && target(servant) /*within*/;
}

Abstract:

package section3.raytracer;

import java.util.HashMap;
import java.util.Vector;

public abstract aspect Replicate<T> {
int numberOfWorkers=4;
HashMap <T,Vector<T>> aggregates = new HashMap<T,Vector<T>>();
HashMap <Integer,T> id = new HashMap<Integer,T>();
boolean debug = true;

protected pointcut broadcast(T servant);  // broadcast funtion

protected pointcut scatter(T servant, Object arg); // scatter function

protected pointcut reduce(T servant); // reduction function
T around() : call( T.new() ) {
if (debug) System.out.println("Number of workers: " + numberOfWorkers);
System.out.println("Creating aggregate of " + numberOfWorkers + " workers");
Vector <T>elements = new Vector<T>();
T target = proceed(); // create aggregate representative
setId(0,target);
elements.add(target);
for(int i=1; i<numberOfWorkers; i++) {
System.out.println("Creating aggregate worker number: " + i);
T targetn = proceed();
//T targetn = new T();
if (debug) System.out.println("Memory address for worker with id " + i + ": " + targetn);
setId(i,targetn);
elements.add(targetn);
}
aggregates.put(target,elements);
return(target);
}
void around(T servant): broadcast(servant) {
if (debug) System.out.println("Broadcasting...");
for(int i=0; i<numberOfWorkers; i++) {
Vector<T> elements = aggregates.get(servant);
final T obj = elements.elementAt(i);
}
proceed(servant);
}
public Object getId(int i) {
return id.get(i);
}
public void setId(int i,T b) {
id.put(i,b);
}
}