private static DeploymentAspect parseDeploymentAspect(XMLStreamReader reader, ClassLoader loader) throws XMLStreamException {
String deploymentAspectClass = reader.getAttributeValue(null, CLASS);
if (deploymentAspectClass == null) {
throw new IllegalStateException("Could not find class attribute for deployment aspect!");
}
DeploymentAspect deploymentAspect = null;
try {
@SuppressWarnings("unchecked")
Class<? extends DeploymentAspect> clazz = (Class<? extends DeploymentAspect>) Class.forName(deploymentAspectClass, true, loader);
ClassLoader orig = getContextClassLoader();
try {
setContextClassLoader(loader);
deploymentAspect = clazz.newInstance();
} finally {
setContextClassLoader(orig);
}
} catch (Exception e) {
throw new IllegalStateException("Could not create a deploymeny aspect of class: " + deploymentAspectClass, e);
}
String priority = reader.getAttributeValue(null, PRIORITY);
if (priority != null) {
deploymentAspect.setRelativeOrder(Integer.parseInt(priority.trim()));
}
while (reader.hasNext()) {
switch (reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT: {
if (match(reader, NS, DEPLOYMENT_ASPECT)) {