public <T> T bind( Class<T> bindClass, URL url, ConnectionInfo connectionInfo )
throws BindingException
{
if ( !bindClass.isInterface() )
{
throw new BindingException( "Class " + bindClass.getName() + "is not an interface" );
}
ServiceObject serviceObject = bindClass.getAnnotation( ServiceObject.class );
if ( serviceObject == null )
{
throw new BindingException( "Could not find ServiceObject annotation on " + bindClass.getName() );
}
final XmlRpcClient client = getXmlRpcClient( url, connectionInfo );
XmlRpcInvocationHandler handler = new XmlRpcInvocationHandler( new XmlRpcClientProvider()
{
public Object execute( String serviceName, String methodName, Vector arguments )
throws BindingException
{
try
{
return client.execute( serviceName + "." + methodName, arguments );
}
catch ( XmlRpcException e )
{
throw new BindingException( e );
}
}
} );
return (T) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[]{bindClass}, handler );