Class AbstractBaseProxy<I,IP extends InvocationProxy>
java.lang.Object
com.sun.ts.tests.common.vehicle.none.proxy.AbstractBaseProxy<I,IP>
- Type Parameters:
I
- - The interface type of the proxy used to represent the test methodsIP
- - The invocation proxy type used to dispatch the method calls
- All Implemented Interfaces:
InvocationProxy<I>
,InvocationHandler
public abstract class AbstractBaseProxy<I,IP extends InvocationProxy>
extends Object
implements InvocationProxy<I>
An abstract base class for creating dynamic proxies used to dispatch method calls to a remote server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the dispatcher that handles the method calls.Utility method to get the generic type information of the proxy.Get the I.class type of the proxy interfaceReturns the invocation proxy class.Returns the last proxy instance created.Class<?>[]
Utility method to get the reified type arguments of the proxy.newProxy()
Creates a new proxy instance of the interface type I that is not bound to a specific dispatcher.Creates a new proxy instance of the interface type I that is bound to the direct dispatcher.Creates a new proxy instance of the interface type I that is bound to the servlet dispatcher.abstract RemoteStatus
Implemented by the IP class to dispatch the method call to the remote server.void
setDispatcher
(Function<Object[], RemoteStatus> dispatcher) Provide a custom dispatcher to handle the method calls.void
Optional setup method that can be overridden by subclasses to perform any necessary setup.void
setup
(String[] args, Properties props) Optional setup method that can be overridden by subclasses to perform any necessary setup.void
useDirectDispatcher
(Object testCase) Use the DirectDispatcher to handle the method calls.void
useServletDispatcher
(String host, String port) Use the ServletDispatcher to handle the method calls.
-
Constructor Details
-
AbstractBaseProxy
public AbstractBaseProxy()
-
-
Method Details
-
setup
Optional setup method that can be overridden by subclasses to perform any necessary setup.- Parameters:
args
- - the command line arguments
-
setup
Optional setup method that can be overridden by subclasses to perform any necessary setup.- Parameters:
args
- - the command line argumentsprops
- - test properties
-
runTest
Implemented by the IP class to dispatch the method call to the remote server.- Specified by:
runTest
in interfaceInvocationProxy<I>
- Parameters:
testName
- - a test method name- Returns:
- - the status of the test method result
-
newProxy
Creates a new proxy instance of the interface type I that is not bound to a specific dispatcher.- Returns:
- - a new proxy instance
-
newProxy
Creates a new proxy instance of the interface type I that is bound to the direct dispatcher. Useful for testing, but not tck tests.- Parameters:
testCase
- - the test case instance- Returns:
- - a new proxy instance
-
newProxy
Creates a new proxy instance of the interface type I that is bound to the servlet dispatcher.- Specified by:
newProxy
in interfaceInvocationProxy<I>
- Parameters:
host
- - servlet hostport
- - servlet port- Returns:
- - a new proxy instance
-
getLastProxy
Returns the last proxy instance created.- Returns:
- the last proxy instance
-
getInterfaceClass
Description copied from interface:InvocationProxy
Get the I.class type of the proxy interface- Specified by:
getInterfaceClass
in interfaceInvocationProxy<I>
- Returns:
- - the class type of the proxy interface
-
getInvocationProxyClass
Returns the invocation proxy class.- Returns:
- the invocation proxy class
-
getReifiedTypeArguments
Utility method to get the reified type arguments of the proxy.- Returns:
- [0] - the interface type, [1] - the proxy type
-
getGenericInfo
Utility method to get the generic type information of the proxy.- Returns:
- - a string representation of the generic type information
-
getDispatcher
Get the dispatcher that handles the method calls.- Returns:
- - the dispatcher
-
setDispatcher
Provide a custom dispatcher to handle the method calls.- Parameters:
dispatcher
- - a function that takes an array of objects and returns a RemoteStatus. The last element in the array is the test method name.
-
useDirectDispatcher
Use the DirectDispatcher to handle the method calls.- Parameters:
testCase
- - the test case instance
-
useServletDispatcher
Use the ServletDispatcher to handle the method calls.- Parameters:
host
- - servlet hostport
- - servlet port
-
invoke
- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- the proxy instance that the method was invoked onmethod
- theMethod
instance corresponding to the interface method invoked on the proxy instance.args
- an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, ornull
if interface method takes no arguments. This method handles the Object methods toString, hashCode, and equals. All other methods are dispatched to the dispatcher.- Returns:
- - the result of the method call
- Throws:
Throwable
- on failure
-