오히려 hackish 솔루션,하지만 그럼에도 불구하고 해결책 : 수동으로 클래스 경로에서 aop.xml
파일을로드하고 화면 클래스 이름 얻기 위해 구문 분석 :
final Enumeration<URL> urls =
getClass().getClassLoader().getResources("META-INF/aop.xml");
final Collection<String> aspectNames = new ArrayList<String>();
for (final URL url : urls)
{
final Stream xml = url.openStream();
final DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(false);
docBuilderFactory.setNamespaceAware(false);
final XPath xpath = XPathFactory.newInstance().newXPath();
final Document aspectXml = docBuilderFactory.newDocumentBuilder().parse(xml);
final XPathExpression selector = xpath.compile("//aspect/@name");
final NodeList matches =
(NodeList) selector.evaluate(aspectXml, XPathConstants.NODESET);
for (int i = 0; i < matches.getLength(); i++)
{
aspectNames.add(matches.item(i).getNodeValue());
}
}
는 그런 측면 인스턴스과 같이 가져올 수 있습니다
을
for (final String className : aspectNames)
{
final Class<?> aspectClass = Class.forName(className);
final Object aspect = Aspects.aspectOf(aspectClass);
// finally (!) do the initialisation on the aspect itself:
aspect.setLogService(logging);
}