final String name = def.getName();
try {
final Class adviceClass = ContextClassLoader.loadClass(adviceClassName);
final AbstractAdvice newAdvice = (AbstractAdvice)adviceClass.
getConstructor(new Class[]{}).
newInstance(new Object[]{});
int deploymentModel;
if (def.getDeploymentModel() == null || def.getDeploymentModel().equals("")) {
deploymentModel = DeploymentModel.PER_JVM;
}
else {
deploymentModel = DeploymentModel.getDeploymentModelAsInt(def.getDeploymentModel());
}
// TODO: use custom security to protect the [AbstractAspect.m_uuid] field from getting modified by the user, setting the field opens up for changes in other AspectWerkz system running in the same JVM
Field field = AbstractAdvice.class.getDeclaredField("m_uuid");
field.setAccessible(true);
field.set(newAdvice, uuid);
newAdvice.setName(def.getName());
newAdvice.setAdviceClass(adviceClass);
newAdvice.setDeploymentModel(deploymentModel);
// handle the parameters passed to the advice
for (Iterator it2 = def.getParameters().entrySet().iterator(); it2.hasNext();) {
Map.Entry entry = (Map.Entry)it2.next();
newAdvice.setParameter((String)entry.getKey(), (String)entry.getValue());
}
// create and set the container for the advice
newAdvice.setContainer(createAdviceContainer(newAdvice));
AspectWerkz.getSystem(uuid).register(name, newAdvice);
}
catch (ClassNotFoundException e) {
throw new DefinitionException(adviceClassName + " could not be found in classpath");