Ejemplo n.º 1
0
        def _java_constructor(self):
            name = self.java_name()
            service_qname = JavaService.java_qname(self)
            return """\
public %(name)s(final %(service_qname)s service) {
    this.service = service;
}""" % locals()
Ejemplo n.º 2
0
        def _java_constructor(self):
            name = self.java_name()
            service_qname = JavaService.java_qname(self)
            return """\
public %(name)s(final %(service_qname)s service) {
    this.service = service;
}""" % locals()
Ejemplo n.º 3
0
        def java_definitions(self):
            annotations = lpad("\n", "\n".join(self.java_annotations()))
            name = self.java_name()
            public_parameters = \
                ', '.join(parameter.java_parameter(final=True) for parameter in self.parameters)
            public_parameter_names = ', '.join(
                parameter.java_name() for parameter in self.parameters)
            parameter_validations = []
            request_type_name = self.java_request_type().java_name()
            service_qname = JavaService.java_qname(self.parent)
            for parameter in self.parameters:
                parameter_name = parameter.java_name()
                parameter_validate_method_name = parameter.java_validate_method_name(
                )
                parameter_validations.append(
                    "%(service_qname)s.Messages.%(request_type_name)s.DefaultConstructionValidator.getInstance().%(parameter_validate_method_name)s(%(parameter_name)s);"
                    % locals())
            if len(parameter_validations) > 0:
                parameter_validations = \
                    "\n".join(indent(' ' * 4, parameter_validations))
                validate_method_name = '_validate' + upper_camelize(
                    self.name) + 'Parameters'
                validate_method = lpad(
                    "\n\n", """\
protected void %(validate_method_name)s(%(public_parameters)s) {
%(parameter_validations)s
}""" % locals())
                validate_method_call = lpad(
                    "\n",
                    indent(
                        ' ' * 4, "%s(%s);" %
                        (validate_method_name, public_parameter_names)))
            else:
                validate_method = validate_method_call = ''
            delegation = \
                "delegate.%s(%s)" % (name, ', '.join(parameter.java_name() for parameter in self.parameters))
            if self.return_field is not None:
                response_type_name = self.java_response_type().java_name()
                return_field_validate_method_name = self.return_field.java_validate_method_name(
                )
                delegation = "return %(service_qname)s.Messages.%(response_type_name)s.DefaultConstructionValidator.getInstance().%(return_field_validate_method_name)s(%(delegation)s)" % locals(
                )
                return_type_name = self.return_field.type.java_qname()
            else:
                return_type_name = 'void'
            throws = \
                lpad(
                    ' throws ',
                    ', '.join(field.type.java_qname()
                               for field in self.throws)
                )

            return [
                """\
@Override%(annotations)s
public final %(return_type_name)s %(name)s(%(public_parameters)s)%(throws)s {%(validate_method_call)s
    %(delegation)s;
}%(validate_method)s
""" % locals()
            ] + self._java_delegating_definitions()
