Package com.sun.jini.proxy
Class ConstrainableProxyUtil
java.lang.Object
com.sun.jini.proxy.ConstrainableProxyUtil
A collection of utility methods for use in implementing constrainable proxies. This class cannot
be instantiated.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequivalentConstraints(MethodConstraints methodConstraints1, MethodConstraints methodConstraints2, Method[] mappings) Test to see if twoMethodConstraintsinstances are equivalent given a method-to-method mapping.static MethodConstraintstranslateConstraints(MethodConstraints methodConstraints, Method[] mappings) Creates aMethodConstraintsusing the constraints inmethodConstraints, but with the methods remapped according tomappings, where the first element of each pair of elements is mapped to the second.static voidverifyConsistentConstraints(MethodConstraints methodConstraints, Object proxy, Method[] mappings) Verify that an object,proxy, is an instance ofRemoteMethodControlitsMethodConstraintsare equivalent to anotherMethodConstraintsinstance,methodConstraintsonce a mapping has been applied.
-
Method Details
-
translateConstraints
public static MethodConstraints translateConstraints(MethodConstraints methodConstraints, Method[] mappings) Creates aMethodConstraintsusing the constraints inmethodConstraints, but with the methods remapped according tomappings, where the first element of each pair of elements is mapped to the second. For example, ifmethodConstraintsreturns constraintsC1for methodM1, and the elements of mappings are methodsM1andM2, then the resulting method constraints returnC1for methodM2.- Parameters:
methodConstraints- the method constraints whose methods should be translated, ornullfor empty constraintsmappings- the method mappings- Returns:
- the translated method constraints
- Throws:
NullPointerException- ifmappingsisnullor containsnullelementsIllegalArgumentException- ifmappingscontains an odd number of elements
-
equivalentConstraints
public static boolean equivalentConstraints(MethodConstraints methodConstraints1, MethodConstraints methodConstraints2, Method[] mappings) Test to see if twoMethodConstraintsinstances are equivalent given a method-to-method mapping. Only the constraints for methods that appear in the mapping are compared. The mapping is represented by an array,mappings, of 2nMethodobjects. For all values p less than n the constraints associated withmappings[2p]inmethodConstraints1are compared to the constraints associated withmappings[2p+1]inmethodConstraints2. If null is passed in for both instances they are considered equivalent.- Parameters:
methodConstraints1- the firstMethodConstraintsobject to compare.methodConstraints2- the secondMethodConstraintsobject to compare.mappings- the method-to-method mapping.- Returns:
trueif theMethodConstraintsinstances represent equivalent constraints, returnsfalseotherwise.- Throws:
NullPointerException- ifmappingisnullcontainsnullelements.IllegalArgumentException- ifmappingcontains an odd number of elements
-
verifyConsistentConstraints
public static void verifyConsistentConstraints(MethodConstraints methodConstraints, Object proxy, Method[] mappings) throws InvalidObjectException Verify that an object,proxy, is an instance ofRemoteMethodControlitsMethodConstraintsare equivalent to anotherMethodConstraintsinstance,methodConstraintsonce a mapping has been applied. Ifproxydoes not implementRemoteMethodControlor the associated constraints are not equivalent throw anInvalidObjectException. The mapping is represented by an array,mappings, of 2nMethodobjects. For all values p less than n the constraints associated withmappings[2p]inmethodConstraintsare compared to the constraints associated withmappings[2p+1]in theMethodConstraintsreturned byproxy.getConstraints. Will also return normally if bothmethodConstraintsand the value returned byproxy.getConstraintsarenull.- Parameters:
methodConstraints- the method constraintsproxyshould have.proxy- the proxy to test, must implementRemoteMethodControl.mappings- the method to method mapping- Throws:
NullPointerException- ifmappingsorproxyisnullor ifmappingcontainsnullelementsIllegalArgumentException- ifmappingscontains an odd number of elementsInvalidObjectException- ifproxydoes not implementRemoteMethodControl, or if the constraints onproxyare not equivalent tomethodConstraints.
-