public interface RemoteFactory
HTTP
protocol, both plain text and secure variants.
In sample code, creates a Java proxy for weather service deployed on http://weather.com/
. When invoke a
method, proxy takes care to create HTTP-RMI transaction that deals with arguments and value marshaling. This way a
remote instance is used as a local one.
interface WeatherService { Weather getCurrentWeather(double latitude, double longitude); } ... String implementationURL = "http://weather.com/"; WeatherService service = remoteFactory.getInstance(implementationURL, WeatherService.class); Weather weather = service.getCurrentWeather(47.1569, 27.5903);Implementation will return a Java proxy instance able to send class and method names and invocation arguments to remote server and to retrieve returned value, using the protocol requested by given URL. It is not required to perform URL validity and is caller responsibility to ensure given implementation context URL points to and existing remote class and that remote class actually implements given interface.
Modifier and Type | Method and Description |
---|---|
<T> T |
getRemoteInstance(String implementationURL,
Class<? super T> interfaceClass)
Create a Java proxy for a remote deployed class located at specified URL.
|
<T> T getRemoteInstance(String implementationURL, Class<? super T> interfaceClass) throws UnsupportedProtocolException
Implementation is not required to perform URL validity tests and is caller responsibility to ensure given URL value points to and existing remote class. This factory method just create local proxy instance and does not throw exceptions. If given arguments does not match an existing remote class there will be exception on actual remote method invocation.
T
- instance type.implementationURL
- remote class context URL,interfaceClass
- interface implemented by remote class.UnsupportedProtocolException
- if URL protocol is not supported.Copyright © 2018. All rights reserved.