List of usage examples for org.springframework.aop.framework ProxyFactoryBean setBeanClassLoader
@Override public void setBeanClassLoader(ClassLoader classLoader)
From source file:org.codehaus.mojo.hibernate3.HibernateExporterMojo.java
/** * Builds a proxy that will respect any configured processor instance if configured. This should only be called on subclasses that end up generated java classes. * * @param delegate the original Exporter * @return an Exporter proxy that will correctly give the processor objects a chance to run after the delegate exporters' start() method's been called. *///from w w w .j a v a 2 s. c o m protected Exporter buildProcessorAwareExporter(final Exporter delegate) { MethodInterceptor interceptor = new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); Object[] objects = invocation.getArguments(); Object result; try { result = method.invoke(delegate, objects); if (method.getName().contains("start")) { handleComposites(); handleProcessor(); } return result; } catch (Throwable throwable) { getLog().error(throwable); } return null; } }; ProxyFactoryBean bean = new ProxyFactoryBean(); bean.addAdvice(interceptor); bean.setProxyTargetClass(true); bean.setBeanClassLoader(delegate.getClass().getClassLoader()); bean.setAutodetectInterfaces(true); bean.setTarget(delegate); return (Exporter) bean.getObject(); }