Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 public void pushNameResolver(NameResolver nameResolver) {
   nameResolvers.push(nameResolver);
 }
Exemplo n.º 3
0
 public NameResolver popNameResolver() {
   return nameResolvers.pop();
 }
Exemplo n.º 4
0
 public SpringVisitorFactory() {
   nameResolvers.push(new DefaultNameResolver());
 }