Пример #1
0
    def getProperty(self, robj, property_name):
        """
        Reads a property from an object, and returns the value.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.getProperty(robj._ref, property_name))

        if response is None:
            raise ReflectionException("expected a response to GET_PROPERTY")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return ReflectedType.fromArgument(response.reflection_response.result, reflector=self)
        else:
            raise ReflectionException(response.reflection_response.errormessage)
Пример #2
0
    def invoke(self, robj, method, *args):
        """
        Invokes a method on an object, and returns the return value.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.invoke(robj._ref, method).setArguments(args))

        if response is None:
            raise ReflectionException("expected a response to INVOKE")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return ReflectedType.fromArgument(response.reflection_response.result, reflector=self)
        else:
            raise ReflectionException(response.reflection_response.errormessage)
Пример #3
0
    def resolve(self, class_name):
        """
        Resolves a Java class, given its fully qualified name, and returns a
        ReflectedObject that can be used to instantiate it with #construct.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.resolve(class_name))

        if response is None:
            raise ReflectionException("expected a response to RESOLVE")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return ReflectedType.fromArgument(response.reflection_response.result, reflector=self)
        else:
            raise ReflectionException(response.reflection_response.errormessage)
Пример #4
0
    def construct(self, robj, *args):
        """
        Constructs a new instance of a class, with optional arguments, and
        returns the object instance.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.construct(robj._ref).setArguments(args))
        
        if response is None:
            raise ReflectionException("expected a response to CONSTRUCT")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return ReflectedType.fromArgument(response.reflection_response.result, reflector=self)
        else:
            raise ReflectionException(response.reflection_response.errormessage)