Beispiel #1
0
    def delete(self, robj):
        """
        Removes an object stored in the remote ObjectStore, and return a boolean
        status.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.delete(robj._ref))

        return response != None and response.reflection_response.status == Message.ReflectionResponse.SUCCESS
Beispiel #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)
Beispiel #3
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)
Beispiel #4
0
    def deleteAll(self):
        """
        Removes all objects stored in the remote ObjectStore.
        """

        response = self.sendAndReceive(ReflectionRequestFactory.deleteAll())

        if response is None:
            raise ReflectionException("expected a response to DELETE_ALL")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return True
        else:
            raise ReflectionException(response.reflection_response.errormessage)
Beispiel #5
0
    def setProperty(self, robj, property_name, value):
        """
        Sets a property on an object to a given value.
        """

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

        if response is None:
            raise ReflectionException("expected a response to SET_PROPERTY")
        elif response.reflection_response.status == Message.ReflectionResponse.SUCCESS:
            return response
        else:
            raise ReflectionException(response.reflection_response.errormessage)
Beispiel #6
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)
Beispiel #7
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)