コード例 #1
0
 public Visitor findVisitorFromClassName(Object instance) {
   try {
     Class<Visitor> visitorClass = nameResolvers.peek().findVisitingClassFromClassName(instance);
     Object target = visitorClass.newInstance();
     if (target instanceof AbstractPatternVisitor) {
       ((AbstractPatternVisitor) target).setVisitorFactory(this);
     }
     ProxyFactory proxyFactory = new ProxyFactory();
     proxyFactory.addInterface(Visitor.class);
     proxyFactory.addAdvice(advice);
     proxyFactory.setTarget(target);
     return (Visitor) proxyFactory.getProxy(this.getClass().getClassLoader());
   } catch (Exception ex) {
     log.info(
         "Could not find visitor class for element named [{}]",
         instance.getClass()); // $NON-NLS-1$
     return new ExceptionThrowingVisitor(ex);
   }
 }
コード例 #2
0
 public void pushNameResolver(NameResolver nameResolver) {
   nameResolvers.push(nameResolver);
 }
コード例 #3
0
 public NameResolver popNameResolver() {
   return nameResolvers.pop();
 }
コード例 #4
0
 public SpringVisitorFactory() {
   nameResolvers.push(new DefaultNameResolver());
 }