Ejemplo n.º 4
0
        def __repr__(self):
            name = self.java_name()
            methods = "\n\n".join(indent(' ' * 4, self._java_methods()))
            service_qname = JavaService.java_qname(self)

            return """\
public abstract class %(name)s implements %(service_qname)s {
%(methods)s
}""" % locals()
Ejemplo n.º 5
0
        def java_definitions(self):
            annotations = lpad("\n", "\n".join(self.java_annotations()))
            name = self.java_name()
            public_parameters = \
                ', '.join(parameter.java_parameter(final=True) for parameter in self.parameters)
            public_parameter_names = ', '.join(parameter.java_name() for parameter in self.parameters)
            parameter_validations = []
            request_type_name = self.java_request_type().java_name()
            service_qname = JavaService.java_qname(self.parent)
            for parameter in self.parameters:
                parameter_name = parameter.java_name()
                parameter_validate_method_name = parameter.java_validate_method_name()
                parameter_validations.append("%(service_qname)s.Messages.%(request_type_name)s.DefaultConstructionValidator.getInstance().%(parameter_validate_method_name)s(%(parameter_name)s);" % locals())
            if len(parameter_validations) > 0:
                parameter_validations = \
                    "\n".join(indent(' ' * 4, parameter_validations))
                validate_method_name = '_validate' + upper_camelize(self.name) + 'Parameters'
                validate_method = lpad("\n\n", """\
protected void %(validate_method_name)s(%(public_parameters)s) {
%(parameter_validations)s
}""" % locals())
                validate_method_call = lpad("\n", indent(' ' * 4, "%s(%s);" % (validate_method_name, public_parameter_names)))
            else:
                validate_method = validate_method_call = ''
            delegation = \
                "delegate.%s(%s)" % (name, ', '.join(parameter.java_name() for parameter in self.parameters))
            if self.return_field is not None:
                response_type_name = self.java_response_type().java_name()
                return_field_validate_method_name = self.return_field.java_validate_method_name()
                delegation = "return %(service_qname)s.Messages.%(response_type_name)s.DefaultConstructionValidator.getInstance().%(return_field_validate_method_name)s(%(delegation)s)" % locals()
                return_type_name = self.return_field.type.java_qname()
            else:
                return_type_name = 'void'
            throws = \
                lpad(
                    ' throws ',
                    ', '.join(field.type.java_qname()
                               for field in self.throws)
                )

            return ["""\
@Override%(annotations)s
public final %(return_type_name)s %(name)s(%(public_parameters)s)%(throws)s {%(validate_method_call)s
    %(delegation)s;
}%(validate_method)s
""" % locals()] + self._java_delegating_definitions()
        def java_repr(self):
            name = self.java_name()
            methods = "\n\n".join(indent(' ' * 4, self._java_methods()))
            delegate_name = "%s.%s.delegate" % (self._parent_document().java_package(), name)
            service_qname = JavaService.java_qname(self)

            return """\
@com.google.inject.Singleton
public class %(name)s implements %(service_qname)s {
    public final static com.google.inject.name.Named DELEGATE_NAME = com.google.inject.name.Names.named("%(delegate_name)s");

    @com.google.inject.Inject
    public %(name)s(@com.google.inject.name.Named("%(delegate_name)s") %(service_qname)s delegate) {
        this.delegate = com.google.common.base.Preconditions.checkNotNull(delegate);
    }

%(methods)s

    private final %(service_qname)s delegate;
}""" % locals()
Ejemplo n.º 7
0
        def java_repr(self):
            name = self.java_name()
            methods = "\n\n".join(indent(' ' * 4, self._java_methods()))
            delegate_name = "%s.%s.delegate" % (
                self._parent_document().java_package(), name)
            service_qname = JavaService.java_qname(self)

            return """\
@com.google.inject.Singleton
public class %(name)s implements %(service_qname)s {
    public final static com.google.inject.name.Named DELEGATE_NAME = com.google.inject.name.Names.named("%(delegate_name)s");

    @com.google.inject.Inject
    public %(name)s(@com.google.inject.name.Named("%(delegate_name)s") %(service_qname)s delegate) {
        this.delegate = com.google.common.base.Preconditions.checkNotNull(delegate);
    }

%(methods)s

    private final %(service_qname)s delegate;
}""" % locals()
        def java_definitions(self):
            annotations = lpad("\n", "\n".join(self.java_annotations()))
            name = self.java_name()
            public_parameters = \
                ', '.join(parameter.java_parameter(final=True) for parameter in self.parameters)
            public_parameter_names = ', '.join(parameter.java_name() for parameter in self.parameters)
            parameter_validations = []
            request_type_name = self.java_request_type().java_name()
            service_qname = JavaService.java_qname(self.parent)
            if len(self.parameters) > 0:
                validate_parameters = """
    %(service_qname)s.Messages.%(request_type_name)s.UncheckedValidator.validate(%(public_parameter_names)s);""" % locals()
            else:
                validate_parameters = ''
            delegation = \
                "delegate.%s(%s);" % (name, ', '.join(parameter.java_name() for parameter in self.parameters))
            if self.return_field is not None:
                response_type_name = self.java_response_type().java_name()
                return_field_validate_method_name = self.return_field.java_validate_method_name()
                return_type_name = self.return_field.type.java_qname()
                delegation = "final %(return_type_name)s __returnValue = %(delegation)s\n%(service_qname)s.Messages.%(response_type_name)s.UncheckedValidator.%(return_field_validate_method_name)s(__returnValue);\nreturn __returnValue;" % locals()
            else:
                return_type_name = 'void'
            delegation = indent(' ' * 4, delegation)
            throws = \
                lpad(
                    ' throws ',
                    ', '.join(field.type.java_qname()
                               for field in self.throws)
                )

            return ["""\
@Override%(annotations)s
public final %(return_type_name)s %(name)s(%(public_parameters)s)%(throws)s {%(validate_parameters)s
%(delegation)s
}
""" % locals()] + self._java_delegating_definitions()
Ejemplo n.º 9
0
        def __repr__(self):
            client_service_package = ''
            try:
                client_service_package = self._parent_document().namespace_by_scope(('gwt_client_java', 'java')).name + '.'
            except KeyError:
                pass
            client_service_qname = client_service_package + JavaService.java_name(self) + 'GwtClient'
            functions = \
                lpad("\n", "\n\n".join(indent(' ' * 4,
                    (repr(function) for function in self.functions)
                )))
            name = self.java_name()
            service_qname = JavaService.java_qname(self)
            return """\
@SuppressWarnings("serial")
@com.google.inject.Singleton
public final class %(name)s extends com.google.gwt.user.server.rpc.RemoteServiceServlet implements %(client_service_qname)s {
    @com.google.inject.Inject
    public %(name)s(final %(service_qname)s service) {
        this.service = service;
    }%(functions)s

    private final %(service_qname)s service;
}""" % locals()
Ejemplo n.º 10
0
 def _java_member_declarations(self):
     service_qname = JavaService.java_qname(self)
     return ["private final %(service_qname)s service;" % locals()]
Ejemplo n.º 11
0
 def _java_member_declarations(self):
     service_qname = JavaService.java_qname(self)
     return [
         "private final %(service_qname)s service;" % locals()
     ]