catch (ClassNotFoundException e) {
throw new RuntimeException(aspectClassName + " could not be found on classpath");
}
// create an instance of the aspect class
final Aspect aspect;
try {
aspect = (Aspect)aspectClass.newInstance();
}
catch (Exception e) {
throw new RuntimeException("could not create a new instance of aspect [" + aspectClassName + "], does the class inherit the [org.codehaus.aspectwerkz.attribdef.aspect.Aspect] class?");
}
int deploymentModel;
if (aspectDef.getDeploymentModel() == null || aspectDef.getDeploymentModel().equals("")) {
deploymentModel = DeploymentModel.PER_JVM;
}
else {
deploymentModel = DeploymentModel.getDeploymentModelAsInt(aspectDef.getDeploymentModel());
}
// set the parameters
Field field = Aspect.class.getDeclaredField("m_uuid");
field.setAccessible(true);
field.set(aspect, uuid);
aspect.___AW_setName(aspectDef.getName());
aspect.___AW_setAspectClass(aspectClass);
aspect.___AW_setDeploymentModel(deploymentModel);
aspect.___AW_setAspectDef(aspectDef);
for (Iterator it = parameters.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry)it.next();
aspect.___AW_setParameter((String)entry.getKey(), (String)entry.getValue());
}
// TODO: handle parameters for attribdef (needs attribute support)
// handle the parameters passed to the advice
// for (Iterator it2 = aspectDef.getParameters().entrySet().iterator(); it2.hasNext();) {
// Map.Entry entry = (Map.Entry)it2.next();
// aspect.setParameter((String)entry.getKey(), (String)entry.getValue());
// }
// create and set the container for the aspect
AspectContainer container = createAspectContainer(aspect);
if (container != null) {
aspect.___AW_setContainer(container);
}
else {
throw new DefinitionException("could not create aspect container for aspect [" + aspect.___AW_getName() + "]");
}
// register the aspect in the system
AspectMetaData aspectMetaData = new AspectMetaData(
uuid, aspectDef.getName(), deploymentModel