/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.aspects.asynch;

import org.jboss.aop.proxy.ClassProxy;
import org.jboss.aop.proxy.ClassProxyFactory;
import org.jboss.aop.proxy.ProxyMixin;
import org.jboss.aspects.remoting.Remoting;
import org.jboss.remoting.InvokerLocator;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.1.8.3 $
 */
public class AsynchRemoting
{
   public static ClassProxy createRemoteProxy(Object objectId, Class clazz, InvokerLocator locator)
   throws Exception
   {
      AsynchMixin mixin = new AsynchMixin();
      AsynchProxyInterceptor interceptor = new AsynchProxyInterceptor(mixin);
      Class[] mixInterfaces = {AsynchProvider.class};
      ProxyMixin[] mixins = {new ProxyMixin(mixin, mixInterfaces)};
      ClassProxy proxy = ClassProxyFactory.newInstance(clazz, mixins);
      proxy._getInstanceAdvisor().insertInterceptor(interceptor);
      Remoting.makeRemotable(proxy, locator, objectId);
      return proxy;
   }

}
