apache-xmlrpc-3.1.3-src/ 40755 0 0 0 11333312072 12054 5ustar 0 0 apache-xmlrpc-3.1.3-src/.settings/ 40755 0 0 0 11333307163 13777 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/ 40755 0 0 0 11333312402 13327 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/.settings/ 40755 0 0 0 11333307170 15253 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/ 40755 0 0 0 11333307163 14126 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/ 40755 0 0 0 11333307165 15054 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/ 40755 0 0 0 11333307165 20662 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/ 40755 0 0 0 11333307166 21452 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/apache/ 40755 0 0 0 11333307167 22674 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/apache/xmlrpc/ 40755 0 0 0 11333307170 24173 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/apache/xmlrpc/client/ 40755 0 0 0 11333307170 25451 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/ 40755 0 0 0 11333307163 15773 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/ 40755 0 0 0 11333307163 16562 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/ 40755 0 0 0 11333307164 20004 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/ 40755 0 0 0 11333307164 21311 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/ 40755 0 0 0 11333307165 22570 5ustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/util/ 40755 0 0 0 11333307165 23545 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/ 40755 0 0 0 11333312306 13344 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/.settings/ 40755 0 0 0 11333307162 15266 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/ 40755 0 0 0 11333307156 14142 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/ 40755 0 0 0 11333307156 15066 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/ 40755 0 0 0 11333307156 16007 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/ 40755 0 0 0 11333307156 16576 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/ 40755 0 0 0 11333307156 20017 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/ 40755 0 0 0 11333307162 21321 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/ 40755 0 0 0 11333307157 22615 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/jaxb/ 40755 0 0 0 11333307157 22251 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/ 40755 0 0 0 11333307161 22614 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ 40755 0 0 0 11333307160 23470 5ustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/ 40755 0 0 0 11333307162 22276 5ustar 0 0 apache-xmlrpc-3.1.3-src/dist/ 40755 0 0 0 11333312567 13030 5ustar 0 0 apache-xmlrpc-3.1.3-src/dist/.settings/ 40755 0 0 0 11333307146 14743 5ustar 0 0 apache-xmlrpc-3.1.3-src/dist/src/ 40755 0 0 0 11333307146 13614 5ustar 0 0 apache-xmlrpc-3.1.3-src/dist/src/main/ 40755 0 0 0 11333307146 14540 5ustar 0 0 apache-xmlrpc-3.1.3-src/dist/src/main/assembly/ 40755 0 0 0 11333307146 16357 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/ 40755 0 0 0 11333312465 13370 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/.settings/ 40755 0 0 0 11333307154 15305 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/ 40755 0 0 0 11333307151 14153 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/ 40755 0 0 0 11333307151 15077 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/ 40755 0 0 0 11333307152 16021 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/ 40755 0 0 0 11333307152 16610 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/ 40755 0 0 0 11333307152 20031 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/ 40755 0 0 0 11333307153 21337 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/ 40755 0 0 0 11333307152 23116 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/ 40755 0 0 0 11333307153 22645 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ 40755 0 0 0 11333307153 23343 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/ 40755 0 0 0 11333307150 15131 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/ 40755 0 0 0 11333307147 16060 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/org/ 40755 0 0 0 11333307147 16647 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/ 40755 0 0 0 11333307147 20070 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/ 40755 0 0 0 11333307147 21375 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ 40755 0 0 0 11333307147 22354 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/ 40755 0 0 0 11333307150 17143 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/ 40755 0 0 0 11333307150 17732 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/ 40755 0 0 0 11333307150 21153 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/ 40755 0 0 0 11333307151 22461 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/ 40755 0 0 0 11333307151 23440 5ustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/webserver/ 40755 0 0 0 11333307151 24465 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/ 40755 0 0 0 11333307155 12651 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/changes/ 40755 0 0 0 11333307155 14261 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/main/ 40755 0 0 0 11333307154 13574 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/site/ 40755 0 0 0 11333307155 13615 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/site/apt/ 40755 0 0 0 11333307154 14400 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/site/fml/ 40755 0 0 0 11333307155 14373 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/site/xdoc/ 40755 0 0 0 11333307154 14551 5ustar 0 0 apache-xmlrpc-3.1.3-src/src/site/xdoc/images/ 40755 0 0 0 11333307155 16017 5ustar 0 0 apache-xmlrpc-3.1.3-src/.classpath100644 0 0 1672 11333307171 14146 0ustar 0 0 apache-xmlrpc-3.1.3-src/.project100644 0 0 1641 11333307171 13626 0ustar 0 0 ws-xmlrpc-3.1 Apache XML-RPC is a Java implementation of XML-RPC, a popular protocol that uses XML over HTTP to implement remote procedure calls. Compared to SOAP, or JAX-RPC, it is stable, much simpler and easier to handle. Version 3 of Apache XML-RPC introduces several important vendor extensions over the original XML-RPC specification. org.eclipse.jdt.core.javabuilder org.maven.ide.eclipse.maven2Builder org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature apache-xmlrpc-3.1.3-src/.settings/org.eclipse.jdt.core.prefs100644 0 0 65004 11333307163 21103 0ustar 0 0 #Thu Feb 04 11:03:55 CET 2010 eclipse.preferences.version=1 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.3 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false org.eclipse.jdt.core.formatter.comment.format_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=80 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false apache-xmlrpc-3.1.3-src/.settings/org.eclipse.jdt.ui.prefs100644 0 0 301 11333307163 20515 0ustar 0 0 #Sat Oct 27 20:52:31 CEST 2007 eclipse.preferences.version=1 formatter_profile=_ws-xmlrpc formatter_settings_version=10 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true apache-xmlrpc-3.1.3-src/.settings/org.maven.ide.eclipse.prefs100644 0 0 417 11333307163 21176 0ustar 0 0 #Fri Sep 11 14:42:11 CEST 2009 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources includeModules=true resolveWorkspaceProjects=true resourceFilterGoals=process-resources resources\:testResources skipCompilerPlugin=true version=1 apache-xmlrpc-3.1.3-src/client/.classpath100644 0 0 650 11333307170 15376 0ustar 0 0 apache-xmlrpc-3.1.3-src/client/.project100644 0 0 1040 11333307171 15075 0ustar 0 0 xmlrpc-client org.eclipse.jdt.core.javabuilder org.maven.ide.eclipse.maven2Builder org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature apache-xmlrpc-3.1.3-src/client/.settings/org.eclipse.jdt.core.prefs100644 0 0 10716 11333307170 22357 0ustar 0 0 #Sat Apr 18 23:07:29 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.3 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.autoboxing=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 apache-xmlrpc-3.1.3-src/client/.settings/org.maven.ide.eclipse.prefs100644 0 0 407 11333307170 22451 0ustar 0 0 #Fri Apr 03 07:55:11 CEST 2009 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true resourceFilterGoals=process-resources resources\:testResources skipCompilerPlugin=true version=1 apache-xmlrpc-3.1.3-src/client/pom.xml100644 0 0 5261 11333307171 14754 0ustar 0 0 4.0.0 org.apache.xmlrpc xmlrpc 3.1.3 ../pom.xml xmlrpc-client Apache XML-RPC Client Library org.apache.maven.plugins maven-jar-plugin 2.2 false org.apache.xmlrpc.client UserLand Software, Inc. 2003-06-30 XML-RPC org.apache Apache Software Foundation ${project.version} org.apache.xmlrpc xmlrpc-common 3.1.3 commons-httpclient commons-httpclient ././@LongLink100644 0 0 154 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/apache/xmlrpc/client/XmlRpcClient.propertiesapache-xmlrpc-3.1.3-src/client/src/main/filtered-resources/org/apache/xmlrpc/client/XmlRpcClient.pro100644 0 0 55 11333307170 30574 0ustar 0 0 user.agent=Apache XML RPC ${project.version} apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/AsyncCallback.java100644 0 0 2670 11333307165 26227 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcRequest; /** A callback interface for an asynchronous XML-RPC call. * @since 3.0 */ public interface AsyncCallback { /** Call went ok, handle result. * @param pRequest The request being performed. * @param pResult The result object, which was returned by the server. */ public void handleResult(XmlRpcRequest pRequest, Object pResult); /** Something went wrong, handle error. * @param pRequest The request being performed. * @param pError The error being thrown. */ public void handleError(XmlRpcRequest pRequest, Throwable pError); } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/TimingOutCallback.java100644 0 0 6334 11333307165 27072 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; /** *

A callback object that can wait up to a specified amount * of time for the XML-RPC response. Suggested use is as follows: *

*
 *   // Wait for 10 seconds.
 *   TimingOutCallback callback = new TimingOutCallback(10 * 1000);
 *   XmlRpcClient client = new XmlRpcClient(url);
 *   client.executeAsync(methodName, aVector, callback);
 *   try {
 *       return callback.waitForResponse();
 *   } catch (TimeoutException e) {
 *       System.out.println("No response from server.");
 *   } catch (Exception e) {
 *       System.out.println("Server returned an error message.");
 *   }
 * 
*/ public class TimingOutCallback implements AsyncCallback { /** This exception is thrown, if the request times out. */ public static class TimeoutException extends XmlRpcException { private static final long serialVersionUID = 4875266372372105081L; /** Creates a new instance with the given error code and * error message. */ public TimeoutException(int pCode, String message) { super(pCode, message); } } private final long timeout; private Object result; private Throwable error; private boolean responseSeen; /** Waits the specified number of milliseconds for a response. */ public TimingOutCallback(long pTimeout) { timeout = pTimeout; } /** Called to wait for the response. * @throws InterruptedException The thread was interrupted. * @throws TimeoutException No response was received after waiting the specified time. * @throws Throwable An error was returned by the server. */ public synchronized Object waitForResponse() throws Throwable { if (!responseSeen) { wait(timeout); if (!responseSeen) { throw new TimeoutException(0, "No response after waiting for " + timeout + " milliseconds."); } } if (error != null) { throw error; } return result; } public synchronized void handleError(XmlRpcRequest pRequest, Throwable pError) { responseSeen = true; error = pError; notify(); } public synchronized void handleResult(XmlRpcRequest pRequest, Object pResult) { responseSeen = true; result = pResult; notify(); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java100644 0 0 15024 11333307165 27275 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client.util; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.UndeclaredThrowableException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.common.TypeConverter; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.common.XmlRpcInvocationException; /** *

The {@link ClientFactory} is a useful tool for simplifying the * use of Apache XML-RPC. The rough idea is as follows: All XML-RPC * handlers are implemented as interfaces. The server uses the actual * implementation. The client uses the {@link ClientFactory} to * obtain an implementation, which is based on running XML-RPC calls.

*/ public class ClientFactory { private final XmlRpcClient client; private final TypeConverterFactory typeConverterFactory; private boolean objectMethodLocal; /** Creates a new instance. * @param pClient A fully configured XML-RPC client, which is * used internally to perform XML-RPC calls. * @param pTypeConverterFactory Creates instances of {@link TypeConverterFactory}, * which are used to transform the result object in its target representation. */ public ClientFactory(XmlRpcClient pClient, TypeConverterFactory pTypeConverterFactory) { typeConverterFactory = pTypeConverterFactory; client = pClient; } /** Creates a new instance. Shortcut for *
     *   new ClientFactory(pClient, new TypeConverterFactoryImpl());
     * 
* @param pClient A fully configured XML-RPC client, which is * used internally to perform XML-RPC calls. * @see TypeConverterFactoryImpl */ public ClientFactory(XmlRpcClient pClient) { this(pClient, new TypeConverterFactoryImpl()); } /** Returns the factories client. */ public XmlRpcClient getClient() { return client; } /** Returns, whether a method declared by the {@link Object * Object class} is performed by the local object, rather than * by the server. Defaults to true. */ public boolean isObjectMethodLocal() { return objectMethodLocal; } /** Sets, whether a method declared by the {@link Object * Object class} is performed by the local object, rather than * by the server. Defaults to true. */ public void setObjectMethodLocal(boolean pObjectMethodLocal) { objectMethodLocal = pObjectMethodLocal; } /** * Creates an object, which is implementing the given interface. * The objects methods are internally calling an XML-RPC server * by using the factories client; shortcut for *
     *   newInstance(Thread.currentThread().getContextClassLoader(),
     *     pClass)
     * 
*/ public Object newInstance(Class pClass) { return newInstance(Thread.currentThread().getContextClassLoader(), pClass); } /** Creates an object, which is implementing the given interface. * The objects methods are internally calling an XML-RPC server * by using the factories client; shortcut for *
     *   newInstance(pClassLoader, pClass, pClass.getName())
     * 
*/ public Object newInstance(ClassLoader pClassLoader, Class pClass) { return newInstance(pClassLoader, pClass, pClass.getName()); } /** Creates an object, which is implementing the given interface. * The objects methods are internally calling an XML-RPC server * by using the factories client. * @param pClassLoader The class loader, which is being used for * loading classes, if required. * @param pClass Interface, which is being implemented. * @param pRemoteName Handler name, which is being used when * calling the server. This is used for composing the * method name. For example, if pRemoteName * is "Foo" and you want to invoke the method "bar" in * the handler, then the full method name would be "Foo.bar". */ public Object newInstance(ClassLoader pClassLoader, final Class pClass, final String pRemoteName) { return Proxy.newProxyInstance(pClassLoader, new Class[]{pClass}, new InvocationHandler(){ public Object invoke(Object pProxy, Method pMethod, Object[] pArgs) throws Throwable { if (isObjectMethodLocal() && pMethod.getDeclaringClass().equals(Object.class)) { return pMethod.invoke(pProxy, pArgs); } final String methodName; if (pRemoteName == null || pRemoteName.length() == 0) { methodName = pMethod.getName(); } else { methodName = pRemoteName + "." + pMethod.getName(); } Object result; try { result = client.execute(methodName, pArgs); } catch (XmlRpcInvocationException e) { Throwable t = e.linkedException; if (t instanceof RuntimeException) { throw t; } Class[] exceptionTypes = pMethod.getExceptionTypes(); for (int i = 0; i < exceptionTypes.length; i++) { Class c = exceptionTypes[i]; if (c.isAssignableFrom(t.getClass())) { throw t; } } throw new UndeclaredThrowableException(t); } TypeConverter typeConverter = typeConverterFactory.getTypeConverter(pMethod.getReturnType()); return typeConverter.convert(result); } }); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClient.java100644 0 0 23674 11333307165 26130 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.util.List; import org.apache.xmlrpc.XmlRpcConfig; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcWorkerFactory; import org.apache.xmlrpc.serializer.XmlWriterFactory; /**

The main access point of an XML-RPC client. This object serves mainly * as an object factory. It is designed with singletons in mind: Basically, * an application should be able to hold a single instance of * XmlRpcClient in a static variable, unless you would be * working with different factories.

*

Until Apache XML-RPC 2.0, this object was used both as an object * factory and as a place, where configuration details (server URL, * suggested encoding, user credentials and the like) have been stored. * In Apache XML-RPC 3.0, the configuration details has been moved to * the {@link org.apache.xmlrpc.client.XmlRpcClientConfig} object. * The configuration object is designed for being passed through the * actual worker methods.

*

A configured XmlRpcClient object is thread safe: In other words, * the suggested use is, that you configure the client using * {@link #setTransportFactory(XmlRpcTransportFactory)} and similar * methods, store it in a field and never modify it again. Without * modifications, the client may be used for an arbitrary number * of concurrent requests.

* @since 3.0 */ public class XmlRpcClient extends XmlRpcController { private XmlRpcTransportFactory transportFactory = XmlRpcClientDefaults.newTransportFactory(this); private XmlRpcClientConfig config = XmlRpcClientDefaults.newXmlRpcClientConfig(); private XmlWriterFactory xmlWriterFactory = XmlRpcClientDefaults.newXmlWriterFactory(); protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory() { return new XmlRpcClientWorkerFactory(this); } /** Sets the clients default configuration. This configuration * is used by the methods * {@link #execute(String, List)}, * {@link #execute(String, Object[])}, and * {@link #execute(XmlRpcRequest)}. * You may overwrite this per request by using * {@link #execute(XmlRpcClientConfig, String, List)}, * or {@link #execute(XmlRpcClientConfig, String, Object[])}. * @param pConfig The default request configuration. */ public void setConfig(XmlRpcClientConfig pConfig) { config = pConfig; } /** Returns the clients default configuration. This configuration * is used by the methods * {@link #execute(String, List)}, * {@link #execute(String, Object[])}. * You may overwrite this per request by using * {@link #execute(XmlRpcClientConfig, String, List)}, * or {@link #execute(XmlRpcClientConfig, String, Object[])}. * @return The default request configuration. */ public XmlRpcConfig getConfig() { return config; } /** Returns the clients default configuration. Shortcut for * (XmlRpcClientConfig) getConfig(). * This configuration is used by the methods * {@link #execute(String, List)}, * {@link #execute(String, Object[])}. * You may overwrite this per request by using * {@link #execute(XmlRpcClientConfig, String, List)}, or * {@link #execute(XmlRpcClientConfig, String, Object[])} * @return The default request configuration. */ public XmlRpcClientConfig getClientConfig() { return config; } /** Sets the clients transport factory. The client will invoke the * factory method {@link XmlRpcTransportFactory#getTransport()} * for any request. * @param pFactory The clients transport factory. */ public void setTransportFactory(XmlRpcTransportFactory pFactory) { transportFactory = pFactory; } /** Returns the clients transport factory. The client will use this factory * for invocation of {@link XmlRpcTransportFactory#getTransport()} * for any request. * @return The clients transport factory. */ public XmlRpcTransportFactory getTransportFactory() { return transportFactory; } /** Performs a request with the clients default configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(String pMethodName, Object[] pParams) throws XmlRpcException { return execute(getClientConfig(), pMethodName, pParams); } /** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); } /** Performs a request with the clients default configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(String pMethodName, List pParams) throws XmlRpcException { return execute(getClientConfig(), pMethodName, pParams); } /** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, List pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); } /** Performs a request with the clients default configuration. * @param pRequest The request being performed. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { return getWorkerFactory().getWorker().execute(pRequest); } /** Performs an asynchronous request with the clients default configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(String pMethodName, Object[] pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(getClientConfig(), pMethodName, pParams, pCallback); } /** Performs an asynchronous request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback); } /** Performs an asynchronous request with the clients default configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(String pMethodName, List pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(getClientConfig(), pMethodName, pParams, pCallback); } /** Performs an asynchronous request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, List pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback); } /** Performs a request with the clients default configuration. * @param pRequest The request being performed. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(XmlRpcRequest pRequest, AsyncCallback pCallback) throws XmlRpcException { XmlRpcClientWorker w = (XmlRpcClientWorker) getWorkerFactory().getWorker(); w.execute(pRequest, pCallback); } /** Returns the clients instance of * {@link org.apache.xmlrpc.serializer.XmlWriterFactory}. * @return A factory for creating instances of * {@link org.apache.ws.commons.serialize.XMLWriter}. */ public XmlWriterFactory getXmlWriterFactory() { return xmlWriterFactory; } /** Sets the clients instance of * {@link org.apache.xmlrpc.serializer.XmlWriterFactory}. * @param pFactory A factory for creating instances of * {@link org.apache.ws.commons.serialize.XMLWriter}. */ public void setXmlWriterFactory(XmlWriterFactory pFactory) { xmlWriterFactory = pFactory; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientConfig.java100644 0 0 2546 11333307165 27231 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcRequestConfig; /** This interface is being implemented by an Apache XML-RPC clients * configuration object. Depending on the transport factory, a * configuration object must implement additional methods. For * example, an HTTP transport requires an instance of * {@link org.apache.xmlrpc.client.XmlRpcHttpClientConfig}. A * local transport requires an instance of * {@link org.apache.xmlrpc.client.XmlRpcLocalClientConfig}. */ public interface XmlRpcClientConfig extends XmlRpcRequestConfig { } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientConfigImpl.java100644 0 0 5474 11333307165 30056 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.Serializable; import java.net.URL; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; import org.apache.xmlrpc.common.XmlRpcRequestProcessor; /** Default implementation of a clients request configuration. */ public class XmlRpcClientConfigImpl extends XmlRpcHttpRequestConfigImpl implements XmlRpcHttpClientConfig, XmlRpcLocalClientConfig, Cloneable, Serializable { private static final long serialVersionUID = 4121131450507800889L; private URL serverURL; private XmlRpcRequestProcessor xmlRpcServer; private String userAgent; /** Creates a new client configuration with default settings. */ public XmlRpcClientConfigImpl() { } /** Creates a clone of this client configuration. * @return A clone of this configuration. */ public XmlRpcClientConfigImpl cloneMe() { try { return (XmlRpcClientConfigImpl) clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Unable to create my clone"); } } /** Sets the servers URL. * @param pURL Servers URL */ public void setServerURL(URL pURL) { serverURL = pURL; } public URL getServerURL() { return serverURL; } /** Returns the {@link XmlRpcRequestProcessor} being invoked. * @param pServer Server object being invoked. This will typically * be a singleton instance, but could as well create a new * instance with any call. */ public void setXmlRpcServer(XmlRpcRequestProcessor pServer) { xmlRpcServer = pServer; } public XmlRpcRequestProcessor getXmlRpcServer() { return xmlRpcServer; } /** * Returns the user agent header to use * @return the http user agent header to set when doing xmlrpc requests */ public String getUserAgent() { return userAgent; } /** * @param pUserAgent the http user agent header to set when doing xmlrpc requests */ public void setUserAgent(String pUserAgent) { userAgent = pUserAgent; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientDefaults.java100644 0 0 4031 11333307165 27562 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.serializer.DefaultXMLWriterFactory; import org.apache.xmlrpc.serializer.XmlWriterFactory; /** * This class is responsible to provide default settings. */ public class XmlRpcClientDefaults { private static final XmlWriterFactory xmlWriterFactory = new DefaultXMLWriterFactory(); /** * Creates a new transport factory for the given client. */ public static XmlRpcTransportFactory newTransportFactory(XmlRpcClient pClient) { try { return new XmlRpcSun15HttpTransportFactory(pClient); } catch (Throwable t1) { try { return new XmlRpcSun14HttpTransportFactory(pClient); } catch (Throwable t2) { return new XmlRpcSunHttpTransportFactory(pClient); } } } /** * Creates a new instance of {@link XmlRpcClientConfig}. */ public static XmlRpcClientConfig newXmlRpcClientConfig() { return new XmlRpcClientConfigImpl(); } /** * Creates a new {@link XmlWriterFactory}. */ public static XmlWriterFactory newXmlWriterFactory() { return xmlWriterFactory; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientException.java100644 0 0 3266 11333307165 27762 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcException; /**

This is thrown by many of the client classes if an error occured processing * and XML-RPC request or response due to client side processing. This exception * will wrap a cause exception in the JDK 1.4 style.

*

This class replaces the class org.apache.xmlrpc.XmlRpcClientException * from Apache XML-RPC 2.0

* @since 3.0 */ public class XmlRpcClientException extends XmlRpcException { private static final long serialVersionUID = 3545798797134608691L; /** * Create an XmlRpcClientException with the given message and * underlying cause exception. * * @param pMessage the message for this exception. * @param pCause the cause of the exception. */ public XmlRpcClientException(String pMessage, Throwable pCause) { super(0, pMessage, pCause); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientRequestImpl.java100644 0 0 5073 11333307165 30274 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.util.List; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.XmlRpcRequestConfig; /** Default implementation of * {@link org.apache.xmlrpc.XmlRpcRequest}. */ public class XmlRpcClientRequestImpl implements XmlRpcRequest { private static final Object[] ZERO_PARAMS = new Object[0]; private final XmlRpcRequestConfig config; private final String methodName; private final Object[] params; /** Creates a new instance. * @param pConfig The request configuration. * @param pMethodName The method name being performed. * @param pParams The parameters. * @throws NullPointerException One of the parameters is null. */ public XmlRpcClientRequestImpl(XmlRpcRequestConfig pConfig, String pMethodName, Object[] pParams) { config = pConfig; if (config == null) { throw new NullPointerException("The request configuration must not be null."); } methodName = pMethodName; if (methodName == null) { throw new NullPointerException("The method name must not be null."); } params = pParams == null ? ZERO_PARAMS : pParams; } /** Creates a new instance. * @param pConfig The request configuration. * @param pMethodName The method name being performed. * @param pParams The parameters. * @throws NullPointerException The method name or the parameters are null. */ public XmlRpcClientRequestImpl(XmlRpcRequestConfig pConfig, String pMethodName, List pParams) { this(pConfig, pMethodName, pParams == null ? null : pParams.toArray()); } public String getMethodName() { return methodName; } public int getParameterCount() { return params.length; } public Object getParameter(int pIndex) { return params[pIndex]; } public XmlRpcRequestConfig getConfig() { return config; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientWorker.java100644 0 0 5725 11333307165 27277 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcWorker; /** Object, which performs a request on the clients behalf. * The client maintains a pool of workers. The main purpose of the * pool is limitation of the maximum number of concurrent requests. * @since 3.0 */ public class XmlRpcClientWorker implements XmlRpcWorker { private final XmlRpcClientWorkerFactory factory; /** Creates a new instance. * @param pFactory The factory, which is being notified, if * the worker's ready. */ public XmlRpcClientWorker(XmlRpcClientWorkerFactory pFactory) { factory = pFactory; } public XmlRpcController getController() { return factory.getController(); } /** Performs a synchronous request. * @param pRequest The request being performed. * @return The requests result. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { try { XmlRpcClient client = (XmlRpcClient) getController(); return client.getTransportFactory().getTransport().sendRequest(pRequest); } finally { factory.releaseWorker(this); } } protected Thread newThread(Runnable pRunnable) { Thread result = new Thread(pRunnable); result.setDaemon(true); return result; } /** Performs an synchronous request. * @param pRequest The request being performed. * @param pCallback The callback being invoked, when the request is finished. */ public void execute(final XmlRpcRequest pRequest, final AsyncCallback pCallback) { Runnable runnable = new Runnable(){ public void run(){ Object result = null; Throwable th = null; try { XmlRpcClient client = (XmlRpcClient) getController(); result = client.getTransportFactory().getTransport().sendRequest(pRequest); } catch (Throwable t) { th = t; } factory.releaseWorker(XmlRpcClientWorker.this); if (th == null) { pCallback.handleResult(pRequest, result); } else { pCallback.handleError(pRequest, th); } } }; newThread(runnable).start(); } } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientWorkerFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcClientWorkerFactory.java100644 0 0 2700 11333307165 30615 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.common.XmlRpcWorker; import org.apache.xmlrpc.common.XmlRpcWorkerFactory; /** A worker factory for the client, creating instances of * {@link org.apache.xmlrpc.client.XmlRpcClientWorker}. */ public class XmlRpcClientWorkerFactory extends XmlRpcWorkerFactory { /** Creates a new instance. * @param pClient The factory controller. */ public XmlRpcClientWorkerFactory(XmlRpcClient pClient) { super(pClient); } /** Creates a new worker instance. * @return New instance of {@link XmlRpcClientWorker}. */ protected XmlRpcWorker newWorker() { return new XmlRpcClientWorker(this); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcCommonsTransport.java100644 0 0 23231 11333307165 30227 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.BufferedOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpVersion; import org.apache.commons.httpclient.URI; import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.util.HttpUtil; import org.apache.xmlrpc.util.XmlRpcIOException; import org.xml.sax.SAXException; /** An HTTP transport factory, which is based on the Jakarta Commons * HTTP Client. */ public class XmlRpcCommonsTransport extends XmlRpcHttpTransport { /** * Maximum number of allowed redirects. */ private static final int MAX_REDIRECT_ATTEMPTS = 100; protected final HttpClient client; private static final String userAgent = USER_AGENT + " (Jakarta Commons httpclient Transport)"; protected PostMethod method; private int contentLength = -1; private XmlRpcHttpClientConfig config; /** Creates a new instance. * @param pFactory The factory, which created this transport. */ public XmlRpcCommonsTransport(XmlRpcCommonsTransportFactory pFactory) { super(pFactory.getClient(), userAgent); HttpClient httpClient = pFactory.getHttpClient(); if (httpClient == null) { httpClient = newHttpClient(); } client = httpClient; } protected void setContentLength(int pLength) { contentLength = pLength; } protected HttpClient newHttpClient() { return new HttpClient(); } protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { config = (XmlRpcHttpClientConfig) pRequest.getConfig(); method = newPostMethod(config); super.initHttpHeaders(pRequest); if (config.getConnectionTimeout() != 0) client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout()); if (config.getReplyTimeout() != 0) client.getHttpConnectionManager().getParams().setSoTimeout(config.getReplyTimeout()); method.getParams().setVersion(HttpVersion.HTTP_1_1); } protected PostMethod newPostMethod(XmlRpcHttpClientConfig pConfig) { return new PostMethod(pConfig.getServerURL().toString()); } protected void setRequestHeader(String pHeader, String pValue) { method.setRequestHeader(new Header(pHeader, pValue)); } protected boolean isResponseGzipCompressed() { Header h = method.getResponseHeader( "Content-Encoding" ); if (h == null) { return false; } else { return HttpUtil.isUsingGzipEncoding(h.getValue()); } } protected InputStream getInputStream() throws XmlRpcException { try { checkStatus(method); return method.getResponseBodyAsStream(); } catch (HttpException e) { throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); } } protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException { String userName = pConfig.getBasicUserName(); if (userName != null) { String enc = pConfig.getBasicEncoding(); if (enc == null) { enc = XmlRpcStreamConfig.UTF8_ENCODING; } client.getParams().setParameter(HttpMethodParams.CREDENTIAL_CHARSET, enc); Credentials creds = new UsernamePasswordCredentials(userName, pConfig.getBasicPassword()); AuthScope scope = new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME); client.getState().setCredentials(scope, creds); client.getParams().setAuthenticationPreemptive(true); } } protected void close() throws XmlRpcClientException { method.releaseConnection(); } protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { Header h = method.getResponseHeader( "Content-Encoding" ); if (h == null) { return false; } else { return HttpUtil.isUsingGzipEncoding(h.getValue()); } } protected boolean isRedirectRequired() { switch (method.getStatusCode()) { case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_SEE_OTHER: case HttpStatus.SC_TEMPORARY_REDIRECT: return true; default: return false; } } protected void resetClientForRedirect() throws XmlRpcException { //get the location header to find out where to redirect to Header locationHeader = method.getResponseHeader("location"); if (locationHeader == null) { throw new XmlRpcException("Invalid redirect: Missing location header"); } String location = locationHeader.getValue(); URI redirectUri = null; URI currentUri = null; try { currentUri = method.getURI(); String charset = currentUri.getProtocolCharset(); redirectUri = new URI(location, true, charset); method.setURI(redirectUri); } catch (URIException ex) { throw new XmlRpcException(ex.getMessage(), ex); } //And finally invalidate the actual authentication scheme method.getHostAuthState().invalidate(); } protected void writeRequest(final ReqWriter pWriter) throws XmlRpcException { method.setRequestEntity(new RequestEntity(){ public boolean isRepeatable() { return true; } public void writeRequest(OutputStream pOut) throws IOException { try { /* Make sure, that the socket is not closed by replacing it with our * own BufferedOutputStream. */ OutputStream ostream; if (isUsingByteArrayOutput(config)) { // No need to buffer the output. ostream = new FilterOutputStream(pOut){ public void close() throws IOException { flush(); } }; } else { ostream = new BufferedOutputStream(pOut){ public void close() throws IOException { flush(); } }; } pWriter.write(ostream); } catch (XmlRpcException e) { throw new XmlRpcIOException(e); } catch (SAXException e) { throw new XmlRpcIOException(e); } } public long getContentLength() { return contentLength; } public String getContentType() { return "text/xml"; } }); try { int redirectAttempts = 0; for (;;) { client.executeMethod(method); if (!isRedirectRequired()) { break; } if (redirectAttempts++ > MAX_REDIRECT_ATTEMPTS) { throw new XmlRpcException("Too many redirects."); } resetClientForRedirect(); } } catch (XmlRpcIOException e) { Throwable t = e.getLinkedException(); if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } else { throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t); } } catch (IOException e) { throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e); } } /** * Check the status of the HTTP request and throw an XmlRpcHttpTransportException if it * indicates that there is an error. * @param pMethod the method that has been executed * @throws XmlRpcHttpTransportException if the status of the method indicates that there is an error. */ private void checkStatus(HttpMethod pMethod) throws XmlRpcHttpTransportException { final int status = pMethod.getStatusCode(); // All status codes except SC_OK are handled as errors. Perhaps some should require special handling (e.g., SC_UNAUTHORIZED) if (status < 200 || status > 299) { throw new XmlRpcHttpTransportException(status, pMethod.getStatusText()); } } } ././@LongLink100644 0 0 151 11333313337 10250 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcCommonsTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcCommonsTransportFactory.100644 0 0 4730 11333307165 30700 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.commons.httpclient.HttpClient; /** An HTTP transport factory, which is based on the Jakarta Commons * HTTP Client. */ public class XmlRpcCommonsTransportFactory extends XmlRpcTransportFactoryImpl { private HttpClient httpClient; /** Creates a new instance. * @param pClient The client, which is controlling the factory. */ public XmlRpcCommonsTransportFactory(XmlRpcClient pClient) { super(pClient); } public XmlRpcTransport getTransport() { return new XmlRpcCommonsTransport(this); } /** *

Sets the factories {@link HttpClient}. By default, a new instance * of {@link HttpClient} is created for any request.

*

Reusing the {@link HttpClient} is required, if you want to preserve * some state between requests. This applies, in particular, if you want * to use cookies: In that case, create an instance of {@link HttpClient}, * give it to the factory, and use {@link HttpClient#getState()} to * read or set cookies. */ public void setHttpClient(HttpClient pHttpClient) { httpClient = pHttpClient; } /** *

Returns the factories {@link HttpClient}. By default, a new instance * of {@link HttpClient} is created for any request.

*

Reusing the {@link HttpClient} is required, if you want to preserve * some state between requests. This applies, in particular, if you want * to use cookies: In that case, create an instance of {@link HttpClient}, * give it to the factory, and use {@link HttpClient#getState()} to * read or set cookies. */ public HttpClient getHttpClient() { return httpClient; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcHttpClientConfig.java100644 0 0 2767 11333307165 30076 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.net.URL; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig; /** Extension of {@link org.apache.xmlrpc.client.XmlRpcClientConfig} * for HTTP based transport. Provides details like server URL, * user credentials, and so on. */ public interface XmlRpcHttpClientConfig extends XmlRpcHttpRequestConfig { /** Returns the HTTP servers URL. * @return XML-RPC servers URL; for example, this may be the URL of a * servlet */ URL getServerURL(); /** * Returns the user agent header to use * @return the http user agent header to set when doing xmlrpc requests */ String getUserAgent(); } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcHttpTransport.java100644 0 0 13463 11333307165 27541 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.UndeclaredThrowableException; import java.net.URL; import java.util.Properties; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.util.HttpUtil; import org.xml.sax.SAXException; /** Abstract base implementation of an HTTP transport. Base class for the * concrete implementations, like {@link org.apache.xmlrpc.client.XmlRpcSunHttpTransport}, * or {@link org.apache.xmlrpc.client.XmlRpcCommonsTransport}. */ public abstract class XmlRpcHttpTransport extends XmlRpcStreamTransport { protected class ByteArrayReqWriter implements ReqWriter { private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { new ReqWriterImpl(pRequest).write(baos); } protected int getContentLength() { return baos.size(); } public void write(OutputStream pStream) throws IOException { try { baos.writeTo(pStream); pStream.close(); pStream = null; } finally { if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} } } } } /** The user agent string. */ public static final String USER_AGENT; static { final String p = "XmlRpcClient.properties"; final URL url = XmlRpcHttpTransport.class.getResource(p); if (url == null) { throw new IllegalStateException("Failed to locate resource: " + p); } InputStream stream = null; try { stream = url.openStream(); final Properties props = new Properties(); props.load(stream); USER_AGENT = props.getProperty("user.agent"); if (USER_AGENT == null || USER_AGENT.trim().length() == 0) { throw new IllegalStateException("The property user.agent is not set."); } stream.close(); stream = null; } catch (IOException e) { throw new UndeclaredThrowableException(e, "Failed to load resource " + url + ": " + e.getMessage()); } finally { if (stream != null) { try { stream.close(); } catch (Throwable t) { /* Ignore me */ } } } } private String userAgent; protected XmlRpcHttpTransport(XmlRpcClient pClient, String pUserAgent) { super(pClient); userAgent = pUserAgent; } protected String getUserAgent() { return userAgent; } protected abstract void setRequestHeader(String pHeader, String pValue); protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException { String auth; try { auth = HttpUtil.encodeBasicAuthentication(pConfig.getBasicUserName(), pConfig.getBasicPassword(), pConfig.getBasicEncoding()); } catch (UnsupportedEncodingException e) { throw new XmlRpcClientException("Unsupported encoding: " + pConfig.getBasicEncoding(), e); } if (auth != null) { setRequestHeader("Authorization", "Basic " + auth); } } protected void setContentLength(int pLength) { setRequestHeader("Content-Length", Integer.toString(pLength)); } protected void setCompressionHeaders(XmlRpcHttpClientConfig pConfig) { if (pConfig.isGzipCompressing()) { setRequestHeader("Content-Encoding", "gzip"); } if (pConfig.isGzipRequesting()) { setRequestHeader("Accept-Encoding", "gzip"); } } protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); setRequestHeader("Content-Type", "text/xml"); if(config.getUserAgent() != null) setRequestHeader("User-Agent", config.getUserAgent()); else setRequestHeader("User-Agent", getUserAgent()); setCredentials(config); setCompressionHeaders(config); } public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { initHttpHeaders(pRequest); return super.sendRequest(pRequest); } protected boolean isUsingByteArrayOutput(XmlRpcHttpClientConfig pConfig) { return !pConfig.isEnabledForExtensions() || !pConfig.isContentLengthOptional(); } protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); if (isUsingByteArrayOutput(config)) { ByteArrayReqWriter reqWriter = new ByteArrayReqWriter(pRequest); setContentLength(reqWriter.getContentLength()); if (isCompressingRequest(config)) { return new GzipReqWriter(reqWriter); } return reqWriter; } else { return super.newReqWriter(pRequest); } } } ././@LongLink100644 0 0 150 11333313337 10247 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcHttpTransportException.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcHttpTransportException.j100644 0 0 3622 11333307165 30704 0ustar 0 0 package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcException; /** * Exception thrown if the HTTP status code sent by the server * indicates that the request could not be processed. In * general, the 400 and 500 level HTTP status codes will * result in an XmlRpcHttpTransportException being thrown. */ public class XmlRpcHttpTransportException extends XmlRpcException { private static final long serialVersionUID = -6933992871198450027L; private final int status; private final String statusMessage; /** * Creates a new instance with the specified HTTP status code * and HTTP status message. * @param pCode The HTTP status code * @param pMessage The HTTP status message returned by the HTTP server */ public XmlRpcHttpTransportException(int pCode, String pMessage) { this(pCode, pMessage, "HTTP server returned unexpected status: " + pMessage); } /** * Construct a new XmlRpcHttpTransportException with the specified HTTP status code, * HTTP status message, and exception message. * @param httpStatusCode the HTTP status code * @param httpStatusMessage the HTTP status message returned by the HTTP server * @param message the exception message. */ public XmlRpcHttpTransportException(int httpStatusCode, String httpStatusMessage, String message) { super( message ); this.status = httpStatusCode; this.statusMessage = httpStatusMessage; } /** * Get the HTTP status code that resulted in this exception. * @return the HTTP status code that resulted in this exception. */ public int getStatusCode() { return status; } /** * Get the status message returned by the HTTP server. * @return the status message returned by the HTTP server. */ public String getStatusMessage() { return statusMessage; } } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLite14HttpTransport.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLite14HttpTransport.java100644 0 0 4421 11333307165 30476 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import javax.net.ssl.SSLSocketFactory; /** * A "light" HTTP transport implementation for Java 1.4. */ public class XmlRpcLite14HttpTransport extends XmlRpcLiteHttpTransport { private SSLSocketFactory sslSocketFactory; /** * Creates a new instance. * @param pClient The client controlling this instance. */ public XmlRpcLite14HttpTransport(XmlRpcClient pClient) { super(pClient); } /** * Sets the SSL Socket Factory to use for https connections. */ public SSLSocketFactory getSSLSocketFactory() { return sslSocketFactory; } /** * Returns the SSL Socket Factory to use for https connections. */ public void setSSLSocketFactory(SSLSocketFactory pSSLSocketFactory) { sslSocketFactory = pSSLSocketFactory; } protected Socket newSocket(boolean pSSL, String pHostName, int pPort) throws UnknownHostException, IOException { if (pSSL) { SSLSocketFactory sslSockFactory = getSSLSocketFactory(); if (sslSockFactory == null) { sslSockFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); } return sslSockFactory.createSocket(pHostName, pPort); } else { return super.newSocket(pSSL, pHostName, pPort); } } } ././@LongLink100644 0 0 154 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLite14HttpTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLite14HttpTransportFacto100644 0 0 3754 11333307165 30543 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import javax.net.ssl.SSLSocketFactory; /** * Java 1.4 specific factory for the lite HTTP transport, * {@link org.apache.xmlrpc.client.XmlRpcLiteHttpTransport}. */ public class XmlRpcLite14HttpTransportFactory extends XmlRpcLiteHttpTransportFactory { private SSLSocketFactory sslSocketFactory; /** * Creates a new instance. * @param pClient The client, which will invoke the factory. */ public XmlRpcLite14HttpTransportFactory(XmlRpcClient pClient) { super(pClient); } /** * Sets the SSL Socket Factory to use for https connections. */ public SSLSocketFactory getSSLSocketFactory() { return sslSocketFactory; } /** * Returns the SSL Socket Factory to use for https connections. */ public void setSSLSocketFactory(SSLSocketFactory pSSLSocketFactory) { sslSocketFactory = pSSLSocketFactory; } public XmlRpcTransport getTransport() { XmlRpcLite14HttpTransport transport = new XmlRpcLite14HttpTransport(getClient()); transport.setSSLSocketFactory(sslSocketFactory); return transport; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLiteHttpTransport.java100644 0 0 20706 11333307165 30355 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.Socket; import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.util.HttpUtil; import org.apache.xmlrpc.util.LimitedInputStream; import org.xml.sax.SAXException; /** * A "light" HTTP transport implementation. */ public class XmlRpcLiteHttpTransport extends XmlRpcHttpTransport { private static final String userAgent = USER_AGENT + " (Lite HTTP Transport)"; private boolean ssl; private String hostname; private String host; private int port; private String uri; private Socket socket; private OutputStream output; private InputStream input; private final Map headers = new HashMap(); private boolean responseGzipCompressed = false; private XmlRpcHttpClientConfig config; /** * Creates a new instance. * @param pClient The client controlling this instance. */ public XmlRpcLiteHttpTransport(XmlRpcClient pClient) { super(pClient, userAgent); } public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { config = (XmlRpcHttpClientConfig) pRequest.getConfig(); URL url = config.getServerURL(); ssl = "https".equals(url.getProtocol()); hostname = url.getHost(); int p = url.getPort(); port = p < 1 ? 80 : p; String u = url.getFile(); uri = (u == null || "".equals(u)) ? "/" : u; host = port == 80 ? hostname : hostname + ":" + port; headers.put("Host", host); return super.sendRequest(pRequest); } protected void setRequestHeader(String pHeader, String pValue) { Object value = headers.get(pHeader); if (value == null) { headers.put(pHeader, pValue); } else { List list; if (value instanceof String) { list = new ArrayList(); list.add(value); headers.put(pHeader, list); } else { list = (List) value; } list.add(pValue); } } protected void close() throws XmlRpcClientException { IOException e = null; if (input != null) { try { input.close(); } catch (IOException ex) { e = ex; } } if (output != null) { try { output.close(); } catch (IOException ex) { if (e != null) { e = ex; } } } if (socket != null) { try { socket.close(); } catch (IOException ex) { if (e != null) { e = ex; } } } if (e != null) { throw new XmlRpcClientException("Failed to close connection: " + e.getMessage(), e); } } private OutputStream getOutputStream() throws XmlRpcException { try { final int retries = 3; final int delayMillis = 100; for (int tries = 0; ; tries++) { try { socket = newSocket(ssl, hostname, port); output = new BufferedOutputStream(socket.getOutputStream()){ /** Closing the output stream would close the whole socket, which we don't want, * because the don't want until the request is processed completely. * A close will later occur within * {@link XmlRpcLiteHttpTransport#close()}. */ public void close() throws IOException { flush(); socket.shutdownOutput(); } }; break; } catch (ConnectException e) { if (tries >= retries) { throw new XmlRpcException("Failed to connect to " + hostname + ":" + port + ": " + e.getMessage(), e); } else { try { Thread.sleep(delayMillis); } catch (InterruptedException ignore) { } } } } sendRequestHeaders(output); return output; } catch (IOException e) { throw new XmlRpcException("Failed to open connection to " + hostname + ":" + port + ": " + e.getMessage(), e); } } protected Socket newSocket(boolean pSSL, String pHostName, int pPort) throws UnknownHostException, IOException { if (pSSL) { throw new IOException("Unable to create SSL connections, use the XmlRpcLite14HttpTransportFactory."); } return new Socket(pHostName, pPort); } private byte[] toHTTPBytes(String pValue) throws UnsupportedEncodingException { return pValue.getBytes("US-ASCII"); } private void sendHeader(OutputStream pOut, String pKey, String pValue) throws IOException { pOut.write(toHTTPBytes(pKey + ": " + pValue + "\r\n")); } private void sendRequestHeaders(OutputStream pOut) throws IOException { pOut.write(("POST " + uri + " HTTP/1.0\r\n").getBytes("US-ASCII")); for (Iterator iter = headers.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); Object value = entry.getValue(); if (value instanceof String) { sendHeader(pOut, key, (String) value); } else { List list = (List) value; for (int i = 0; i < list.size(); i++) { sendHeader(pOut, key, (String) list.get(i)); } } } pOut.write(toHTTPBytes("\r\n")); } protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { return responseGzipCompressed; } protected InputStream getInputStream() throws XmlRpcException { final byte[] buffer = new byte[2048]; try { // If reply timeout specified, set the socket timeout accordingly if (config.getReplyTimeout() != 0) socket.setSoTimeout(config.getReplyTimeout()); input = new BufferedInputStream(socket.getInputStream()); // start reading server response headers String line = HttpUtil.readLine(input, buffer); StringTokenizer tokens = new StringTokenizer(line); tokens.nextToken(); // Skip HTTP version String statusCode = tokens.nextToken(); String statusMsg = tokens.nextToken("\n\r"); final int code; try { code = Integer.parseInt(statusCode); } catch (NumberFormatException e) { throw new XmlRpcClientException("Server returned invalid status code: " + statusCode + " " + statusMsg, null); } if (code < 200 || code > 299) { throw new XmlRpcHttpTransportException(code, statusMsg); } int contentLength = -1; for (;;) { line = HttpUtil.readLine(input, buffer); if (line == null || "".equals(line)) { break; } line = line.toLowerCase(); if (line.startsWith("content-length:")) { contentLength = Integer.parseInt(line.substring("content-length:".length()).trim()); } else if (line.startsWith("content-encoding:")) { responseGzipCompressed = HttpUtil.isUsingGzipEncoding(line.substring("content-encoding:".length())); } } InputStream result; if (contentLength == -1) { result = input; } else { result = new LimitedInputStream(input, contentLength); } return result; } catch (IOException e) { throw new XmlRpcClientException("Failed to read server response: " + e.getMessage(), e); } } protected boolean isUsingByteArrayOutput(XmlRpcHttpClientConfig pConfig) { boolean result = super.isUsingByteArrayOutput(pConfig); if (!result) { throw new IllegalStateException("The Content-Length header is required with HTTP/1.0, and HTTP/1.1 is unsupported by the Lite HTTP Transport."); } return result; } protected void writeRequest(ReqWriter pWriter) throws XmlRpcException, IOException, SAXException { pWriter.write(getOutputStream()); } } ././@LongLink100644 0 0 152 11333313337 10251 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLiteHttpTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLiteHttpTransportFactory100644 0 0 2442 11333307165 30742 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Factory for the lite HTTP transport, * {@link org.apache.xmlrpc.client.XmlRpcLiteHttpTransport}. */ public class XmlRpcLiteHttpTransportFactory extends XmlRpcTransportFactoryImpl { /** * Creates a new instance. * @param pClient The client, which will invoke the factory. */ public XmlRpcLiteHttpTransportFactory(XmlRpcClient pClient) { super(pClient); } public XmlRpcTransport getTransport() { return new XmlRpcLiteHttpTransport(getClient()); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalClientConfig.java100644 0 0 2230 11333307165 30172 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.common.XmlRpcRequestProcessorFactory; /** Interface of a client configuration for local rpc calls. Local * rpc calls are mainly useful for testing, because you don't need * a running server. */ public interface XmlRpcLocalClientConfig extends XmlRpcClientConfig, XmlRpcRequestProcessorFactory { } ././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalStreamTransport.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalStreamTransport.jav100644 0 0 6002 11333307165 30636 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.LocalStreamConnection; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestProcessor; import org.xml.sax.SAXException; /** Another local transport for debugging and testing. This one is * similar to the {@link org.apache.xmlrpc.client.XmlRpcLocalTransport}, * except that it adds request serialization. In other words, it is * particularly well suited for development and testing of XML serialization * and parsing. */ public class XmlRpcLocalStreamTransport extends XmlRpcStreamTransport { private final XmlRpcStreamRequestProcessor localServer; private LocalStreamConnection conn; private XmlRpcRequest request; /** Creates a new instance. * @param pClient The client, which is controlling the transport. * @param pServer An instance of {@link XmlRpcStreamRequestProcessor}. */ public XmlRpcLocalStreamTransport(XmlRpcClient pClient, XmlRpcStreamRequestProcessor pServer) { super(pClient); localServer = pServer; } protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { return pConfig.isGzipRequesting(); } protected void close() throws XmlRpcClientException { } protected InputStream getInputStream() throws XmlRpcException { localServer.execute(conn.getConfig(), conn.getServerStreamConnection()); return new ByteArrayInputStream(conn.getResponse().toByteArray()); } protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { request = pRequest; return super.newReqWriter(pRequest); } protected void writeRequest(ReqWriter pWriter) throws XmlRpcException, IOException, SAXException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); pWriter.write(baos); XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) request.getConfig(); conn = new LocalStreamConnection(config, new ByteArrayInputStream(baos.toByteArray())); } } ././@LongLink100644 0 0 155 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalStreamTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalStreamTransportFact100644 0 0 3413 11333307165 30660 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.common.XmlRpcStreamRequestProcessor; /** Another local transport factory for debugging and testing. This one is * similar to the {@link org.apache.xmlrpc.client.XmlRpcLocalTransportFactory}, * except that it adds request serialization. In other words, it is * particularly well suited for development and testing of XML serialization * and parsing. */ public class XmlRpcLocalStreamTransportFactory extends XmlRpcStreamTransportFactory { private final XmlRpcStreamRequestProcessor server; /** Creates a new instance. * @param pClient The client controlling the factory. * @param pServer An instance of {@link XmlRpcStreamRequestProcessor}. */ public XmlRpcLocalStreamTransportFactory(XmlRpcClient pClient, XmlRpcStreamRequestProcessor pServer) { super(pClient); server = pServer; } public XmlRpcTransport getTransport() { return new XmlRpcLocalStreamTransport(getClient(), server); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalTransport.java100644 0 0 7634 11333307165 27637 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.util.Collection; import java.util.Date; import java.util.Iterator; import java.util.Map; import org.apache.xmlrpc.XmlRpcConfig; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.TypeConverter; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.XmlRpcExtensionException; import org.apache.xmlrpc.common.XmlRpcRequestProcessor; /** The default implementation of a local transport. */ public class XmlRpcLocalTransport extends XmlRpcTransportImpl { /** Creates a new instance. * @param pClient The client, which creates the transport. */ public XmlRpcLocalTransport(XmlRpcClient pClient) { super(pClient); } private boolean isExtensionType(Object pObject) { if (pObject == null) { return true; } else if (pObject instanceof Object[]) { Object[] objects = (Object[]) pObject; for (int i = 0; i < objects.length; i++) { if (isExtensionType(objects[i])) { return true; } } return false; } else if (pObject instanceof Collection) { for (Iterator iter = ((Collection) pObject).iterator(); iter.hasNext(); ) { if (isExtensionType(iter.next())) { return true; } } return false; } else if (pObject instanceof Map) { Map map = (Map) pObject; for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); if (isExtensionType(entry.getKey()) || isExtensionType(entry.getValue())) { return true; } } return false; } else { return !(pObject instanceof Integer || pObject instanceof Date || pObject instanceof String || pObject instanceof byte[] || pObject instanceof Double); } } public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcConfig config = pRequest.getConfig(); if (!config.isEnabledForExtensions()) { for (int i = 0; i < pRequest.getParameterCount(); i++) { if (isExtensionType(pRequest.getParameter(i))) { throw new XmlRpcExtensionException("Parameter " + i + " has invalid type, if isEnabledForExtensions() == false"); } } } final XmlRpcRequestProcessor server = ((XmlRpcLocalClientConfig) config).getXmlRpcServer(); Object result; try { result = server.execute(pRequest); } catch (XmlRpcException t) { throw t; } catch (Throwable t) { throw new XmlRpcClientException("Failed to invoke method " + pRequest.getMethodName() + ": " + t.getMessage(), t); } if (!config.isEnabledForExtensions()) { if (isExtensionType(result)) { throw new XmlRpcExtensionException("Result has invalid type, if isEnabledForExtensions() == false"); } } if (result == null) { return null; } final TypeConverterFactory typeConverterFactory = server.getTypeConverterFactory(); final TypeConverter typeConverter = typeConverterFactory.getTypeConverter(result.getClass()); return typeConverter.backConvert(result); } }././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcLocalTransportFactory.ja100644 0 0 3342 11333307165 30630 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /**

A transport factory being used for local XML-RPC calls. Local XML-RPC * calls are mainly useful for development and unit testing: Both client * and server are runing within the same JVM and communication is implemented * in simple method invokcations.

*

This class is thread safe and the returned instance of * {@link org.apache.xmlrpc.client.XmlRpcTransport} will always return the * same object, an instance of {@link XmlRpcLocalTransport}

*/ public class XmlRpcLocalTransportFactory extends XmlRpcTransportFactoryImpl { /** Creates a new instance, operated by the given client. * @param pClient The client, which will invoke the factory. */ public XmlRpcLocalTransportFactory(XmlRpcClient pClient) { super(pClient); } private final XmlRpcTransport LOCAL_TRANSPORT = new XmlRpcLocalTransport(getClient()); public XmlRpcTransport getTransport() { return LOCAL_TRANSPORT; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcStreamTransport.java100644 0 0 17042 11333307165 30052 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.parser.XmlRpcResponseParser; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.apache.xmlrpc.util.SAXParsers; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** Implementation of a transport class, which is based on an output * stream for sending the request and an input stream for receiving * the response, */ public abstract class XmlRpcStreamTransport extends XmlRpcTransportImpl { protected interface ReqWriter { /** * Writes the requests data to the given output stream. * The method ensures, that the target is being closed. */ void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException; } protected class ReqWriterImpl implements ReqWriter { private final XmlRpcRequest request; protected ReqWriterImpl(XmlRpcRequest pRequest) { request = pRequest; } /** Writes the requests uncompressed XML data to the given * output stream. Ensures, that the output stream is being * closed. */ public void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException { final XmlRpcStreamConfig config = (XmlRpcStreamConfig) request.getConfig(); try { ContentHandler h = getClient().getXmlWriterFactory().getXmlWriter(config, pStream); XmlRpcWriter xw = new XmlRpcWriter(config, h, getClient().getTypeFactory()); xw.write(request); pStream.close(); pStream = null; } finally { if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} } } } } protected class GzipReqWriter implements ReqWriter { private final ReqWriter reqWriter; protected GzipReqWriter(ReqWriter pReqWriter) { reqWriter = pReqWriter; } public void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException { try { GZIPOutputStream gStream = new GZIPOutputStream(pStream); reqWriter.write(gStream); pStream.close(); pStream = null; } catch (IOException e) { throw new XmlRpcException("Failed to write request: " + e.getMessage(), e); } finally { if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} } } } } /** Creates a new instance on behalf of the given client. */ protected XmlRpcStreamTransport(XmlRpcClient pClient) { super(pClient); } /** Closes the connection and ensures, that all resources are being * released. */ protected abstract void close() throws XmlRpcClientException; /** Returns, whether the response is gzip compressed. * @param pConfig The clients configuration. * @return Whether the response stream is gzip compressed. */ protected abstract boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig); /** Returns the input stream, from which the response is * being read. */ protected abstract InputStream getInputStream() throws XmlRpcException; protected boolean isCompressingRequest(XmlRpcStreamRequestConfig pConfig) { return pConfig.isEnabledForExtensions() && pConfig.isGzipCompressing(); } /** * Creates a new instance of {@link ReqWriter}. * @throws XmlRpcException Creating the instance failed. * @throws IOException Creating the instance failed, because * an {@link IOException} occurs. * @throws SAXException Creating the instance failed, because * the request could not be parsed. */ protected ReqWriter newReqWriter(XmlRpcRequest pRequest) throws XmlRpcException, IOException, SAXException { ReqWriter reqWriter = new ReqWriterImpl(pRequest); if (isCompressingRequest((XmlRpcStreamRequestConfig) pRequest.getConfig())) { reqWriter = new GzipReqWriter(reqWriter); } return reqWriter; } protected abstract void writeRequest(ReqWriter pWriter) throws XmlRpcException, IOException, SAXException; public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) pRequest.getConfig(); boolean closed = false; try { ReqWriter reqWriter = newReqWriter(pRequest); writeRequest(reqWriter); InputStream istream = getInputStream(); if (isResponseGzipCompressed(config)) { istream = new GZIPInputStream(istream); } Object result = readResponse(config, istream); closed = true; close(); return result; } catch (IOException e) { throw new XmlRpcException("Failed to read server's response: " + e.getMessage(), e); } catch (SAXException e) { Exception ex = e.getException(); if (ex != null && ex instanceof XmlRpcException) { throw (XmlRpcException) ex; } throw new XmlRpcException("Failed to generate request: " + e.getMessage(), e); } finally { if (!closed) { try { close(); } catch (Throwable ignore) {} } } } protected XMLReader newXMLReader() throws XmlRpcException { return SAXParsers.newXMLReader(); } protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { InputSource isource = new InputSource(pStream); XMLReader xr = newXMLReader(); XmlRpcResponseParser xp; try { xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory()); xr.setContentHandler(xp); xr.parse(isource); } catch (SAXException e) { throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e); } if (xp.isSuccess()) { return xp.getResult(); } Throwable t = xp.getErrorCause(); if (t == null) { throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage()); } if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t); } } ././@LongLink100644 0 0 150 11333313337 10247 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcStreamTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcStreamTransportFactory.j100644 0 0 2110 11333307165 30660 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Abstract base implementation of a factory for stream transports. */ public abstract class XmlRpcStreamTransportFactory extends XmlRpcTransportFactoryImpl { protected XmlRpcStreamTransportFactory(XmlRpcClient pClient) { super(pClient); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun14HttpTransport.java100644 0 0 4535 11333307165 30354 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; /** * Default implementation of an HTTP transport in Java 1.4, based on the * {@link java.net.HttpURLConnection} class. Adds support for the * {@link SSLSocketFactory}. */ public class XmlRpcSun14HttpTransport extends XmlRpcSunHttpTransport { private SSLSocketFactory sslSocketFactory; /** * Creates a new instance. * @param pClient The client controlling this instance. */ public XmlRpcSun14HttpTransport(XmlRpcClient pClient) { super(pClient); } /** * Sets the SSLSocketFactory used to create secure sockets. * @param pSocketFactory The SSLSocketFactory to use. */ public void setSSLSocketFactory(SSLSocketFactory pSocketFactory) { sslSocketFactory = pSocketFactory; } /** * Returns the SSLSocketFactory used to create secure sockets. */ public SSLSocketFactory getSSLSocketFactory() { return sslSocketFactory; } protected URLConnection newURLConnection(URL pURL) throws IOException { final URLConnection conn = super.newURLConnection(pURL); final SSLSocketFactory sslSockFactory = getSSLSocketFactory(); if ((sslSockFactory != null) && (conn instanceof HttpsURLConnection)) ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory); return conn; } } ././@LongLink100644 0 0 153 11333313337 10252 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun14HttpTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun14HttpTransportFactor100644 0 0 4103 11333307165 30562 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import javax.net.ssl.SSLSocketFactory; /** * Default implementation of an HTTP transport factory in Java 1.4, based * on the {@link java.net.HttpURLConnection} class. */ public class XmlRpcSun14HttpTransportFactory extends XmlRpcTransportFactoryImpl { private SSLSocketFactory sslSocketFactory; /** * Creates a new factory, which creates transports for the given client. * @param pClient The client, which is operating the factory. */ public XmlRpcSun14HttpTransportFactory(XmlRpcClient pClient) { super(pClient); } /** * Sets the SSLSocketFactory to be used by transports. * @param pSocketFactory The SSLSocketFactory to use. */ public void setSSLSocketFactory(SSLSocketFactory pSocketFactory) { sslSocketFactory = pSocketFactory; } /** * Returns the SSLSocketFactory to be used by transports. */ public SSLSocketFactory getSSLSocketFactory() { return sslSocketFactory; } public XmlRpcTransport getTransport() { XmlRpcSun14HttpTransport transport = new XmlRpcSun14HttpTransport(getClient()); transport.setSSLSocketFactory(sslSocketFactory); return transport; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun15HttpTransport.java100644 0 0 5537 11333307165 30360 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.IOException; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; import org.apache.xmlrpc.XmlRpcRequest; /** * Default implementation of an HTTP transport in Java 1.4, based on the * {@link java.net.HttpURLConnection} class. Adds support for the * {@link Proxy} class. */ public class XmlRpcSun15HttpTransport extends XmlRpcSun14HttpTransport { /** * Creates a new instance. * @param pClient The client controlling this instance. */ public XmlRpcSun15HttpTransport(XmlRpcClient pClient) { super(pClient); } private Proxy proxy; /** * Sets the proxy to use. */ public void setProxy(Proxy pProxy) { proxy = pProxy; } /** * Returns the proxy to use. */ public Proxy getProxy() { return proxy; } protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); int connectionTimeout = config.getConnectionTimeout(); if (connectionTimeout > 0) { getURLConnection().setConnectTimeout(connectionTimeout); } int replyTimeout = config.getReplyTimeout(); if (replyTimeout > 0) { getURLConnection().setReadTimeout(replyTimeout); } super.initHttpHeaders(pRequest); } protected URLConnection newURLConnection(URL pURL) throws IOException { final Proxy prox = getProxy(); final URLConnection conn = prox == null ? pURL.openConnection() : pURL.openConnection(prox); final SSLSocketFactory sslSockFactory = getSSLSocketFactory(); if (sslSockFactory != null && conn instanceof HttpsURLConnection) { ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory); } return conn; } } ././@LongLink100644 0 0 153 11333313337 10252 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun15HttpTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSun15HttpTransportFactor100644 0 0 4444 11333307165 30573 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.net.InetSocketAddress; import java.net.Proxy; /** * Default implementation of an HTTP transport in Java 1.5, based on the * {@link java.net.HttpURLConnection} class. */ public class XmlRpcSun15HttpTransportFactory extends XmlRpcSun14HttpTransportFactory { private Proxy proxy; /** * Creates a new factory, which creates transports for the given client. * @param pClient The client, which is operating the factory. */ public XmlRpcSun15HttpTransportFactory(XmlRpcClient pClient) { super(pClient); } /** * Sets the proxy to use. * @param proxyHost The proxy hostname. * @param proxyPort The proxy port number. * @throws IllegalArgumentException if the proxyHost parameter is null or if * the proxyPort parameter is outside the range of valid port values. */ public void setProxy(String proxyHost, int proxyPort) { setProxy(new Proxy(Proxy.Type.HTTP,new InetSocketAddress(proxyHost,proxyPort))); } /** * Sets the proxy to use. * @param pProxy The proxy settings. */ public void setProxy(Proxy pProxy) { proxy = pProxy; } public XmlRpcTransport getTransport() { XmlRpcSun15HttpTransport transport = new XmlRpcSun15HttpTransport(getClient()); transport.setSSLSocketFactory(getSSLSocketFactory()); transport.setProxy(proxy); return transport; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSunHttpTransport.java100644 0 0 7221 11333307165 30202 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.util.HttpUtil; import org.xml.sax.SAXException; /** Default implementation of an HTTP transport, based on the * {@link java.net.HttpURLConnection} class. */ public class XmlRpcSunHttpTransport extends XmlRpcHttpTransport { private static final String userAgent = USER_AGENT + " (Sun HTTP Transport)"; private URLConnection conn; /** Creates a new instance. * @param pClient The client controlling this instance. */ public XmlRpcSunHttpTransport(XmlRpcClient pClient) { super(pClient, userAgent); } protected URLConnection newURLConnection(URL pURL) throws IOException { return pURL.openConnection(); } /** * For use by subclasses. */ protected URLConnection getURLConnection() { return conn; } public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig(); try { final URLConnection c = conn = newURLConnection(config.getServerURL()); c.setUseCaches(false); c.setDoInput(true); c.setDoOutput(true); } catch (IOException e) { throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e); } return super.sendRequest(pRequest); } protected void setRequestHeader(String pHeader, String pValue) { getURLConnection().setRequestProperty(pHeader, pValue); } protected void close() throws XmlRpcClientException { final URLConnection c = getURLConnection(); if (c instanceof HttpURLConnection) { ((HttpURLConnection) c).disconnect(); } } protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { return HttpUtil.isUsingGzipEncoding(getURLConnection().getHeaderField("Content-Encoding")); } protected InputStream getInputStream() throws XmlRpcException { try { URLConnection connection = getURLConnection(); if ( connection instanceof HttpURLConnection ) { HttpURLConnection httpConnection = (HttpURLConnection) connection; int responseCode = httpConnection.getResponseCode(); if (responseCode < 200 || responseCode > 299) { throw new XmlRpcHttpTransportException(responseCode, httpConnection.getResponseMessage()); } } return connection.getInputStream(); } catch (IOException e) { throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e); } } protected void writeRequest(ReqWriter pWriter) throws IOException, XmlRpcException, SAXException { pWriter.write(getURLConnection().getOutputStream()); } }././@LongLink100644 0 0 151 11333313337 10250 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSunHttpTransportFactory.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcSunHttpTransportFactory.100644 0 0 2542 11333307165 30671 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Default implementation of a HTTP transport factory, based on the * {@link java.net.HttpURLConnection} class. */ public class XmlRpcSunHttpTransportFactory extends XmlRpcTransportFactoryImpl { /** Creates a new factory, which creates transports for the given client. * @param pClient The client, which is operating the factory. */ public XmlRpcSunHttpTransportFactory(XmlRpcClient pClient) { super(pClient); } public XmlRpcTransport getTransport() { return new XmlRpcSunHttpTransport(getClient()); } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcTransport.java100644 0 0 3046 11333307165 26655 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; /**

Interface from XML-RPC to an underlying transport, most likely based on HTTP.

* Replaces the interface org.apache.xmlrpc.client from Apache XML-RPC * 2.0, which has actually been a stream based transport. * @since 3.0 */ public interface XmlRpcTransport { /** Send an XML-RPC message. This method is called to send a message to the * other party. * @param pRequest The request being performed. * @return Result object, if invoking the remote method was successfull. * @throws XmlRpcException Performing the request failed. */ public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcTransportFactory.java100644 0 0 2453 11333307165 30206 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Interface of an object creating instances of * {@link org.apache.xmlrpc.client.XmlRpcTransport}. The implementation * is typically based on singletons. */ public interface XmlRpcTransportFactory { /** Returns an instance of {@link XmlRpcTransport}. This may * be a singleton, but the caller should not depend on that: * A new instance may as well be created for any request. * @return The configured transport. */ public XmlRpcTransport getTransport(); } ././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcTransportFactoryImpl.javaapache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcTransportFactoryImpl.jav100644 0 0 2516 11333307165 30667 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Abstract base implementation of an {@link XmlRpcTransportFactory}. */ public abstract class XmlRpcTransportFactoryImpl implements XmlRpcTransportFactory { private final XmlRpcClient client; /** Creates a new instance. * @param pClient The client, which will invoke the factory. */ protected XmlRpcTransportFactoryImpl(XmlRpcClient pClient) { client = pClient; } /** Returns the client operating this factory. * @return The client. */ public XmlRpcClient getClient() { return client; } } apache-xmlrpc-3.1.3-src/client/src/main/java/org/apache/xmlrpc/client/XmlRpcTransportImpl.java100644 0 0 2520 11333307165 27473 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.client; /** Abstract base implementation of an {@link org.apache.xmlrpc.client.XmlRpcTransport}. */ public abstract class XmlRpcTransportImpl implements XmlRpcTransport { private final XmlRpcClient client; /** Creates a new instance. * @param pClient The client, which creates the transport. */ protected XmlRpcTransportImpl(XmlRpcClient pClient) { client = pClient; } /** Returns the client, which created this transport. * @return The client. */ public XmlRpcClient getClient() { return client; } } apache-xmlrpc-3.1.3-src/common/.classpath100644 0 0 650 11333307162 15411 0ustar 0 0 apache-xmlrpc-3.1.3-src/common/.project100644 0 0 1040 11333307162 15107 0ustar 0 0 xmlrpc-common org.eclipse.jdt.core.javabuilder org.maven.ide.eclipse.maven2Builder org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature apache-xmlrpc-3.1.3-src/common/.settings/org.eclipse.jdt.core.prefs100644 0 0 11556 11333307162 22375 0ustar 0 0 #Sat Apr 18 23:07:10 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.3 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore org.eclipse.jdt.core.compiler.problem.autoboxing=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 apache-xmlrpc-3.1.3-src/common/.settings/org.maven.ide.eclipse.prefs100644 0 0 407 11333307162 22464 0ustar 0 0 #Fri Apr 03 07:55:11 CEST 2009 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true resourceFilterGoals=process-resources resources\:testResources skipCompilerPlugin=true version=1 apache-xmlrpc-3.1.3-src/common/pom.xml100644 0 0 5233 11333307162 14765 0ustar 0 0 4.0.0 org.apache.xmlrpc xmlrpc 3.1.3 ../pom.xml xmlrpc-common Apache XML-RPC Common Library org.apache.maven.plugins maven-jar-plugin 2.2 false org.apache.xmlrpc UserLand Software, Inc. 2003-06-30 XML-RPC org.apache Apache Software Foundation ${project.version} org.apache.ws.commons.util ws-commons-util jaxme jaxmeapi provided apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java100644 0 0 5060 11333307157 30004 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** Implementation of {@link ServerStreamConnection} for * use by the * {@link org.apache.xmlrpc.client.XmlRpcLocalStreamTransport}. */ public class LocalStreamConnection { private class LocalServerStreamConnection implements ServerStreamConnection { public InputStream newInputStream() throws IOException { return request; } public OutputStream newOutputStream() throws IOException { return response; } public void close() throws IOException { if (response != null) { response.close(); } } } private final InputStream request; private final XmlRpcStreamRequestConfig config; private final ByteArrayOutputStream response = new ByteArrayOutputStream(); private final ServerStreamConnection serverStreamConnection; /** Creates a new instance with the given request stream. */ public LocalStreamConnection(XmlRpcStreamRequestConfig pConfig, InputStream pRequest) { config = pConfig; request = pRequest; serverStreamConnection = new LocalServerStreamConnection(); } /** Returns the request stream. */ public InputStream getRequest() { return request; } /** Returns the request configuration. */ public XmlRpcStreamRequestConfig getConfig() { return config; } /** Returns an output stream, to which the response * may be written. */ public ByteArrayOutputStream getResponse() { return response; } /** Returns the servers connection. */ public ServerStreamConnection getServerStreamConnection() { return serverStreamConnection; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java100644 0 0 2716 11333307157 30225 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** Interface of an object, which is able to provide * an XML stream, containing an XML-RPC request. * Additionally, the object may also be used to * write the response as an XML stream. */ public interface ServerStreamConnection { /** Returns the connections input stream. */ InputStream newInputStream() throws IOException; /** Returns the connections output stream. */ OutputStream newOutputStream() throws IOException; /** Closes the connection, and frees resources. */ void close() throws IOException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/TypeConverter.java100644 0 0 3352 11333307157 26371 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.util.List; import java.util.Vector; /** A {@link TypeConverter} is used when actually calling the * handler method or actually returning the result object. It's * purpose is to convert a single parameter or the return value * from a generic representation (for example an array of objects) * to an alternative representation, which is actually used in * the methods signature (for example {@link List}, or * {@link Vector}. */ public interface TypeConverter { /** Returns, whether the {@link TypeConverter} is * ready to handle the given object. If so, * {@link #convert(Object)} may be called. */ boolean isConvertable(Object pObject); /** Converts the given object into the required * representation. */ Object convert(Object pObject); /** Converts the given object into its generic * representation. */ Object backConvert(Object result); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/TypeConverterFactory.java100644 0 0 2216 11333307157 27717 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; /** A {@link TypeConverterFactory} is called for creating instances * of {@link TypeConverter}. */ public interface TypeConverterFactory { /** Creates an instance of {@link TypeFactory}, which may be * used to create instances of the given class. */ TypeConverter getTypeConverter(Class pClass); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/TypeConverterFactoryImpl.java100644 0 0 27206 11333307157 30567 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Vector; import org.w3c.dom.Document; /** Default implementation of {@link TypeConverterFactory}. */ public class TypeConverterFactoryImpl implements TypeConverterFactory { private static class IdentityTypeConverter implements TypeConverter { private final Class clazz; IdentityTypeConverter(Class pClass) { clazz = pClass; } public boolean isConvertable(Object pObject) { return pObject == null || clazz.isAssignableFrom(pObject.getClass()); } public Object convert(Object pObject) { return pObject; } public Object backConvert(Object pObject) { return pObject; } } private static abstract class ListTypeConverter implements TypeConverter { private final Class clazz; ListTypeConverter(Class pClass) { clazz = pClass; } protected abstract List newList(int pSize); public boolean isConvertable(Object pObject) { return pObject == null || pObject instanceof Object[] || pObject instanceof Collection; } public Object convert(Object pObject) { if (pObject == null) { return null; } if (clazz.isAssignableFrom(pObject.getClass())) { return pObject; } if (pObject instanceof Object[]) { Object[] objects = (Object[]) pObject; List result = newList(objects.length); for (int i = 0; i < objects.length; i++) { result.add(objects[i]); } return result; } Collection collection = (Collection) pObject; List result = newList(collection.size()); result.addAll(collection); return result; } public Object backConvert(Object pObject) { return ((List) pObject).toArray(); } } private static class PrimitiveTypeConverter implements TypeConverter { private final Class clazz; PrimitiveTypeConverter(Class pClass) { clazz = pClass; } public boolean isConvertable(Object pObject) { return pObject != null && pObject.getClass().isAssignableFrom(clazz); } public Object convert(Object pObject) { return pObject; } public Object backConvert(Object pObject) { return pObject; } } private static final TypeConverter voidTypeConverter = new IdentityTypeConverter(void.class); private static final TypeConverter mapTypeConverter = new IdentityTypeConverter(Map.class); private static final TypeConverter objectArrayTypeConverter = new IdentityTypeConverter(Object[].class); private static final TypeConverter byteArrayTypeConverter = new IdentityTypeConverter(byte[].class); private static final TypeConverter stringTypeConverter = new IdentityTypeConverter(String.class); private static final TypeConverter booleanTypeConverter = new IdentityTypeConverter(Boolean.class); private static final TypeConverter characterTypeConverter = new IdentityTypeConverter(Character.class); private static final TypeConverter byteTypeConverter = new IdentityTypeConverter(Byte.class); private static final TypeConverter shortTypeConverter = new IdentityTypeConverter(Short.class); private static final TypeConverter integerTypeConverter = new IdentityTypeConverter(Integer.class); private static final TypeConverter longTypeConverter = new IdentityTypeConverter(Long.class); private static final TypeConverter bigDecimalTypeConverter = new IdentityTypeConverter(BigDecimal.class); private static final TypeConverter bigIntegerTypeConverter = new IdentityTypeConverter(BigInteger.class); private static final TypeConverter floatTypeConverter = new IdentityTypeConverter(Float.class); private static final TypeConverter doubleTypeConverter = new IdentityTypeConverter(Double.class); private static final TypeConverter dateTypeConverter = new IdentityTypeConverter(Date.class); private static final TypeConverter calendarTypeConverter = new IdentityTypeConverter(Calendar.class); private static final TypeConverter domTypeConverter = new IdentityTypeConverter(Document.class); private static final TypeConverter primitiveBooleanTypeConverter = new PrimitiveTypeConverter(Boolean.class); private static final TypeConverter primitiveCharTypeConverter = new PrimitiveTypeConverter(Character.class); private static final TypeConverter primitiveByteTypeConverter = new PrimitiveTypeConverter(Byte.class); private static final TypeConverter primitiveShortTypeConverter = new PrimitiveTypeConverter(Short.class); private static final TypeConverter primitiveIntTypeConverter = new PrimitiveTypeConverter(Integer.class); private static final TypeConverter primitiveLongTypeConverter = new PrimitiveTypeConverter(Long.class); private static final TypeConverter primitiveFloatTypeConverter = new PrimitiveTypeConverter(Float.class); private static final TypeConverter primitiveDoubleTypeConverter = new PrimitiveTypeConverter(Double.class); private static final TypeConverter propertiesTypeConverter = new TypeConverter() { public boolean isConvertable(Object pObject) { return pObject == null || pObject instanceof Map; } public Object convert(Object pObject) { if (pObject == null) { return null; } Properties props = new Properties(); props.putAll((Map) pObject); return props; } public Object backConvert(Object pObject) { return pObject; } }; private static final TypeConverter hashTableTypeConverter = new TypeConverter() { public boolean isConvertable(Object pObject) { return pObject == null || pObject instanceof Map; } public Object convert(Object pObject) { if (pObject == null) { return null; } return new Hashtable((Map) pObject); } public Object backConvert(Object pObject) { return pObject; } }; private static final TypeConverter listTypeConverter = new ListTypeConverter(List.class) { protected List newList(int pSize) { return new ArrayList(pSize); } }; private static final TypeConverter vectorTypeConverter = new ListTypeConverter(Vector.class) { protected List newList(int pSize) { return new Vector(pSize); } }; private static class CastCheckingTypeConverter implements TypeConverter { private final Class clazz; CastCheckingTypeConverter(Class pClass) { clazz = pClass; } public boolean isConvertable(Object pObject) { return pObject == null || clazz.isAssignableFrom(pObject.getClass()); } public Object convert(Object pObject) { return pObject; } public Object backConvert(Object pObject) { return pObject; } } /** Returns a type converter for the given class. */ public TypeConverter getTypeConverter(Class pClass) { if (void.class.equals(pClass)) { return voidTypeConverter; } if (pClass.isAssignableFrom(boolean.class)) { return primitiveBooleanTypeConverter; } if (pClass.isAssignableFrom(char.class)) { return primitiveCharTypeConverter; } if (pClass.isAssignableFrom(byte.class)) { return primitiveByteTypeConverter; } if (pClass.isAssignableFrom(short.class)) { return primitiveShortTypeConverter; } if (pClass.isAssignableFrom(int.class)) { return primitiveIntTypeConverter; } if (pClass.isAssignableFrom(long.class)) { return primitiveLongTypeConverter; } if (pClass.isAssignableFrom(float.class)) { return primitiveFloatTypeConverter; } if (pClass.isAssignableFrom(double.class)) { return primitiveDoubleTypeConverter; } if (pClass.isAssignableFrom(String.class)) { return stringTypeConverter; } if (pClass.isAssignableFrom(Boolean.class)) { return booleanTypeConverter; } if (pClass.isAssignableFrom(Character.class)) { return characterTypeConverter; } if (pClass.isAssignableFrom(Byte.class)) { return byteTypeConverter; } if (pClass.isAssignableFrom(Short.class)) { return shortTypeConverter; } if (pClass.isAssignableFrom(Integer.class)) { return integerTypeConverter; } if (pClass.isAssignableFrom(Long.class)) { return longTypeConverter; } if (pClass.isAssignableFrom(BigDecimal.class)) { return bigDecimalTypeConverter; } if (pClass.isAssignableFrom(BigInteger.class)) { return bigIntegerTypeConverter; } if (pClass.isAssignableFrom(Float.class)) { return floatTypeConverter; } if (pClass.isAssignableFrom(Double.class)) { return doubleTypeConverter; } if (pClass.isAssignableFrom(Date.class)) { return dateTypeConverter; } if (pClass.isAssignableFrom(Calendar.class)) { return calendarTypeConverter; } if (pClass.isAssignableFrom(Object[].class)) { return objectArrayTypeConverter; } if (pClass.isAssignableFrom(List.class)) { return listTypeConverter; } if (pClass.isAssignableFrom(Vector.class)) { return vectorTypeConverter; } if (pClass.isAssignableFrom(Map.class)) { return mapTypeConverter; } if (pClass.isAssignableFrom(Hashtable.class)) { return hashTableTypeConverter; } if (pClass.isAssignableFrom(Properties.class)) { return propertiesTypeConverter; } if (pClass.isAssignableFrom(byte[].class)) { return byteArrayTypeConverter; } if (pClass.isAssignableFrom(Document.class)) { return domTypeConverter; } if (Serializable.class.isAssignableFrom(pClass)) { return new CastCheckingTypeConverter(pClass); } throw new IllegalStateException("Invalid parameter or result type: " + pClass.getName()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/TypeFactory.java100644 0 0 3741 11333307157 26033 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.parser.TypeParser; import org.apache.xmlrpc.serializer.TypeSerializer; import org.xml.sax.SAXException; /** A type factory creates serializers or handlers, based on the object * type. */ public interface TypeFactory { /** Creates a serializer for the object pObject. * @param pConfig The request configuration. * @param pObject The object being serialized. * @return A serializer for pObject. * @throws SAXException Creating the serializer failed. */ TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException; /** Creates a parser for a parameter or result object. * @param pConfig The request configuration. * @param pContext A namespace context, for looking up prefix mappings. * @param pURI The namespace URI of the element containing the parameter or result. * @param pLocalName The local name of the element containing the parameter or result. * @return The created parser. */ TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/TypeFactoryImpl.java100644 0 0 26360 11333307157 26677 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import java.util.TimeZone; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.parser.BigDecimalParser; import org.apache.xmlrpc.parser.BigIntegerParser; import org.apache.xmlrpc.parser.BooleanParser; import org.apache.xmlrpc.parser.ByteArrayParser; import org.apache.xmlrpc.parser.CalendarParser; import org.apache.xmlrpc.parser.DateParser; import org.apache.xmlrpc.parser.DoubleParser; import org.apache.xmlrpc.parser.FloatParser; import org.apache.xmlrpc.parser.I1Parser; import org.apache.xmlrpc.parser.I2Parser; import org.apache.xmlrpc.parser.I4Parser; import org.apache.xmlrpc.parser.I8Parser; import org.apache.xmlrpc.parser.MapParser; import org.apache.xmlrpc.parser.NodeParser; import org.apache.xmlrpc.parser.NullParser; import org.apache.xmlrpc.parser.ObjectArrayParser; import org.apache.xmlrpc.parser.SerializableParser; import org.apache.xmlrpc.parser.StringParser; import org.apache.xmlrpc.parser.TypeParser; import org.apache.xmlrpc.serializer.BigDecimalSerializer; import org.apache.xmlrpc.serializer.BigIntegerSerializer; import org.apache.xmlrpc.serializer.BooleanSerializer; import org.apache.xmlrpc.serializer.ByteArraySerializer; import org.apache.xmlrpc.serializer.CalendarSerializer; import org.apache.xmlrpc.serializer.DateSerializer; import org.apache.xmlrpc.serializer.DoubleSerializer; import org.apache.xmlrpc.serializer.FloatSerializer; import org.apache.xmlrpc.serializer.I1Serializer; import org.apache.xmlrpc.serializer.I2Serializer; import org.apache.xmlrpc.serializer.I4Serializer; import org.apache.xmlrpc.serializer.I8Serializer; import org.apache.xmlrpc.serializer.ListSerializer; import org.apache.xmlrpc.serializer.MapSerializer; import org.apache.xmlrpc.serializer.NodeSerializer; import org.apache.xmlrpc.serializer.NullSerializer; import org.apache.xmlrpc.serializer.ObjectArraySerializer; import org.apache.xmlrpc.serializer.SerializableSerializer; import org.apache.xmlrpc.serializer.StringSerializer; import org.apache.xmlrpc.serializer.TypeSerializer; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.apache.xmlrpc.util.XmlRpcDateTimeDateFormat; import org.w3c.dom.Node; import org.xml.sax.SAXException; /** Default implementation of a type factory. */ public class TypeFactoryImpl implements TypeFactory { private static final TypeSerializer NULL_SERIALIZER = new NullSerializer(); private static final TypeSerializer STRING_SERIALIZER = new StringSerializer(); private static final TypeSerializer I4_SERIALIZER = new I4Serializer(); private static final TypeSerializer BOOLEAN_SERIALIZER = new BooleanSerializer(); private static final TypeSerializer DOUBLE_SERIALIZER = new DoubleSerializer(); private static final TypeSerializer BYTE_SERIALIZER = new I1Serializer(); private static final TypeSerializer SHORT_SERIALIZER = new I2Serializer(); private static final TypeSerializer LONG_SERIALIZER = new I8Serializer(); private static final TypeSerializer FLOAT_SERIALIZER = new FloatSerializer(); private static final TypeSerializer NODE_SERIALIZER = new NodeSerializer(); private static final TypeSerializer SERIALIZABLE_SERIALIZER = new SerializableSerializer(); private static final TypeSerializer BIGDECIMAL_SERIALIZER = new BigDecimalSerializer(); private static final TypeSerializer BIGINTEGER_SERIALIZER = new BigIntegerSerializer(); private static final TypeSerializer CALENDAR_SERIALIZER = new CalendarSerializer(); private final XmlRpcController controller; private DateSerializer dateSerializer; /** Creates a new instance. * @param pController The controller, which operates the type factory. */ public TypeFactoryImpl(XmlRpcController pController) { controller = pController; } /** Returns the controller, which operates the type factory. * @return The controller, an instance of * {@link org.apache.xmlrpc.client.XmlRpcClient}, * or {@link org.apache.xmlrpc.server.XmlRpcServer}. */ public XmlRpcController getController() { return controller; } public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException { if (pObject == null) { if (pConfig.isEnabledForExtensions()) { return NULL_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Null values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof String) { return STRING_SERIALIZER; } else if (pObject instanceof Byte) { if (pConfig.isEnabledForExtensions()) { return BYTE_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Byte values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Short) { if (pConfig.isEnabledForExtensions()) { return SHORT_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Short values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Integer) { return I4_SERIALIZER; } else if (pObject instanceof Long) { if (pConfig.isEnabledForExtensions()) { return LONG_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Long values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Boolean) { return BOOLEAN_SERIALIZER; } else if (pObject instanceof Float) { if (pConfig.isEnabledForExtensions()) { return FLOAT_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Float values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Double) { return DOUBLE_SERIALIZER; } else if (pObject instanceof Calendar) { if (pConfig.isEnabledForExtensions()) { return CALENDAR_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Calendar values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Date) { if (dateSerializer == null) { dateSerializer = new DateSerializer(new XmlRpcDateTimeDateFormat(){ private static final long serialVersionUID = 24345909123324234L; protected TimeZone getTimeZone() { return controller.getConfig().getTimeZone(); } }); } return dateSerializer; } else if (pObject instanceof byte[]) { return new ByteArraySerializer(); } else if (pObject instanceof Object[]) { return new ObjectArraySerializer(this, pConfig); } else if (pObject instanceof List) { return new ListSerializer(this, pConfig); } else if (pObject instanceof Map) { return new MapSerializer(this, pConfig); } else if (pObject instanceof Node) { if (pConfig.isEnabledForExtensions()) { return NODE_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("DOM nodes aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof BigInteger) { if (pConfig.isEnabledForExtensions()) { return BIGINTEGER_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("BigInteger values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof BigDecimal) { if (pConfig.isEnabledForExtensions()) { return BIGDECIMAL_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("BigDecimal values aren't supported, if isEnabledForExtensions() == false")); } } else if (pObject instanceof Serializable) { if (pConfig.isEnabledForExtensions()) { return SERIALIZABLE_SERIALIZER; } else { throw new SAXException(new XmlRpcExtensionException("Serializable objects aren't supported, if isEnabledForExtensions() == false")); } } else { return null; } } public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) { if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI)) { if (!pConfig.isEnabledForExtensions()) { return null; } if (NullSerializer.NIL_TAG.equals(pLocalName)) { return new NullParser(); } else if (I1Serializer.I1_TAG.equals(pLocalName)) { return new I1Parser(); } else if (I2Serializer.I2_TAG.equals(pLocalName)) { return new I2Parser(); } else if (I8Serializer.I8_TAG.equals(pLocalName)) { return new I8Parser(); } else if (FloatSerializer.FLOAT_TAG.equals(pLocalName)) { return new FloatParser(); } else if (NodeSerializer.DOM_TAG.equals(pLocalName)) { return new NodeParser(); } else if (BigDecimalSerializer.BIGDECIMAL_TAG.equals(pLocalName)) { return new BigDecimalParser(); } else if (BigIntegerSerializer.BIGINTEGER_TAG.equals(pLocalName)) { return new BigIntegerParser(); } else if (SerializableSerializer.SERIALIZABLE_TAG.equals(pLocalName)) { return new SerializableParser(); } else if (CalendarSerializer.CALENDAR_TAG.equals(pLocalName)) { return new CalendarParser(); } } else if ("".equals(pURI)) { if (I4Serializer.INT_TAG.equals(pLocalName) || I4Serializer.I4_TAG.equals(pLocalName)) { return new I4Parser(); } else if (BooleanSerializer.BOOLEAN_TAG.equals(pLocalName)) { return new BooleanParser(); } else if (DoubleSerializer.DOUBLE_TAG.equals(pLocalName)) { return new DoubleParser(); } else if (DateSerializer.DATE_TAG.equals(pLocalName)) { return new DateParser(new XmlRpcDateTimeDateFormat(){ private static final long serialVersionUID = 7585237706442299067L; protected TimeZone getTimeZone() { return controller.getConfig().getTimeZone(); } }); } else if (ObjectArraySerializer.ARRAY_TAG.equals(pLocalName)) { return new ObjectArrayParser(pConfig, pContext, this); } else if (MapSerializer.STRUCT_TAG.equals(pLocalName)) { return new MapParser(pConfig, pContext, this); } else if (ByteArraySerializer.BASE_64_TAG.equals(pLocalName)) { return new ByteArrayParser(); } else if (StringSerializer.STRING_TAG.equals(pLocalName)) { return new StringParser(); } } return null; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcController.java100644 0 0 5271 11333307157 27033 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcConfig; /** A common base class for * {@link org.apache.xmlrpc.server.XmlRpcServer} and * {@link org.apache.xmlrpc.client.XmlRpcClient}. */ public abstract class XmlRpcController { private XmlRpcWorkerFactory workerFactory = getDefaultXmlRpcWorkerFactory(); private int maxThreads; private TypeFactory typeFactory = new TypeFactoryImpl(this); /** Creates the controllers default worker factory. * @return The default factory for workers. */ protected abstract XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory(); /** Sets the maximum number of concurrent requests. This includes * both synchronous and asynchronous requests. * @param pMaxThreads Maximum number of threads or 0 to disable * the limit. */ public void setMaxThreads(int pMaxThreads) { maxThreads = pMaxThreads; } /** Returns the maximum number of concurrent requests. This includes * both synchronous and asynchronous requests. * @return Maximum number of threads or 0 to disable * the limit. */ public int getMaxThreads() { return maxThreads; } /** Sets the clients worker factory. * @param pFactory The factory being used to create workers. */ public void setWorkerFactory(XmlRpcWorkerFactory pFactory) { workerFactory = pFactory; } /** Returns the clients worker factory. * @return The factory being used to create workers. */ public XmlRpcWorkerFactory getWorkerFactory() { return workerFactory; } /** Returns the controllers default configuration. * @return The default configuration. */ public abstract XmlRpcConfig getConfig(); /** Sets the type factory. * @param pTypeFactory The type factory. */ public void setTypeFactory(TypeFactory pTypeFactory) { typeFactory = pTypeFactory; } /** Returns the type factory. * @return The type factory. */ public TypeFactory getTypeFactory() { return typeFactory; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcExtensionException.java100644 0 0 2455 11333307157 30544 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; /** This exception is thrown, if an attempt to use extensions * is made, but extensions aren't explicitly enabled. */ public class XmlRpcExtensionException extends XmlRpcException { private static final long serialVersionUID = 3617014169594311221L; /** Creates a new instance with the given error message. * @param pMessage The error message. */ public XmlRpcExtensionException(String pMessage) { super(0, pMessage); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcHttpConfig.java100644 0 0 3006 11333307157 26747 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; /** Interface of a configuration for HTTP requests. */ public interface XmlRpcHttpConfig extends XmlRpcStreamConfig { /** Returns the encoding being used to convert the String "username:password" * into bytes. * @return Encoding being used for basic HTTP authentication credentials, * or null, if the default encoding * ({@link org.apache.xmlrpc.common.XmlRpcStreamRequestConfig#UTF8_ENCODING}) * is being used. */ String getBasicEncoding(); /** Returns, whether a "Content-Length" header may be * omitted. The XML-RPC specification demands, that such * a header be present. * @return True, if the content length may be omitted. */ boolean isContentLengthOptional(); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcHttpRequestConfig.java100644 0 0 3665 11333307157 30333 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.common.XmlRpcHttpConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; /** Extension of {@link org.apache.xmlrpc.client.XmlRpcClientConfig} * for HTTP based transport. Provides details like server URL, * user credentials, and so on. */ public interface XmlRpcHttpRequestConfig extends XmlRpcStreamRequestConfig, XmlRpcHttpConfig { /** Returns the user name being used for basic HTTP authentication. * @return User name or null, if no basic HTTP authentication is being used. */ String getBasicUserName(); /** Returns the password being used for basic HTTP authentication. * @return Password or null, if no basic HTTP authentication is beind used. * @throws IllegalStateException A user name is configured, but no password. */ String getBasicPassword(); /** Return the connection timeout in milliseconds * @return connection timeout in milliseconds or 0 if no set */ int getConnectionTimeout(); /** Return the reply timeout in milliseconds * @return reply timeout in milliseconds or 0 if no set */ int getReplyTimeout(); } ././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcHttpRequestConfigImpl.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcHttpRequestConfigImpl.ja100644 0 0 6700 11333307157 30617 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcConfigImpl; /** Default implementation of a request configuration. */ public class XmlRpcHttpRequestConfigImpl extends XmlRpcConfigImpl implements XmlRpcHttpRequestConfig { private boolean gzipCompressing; private boolean gzipRequesting; private String basicUserName; private String basicPassword; private int connectionTimeout = 0; private int replyTimeout = 0; private boolean enabledForExceptions; /** Sets, whether gzip compression is being used for * transmitting the request. * @param pCompressing True for enabling gzip compression, * false otherwise. * @see #setGzipRequesting(boolean) */ public void setGzipCompressing(boolean pCompressing) { gzipCompressing = pCompressing; } public boolean isGzipCompressing() { return gzipCompressing; } /** Sets, whether gzip compression is requested for the * response. * @param pRequesting True for requesting gzip compression, * false otherwise. * @see #setGzipCompressing(boolean) */ public void setGzipRequesting(boolean pRequesting) { gzipRequesting = pRequesting; } public boolean isGzipRequesting() { return gzipRequesting; } /** Sets the user name for basic authentication. * @param pUser The user name. */ public void setBasicUserName(String pUser) { basicUserName = pUser; } public String getBasicUserName() { return basicUserName; } /** Sets the password for basic authentication. * @param pPassword The password. */ public void setBasicPassword(String pPassword) { basicPassword = pPassword; } public String getBasicPassword() { return basicPassword; } /** Set the connection timeout in milliseconds. * @param pTimeout connection timeout, 0 to disable it */ public void setConnectionTimeout(int pTimeout) { connectionTimeout = pTimeout; } public int getConnectionTimeout() { return connectionTimeout; } /** Set the reply timeout in milliseconds. * @param pTimeout reply timeout, 0 to disable it */ public void setReplyTimeout(int pTimeout) { replyTimeout = pTimeout; } public int getReplyTimeout() { return replyTimeout; } /** Sets, whether the response should contain a "faultCause" element * in case of errors. The "faultCause" is an exception, which the * server has trapped and written into a byte stream as a serializable * object. */ public void setEnabledForExceptions(boolean pEnabledForExceptions) { enabledForExceptions = pEnabledForExceptions; } public boolean isEnabledForExceptions() { return enabledForExceptions; } } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcInvocationException.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcInvocationException.java100644 0 0 3116 11333307157 30674 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; /** * This exception is thrown, if the server catches an exception, which * is thrown by the handler. */ public class XmlRpcInvocationException extends XmlRpcException { private static final long serialVersionUID = 7439737967784966169L; /** * Creates a new instance with the given error code, error message * and cause. */ public XmlRpcInvocationException(int pCode, String pMessage, Throwable pLinkedException) { super(pCode, pMessage, pLinkedException); } /** * Creates a new instance with the given error message and cause. */ public XmlRpcInvocationException(String pMessage, Throwable pLinkedException) { super(pMessage, pLinkedException); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcLoadException.java100644 0 0 2405 11333307157 27442 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; /** This exception is thrown, if the clients or servers maximum * number of concurrent threads is exceeded. */ public class XmlRpcLoadException extends XmlRpcException { private static final long serialVersionUID = 4050760511635272755L; /** Creates a new instance. * @param pMessage Error description. */ public XmlRpcLoadException(String pMessage) { super(0, pMessage, null); } } ././@LongLink100644 0 0 150 11333313337 10247 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcNotAuthorizedException.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcNotAuthorizedException.j100644 0 0 2405 11333307157 30672 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; /** This exception must be thrown, if the user isn't authenticated. */ public class XmlRpcNotAuthorizedException extends XmlRpcException { private static final long serialVersionUID = 3258410629709574201L; /** Creates a new instance with the given error message. * @param pMessage The error message. */ public XmlRpcNotAuthorizedException(String pMessage) { super(0, pMessage); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java100644 0 0 2533 11333307157 30236 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; /** Interface of an object, which is able to process * XML-RPC requests. */ public interface XmlRpcRequestProcessor { /** Processes the given request and returns a * result object. * @throws XmlRpcException Processing the request failed. */ Object execute(XmlRpcRequest pRequest) throws XmlRpcException; /** Returns the request processors {@link TypeConverterFactory}. */ TypeConverterFactory getTypeConverterFactory(); } ././@LongLink100644 0 0 151 11333313337 10250 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.100644 0 0 2363 11333307157 30725 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; /** Interface of an object, which may be used * to create instances of {@link XmlRpcRequestProcessor}. */ public interface XmlRpcRequestProcessorFactory { /** Returns the {@link XmlRpcRequestProcessor} being invoked. * @return Server object being invoked. This will typically * be a singleton instance, but could as well create a new * instance with any call. */ XmlRpcRequestProcessor getXmlRpcServer(); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamConfig.java100644 0 0 2436 11333307157 27271 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcConfig; /** Interface of a configuration for a stream based transport. */ public interface XmlRpcStreamConfig extends XmlRpcConfig { /** Default encoding (UTF-8). */ public static final String UTF8_ENCODING = "UTF-8"; /** Returns the encoding being used for data encoding, when writing * to a stream. * @return Suggested encoding, or null, if the {@link #UTF8_ENCODING} * is being used. */ String getEncoding(); } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestConfig.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestConfig.java100644 0 0 3741 11333307157 30642 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcRequestConfig; /** Interface of a client configuration for a transport, which * is implemented by writing to a stream. */ public interface XmlRpcStreamRequestConfig extends XmlRpcStreamConfig, XmlRpcRequestConfig { /** Returns, whether the request stream is being compressed. Note, * that the response stream may still be uncompressed. * @return Whether to use Gzip compression or not. Defaults to false. * @see #isGzipRequesting() */ boolean isGzipCompressing(); /** Returns, whether compression is requested for the response stream. * Note, that the request is stull uncompressed, unless * {@link #isGzipCompressing()} is activated. Also note, that the * server may still decide to send uncompressed data. * @return Whether to use Gzip compression or not. Defaults to false. * @see #isGzipCompressing() */ boolean isGzipRequesting(); /** Returns, whether the response should contain a "faultCause" element * in case of errors. The "faultCause" is an exception, which the * server has trapped and written into a byte stream as a serializable * object. */ boolean isEnabledForExceptions(); } ././@LongLink100644 0 0 150 11333313337 10247 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.j100644 0 0 2544 11333307157 30724 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; /** An instance of {@link XmlRpcRequestProcessor}, * which is processing an XML stream. */ public interface XmlRpcStreamRequestProcessor extends XmlRpcRequestProcessor { /** Reads an XML-RPC request from the connection * object and processes the request, writing the * result to the same connection object. * @throws XmlRpcException Processing the request failed. */ void execute(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcWorker.java100644 0 0 3341 11333307157 26155 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; /** An object, which executes requests on the controllers * behalf. These objects are mainly used for controlling the * clients or servers load, which is defined in terms of the * number of currently active workers. */ public interface XmlRpcWorker { /** Returns the workers controller. * @return The controller, an instance of * {@link org.apache.xmlrpc.client.XmlRpcClient}, or * {@link org.apache.xmlrpc.server.XmlRpcServer}. */ XmlRpcController getController(); /** Performs a synchronous request. The client worker extends * this interface with the ability to perform asynchronous * requests. * @param pRequest The request being performed. * @return The requests result. * @throws XmlRpcException Performing the request failed. */ Object execute(XmlRpcRequest pRequest) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/common/XmlRpcWorkerFactory.java100644 0 0 5721 11333307157 27511 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.common; import java.util.ArrayList; import java.util.List; /** A factory for {@link XmlRpcWorker} instances. */ public abstract class XmlRpcWorkerFactory { private final XmlRpcWorker singleton = newWorker(); private final XmlRpcController controller; private final List pool = new ArrayList(); private int numThreads; /** Creates a new instance. * @param pController The client controlling the factory. */ public XmlRpcWorkerFactory(XmlRpcController pController) { controller = pController; } /** Creates a new worker instance. * @return New instance of {@link XmlRpcWorker}. */ protected abstract XmlRpcWorker newWorker(); /** Returns the factory controller. * @return The controller, an instance of * {@link org.apache.xmlrpc.client.XmlRpcClient}, or * {@link org.apache.xmlrpc.server.XmlRpcServer}. */ public XmlRpcController getController() { return controller; } /** Returns a worker for synchronous processing. * @return An instance of {@link XmlRpcWorker}, which is ready * for use. * @throws XmlRpcLoadException The clients maximum number of concurrent * threads is exceeded. */ public synchronized XmlRpcWorker getWorker() throws XmlRpcLoadException { int max = controller.getMaxThreads(); if (max > 0 && numThreads == max) { throw new XmlRpcLoadException("Maximum number of concurrent requests exceeded: " + max); } if (max == 0) { return singleton; } ++numThreads; if (pool.size() == 0) { return newWorker(); } else { return (XmlRpcWorker) pool.remove(pool.size() - 1); } } /** Called, when the worker did its job. Frees resources and * decrements the number of concurrent requests. * @param pWorker The worker being released. */ public synchronized void releaseWorker(XmlRpcWorker pWorker) { --numThreads; int max = controller.getMaxThreads(); if (pWorker == singleton) { // Do nothing, it's the singleton } else { if (pool.size() < max) { pool.add(pWorker); } } } /** Returns the number of currently running requests. * @return Current number of concurrent requests. */ public synchronized int getCurrentRequests() { return numThreads; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/jaxb/JaxbParser.java100644 0 0 3671 11333307157 25261 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.jaxb; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.UnmarshallerHandler; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.parser.ExtParser; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A parser for JAXB objects. */ public class JaxbParser extends ExtParser { private final JAXBContext context; private UnmarshallerHandler handler; /** Creates a new instance with the given context. * @param pContext The context being used for creating unmarshallers. */ public JaxbParser(JAXBContext pContext) { context = pContext; } protected ContentHandler getExtHandler() throws SAXException { try { handler = context.createUnmarshaller().getUnmarshallerHandler(); } catch (JAXBException e) { throw new SAXException(e); } return handler; } protected String getTagName() { return JaxbSerializer.JAXB_TAG; } public Object getResult() throws XmlRpcException { try { return handler.getResult(); } catch (JAXBException e) { throw new XmlRpcException("Failed to create result object: " + e.getMessage(), e); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/jaxb/JaxbSerializer.java100644 0 0 6645 11333307157 26142 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.jaxb; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import org.apache.xmlrpc.serializer.ExtSerializer; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; /** A serializer for JAXB objects. */ public class JaxbSerializer extends ExtSerializer { private final JAXBContext context; /** The tag name for serializing JAXB objects. */ public static final String JAXB_TAG = "jaxb"; /** Creates a new instance with the given context. * @param pContext The context being used for creating marshallers. */ public JaxbSerializer(JAXBContext pContext) { context = pContext; } protected String getTagName() { return JAXB_TAG; } protected void serialize(final ContentHandler pHandler, Object pObject) throws SAXException { /* We must ensure, that startDocument() and endDocument() events * are suppressed. So we replace the content handler with the following: */ ContentHandler h = new ContentHandler() { public void endDocument() throws SAXException {} public void startDocument() throws SAXException {} public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { pHandler.characters(pChars, pOffset, pLength); } public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException { pHandler.ignorableWhitespace(pChars, pOffset, pLength); } public void endPrefixMapping(String pPrefix) throws SAXException { pHandler.endPrefixMapping(pPrefix); } public void skippedEntity(String pName) throws SAXException { pHandler.endPrefixMapping(pName); } public void setDocumentLocator(Locator pLocator) { pHandler.setDocumentLocator(pLocator); } public void processingInstruction(String pTarget, String pData) throws SAXException { pHandler.processingInstruction(pTarget, pData); } public void startPrefixMapping(String pPrefix, String pURI) throws SAXException { pHandler.startPrefixMapping(pPrefix, pURI); } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { pHandler.endElement(pURI, pLocalName, pQName); } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { pHandler.startElement(pURI, pLocalName, pQName, pAttrs); } }; try { context.createMarshaller().marshal(pObject, h); } catch (JAXBException e) { Throwable t = e.getLinkedException(); if (t != null && t instanceof SAXException) { throw (SAXException) t; } else { throw new SAXException(e); } } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/jaxb/JaxbTypeFactory.java100644 0 0 4760 11333307157 26276 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.jaxb; import javax.xml.bind.Element; import javax.xml.bind.JAXBContext; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.common.TypeFactoryImpl; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.parser.TypeParser; import org.apache.xmlrpc.serializer.TypeSerializer; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.xml.sax.SAXException; /** A type factory with support for JAXB objects. */ public class JaxbTypeFactory extends TypeFactoryImpl { private final JAXBContext context; private final JaxbSerializer serializer; /** Creates a new instance with the given controller and * JAXB context. * @param pController The controller, which will invoke the factory. * @param pContext The context being used to create marshallers * and unmarshallers. */ public JaxbTypeFactory(XmlRpcController pController, JAXBContext pContext) { super(pController); context = pContext; serializer = new JaxbSerializer(context); } public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) { TypeParser tp = super.getParser(pConfig, pContext, pURI, pLocalName); if (tp == null) { if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI) && JaxbSerializer.JAXB_TAG.equals(pLocalName)) { return new JaxbParser(context); } } return tp; } public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException { TypeSerializer ts = super.getSerializer(pConfig, pObject); if (ts == null) { if (pObject instanceof Element) { return serializer; } } return ts; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/AtomicParser.java100644 0 0 4520 11333307161 26146 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import javax.xml.namespace.QName; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Abstract base implementation of {@link org.apache.xmlrpc.parser.TypeParser} * for parsing an atomic value. */ public abstract class AtomicParser extends TypeParserImpl { private int level; protected StringBuffer sb; /** Creates a new instance. */ protected AtomicParser() { } protected abstract void setResult(String pResult) throws SAXException; public void startDocument() throws SAXException { level = 0; } public void characters(char[] pChars, int pStart, int pLength) throws SAXException { if (sb == null) { if (!isEmpty(pChars, pStart, pLength)) { throw new SAXParseException("Unexpected non-whitespace characters", getDocumentLocator()); } } else { sb.append(pChars, pStart, pLength); } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { if (--level == 0) { setResult(sb.toString()); } else { throw new SAXParseException("Unexpected end tag in atomic element: " + new QName(pURI, pLocalName), getDocumentLocator()); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { if (level++ == 0) { sb = new StringBuffer(); } else { throw new SAXParseException("Unexpected start tag in atomic element: " + new QName(pURI, pLocalName), getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/BigDecimalParser.java100644 0 0 2623 11333307161 26714 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.math.BigDecimal; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for BigDecimal values. */ public class BigDecimalParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new BigDecimal(pResult)); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse BigDecimal value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/BigIntegerParser.java100644 0 0 2623 11333307161 26753 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.math.BigInteger; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for BigInteger values. */ public class BigIntegerParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new BigInteger(pResult)); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse BigInteger value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/BooleanParser.java100644 0 0 2505 11333307161 26312 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for boolean values. */ public class BooleanParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { String s = pResult.trim(); if ("1".equals(s)) { super.setResult(Boolean.TRUE); } else if ("0".equals(s)) { super.setResult(Boolean.FALSE); } else { throw new SAXParseException("Failed to parse boolean value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/ByteArrayParser.java100644 0 0 5363 11333307161 26642 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.xml.namespace.QName; import org.apache.ws.commons.util.Base64; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** A parser for base64 elements. */ public class ByteArrayParser extends TypeParserImpl { private int level; private ByteArrayOutputStream baos; private Base64.Decoder decoder; public void startDocument() throws SAXException { level = 0; } public void characters(char[] pChars, int pStart, int pLength) throws SAXException { if (baos == null) { if (!isEmpty(pChars, pStart, pLength)) { throw new SAXParseException("Unexpected non-whitespace characters", getDocumentLocator()); } } else { try { decoder.write(pChars, pStart, pLength); } catch (IOException e) { throw new SAXParseException("Failed to decode base64 stream.", getDocumentLocator(), e); } } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { if (--level == 0) { try { decoder.flush(); } catch (IOException e) { throw new SAXParseException("Failed to decode base64 stream.", getDocumentLocator(), e); } setResult(baos.toByteArray()); } else { throw new SAXParseException("Unexpected end tag in atomic element: " + new QName(pURI, pLocalName), getDocumentLocator()); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { if (level++ == 0) { baos = new ByteArrayOutputStream(); decoder = new Base64.Decoder(1024){ protected void writeBuffer(byte[] pBytes, int pOffset, int pLen) throws IOException { baos.write(pBytes, pOffset, pLen); } }; } else { throw new SAXParseException("Unexpected start tag in atomic element: " + new QName(pURI, pLocalName), getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/CalendarParser.java100644 0 0 3317 11333307161 26446 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.text.ParseException; import org.apache.ws.commons.util.XsDateTimeFormat; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for integer values. */ public class CalendarParser extends AtomicParser { private static final XsDateTimeFormat format = new XsDateTimeFormat(); protected void setResult(String pResult) throws SAXException { try { super.setResult(format.parseObject(pResult.trim())); } catch (ParseException e) { int offset = e.getErrorOffset(); final String msg; if (offset == -1) { msg = "Failed to parse dateTime value: " + pResult; } else { msg = "Failed to parse dateTime value " + pResult + " at position " + e.getErrorOffset(); } throw new SAXParseException(msg, getDocumentLocator(), e); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/DateParser.java100644 0 0 3506 11333307161 25612 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.text.Format; import java.text.ParseException; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for integer values. */ public class DateParser extends AtomicParser { private final Format f; /** Creates a new instance with the given format. */ public DateParser(Format pFormat) { f = pFormat; } protected void setResult(String pResult) throws SAXException { final String s = pResult.trim(); if (s.length() == 0) { return; } try { super.setResult(f.parseObject(s)); } catch (ParseException e) { final String msg; int offset = e.getErrorOffset(); if (e.getErrorOffset() == -1) { msg = "Failed to parse date value: " + pResult; } else { msg = "Failed to parse date value " + pResult + " at position " + offset; } throw new SAXParseException(msg, getDocumentLocator(), e); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/DoubleParser.java100644 0 0 2367 11333307161 26153 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for double values. */ public class DoubleParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Double(pResult)); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse double value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/ExtParser.java100644 0 0 10713 11333307161 25513 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Base class for parsing external XML representations, like DOM, * or JAXB. */ public abstract class ExtParser implements TypeParser { private Locator locator; private ContentHandler handler; private int level = 0; private final List prefixes = new ArrayList(); /** Returns a content handler for parsing the actual * contents. * @return A SAX handler for parsing the XML inside * the outer ex:foo element. * @throws SAXException Creating the handler failed. */ protected abstract ContentHandler getExtHandler() throws SAXException; /** Returns the outer node name. */ protected abstract String getTagName(); public void endDocument() throws SAXException { } public void startDocument() throws SAXException { } public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { if (handler == null) { if (!TypeParserImpl.isEmpty(pChars, pOffset, pLength)) { throw new SAXParseException("Unexpected non-whitespace content: " + new String(pChars, pOffset, pLength), locator); } } else { handler.characters(pChars, pOffset, pLength); } } public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException { if (handler != null) { ignorableWhitespace(pChars, pOffset, pLength); } } public void endPrefixMapping(String pPrefix) throws SAXException { if (handler != null) { handler.endPrefixMapping(pPrefix); } } public void skippedEntity(String pName) throws SAXException { if (handler == null) { throw new SAXParseException("Don't know how to handle entity " + pName, locator); } else { handler.skippedEntity(pName); } } public void setDocumentLocator(Locator pLocator) { locator = pLocator; if (handler != null) { handler.setDocumentLocator(pLocator); } } public void processingInstruction(String pTarget, String pData) throws SAXException { if (handler != null) { handler.processingInstruction(pTarget, pData); } } public void startPrefixMapping(String pPrefix, String pURI) throws SAXException { if (handler == null) { prefixes.add(pPrefix); prefixes.add(pURI); } else { handler.startPrefixMapping(pPrefix, pURI); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { switch (level++) { case 0: final String tag = getTagName(); if (!XmlRpcWriter.EXTENSIONS_URI.equals(pURI) || !tag.equals(pLocalName)) { throw new SAXParseException("Expected " + new QName(XmlRpcWriter.EXTENSIONS_URI, tag) + ", got " + new QName(pURI, pLocalName), locator); } handler = getExtHandler(); handler.startDocument(); for (int i = 0; i < prefixes.size(); i += 2) { handler.startPrefixMapping((String) prefixes.get(i), (String) prefixes.get(i+1)); } break; default: handler.startElement(pURI, pLocalName, pQName, pAttrs); break; } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { switch (--level) { case 0: for (int i = 0; i < prefixes.size(); i += 2) { handler.endPrefixMapping((String) prefixes.get(i)); } handler.endDocument(); handler = null; break; default: handler.endElement(pURI, pLocalName, pQName); break; } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/FloatParser.java100644 0 0 2363 11333307161 26002 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for float values. */ public class FloatParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Float(pResult)); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse float value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/I1Parser.java100644 0 0 2364 11333307161 25207 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for byte values. */ public class I1Parser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Byte(pResult.trim())); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse byte value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/I2Parser.java100644 0 0 2367 11333307161 25213 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for short values. */ public class I2Parser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Short(pResult.trim())); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse short value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/I4Parser.java100644 0 0 2375 11333307161 25214 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for integer values. */ public class I4Parser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Integer(pResult.trim())); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse integer value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/I8Parser.java100644 0 0 2364 11333307161 25216 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for long values. */ public class I8Parser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Long(pResult.trim())); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse long value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/LongParser.java100644 0 0 2366 11333307161 25637 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for long values. */ public class LongParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { try { super.setResult(new Long(pResult.trim())); } catch (NumberFormatException e) { throw new SAXParseException("Failed to parse long value: " + pResult, getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/MapParser.java100644 0 0 15072 11333307161 25473 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.util.HashMap; import java.util.Map; import javax.xml.namespace.QName; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.serializer.MapSerializer; import org.apache.xmlrpc.serializer.TypeSerializerImpl; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** {@link org.apache.xmlrpc.parser.TypeParser} implementation * for maps. */ public class MapParser extends RecursiveTypeParserImpl { private int level = 0; private StringBuffer nameBuffer = new StringBuffer(); private Object nameObject; private Map map; private boolean inName, inValue, doneValue; /** Creates a new instance. * @param pConfig The request or response configuration. * @param pContext The namespace context. * @param pFactory The factory. */ public MapParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, TypeFactory pFactory) { super(pConfig, pContext, pFactory); } protected void addResult(Object pResult) throws SAXException { if (inName) { nameObject = pResult; } else { if (nameObject == null) { throw new SAXParseException("Invalid state: Expected name", getDocumentLocator()); } else { if (map.containsKey(nameObject)) { throw new SAXParseException("Duplicate name: " + nameObject, getDocumentLocator()); } else { map.put(nameObject, pResult); } } } } public void startDocument() throws SAXException { super.startDocument(); level = 0; map = new HashMap(); inValue = inName = false; } public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { if (inName && !inValue) { nameBuffer.append(pChars, pOffset, pLength); } else { super.characters(pChars, pOffset, pLength); } } public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException { if (inName) { characters(pChars, pOffset, pLength); } else { super.ignorableWhitespace(pChars, pOffset, pLength); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { switch (level++) { case 0: if (!"".equals(pURI) || !MapSerializer.STRUCT_TAG.equals(pLocalName)) { throw new SAXParseException("Expected " + MapSerializer.STRUCT_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 1: if (!"".equals(pURI) || !MapSerializer.MEMBER_TAG.equals(pLocalName)) { throw new SAXParseException("Expected " + MapSerializer.MEMBER_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } doneValue = inName = inValue = false; nameObject = null; nameBuffer.setLength(0); break; case 2: if (doneValue) { throw new SAXParseException("Expected /" + MapSerializer.MEMBER_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } if ("".equals(pURI) && MapSerializer.NAME_TAG.equals(pLocalName)) { if (nameObject == null) { inName = true; } else { throw new SAXParseException("Expected " + TypeSerializerImpl.VALUE_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else if ("".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) { if (nameObject == null) { throw new SAXParseException("Expected " + MapSerializer.NAME_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } else { inValue = true; startValueTag(); } } break; case 3: if (inName && "".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) { if (cfg.isEnabledForExtensions()) { inValue = true; startValueTag(); } else { throw new SAXParseException("Expected /" + MapSerializer.NAME_TAG + ", got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { super.startElement(pURI, pLocalName, pQName, pAttrs); } break; default: super.startElement(pURI, pLocalName, pQName, pAttrs); break; } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { switch (--level) { case 0: setResult(map); break; case 1: break; case 2: if (inName) { inName = false; if (nameObject == null) { nameObject = nameBuffer.toString(); } else { for (int i = 0; i < nameBuffer.length(); i++) { if (!Character.isWhitespace(nameBuffer.charAt(i))) { throw new SAXParseException("Unexpected non-whitespace character in member name", getDocumentLocator()); } } } } else if (inValue) { endValueTag(); doneValue = true; } break; case 3: if (inName && inValue && "".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) { endValueTag(); } else { super.endElement(pURI, pLocalName, pQName); } break; default: super.endElement(pURI, pLocalName, pQName); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/NodeParser.java100644 0 0 3265 11333307161 25624 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.ws.commons.serialize.DOMBuilder; import org.apache.xmlrpc.serializer.NodeSerializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A parser for DOM document. */ public class NodeParser extends ExtParser { private static final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); private final DOMBuilder builder = new DOMBuilder(); protected String getTagName() { return NodeSerializer.DOM_TAG; } protected ContentHandler getExtHandler() throws SAXException { try { builder.setTarget(dbf.newDocumentBuilder().newDocument()); } catch (ParserConfigurationException e) { throw new SAXException(e); } return builder; } public Object getResult() { return builder.getTarget(); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/NullParser.java100644 0 0 2422 11333307161 25643 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** SAX parser for a nil element (null value). */ public class NullParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { if (pResult == null || "".equals(pResult.trim())) { super.setResult((Object) null); } else { throw new SAXParseException("Unexpected characters in nil element.", getDocumentLocator()); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/ObjectArrayParser.java100644 0 0 6444 11333307161 27146 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.serializer.ObjectArraySerializer; import org.apache.xmlrpc.serializer.TypeSerializerImpl; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Parser for an array of objects, as created by * {@link org.apache.xmlrpc.serializer.ObjectArraySerializer}. */ public class ObjectArrayParser extends RecursiveTypeParserImpl { private int level = 0; private List list; /** Creates a new instance. * @param pContext The namespace context. * @param pConfig The request or response configuration. * @param pFactory The type factory. */ public ObjectArrayParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, TypeFactory pFactory) { super(pConfig, pContext, pFactory); } public void startDocument() throws SAXException { level = 0; list = new ArrayList(); super.startDocument(); } protected void addResult(Object pValue) { list.add(pValue); } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { switch (--level) { case 0: setResult(list.toArray()); break; case 1: break; case 2: endValueTag(); break; default: super.endElement(pURI, pLocalName, pQName); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { switch (level++) { case 0: if (!"".equals(pURI) || !ObjectArraySerializer.ARRAY_TAG.equals(pLocalName)) { throw new SAXParseException("Expected array element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 1: if (!"".equals(pURI) || !ObjectArraySerializer.DATA_TAG.equals(pLocalName)) { throw new SAXParseException("Expected data element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 2: if (!"".equals(pURI) || !TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) { throw new SAXParseException("Expected data element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } startValueTag(); break; default: super.startElement(pURI, pLocalName, pQName, pAttrs); break; } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/RecursiveTypeParserImpl.java100644 0 0 13605 11333307161 30411 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import javax.xml.namespace.QName; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcExtensionException; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Abstract base class of a parser, that invokes other type * parsers recursively. */ public abstract class RecursiveTypeParserImpl extends TypeParserImpl { private final NamespaceContextImpl context; protected final XmlRpcStreamConfig cfg; private final TypeFactory factory; private boolean inValueTag; private TypeParser typeParser; private StringBuffer text = new StringBuffer(); /** Creates a new instance. * @param pContext The namespace context. * @param pConfig The request or response configuration. * @param pFactory The type factory. */ protected RecursiveTypeParserImpl(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, TypeFactory pFactory) { cfg = pConfig; context = pContext; factory = pFactory; } /** * Called to start a value tag. * @throws SAXException */ protected void startValueTag() throws SAXException { inValueTag = true; text.setLength(0); typeParser = null; } protected abstract void addResult(Object pResult) throws SAXException; protected void endValueTag() throws SAXException { if (inValueTag) { if (typeParser == null) { addResult(text.toString()); text.setLength(0); } else { typeParser.endDocument(); try { addResult(typeParser.getResult()); } catch (XmlRpcException e) { throw new SAXException(e); } typeParser = null; } } else { throw new SAXParseException("Invalid state: Not inside value tag.", getDocumentLocator()); } } public void startDocument() throws SAXException { inValueTag = false; text.setLength(0); typeParser = null; } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { if (inValueTag) { if (typeParser == null) { throw new SAXParseException("Invalid state: No type parser configured.", getDocumentLocator()); } else { typeParser.endElement(pURI, pLocalName, pQName); } } else { throw new SAXParseException("Invalid state: Not inside value tag.", getDocumentLocator()); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { if (inValueTag) { if (typeParser == null) { typeParser = factory.getParser(cfg, context, pURI, pLocalName); if (typeParser == null) { if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI) && !cfg.isEnabledForExtensions()) { String msg = "The tag " + new QName(pURI, pLocalName) + " is invalid, if isEnabledForExtensions() == false."; throw new SAXParseException(msg, getDocumentLocator(), new XmlRpcExtensionException(msg)); } else { throw new SAXParseException("Unknown type: " + new QName(pURI, pLocalName), getDocumentLocator()); } } typeParser.setDocumentLocator(getDocumentLocator()); typeParser.startDocument(); if (text.length() > 0) { typeParser.characters(text.toString().toCharArray(), 0, text.length()); text.setLength(0); } } typeParser.startElement(pURI, pLocalName, pQName, pAttrs); } else { throw new SAXParseException("Invalid state: Not inside value tag.", getDocumentLocator()); } } public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { if (typeParser == null) { if (inValueTag) { text.append(pChars, pOffset, pLength); } else { super.characters(pChars, pOffset, pLength); } } else { typeParser.characters(pChars, pOffset, pLength); } } public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException { if (typeParser == null) { if (inValueTag) { text.append(pChars, pOffset, pLength); } else { super.ignorableWhitespace(pChars, pOffset, pLength); } } else { typeParser.ignorableWhitespace(pChars, pOffset, pLength); } } public void processingInstruction(String pTarget, String pData) throws SAXException { if (typeParser == null) { super.processingInstruction(pTarget, pData); } else { typeParser.processingInstruction(pTarget, pData); } } public void skippedEntity(String pEntity) throws SAXException { if (typeParser == null) { super.skippedEntity(pEntity); } else { typeParser.skippedEntity(pEntity); } } public void startPrefixMapping(String pPrefix, String pURI) throws SAXException { if (typeParser == null) { super.startPrefixMapping(pPrefix, pURI); } else { context.startPrefixMapping(pPrefix, pURI); } } public void endPrefixMapping(String pPrefix) throws SAXException { if (typeParser == null) { super.endPrefixMapping(pPrefix); } else { context.endPrefixMapping(pPrefix); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/SerializableParser.java100644 0 0 3074 11333307161 27343 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import org.apache.xmlrpc.XmlRpcException; /** A parser for serializable objects. */ public class SerializableParser extends ByteArrayParser { public Object getResult() throws XmlRpcException { try { byte[] res = (byte[]) super.getResult(); ByteArrayInputStream bais = new ByteArrayInputStream(res); ObjectInputStream ois = new ObjectInputStream(bais); return ois.readObject(); } catch (IOException e) { throw new XmlRpcException("Failed to read result object: " + e.getMessage(), e); } catch (ClassNotFoundException e) { throw new XmlRpcException("Failed to load class for result object: " + e.getMessage(), e); } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/StringParser.java100644 0 0 2102 11333307161 26172 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.xml.sax.SAXException; /** Parser implementation for parsing a string. */ public class StringParser extends AtomicParser { protected void setResult(String pResult) throws SAXException { super.setResult((Object) pResult); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/TypeParser.java100644 0 0 2537 11333307161 25661 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.apache.xmlrpc.XmlRpcException; import org.xml.sax.ContentHandler; /** Interface of a SAX handler parsing a single parameter or * result object. */ public interface TypeParser extends ContentHandler { /** Returns the parsed object. * @return The parameter or result object. * @throws XmlRpcException Creating the result object failed. * @throws IllegalStateException The method was invoked before * {@link org.xml.sax.ContentHandler#endDocument}. */ public Object getResult() throws XmlRpcException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/TypeParserImpl.java100644 0 0 5467 11333307161 26510 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import org.apache.xmlrpc.XmlRpcException; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** Abstract base implementation of a {@link org.apache.xmlrpc.parser.TypeParser}, * for derivation of subclasses. */ public abstract class TypeParserImpl implements TypeParser { private Object result; private Locator locator; /** Sets the result object. * @param pResult The result object. */ public void setResult(Object pResult) { result = pResult; } public Object getResult() throws XmlRpcException { return result; } /** Returns the document locator. * @return Locator object describing the current location within the * document. */ public Locator getDocumentLocator() { return locator; } public void setDocumentLocator(Locator pLocator) { locator = pLocator; } /** PI's are by default ignored. */ public void processingInstruction(String pTarget, String pData) throws SAXException { } /** Skipped entities raise an exception by default. */ public void skippedEntity(String pName) throws SAXException { throw new SAXParseException("Don't know how to handle entity " + pName, getDocumentLocator()); } public void startPrefixMapping(String pPrefix, String pURI) throws SAXException { } public void endPrefixMapping(String pPrefix) throws SAXException { } public void endDocument() throws SAXException { } public void startDocument() throws SAXException { } protected static boolean isEmpty(char[] pChars, int pStart, int pLength) { for (int i = 0; i < pLength; i++) { if (!Character.isWhitespace(pChars[pStart+i])) { return false; } } return true; } public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { if (!isEmpty(pChars, pOffset, pLength)) { throw new SAXParseException("Unexpected non-whitespace character data", getDocumentLocator()); } } public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException { } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/XmlRpcRequestParser.java100644 0 0 12546 11333307161 27537 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** A SAX parser for an {@link org.apache.xmlrpc.client.XmlRpcClient}'s * request. */ public class XmlRpcRequestParser extends RecursiveTypeParserImpl { private int level; private boolean inMethodName; private String methodName; private List params; /** Creates a new instance, which parses a clients request. * @param pConfig The client configuration. * @param pTypeFactory The type factory. */ public XmlRpcRequestParser(XmlRpcStreamConfig pConfig, TypeFactory pTypeFactory) { super(pConfig, new NamespaceContextImpl(), pTypeFactory); } protected void addResult(Object pResult) { params.add(pResult); } public void startDocument() throws SAXException { super.startDocument(); level = 0; inMethodName = false; methodName = null; params = null; } public void characters(char[] pChars, int pOffset, int pLength) throws SAXException { if (inMethodName) { String s = new String(pChars, pOffset, pLength); methodName = methodName == null ? s : methodName + s; } else { super.characters(pChars, pOffset, pLength); } } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { switch (level++) { case 0: if (!"".equals(pURI) || !"methodCall".equals(pLocalName)) { throw new SAXParseException("Expected root element 'methodCall', got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 1: if (methodName == null) { if ("".equals(pURI) && "methodName".equals(pLocalName)) { inMethodName = true; } else { throw new SAXParseException("Expected methodName element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else if (params == null) { if ("".equals(pURI) && "params".equals(pLocalName)) { params = new ArrayList(); } else { throw new SAXParseException("Expected params element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { throw new SAXParseException("Expected /methodCall, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 2: if (!"".equals(pURI) || !"param".equals(pLocalName)) { throw new SAXParseException("Expected param element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 3: if (!"".equals(pURI) || !"value".equals(pLocalName)) { throw new SAXParseException("Expected value element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } startValueTag(); break; default: super.startElement(pURI, pLocalName, pQName, pAttrs); break; } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { switch(--level) { case 0: break; case 1: if (inMethodName) { if ("".equals(pURI) && "methodName".equals(pLocalName)) { if (methodName == null) { methodName = ""; } } else { throw new SAXParseException("Expected /methodName, got " + new QName(pURI, pLocalName), getDocumentLocator()); } inMethodName = false; } else if (!"".equals(pURI) || !"params".equals(pLocalName)) { throw new SAXParseException("Expected /params, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 2: if (!"".equals(pURI) || !"param".equals(pLocalName)) { throw new SAXParseException("Expected /param, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 3: if (!"".equals(pURI) || !"value".equals(pLocalName)) { throw new SAXParseException("Expected /value, got " + new QName(pURI, pLocalName), getDocumentLocator()); } endValueTag(); break; default: super.endElement(pURI, pLocalName, pQName); break; } } /** Returns the method name being invoked. * @return Requested method name. */ public String getMethodName() { return methodName; } /** Returns the parameter list. * @return Parameter list. */ public List getParams() { return params; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/parser/XmlRpcResponseParser.java100644 0 0 16313 11333307161 27701 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.parser; import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; import java.util.Map; import javax.xml.namespace.QName; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** A SAX parser for an {@link org.apache.xmlrpc.server.XmlRpcServer}'s * response. */ public class XmlRpcResponseParser extends RecursiveTypeParserImpl { private int level; private boolean isSuccess; private int errorCode; private String errorMessage; private Throwable errorCause; /** Creates a new instance. * @param pConfig The response configuration. * @param pTypeFactory The type factory for creating instances of * {@link TypeParser}. */ public XmlRpcResponseParser(XmlRpcStreamRequestConfig pConfig, TypeFactory pTypeFactory) { super(pConfig, new NamespaceContextImpl(), pTypeFactory); } protected void addResult(Object pResult) throws SAXException { if (isSuccess) { super.setResult(pResult); } else { Map map = (Map) pResult; Integer faultCode = (Integer) map.get("faultCode"); if (faultCode == null) { throw new SAXParseException("Missing faultCode", getDocumentLocator()); } try { errorCode = faultCode.intValue(); } catch (NumberFormatException e) { throw new SAXParseException("Invalid faultCode: " + faultCode, getDocumentLocator()); } errorMessage = (String) map.get("faultString"); Object exception = map.get("faultCause"); if (exception != null) { try { byte[] bytes = (byte[]) exception; ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); errorCause = (Throwable) ois.readObject(); ois.close(); bais.close(); } catch (Throwable t) { // Ignore me } } } } public void startDocument() throws SAXException { super.startDocument(); level = 0; isSuccess = false; errorCode = 0; errorMessage = null; } public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException { switch (level++) { case 0: if (!"".equals(pURI) || !"methodResponse".equals(pLocalName)) { throw new SAXParseException("Expected methodResponse element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 1: if ("".equals(pURI) && "params".equals(pLocalName)) { isSuccess = true; } else if ("".equals(pURI) && "fault".equals(pLocalName)) { isSuccess = false; } else { throw new SAXParseException("Expected params or fault element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 2: if (isSuccess) { if (!"".equals(pURI) || !"param".equals(pLocalName)) { throw new SAXParseException("Expected param element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { if ("".equals(pURI) && "value".equals(pLocalName)) { startValueTag(); } else { throw new SAXParseException("Expected value element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } break; case 3: if (isSuccess) { if ("".equals(pURI) && "value".equals(pLocalName)) { startValueTag(); } else { throw new SAXParseException("Expected value element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { super.startElement(pURI, pLocalName, pQName, pAttrs); } break; default: super.startElement(pURI, pLocalName, pQName, pAttrs); break; } } public void endElement(String pURI, String pLocalName, String pQName) throws SAXException { switch (--level) { case 0: if (!"".equals(pURI) || !"methodResponse".equals(pLocalName)) { throw new SAXParseException("Expected /methodResponse element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; case 1: { String tag; if (isSuccess) { tag = "params"; } else { tag = "fault"; } if (!"".equals(pURI) || !tag.equals(pLocalName)) { throw new SAXParseException("Expected /" + tag + " element, got " + new QName(pURI, pLocalName), getDocumentLocator()); } break; } case 2: if (isSuccess) { if (!"".equals(pURI) || !"param".equals(pLocalName)) { throw new SAXParseException("Expected /param, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { if ("".equals(pURI) && "value".equals(pLocalName)) { endValueTag(); } else { throw new SAXParseException("Expected /value, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } break; case 3: if (isSuccess) { if ("".equals(pURI) && "value".equals(pLocalName)) { endValueTag(); } else { throw new SAXParseException("Expected /value, got " + new QName(pURI, pLocalName), getDocumentLocator()); } } else { super.endElement(pURI, pLocalName, pQName); } break; default: super.endElement(pURI, pLocalName, pQName); break; } } /** Returns whether the response returned success. If so, the * result object may be fetched using {@link #getResult()}. * Otherwise, you may use the methods * {@link #getErrorCode()} and {@link #getErrorMessage()} to * check for error reasons. * @return True, if the response indicated success, false otherwise. */ public boolean isSuccess() { return isSuccess; } /** If the response contained a fault, returns the error code. * @return The numeric error code. */ public int getErrorCode() { return errorCode; } /** If the response contained a fault, returns the error message. * @return The error message. */ public String getErrorMessage() { return errorMessage; } /** If the response contained a fault, returns the (optional) * exception. */ public Throwable getErrorCause() { return errorCause; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/BaseXmlWriterFactory.java100644 0 0 4100 11333307160 30503 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import org.apache.ws.commons.serialize.XMLWriter; import org.apache.ws.commons.serialize.XMLWriterImpl; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; /** The default instance of {@link XmlWriterFactory} creates * instances of {@link org.apache.ws.commons.serialize.XMLWriterImpl}. * This works for any Java version since 1.2 */ public class BaseXmlWriterFactory implements XmlWriterFactory { protected XMLWriter newXmlWriter() { return new XMLWriterImpl(); } public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream) throws XmlRpcException { XMLWriter xw = newXmlWriter(); xw.setDeclarating(true); String enc = pConfig.getEncoding(); if (enc == null) { enc = XmlRpcStreamConfig.UTF8_ENCODING; } xw.setEncoding(enc); xw.setIndenting(false); xw.setFlushing(true); try { xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc))); } catch (UnsupportedEncodingException e) { throw new XmlRpcException("Unsupported encoding: " + enc, e); } return xw; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/BigDecimalSerializer.java100644 0 0 2631 11333307160 30444 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for BigDecimal. */ public class BigDecimalSerializer extends TypeSerializerImpl { /** Tag name of a BigDecimal value. */ public static final String BIGDECIMAL_TAG = "bigdecimal"; private static final String EX_BIGDECIMAL_TAG = "ex:" + BIGDECIMAL_TAG; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, BIGDECIMAL_TAG, EX_BIGDECIMAL_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/BigIntegerSerializer.java100644 0 0 2631 11333307160 30503 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for BigInteger. */ public class BigIntegerSerializer extends TypeSerializerImpl { /** Tag name of a BigDecimal value. */ public static final String BIGINTEGER_TAG = "biginteger"; private static final String EX_BIGINTEGER_TAG = "ex:" + BIGINTEGER_TAG; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, BIGINTEGER_TAG, EX_BIGINTEGER_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/BooleanSerializer.java100644 0 0 2564 11333307160 30050 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for booleans. */ public class BooleanSerializer extends TypeSerializerImpl { /** Tag name of a boolean value. */ public static final String BOOLEAN_TAG = "boolean"; private static final char[] TRUE = new char[]{'1'}; private static final char[] FALSE = new char[]{'0'}; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, BOOLEAN_TAG, ((Boolean) pObject).booleanValue() ? TRUE : FALSE); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ByteArraySerializer.java100644 0 0 3745 11333307160 30375 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.IOException; import org.apache.ws.commons.util.Base64; import org.apache.ws.commons.util.Base64.Encoder; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for byte arrays. */ public class ByteArraySerializer extends TypeSerializerImpl { /** Tag name of a base64 value. */ public static final String BASE_64_TAG = "base64"; public void write(final ContentHandler pHandler, Object pObject) throws SAXException { pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", BASE_64_TAG, BASE_64_TAG, ZERO_ATTRIBUTES); byte[] buffer = (byte[]) pObject; if (buffer.length > 0) { char[] charBuffer = new char[buffer.length >= 1024 ? 1024 : ((buffer.length+3)/4)*4]; Encoder encoder = new Base64.SAXEncoder(charBuffer, 0, null, pHandler); try { encoder.write(buffer, 0, buffer.length); encoder.flush(); } catch (Base64.SAXIOException e) { throw e.getSAXException(); } catch (IOException e) { throw new SAXException(e); } } pHandler.endElement("", BASE_64_TAG, BASE_64_TAG); pHandler.endElement("", VALUE_TAG, VALUE_TAG); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/CalendarSerializer.java100644 0 0 3114 11333307160 30172 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.apache.ws.commons.util.XsDateTimeFormat; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for date values. */ public class CalendarSerializer extends TypeSerializerImpl { private static final XsDateTimeFormat format = new XsDateTimeFormat(); /** Tag name of a BigDecimal value. */ public static final String CALENDAR_TAG = "dateTime"; private static final String EX_CALENDAR_TAG = "ex:" + CALENDAR_TAG; /** Tag name of a date value. */ public static final String DATE_TAG = "dateTime.iso8601"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, CALENDAR_TAG, EX_CALENDAR_TAG, format.format(pObject)); } } ././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/CharSetXmlWriterFactory.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/CharSetXmlWriterFactory.ja100644 0 0 2402 11333307160 30636 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.apache.ws.commons.serialize.CharSetXMLWriter; import org.apache.ws.commons.serialize.XMLWriter; /** An implementation of {@link org.apache.xmlrpc.serializer.XmlWriterFactory}, * which creates instances of * {@link org.apache.ws.commons.serialize.CharSetXMLWriter}. */ public class CharSetXmlWriterFactory extends BaseXmlWriterFactory { protected XMLWriter newXmlWriter() { return new CharSetXMLWriter(); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/DateSerializer.java100644 0 0 2711 11333307160 27340 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.text.Format; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for date values. */ public class DateSerializer extends TypeSerializerImpl { /** Tag name of a date value. */ public static final String DATE_TAG = "dateTime.iso8601"; private final Format format; /** Creates a new instance with the given formatter. */ public DateSerializer(Format pFormat) { format = pFormat; } public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, DATE_TAG, format.format(pObject)); } } ././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/DefaultXMLWriterFactory.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/DefaultXMLWriterFactory.ja100644 0 0 4366 11333307160 30604 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.OutputStream; import java.io.StringWriter; import org.apache.ws.commons.serialize.CharSetXMLWriter; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; import org.xml.sax.helpers.AttributesImpl; /** The default implementation of {@link org.apache.xmlrpc.serializer.XmlWriterFactory} * tests, whether the {@link org.apache.xmlrpc.serializer.CharSetXmlWriterFactory} * is usable. This is the case, when running in Java 1.4 or later. If so, * this factory is used. Otherwise, the * {@link org.apache.xmlrpc.serializer.BaseXmlWriterFactory} is used as a * fallback. */ public class DefaultXMLWriterFactory implements XmlWriterFactory { private final XmlWriterFactory factory; /** Creates a new instance. */ public DefaultXMLWriterFactory() { XmlWriterFactory xwf; try { CharSetXMLWriter csw = new CharSetXMLWriter(); StringWriter sw = new StringWriter(); csw.setWriter(sw); csw.startDocument(); csw.startElement("", "test", "test", new AttributesImpl()); csw.endElement("", "test", "test"); csw.endDocument(); xwf = new CharSetXmlWriterFactory(); } catch (Throwable t) { xwf = new BaseXmlWriterFactory(); } factory = xwf; } public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream) throws XmlRpcException { return factory.getXmlWriter(pConfig, pStream); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/DoubleSerializer.java100644 0 0 2345 11333307160 27700 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for doubles. */ public class DoubleSerializer extends TypeSerializerImpl { /** Tag name of a double value. */ public static final String DOUBLE_TAG = "double"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, DOUBLE_TAG, pObject.toString()); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ExtSerializer.java100644 0 0 3514 11333307160 27225 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** Base class for external XML representations, like DOM, * or JAXB. */ public abstract class ExtSerializer implements TypeSerializer { /** Returns the unqualied tag name. */ protected abstract String getTagName(); /** Performs the actual serialization. */ protected abstract void serialize(ContentHandler pHandler, Object pObject) throws SAXException; public void write(ContentHandler pHandler, Object pObject) throws SAXException { final String tag = getTagName(); final String exTag = "ex:" + getTagName(); pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.ZERO_ATTRIBUTES); pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, tag, exTag, TypeSerializerImpl.ZERO_ATTRIBUTES); serialize(pHandler, pObject); pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, tag, exTag); pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/FloatSerializer.java100644 0 0 2526 11333307160 27534 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for floats. */ public class FloatSerializer extends TypeSerializerImpl { /** Tag name of a float value. */ public static final String FLOAT_TAG = "float"; /** Fully qualified name of a float value. */ public static final String EX_FLOAT_TAG = "ex:float"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, FLOAT_TAG, EX_FLOAT_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/I1Serializer.java100644 0 0 2474 11333307160 26742 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for bytes. */ public class I1Serializer extends TypeSerializerImpl { /** Tag name of an i1 value. */ public static final String I1_TAG = "i1"; /** Fully qualified name of an i1 value. */ public static final String EX_I1_TAG = "ex:i1"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, I1_TAG, EX_I1_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/I2Serializer.java100644 0 0 2475 11333307160 26744 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for shorts. */ public class I2Serializer extends TypeSerializerImpl { /** Tag name of an i2 value. */ public static final String I2_TAG = "i2"; /** Fully qualified name of an i2 value. */ public static final String EX_I2_TAG = "ex:i2"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, I2_TAG, EX_I2_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/I4Serializer.java100644 0 0 2444 11333307160 26742 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for integers. */ public class I4Serializer extends TypeSerializerImpl { /** Tag name of an int value. */ public static final String INT_TAG = "int"; /** Tag name of an i4 value. */ public static final String I4_TAG = "i4"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, I4_TAG, pObject.toString()); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/I8Serializer.java100644 0 0 2474 11333307160 26751 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for longs. */ public class I8Serializer extends TypeSerializerImpl { /** Tag name of an i8 value. */ public static final String I8_TAG = "i8"; /** Fully qualified name of an i8 value. */ public static final String EX_I8_TAG = "ex:i8"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, I8_TAG, EX_I8_TAG, pObject.toString()); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ListSerializer.java100644 0 0 3163 11333307160 27400 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.util.List; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for lists. */ public class ListSerializer extends ObjectArraySerializer { /** Creates a new instance. * @param pTypeFactory The factory being used for creating serializers. * @param pConfig The configuration being used for creating serializers. */ public ListSerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) { super(pTypeFactory, pConfig); } protected void writeData(ContentHandler pHandler, Object pObject) throws SAXException { List data = (List) pObject; for (int i = 0; i < data.size(); i++) { writeObject(pHandler, data.get(i)); } } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/MapSerializer.java100644 0 0 6630 11333307160 27204 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.util.Iterator; import java.util.Map; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for maps. */ public class MapSerializer extends TypeSerializerImpl { /** Tag name of a maps struct tag. */ public static final String STRUCT_TAG = "struct"; /** Tag name of a maps member tag. */ public static final String MEMBER_TAG = "member"; /** Tag name of a maps members name tag. */ public static final String NAME_TAG = "name"; private final XmlRpcStreamConfig config; private final TypeFactory typeFactory; /** Creates a new instance. * @param pTypeFactory The factory being used for creating serializers. * @param pConfig The configuration being used for creating serializers. */ public MapSerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) { typeFactory = pTypeFactory; config = pConfig; } protected void writeEntry(ContentHandler pHandler, Object pKey, Object pValue) throws SAXException { pHandler.startElement("", MEMBER_TAG, MEMBER_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", NAME_TAG, NAME_TAG, ZERO_ATTRIBUTES); if (config.isEnabledForExtensions() && !(pKey instanceof String)) { writeValue(pHandler, pKey); } else { String key = pKey.toString(); pHandler.characters(key.toCharArray(), 0, key.length()); } pHandler.endElement("", NAME_TAG, NAME_TAG); writeValue(pHandler, pValue); pHandler.endElement("", MEMBER_TAG, MEMBER_TAG); } private void writeValue(ContentHandler pHandler, Object pValue) throws SAXException { TypeSerializer ts = typeFactory.getSerializer(config, pValue); if (ts == null) { throw new SAXException("Unsupported Java type: " + pValue.getClass().getName()); } ts.write(pHandler, pValue); } protected void writeData(ContentHandler pHandler, Object pData) throws SAXException { Map map = (Map) pData; for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); writeEntry(pHandler, entry.getKey(), entry.getValue()); } } public void write(final ContentHandler pHandler, Object pObject) throws SAXException { pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", STRUCT_TAG, STRUCT_TAG, ZERO_ATTRIBUTES); writeData(pHandler, pObject); pHandler.endElement("", STRUCT_TAG, STRUCT_TAG); pHandler.endElement("", VALUE_TAG, VALUE_TAG); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/NodeSerializer.java100644 0 0 2724 11333307160 27354 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.apache.ws.commons.serialize.DOMSerializer; import org.w3c.dom.Node; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** The node serializer is serializing a DOM node. */ public class NodeSerializer extends ExtSerializer { private static final DOMSerializer ser = new DOMSerializer(); static { ser.setStartingDocument(false); } /** The local name of a dom tag. */ public static final String DOM_TAG = "dom"; protected String getTagName() { return DOM_TAG; } protected void serialize(ContentHandler pHandler, Object pObject) throws SAXException { ser.serialize((Node) pObject, pHandler); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/NullSerializer.java100644 0 0 3046 11333307160 27377 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for null values. */ public class NullSerializer extends TypeSerializerImpl { /** Tag name of a nil value. */ public static final String NIL_TAG = "nil"; /** Qualified tag name of a nil value. */ public static final String EX_NIL_TAG = "ex:nil"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, NIL_TAG, EX_NIL_TAG, ZERO_ATTRIBUTES); pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, NIL_TAG, EX_NIL_TAG); pHandler.endElement("", VALUE_TAG, VALUE_TAG); } } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ObjectArraySerializer.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/ObjectArraySerializer.java100644 0 0 5206 11333307160 30672 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for object arrays. */ public class ObjectArraySerializer extends TypeSerializerImpl { /** Tag name of an array value. */ public static final String ARRAY_TAG = "array"; /** Tag name of an arrays data. */ public static final String DATA_TAG = "data"; private final XmlRpcStreamConfig config; private final TypeFactory typeFactory; /** Creates a new instance. * @param pTypeFactory The factory being used for creating serializers. * @param pConfig The configuration being used for creating serializers. */ public ObjectArraySerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) { typeFactory = pTypeFactory; config = pConfig; } protected void writeObject(ContentHandler pHandler, Object pObject) throws SAXException { TypeSerializer ts = typeFactory.getSerializer(config, pObject); if (ts == null) { throw new SAXException("Unsupported Java type: " + pObject.getClass().getName()); } ts.write(pHandler, pObject); } protected void writeData(ContentHandler pHandler, Object pObject) throws SAXException { Object[] data = (Object[]) pObject; for (int i = 0; i < data.length; i++) { writeObject(pHandler, data[i]); } } public void write(final ContentHandler pHandler, Object pObject) throws SAXException { pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", ARRAY_TAG, ARRAY_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", DATA_TAG, DATA_TAG, ZERO_ATTRIBUTES); writeData(pHandler, pObject); pHandler.endElement("", DATA_TAG, DATA_TAG); pHandler.endElement("", ARRAY_TAG, ARRAY_TAG); pHandler.endElement("", VALUE_TAG, VALUE_TAG); } }././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/SerializableSerializer.javaapache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/SerializableSerializer.jav100644 0 0 4365 11333307160 30737 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import org.apache.ws.commons.util.Base64; import org.apache.ws.commons.util.Base64.Encoder; import org.apache.ws.commons.util.Base64.EncoderOutputStream; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link org.apache.xmlrpc.serializer.TypeSerializer} for * instances of {@link java.io.Serializable}. */ public class SerializableSerializer extends TypeSerializerImpl { /** Tag name of a base64 value. */ public static final String SERIALIZABLE_TAG = "serializable"; private static final String EX_SERIALIZABLE_TAG = "ex:" + SERIALIZABLE_TAG; public void write(final ContentHandler pHandler, Object pObject) throws SAXException { pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement("", SERIALIZABLE_TAG, EX_SERIALIZABLE_TAG, ZERO_ATTRIBUTES); char[] buffer = new char[1024]; Encoder encoder = new Base64.SAXEncoder(buffer, 0, null, pHandler); try { OutputStream ostream = new EncoderOutputStream(encoder); ObjectOutputStream oos = new ObjectOutputStream(ostream); oos.writeObject(pObject); oos.close(); } catch (Base64.SAXIOException e) { throw e.getSAXException(); } catch (IOException e) { throw new SAXException(e); } pHandler.endElement("", SERIALIZABLE_TAG, EX_SERIALIZABLE_TAG); pHandler.endElement("", VALUE_TAG, VALUE_TAG); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/StringSerializer.java100644 0 0 2352 11333307160 27732 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A {@link TypeSerializer} for strings. */ public class StringSerializer extends TypeSerializerImpl { /** (Optional) Tag name of a string value. */ public static final String STRING_TAG = "string"; public void write(ContentHandler pHandler, Object pObject) throws SAXException { write(pHandler, null, pObject.toString()); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/TypeSerializer.java100644 0 0 2557 11333307160 27414 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** A TypeSerializer is able to write a parameter * or result object to the XML RPC request or response. */ public interface TypeSerializer { /** Writes the object pObject to the SAX handler * pHandler. * @param pHandler The destination handler. * @param pObject The object being written. * @throws SAXException Writing the object failed. */ void write(ContentHandler pHandler, Object pObject) throws SAXException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/TypeSerializerImpl.java100644 0 0 4750 11333307160 30233 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** Abstract base implementation of a type serializer. */ public abstract class TypeSerializerImpl implements TypeSerializer { protected static final Attributes ZERO_ATTRIBUTES = new AttributesImpl(); /** Tag name of a value element. */ public static final String VALUE_TAG = "value"; protected void write(ContentHandler pHandler, String pTagName, String pValue) throws SAXException { write(pHandler, pTagName, pValue.toCharArray()); } protected void write(ContentHandler pHandler, String pTagName, char[] pValue) throws SAXException { pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES); if (pTagName != null) { pHandler.startElement("", pTagName, pTagName, ZERO_ATTRIBUTES); } pHandler.characters(pValue, 0, pValue.length); if (pTagName != null) { pHandler.endElement("", pTagName, pTagName); } pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG); } protected void write(ContentHandler pHandler, String pLocalName, String pQName, String pValue) throws SAXException { pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES); pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName, ZERO_ATTRIBUTES); char[] value = pValue.toCharArray(); pHandler.characters(value, 0, value.length); pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName); pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG); } }apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/XmlRpcWriter.java100644 0 0 15454 11333307160 27063 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.XmlRpcRequestConfig; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** This class is responsible for writing an XmlRpc request or an * XmlRpc response to an output stream. */ public class XmlRpcWriter { /** The namespace URI for proprietary XML-RPC extensions. */ public static final String EXTENSIONS_URI = "http://ws.apache.org/xmlrpc/namespaces/extensions"; private static final Attributes ZERO_ATTRIBUTES = new AttributesImpl(); private final XmlRpcStreamConfig config; private final TypeFactory typeFactory; private final ContentHandler handler; /** Creates a new instance. * @param pConfig The clients configuration. * @param pHandler The target SAX handler. * @param pTypeFactory The type factory being used to create serializers. */ public XmlRpcWriter(XmlRpcStreamConfig pConfig, ContentHandler pHandler, TypeFactory pTypeFactory) { config = pConfig; handler = pHandler; typeFactory = pTypeFactory; } /** Writes a clients request to the output stream. * @param pRequest The request being written. * @throws SAXException Writing the request failed. */ public void write(XmlRpcRequest pRequest) throws SAXException { handler.startDocument(); boolean extensions = pRequest.getConfig().isEnabledForExtensions(); if (extensions) { handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI); } handler.startElement("", "methodCall", "methodCall", ZERO_ATTRIBUTES); handler.startElement("", "methodName", "methodName", ZERO_ATTRIBUTES); String s = pRequest.getMethodName(); handler.characters(s.toCharArray(), 0, s.length()); handler.endElement("", "methodName", "methodName"); handler.startElement("", "params", "params", ZERO_ATTRIBUTES); int num = pRequest.getParameterCount(); for (int i = 0; i < num; i++) { handler.startElement("", "param", "param", ZERO_ATTRIBUTES); writeValue(pRequest.getParameter(i)); handler.endElement("", "param", "param"); } handler.endElement("", "params", "params"); handler.endElement("", "methodCall", "methodCall"); if (extensions) { handler.endPrefixMapping("ex"); } handler.endDocument(); } /** Writes a servers response to the output stream. * @param pConfig The request configuration. * @param pResult The result object. * @throws SAXException Writing the response failed. */ public void write(XmlRpcRequestConfig pConfig, Object pResult) throws SAXException { handler.startDocument(); boolean extensions = pConfig.isEnabledForExtensions(); if (extensions) { handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI); } handler.startElement("", "methodResponse", "methodResponse", ZERO_ATTRIBUTES); handler.startElement("", "params", "params", ZERO_ATTRIBUTES); handler.startElement("", "param", "param", ZERO_ATTRIBUTES); writeValue(pResult); handler.endElement("", "param", "param"); handler.endElement("", "params", "params"); handler.endElement("", "methodResponse", "methodResponse"); if (extensions) { handler.endPrefixMapping("ex"); } handler.endDocument(); } /** Writes a servers error message to the output stream. * @param pConfig The request configuration. * @param pCode The error code * @param pMessage The error message * @throws SAXException Writing the error message failed. */ public void write(XmlRpcRequestConfig pConfig, int pCode, String pMessage) throws SAXException { write(pConfig, pCode, pMessage, null); } /** Writes a servers error message to the output stream. * @param pConfig The request configuration. * @param pCode The error code * @param pMessage The error message * @param pThrowable An exception, which is being sent to the client * @throws SAXException Writing the error message failed. */ public void write(XmlRpcRequestConfig pConfig, int pCode, String pMessage, Throwable pThrowable) throws SAXException { handler.startDocument(); boolean extensions = pConfig.isEnabledForExtensions(); if (extensions) { handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI); } handler.startElement("", "methodResponse", "methodResponse", ZERO_ATTRIBUTES); handler.startElement("", "fault", "fault", ZERO_ATTRIBUTES); Map map = new HashMap(); map.put("faultCode", new Integer(pCode)); map.put("faultString", pMessage == null ? "" : pMessage); if (pThrowable != null && extensions && (pConfig instanceof XmlRpcStreamRequestConfig) && ((XmlRpcStreamRequestConfig) pConfig).isEnabledForExceptions()) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(pThrowable); oos.close(); baos.close(); map.put("faultCause", baos.toByteArray()); } catch (Throwable t) { // Ignore me } } writeValue(map); handler.endElement("", "fault", "fault"); handler.endElement("", "methodResponse", "methodResponse"); if (extensions) { handler.endPrefixMapping("ex"); } handler.endDocument(); } /** Writes the XML representation of a Java object. * @param pObject The object being written. * @throws SAXException Writing the object failed. */ protected void writeValue(Object pObject) throws SAXException { TypeSerializer serializer = typeFactory.getSerializer(config, pObject); if (serializer == null) { throw new SAXException("Unsupported Java type: " + pObject.getClass().getName()); } serializer.write(handler, pObject); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/serializer/XmlWriterFactory.java100644 0 0 3226 11333307160 27720 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.serializer; import java.io.OutputStream; import org.apache.ws.commons.serialize.XMLWriter; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.xml.sax.ContentHandler; /** This factory is responsible for creating instances of * {@link org.apache.ws.commons.serialize.XMLWriter}. */ public interface XmlWriterFactory { /** Creates a new instance of {@link ContentHandler}, * writing to the given {@link java.io.OutputStream}. * @return A SAX handler, typically an instance of * {@link XMLWriter}. * @param pStream The destination stream. * @param pConfig The request or response configuration. * @throws XmlRpcException Creating the handler failed. */ public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/HttpUtil.java100644 0 0 15465 11333307162 25046 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.Enumeration; import java.util.StringTokenizer; import org.apache.ws.commons.util.Base64; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; import org.apache.xmlrpc.common.XmlRpcStreamConfig; /** Provides utility functions useful in HTTP communications */ public class HttpUtil { /** Creates the Base64 encoded credentials for HTTP Basic Authentication. * @param pUser User name, or null, if no Basic Authentication is being used. * @param pPassword Users password, or null, if no Basic Authentication is being used. * @param pEncoding Encoding being used for conversion of the credential string into a byte array. * @return Base64 encoded credentials, for use in the HTTP header * @throws UnsupportedEncodingException The encoding pEncoding is invalid. */ public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding) throws UnsupportedEncodingException { if (pUser == null) { return null; } final String s = pUser + ':' + pPassword; if (pEncoding == null) { pEncoding = XmlRpcStreamConfig.UTF8_ENCODING; } final byte[] bytes = s.getBytes(pEncoding); return Base64.encode(s.getBytes(pEncoding), 0, bytes.length, 0, null); } /** Returns, whether the HTTP header value pHeaderValue * indicates, that GZIP encoding is used or may be used. * @param pHeaderValue The HTTP header value being parsed. This is typically * the value of "Content-Encoding", or "Accept-Encoding". * @return True, if the header value suggests that GZIP encoding is or may * be used. */ public static boolean isUsingGzipEncoding(String pHeaderValue) { if (pHeaderValue == null) { return false; } for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) { String encoding = st.nextToken(); int offset = encoding.indexOf(';'); if (offset >= 0) { encoding = encoding.substring(0, offset); } if ("gzip".equalsIgnoreCase(encoding.trim())) { return true; } } return false; } /** * Returns, whether the HTTP header value pHeaderValue * indicates, that another encoding than "identity" is used. * This is typically the value of "Transfer-Encoding", or "TE". * @return Null, if the transfer encoding in use is "identity". * Otherwise, another transfer encoding. */ public static String getNonIdentityTransferEncoding(String pHeaderValue) { if (pHeaderValue == null) { return null; } for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) { String encoding = st.nextToken(); int offset = encoding.indexOf(';'); if (offset >= 0) { encoding = encoding.substring(0, offset); } if (!"identity".equalsIgnoreCase(encoding.trim())) { return encoding.trim(); } } return null; } /** Returns, whether the HTTP header values in pValues * indicate, that GZIP encoding is used or may be used. * @param pValues The HTTP header values being parsed. These are typically * the values of "Content-Encoding", or "Accept-Encoding". * @return True, if the header values suggests that GZIP encoding is or may * be used. */ public static boolean isUsingGzipEncoding(Enumeration pValues) { if (pValues != null) { while (pValues.hasMoreElements()) { if (isUsingGzipEncoding((String) pValues.nextElement())) { return true; } } } return false; } /** Reads a header line from the input stream pIn * and converts it into a string. * @param pIn The input stream being read. * @param pBuffer A buffer being used for temporary storage. * The buffers length is a limit of the header lines length. * @return Next header line or null, if no more header lines * are available. * @throws IOException Reading the header line failed. */ public static String readLine(InputStream pIn, byte[] pBuffer) throws IOException { int next; int count = 0; while (true) { next = pIn.read(); if (next < 0 || next == '\n') { break; } if (next != '\r') { pBuffer[count++] = (byte) next; } if (count >= pBuffer.length) { throw new IOException ("HTTP Header too long"); } } return new String(pBuffer, 0, count, "US-ASCII"); } /** Parses an "Authorization" header and adds the username and password * to pConfig. * @param pConfig The request configuration being created. * @param pLine The header being parsed, including the "basic" part. */ public static void parseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, String pLine) { if (pLine == null) { return; } pLine = pLine.trim(); StringTokenizer st = new StringTokenizer(pLine); if (!st.hasMoreTokens()) { return; } String type = st.nextToken(); if (!"basic".equalsIgnoreCase(type)) { return; } if (!st.hasMoreTokens()) { return; } String auth = st.nextToken(); try { byte[] c = Base64.decode(auth.toCharArray(), 0, auth.length()); String enc = pConfig.getBasicEncoding(); if (enc == null) { enc = XmlRpcStreamConfig.UTF8_ENCODING; } String str = new String(c, enc); int col = str.indexOf(':'); if (col >= 0) { pConfig.setBasicUserName(str.substring(0, col)); pConfig.setBasicPassword(str.substring(col+1)); } } catch (Throwable ignore) { } } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/LimitedInputStream.java100644 0 0 5677 11333307162 27040 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.io.InputStream; import java.io.IOException; /** A filtering {@link java.io.InputStream} for proper handling of * the Content-Length header: It guarantees to return * at most a given number of bytes. */ public class LimitedInputStream extends InputStream { // bytes remaining to be read from the input stream. This is // initialized from CONTENT_LENGTH (or getContentLength()). // This is used in order to correctly return a -1 when all the // data POSTed was read. If this is left to -1, content length is // assumed as unknown and the standard InputStream methods will be used private long available; private long markedAvailable; private InputStream in; /** Creates a new instance, reading from the given input stream * and returning at most the given number of bytes. * @param pIn Input stream being read. * @param pAvailable Number of bytes available in pIn. */ public LimitedInputStream(InputStream pIn, int pAvailable) { in = pIn; available = pAvailable; } public int read() throws IOException { if (available > 0) { available--; return in.read(); } return -1; } public int read(byte b[], int off, int len) throws IOException { if (available > 0) { if (len > available) { // shrink len len = (int) available; } int read = in.read(b, off, len); if (read == -1) { available = 0; } else { available -= read; } return read; } return -1; } public long skip(long n) throws IOException { long skip = in.skip(n); if (available > 0) { available -= skip; } return skip; } public void mark(int readlimit) { in.mark(readlimit); markedAvailable = available; } public void reset() throws IOException { in.reset(); available = markedAvailable; } public boolean markSupported() { return true; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/ReflectionUtil.java100644 0 0 11771 11333307162 26215 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** A utility class for using reflection. */ public class ReflectionUtil { /** * This method attempts to set a property value on a given object by calling a * matching setter. * @param pObject The object, on which a property is being set. * @param pPropertyName The property name. * @param pPropertyValue The property value. * @throws IllegalAccessException Setting the property value failed, because invoking * the setter raised an {@link IllegalAccessException}. * @throws InvocationTargetException Setting the property value failed, because invoking * the setter raised another exception. * @return Whether a matching setter was found. The value false indicates, that no such * setter exists. */ public static boolean setProperty(Object pObject, String pPropertyName, String pPropertyValue) throws IllegalAccessException, InvocationTargetException { final String methodName = "set" + pPropertyName.substring(0, 1).toUpperCase() + pPropertyName.substring(1); // try to find method signature that matches init param Method[] methods = pObject.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { final Method method = methods[i]; if (!method.getName().equals(methodName)) { continue; // Ignore methods, which does have the right name } if (!Modifier.isPublic(method.getModifiers())) { continue; // Ignore methods, which aren't public } Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { continue; // Ignore methods, which don't not have exactly one parameter } Class parameterType = parameterTypes[0]; final Object param; try { if (parameterType.equals(boolean.class) || parameterType.equals(Boolean.class)) { param = Boolean.valueOf(pPropertyValue); } else if (parameterType.equals(char.class) || parameterType.equals(Character.class)) { if (pPropertyValue.length() != 1) { throw new IllegalArgumentException("Invalid value for parameter " + pPropertyName + "(length != 1):" + pPropertyValue); } param = new Character(pPropertyValue.charAt(0)); } else if (parameterType.equals(byte.class) || parameterType.equals(Byte.class)) { param = Byte.valueOf(pPropertyValue); } else if (parameterType.equals(short.class) || parameterType.equals(Short.class)) { param = Short.valueOf(pPropertyValue); } else if (parameterType.equals(int.class) || parameterType.equals(Integer.class)) { param = Integer.valueOf(pPropertyValue); } else if (parameterType.equals(long.class) || parameterType.equals(Long.class)) { param = Long.valueOf(pPropertyValue); } else if (parameterType.equals(float.class) || parameterType.equals(Float.class)) { param = Float.valueOf(pPropertyValue); } else if (parameterType.equals(double.class) || parameterType.equals(Double.class)) { param = Double.valueOf(pPropertyValue); } else if (parameterType.equals(String.class)) { param = pPropertyValue; } else { throw new IllegalStateException("The property " + pPropertyName + " has an unsupported type of " + parameterType.getName()); } } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid value for property " + pPropertyName + ": " + pPropertyValue); } method.invoke(pObject, new Object[]{param}); return true; } return false; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/SAXParsers.java100644 0 0 5165 11333307162 25240 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import org.apache.xmlrpc.XmlRpcException; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** Utility class for working with SAX parsers. */ public class SAXParsers { private static SAXParserFactory spf; static { spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setValidating(false); try { spf.setFeature("http://xml.org/sax/features/external-general-entities", false); } catch (javax.xml.parsers.ParserConfigurationException e) { // Ignore it } catch (org.xml.sax.SAXException e) { // Ignore it } try { spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); } catch (javax.xml.parsers.ParserConfigurationException e) { // Ignore it } catch (org.xml.sax.SAXException e) { // Ignore it } } /** Creates a new instance of {@link XMLReader}. */ public static XMLReader newXMLReader() throws XmlRpcException { try { return spf.newSAXParser().getXMLReader(); } catch (ParserConfigurationException e) { throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e); } catch (SAXException e) { throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e); } } /** * Returns the SAX parser factory, which is used by Apache XML-RPC. You may * use this to configure the factory. */ public static SAXParserFactory getSAXParserFactory() { return spf; } /** * Sets the SAX parser factory, which is used by Apache XML-RPC. You may use * this to configure another instance than the default. */ public static void setSAXParserFactory(SAXParserFactory pFactory) { spf = pFactory; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/ThreadPool.java100644 0 0 16562 11333307162 25331 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.util.ArrayList; import java.util.List; /** Simple thread pool. A task is executed by obtaining a thread from * the pool */ public class ThreadPool { /** The thread pool contains instances of {@link ThreadPool.Task}. */ public interface Task { /** Performs the task. * @throws Throwable The task failed, and the worker thread won't be used again. */ void run() throws Throwable; } /** A task, which may be interrupted, if the pool is shutting down. */ public interface InterruptableTask extends Task { /** Interrupts the task. * @throws Throwable Shutting down the task failed. */ void shutdown() throws Throwable; } private class Poolable { private volatile boolean shuttingDown; private Task task; private Thread thread; Poolable(ThreadGroup pGroup, int pNum) { thread = new Thread(pGroup, pGroup.getName() + "-" + pNum){ public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } }; thread.start(); } synchronized void shutdown() { shuttingDown = true; final Task t = getTask(); if (t != null && t instanceof InterruptableTask) { try { ((InterruptableTask) t).shutdown(); } catch (Throwable th) { // Ignore me } } task = null; synchronized (thread) { thread.notify(); } } private Task getTask() { return task; } private void resetTask() { task = null; } void start(Task pTask) { task = pTask; synchronized (thread) { thread.notify(); } } } private final ThreadGroup threadGroup; private final int maxSize; private final List waitingThreads = new ArrayList(); private final List runningThreads = new ArrayList(); private final List waitingTasks = new ArrayList(); private int num; /** Creates a new instance. * @param pMaxSize Maximum number of concurrent threads. * @param pName Thread group name. */ public ThreadPool(int pMaxSize, String pName) { maxSize = pMaxSize; threadGroup = new ThreadGroup(pName); } private synchronized void remove(Poolable pPoolable) { runningThreads.remove(pPoolable); waitingThreads.remove(pPoolable); } void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } } /** Starts a task immediately. * @param pTask The task being started. * @return True, if the task could be started immediately. False, if * the maxmimum number of concurrent tasks was exceeded. If so, you * might consider to use the {@link #addTask(ThreadPool.Task)} method instead. */ public boolean startTask(Task pTask) { final Poolable poolable = getPoolable(pTask, false); if (poolable == null) { return false; } poolable.start(pTask); return true; } private synchronized Poolable getPoolable(Task pTask, boolean pQueue) { if (maxSize != 0 && runningThreads.size() >= maxSize) { if (pQueue) { waitingTasks.add(pTask); } return null; } Poolable poolable; if (waitingThreads.size() > 0) { poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1); } else { poolable = new Poolable(threadGroup, num++); } runningThreads.add(poolable); return poolable; } /** Adds a task for immediate or deferred execution. * @param pTask The task being added. * @return True, if the task was started immediately. False, if * the task will be executed later. * @deprecated No longer in use. */ public boolean addTask(Task pTask) { final Poolable poolable = getPoolable(pTask, true); if (poolable != null) { poolable.start(pTask); return true; } return false; } /** Closes the pool. */ public synchronized void shutdown() { while (!waitingThreads.isEmpty()) { Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1); poolable.shutdown(); } while (!runningThreads.isEmpty()) { Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1); poolable.shutdown(); } } /** Returns the maximum number of concurrent threads. * @return Maximum number of threads. */ public int getMaxThreads() { return maxSize; } /** Returns the number of threads, which have actually been created, * as opposed to the number of currently running threads. */ public synchronized int getNumThreads() { return num; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/XmlRpcDateTimeDateFormat.java100644 0 0 3531 11333307162 30031 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.text.FieldPosition; import java.text.ParsePosition; import java.util.Calendar; import java.util.Date; /** An extension of {@link XmlRpcDateTimeFormat}, which accepts * and/or creates instances of {@link Date}. */ public abstract class XmlRpcDateTimeDateFormat extends XmlRpcDateTimeFormat { private static final long serialVersionUID = -5107387618606150784L; public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) { final Object cal; if (pCalendar != null && pCalendar instanceof Date) { Calendar calendar = Calendar.getInstance(getTimeZone()); calendar.setTime((Date) pCalendar); cal = calendar; } else { cal = pCalendar; } return super.format(cal, pBuffer, pPos); } public Object parseObject(String pString, ParsePosition pParsePosition) { Calendar cal = (Calendar) super.parseObject(pString, pParsePosition); return cal == null ? null : cal.getTime(); } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/XmlRpcDateTimeFormat.java100644 0 0 13707 11333307162 27261 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; import java.util.Calendar; import java.util.TimeZone; /**

An instance of {@link java.text.Format}, which may be used * to parse and format dateTime values, as specified * by the XML-RPC specification. The specification doesn't precisely * describe the format, it only gives an example:

*
 *   19980717T14:08:55
 * 
* This class accepts and creates instances of {@link Calendar}. */ public abstract class XmlRpcDateTimeFormat extends Format { private static final long serialVersionUID = -8008230377361175138L; /** Returns the time zone, which is used to interpret date/time * values. */ protected abstract TimeZone getTimeZone(); private int parseInt(String pString, int pOffset, StringBuffer pDigits, int pMaxDigits) { int length = pString.length(); pDigits.setLength(0); while (pMaxDigits-- > 0 && pOffset < length) { char c = pString.charAt(pOffset); if (Character.isDigit(c)) { pDigits.append(c); ++pOffset; } else { break; } } return pOffset; } public Object parseObject(String pString, ParsePosition pParsePosition) { if (pString == null) { throw new NullPointerException("The String argument must not be null."); } if (pParsePosition == null) { throw new NullPointerException("The ParsePosition argument must not be null."); } int offset = pParsePosition.getIndex(); int length = pString.length(); StringBuffer digits = new StringBuffer(); int year, month, mday; offset = parseInt(pString, offset, digits, 4); if (digits.length() < 4) { pParsePosition.setErrorIndex(offset); return null; } year = Integer.parseInt(digits.toString()); offset = parseInt(pString, offset, digits, 2); if (digits.length() != 2) { pParsePosition.setErrorIndex(offset); return null; } month = Integer.parseInt(digits.toString()); offset = parseInt(pString, offset, digits, 2); if (digits.length() != 2) { pParsePosition.setErrorIndex(offset); return null; } mday = Integer.parseInt(digits.toString()); if (offset < length && pString.charAt(offset) == 'T') { ++offset; } else { pParsePosition.setErrorIndex(offset); return null; } int hour, minute, second; offset = parseInt(pString, offset, digits, 2); if (digits.length() != 2) { pParsePosition.setErrorIndex(offset); return null; } hour = Integer.parseInt(digits.toString()); if (offset < length && pString.charAt(offset) == ':') { ++offset; } else { pParsePosition.setErrorIndex(offset); return null; } offset = parseInt(pString, offset, digits, 2); if (digits.length() != 2) { pParsePosition.setErrorIndex(offset); return null; } minute = Integer.parseInt(digits.toString()); if (offset < length && pString.charAt(offset) == ':') { ++offset; } else { pParsePosition.setErrorIndex(offset); return null; } offset = parseInt(pString, offset, digits, 2); if (digits.length() != 2) { pParsePosition.setErrorIndex(offset); return null; } second = Integer.parseInt(digits.toString()); Calendar cal = Calendar.getInstance(getTimeZone()); cal.set(year, month-1, mday, hour, minute, second); cal.set(Calendar.MILLISECOND, 0); pParsePosition.setIndex(offset); return cal; } private void append(StringBuffer pBuffer, int pNum, int pMinLen) { String s = Integer.toString(pNum); for (int i = s.length(); i < pMinLen; i++) { pBuffer.append('0'); } pBuffer.append(s); } public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) { if (pCalendar == null) { throw new NullPointerException("The Calendar argument must not be null."); } if (pBuffer == null) { throw new NullPointerException("The StringBuffer argument must not be null."); } if (pPos == null) { throw new NullPointerException("The FieldPosition argument must not be null."); } Calendar cal = (Calendar) pCalendar; int year = cal.get(Calendar.YEAR); append(pBuffer, year, 4); append(pBuffer, cal.get(Calendar.MONTH)+1, 2); append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2); pBuffer.append('T'); append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2); pBuffer.append(':'); append(pBuffer, cal.get(Calendar.MINUTE), 2); pBuffer.append(':'); append(pBuffer, cal.get(Calendar.SECOND), 2); return pBuffer; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/util/XmlRpcIOException.java100644 0 0 3102 11333307162 26546 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.util; import java.io.IOException; /** This is a subclass of {@link IOException}, which * allows to attach a linked exception. Throwing this * particular instance of {@link IOException} allows * to catch it and throw the linked exception instead. */ public class XmlRpcIOException extends IOException { private static final long serialVersionUID = -7704704099502077919L; private final Throwable linkedException; /** Creates a new instance of {@link XmlRpcIOException} * with the given cause. */ public XmlRpcIOException(Throwable t) { super(t.getMessage()); linkedException = t; } /** Returns the linked exception, which is the actual * cause for this exception. */ public Throwable getLinkedException() { return linkedException; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcConfig.java100644 0 0 3131 11333307162 24612 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; import java.util.TimeZone; /** A common base interface for * {@link org.apache.xmlrpc.client.XmlRpcClientConfig}, and * {@link org.apache.xmlrpc.server.XmlRpcServerConfig}. */ public interface XmlRpcConfig { /** Returns, whether support for extensions are enabled. * By default, extensions are disabled and your client is * interoperable with other XML-RPC implementations. * Interoperable XML-RPC implementations are those, which * are compliant to the * XML-RPC Specification. * @return Whether extensions are enabled or not. */ boolean isEnabledForExtensions(); /** Returns the timezone, which is used to interpret date/time * values. Defaults to {@link TimeZone#getDefault()}. */ TimeZone getTimeZone(); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcConfigImpl.java100644 0 0 5537 11333307162 25450 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; import java.util.TimeZone; import org.apache.xmlrpc.common.XmlRpcHttpConfig; /** Default implementation of {@link org.apache.xmlrpc.XmlRpcConfig}. */ public abstract class XmlRpcConfigImpl implements XmlRpcConfig, XmlRpcHttpConfig { private boolean enabledForExtensions; private boolean contentLengthOptional; private String basicEncoding; private String encoding; private TimeZone timeZone = TimeZone.getDefault(); public boolean isEnabledForExtensions() { return enabledForExtensions; } /** Sets, whether extensions are enabled. By default, the * client or server is strictly compliant to the XML-RPC * specification and extensions are disabled. * @param pExtensions True to enable extensions, false otherwise. */ public void setEnabledForExtensions(boolean pExtensions) { enabledForExtensions = pExtensions; } /** Sets the encoding for basic authentication. * @param pEncoding The encoding; may be null, in which case * UTF-8 is choosen. */ public void setBasicEncoding(String pEncoding) { basicEncoding = pEncoding; } public String getBasicEncoding() { return basicEncoding; } /** Sets the requests encoding. * @param pEncoding The requests encoding or null (default * UTF-8). */ public void setEncoding(String pEncoding) { encoding = pEncoding; } public String getEncoding() { return encoding; } public boolean isContentLengthOptional() { return contentLengthOptional; } /** Sets, whether a "Content-Length" header may be * omitted. The XML-RPC specification demands, that such * a header be present. * @param pContentLengthOptional True, if the content length may be omitted. */ public void setContentLengthOptional(boolean pContentLengthOptional) { contentLengthOptional = pContentLengthOptional; } public TimeZone getTimeZone() { return timeZone; } /** Returns the timezone, which is used to interpret date/time * values. Defaults to {@link TimeZone#getDefault()}. */ public void setTimeZone(TimeZone pTimeZone) { timeZone = pTimeZone; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcException.java100644 0 0 6726 11333307162 25360 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; import java.io.PrintStream; import java.io.PrintWriter; /** This exception is thrown by the XmlRpcClient, if an invocation of the * remote method failed. Failure may have two reasons: The invocation * failed on the remote side (for example, an exception was thrown within * the server) or the communication with the server failed. The latter * is indicated by throwing an instance of * {@link org.apache.xmlrpc.client.XmlRpcClientException}. */ public class XmlRpcException extends Exception { private static final long serialVersionUID = 3258693217049325618L; /** The fault code of the exception. For servers based on this library, this * will always be 0. (If there are predefined error codes, they should be in * the XML-RPC spec.) */ public final int code; /** If the transport was able to catch a remote exception * (as is the case, if the local transport is used or if extensions * are enabled and the server returned a serialized exception), * then this field contains the trapped exception. */ public final Throwable linkedException; /** Creates a new instance with the given error code and error message. * @param pCode Error code. * @param pMessage Detail message. */ public XmlRpcException(int pCode, String pMessage) { this(pCode, pMessage, null); } /** Creates a new instance with the given error message * and cause. * @param pMessage Detail message. * @param pLinkedException The errors cause. */ public XmlRpcException(String pMessage, Throwable pLinkedException) { this(0, pMessage, pLinkedException); } /** Creates a new instance with the given error message * and error code 0. * @param pMessage Detail message. */ public XmlRpcException(String pMessage) { this(0, pMessage, null); } /** Creates a new instance with the given error code, error message * and cause. * @param pCode Error code. * @param pMessage Detail message. * @param pLinkedException The errors cause. */ public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException) { super(pMessage); code = pCode; linkedException = pLinkedException; } public void printStackTrace(PrintStream pStream) { super.printStackTrace(pStream); if (linkedException != null) { pStream.println("Caused by:"); linkedException.printStackTrace(pStream); } } public void printStackTrace(PrintWriter pWriter) { super.printStackTrace(pWriter); if (linkedException != null) { pWriter.println("Caused by:"); linkedException.printStackTrace(pWriter); } } public Throwable getCause() { return linkedException; } } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcHandler.java100644 0 0 2406 11333307162 24766 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; /** The XML-RPC server uses this interface to call a method of an RPC handler. */ public interface XmlRpcHandler { /** Performs the request and returns the result object. * @param pRequest The request being performed (method name and * parameters.) * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcRequest pRequest) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcRequest.java100644 0 0 3120 11333307162 25033 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; /** Interface to an XML-RPC request made by a client. Replaces the * class org.apache.xmlrpc.XmlRpcClientRequest from * Apache XML-RPC 2.0. * @since 3.0 */ public interface XmlRpcRequest { /** Returns the request configuration. * @return The request configuration. */ XmlRpcRequestConfig getConfig(); /** Returns the requests method name. * @return Name of the method being invoked. */ String getMethodName(); /** Returns the number of parameters. * @return Number of parameters. */ int getParameterCount(); /** Returns the parameter with index pIndex. * @param pIndex Number between 0 and {@link #getParameterCount()}-1. * @return Parameter being sent to the server. */ public Object getParameter(int pIndex); } apache-xmlrpc-3.1.3-src/common/src/main/java/org/apache/xmlrpc/XmlRpcRequestConfig.java100644 0 0 2126 11333307162 26166 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc; /** Interface of a request configuration. Depending on * the transport, implementations will also implement * additional interfaces like * {@link org.apache.xmlrpc.common.XmlRpcStreamRequestConfig}. */ public interface XmlRpcRequestConfig extends XmlRpcConfig { } apache-xmlrpc-3.1.3-src/dist/.project100644 0 0 571 11333307146 14554 0ustar 0 0 xmlrpc-tests org.maven.ide.eclipse.maven2Builder org.maven.ide.eclipse.maven2Nature apache-xmlrpc-3.1.3-src/dist/.settings/org.maven.ide.eclipse.prefs100644 0 0 407 11333307146 22141 0ustar 0 0 #Fri Apr 03 07:55:11 CEST 2009 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true resourceFilterGoals=process-resources resources\:testResources skipCompilerPlugin=true version=1 apache-xmlrpc-3.1.3-src/dist/pom.xml100644 0 0 7706 11333307146 14451 0ustar 0 0 4.0.0 Assembly project for building the XML-RPC distribution. org.apache.xmlrpc xmlrpc 3.1.3 ../pom.xml xmlrpc-dist pom Apache XML-RPC Distribution org.apache.maven.plugins maven-jar-plugin 2.2 false org.apache.xmlrpc.test UserLand Software, Inc. 2003-06-30 XML-RPC org.apache Apache Software Foundation ${project.version} javax.servlet servlet-api org.apache.xmlrpc xmlrpc-client 3.1.3 org.apache.xmlrpc xmlrpc-server 3.1.3 release org.apache.maven.plugins maven-assembly-plugin 2.2-beta-3 create-assemblies attached package apache-xmlrpc-${project.version} src/main/assembly/bin.xml src/main/assembly/src.xml gnu apache-xmlrpc-3.1.3-src/dist/src/main/assembly/bin.xml100644 0 0 3732 11333307146 17753 0ustar 0 0 bin tar.gz tar.bz2 zip apache-xmlrpc-${project.version} .. LICENSE.txt NOTICE.txt ../target/site docs lib org.apache.xmlrpc:* org.apache.xmlrpc:* commons-logging:commons-logging org.apache.ws.commons.util:ws-commons-util apache-xmlrpc-3.1.3-src/dist/src/main/assembly/src.xml100644 0 0 3422 11333307146 17766 0ustar 0 0 src tar.gz tar.bz2 zip apache-xmlrpc-${project.version}-src .. common/target client/target server/target dist/target common/target/**/* client/target/**/* server/target/**/* dist/target/**/* target target/**/* apache-xmlrpc-3.1.3-src/LICENSE.txt100644 0 0 26450 11333307171 14027 0ustar 0 0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. apache-xmlrpc-3.1.3-src/NOTICE.txt100644 0 0 250 11333307171 13654 0ustar 0 0 Apache XML-RPC Copyright 1999-2009 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). apache-xmlrpc-3.1.3-src/pom.xml100644 0 0 44070 11333307171 13517 0ustar 0 0 4.0.0 org.apache apache 5 org.apache.xmlrpc xmlrpc Apache XML-RPC 3.1.3 Apache XML-RPC is a Java implementation of XML-RPC, a popular protocol that uses XML over HTTP to implement remote procedure calls. Compared to SOAP, or JAX-RPC, it is stable, much simpler and easier to handle. Version 3 of Apache XML-RPC introduces several important vendor extensions over the original XML-RPC specification. pom http://ws.apache.org/xmlrpc/ 2001 common client server dist jira http://issues.apache.org/jira/BrowseProject.jspa?pid=10465 Gump http://vmgump.apache.org/gump/public/ws-xmlrpc/xmlrpc/index.html XML-RPC Developers xmlrpc-dev-subscribe@ws.apache.org xmlrpc-dev-unsubscribe@ws.apache.org xmlrpc-dev@ws.apache.org http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-dev/ http://marc.theaimsgroup.com/?l=xmlrpc-dev XML-RPC Automatic Mails xmlrpc-auto-subscribe@ws.apache.org xmlrpc-auto-unsubscribe@ws.apache.org xmlrpc-auto@ws.apache.org http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-auto/ Andrew Evers aevers aevers@redwood.nl Siegfried Goeschl sgoeschl sgoeschl@apache.org Henri Gomez hgomez hgomez@apache.org Ryan Hoegg rhoegg rhoegg@isisnetworks.net ISIS Networks Daniel Rall dlr dlr@finemaltcoding.com CollabNet, Inc. Leonard Richarson leonardr leonardr@collab.net CollabNet, Inc. Jon Scott Stevens jon jon@latchkey.com CollabNet, Inc. Hannes Wallnoefer hannes hannes@apache.org Jochen Wiedmann jochen jochen.wiedmann@gmail.com John Wilson jwilson tug@wilson.co.uk The Wilson Partnership Jason van Zyl jvanzyl jason@zenplex.com Zenplex Gamaliel Amaudruz gamaliel@fastmail.fm Póka Balázs p.balazs@gmail.com Alan Burlison Alan.Burlison@sun.com James Baldassari jbaldassari@gmail.com Denis Carniel 2nis@aktiv-design.com Steve Cohen sc1478@att.com Chris Conrad rhavyn@gmail.com Brandon DuRette brandond@alum.mit.edu Landon Fuller landonf@threerings.net Gam gamaliel@fastmail.fm Mark Gertsvolf markg@nortel.com Johan Hôgre johan.hagre@home.se Catalin Hritcu Catalin.Hritcu@gmail.com Brad Karp bkarp@cs.ucl.ac.uk Kay Tiong Khoo kaytiong@gmail.com Jimisola Laursen jimisola@jimisola.com Mario Linke linke.mario@web.de Marek Ludha mludha@gmail.com Jason McLaurin jmclaurin@petronworld.com Keith McNeill mcneill@streambase.com Stanislav Miklik stanislav.miklik@gmail.com Walter Mundt Walter.Mundt@coleengineering.com Andrew Norman anorman@piczoinc.com Perry Nguyen pfnguyen@hanhuy.com Jonathan Oexner jonathan.oexner@alum.wpi.edu Mark Petrovic mspetrovic@gmail.com Steffen Pingel steffenp@gmx.de Matt Preston matt@knowledgeview.co.uk Eugene Prokopiev prokopiev@stc.donpac.ru Sir Bode Rafael sirboderafael@gmail.com Andreas Sahlbach andreas.sahlbach@gmail.com Julio Francisco Veronelli ckjfveronelli@fibertel.com.ar Ken Weiner kweiner@gmail.com Carsten Wolters c.wolters@gmx.de Juho Yli-Krekola Juho.Yli-Krekola@iki.fi Greg Wurth hackwurth@mac.com Livnat Peer livnats@gmail.com scm:svn:https://svn.apache.org/repos/asf/webservices/xmlrpc/tags/xmlrpc-3.1.3 scm:svn:https://svn.apache.org/repos/asf/webservices/xmlrpc/tags/xmlrpc-3.1.3 https://svn.apache.org/viewvc/webservices/xmlrpc/tags/xmlrpc-3.1.3 true src/main/filtered-resources org.apache.maven.plugins maven-compiler-plugin 2.0.2 true 1.3 1.2 commons-httpclient commons-httpclient 3.0.1 provided commons-logging commons-logging 1.1 avalon-framework avalon-framework logkit logkit javax.servlet servlet-api 2.4 provided junit junit 3.8.1 test org.apache.ws.commons.util ws-commons-util 1.0.2 jaxme jaxmeapi 0.5.1 provided org.apache.maven.plugins maven-javadoc-plugin 2.5 true ${maven.compile.source} javadoc org.apache.maven.plugins maven-changes-plugin 2.1 changes-report org.apache.rat apache-rat-plugin 0.6 ${xmlrpc.www.id} XML-RPC directory on ws.apache.org ${xmlrpc.www.url} 1.4 org.apache.ws.commons ws-commons-java5 1.0.1 release maven-site-plugin false generate-resources site maven-remote-resources-plugin 1.0 process org.apache:apache-jar-resource-bundle:1.4 true org.apache.maven.plugins maven-assembly-plugin 2.2-beta-3 create-assemblies attached packaging src/main/assembly/bin.xml src/main/assembly/src.xml gnu org.apache.maven.plugins maven-gpg-plugin 1.0-alpha-4 ${gpg.passphrase} sign true org.apache.maven.plugins maven-deploy-plugin 2.4 ${deploy.altRepository} true org.apache.maven.plugins maven-source-plugin 2.0.4 attach-sources jar org.apache.maven.plugins maven-javadoc-plugin 2.5 ${maven.compile.source} attach-javadocs jar aggregate org.codehaus.mojo clirr-maven-plugin 2.2.2 clirr-check package check org.apache.rat apache-rat-plugin 0.6 UTF-8 scp://people.apache.org/www/ws.apache.org/xmlrpc people.apache.org apache-xmlrpc-3.1.3-src/server/.classpath100644 0 0 1134 11333307154 15446 0ustar 0 0 apache-xmlrpc-3.1.3-src/server/.project100644 0 0 1040 11333307154 15126 0ustar 0 0 xmlrpc-server org.eclipse.jdt.core.javabuilder org.maven.ide.eclipse.maven2Builder org.maven.ide.eclipse.maven2Nature org.eclipse.jdt.core.javanature apache-xmlrpc-3.1.3-src/server/.settings/org.eclipse.jdt.core.prefs100644 0 0 10716 11333307154 22411 0ustar 0 0 #Sat Apr 18 23:07:49 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.3 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.autoboxing=warning org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.3 apache-xmlrpc-3.1.3-src/server/.settings/org.maven.ide.eclipse.prefs100644 0 0 407 11333307154 22503 0ustar 0 0 #Sat Apr 18 22:52:18 CEST 2009 activeProfiles= eclipse.preferences.version=1 fullBuildGoals=process-test-resources includeModules=false resolveWorkspaceProjects=true resourceFilterGoals=process-resources resources\:testResources skipCompilerPlugin=true version=1 apache-xmlrpc-3.1.3-src/server/pom.xml100644 0 0 6662 11333307154 15013 0ustar 0 0 4.0.0 org.apache.xmlrpc xmlrpc 3.1.3 ../pom.xml xmlrpc-server Apache XML-RPC Server Library org.apache.maven.plugins maven-jar-plugin 2.2 false org.apache.xmlrpc.server UserLand Software, Inc. 2003-06-30 XML-RPC org.apache Apache Software Foundation ${project.version} org.apache.maven.plugins maven-surefire-plugin org/apache/xmlrpc/test/ScalabilityTest.java commons-logging commons-logging org.apache.xmlrpc xmlrpc-common 3.1.3 org.apache.xmlrpc xmlrpc-client 3.1.3 test javax.servlet servlet-api commons-httpclient commons-httpclient test ././@LongLink100644 0 0 155 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/ReflectiveXmlRpcMetaDataHandler.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/ReflectiveXmlRpcMetaDataHand100644 0 0 5026 11333307152 30553 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.metadata; import java.lang.reflect.Method; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping; import org.apache.xmlrpc.server.ReflectiveXmlRpcHandler; import org.apache.xmlrpc.server.RequestProcessorFactoryFactory.RequestProcessorFactory; /** Default implementation of {@link XmlRpcMetaDataHandler}. */ public class ReflectiveXmlRpcMetaDataHandler extends ReflectiveXmlRpcHandler implements XmlRpcMetaDataHandler { private final String[][] signatures; private final String methodHelp; /** Creates a new instance. * @param pMapping The mapping, which creates this handler. * @param pClass The class, which has been inspected to create * this handler. Typically, this will be the same as *
pInstance.getClass()
. It is used for diagnostic * messages only. * @param pMethods The method, which will be invoked for * executing the handler. * @param pSignatures The signature, which will be returned by * {@link #getSignatures()}. * @param pMethodHelp The help string, which will be returned * by {@link #getMethodHelp()}. */ public ReflectiveXmlRpcMetaDataHandler(AbstractReflectiveHandlerMapping pMapping, TypeConverterFactory pTypeConverterFactory, Class pClass, RequestProcessorFactory pFactory, Method[] pMethods, String[][] pSignatures, String pMethodHelp) { super(pMapping, pTypeConverterFactory, pClass, pFactory, pMethods); signatures = pSignatures; methodHelp = pMethodHelp; } public String[][] getSignatures() throws XmlRpcException { return signatures; } public String getMethodHelp() throws XmlRpcException { return methodHelp; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/Util.java100644 0 0 15343 11333307152 25021 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.metadata; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import org.apache.xmlrpc.XmlRpcException; import org.w3c.dom.Node; /** Utility class, which provides services to meta data * handlers and handler mappings. */ public class Util { /** This field should solve the problem, that we do not * want to depend on the presence of JAXB. However, if * it is available, we want to support it. */ private static final Class jaxbElementClass; static { Class c; try { c = Class.forName("javax.xml.bind.Element"); } catch (ClassNotFoundException e) { c = null; } jaxbElementClass = c; } /** Returns a signature for the given return type or * parameter class. * @param pType The class for which a signature is being * queried. * @return Signature, if known, or null. */ public static String getSignatureType(Class pType) { if (pType == Integer.TYPE || pType == Integer.class) return "int"; if (pType == Double.TYPE || pType == Double.class) return "double"; if (pType == Boolean.TYPE || pType == Boolean.class) return "boolean"; if (pType == String.class) return "string"; if (Object[].class.isAssignableFrom(pType) || List.class.isAssignableFrom(pType)) return "array"; if (Map.class.isAssignableFrom(pType)) return "struct"; if (Date.class.isAssignableFrom(pType) || Calendar.class.isAssignableFrom(pType)) return "dateTime.iso8601"; if (pType == byte[].class) return "base64"; // extension types if (pType == void.class) return "ex:nil"; if (pType == Byte.TYPE || pType == Byte.class) return "ex:i1"; if (pType == Short.TYPE || pType == Short.class) return "ex:i2"; if (pType == Long.TYPE || pType == Long.class) return "ex:i8"; if (pType == Float.TYPE || pType == Float.class) return "ex:float"; if (Node.class.isAssignableFrom(pType)) return "ex:node"; if (jaxbElementClass != null && jaxbElementClass.isAssignableFrom(pType)) { return "ex:jaxbElement"; } if (Serializable.class.isAssignableFrom(pType)) return "base64"; // give up return null; } /** Returns a signature for the given methods. * @param pMethods Methods, for which a signature is * being queried. * @return Signature string, or null, if no signature * is available. */ public static String[][] getSignature(Method[] pMethods) { final List result = new ArrayList(); for (int i = 0; i < pMethods.length; i++) { String[] sig = getSignature(pMethods[i]); if (sig != null) { result.add(sig); } } return (String[][]) result.toArray(new String[result.size()][]); } /** Returns a signature for the given methods. * @param pMethod Method, for which a signature is * being queried. * @return Signature string, or null, if no signature * is available. */ public static String[] getSignature(Method pMethod) { Class[] paramClasses = pMethod.getParameterTypes(); String[] sig = new String[paramClasses.length + 1]; String s = getSignatureType(pMethod.getReturnType()); if (s == null) { return null; } sig[0] = s; for (int i = 0; i < paramClasses.length; i++) { s = getSignatureType(paramClasses[i]); if (s == null) { return null; } sig[i+1] = s; } return sig; } /** Returns a help string for the given method, which * is applied to the given class. */ public static String getMethodHelp(Class pClass, Method[] pMethods) { final List result = new ArrayList(); for (int i = 0; i < pMethods.length; i++) { String help = getMethodHelp(pClass, pMethods[i]); if (help != null) { result.add(help); } } switch (result.size()) { case 0: return null; case 1: return (String) result.get(0); default: StringBuffer sb = new StringBuffer(); for (int i = 0; i < result.size(); i++) { sb.append(i+1); sb.append(": "); sb.append(result.get(i)); sb.append("\n"); } return sb.toString(); } } /** Returns a help string for the given method, which * is applied to the given class. */ public static String getMethodHelp(Class pClass, Method pMethod) { StringBuffer sb = new StringBuffer(); sb.append("Invokes the method "); sb.append(pClass.getName()); sb.append("."); sb.append(pMethod.getName()); sb.append("("); Class[] paramClasses = pMethod.getParameterTypes(); for (int i = 0; i < paramClasses.length; i++) { if (i > 0) { sb.append(", "); } sb.append(paramClasses[i].getName()); } sb.append(")."); return sb.toString(); } /** Returns a signature for the given parameter set. This is used * in error messages. */ public static String getSignature(Object[] args) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < args.length; i++) { if (i > 0) { sb.append(", "); } if (args[i] == null) { sb.append("null"); } else { sb.append(args[i].getClass().getName()); } } return sb.toString(); } /** * Creates a new instance of pClass. */ public static Object newInstance(Class pClass) throws XmlRpcException { try { return pClass.newInstance(); } catch (InstantiationException e) { throw new XmlRpcException("Failed to instantiate class " + pClass.getName(), e); } catch (IllegalAccessException e) { throw new XmlRpcException("Illegal access when instantiating class " + pClass.getName(), e); } } } ././@LongLink100644 0 0 152 11333313337 10251 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/XmlRpcListableHandlerMapping.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/XmlRpcListableHandlerMapping100644 0 0 11066 11333307152 30661 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.metadata; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; /** A listable handler mapping is able to provide support for * XML-RPC meta data, as specified * * here.
* * @see * Specification of XML-RPC introspection */ public interface XmlRpcListableHandlerMapping extends XmlRpcHandlerMapping { /** This method implements the introspection method * system.listMethods, which is specified * as follows: * *

This method may be used to enumerate the methods implemented * by the XML-RPC server.

*

The system.listMethods method requires no * parameters. It returns an array of strings, each of which is * the name of a method implemented by the server. * *

Note, that the specification doesn't require that the list * must be exhaustive. We conclude, that a valid method * "handlerName" doesn't need to be in the list. For example, * a handler, which implements {@link XmlRpcHandler}, but not * {@link XmlRpcMetaDataHandler}, should possibly excluded: * Otherwise, the listable handler mapping could not provide * meaningful replies to system.methodSignature, * and system.methodHelp. * * @throws XmlRpcException An internal error occurred. */ String[] getListMethods() throws XmlRpcException; /** This method implements the introspection method * system.methodSignature, which is specified * as follows: * *

This method takes one parameter, the name of a method * implemented by the XML-RPC server. It returns an array * of possible signatures for this method. A signature is * an array of types. The first of these types is the return * type of the method, the rest are parameters.

*

Multiple signatures (ie. overloading) are permitted: * this is the reason that an array of signatures are returned * by this method.

*

Signatures themselves are restricted to the top level * parameters expected by a method. For instance if a method * expects one array of structs as a parameter, and it returns * a string, its signature is simply "string, array". If it * expects three integers, its signature is * "string, int, int, int".

*

If no signature is defined for the method, a none-array * value is returned. Therefore this is the way to test for a * non-signature, if $resp below is the response object from * a method call to system.methodSignature: *

	 *      $v=$resp->value();
	 *      if ($v->kindOf()!="array") {
	 *        // then the method did not have a signature defined
	 *      }
	 *    
* See the introspect.php demo included in this distribution * for an example of using this method.

*
* @see XmlRpcMetaDataHandler#getSignatures() */ String[][] getMethodSignature(String pHandlerName) throws XmlRpcException; /** This method implements the introspection method * system.methodSignature, which is specified * as follows: * *

This method takes one parameter, the name of a * method implemented by the XML-RPC server. It * returns a documentation string describing the * use of that method. If no such string is available, * an empty string is returned.

*

The documentation string may contain HTML markup.

*
*/ String getMethodHelp(String pHandlerName) throws XmlRpcException; } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/XmlRpcMetaDataHandler.java100644 0 0 4531 11333307152 30165 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.metadata; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping; /** A metadata handler is able to provide metadata about * itself, as specified * * here.
* * @see * Specification of XML-RPC introspection */ public interface XmlRpcMetaDataHandler extends XmlRpcHandler { /**

This method may be used to implement * {@link XmlRpcListableHandlerMapping#getMethodSignature(String)}. * Typically, the handler mapping will pick up the * matching handler, invoke its method * {@link #getSignatures()}, and return the result.

*

Method handlers, which are created by the * {@link AbstractReflectiveHandlerMapping}, will typically * return a single signature only.

* @return An array of arrays. Any element in the outer * array is a signature. The elements in the inner array * are being concatenated with commas. The inner arrays * first element is the return type, followed by the * parameter types. */ String[][] getSignatures() throws XmlRpcException; /**

This method may be used to implement * {@link XmlRpcListableHandlerMapping#getMethodHelp(String)}. * Typically, the handler mapping will pick up the * matching handler, invoke its method * {@link #getMethodHelp()}, and return the result.

*/ String getMethodHelp() throws XmlRpcException; } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/metadata/XmlRpcSystemImpl.java100644 0 0 6500 11333307152 27313 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.metadata; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.RequestProcessorFactoryFactory; /** This class implements the various "system" calls, * as specifies by {@link XmlRpcListableHandlerMapping}. * Suggested use is to create an instance and add it to * the handler mapping with the "system" prefix. */ public class XmlRpcSystemImpl { private XmlRpcListableHandlerMapping mapping; /** Creates a new instance, which provides meta data * for the given handler mappings methods. */ public XmlRpcSystemImpl(XmlRpcListableHandlerMapping pMapping) { mapping = pMapping; } /** Implements the "system.methodSignature" call. * @see XmlRpcListableHandlerMapping#getMethodSignature(String) */ public String[][] methodSignature(String methodName) throws XmlRpcException { return mapping.getMethodSignature(methodName); } /** Implements the "system.methodHelp" call. * @see XmlRpcListableHandlerMapping#getMethodHelp(String) */ public String methodHelp(String methodName) throws XmlRpcException { return mapping.getMethodHelp(methodName); } /** Implements the "system.listMethods" call. * @see XmlRpcListableHandlerMapping#getListMethods() */ public String[] listMethods() throws XmlRpcException { return mapping.getListMethods(); } /** * Adds an instance of this class to the given handler * mapping. */ public static void addSystemHandler(final PropertyHandlerMapping pMapping) throws XmlRpcException { final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory(); final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping); pMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory(){ public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException { if (XmlRpcSystemImpl.class.equals(pClass)) { return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest request) throws XmlRpcException { return systemHandler; } }; } else { return factory.getRequestProcessorFactory(pClass); } } }); pMapping.addHandler("system", XmlRpcSystemImpl.class); } } ././@LongLink100644 0 0 154 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/AbstractReflectiveHandlerMapping.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/AbstractReflectiveHandlerMappi100644 0 0 24226 11333307153 30754 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.metadata.ReflectiveXmlRpcMetaDataHandler; import org.apache.xmlrpc.metadata.Util; import org.apache.xmlrpc.metadata.XmlRpcListableHandlerMapping; import org.apache.xmlrpc.metadata.XmlRpcMetaDataHandler; import org.apache.xmlrpc.server.RequestProcessorFactoryFactory.RequestProcessorFactory; /** Abstract base class of handler mappings, which are * using reflection. */ public abstract class AbstractReflectiveHandlerMapping implements XmlRpcListableHandlerMapping { /** An object implementing this interface may be used * to validate user names and passwords. */ public interface AuthenticationHandler { /** Returns, whether the user is authenticated and * authorized to perform the request. */ boolean isAuthorized(XmlRpcRequest pRequest) throws XmlRpcException; } private TypeConverterFactory typeConverterFactory = new TypeConverterFactoryImpl(); protected Map handlerMap = new HashMap(); private AuthenticationHandler authenticationHandler; private RequestProcessorFactoryFactory requestProcessorFactoryFactory = new RequestProcessorFactoryFactory.RequestSpecificProcessorFactoryFactory(); private boolean voidMethodEnabled; /** * Sets the mappings {@link TypeConverterFactory}. */ public void setTypeConverterFactory(TypeConverterFactory pFactory) { typeConverterFactory = pFactory; } /** * Returns the mappings {@link TypeConverterFactory}. */ public TypeConverterFactory getTypeConverterFactory() { return typeConverterFactory; } /** Sets the mappings {@link RequestProcessorFactoryFactory}. Note, that this doesn't * affect already registered handlers. */ public void setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory) { requestProcessorFactoryFactory = pFactory; } /** Returns the mappings {@link RequestProcessorFactoryFactory}. */ public RequestProcessorFactoryFactory getRequestProcessorFactoryFactory() { return requestProcessorFactoryFactory; } /** Returns the authentication handler, if any, or null. */ public AuthenticationHandler getAuthenticationHandler() { return authenticationHandler; } /** Sets the authentication handler, if any, or null. */ public void setAuthenticationHandler(AuthenticationHandler pAuthenticationHandler) { authenticationHandler = pAuthenticationHandler; } protected boolean isHandlerMethod(Method pMethod) { if (!Modifier.isPublic(pMethod.getModifiers())) { return false; // Ignore methods, which aren't public } if (Modifier.isStatic(pMethod.getModifiers())) { return false; // Ignore methods, which are static } if (!isVoidMethodEnabled() && pMethod.getReturnType() == void.class) { return false; // Ignore void methods. } if (pMethod.getDeclaringClass() == Object.class) { return false; // Ignore methods from Object.class } return true; } /** Searches for methods in the given class. For any valid * method, it creates an instance of {@link XmlRpcHandler}. * Valid methods are defined as follows: * * @param pKey Suffix for building handler names. A dot and * the method name are being added. * @param pType The class being inspected. */ protected void registerPublicMethods(String pKey, Class pType) throws XmlRpcException { Map map = new HashMap(); Method[] methods = pType.getMethods(); for (int i = 0; i < methods.length; i++) { final Method method = methods[i]; if (!isHandlerMethod(method)) { continue; } String name = pKey + "." + method.getName(); Method[] mArray; Method[] oldMArray = (Method[]) map.get(name); if (oldMArray == null) { mArray = new Method[]{method}; } else { mArray = new Method[oldMArray.length+1]; System.arraycopy(oldMArray, 0, mArray, 0, oldMArray.length); mArray[oldMArray.length] = method; } map.put(name, mArray); } for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Method[] mArray = (Method[]) entry.getValue(); handlerMap.put(name, newXmlRpcHandler(pType, mArray)); } } /** Creates a new instance of {@link XmlRpcHandler}. * @param pClass The class, which was inspected for handler * methods. This is used for error messages only. Typically, * it is the same than
pInstance.getClass()
. * @param pMethods The method being invoked. */ protected XmlRpcHandler newXmlRpcHandler(final Class pClass, final Method[] pMethods) throws XmlRpcException { String[][] sig = getSignature(pMethods); String help = getMethodHelp(pClass, pMethods); RequestProcessorFactory factory = requestProcessorFactoryFactory.getRequestProcessorFactory(pClass); if (sig == null || help == null) { return new ReflectiveXmlRpcHandler(this, typeConverterFactory, pClass, factory, pMethods); } return new ReflectiveXmlRpcMetaDataHandler(this, typeConverterFactory, pClass, factory, pMethods, sig, help); } /** Creates a signature for the given method. */ protected String[][] getSignature(Method[] pMethods) { return Util.getSignature(pMethods); } /** Creates a help string for the given method, when applied * to the given class. */ protected String getMethodHelp(Class pClass, Method[] pMethods) { return Util.getMethodHelp(pClass, pMethods); } /** Returns the {@link XmlRpcHandler} with the given name. * @param pHandlerName The handlers name * @throws XmlRpcNoSuchHandlerException A handler with the given * name is unknown. */ public XmlRpcHandler getHandler(String pHandlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException { XmlRpcHandler result = (XmlRpcHandler) handlerMap.get(pHandlerName); if (result == null) { throw new XmlRpcNoSuchHandlerException("No such handler: " + pHandlerName); } return result; } public String[] getListMethods() throws XmlRpcException { List list = new ArrayList(); for (Iterator iter = handlerMap.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); if (entry.getValue() instanceof XmlRpcMetaDataHandler) { list.add(entry.getKey()); } } return (String[]) list.toArray(new String[list.size()]); } public String getMethodHelp(String pHandlerName) throws XmlRpcException { XmlRpcHandler h = getHandler(pHandlerName); if (h instanceof XmlRpcMetaDataHandler) return ((XmlRpcMetaDataHandler)h).getMethodHelp(); throw new XmlRpcNoSuchHandlerException("No help available for method: " + pHandlerName); } public String[][] getMethodSignature(String pHandlerName) throws XmlRpcException { XmlRpcHandler h = getHandler(pHandlerName); if (h instanceof XmlRpcMetaDataHandler) return ((XmlRpcMetaDataHandler)h).getSignatures(); throw new XmlRpcNoSuchHandlerException("No metadata available for method: " + pHandlerName); } /** * Returns, whether void methods are enabled. By default, null values * aren't supported by XML-RPC and void methods are in fact returning * null (at least from the perspective of reflection). */ public boolean isVoidMethodEnabled() { return voidMethodEnabled; } /** * Sets, whether void methods are enabled. By default, null values * aren't supported by XML-RPC and void methods are in fact returning * null (at least from the perspective of reflection). */ public void setVoidMethodEnabled(boolean pVoidMethodEnabled) { voidMethodEnabled = pVoidMethodEnabled; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/PropertyHandlerMapping.java100644 0 0 11341 11333307153 30263 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import java.io.IOException; import java.net.URL; import java.util.Iterator; import java.util.Map; import java.util.Properties; import org.apache.xmlrpc.XmlRpcException; /** * A handler mapping based on a property file. The property file * contains a set of properties. The property key is taken as the * handler name. The property value is taken as the name of a * class being instantiated. For any non-void, non-static, and * public method in the class, an entry in the handler map is * generated. A typical use would be, to specify interface names * as the property keys and implementations as the values. */ public class PropertyHandlerMapping extends AbstractReflectiveHandlerMapping { /** * Reads handler definitions from a resource file. * @param pClassLoader The class loader being used to load * handler classes. * @param pResource The resource being used, for example * "org/apache/xmlrpc/webserver/XmlRpcServlet.properties" * @throws IOException Loading the property file failed. * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, String pResource) throws IOException, XmlRpcException { URL url = pClassLoader.getResource(pResource); if (url == null) { throw new IOException("Unable to locate resource " + pResource); } load(pClassLoader, url); } /** * Reads handler definitions from a property file. * @param pClassLoader The class loader being used to load * handler classes. * @param pURL The URL from which to load the property file * @throws IOException Loading the property file failed. * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, URL pURL) throws IOException, XmlRpcException { Properties props = new Properties(); props.load(pURL.openStream()); load(pClassLoader, props); } /** * Reads handler definitions from an existing Map. * @param pClassLoader The class loader being used to load * handler classes. * @param pMap The existing Map to read from * @throws XmlRpcException Initializing the handlers failed. */ public void load(ClassLoader pClassLoader, Map pMap) throws XmlRpcException { for (Iterator iter = pMap.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); Class c = newHandlerClass(pClassLoader, value); registerPublicMethods(key, c); } } protected Class newHandlerClass(ClassLoader pClassLoader, String pClassName) throws XmlRpcException { final Class c; try { c = pClassLoader.loadClass(pClassName); } catch (ClassNotFoundException e) { throw new XmlRpcException("Unable to load class: " + pClassName, e); } if (c == null) { throw new XmlRpcException(0, "Loading class " + pClassName + " returned null."); } return c; } /** Adds handlers for the given object to the mapping. * The handlers are build by invoking * {@link #registerPublicMethods(String, Class)}. * @param pKey The class key, which is passed * to {@link #registerPublicMethods(String, Class)}. * @param pClass Class, which is responsible for handling the request. */ public void addHandler(String pKey, Class pClass) throws XmlRpcException { registerPublicMethods(pKey, pClass); } /** Removes all handlers with the given class key. */ public void removeHandler(String pKey) { for (Iterator i = handlerMap.keySet().iterator(); i.hasNext();) { String k = (String)i.next(); if (k.startsWith(pKey)) i.remove(); } } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/ReflectiveXmlRpcHandler.java100644 0 0 13374 11333307153 30351 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.TypeConverter; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.XmlRpcInvocationException; import org.apache.xmlrpc.common.XmlRpcNotAuthorizedException; import org.apache.xmlrpc.metadata.Util; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler; import org.apache.xmlrpc.server.RequestProcessorFactoryFactory.RequestProcessorFactory; /** Default implementation of {@link XmlRpcHandler}. */ public class ReflectiveXmlRpcHandler implements XmlRpcHandler { private static class MethodData { final Method method; final TypeConverter[] typeConverters; MethodData(Method pMethod, TypeConverterFactory pTypeConverterFactory) { method = pMethod; Class[] paramClasses = method.getParameterTypes(); typeConverters = new TypeConverter[paramClasses.length]; for (int i = 0; i < paramClasses.length; i++) { typeConverters[i] = pTypeConverterFactory.getTypeConverter(paramClasses[i]); } } } private final AbstractReflectiveHandlerMapping mapping; private final MethodData[] methods; private final Class clazz; private final RequestProcessorFactory requestProcessorFactory; /** Creates a new instance. * @param pMapping The mapping, which creates this handler. * @param pClass The class, which has been inspected to create * this handler. Typically, this will be the same as *
pInstance.getClass()
. It is used for diagnostic * messages only. * @param pMethods The method, which will be invoked for * executing the handler. */ public ReflectiveXmlRpcHandler(AbstractReflectiveHandlerMapping pMapping, TypeConverterFactory pTypeConverterFactory, Class pClass, RequestProcessorFactory pFactory, Method[] pMethods) { mapping = pMapping; clazz = pClass; methods = new MethodData[pMethods.length]; requestProcessorFactory = pFactory; for (int i = 0; i < methods.length; i++) { methods[i] = new MethodData(pMethods[i], pTypeConverterFactory); } } private Object getInstance(XmlRpcRequest pRequest) throws XmlRpcException { return requestProcessorFactory.getRequestProcessor(pRequest); } public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { AuthenticationHandler authHandler = mapping.getAuthenticationHandler(); if (authHandler != null && !authHandler.isAuthorized(pRequest)) { throw new XmlRpcNotAuthorizedException("Not authorized"); } Object[] args = new Object[pRequest.getParameterCount()]; for (int j = 0; j < args.length; j++) { args[j] = pRequest.getParameter(j); } Object instance = getInstance(pRequest); for (int i = 0; i < methods.length; i++) { MethodData methodData = methods[i]; TypeConverter[] converters = methodData.typeConverters; if (args.length == converters.length) { boolean matching = true; for (int j = 0; j < args.length; j++) { if (!converters[j].isConvertable(args[j])) { matching = false; break; } } if (matching) { for (int j = 0; j < args.length; j++) { args[j] = converters[j].convert(args[j]); } return invoke(instance, methodData.method, args); } } } throw new XmlRpcException("No method matching arguments: " + Util.getSignature(args)); } private Object invoke(Object pInstance, Method pMethod, Object[] pArgs) throws XmlRpcException { try { return pMethod.invoke(pInstance, pArgs); } catch (IllegalAccessException e) { throw new XmlRpcException("Illegal access to method " + pMethod.getName() + " in class " + clazz.getName(), e); } catch (IllegalArgumentException e) { throw new XmlRpcException("Illegal argument for method " + pMethod.getName() + " in class " + clazz.getName(), e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof XmlRpcException) { throw (XmlRpcException) t; } throw new XmlRpcInvocationException("Failed to invoke method " + pMethod.getName() + " in class " + clazz.getName() + ": " + t.getMessage(), t); } } } ././@LongLink100644 0 0 152 11333313337 10251 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/RequestProcessorFactoryFactory.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/RequestProcessorFactoryFactory100644 0 0 16363 11333307153 31126 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.metadata.Util; /** *

The request processor is the object, which is actually performing * the request. There is nothing magic about the request processor: * It may very well be a POJO. The {@link RequestProcessorFactoryFactory} * is passed to the {@link AbstractReflectiveHandlerMapping} at startup. * The mapping uses this factory to create instances of * {@link RequestProcessorFactory}, which are used to initialize * the {@link ReflectiveXmlRpcHandler}. The handler in turn uses its * factory to create the actual request processor when a request comes * in.

*

However, the question arises, when and how the request processor * is created and whether it needs request specific initialization. * The {@link RequestProcessorFactoryFactory} is an object, which makes * that logic pluggable. Unfortunately, we aren't done with a single * factory: We even need a factory for factories. The rationale is * best explained by looking at the different use cases and how to * implement them.

*

The default {@link RequestProcessorFactoryFactory} is the * {@link RequestSpecificProcessorFactoryFactory}. It creates a new * processor instance for any request. In other words, it allows the * request processor to have some state. This is fine, if the request * processor is a lightweight object or needs request specific * initialization. In this case, the actual request processor is * created and invoked when * calling {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.

*

An alternative implementation is the * {@link StatelessProcessorFactoryFactory}, which may be used to * create stateless request processors. Stateless request processors * are typically heavyweight objects, which have an expensive * initialization phase. The processor factory, which is created by * {@link #getRequestProcessorFactory(Class pClass)} contains an * initialized singleton, which is returned by * {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.

*

Other alternatives might be a * {@link RequestProcessorFactoryFactory}, which maintains a pool * of {@link RequestProcessorFactory} instances. The instances are * configured by calling * {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.

*/ public interface RequestProcessorFactoryFactory { /** * This is the factory for request processors. This factory is itself * created by a call to * {@link RequestProcessorFactoryFactory#getRequestProcessorFactory(Class)}. */ public interface RequestProcessorFactory { /** * This method is invoked for any request in order to create and * configure the request processor. The returned object is an * instance of the class parameter in * {@link RequestProcessorFactoryFactory#getRequestProcessorFactory(Class)}. */ public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException; } /** * This method is invoked at startup. It creates a factory for instances of * pClass. */ public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException; /** * This is the default implementation of {@link RequestProcessorFactoryFactory}. * A new instance is created and initialized for any request. The instance may * be configured by overwriting {@link #getRequestProcessor(Class, XmlRpcRequest)}. */ public static class RequestSpecificProcessorFactoryFactory implements RequestProcessorFactoryFactory { /** * Subclasses may override this method for request specific configuration. * A typical subclass will look like this: *
         *   public class MyRequestProcessorFactoryFactory
         *           extends RequestProcessorFactoryFactory {
         *       protected Object getRequestProcessor(Class pClass, XmlRpcRequest pRequest) {
         *           Object result = super.getRequestProcessor(pClass, pRequest);
         *           // Configure the object here
         *           ...
         *           return result;
         *       }
         *   }
         * 
* @param pRequest The request object. */ protected Object getRequestProcessor(Class pClass, XmlRpcRequest pRequest) throws XmlRpcException { return Util.newInstance(pClass); } public RequestProcessorFactory getRequestProcessorFactory(final Class pClass) throws XmlRpcException { return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException { return RequestSpecificProcessorFactoryFactory.this.getRequestProcessor(pClass, pRequest); } }; } } /** * This is an alternative implementation of {@link RequestProcessorFactoryFactory}. * It creates stateless request processors, which are able to process concurrent * requests without request specific initialization. */ public static class StatelessProcessorFactoryFactory implements RequestProcessorFactoryFactory { /** * Subclasses may override this method for class specific configuration. Note, * that this method will be called at startup only! A typical subclass will * look like this: *
         *   public class MyRequestProcessorFactoryFactory
         *           extends StatelessProcessorFactoryFactory {
         *       protected Object getRequestProcessor(Class pClass) {
         *           Object result = super.getRequestProcessor(pClass);
         *           // Configure the object here
         *           ...
         *           return result;
         *       }
         *   }
         * 
*/ protected Object getRequestProcessor(Class pClass) throws XmlRpcException { return Util.newInstance(pClass); } public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException { final Object processor = getRequestProcessor(pClass); return new RequestProcessorFactory(){ public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException { return processor; } }; } } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/ServerHttpConnection.java100644 0 0 2340 11333307153 27732 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.common.ServerStreamConnection; /** Interface of a {@link ServerStreamConnection} for HTTP * response transport. */ public interface ServerHttpConnection extends ServerStreamConnection { /** Sets a response header. */ void setResponseHeader(String pKey, String pValue); /** Sets the content length. */ void setContentLength(int pContentLength); } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcErrorLogger.java100644 0 0 2713 11333307153 27167 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Instances of this class can be used to customize the servers * error logging. */ public class XmlRpcErrorLogger { private static final Log log = LogFactory.getLog(XmlRpcErrorLogger.class); /** * Called to log the given error. */ public void log(String pMessage, Throwable pThrowable) { log.error(pMessage, pThrowable); } /** * Called to log the given error message. */ public void log(String pMessage) { log.error(pMessage); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcHandlerMapping.java100644 0 0 2746 11333307153 27635 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; /** Maps from a handler name to a handler object. * @since 1.2 */ public interface XmlRpcHandlerMapping { /** Return the handler for the specified handler name. * @param handlerName The name of the handler to retrieve. * @return Object The desired handler. Never null, an exception * is thrown if no such handler is available. * @throws XmlRpcNoSuchHandlerException The handler is not available. * @throws XmlRpcException An internal error occurred. */ public XmlRpcHandler getHandler(String handlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException; } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcHttpServer.java100644 0 0 3165 11333307153 27046 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import java.io.IOException; import java.io.OutputStream; import org.apache.xmlrpc.common.ServerStreamConnection; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; /** Abstract extension of {@link XmlRpcStreamServer} for deriving * HTTP servers. */ public abstract class XmlRpcHttpServer extends XmlRpcStreamServer { protected abstract void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue); protected OutputStream getOutputStream(ServerStreamConnection pConnection, XmlRpcStreamRequestConfig pConfig, OutputStream pStream) throws IOException { if (pConfig.isEnabledForExtensions() && pConfig.isGzipRequesting()) { setResponseHeader(pConnection, "Content-Encoding", "gzip"); } return super.getOutputStream(pConnection, pConfig, pStream); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcHttpServerConfig.java100644 0 0 2521 11333307153 30167 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.common.XmlRpcHttpConfig; /** HTTP servers configuration. */ public interface XmlRpcHttpServerConfig extends XmlRpcServerConfig, XmlRpcHttpConfig { /** Returns, whether HTTP keepalive is being enabled. * @return True, if keepalive is enabled, false otherwise. */ boolean isKeepAliveEnabled(); /** Returns, whether the server may create a "faultCause" element in an error * response. Note, that this may be a security issue! */ boolean isEnabledForExceptions(); } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java100644 0 0 2550 11333307153 30332 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcRequestProcessor; import org.apache.xmlrpc.common.XmlRpcRequestProcessorFactory; /** Server part of a local stream transport. */ public class XmlRpcLocalStreamServer extends XmlRpcStreamServer { public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcRequestProcessor server = ((XmlRpcRequestProcessorFactory) pRequest.getConfig()).getXmlRpcServer(); return server.execute(pRequest); } }././@LongLink100644 0 0 150 11333313337 10247 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcNoSuchHandlerException.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcNoSuchHandlerException.j100644 0 0 2372 11333307153 30623 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcException; /** This exception is thrown, if an unknown handler is called. */ public class XmlRpcNoSuchHandlerException extends XmlRpcException { private static final long serialVersionUID = 3257002138218344501L; /** Creates a new instance with the given message. * @param pMessage The error details. */ public XmlRpcNoSuchHandlerException(String pMessage) { super(0, pMessage); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServer.java100644 0 0 6327 11333307153 26211 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcConfig; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcRequestProcessor; import org.apache.xmlrpc.common.XmlRpcWorker; import org.apache.xmlrpc.common.XmlRpcWorkerFactory; /** A multithreaded, reusable XML-RPC server object. The name may * be misleading because this does not open any server sockets. * Instead it is fed by passing instances of * {@link org.apache.xmlrpc.XmlRpcRequest} from * a transport. */ public class XmlRpcServer extends XmlRpcController implements XmlRpcRequestProcessor { private XmlRpcHandlerMapping handlerMapping; private TypeConverterFactory typeConverterFactory = new TypeConverterFactoryImpl(); private XmlRpcServerConfig config = new XmlRpcServerConfigImpl(); protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory() { return new XmlRpcServerWorkerFactory(this); } /** Sets the servers {@link TypeConverterFactory}. */ public void setTypeConverterFactory(TypeConverterFactory pFactory) { typeConverterFactory = pFactory; } public TypeConverterFactory getTypeConverterFactory() { return typeConverterFactory; } /** Sets the servers configuration. * @param pConfig The new server configuration. */ public void setConfig(XmlRpcServerConfig pConfig) { config = pConfig; } public XmlRpcConfig getConfig() { return config; } /** Sets the servers handler mapping. * @param pMapping The servers handler mapping. */ public void setHandlerMapping(XmlRpcHandlerMapping pMapping) { handlerMapping = pMapping; } /** Returns the servers handler mapping. * @return The servers handler mapping. */ public XmlRpcHandlerMapping getHandlerMapping() { return handlerMapping; } /** Performs the given request. * @param pRequest The request being executed. * @return The result object. * @throws XmlRpcException The request failed. */ public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { final XmlRpcWorkerFactory factory = getWorkerFactory(); final XmlRpcWorker worker = factory.getWorker(); try { return worker.execute(pRequest); } finally { factory.releaseWorker(worker); } } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServerConfig.java100644 0 0 2003 11333307153 27322 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcConfig; /** Server specific extension of {@link org.apache.xmlrpc.XmlRpcConfig}. */ public interface XmlRpcServerConfig extends XmlRpcConfig { } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServerConfigImpl.java100644 0 0 3507 11333307153 30156 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcConfigImpl; /** Default implementation of {@link org.apache.xmlrpc.server.XmlRpcServerConfig}. */ public class XmlRpcServerConfigImpl extends XmlRpcConfigImpl implements XmlRpcServerConfig, XmlRpcHttpServerConfig { private boolean isKeepAliveEnabled; private boolean isEnabledForExceptions; /** Sets, whether HTTP keepalive is enabled for this server. * @param pKeepAliveEnabled True, if keepalive is enabled. False otherwise. */ public void setKeepAliveEnabled(boolean pKeepAliveEnabled) { isKeepAliveEnabled = pKeepAliveEnabled; } public boolean isKeepAliveEnabled() { return isKeepAliveEnabled; } /** Sets, whether the server may create a "faultCause" element in an error * response. Note, that this may be a security issue! */ public void setEnabledForExceptions(boolean pEnabledForExceptions) { isEnabledForExceptions = pEnabledForExceptions; } public boolean isEnabledForExceptions() { return isEnabledForExceptions; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServerWorker.java100644 0 0 3406 11333307153 27376 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcWorker; /** Server specific implementation of {@link XmlRpcWorker}. */ public class XmlRpcServerWorker implements XmlRpcWorker { private final XmlRpcServerWorkerFactory factory; /** Creates a new instance. * @param pFactory The factory creating the worker. */ public XmlRpcServerWorker(XmlRpcServerWorkerFactory pFactory) { factory = pFactory; } public XmlRpcController getController() { return factory.getController(); } public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcServer server = (XmlRpcServer) getController(); XmlRpcHandlerMapping mapping = server.getHandlerMapping(); XmlRpcHandler handler = mapping.getHandler(pRequest.getMethodName()); return handler.execute(pRequest); } } ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServerWorkerFactory.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcServerWorkerFactory.java100644 0 0 2451 11333307153 30725 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import org.apache.xmlrpc.common.XmlRpcWorker; import org.apache.xmlrpc.common.XmlRpcWorkerFactory; /** Server specific worker factory. */ public class XmlRpcServerWorkerFactory extends XmlRpcWorkerFactory { /** Creates a new factory with the given controller. * @param pServer The factory controller. */ public XmlRpcServerWorkerFactory(XmlRpcServer pServer) { super(pServer); } protected XmlRpcWorker newWorker() { return new XmlRpcServerWorker(this); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/server/XmlRpcStreamServer.java100644 0 0 22245 11333307153 27402 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.server; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.XmlRpcRequestConfig; import org.apache.xmlrpc.common.ServerStreamConnection; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestProcessor; import org.apache.xmlrpc.parser.XmlRpcRequestParser; import org.apache.xmlrpc.serializer.DefaultXMLWriterFactory; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.apache.xmlrpc.serializer.XmlWriterFactory; import org.apache.xmlrpc.util.SAXParsers; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** Extension of {@link XmlRpcServer} with support for reading * requests from a stream and writing the response to another * stream. */ public abstract class XmlRpcStreamServer extends XmlRpcServer implements XmlRpcStreamRequestProcessor { private static final Log log = LogFactory.getLog(XmlRpcStreamServer.class); private XmlWriterFactory writerFactory = new DefaultXMLWriterFactory(); private static final XmlRpcErrorLogger theErrorLogger = new XmlRpcErrorLogger(); private XmlRpcErrorLogger errorLogger = theErrorLogger; protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException { final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory()); final XMLReader xr = SAXParsers.newXMLReader(); xr.setContentHandler(parser); try { xr.parse(new InputSource(pStream)); } catch (SAXException e) { Exception ex = e.getException(); if (ex != null && ex instanceof XmlRpcException) { throw (XmlRpcException) ex; } throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e); } catch (IOException e) { throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e); } final List params = parser.getParams(); return new XmlRpcRequest(){ public XmlRpcRequestConfig getConfig() { return pConfig; } public String getMethodName() { return parser.getMethodName(); } public int getParameterCount() { return params == null ? 0 : params.size(); } public Object getParameter(int pIndex) { return params.get(pIndex); } }; } protected XmlRpcWriter getXmlRpcWriter(XmlRpcStreamRequestConfig pConfig, OutputStream pStream) throws XmlRpcException { ContentHandler w = getXMLWriterFactory().getXmlWriter(pConfig, pStream); return new XmlRpcWriter(pConfig, w, getTypeFactory()); } protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException { try { getXmlRpcWriter(pConfig, pStream).write(pConfig, pResult); } catch (SAXException e) { throw new XmlRpcException("Failed to write XML-RPC response: " + e.getMessage(), e); } } /** * This method allows to convert the error into another error. For example, this * may be an error, which could be deserialized by the client. */ protected Throwable convertThrowable(Throwable pError) { return pError; } protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Throwable pError) throws XmlRpcException { final Throwable error = convertThrowable(pError); final int code; final String message; if (error instanceof XmlRpcException) { XmlRpcException ex = (XmlRpcException) error; code = ex.code; } else { code = 0; } message = error.getMessage(); try { getXmlRpcWriter(pConfig, pStream).write(pConfig, code, message, error); } catch (SAXException e) { throw new XmlRpcException("Failed to write XML-RPC response: " + e.getMessage(), e); } } /** Sets the XML Writer factory. * @param pFactory The XML Writer factory. */ public void setXMLWriterFactory(XmlWriterFactory pFactory) { writerFactory = pFactory; } /** Returns the XML Writer factory. * @return The XML Writer factory. */ public XmlWriterFactory getXMLWriterFactory() { return writerFactory; } protected InputStream getInputStream(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws IOException { InputStream istream = pConnection.newInputStream(); if (pConfig.isEnabledForExtensions() && pConfig.isGzipCompressing()) { istream = new GZIPInputStream(istream); } return istream; } /** Called to prepare the output stream. Typically used for enabling * compression, or similar filters. * @param pConnection The connection object. */ protected OutputStream getOutputStream(ServerStreamConnection pConnection, XmlRpcStreamRequestConfig pConfig, OutputStream pStream) throws IOException { if (pConfig.isEnabledForExtensions() && pConfig.isGzipRequesting()) { return new GZIPOutputStream(pStream); } else { return pStream; } } /** Called to prepare the output stream, if content length is * required. * @param pConfig The configuration object. * @param pSize The requests size. */ protected OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection, int pSize) throws IOException { return pConnection.newOutputStream(); } /** Returns, whether the requests content length is required. * @param pConfig The configuration object. */ protected boolean isContentLengthRequired(XmlRpcStreamRequestConfig pConfig) { return false; } /** Returns, whether the /** Processes a "connection". The "connection" is an opaque object, which is * being handled by the subclasses. * @param pConfig The request configuration. * @param pConnection The "connection" being processed. * @throws XmlRpcException Processing the request failed. */ public void execute(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws XmlRpcException { log.debug("execute: ->"); try { Object result; Throwable error; InputStream istream = null; try { istream = getInputStream(pConfig, pConnection); XmlRpcRequest request = getRequest(pConfig, istream); result = execute(request); istream.close(); istream = null; error = null; log.debug("execute: Request performed successfully"); } catch (Throwable t) { logError(t); result = null; error = t; } finally { if (istream != null) { try { istream.close(); } catch (Throwable ignore) {} } } boolean contentLengthRequired = isContentLengthRequired(pConfig); ByteArrayOutputStream baos; OutputStream ostream; if (contentLengthRequired) { baos = new ByteArrayOutputStream(); ostream = baos; } else { baos = null; ostream = pConnection.newOutputStream(); } ostream = getOutputStream(pConnection, pConfig, ostream); try { if (error == null) { writeResponse(pConfig, ostream, result); } else { writeError(pConfig, ostream, error); } ostream.close(); ostream = null; } finally { if (ostream != null) { try { ostream.close(); } catch (Throwable ignore) {} } } if (baos != null) { OutputStream dest = getOutputStream(pConfig, pConnection, baos.size()); try { baos.writeTo(dest); dest.close(); dest = null; } finally { if (dest != null) { try { dest.close(); } catch (Throwable ignore) {} } } } pConnection.close(); pConnection = null; } catch (IOException e) { throw new XmlRpcException("I/O error while processing request: " + e.getMessage(), e); } finally { if (pConnection != null) { try { pConnection.close(); } catch (Throwable ignore) {} } } log.debug("execute: <-"); } protected void logError(Throwable t) { final String msg = t.getMessage() == null ? t.getClass().getName() : t.getMessage(); errorLogger.log(msg, t); } /** * Returns the error logger. */ public XmlRpcErrorLogger getErrorLogger() { return errorLogger; } /** * Sets the error logger. */ public void setErrorLogger(XmlRpcErrorLogger pErrorLogger) { errorLogger = pErrorLogger; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/Connection.java100644 0 0 40766 11333307153 26437 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.SocketException; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; import org.apache.xmlrpc.common.ServerStreamConnection; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig; import org.apache.xmlrpc.common.XmlRpcNotAuthorizedException; import org.apache.xmlrpc.server.XmlRpcHttpServerConfig; import org.apache.xmlrpc.server.XmlRpcStreamServer; import org.apache.xmlrpc.util.HttpUtil; import org.apache.xmlrpc.util.LimitedInputStream; import org.apache.xmlrpc.util.ThreadPool; /** Handler for a single clients connection. This implementation * is able to do HTTP keepalive. In other words, it can serve * multiple requests via a single, physical connection. */ public class Connection implements ThreadPool.InterruptableTask, ServerStreamConnection { private static final String US_ASCII = "US-ASCII"; private static final byte[] ctype = toHTTPBytes("Content-Type: text/xml\r\n"); private static final byte[] clength = toHTTPBytes("Content-Length: "); private static final byte[] newline = toHTTPBytes("\r\n"); private static final byte[] doubleNewline = toHTTPBytes("\r\n\r\n"); private static final byte[] conkeep = toHTTPBytes("Connection: Keep-Alive\r\n"); private static final byte[] conclose = toHTTPBytes("Connection: close\r\n"); private static final byte[] ok = toHTTPBytes(" 200 OK\r\n"); private static final byte[] serverName = toHTTPBytes("Server: Apache XML-RPC 1.0\r\n"); private static final byte[] wwwAuthenticate = toHTTPBytes("WWW-Authenticate: Basic realm=XML-RPC\r\n"); private static abstract class RequestException extends IOException { private static final long serialVersionUID = 2113732921468653309L; private final RequestData requestData; RequestException(RequestData pData, String pMessage) { super(pMessage); requestData = pData; } RequestData getRequestData() { return requestData; } } private static class BadEncodingException extends RequestException { private static final long serialVersionUID = -2674424938251521248L; BadEncodingException(RequestData pData, String pTransferEncoding) { super(pData, pTransferEncoding); } } private static class BadRequestException extends RequestException { private static final long serialVersionUID = 3257848779234554934L; BadRequestException(RequestData pData, String pTransferEncoding) { super(pData, pTransferEncoding); } } /** Returns the US-ASCII encoded byte representation of text for * HTTP use (as per section 2.2 of RFC 2068). */ private static final byte[] toHTTPBytes(String text) { try { return text.getBytes(US_ASCII); } catch (UnsupportedEncodingException e) { throw new Error(e.getMessage() + ": HTTP requires US-ASCII encoding"); } } private final WebServer webServer; private final Socket socket; private final InputStream input; private final OutputStream output; private final XmlRpcStreamServer server; private byte[] buffer; private Map headers; private RequestData requestData; private boolean shuttingDown; private boolean firstByte; /** Creates a new webserver connection on the given socket. * @param pWebServer The webserver maintaining this connection. * @param pServer The server being used to execute requests. * @param pSocket The server socket to handle; the Connection * is responsible for closing this socket. * @throws IOException */ public Connection(WebServer pWebServer, XmlRpcStreamServer pServer, Socket pSocket) throws IOException { webServer = pWebServer; server = pServer; socket = pSocket; input = new BufferedInputStream(socket.getInputStream()){ /** It may happen, that the XML parser invokes close(). * Closing the input stream must not occur, because * that would close the whole socket. So we suppress it. */ public void close() throws IOException { } }; output = new BufferedOutputStream(socket.getOutputStream()); } /** Returns the connections request configuration by * merging the HTTP request headers and the servers configuration. * @return The connections request configuration. * @throws IOException Reading the request headers failed. */ private RequestData getRequestConfig() throws IOException { requestData = new RequestData(this); if (headers != null) { headers.clear(); } firstByte = true; XmlRpcHttpServerConfig serverConfig = (XmlRpcHttpServerConfig) server.getConfig(); requestData.setBasicEncoding(serverConfig.getBasicEncoding()); requestData.setContentLengthOptional(serverConfig.isContentLengthOptional()); requestData.setEnabledForExtensions(serverConfig.isEnabledForExtensions()); requestData.setEnabledForExceptions(serverConfig.isEnabledForExceptions()); // reset user authentication String line = readLine(); if (line == null && firstByte) { return null; } // Netscape sends an extra \n\r after bodypart, swallow it if (line != null && line.length() == 0) { line = readLine(); if (line == null || line.length() == 0) { return null; } } // tokenize first line of HTTP request StringTokenizer tokens = new StringTokenizer(line); String method = tokens.nextToken(); if (!"POST".equalsIgnoreCase(method)) { throw new BadRequestException(requestData, method); } requestData.setMethod(method); tokens.nextToken(); // Skip URI String httpVersion = tokens.nextToken(); requestData.setHttpVersion(httpVersion); requestData.setKeepAlive(serverConfig.isKeepAliveEnabled() && WebServer.HTTP_11.equals(httpVersion)); do { line = readLine(); if (line != null) { String lineLower = line.toLowerCase(); if (lineLower.startsWith("content-length:")) { String cLength = line.substring("content-length:".length()); requestData.setContentLength(Integer.parseInt(cLength.trim())); } else if (lineLower.startsWith("connection:")) { requestData.setKeepAlive(serverConfig.isKeepAliveEnabled() && lineLower.indexOf("keep-alive") > -1); } else if (lineLower.startsWith("authorization:")) { String credentials = line.substring("authorization:".length()); HttpUtil.parseAuthorization(requestData, credentials); } else if (lineLower.startsWith("transfer-encoding:")) { String transferEncoding = line.substring("transfer-encoding:".length()); String nonIdentityEncoding = HttpUtil.getNonIdentityTransferEncoding(transferEncoding); if (nonIdentityEncoding != null) { throw new BadEncodingException(requestData, nonIdentityEncoding); } } } } while (line != null && line.length() != 0); return requestData; } public void run() { try { for (int i = 0; ; i++) { RequestData data = getRequestConfig(); if (data == null) { break; } server.execute(data, this); output.flush(); if (!data.isKeepAlive() || !data.isSuccess()) { break; } } } catch (RequestException e) { webServer.log(e.getClass().getName() + ": " + e.getMessage()); try { writeErrorHeader(e.requestData, e, -1); output.flush(); } catch (IOException e1) { /* Ignore me */ } } catch (Throwable t) { if (!shuttingDown) { webServer.log(t); } } finally { try { output.close(); } catch (Throwable ignore) {} try { input.close(); } catch (Throwable ignore) {} try { socket.close(); } catch (Throwable ignore) {} } } private String readLine() throws IOException { if (buffer == null) { buffer = new byte[2048]; } int next; int count = 0; for (;;) { try { next = input.read(); firstByte = false; } catch (SocketException e) { if (firstByte) { return null; } else { throw e; } } if (next < 0 || next == '\n') { break; } if (next != '\r') { buffer[count++] = (byte) next; } if (count >= buffer.length) { throw new IOException("HTTP Header too long"); } } return new String(buffer, 0, count, US_ASCII); } /** Writes the response header and the response to the * output stream. * @param pData The request data. * @param pBuffer The {@link ByteArrayOutputStream} holding the response. * @throws IOException Writing the response failed. */ public void writeResponse(RequestData pData, OutputStream pBuffer) throws IOException { ByteArrayOutputStream response = (ByteArrayOutputStream) pBuffer; writeResponseHeader(pData, response.size()); response.writeTo(output); } /** Writes the response header to the output stream. * * @param pData The request data * @param pContentLength The content length, if known, or -1. * @throws IOException Writing the response failed. */ public void writeResponseHeader(RequestData pData, int pContentLength) throws IOException { output.write(toHTTPBytes(pData.getHttpVersion())); output.write(ok); output.write(serverName); output.write(pData.isKeepAlive() ? conkeep : conclose); output.write(ctype); if (headers != null) { for (Iterator iter = headers.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String header = (String) entry.getKey(); String value = (String) entry.getValue(); output.write(toHTTPBytes(header + ": " + value + "\r\n")); } } if (pContentLength != -1) { output.write(clength); output.write(toHTTPBytes(Integer.toString(pContentLength))); output.write(doubleNewline); } else { output.write(newline); } pData.setSuccess(true); } /** Writes an error response to the output stream. * @param pData The request data. * @param pError The error being reported. * @param pStream The {@link ByteArrayOutputStream} with the error response. * @throws IOException Writing the response failed. */ public void writeError(RequestData pData, Throwable pError, ByteArrayOutputStream pStream) throws IOException { writeErrorHeader(pData, pError, pStream.size()); pStream.writeTo(output); output.flush(); } /** Writes an error responses headers to the output stream. * @param pData The request data. * @param pError The error being reported. * @param pContentLength The response length, if known, or -1. * @throws IOException Writing the response failed. */ public void writeErrorHeader(RequestData pData, Throwable pError, int pContentLength) throws IOException { if (pError instanceof BadRequestException) { final byte[] content = toHTTPBytes("Method " + pData.getMethod() + " not implemented (try POST)\r\n"); output.write(toHTTPBytes(pData.getHttpVersion())); output.write(toHTTPBytes(" 400 Bad Request")); output.write(newline); output.write(serverName); writeContentLengthHeader(content.length); output.write(newline); output.write(content); } else if (pError instanceof BadEncodingException) { final byte[] content = toHTTPBytes("The Transfer-Encoding " + pError.getMessage() + " is not implemented.\r\n"); output.write(toHTTPBytes(pData.getHttpVersion())); output.write(toHTTPBytes(" 501 Not Implemented")); output.write(newline); output.write(serverName); writeContentLengthHeader(content.length); output.write(newline); output.write(content); } else if (pError instanceof XmlRpcNotAuthorizedException) { final byte[] content = toHTTPBytes("Method " + pData.getMethod() + " requires a " + "valid user name and password.\r\n"); output.write(toHTTPBytes(pData.getHttpVersion())); output.write(toHTTPBytes(" 401 Unauthorized")); output.write(newline); output.write(serverName); writeContentLengthHeader(content.length); output.write(wwwAuthenticate); output.write(newline); output.write(content); } else { output.write(toHTTPBytes(pData.getHttpVersion())); output.write(ok); output.write(serverName); output.write(conclose); output.write(ctype); writeContentLengthHeader(pContentLength); output.write(newline); } } private void writeContentLengthHeader(int pContentLength) throws IOException { if (pContentLength == -1) { return; } output.write(clength); output.write(toHTTPBytes(Integer.toString(pContentLength))); output.write(newline); } /** Sets a response header value. */ public void setResponseHeader(String pHeader, String pValue) { headers.put(pHeader, pValue); } public OutputStream newOutputStream() throws IOException { boolean useContentLength; useContentLength = !requestData.isEnabledForExtensions() || !((XmlRpcHttpRequestConfig) requestData).isContentLengthOptional(); if (useContentLength) { return new ByteArrayOutputStream(); } else { return output; } } public InputStream newInputStream() throws IOException { int contentLength = requestData.getContentLength(); if (contentLength == -1) { return input; } else { return new LimitedInputStream(input, contentLength); } } public void close() throws IOException { } public void shutdown() throws Throwable { shuttingDown = true; socket.close(); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ConnectionServer.java100644 0 0 5034 11333307153 27573 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.ServerStreamConnection; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.server.XmlRpcHttpServer; class ConnectionServer extends XmlRpcHttpServer { protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Throwable pError) throws XmlRpcException { RequestData data = (RequestData) pConfig; try { if (data.isByteArrayRequired()) { super.writeError(pConfig, pStream, pError); data.getConnection().writeError(data, pError, (ByteArrayOutputStream) pStream); } else { data.getConnection().writeErrorHeader(data, pError, -1); super.writeError(pConfig, pStream, pError); pStream.flush(); } } catch (IOException e) { throw new XmlRpcException(e.getMessage(), e); } } protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException { RequestData data = (RequestData) pConfig; try { if (data.isByteArrayRequired()) { super.writeResponse(pConfig, pStream, pResult); data.getConnection().writeResponse(data, pStream); } else { data.getConnection().writeResponseHeader(data, -1); super.writeResponse(pConfig, pStream, pResult); pStream.flush(); } } catch (IOException e) { throw new XmlRpcException(e.getMessage(), e); } } protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) { ((Connection) pConnection).setResponseHeader(pHeader, pValue); } }././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/HttpServletRequestImpl.java100644 0 0 41315 11333307153 31006 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.lang.reflect.UndeclaredThrowableException; import java.net.Socket; import java.net.URLDecoder; import java.security.Principal; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.StringTokenizer; import javax.servlet.RequestDispatcher; import javax.servlet.ServletInputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.util.HttpUtil; /** Stub implementation of a {@link javax.servlet.http.HttpServletRequest} * with lots of unimplemented methods. I implemented only those, which * are required for testing the {@link org.apache.xmlrpc.webserver.XmlRpcServlet}. * Perhaps someone else is adding more at a later time? */ public class HttpServletRequestImpl implements HttpServletRequest { private final Socket socket; private final ServletInputStream istream; private ServletInputStream sistream; private BufferedReader reader; private boolean postParametersParsed; private String method; private String protocol; private String uri; private String queryString; private String httpVersion; private final Map headers = new HashMap(); private final Map attributes = new HashMap(); private Map parameters; private String characterEncoding; private int contentBytesRemaining = -1; /** Creates a new instance, which reads input from the given * socket. * @param pSocket The socket, to which the client is connected. * @throws IOException Accessing the sockets input stream failed. */ public HttpServletRequestImpl(Socket pSocket) throws IOException { socket = pSocket; final InputStream bis = new BufferedInputStream(socket.getInputStream()){ /** It may happen, that the XML parser invokes close(). * Closing the input stream must not occur, because * that would close the whole socket. So we suppress it. */ public void close() throws IOException { } }; istream = new ServletInputStream(){ public int read() throws IOException { if (contentBytesRemaining == 0) { return -1; } int c = bis.read(); if (c != -1 && contentBytesRemaining > 0) { --contentBytesRemaining; } return c; } }; } /** * Read the header lines, one by one. Note, that the size of * the buffer is a limitation of the maximum header length! */ public void readHttpHeaders() throws IOException, ServletWebServer.Exception { byte[] buffer = new byte[2048]; String line = readLine(buffer); StringTokenizer tokens = line != null ? new StringTokenizer(line) : null; if (tokens == null || !tokens.hasMoreTokens()) { throw new ServletWebServer.Exception(400, "Bad Request", "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was empty."); } method = tokens.nextToken(); if (!"POST".equalsIgnoreCase(method)) { throw new ServletWebServer.Exception(400, "Bad Request", "Expected 'POST' method, got " + method); } if (!tokens.hasMoreTokens()) { throw new ServletWebServer.Exception(400, "Bad Request", "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was: " + line); } String u = tokens.nextToken(); int offset = u.indexOf('?'); if (offset >= 0) { uri = u.substring(0, offset); queryString = u.substring(offset + 1); } else { uri = u; queryString = null; } if (tokens.hasMoreTokens()) { String v = tokens.nextToken().toUpperCase(); if (tokens.hasMoreTokens()) { throw new ServletWebServer.Exception(400, "Bad Request", "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was: " + line); } else { int index = v.indexOf('/'); if (index == -1) { throw new ServletWebServer.Exception(400, "Bad Request", "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was: " + line); } protocol = v.substring(0, index).toUpperCase(); httpVersion = v.substring(index + 1); } } else { httpVersion = "1.0"; protocol = "HTTP"; } for (;;) { line = HttpUtil.readLine(istream, buffer); if (line == null || line.length() == 0) { break; } int off = line.indexOf(':'); if (off > 0) { addHeader(line.substring(0, off), line.substring(off + 1).trim()); } else { throw new ServletWebServer.Exception(400, "Bad Request", "Unable to parse header line: " + line); } } contentBytesRemaining = getIntHeader("content-length"); } protected String readLine(byte[] pBuffer) throws IOException { int res = istream.readLine(pBuffer, 0, pBuffer.length); if (res == -1) { return null; } if (res == pBuffer.length && pBuffer[pBuffer.length] != '\n') { throw new ServletWebServer.Exception(400, "Bad Request", "Maximum header size of " + pBuffer.length + " characters exceeded."); } return new String(pBuffer, 0, res, "US-ASCII"); } protected void addHeader(String pHeader, String pValue) { String key = pHeader.toLowerCase(); addParameter(headers, key, pValue); } public String getAuthType() { String s = getHeader("Authorization"); if (s == null) { return null; } StringTokenizer st = new StringTokenizer(s); if (st.hasMoreTokens()) { return st.nextToken().toUpperCase(); } else { return null; } } public String getContextPath() { return ""; } public Cookie[] getCookies() { throw new IllegalStateException("Not implemented"); } public long getDateHeader(String arg0) { throw new IllegalStateException("Not implemented"); } public String getHeader(String pHeader) { String key = pHeader.toLowerCase(); Object o = headers.get(key); if (o instanceof List) { o = ((List) o).get(0); } return (String) o; } public Enumeration getHeaderNames() { return Collections.enumeration(headers.keySet()); } public Enumeration getHeaders(String pHeader) { String key = pHeader.toLowerCase(); Object o = headers.get(key); List list; if (o instanceof List) { list = (List) o; } else { list = Collections.singletonList(o); } return Collections.enumeration(list); } public int getIntHeader(String pHeader) { String s = getHeader(pHeader); return s == null ? -1 : Integer.parseInt(s); } public String getMethod() { return method; } public String getPathInfo() { return null; } public String getPathTranslated() { return null; } public String getQueryString() { return queryString; } public String getRemoteUser() { throw new IllegalStateException("Not implemented"); } public String getRequestURI() { return uri; } public StringBuffer getRequestURL() { String scheme = getScheme().toLowerCase(); StringBuffer sb = new StringBuffer(scheme); sb.append("://"); String host = getHeader("host"); if (host == null) { host = getLocalName(); if (host == null) { host = getLocalAddr(); } } int port = getLocalPort(); int offset = host.indexOf(':'); if (offset != -1) { host = host.substring(0, offset); try { port = Integer.parseInt(host.substring(offset+1)); } catch (Exception e) { } } boolean isDefaultPort; if ("http".equalsIgnoreCase(scheme)) { isDefaultPort = port == 80; } else if ("https".equalsIgnoreCase(scheme)) { isDefaultPort = port == 443; } else { isDefaultPort = false; } if (!isDefaultPort) { sb.append(':'); sb.append(port); } sb.append(getRequestURI()); return sb; } public String getRequestedSessionId() { throw new IllegalStateException("Not implemented"); } public String getServletPath() { return uri; } public HttpSession getSession() { throw new IllegalStateException("Not implemented"); } public HttpSession getSession(boolean pCreate) { throw new IllegalStateException("Not implemented"); } public Principal getUserPrincipal() { throw new IllegalStateException("Not implemented"); } public boolean isRequestedSessionIdFromCookie() { throw new IllegalStateException("Not implemented"); } public boolean isRequestedSessionIdFromURL() { throw new IllegalStateException("Not implemented"); } public boolean isRequestedSessionIdFromUrl() { throw new IllegalStateException("Not implemented"); } public boolean isRequestedSessionIdValid() { throw new IllegalStateException("Not implemented"); } public boolean isUserInRole(String pRole) { throw new IllegalStateException("Not implemented"); } public Object getAttribute(String pKey) { return attributes.get(pKey); } public Enumeration getAttributeNames() { return Collections.enumeration(attributes.keySet()); } public String getCharacterEncoding() { if (characterEncoding == null) { String contentType = getHeader("content-type"); if (contentType != null) { for (StringTokenizer st = new StringTokenizer(contentType, ";"); st.hasMoreTokens(); ) { String s = st.nextToken().trim(); if (s.toLowerCase().startsWith("charset=")) { return s.substring("charset=".length()).trim(); } } } return null; } else { return characterEncoding; } } public void setCharacterEncoding(String pEncoding) { characterEncoding = pEncoding; } public int getContentLength() { try { return getIntHeader("content-length"); } catch (NumberFormatException e) { return -1; } } public String getContentType() { return getHeader("content-type"); } public ServletInputStream getInputStream() throws IOException { if (reader == null) { if (sistream == null) { if (postParametersParsed) { throw new IllegalStateException("The method getInputStream() must not be called, after POST parameters have been parsed."); } sistream = istream; } return sistream; } else { throw new IllegalStateException("The method getReader() has already been invoked."); } } public Locale getLocale() { throw new IllegalStateException("Not implemented"); } public Enumeration getLocales() { throw new IllegalStateException("Not implemented"); } private void addParameter(Map pParams, String pKey, String pValue) { Object o = pParams.get(pKey); if (o == null) { pParams.put(pKey, pValue); } else { List list; if (o instanceof String) { list = new ArrayList(); list.add(o); pParams.put(pKey, list); } else { list = (List) o; } list.add(pParams); } } private void parseQueryString(Map pParams, String pQueryString, String pEncoding) throws UnsupportedEncodingException { for (StringTokenizer st = new StringTokenizer(pQueryString, "&"); st.hasMoreTokens(); ) { String s = st.nextToken(); parseParameter(pParams, s, pEncoding); } } private void parseParameter(Map pParams, String pParam, String pEncoding) throws UnsupportedEncodingException { if (pParam.length() == 0) { return; } int offset = pParam.indexOf('='); final String name, value; if (offset == -1) { name = pParam; value = ""; } else { name = pParam.substring(0, offset); value = pParam.substring(offset+1); } addParameter(pParams, URLDecoder.decode(name, pEncoding), URLDecoder.decode(value, pEncoding)); } private void parsePostData(Map pParams, InputStream pStream, String pEncoding) throws IOException { Reader r = new InputStreamReader(pStream, "US-ASCII"); StringBuffer sb = new StringBuffer(); for (;;) { int c = r.read(); if (c == -1 || c == '&') { parseParameter(pParams, sb.toString(), pEncoding); if (c == -1) { break; } else { sb.setLength(0); } } else { sb.append((char) c); } } } protected void parseParameters() { if (parameters != null) { return; } String encoding = getCharacterEncoding(); if (encoding == null) { encoding = XmlRpcStreamConfig.UTF8_ENCODING; } Map params = new HashMap(); String s = getQueryString(); if (s != null) { try { parseQueryString(params, s, encoding); } catch (IOException e) { throw new UndeclaredThrowableException(e); } } if ("POST".equals(getMethod()) && "application/x-www-form-urlencoded".equals(getContentType())) { if (sistream != null || reader != null) { throw new IllegalStateException("POST parameters cannot be parsed, after" + " getInputStream(), or getReader()," + " have been called."); } postParametersParsed = true; try { parsePostData(params, istream, encoding); } catch (IOException e) { throw new UndeclaredThrowableException(e); } } parameters = params; } public String getParameter(String pName) { parseParameters(); Object o = parameters.get(pName); if (o instanceof List) { o = ((List) o).get(0); } return (String) o; } public Map getParameterMap() { parseParameters(); final Map result = new HashMap(); for (final Iterator iter = parameters.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry entry = (Map.Entry) iter.next(); final String name = (String) entry.getKey(); final Object o = entry.getValue(); final String[] array; if (o instanceof String) { array = new String[]{(String) o}; } else if (o instanceof List) { final List list = (List) o; array = (String[]) list.toArray(new String[list.size()]); } else { throw new IllegalStateException("Invalid object: " + o.getClass().getName()); } result.put(name, array); } return Collections.unmodifiableMap(result); } public Enumeration getParameterNames() { parseParameters(); return Collections.enumeration(parameters.keySet()); } public String[] getParameterValues(String pName) { parseParameters(); Object o = parameters.get(pName); if (o instanceof String) { return new String[]{(String) o}; } else { List list = (List) o; return (String[]) list.toArray(new String[list.size()]); } } public String getProtocol() { return protocol; } public BufferedReader getReader() throws IOException { if (sistream == null) { if (reader == null) { if (postParametersParsed) { throw new IllegalStateException("The method getReader() must not be called, after POST parameters have been parsed."); } String encoding = getCharacterEncoding(); if (encoding == null) { encoding = "UTF8"; } reader = new BufferedReader(new InputStreamReader(istream, encoding)); } return reader; } else { throw new IllegalStateException("The methods getInputStream(), and getReader(), are mutually exclusive."); } } public String getRealPath(String pPath) { throw new IllegalStateException("Not implemented."); } public String getLocalAddr() { return socket.getLocalAddress().getHostAddress(); } public String getLocalName() { return socket.getLocalAddress().getHostName(); } public int getLocalPort() { return socket.getLocalPort(); } public String getRemoteAddr() { return socket.getInetAddress().getHostAddress(); } public String getRemoteHost() { return socket.getInetAddress().getHostName(); } public int getRemotePort() { return socket.getPort(); } public RequestDispatcher getRequestDispatcher(String pUri) { throw new IllegalStateException("Not implemented"); } public String getScheme() { return "http"; } public String getServerName() { return socket.getLocalAddress().getHostName(); } public int getServerPort() { return socket.getLocalPort(); } public boolean isSecure() { return false; } public void removeAttribute(String pKey) { attributes.remove(pKey); } public void setAttribute(String pKey, Object pValue) { attributes.put(pKey, pValue); } protected String getHttpVersion() { return httpVersion; } } ././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/HttpServletResponseImpl.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/HttpServletResponseImpl.jav100644 0 0 36141 11333307153 31014 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.StringTokenizer; import javax.servlet.ServletOutputStream; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; /** Stub implementation of a {@link javax.servlet.http.HttpServletResponse} * with lots of unimplemented methods. I implemented only those, which * are required for testing the {@link org.apache.xmlrpc.webserver.XmlRpcServlet}. * Perhaps someone else is adding more at a later time? */ public class HttpServletResponseImpl implements HttpServletResponse { static final int BUFFER_SIZE = 8192; private final Socket socket; private final OutputStream ostream; private final Map headers = new HashMap(); private int status = HttpServletResponse.SC_OK; private String message = getStatusMessage(status); private Locale locale; private String charEncoding; private PrintWriter writer; private ServletOutputStreamImpl soStream; /** Creates a new instance. * @param pSocket The clients socket. * @throws IOException Accessing the sockets output stream failed. */ public HttpServletResponseImpl(Socket pSocket) throws IOException { socket = pSocket; ostream = socket.getOutputStream(); } public void addCookie(Cookie pCookie) { throw new IllegalStateException("Not implemented"); } public void addDateHeader(String pHeader, long pDate) { throw new IllegalStateException("Not implemented"); } public void addHeader(String pHeader, String pValue) { String key = pHeader.toLowerCase(); Object o = headers.get(key); if (o == null) { headers.put(key, pValue); } else { List list; if (o instanceof String) { list = new ArrayList(); headers.put(key, list); list.add(o); } else { list = (List) o; } list.add(pValue); } } private String getHeader(String pHeader) { String key = pHeader.toLowerCase(); Object o = headers.get(key); if (o == null) { return null; } else if (o instanceof String) { return (String) o; } else { List list = (List) o; if (list.size() == 0) { return null; } else { return (String) list.get(0); } } } public void addIntHeader(String pHeader, int pValue) { addHeader(pHeader, Integer.toString(pValue)); } public boolean containsHeader(String pHeader) { return headers.containsKey(pHeader.toLowerCase()); } public String encodeRedirectURL(String pURL) { throw new IllegalStateException("Not implemented"); } public String encodeRedirectUrl(String pURL) { return encodeRedirectURL(pURL); } public String encodeURL(String pURL) { throw new IllegalStateException("Not implemented"); } public String encodeUrl(String pURL) { return encodeUrl(pURL); } public void sendError(int pStatusCode) throws IOException { sendError(pStatusCode, getStatusMessage(pStatusCode)); } public void sendError(int pStatusCode, String pMessage) throws IOException { sendError(pStatusCode, pMessage, null); } protected void sendError(int pStatusCode, String pMessage, String pDescription) throws IOException { if (isCommitted()) { throw new IllegalStateException("Can't send an error message, if the response has already been committed."); } headers.clear(); setContentType("text/html"); setStatus(pStatusCode, pMessage); if (soStream == null) { soStream = new ServletOutputStreamImpl(ostream, this); } else { soStream.reset(); } OutputStreamWriter osw = new OutputStreamWriter(soStream, getCharacterEncoding()); osw.write("" + pStatusCode + " " + pMessage + "\r\n"); osw.write("

" + pStatusCode + " " + pMessage + "

\r\n"); if (pDescription != null) { osw.write("

" + pDescription + "

\r\n"); } osw.write("\r\n"); osw.close(); } public void sendRedirect(String arg0) throws IOException { throw new IllegalStateException("Not implemented"); } public void setDateHeader(String arg0, long arg1) { throw new IllegalStateException("Not implemented"); } public void setHeader(String pHeader, String pValue) { headers.remove(pHeader.toLowerCase()); addHeader(pHeader, pValue); } public void setIntHeader(String pHeader, int pValue) { setHeader(pHeader, Integer.toString(pValue)); } public void setStatus(int pStatusCode) { setStatus(pStatusCode, getStatusMessage(pStatusCode)); } public void setStatus(int pStatusCode, String pMessage) { status = pStatusCode; message = pMessage; } public void flushBuffer() throws IOException { ostream.flush(); } public int getBufferSize() { return BUFFER_SIZE; } /**

Sets the character encoding (MIME charset) of the response being sent * to the client, for example, to UTF-8. If the character encoding has * already been set by setContentType(java.lang.String) or * setLocale(java.util.Locale), this method overrides it. * Calling setContentType(java.lang.String) with the String * of text/html and calling this method with the String of UTF-8 * is equivalent with calling setContentType with the String of * text/html; charset=UTF-8.

*

This method can be called repeatedly to change the character * encoding. This method has no effect if it is called after getWriter * has been called or after the response has been committed.

*

Containers must communicate the character encoding used for * the servlet response's writer to the client if the protocol * provides a way for doing so. In the case of HTTP, the character * encoding is communicated as part of the Content-Type header for * text media types. Note that the character encoding cannot be * communicated via HTTP headers if the servlet does not specify * a content type; however, it is still used to encode text written * via the servlet response's writer.

* @param pCharset A String specifying only the character set defined * by IANA Character Sets (http://www.iana.org/assignments/character-sets) * @since Servlet API 2.4 * @see #setLocale(Locale) */ public void setCharacterEncoding(String pCharset) { charEncoding = pCharset; } public String getCharacterEncoding() { if (charEncoding == null) { return "ISO-8859-1"; } else { return charEncoding; } } public Locale getLocale() { return locale; } public ServletOutputStream getOutputStream() throws IOException { if (writer != null) { throw new IllegalStateException("You may call either getWriter() or getOutputStream(), but not both."); } else { if (soStream == null) { soStream = new ServletOutputStreamImpl(ostream, this); } return soStream; } } public PrintWriter getWriter() throws IOException { if (writer != null) { return writer; } else if (soStream != null) { throw new IllegalStateException("You may call either getWriter() or getOutputStream(), but not both."); } else { writer = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding())); return writer; } } public boolean isCommitted() { return soStream != null && soStream.isCommitted(); } public void reset() { resetBuffer(); setStatus(HttpServletResponse.SC_OK); headers.clear(); charEncoding = null; locale = null; } public void resetBuffer() { if (isCommitted()) { throw new IllegalStateException("The ServletOutputStream is already committed. A reset is no longer possible."); } if (soStream != null) { soStream.reset(); } } public void setBufferSize(int pBufferSize) { throw new IllegalStateException("Not implemented"); } public void setContentLength(int pContentLength) { if (pContentLength == -1) { headers.remove("content-length"); } else { setIntHeader("content-length", pContentLength); } } /**

Returns the content type used for the MIME body sent in this * response. The content type proper must have been specified * using setContentType(java.lang.String) before the response is * committed. If no content type has been specified, this method * returns null. If a content type has been specified and a * character encoding has been explicitly or implicitly specified * as described in getCharacterEncoding(), the charset parameter * is included in the string returned. If no character encoding * has been specified, the charset parameter is omitted.

* @return A String specifying the content type, for example, * text/html; charset=UTF-8, or null * @since Servlet API 2.4 * @see #setContentType(String) */ public String getContentType() { String s = getHeader("content-type"); if (s != null && s.toLowerCase().startsWith("text/")) { String enc = getCharacterEncoding(); if (enc != null) { s += "; charset=" + enc; } } return s; } public void setContentType(String pType) { if (pType != null) { boolean charSetFound = false; StringBuffer sb = new StringBuffer(); for (StringTokenizer st = new StringTokenizer(pType, ";"); st.hasMoreTokens(); ) { String t = st.nextToken(); if (t.toLowerCase().startsWith("charset=")) { charSetFound = true; setCharacterEncoding(t.substring("charset=".length()).trim()); } else { if (sb.length() > 0) { sb.append("; "); } sb.append(t); } } if (charSetFound) { pType = sb.toString(); } } setHeader("content-type", pType); } public void setLocale(Locale pLocale) { locale = pLocale; } /** Returns a default message for a given HTTP status code. * @param pStatusCode The status code being queried. * @return The default message. */ public static String getStatusMessage(int pStatusCode) { switch (pStatusCode) { case HttpServletResponse.SC_OK: return ("OK"); case HttpServletResponse.SC_ACCEPTED: return ("Accepted"); case HttpServletResponse.SC_BAD_GATEWAY: return ("Bad Gateway"); case HttpServletResponse.SC_BAD_REQUEST: return ("Bad Request"); case HttpServletResponse.SC_CONFLICT: return ("Conflict"); case HttpServletResponse.SC_CONTINUE: return ("Continue"); case HttpServletResponse.SC_CREATED: return ("Created"); case HttpServletResponse.SC_EXPECTATION_FAILED: return ("Expectation Failed"); case HttpServletResponse.SC_FORBIDDEN: return ("Forbidden"); case HttpServletResponse.SC_GATEWAY_TIMEOUT: return ("Gateway Timeout"); case HttpServletResponse.SC_GONE: return ("Gone"); case HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED: return ("HTTP Version Not Supported"); case HttpServletResponse.SC_INTERNAL_SERVER_ERROR: return ("Internal Server Error"); case HttpServletResponse.SC_LENGTH_REQUIRED: return ("Length Required"); case HttpServletResponse.SC_METHOD_NOT_ALLOWED: return ("Method Not Allowed"); case HttpServletResponse.SC_MOVED_PERMANENTLY: return ("Moved Permanently"); case HttpServletResponse.SC_MOVED_TEMPORARILY: return ("Moved Temporarily"); case HttpServletResponse.SC_MULTIPLE_CHOICES: return ("Multiple Choices"); case HttpServletResponse.SC_NO_CONTENT: return ("No Content"); case HttpServletResponse.SC_NON_AUTHORITATIVE_INFORMATION: return ("Non-Authoritative Information"); case HttpServletResponse.SC_NOT_ACCEPTABLE: return ("Not Acceptable"); case HttpServletResponse.SC_NOT_FOUND: return ("Not Found"); case HttpServletResponse.SC_NOT_IMPLEMENTED: return ("Not Implemented"); case HttpServletResponse.SC_NOT_MODIFIED: return ("Not Modified"); case HttpServletResponse.SC_PARTIAL_CONTENT: return ("Partial Content"); case HttpServletResponse.SC_PAYMENT_REQUIRED: return ("Payment Required"); case HttpServletResponse.SC_PRECONDITION_FAILED: return ("Precondition Failed"); case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED: return ("Proxy Authentication Required"); case HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE: return ("Request Entity Too Large"); case HttpServletResponse.SC_REQUEST_TIMEOUT: return ("Request Timeout"); case HttpServletResponse.SC_REQUEST_URI_TOO_LONG: return ("Request URI Too Long"); case HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE: return ("Requested Range Not Satisfiable"); case HttpServletResponse.SC_RESET_CONTENT: return ("Reset Content"); case HttpServletResponse.SC_SEE_OTHER: return ("See Other"); case HttpServletResponse.SC_SERVICE_UNAVAILABLE: return ("Service Unavailable"); case HttpServletResponse.SC_SWITCHING_PROTOCOLS: return ("Switching Protocols"); case HttpServletResponse.SC_UNAUTHORIZED: return ("Unauthorized"); case HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE: return ("Unsupported Media Type"); case HttpServletResponse.SC_USE_PROXY: return ("Use Proxy"); case 207: // WebDAV return ("Multi-Status"); case 422: // WebDAV return ("Unprocessable Entity"); case 423: // WebDAV return ("Locked"); case 507: // WebDAV return ("Insufficient Storage"); default: return ("HTTP Response Status " + pStatusCode); } } String getHttpHeaders(Integer pContentLength) { StringBuffer sb = new StringBuffer(); sb.append("HTTP/1.0 "); sb.append(status); sb.append(' '); sb.append(message); sb.append("\r\n"); String contentType = getContentType(); if (contentType != null) { sb.append("Content-Type: "); sb.append(contentType); sb.append("\r\n"); } boolean contentLengthSeen = false; for (Iterator iter = headers.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String header = (String) entry.getKey(); if ("content-type".equalsIgnoreCase(header)) { continue; } Object o = entry.getValue(); if (o == null) { continue; } if ("content-length".equalsIgnoreCase(header)) { contentLengthSeen = true; } if (o instanceof String) { sb.append(header); sb.append(": "); sb.append(o); sb.append("\r\n"); } else { List list = (List) o; for (int i = 0; i < list.size(); i++) { sb.append(header); sb.append(": "); sb.append(list.get(i)); sb.append("\r\n"); } } } if (pContentLength != null && !contentLengthSeen) { sb.append("Content-Length: "); sb.append(pContentLength); sb.append("\r\n"); } sb.append("\r\n"); return sb.toString(); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/RequestData.java100644 0 0 7135 11333307153 26533 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; /** Web servers extension of * {@link org.apache.xmlrpc.common.XmlRpcHttpRequestConfig}, * which allows to store additional per request data. */ public class RequestData extends XmlRpcHttpRequestConfigImpl { private final Connection connection; private boolean keepAlive; private String method, httpVersion; private int contentLength = -1; private boolean success; /** Creates a new instance. * @param pConnection The connection, which is serving the request. */ public RequestData(Connection pConnection) { connection = pConnection; } /** Returns the connection, which is serving the request. * @return The request connection. */ public Connection getConnection() { return connection; } /** Returns, whether HTTP keepAlive is enabled for this * connection. * @return True, if keepAlive is enabled, false otherwise. */ public boolean isKeepAlive() { return keepAlive; } /** Sets, whether HTTP keepAlive is enabled for this * connection. * @param pKeepAlive True, if keepAlive is enabled, false otherwise. */ public void setKeepAlive(boolean pKeepAlive) { keepAlive = pKeepAlive; } /** Returns the requests HTTP version. * @return HTTP version, for example "1.0" */ public String getHttpVersion() { return httpVersion; } /** Sets the requests HTTP version. * @param pHttpVersion HTTP version, for example "1.0" */ public void setHttpVersion(String pHttpVersion) { httpVersion = pHttpVersion; } /** Returns the requests content length. * @return Content length, if known, or -1, if unknown. */ public int getContentLength() { return contentLength; } /** Sets the requests content length. * @param pContentLength Content length, if known, or -1, if unknown. */ public void setContentLength(int pContentLength) { contentLength = pContentLength; } /** Returns, whether a byte array for buffering the output is * required. * @return True, if the byte array is required, false otherwise. */ public boolean isByteArrayRequired() { return isKeepAlive() || !isEnabledForExtensions() || !isContentLengthOptional(); } /** Returns the request method. * @return The request method, should be "POST". */ public String getMethod() { return method; } /** Sets the request method. * @param pMethod The request method, should be "POST". */ public void setMethod(String pMethod) { method = pMethod; } /** Returns, whether the request was executed successfull. * @return True for success, false, if an error occurred. */ public boolean isSuccess() { return success; } /** Sets, whether the request was executed successfull. * @param pSuccess True for success, false, if an error occurred. */ public void setSuccess(boolean pSuccess) { success = pSuccess; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ServletConnection.java100644 0 0 4257 11333307153 27757 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.net.Socket; import javax.servlet.http.HttpServlet; import org.apache.xmlrpc.util.ThreadPool.InterruptableTask; /** {@link org.apache.xmlrpc.webserver.ServletWebServer ServletWebServer's} * {@link org.apache.xmlrpc.util.ThreadPool.Task} for handling a single * servlet connection. */ public class ServletConnection implements InterruptableTask { private final HttpServlet servlet; private final Socket socket; private final HttpServletRequestImpl request; private final HttpServletResponseImpl response; private boolean shuttingDown; /** Creates a new instance. * @param pServlet The servlet, which ought to handle the request. * @param pSocket The socket, to which the client is connected. * @throws IOException */ public ServletConnection(HttpServlet pServlet, Socket pSocket) throws IOException { servlet = pServlet; socket = pSocket; request = new HttpServletRequestImpl(socket); response = new HttpServletResponseImpl(socket); } public void run() throws Throwable { try { request.readHttpHeaders(); servlet.service(request, response); } catch (Throwable t) { if (!shuttingDown) { throw t; } } } public void shutdown() throws Throwable { shuttingDown = true; socket.close(); } } ././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ServletOutputStreamImpl.javaapache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ServletOutputStreamImpl.jav100644 0 0 5403 11333307153 31007 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.io.OutputStream; import javax.servlet.ServletOutputStream; /** Default implementation of a servlet output stream. * Handles output of HTTP headers. */ class ServletOutputStreamImpl extends ServletOutputStream { private final OutputStream target; private final HttpServletResponseImpl res; private final byte[] buffer = new byte[HttpServletResponseImpl.BUFFER_SIZE]; private int bufferOffset; private boolean closed; private boolean committed; ServletOutputStreamImpl(OutputStream pTarget, HttpServletResponseImpl pResponse) { target = pTarget; res = pResponse; } public void write(int b) throws IOException { if (closed) { throw new IOException("This output stream is already closed."); } if (bufferOffset == buffer.length) { flush(); } buffer[bufferOffset++] = (byte) b; } public void write(byte[] pChars, int pOffset, int pLen) throws IOException { if (closed) { throw new IOException("This output stream is already closed."); } while (pLen-- > 0) { if (bufferOffset == buffer.length) { flush(); } buffer[bufferOffset++] = pChars[pOffset++]; } } private void flush(boolean pClosing) throws IOException { if (!committed) { committed = true; String headers = res.getHttpHeaders(pClosing ? new Integer(bufferOffset) : null); target.write(headers.getBytes("US-ASCII")); } if (bufferOffset > 0) { target.write(buffer, 0, bufferOffset); bufferOffset = 0; } } public void close() throws IOException { if (!closed) { flush(true); closed = true; target.close(); } } public void flush() throws IOException { if (closed) { throw new IOException("This output stream is already closed."); } flush(false); target.flush(); } void reset() { if (committed) { throw new IllegalStateException("The response is already committed. A reset cannot be performed."); } } boolean isCommitted() { return committed; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/ServletWebServer.java100644 0 0 12355 11333307153 27602 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.util.Enumeration; import java.util.NoSuchElementException; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcStreamServer; import org.apache.xmlrpc.util.ThreadPool; /** *

This is a subclass of the {@link WebServer}, which offers a minimal * servlet API. It is recommended to use this class, rather than the * {@link WebServer}, because it offers you a smooth migration path to * a full blown servlet engine.

*

Use of the {@link ServletWebServer} goes like this: First of all, * create a servlet. It may be an instance of {@link XmlRpcServlet} or * a subclass thereof. Note, that servlets are stateless: One servlet * may be used by multiple threads (aka requests) concurrently. In * other words, the servlet must not have any instance variables, * other than those which are read only after the servlets * initialization.

*

The XmlRpcServlet is by default using a property file named * org/apache/xmlrpc/server/webserver/XmlRpcServlet.properties. * See the {@link PropertyHandlerMapping} for details on the property * file.

*
 *   final int port = 8088;
 *
 *   XmlRpcServlet servlet = new XmlRpcServlet();
 *   ServletWebServer webServer = new ServletWebServer(servlet, port);
 *   webServer.start();
 * 
*/ public class ServletWebServer extends WebServer { /** This exception is thrown by the request handling classes, * advising the server, that it should return an error response. */ public static class Exception extends IOException { private static final long serialVersionUID = 49879832748972394L; private final int statusCode; private final String description; /** Creates a new instance. * @param pStatusCode The HTTP status code being sent to the client. * @param pMessage The HTTP status message being sent to the client. * @param pDescription The error description being sent to the client * in the response body. */ public Exception(int pStatusCode, String pMessage, String pDescription) { super(pMessage); statusCode = pStatusCode; description = pDescription; } public String getMessage() { return statusCode + " " + super.getMessage(); } /** Returns the error description. The server will send the description * as plain text in the response body. * @return The error description. */ public String getDescription() { return description; } /** Returns the HTTP status code. * @return The status code. */ public int getStatusCode() { return statusCode; } } private final HttpServlet servlet; /** Creates a new instance, which is listening on all * local IP addresses and the given port. * @param pServlet The servlet, which is handling requests. * @param pPort The servers port number; 0 for a random * port being choosen. * @throws ServletException Initializing the servlet failed. */ public ServletWebServer(HttpServlet pServlet, int pPort) throws ServletException { this(pServlet, pPort, null); } /** Creates a new instance, which is listening on the * given IP address and the given port. * @param pServlet The servlet, which is handling requests. * @param pPort The servers port number; 0 for a random * port being choosen. * @param pAddr The servers IP address. * @throws ServletException Initializing the servlet failed. */ public ServletWebServer(HttpServlet pServlet, int pPort, InetAddress pAddr) throws ServletException { super(pPort, pAddr); servlet = pServlet; servlet.init(new ServletConfig(){ public String getServletName() { return servlet.getClass().getName(); } public ServletContext getServletContext() { throw new IllegalStateException("Context not available"); } public String getInitParameter(String pArg0) { return null; } public Enumeration getInitParameterNames() { return new Enumeration(){ public boolean hasMoreElements() { return false; } public Object nextElement() { throw new NoSuchElementException(); } }; } }); } protected ThreadPool.Task newTask(WebServer pWebServer, XmlRpcStreamServer pXmlRpcServer, Socket pSocket) throws IOException { return new ServletConnection(servlet, pSocket); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/WebServer.java100644 0 0 31131 11333307153 26226 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.io.InterruptedIOException; import java.net.BindException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.apache.xmlrpc.server.XmlRpcStreamServer; import org.apache.xmlrpc.util.ThreadPool; /** *

The {@link WebServer} is a minimal HTTP server, that might be used * as an embedded web server.

*

Use of the {@link WebServer} has grown very popular amongst users * of Apache XML-RPC. Why this is the case, can hardly be explained, * because the {@link WebServer} is at best a workaround, compared to * full blown servlet engines like Tomcat or Jetty. For example, under * heavy load it will almost definitely be slower than a real servlet * engine, because it does neither support proper keepalive (multiple * requests per physical connection) nor chunked mode (in other words, * it cannot stream requests).

*

If you still insist in using the {@link WebServer}, it is * recommended to use its subclass, the {@link ServletWebServer} instead, * which offers a minimal subset of the servlet API. In other words, * you keep yourself the option to migrate to a real servlet engine * later.

*

Use of the {@link WebServer} goes roughly like this: First of all, * create a property file (for example "MyHandlers.properties") and * add it to your jar file. The property keys are handler names and * the property values are the handler classes. Once that is done, * create an instance of WebServer: *

 *   final int port = 8088;
 *   final String propertyFile = "MyHandler.properties";
 *
 *   PropertyHandlerMapping mapping = new PropertyHandlerMapping();
 *   ClassLoader cl = Thread.currentThread().getContextClassLoader();
 *   mapping.load(cl, propertyFile);
 *   WebServer webServer = new WebServer(port);
 *   XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl();
 *   XmlRpcServer server = webServer.getXmlRpcServer();
 *   server.setConfig(config);
 *   server.setHandlerMapping(mapping);
 *   webServer.start();
 * 
*/ public class WebServer implements Runnable { private class AddressMatcher { private final int pattern[]; AddressMatcher(String pAddress) { try { pattern = new int[4]; StringTokenizer st = new StringTokenizer(pAddress, "."); if (st.countTokens() != 4) { throw new IllegalArgumentException(); } for (int i = 0; i < 4; i++) { String next = st.nextToken(); if ("*".equals(next)) { pattern[i] = 256; } else { /* Note: *Not* pattern[i] = Integer.parseInt(next); * See XMLRPC-145 */ pattern[i] = (byte) Integer.parseInt(next); } } } catch (Exception e) { throw new IllegalArgumentException("\"" + pAddress + "\" does not represent a valid IP address"); } } boolean matches(byte[] pAddress) { for (int i = 0; i < 4; i++) { if (pattern[i] > 255) { continue; // Wildcard } if (pattern[i] != pAddress[i]) { return false; } } return true; } } protected ServerSocket serverSocket; private Thread listener; private ThreadPool pool; protected final List accept = new ArrayList(); protected final List deny = new ArrayList(); protected final XmlRpcStreamServer server = newXmlRpcStreamServer(); protected XmlRpcStreamServer newXmlRpcStreamServer(){ return new ConnectionServer(); } // Inputs to setupServerSocket() private InetAddress address; private int port; private boolean paranoid; static final String HTTP_11 = "HTTP/1.1"; /** Creates a web server at the specified port number. * @param pPort Port number; 0 for a random port, choosen by the * operating system. */ public WebServer(int pPort) { this(pPort, null); } /** Creates a web server at the specified port number and IP address. * @param pPort Port number; 0 for a random port, choosen by the * operating system. * @param pAddr Local IP address; null for all available IP addresses. */ public WebServer(int pPort, InetAddress pAddr) { address = pAddr; port = pPort; } /** * Factory method to manufacture the server socket. Useful as a * hook method for subclasses to override when they desire * different flavor of socket (i.e. a SSLServerSocket). * * @param pPort Port number; 0 for a random port, choosen by the operating * system. * @param backlog * @param addr If null, binds to * INADDR_ANY, meaning that all network interfaces on * a multi-homed host will be listening. * @exception IOException Error creating listener socket. */ protected ServerSocket createServerSocket(int pPort, int backlog, InetAddress addr) throws IOException { return new ServerSocket(pPort, backlog, addr); } /** * Initializes this server's listener socket with the specified * attributes, assuring that a socket timeout has been set. The * {@link #createServerSocket(int, int, InetAddress)} method can * be overridden to change the flavor of socket used. * * @see #createServerSocket(int, int, InetAddress) */ private synchronized void setupServerSocket(int backlog) throws IOException { // Since we can't reliably set SO_REUSEADDR until JDK 1.4 is // the standard, try to (re-)open the server socket several // times. Some OSes (Linux and Solaris, for example), hold on // to listener sockets for a brief period of time for security // reasons before relinquishing their hold. for (int i = 1; ; i++) { try { serverSocket = createServerSocket(port, backlog, address); // A socket timeout must be set. if (serverSocket.getSoTimeout() <= 0) { serverSocket.setSoTimeout(4096); } return; } catch (BindException e) { if (i == 10) { throw e; } else { long waitUntil = System.currentTimeMillis() + 1000; for (;;) { long l = waitUntil - System.currentTimeMillis(); if (l > 0) { try { Thread.sleep(l); } catch (InterruptedException ex) { } } else { break; } } } } } } /** * Spawns a new thread which binds this server to the port it's * configured to accept connections on. * * @see #run() * @throws IOException Binding the server socket failed. */ public void start() throws IOException { setupServerSocket(50); // The listener reference is released upon shutdown(). if (listener == null) { listener = new Thread(this, "XML-RPC Weblistener"); // Not marked as daemon thread since run directly via main(). listener.start(); } } /** * Switch client filtering on/off. * @param pParanoid True to enable filtering, false otherwise. * @see #acceptClient(java.lang.String) * @see #denyClient(java.lang.String) */ public void setParanoid(boolean pParanoid) { paranoid = pParanoid; } /** * Returns the client filtering state. * @return True, if client filtering is enabled, false otherwise. * @see #acceptClient(java.lang.String) * @see #denyClient(java.lang.String) */ protected boolean isParanoid() { return paranoid; } /** Add an IP address to the list of accepted clients. The parameter can * contain '*' as wildcard character, e.g. "192.168.*.*". You must call * setParanoid(true) in order for this to have any effect. * @param pAddress The IP address being enabled. * @see #denyClient(java.lang.String) * @see #setParanoid(boolean) * @throws IllegalArgumentException Parsing the address failed. */ public void acceptClient(String pAddress) { accept.add(new AddressMatcher(pAddress)); } /** * Add an IP address to the list of denied clients. The parameter can * contain '*' as wildcard character, e.g. "192.168.*.*". You must call * setParanoid(true) in order for this to have any effect. * @param pAddress The IP address being disabled. * @see #acceptClient(java.lang.String) * @see #setParanoid(boolean) * @throws IllegalArgumentException Parsing the address failed. */ public void denyClient(String pAddress) { deny.add(new AddressMatcher(pAddress)); } /** * Checks incoming connections to see if they should be allowed. * If not in paranoid mode, always returns true. * * @param s The socket to inspect. * @return Whether the connection should be allowed. */ protected boolean allowConnection(Socket s) { if (!paranoid) { return true; } int l = deny.size(); byte addr[] = s.getInetAddress().getAddress(); for (int i = 0; i < l; i++) { AddressMatcher match = (AddressMatcher) deny.get(i); if (match.matches(addr)) { return false; } } l = accept.size(); for (int i = 0; i < l; i++) { AddressMatcher match = (AddressMatcher) accept.get(i); if (match.matches(addr)) { return true; } } return false; } protected ThreadPool.Task newTask(WebServer pServer, XmlRpcStreamServer pXmlRpcServer, Socket pSocket) throws IOException { return new Connection(pServer, pXmlRpcServer, pSocket); } /** * Listens for client requests until stopped. Call {@link * #start()} to invoke this method, and {@link #shutdown()} to * break out of it. * * @throws RuntimeException Generally caused by either an * UnknownHostException or BindException * with the vanilla web server. * * @see #start() * @see #shutdown() */ public void run() { pool = newThreadPool(); try { while (listener != null) { try { Socket socket = serverSocket.accept(); try { socket.setTcpNoDelay(true); } catch (SocketException socketOptEx) { log(socketOptEx); } try { if (allowConnection(socket)) { // set read timeout to 30 seconds socket.setSoTimeout(30000); final ThreadPool.Task task = newTask(this, server, socket); if (pool.startTask(task)) { socket = null; } else { log("Maximum load of " + pool.getMaxThreads() + " exceeded, rejecting client"); } } } finally { if (socket != null) { try { socket.close(); } catch (Throwable ignore) {} } } } catch (InterruptedIOException checkState) { // Timeout while waiting for a client (from // SO_TIMEOUT)...try again if still listening. } catch (Throwable t) { log(t); } } } finally { if (serverSocket != null) { try { serverSocket.close(); } catch (IOException e) { log(e); } } // Shutdown our Runner-based threads pool.shutdown(); } } protected ThreadPool newThreadPool() { return new ThreadPool(server.getMaxThreads(), "XML-RPC"); } /** * Stop listening on the server port. Shutting down our {@link * #listener} effectively breaks it out of its {@link #run()} * loop. * * @see #run() */ public synchronized void shutdown() { // Stop accepting client connections if (listener != null) { Thread l = listener; listener = null; l.interrupt(); if (pool != null) { pool.shutdown(); } } } /** Returns the port, on which the web server is running. * This method may be invoked after {@link #start()} only. * @return Servers port number */ public int getPort() { return serverSocket.getLocalPort(); } /** Logs an error. * @param pError The error being logged. */ public void log(Throwable pError) { final String msg = pError.getMessage() == null ? pError.getClass().getName() : pError.getMessage(); server.getErrorLogger().log(msg, pError); } /** Logs a message. * @param pMessage The being logged. */ public void log(String pMessage) { server.getErrorLogger().log(pMessage); } /** Returns the {@link org.apache.xmlrpc.server.XmlRpcServer}. * @return The server object. */ public XmlRpcStreamServer getXmlRpcServer() { return server; } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/XmlRpcServlet.java100644 0 0 20053 11333307153 27075 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.Enumeration; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlrpc.XmlRpcConfig; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.RequestProcessorFactoryFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.util.ReflectionUtil; /**

A default servlet implementation The typical use would * be to derive a subclass, which is overwriting at least the * method {@link #newXmlRpcHandlerMapping()}.

*

The servlet accepts the following init parameters: * * * *
NameDescription
enabledForExtensionsSets the value * {@link XmlRpcConfig#isEnabledForExtensions()} * to true.
*

*/ public class XmlRpcServlet extends HttpServlet { private static final long serialVersionUID = 2348768267234L; private static final Log log = LogFactory.getLog(XmlRpcServlet.class); private XmlRpcServletServer server; private AbstractReflectiveHandlerMapping.AuthenticationHandler authenticationHandler; private RequestProcessorFactoryFactory requestProcessorFactoryFactory; private TypeConverterFactory typeConverterFactory; /** Returns the servlets instance of {@link XmlRpcServletServer}. * @return The configurable instance of {@link XmlRpcServletServer}. */ public XmlRpcServletServer getXmlRpcServletServer() { return server; } private void handleInitParameters(ServletConfig pConfig) throws ServletException { for (Enumeration en = pConfig.getInitParameterNames(); en.hasMoreElements(); ) { String name = (String) en.nextElement(); String value = pConfig.getInitParameter(name); try { if (!ReflectionUtil.setProperty(this, name, value) && !ReflectionUtil.setProperty(server, name, value) && !ReflectionUtil.setProperty(server.getConfig(), name, value)) { throw new ServletException("Unknown init parameter " + name); } } catch (IllegalAccessException e) { throw new ServletException("Illegal access to instance of " + server.getClass().getName() + " while setting property " + name + ": " + e.getMessage(), e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw new ServletException("Failed to invoke setter for property " + name + " on instance of " + server.getClass().getName() + ": " + t.getMessage(), t); } } } public void init(ServletConfig pConfig) throws ServletException { super.init(pConfig); try { server = newXmlRpcServer(pConfig); handleInitParameters(pConfig); server.setHandlerMapping(newXmlRpcHandlerMapping()); } catch (XmlRpcException e) { try { log("Failed to create XmlRpcServer: " + e.getMessage(), e); } catch (Throwable ignore) { } throw new ServletException(e); } } /** Sets the servlets {@link AbstractReflectiveHandlerMapping.AuthenticationHandler}. */ public void setAuthenticationHandler(AbstractReflectiveHandlerMapping.AuthenticationHandler pHandler) { authenticationHandler = pHandler; } /** Returns the servlets {@link AbstractReflectiveHandlerMapping.AuthenticationHandler}. */ public AbstractReflectiveHandlerMapping.AuthenticationHandler getAuthenticationHandler() { return authenticationHandler; } /** Sets the servlets {@link RequestProcessorFactoryFactory}. */ public void setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory) { requestProcessorFactoryFactory = pFactory; } /** Returns the servlets {@link RequestProcessorFactoryFactory}. */ public RequestProcessorFactoryFactory getRequestProcessorFactoryFactory() { return requestProcessorFactoryFactory; } /** Sets the servlets {@link TypeConverterFactory}. */ public void setTypeConverterFactory(TypeConverterFactory pFactory) { typeConverterFactory = pFactory; } /** Returns the servlets {@link TypeConverterFactory}. */ public TypeConverterFactory getTypeConverterFactory() { return typeConverterFactory; } /** Creates a new instance of {@link XmlRpcServer}, * which is being used to process the requests. The default implementation * will simply invoke new {@link XmlRpcServer}. * @param pConfig The servlets configuration. * @throws XmlRpcException */ protected XmlRpcServletServer newXmlRpcServer(ServletConfig pConfig) throws XmlRpcException { return new XmlRpcServletServer(); } /** Creates a new handler mapping. The default implementation loads * a property file from the resource * org/apache/xmlrpc/webserver/XmlRpcServlet.properties */ protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { URL url = XmlRpcServlet.class.getResource("XmlRpcServlet.properties"); if (url == null) { throw new XmlRpcException("Failed to locate resource XmlRpcServlet.properties"); } try { return newPropertyHandlerMapping(url); } catch (IOException e) { throw new XmlRpcException("Failed to load resource " + url + ": " + e.getMessage(), e); } } /** Creates a new instance of {@link PropertyHandlerMapping} by * loading the property file from the given URL. Called from * {@link #newXmlRpcHandlerMapping()}. */ protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.setAuthenticationHandler(authenticationHandler); if (requestProcessorFactoryFactory != null) { mapping.setRequestProcessorFactoryFactory(requestProcessorFactoryFactory); } if (typeConverterFactory != null) { mapping.setTypeConverterFactory(typeConverterFactory); } else { mapping.setTypeConverterFactory(server.getTypeConverterFactory()); } mapping.setVoidMethodEnabled(server.getConfig().isEnabledForExtensions()); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; } /** Creates a new instance of {@link org.apache.xmlrpc.webserver.RequestData} * for the request. */ public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException, ServletException { server.execute(pRequest, pResponse); } public void log(String pMessage, Throwable pThrowable) { server.getErrorLogger().log(pMessage, pThrowable); } public void log(String pMessage) { log.info(pMessage); } } apache-xmlrpc-3.1.3-src/server/src/main/java/org/apache/xmlrpc/webserver/XmlRpcServletServer.java100644 0 0 12717 11333307153 30274 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.webserver; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.common.ServerStreamConnection; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.server.XmlRpcHttpServer; import org.apache.xmlrpc.server.XmlRpcHttpServerConfig; import org.apache.xmlrpc.util.HttpUtil; /** An extension of {@link org.apache.xmlrpc.server.XmlRpcServer}, * which is suitable for processing servlet requests. */ public class XmlRpcServletServer extends XmlRpcHttpServer { protected static class ServletStreamConnection implements ServerStreamConnection { private final HttpServletRequest request; private final HttpServletResponse response; protected ServletStreamConnection(HttpServletRequest pRequest, HttpServletResponse pResponse) { request = pRequest; response = pResponse; } /** Returns the servlet request. */ public HttpServletRequest getRequest() { return request; } /** Returns the servlet response. */ public HttpServletResponse getResponse() { return response; } public InputStream newInputStream() throws IOException { return request.getInputStream(); } public OutputStream newOutputStream() throws IOException { response.setContentType("text/xml"); return response.getOutputStream(); } public void close() throws IOException { response.getOutputStream().close(); } } /** * @param pRequest The request object. */ protected XmlRpcHttpRequestConfigImpl newConfig(HttpServletRequest pRequest) { return new XmlRpcHttpRequestConfigImpl(); } protected XmlRpcHttpRequestConfigImpl getConfig(HttpServletRequest pRequest) { XmlRpcHttpRequestConfigImpl result = newConfig(pRequest); XmlRpcHttpServerConfig serverConfig = (XmlRpcHttpServerConfig) getConfig(); result.setBasicEncoding(serverConfig.getBasicEncoding()); result.setContentLengthOptional(serverConfig.isContentLengthOptional() && (pRequest.getHeader("Content-Length") == null)); result.setEnabledForExtensions(serverConfig.isEnabledForExtensions()); result.setGzipCompressing(HttpUtil.isUsingGzipEncoding(pRequest.getHeader("Content-Encoding"))); result.setGzipRequesting(HttpUtil.isUsingGzipEncoding(pRequest.getHeaders("Accept-Encoding"))); result.setEncoding(pRequest.getCharacterEncoding()); result.setEnabledForExceptions(serverConfig.isEnabledForExceptions()); HttpUtil.parseAuthorization(result, pRequest.getHeader("Authorization")); return result; } protected ServletStreamConnection newStreamConnection(HttpServletRequest pRequest, HttpServletResponse pResponse) { return new ServletStreamConnection(pRequest, pResponse); } /** Processes the servlet request. * @param pRequest The servlet request being read. * @param pResponse The servlet response being created. * @throws IOException Reading the request or writing the response failed. * @throws ServletException Processing the request failed. */ public void execute(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException, IOException { XmlRpcHttpRequestConfigImpl config = getConfig(pRequest); ServletStreamConnection ssc = newStreamConnection(pRequest, pResponse); try { super.execute(config, ssc); } catch (XmlRpcException e) { throw new ServletException(e); } } /** Returns, whether the requests content length is required. */ protected boolean isContentLengthRequired(XmlRpcStreamRequestConfig pConfig) { if (!pConfig.isEnabledForExtensions()) { // The spec requires a content-length. return true; } boolean isRequired = !((XmlRpcHttpServerConfig) getConfig()).isContentLengthOptional(); if(pConfig instanceof XmlRpcHttpRequestConfig) { isRequired |= !((XmlRpcHttpRequestConfig)pConfig).isContentLengthOptional(); } return isRequired; } protected OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection, int pSize) throws IOException { if (pSize != -1) { ((ServletStreamConnection) pConnection).getResponse().setContentLength(pSize); } return super.getOutputStream(pConfig, pConnection, pSize); } protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) { ((ServletStreamConnection) pConnection).getResponse().setHeader(pHeader, pValue); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/AuthenticationTest.java100644 0 0 10250 11333307147 27151 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.XmlRpcRequestConfig; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.util.ClientFactory; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler; /** * Test case for supported authentication variants. */ public class AuthenticationTest extends XmlRpcTestCase { private static final String PASSWORD = "98765432109876543210987654321098765432109876543210"; private static final String USER_NAME = "01234567890123456789012345678901234567890123456789" + "\u00C4\u00D6\u00DC\u00F6\u00FC\u00E4\u00DF"; /** An interface, which is being implemented by the * server. */ public interface Adder { /** Returns the sum of the given integers. */ public int add(int pNum1, int pNum2); } /** Implementation of {@link DynamicProxyTest.Adder}, which is used by * the server. */ public static class AdderImpl implements Adder { public int add(int pNum1, int pNum2) { return pNum1 + pNum2; } } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { XmlRpcHandlerMapping mapping = getHandlerMapping("AuthenticationTest.properties"); ((AbstractReflectiveHandlerMapping) mapping).setAuthenticationHandler(new AuthenticationHandler(){ public boolean isAuthorized(XmlRpcRequest pRequest) throws XmlRpcException { XmlRpcRequestConfig config = pRequest.getConfig(); if (config instanceof XmlRpcHttpRequestConfig) { XmlRpcHttpRequestConfig httpRequestConfig = (XmlRpcHttpRequestConfig) config; return USER_NAME.equals(httpRequestConfig.getBasicUserName()) && PASSWORD.equals(httpRequestConfig.getBasicPassword()); } return true; } }); return mapping; } protected XmlRpcClientConfigImpl getConfig(ClientProvider pProvider) throws Exception { XmlRpcClientConfigImpl config = super.getConfig(pProvider); config.setBasicUserName(USER_NAME); config.setBasicPassword(PASSWORD); return config; } private ClientFactory getClientFactory(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); return new ClientFactory(client); } /** Tests calling the {@link Adder#add(int,int)} method * by using an object, which has been created by the * {@link ClientFactory}. */ public void testAdderCall() throws Exception { for (int i = 0; i < providers.length; i++) { testAdderCall(providers[i]); } } private void testAdderCall(ClientProvider pProvider) throws Exception { ClientFactory factory = getClientFactory(pProvider); Adder adder = (Adder) factory.newInstance(Adder.class); assertEquals(6, adder.add(2, 4)); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/BaseTest.java100644 0 0 76660 11333307147 25065 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.io.Serializable; import java.io.StringReader; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.TimeZone; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.common.XmlRpcExtensionException; import org.apache.xmlrpc.common.XmlRpcInvocationException; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.InputSource; /** An abstract test case, to be implemented for the various * transport classes. */ public class BaseTest extends XmlRpcTestCase { /** The remote class being invoked by the test case. */ public static class Remote { /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public int byteParam(byte pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public byte byteResult(byte pArg) { return (byte) (pArg*2); } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public int shortParam(short pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public short shortResult(short pArg) { return (short) (pArg*2); } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public int intParam(int pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public int longParam(long pArg) { return (int) (pArg*2); } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public long longResult(long pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public double floatParam(float pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public float floatResult(float pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public double doubleParam(double pArg) { return pArg*2; } /** Returns the argument, multiplied by two. * @param pArg The argument being doubled. * @return The argument, multiplied by two. */ public double doubleResult(double pArg) { return pArg*2; } /** Returns the argument, concatenated with itself. * @param pArg The argument being concatenated. * @return The argument, concatenated with itself. */ public String stringParam(String pArg) { return pArg+pArg; } /** * Throws a NullPointerException. */ public Object throwNPE() { throw new NullPointerException(); } /** Returns the argument, concatenated with itself. * @param pArg The argument being concatenated. * @return The argument, concatenated with itself. */ public String nullableStringParam(String pArg) { if (pArg == null) { pArg = ""; } return pArg+pArg; } /** Returns the argument, concatenated with itself. * @param pArg The argument being concatenated. * @return The argument, concatenated with itself. */ public String nullableStringResult(String pArg) { if (pArg == null) { return null; } return pArg+pArg; } /** Returns the sum of the bytes in the given byte array. * @param pArg The array of bytes being added. * @return Sum over the bytes in the array. */ public int byteArrayParam(byte[] pArg) { int sum = 0; for (int i = 0; i < pArg.length; i++) { sum += pArg[i]; } return sum; } /** Returns an array with the bytes 0..pArg. * @param pArg Requestes byte array length. * @return Byte array with 0..pArg. */ public byte[] byteArrayResult(int pArg) { byte[] result = new byte[pArg]; for (int i = 0; i < result.length; i++) { result[i] = (byte) i; } return result; } /** Returns the sum over the objects in the array. * @param pArg Object array being added * @return Sum over the objects in the array */ public int objectArrayParam(Object[] pArg) { int sum = 0; for (int i = 0; i < pArg.length; i++) { if (pArg[i] instanceof Number) { sum += ((Number) pArg[i]).intValue(); } else { sum += Integer.parseInt((String) pArg[i]); } } return sum; } /** Returns an array of integers with the values * 0..pArg. * @param pArg Requested array length. * @return Array of integers with the values 0..pArg */ public Object[] objectArrayResult(int pArg) { Object[] result = new Object[pArg]; for (int i = 0; i < result.length; i++) { result[i] = new Integer(i); } return result; } /** Returns a sum over the entries in the map. Each * key is multiplied with its value. * @param pArg The map being iterated. * @return Sum of keys, multiplied by their values. */ public int mapParam(Map pArg) { int sum = 0; for (Iterator iter = pArg.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); Integer value = (Integer) entry.getValue(); sum += Integer.parseInt(key) * value.intValue(); } return sum; } /** Returns a map with the stringified values 0..pArg as * keys and the corresponding integers as values. * @param pArg Requested map size. * @return Map with the keys "0".."pArg" and * 0..pArg as values. */ public Map mapResult(int pArg) { Map result = new HashMap(); for (int i = 0; i < pArg; i++) { result.put(Integer.toString(i), new Integer(i)); } return result; } /** Returns the sum of all "int" nodes in pNode. * @param pNode The node being counted. * @return The sum of the values of all "int" nodes. */ public int nodeParam(Node pNode) { if (pNode.getNodeType() != Node.DOCUMENT_NODE) { throw new IllegalStateException("Expected document node, got " + pNode); } Element e = ((Document) pNode).getDocumentElement(); if (!ROOT_TAG.equals(e.getLocalName()) || !INT_URI.equals(e.getNamespaceURI())) { throw new IllegalStateException("Expected root element 'root', got " + new QName(e.getNamespaceURI(), e.getLocalName())); } return count(pNode); } private int count(Node pNode) { if (INT_TAG.equals(pNode.getLocalName()) && INT_URI.equals(pNode.getNamespaceURI())) { StringBuffer sb = new StringBuffer(); for (Node child = pNode.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.TEXT_NODE || child.getNodeType() == Node.CDATA_SECTION_NODE) { sb.append(child.getNodeValue()); } } return Integer.parseInt(sb.toString()); } else { int result = 0; for (Node child = pNode.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.ELEMENT_NODE) { result += count(child); } } return result; } } /** Example of a Serializable instance. */ public static class CalendarWrapper implements Serializable { private static final long serialVersionUID = 8153663910532549627L; final Calendar cal; CalendarWrapper(Calendar pCalendar) { cal = pCalendar; } } /** Returns the calendar value in milliseconds. * @param pCal Calendar object * @return pCal.getTime().getTime(). */ public long serializableParam(CalendarWrapper pCal) { return pCal.cal.getTime().getTime(); } /** Returns midnight of the following day. */ public Calendar calendarParam(Calendar pCal) { Calendar cal = (Calendar) pCal.clone(); cal.add(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; } /** Returns midnight of the following day. */ public Date dateParam(Date pDate) { Calendar cal = Calendar.getInstance(); cal.setTime(pDate); return calendarParam(cal).getTime(); } } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { return getHandlerMapping("BaseTest.properties"); } /** Test, whether we can invoke a method, passing a byte value. * @throws Exception The test failed. */ public void testByteParam() throws Exception { for (int i = 0; i < providers.length; i++) { testByteParam(providers[i]); } } private void testByteParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.byteParam"; final Object[] params = new Object[]{new Byte((byte) 3)}; XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(6), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, returning a byte. * @throws Exception The test failed. */ public void testByteResult() throws Exception { for (int i = 0; i < providers.length; i++) { testByteResult(providers[i]); } } private void testByteResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.byteResult"; final Object[] params = new Object[]{new Byte((byte) 3)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Byte((byte) 6), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing a short value. * @throws Exception The test failed. */ public void testShortParam() throws Exception { for (int i = 0; i < providers.length; i++) { testShortParam(providers[i]); } } private void testShortParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.shortParam"; final Object[] params = new Object[]{new Short((short) 4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(8), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, returning a short value. * @throws Exception The test failed. */ public void testShortResult() throws Exception { for (int i = 0; i < providers.length; i++) { testShortResult(providers[i]); } } private void testShortResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.shortResult"; final Object[] params = new Object[]{new Short((short) 4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Short((short) 8), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing an * integer value. * @throws Exception The test failed. */ public void testIntParam() throws Exception { for (int i = 0; i < providers.length; i++) { testIntParam(providers[i]); } } private void testIntParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.intParam"; final Object[] params = new Object[]{new Integer(5)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals(new Integer(10), result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(10), result); } /** Test, whether we can invoke a method, passing a long value. * @throws Exception The test failed. */ public void testLongParam() throws Exception { for (int i = 0; i < providers.length; i++) { testLongParam(providers[i]); } } private void testLongParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.longParam"; final Object[] params = new Object[]{new Long(6L)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(12), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, returning a long value. * @throws Exception The test failed. */ public void testLongResult() throws Exception { for (int i = 0; i < providers.length; i++) { testLongResult(providers[i]); } } private void testLongResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.longResult"; final Object[] params = new Object[]{new Long(6L)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Long(12L), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing a * string value. * @throws Exception The test failed. */ public void testStringParam() throws Exception { for (int i = 0; i < providers.length; i++) { testStringParam(providers[i]); } } private void testStringParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.stringParam"; final Object[] params = new Object[]{"abc"}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals("abcabc", result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals("abcabc", result); } /** Test, whether we can invoke a method, passing a * string value or null. * @throws Exception The test failed. */ public void testNullableStringParam() throws Exception { for (int i = 0; i < providers.length; i++) { testNullableStringParam(providers[i]); } } private void testNullableStringParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.nullableStringParam"; final Object[] params = new Object[]{"abc"}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals("abcabc", result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals("abcabc", result); final Object[] nullParams = new Object[]{null}; result = client.execute(getExConfig(pProvider), methodName, nullParams); assertEquals("", result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, nullParams); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, returning a * string value or null. * @throws Exception The test failed. */ public void testNullableStringResult() throws Exception { for (int i = 0; i < providers.length; i++) { testNullableStringResult(providers[i]); } } private void testNullableStringResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.nullableStringResult"; final Object[] params = new Object[]{"abc"}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals("abcabc", result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals("abcabc", result); final Object[] nullParams = new Object[]{null}; result = client.execute(getExConfig(pProvider), methodName, nullParams); assertEquals(null, result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, nullParams); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing a float value. * @throws Exception The test failed. */ public void testFloatParam() throws Exception { for (int i = 0; i < providers.length; i++) { testFloatParam(providers[i]); } } private void testFloatParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.floatParam"; final Object[] params = new Object[]{new Float(0.4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(8, Math.round(((Double) result).doubleValue()*10)); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, returning a float value. * @throws Exception The test failed. */ public void testFloatResult() throws Exception { for (int i = 0; i < providers.length; i++) { testFloatResult(providers[i]); } } private void testFloatResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.floatResult"; final Object[] params = new Object[]{new Float(0.4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Float(0.8), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing a * double value. * @throws Exception The test failed. */ public void testDoubleParam() throws Exception { for (int i = 0; i < providers.length; i++) { testDoubleParam(providers[i]); } } private void testDoubleParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.doubleParam"; final Object[] params = new Object[]{new Double(0.6)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals(new Double(1.2), result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Double(1.2), result); } /** Test, whether we can invoke a method, returning a * double value. * @throws Exception The test failed. */ public void testDoubleResult() throws Exception { for (int i = 0; i < providers.length; i++) { testDoubleResult(providers[i]); } } private void testDoubleResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.doubleResult"; final Object[] params = new Object[]{new Double(0.6)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals(new Double(1.2), result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Double(1.2), result); } /** Test, whether we can invoke a method, passing a * byte array. * @throws Exception The test failed. */ public void testByteArrayParam() throws Exception { for (int i = 0; i < providers.length; i++) { testByteArrayParam(providers[i]); } } private void testByteArrayParam(ClientProvider pProvider) throws Exception { final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; final String methodName = "Remote.byteArrayParam"; final Object[] params = new Object[]{bytes}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals(new Integer(0+1+2+3+4+5+6+7+8+9), result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(0+1+2+3+4+5+6+7+8+9), result); } /** Test, whether we can invoke a method, returning a * byte array. * @throws Exception The test failed. */ public void testByteArrayResult() throws Exception { for (int i = 0; i < providers.length; i++) { testByteArrayResult(providers[i]); } } private void testByteArrayResult(ClientProvider pProvider) throws Exception { final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; final String methodName = "Remote.byteArrayResult"; final Object[] params = new Object[]{new Integer(8)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertTrue(Arrays.equals(bytes, (byte[]) result)); result = client.execute(getExConfig(pProvider), methodName, params); assertTrue(Arrays.equals(bytes, (byte[]) result)); } /** Test, whether we can invoke a method, passing an * object array. * @throws Exception The test failed. */ public void testObjectArrayParam() throws Exception { for (int i = 0; i < providers.length; i++) { testObjectArrayParam(providers[i]); } } private void testObjectArrayParam(ClientProvider pProvider) throws Exception { final Object[] objects = new Object[]{new Byte((byte) 1), new Short((short) 2), new Integer(3), new Long(4), "5"}; final String methodName = "Remote.objectArrayParam"; final Object[] params = new Object[]{objects}; final XmlRpcClient client = pProvider.getClient(); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(15), result); } /** Test, whether we can invoke a method, returning an * object array. * @throws Exception The test failed. */ public void testObjectArrayResult() throws Exception { for (int i = 0; i < providers.length; i++) { testObjectArrayResult(providers[i]); } } private void testObjectArrayResult(ClientProvider pProvider) throws Exception { final Object[] objects = new Object[]{new Integer(0), new Integer(1), new Integer(2), new Integer(3)}; final String methodName = "Remote.objectArrayResult"; final Object[] params = new Object[]{new Integer(4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertTrue(Arrays.equals(objects, (Object[]) result)); result = client.execute(getExConfig(pProvider), methodName, params); assertTrue(Arrays.equals(objects, (Object[]) result)); } /** Test, whether we can invoke a method, passing a map. * @throws Exception The test failed. */ public void testMapParam() throws Exception { for (int i = 0; i < providers.length; i++) { testMapParam(providers[i]); } } private void testMapParam(ClientProvider pProvider) throws Exception { final Map map = new HashMap(); map.put("2", new Integer(3)); map.put("3", new Integer(5)); final String methodName = "Remote.mapParam"; final Object[] params = new Object[]{map}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); assertEquals(new Integer(21), result); result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(21), result); } private void checkMap(Map pResult) { assertEquals(4, pResult.size()); assertEquals(new Integer(0), pResult.get("0")); assertEquals(new Integer(1), pResult.get("1")); assertEquals(new Integer(2), pResult.get("2")); assertEquals(new Integer(3), pResult.get("3")); } /** Test, whether we can invoke a method, returning a map. * @throws Exception The test failed. */ public void testMapResult() throws Exception { for (int i = 0; i < providers.length; i++) { testMapResult(providers[i]); } } private void testMapResult(ClientProvider pProvider) throws Exception { final String methodName = "Remote.mapResult"; final Object[] params = new Object[]{new Integer(4)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getConfig(pProvider), methodName, params); checkMap((Map) result); result = client.execute(getExConfig(pProvider), methodName, params); checkMap((Map) result); } /** Test, whether we can invoke a method, passing a DOM * node as parameter. * @throws Exception The test failed. */ public void testNodeParam() throws Exception { for (int i = 0; i < providers.length; i++) { testNodeParam(providers[i]); } } private static final String ROOT_TAG = "root"; private static final String INT_TAG = "int"; private static final String INT_URI = "http://ws.apache.org/xmlrpc/namespaces/testNodeParam"; private void testNodeParam(ClientProvider pProvider) throws Exception { final String xml = "<" + ROOT_TAG + " xmlns='" + INT_URI +"'>" + " <" + INT_TAG + ">1" + " <" + INT_TAG + ">2" + " <" + INT_TAG + ">3" + " <" + INT_TAG + ">4" + " <" + INT_TAG + ">5" + ""; final String methodName = "Remote.nodeParam"; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(xml))); final Object[] params = new Object[]{doc}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Integer(1+2+3+4+5), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Test, whether we can invoke a method, passing an instance of * {@link java.io.Serializable} as a parameter. * @throws Exception The test failed. */ public void testSerializableParam() throws Exception { for (int i = 0; i < providers.length; i++) { testSerializableParam(providers[i]); } } private void testSerializableParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.serializableParam"; Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(2005, 5, 23, 8, 4, 0); cal.set(Calendar.MILLISECOND, 5); final Object[] params = new Object[]{new Remote.CalendarWrapper(cal)}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(new Long(cal.getTime().getTime()), result); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } /** Tests, whether we can invoke a method, passing an instance of * {@link Calendar} as a parameter. * @throws Exception The test failed. */ public void testCalendarParam() throws Exception { for (int i = 0; i < providers.length; i++) { testCalendarParam(providers[i]); } } private void testCalendarParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.calendarParam"; Calendar cal1 = newCalendarParam(); Calendar cal2 = newCalendarResult(); final Object[] params = new Object[]{cal1}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(cal2.getTime(), ((Calendar) result).getTime()); boolean ok = false; try { client.execute(getConfig(pProvider), methodName, params); } catch (XmlRpcExtensionException e) { ok = true; } assertTrue(ok); } private Calendar newCalendarResult() { Calendar cal2 = Calendar.getInstance(TimeZone.getDefault()); cal2.set(2005, 5, 24, 0, 0, 0); cal2.set(Calendar.MILLISECOND, 0); return cal2; } private Calendar newCalendarParam() { Calendar cal1 = Calendar.getInstance(TimeZone.getDefault()); cal1.set(2005, 5, 23, 8, 4, 0); cal1.set(Calendar.MILLISECOND, 5); return cal1; } /** Tests, whether we can invoke a method, passing an instance of * {@link Date} as a parameter. * @throws Exception The test failed. */ public void testDateParam() throws Exception { for (int i = 0; i < providers.length; i++) { testDateParam(providers[i]); } } private void testDateParam(ClientProvider pProvider) throws Exception { final String methodName = "Remote.dateParam"; Date date1 = newCalendarParam().getTime(); Calendar cal2 = newCalendarResult(); final Object[] params = new Object[]{date1}; final XmlRpcClient client = pProvider.getClient(); Object result = client.execute(getExConfig(pProvider), methodName, params); assertEquals(cal2.getTime(), result); result = client.execute(getConfig(pProvider), methodName, params); assertEquals(cal2.getTime(), result); } /** * Tests, whether a NullPointerException, thrown by the server, can be * trapped by the client. */ public void testCatchNPE() throws Exception { for (int i = 0; i < providers.length; i++) { testCatchNPE(providers[i]); } } private void testCatchNPE(ClientProvider pProvider) throws Exception { final XmlRpcClient client = pProvider.getClient(); final String methodName = "Remote.throwNPE"; try { client.execute(getExConfig(pProvider), methodName, (Object[]) null); } catch (XmlRpcInvocationException e) { if (!(e.getCause() instanceof NullPointerException)) { throw e; } } } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ClientIpTest.java100644 0 0 11753 11333307147 25712 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcNoSuchHandlerException; import org.apache.xmlrpc.webserver.XmlRpcServlet; /** * Test case for reading the clients IP address. */ public class ClientIpTest extends XmlRpcTestCase { /** * An object, which provides additional information * about the client to the user. */ public static class ClientInfo { private final String ipAddress; /** * Creates a new instance. */ public ClientInfo(String pIpAddress) { ipAddress = pIpAddress; } /** * Returns the clients IP address. */ public String getIpAddress() { return ipAddress; } } /** * An extension of the {@link XmlRpcServlet}, which * ensures the availability of a {@link ClientIpTest.ClientInfo} * object. */ public static class ClientInfoServlet extends XmlRpcServlet { private static final long serialVersionUID = 8210342625908021538L; private static ThreadLocal clientInfo = new ThreadLocal(); /** * Returns the current threads. client info object. */ public static ClientInfo getClientInfo() { return (ClientInfo) clientInfo.get(); } public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException, ServletException { clientInfo.set(new ClientInfo(pRequest.getRemoteAddr())); super.doPost(pRequest, pResponse); } } private static class ClientIpTestProvider extends ServletWebServerProvider { ClientIpTestProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) throws ServletException, IOException { super(pMapping, pContentLength); } protected XmlRpcServlet newXmlRpcServlet() { return new ClientInfoServlet(); } } protected ClientProvider[] initProviders(XmlRpcHandlerMapping pMapping) throws ServletException, IOException { return new ClientProvider[]{ new ClientIpTestProvider(pMapping, false), new ClientIpTestProvider(pMapping, true) }; } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { final XmlRpcHandler handler = new XmlRpcHandler(){ public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { final ClientInfo clientInfo = ClientInfoServlet.getClientInfo(); if (clientInfo == null) { return ""; } final String ip = clientInfo.getIpAddress(); if (ip == null) { return ""; } return ip; } }; return new XmlRpcHandlerMapping(){ public XmlRpcHandler getHandler(String pHandlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException { return handler; } }; } private void testClientIpAddress(ClientProvider pProvider) throws Exception { final XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); final String ip = (String) client.execute("getIpAddress", new Object[]{}); assertEquals("127.0.0.1", ip); } /** Test, whether we can invoke a method, returning a byte. * @throws Exception The test failed. */ public void testClientIpAddress() throws Exception { for (int i = 0; i < providers.length; i++) { testClientIpAddress(providers[i]); } } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ClientProvider.java100644 0 0 3363 11333307147 26252 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.server.XmlRpcServer; /** This interface allows to perform a unit test with various * transports. Basically, the implementation creates the client, * including the transport, and the server, if required. */ public interface ClientProvider { /** Returns the clients default configuration. * @return The clients configuration. * @throws Exception Creating the configuration failed. */ XmlRpcClientConfigImpl getConfig() throws Exception; /** Returns a new client instance. * @return A client being used for performing the test. */ XmlRpcClient getClient(); /** Returns the providers server instance. * @return A server instance, which is being used for performing the test. */ XmlRpcServer getServer(); /** Performs a shutdown of the server. */ void shutdown(); } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ClientProviderImpl.java100644 0 0 3774 11333307147 27102 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; /** Abstract base implementation of {@link org.apache.xmlrpc.test.ClientProvider}. */ public abstract class ClientProviderImpl implements ClientProvider { protected final XmlRpcHandlerMapping mapping; protected abstract XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient); /** Creates a new instance. * @param pMapping The test servers handler mapping. */ protected ClientProviderImpl(XmlRpcHandlerMapping pMapping) { mapping = pMapping; } protected XmlRpcServer getXmlRpcServer() throws Exception { XmlRpcServer server = new XmlRpcServer(); server.setHandlerMapping(mapping); return server; } public XmlRpcClientConfigImpl getConfig() throws Exception { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); return config; } public XmlRpcClient getClient() { XmlRpcClient client = new XmlRpcClient(); client.setTransportFactory(getTransportFactory(client)); return client; } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/CommonsProvider.java100644 0 0 2766 11333307147 26455 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; /** Provider for testing the * {@link org.apache.xmlrpc.client.XmlRpcCommonsTransport}. */ public class CommonsProvider extends WebServerProvider { /** Creates a new instance. * @param pMapping The test servers handler mapping. */ public CommonsProvider(XmlRpcHandlerMapping pMapping) { super(pMapping, true); } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { return new XmlRpcCommonsTransportFactory(pClient); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/CustomTypesTest.java100644 0 0 12156 11333307147 26500 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.text.DateFormat; import java.text.Format; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import org.apache.ws.commons.util.NamespaceContextImpl; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcClientRequestImpl; import org.apache.xmlrpc.common.TypeFactory; import org.apache.xmlrpc.common.TypeFactoryImpl; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.parser.DateParser; import org.apache.xmlrpc.parser.TypeParser; import org.apache.xmlrpc.serializer.DateSerializer; import org.apache.xmlrpc.serializer.TypeSerializer; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.xml.sax.SAXException; /** * Test suite for working with custom types. */ public class CustomTypesTest extends XmlRpcTestCase { /** * Sample date converter */ public static class DateConverter { /** * Adds one day to the given date. */ public Date tomorrow(Date pDate) { Calendar cal = Calendar.getInstance(); cal.setTime(pDate); cal.add(Calendar.DAY_OF_MONTH, 1); return cal.getTime(); } } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.addHandler("DateConverter", DateConverter.class); return mapping; } /** Tests using a custom date format. */ public void testCustomDateFormat() throws Exception { for (int i = 0; i < providers.length; i++) { testCustomDateFormat(providers[i]); } } private TypeFactory getCustomDateTypeFactory(XmlRpcController pController, final Format pFormat) { return new TypeFactoryImpl(pController){ private TypeSerializer dateSerializer = new DateSerializer(pFormat); public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) { if (DateSerializer.DATE_TAG.equals(pLocalName)) { return new DateParser(pFormat); } else { return super.getParser(pConfig, pContext, pURI, pLocalName); } } public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException { if (pObject instanceof Date) { return dateSerializer; } else { return super.getSerializer(pConfig, pObject); } } }; } private void testCustomDateFormat(ClientProvider pProvider) throws Exception { final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); XmlRpcClient client = pProvider.getClient(); XmlRpcClientConfigImpl config = getConfig(pProvider); client.setConfig(config); TypeFactory typeFactory = getCustomDateTypeFactory(client, format); client.setTypeFactory(typeFactory); Calendar cal1 = Calendar.getInstance(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "DateConverter.tomorrow", new Object[]{cal1.getTime()}); final String got = XmlRpcTestCase.writeRequest(client, request); final String expect = "" + "DateConverter.tomorrow" + "" + format.format(cal1.getTime()) + ""; assertEquals(expect, got); XmlRpcServer server = pProvider.getServer(); server.setTypeFactory(getCustomDateTypeFactory(server, format)); Date date = (Date) client.execute(request); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date); cal1.add(Calendar.DAY_OF_MONTH, 1); assertEquals(cal1, cal2); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/DynamicProxyTest.java100644 0 0 10506 11333307147 26624 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.util.ClientFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.xml.sax.SAXException; /** Test case for the {@link ClientFactory}. */ public class DynamicProxyTest extends XmlRpcTestCase { /** An interface, which is being implemented by the * server. */ public interface Adder { /** Returns the sum of the given integers. */ public int add(int pNum1, int pNum2); /** * Throws a SAXException. */ public Object parse(String pMessage) throws SAXException; /** * A void method; these are disabled without support for * extensions, but enabled when extensions are on. */ public void ping(); } /** Implementation of {@link DynamicProxyTest.Adder}, which is used by * the server. */ public static class AdderImpl implements Adder { public int add(int pNum1, int pNum2) { return pNum1 + pNum2; } public Object parse(String pMessage) throws SAXException { throw new SAXException("Failed to parse message: " + pMessage); } public void ping() { } } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { return getHandlerMapping("DynamicProxyTest.properties"); } private ClientFactory getClientFactory(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); return new ClientFactory(client); } private ClientFactory getExClientFactory(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getExConfig(pProvider)); return new ClientFactory(client); } /** Tests calling the {@link Adder#add(int,int)} method * by using an object, which has been created by the * {@link ClientFactory}. */ public void testAdderCall() throws Exception { for (int i = 0; i < providers.length; i++) { testAdderCall(providers[i]); } } private void testAdderCall(ClientProvider pProvider) throws Exception { ClientFactory factory = getClientFactory(pProvider); Adder adder = (Adder) factory.newInstance(Adder.class); assertEquals(6, adder.add(2, 4)); } /** Tests trapping a SAXException. */ public void testParseCall() throws Exception { for (int i = 0; i < providers.length; i++) { testParseCall(providers[i]); } } private void testParseCall(ClientProvider pProvider) throws Exception { ClientFactory factory = getExClientFactory(pProvider); Adder adder = (Adder) factory.newInstance(Adder.class); try { adder.parse("foo"); fail("Expected SAXException"); } catch (SAXException e) { // Ok } } /** * Tests invoking a "void" method. */ public void testVoidMethod() throws Exception { for (int i = 0; i < providers.length; i++) { testVoidMethod(providers[i]); } } private void testVoidMethod(ClientProvider pProvider) throws Exception { ClientFactory factory = getExClientFactory(pProvider); Adder adder = (Adder) factory.newInstance(Adder.class); adder.ping(); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/JiraTest.java100644 0 0 35573 11333307147 25076 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.lang.reflect.UndeclaredThrowableException; import java.net.HttpURLConnection; import java.net.URL; import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Vector; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.TimingOutCallback; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; import org.apache.xmlrpc.client.util.ClientFactory; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.parser.XmlRpcResponseParser; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.util.SAXParsers; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; /** * Test case for various jira issues. */ public class JiraTest extends XmlRpcTestCase { /** Interface of the handler for {@link JiraTest#testXMLRPC89()} */ public interface XMLRPC89Handler { /** * Returns the reversed vector. */ Vector reverse(Vector pVector); /** * Returns the same hashtable, but doubles the * values. */ Hashtable doubledValues(Hashtable pMap); /** * Returns the same properties, but doubles the * values. */ Properties doubledPropertyValues(Properties pMap); } /** * Handler for {@link JiraTest#testXMLRPC89()} */ public static class XMLRPC89HandlerImpl implements XMLRPC89Handler { public Vector reverse(Vector pVector) { Vector result = new Vector(pVector.size()); result.addAll(pVector); Collections.reverse(result); return result; } public Hashtable doubledValues(Hashtable pMap) { final Hashtable result; if (pMap instanceof Properties) { result = new Properties(); } else { result = new Hashtable(); } result.putAll(pMap); for (Iterator iter = result.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); Object value = entry.getValue(); final Integer i; if (pMap instanceof Properties) { i = Integer.valueOf((String) value); } else { i = (Integer) value; } Integer iDoubled = new Integer(i.intValue()*2); if (pMap instanceof Properties) { entry.setValue(iDoubled.toString()); } else { entry.setValue(iDoubled); } } return result; } public Properties doubledPropertyValues(Properties pProperties) { return (Properties) doubledValues(pProperties); } } protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { return getHandlerMapping("JiraTest.properties"); } /** * Test case for * XMLRPC-89 */ public void testXMLRPC89() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC89Vector(providers[i]); testXMLRPC89Hashtable(providers[i]); testXMLRPC89Properties(providers[i]); } } private void testXMLRPC89Vector(ClientProvider pProvider) throws Exception { Vector values = new Vector(); for (int i = 0; i < 3; i++) { values.add(new Integer(i)); } Vector params = new Vector(); params.add(values); XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); Object res = client.execute(XMLRPC89Handler.class.getName() + ".reverse", params); Object[] result = (Object[]) res; assertNotNull(result); assertEquals(3, result.length); for (int i = 0; i < 3; i++) { assertEquals(new Integer(2-i), result[i]); } ClientFactory factory = new ClientFactory(client); XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class); Vector resultVector = handler.reverse(values); assertNotNull(resultVector); assertEquals(3, resultVector.size()); for (int i = 0; i < 3; i++) { assertEquals(new Integer(2-i), resultVector.get(i)); } } private void verifyXMLRPC89Hashtable(Map pMap) { assertNotNull(pMap); assertEquals(3, pMap.size()); for (int i = 0; i < 3; i++) { Integer j = (Integer) pMap.get(String.valueOf(i)); assertEquals(i*2, j.intValue()); } } private void testXMLRPC89Hashtable(ClientProvider pProvider) throws Exception { Hashtable values = new Hashtable(); for (int i = 0; i < 3; i++) { values.put(String.valueOf(i), new Integer(i)); } XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); Object res = client.execute(XMLRPC89Handler.class.getName() + ".doubledValues", new Object[]{values}); verifyXMLRPC89Hashtable((Map) res); ClientFactory factory = new ClientFactory(client); XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class); Hashtable result = handler.doubledValues(values); verifyXMLRPC89Hashtable(result); } private void verifyXMLRPC89Properties(Map pMap) { assertNotNull(pMap); assertEquals(3, pMap.size()); for (int i = 0; i < 3; i++) { String j = (String) pMap.get(String.valueOf(i)); assertEquals(i*2, Integer.parseInt(j)); } } private void testXMLRPC89Properties(ClientProvider pProvider) throws Exception { Properties values = new Properties(); for (int i = 0; i < 3; i++) { values.put(String.valueOf(i), String.valueOf(i)); } XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); Object res = client.execute(XMLRPC89Handler.class.getName() + ".doubledPropertyValues", new Object[]{values}); verifyXMLRPC89Properties((Map) res); ClientFactory factory = new ClientFactory(client); XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class); Properties result = handler.doubledPropertyValues(values); verifyXMLRPC89Properties(result); } /** Handler for XMLRPC-96 */ public static class XMLRPC96Handler { /** Returns the "Hello, world!" string. */ public String getHelloWorld() { return "Hello, world!"; } } /** * Test case for * XMLRPC-96 */ public void testXMLRPC96() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC96(providers[i]); } } private void testXMLRPC96(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); String s = (String) client.execute(XMLRPC96Handler.class.getName() + ".getHelloWorld", new Object[0]); assertEquals("Hello, world!", s); s = (String) client.execute(XMLRPC96Handler.class.getName() + ".getHelloWorld", (Object[]) null); assertEquals("Hello, world!", s); } /** * Test case for * XMLRPC-112 */ public void testXMLRPC112() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC112(providers[i]); } } /** * Test case for * XMLRPC-113 */ public void testXMLRPC113() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC113(providers[i]); } } private void testXMLRPC112(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); TimingOutCallback toc = new TimingOutCallback(5000); final String methodName = XMLRPC89Handler.class.getName() + ".reverse"; client.executeAsync(methodName, new Object[]{new Object[]{"1", "2", "3"}}, toc); Object o; try { o = toc.waitForResponse(); } catch (Exception e) { throw e; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } checkXMLRPC112Result(o); checkXMLRPC112Result(client.execute(methodName, new Object[]{new Object[]{"1", "2", "3"}})); checkXMLRPC112Result(client.execute(methodName, new Object[]{new Object[]{"1", "2", "3"}})); } private void checkXMLRPC112Result(Object pObject) { Object[] args = (Object[]) pObject; assertEquals(3, args.length); assertEquals("3", args[0]); assertEquals("2", args[1]); assertEquals("1", args[2]); } /** * Handler interface for {@link JiraTest#testXMLRPC113()} */ public interface XMLRPC113Handler { /** * Throws an {@link XmlRpcException} with the given error code. */ Object throwCode(int pCode) throws XmlRpcException; } /** * Handler for {@link JiraTest#testXMLRPC113()} */ public static class XMLRPC113HandlerImpl implements XMLRPC113Handler { public Object throwCode(int pCode) throws XmlRpcException { throw new XmlRpcException(pCode, "Message: " + pCode); } } private void testXMLRPC113(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); XMLRPC113Handler handler = (XMLRPC113Handler) new ClientFactory(client).newInstance(XMLRPC113Handler.class); for (int i = 0; i < 5; i++) { try { client.execute(XMLRPC113Handler.class.getName() + ".throwCode", new Object[]{new Integer(i)}); fail("Excpected exception"); } catch (XmlRpcException e) { assertEquals(i, e.code); } try { handler.throwCode(i); } catch (XmlRpcException e) { assertEquals(i, e.code); } } } /** * Handler for {@link JiraTest#testXMLRPC115()} */ public static class XMLRPC115Handler { /** * Does nothing, just for checking, whether the server is alive. */ public Object[] ping() { return new Object[0]; } } /** * Test case for * XMLRPC-115 */ public void testXMLRPC115() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC115(providers[i]); } } private void testXMLRPC115(ClientProvider pProvider) throws Exception { if (pProvider instanceof SunHttpTransportProvider) { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); URL url = ((XmlRpcHttpClientConfig) client.getConfig()).getServerURL(); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("content-type", "text/xml"); OutputStream ostream = conn.getOutputStream(); Writer w = new OutputStreamWriter(ostream, "UTF-8"); w.write("" + XMLRPC115Handler.class.getName() + ".ping" + ""); w.close(); InputStream istream = conn.getInputStream(); XmlRpcResponseParser parser = new XmlRpcResponseParser((XmlRpcStreamRequestConfig) client.getClientConfig(), client.getTypeFactory()); XMLReader xr = SAXParsers.newXMLReader(); xr.setContentHandler(parser); xr.parse(new InputSource(istream)); istream.close(); assertTrue(parser.getResult() instanceof Object[]); assertEquals(0, ((Object[]) parser.getResult()).length); } } /** * Test case for * XMLRPC-119 */ public void testXMLRPC119() throws Exception { for (int i = 0; i < providers.length; i++) { testXMLRPC119(providers[i]); } } /** Handler for XMLRPC-119 */ public static class XMLRPC119Handler { /** Returns a string with a length of "num" Kilobytes. */ public String getString(int pSize) { StringBuffer sb = new StringBuffer(pSize*1024); for (int i = 0; i < pSize*1024; i++) { sb.append('&'); } return sb.toString(); } } private void testXMLRPC119(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); client.setConfig(getConfig(pProvider)); for (int i = 0; i < 100; i+= 10) { String s = (String) client.execute(XMLRPC119Handler.class.getName() + ".getString", new Object[]{new Integer(i)}); assertEquals(i*1024, s.length()); } } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/LiteTransportProvider.java100644 0 0 3167 11333307147 27650 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcLiteHttpTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; /** Provider for testing the * {@link org.apache.xmlrpc.client.XmlRpcLiteHttpTransport}. */ public class LiteTransportProvider extends WebServerProvider { /** Creates a new instance. * @param pMapping The test servers handler mapping. * @param pContentLength Whether a Content-Length header is required. */ public LiteTransportProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) { super(pMapping, pContentLength); } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { return new XmlRpcLiteHttpTransportFactory(pClient); } } ././@LongLink100644 0 0 146 11333313337 10254 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/LocalStreamTransportProvider.javaapache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/LocalStreamTransportProvider.jav100644 0 0 3634 11333307147 31017 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcLocalStreamTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcLocalStreamServer; import org.apache.xmlrpc.server.XmlRpcServer; /** Implementation of {@link org.apache.xmlrpc.test.BaseTest} * for testing the {@link org.apache.xmlrpc.client.XmlRpcLocalStreamTransport}. */ public class LocalStreamTransportProvider extends LocalTransportProvider { private XmlRpcLocalStreamServer server; /** Creates a new instance. * @param pMapping The test servers handler mapping. */ public LocalStreamTransportProvider(XmlRpcHandlerMapping pMapping) { super(pMapping); } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { server = new XmlRpcLocalStreamServer(); XmlRpcLocalStreamTransportFactory factory = new XmlRpcLocalStreamTransportFactory(pClient, server); return factory; } public XmlRpcServer getServer() { return server; } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/LocalTransportProvider.java100644 0 0 4064 11333307147 30002 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcLocalTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; /** Implementation of {@link org.apache.xmlrpc.test.BaseTest} * for testing the {@link org.apache.xmlrpc.client.XmlRpcLocalTransport}. */ public class LocalTransportProvider extends ClientProviderImpl { private XmlRpcServer server; /** Creates a new instance. * @param pMapping The test servers handler mapping. */ public LocalTransportProvider(XmlRpcHandlerMapping pMapping) { super(pMapping); } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { XmlRpcLocalTransportFactory factory = new XmlRpcLocalTransportFactory(pClient); return factory; } public XmlRpcClientConfigImpl getConfig() throws Exception { XmlRpcClientConfigImpl config = super.getConfig(); server = getXmlRpcServer(); config.setXmlRpcServer(server); return config; } public XmlRpcServer getServer() { return server; } public void shutdown() { // Does nothing } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/MetadataTest.java100644 0 0 11116 11333307147 25714 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.text.Collator; import java.util.Arrays; import java.util.Locale; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfig; import org.apache.xmlrpc.metadata.XmlRpcSystemImpl; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; /** * Test class for the introspection stuff. */ public class MetadataTest extends XmlRpcTestCase { protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.addHandler("Adder", AuthenticationTest.AdderImpl.class); XmlRpcSystemImpl.addSystemHandler(mapping); return mapping; } /** * Test, whether the actual handlers are working. */ public void testAdder() throws Exception { for (int i = 0; i < providers.length; i++) { testAdder(providers[i]); } } private void testAdder(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); XmlRpcClientConfig config = getConfig(pProvider); client.setConfig(config); Object o = client.execute("Adder.add", new Object[]{new Integer(3), new Integer(5)}); assertEquals(new Integer(8), o); } /** * Test for system.listMethods. */ public void testListMethods() throws Exception { for (int i = 0; i < providers.length; i++) { testListMethods(providers[i]); } } private void testListMethods(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); XmlRpcClientConfig config = getConfig(pProvider); client.setConfig(config); Object o = client.execute("system.listMethods", new Object[0]); Object[] methodList = (Object[]) o; Arrays.sort(methodList, Collator.getInstance(Locale.US)); assertEquals(4, methodList.length); assertEquals("Adder.add", methodList[0]); assertEquals("system.listMethods", methodList[1]); assertEquals("system.methodHelp", methodList[2]); assertEquals("system.methodSignature", methodList[3]); } /** * Test for system.methodHelp. */ public void testMethodHelp() throws Exception { for (int i = 0; i < providers.length; i++) { testMethodHelp(providers[i]); } } private void testMethodHelp(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); XmlRpcClientConfig config = getConfig(pProvider); client.setConfig(config); String help = (String) client.execute("system.methodHelp", new Object[]{"Adder.add"}); assertEquals("Invokes the method org.apache.xmlrpc.test.AuthenticationTest$AdderImpl.add(int, int).", help); } /** * Test for system.methodSignature. */ public void testMethodSignature() throws Exception { for (int i = 0; i < providers.length; i++) { testMethodSignature(providers[i]); } } private void testMethodSignature(ClientProvider pProvider) throws Exception { XmlRpcClient client = pProvider.getClient(); XmlRpcClientConfig config = getConfig(pProvider); client.setConfig(config); Object[] signatures = (Object[]) client.execute("system.methodSignature", new Object[]{"Adder.add"}); assertEquals(signatures.length, 1); Object[] signature = (Object[]) signatures[0]; assertEquals(3, signature.length); assertEquals("int", signature[0]); assertEquals("int", signature[1]); assertEquals("int", signature[2]); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ParserTest.java100644 0 0 14023 11333307147 25430 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.UndeclaredThrowableException; import java.text.ParseException; import java.util.TimeZone; import junit.framework.TestCase; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.parser.DateParser; import org.apache.xmlrpc.parser.XmlRpcRequestParser; import org.apache.xmlrpc.parser.XmlRpcResponseParser; import org.apache.xmlrpc.util.SAXParsers; import org.apache.xmlrpc.util.XmlRpcDateTimeFormat; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; /** Test for the various parsers. */ public class ParserTest extends TestCase { private Object parseResponse(final String s) throws XmlRpcException, IOException, SAXException { return parseResponse(new InputSource(new StringReader(s))); } private Object parseResponse(InputSource isource) throws XmlRpcException, IOException, SAXException { XmlRpcStreamRequestConfig config = new XmlRpcClientConfigImpl(); XmlRpcClient client = new XmlRpcClient(); XmlRpcResponseParser parser = new XmlRpcResponseParser(config, client.getTypeFactory()); XMLReader xr = SAXParsers.newXMLReader(); xr.setContentHandler(parser); xr.parse(isource); Object o = parser.getResult(); return o; } private XmlRpcRequestParser parseRequest(final String s) throws XmlRpcException, IOException, SAXException { XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl(); XmlRpcClient client = new XmlRpcClient(); XmlRpcRequestParser parser = new XmlRpcRequestParser(config, client.getTypeFactory()); XMLReader xr = SAXParsers.newXMLReader(); xr.setContentHandler(parser); xr.parse(new InputSource(new StringReader(s))); return parser; } /** Tests, whether strings can be parsed with, * or without, the "string" tag. */ public void testStringType() throws Exception { final String[] strings = new String[]{ "3", "3", " 3 " }; for (int i = 0; i < strings.length; i++) { final String s = "\n" + "\n" + "" + strings[i] + "\n" + "\n"; Object o = parseResponse(s); assertEquals("3", o); } } /** Tests, whether nested arrays can be parsed. */ public void testNestedObjectArrays() throws Exception { final String s = "\n" + "\n" + "\n" + "array\n" + "string\n" + "\n" + "\n"; Object o = parseResponse(s); assertTrue(o instanceof Object[]); Object[] outer = (Object[]) o; assertEquals(1, outer.length); o = outer[0]; assertTrue(o instanceof Object[]); Object[] inner = (Object[]) o; assertEquals(2, inner.length); assertEquals("array", inner[0]); assertEquals("string", inner[1]); } /** * Tests, whether a request may omit the tag. */ public void testOptionalParams() throws Exception { final String s1 = ""; Object o1 = parseResponse(s1); assertNull(o1); final String s2 = ""; Object o2 = parseResponse(s2); assertNull(o2); final String s3 = "foo"; XmlRpcRequestParser p3 = parseRequest(s3); assertEquals("foo", p3.getMethodName()); assertNull(p3.getParams()); final String s4 = "bar"; XmlRpcRequestParser p4 = parseRequest(s4); assertEquals("bar", p4.getMethodName()); assertNotNull(p4.getParams()); assertTrue(p4.getParams().size() == 0); } /** * Test for XMLRPC-140. */ public void testXMLRPC140() throws Exception { DateParser parser = new DateParser(new XmlRpcDateTimeFormat(){ private static final long serialVersionUID = 0L; protected TimeZone getTimeZone() { return TimeZone.getDefault(); } }){ public void setResult(Object pObject){ try { super.setResult((String) pObject); } catch (SAXException e) { throw new UndeclaredThrowableException(e); } } }; try { parser.setResult("20070316T162808Z"); fail("Expected exception"); } catch (UndeclaredThrowableException e) { SAXParseException spe = (SAXParseException) e.getUndeclaredThrowable(); ParseException pe = (ParseException) spe.getException(); assertEquals(11, pe.getErrorOffset()); } } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ScalabilityTest.java100644 0 0 16175 11333307147 26446 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.net.URL; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.util.ThreadPool; import org.apache.xmlrpc.webserver.ServletWebServer; import org.apache.xmlrpc.webserver.WebServer; import org.apache.xmlrpc.webserver.XmlRpcServlet; import junit.framework.TestCase; /** * Tests the frameworks scalability. */ public class ScalabilityTest extends TestCase { /** * Primitive handler class */ public static class Adder { /** * Returns the sum of the numbers p1 and p2. */ public int add(int p1, int p2) { return p1 + p2; } } private class MyServletWebServer extends ServletWebServer { protected ThreadPool pool; MyServletWebServer(HttpServlet pServlet, int pPort) throws ServletException { super(pServlet, pPort); } public ThreadPool newThreadPool(){ pool = new ThreadPool(getXmlRpcServer().getMaxThreads(), "XML-RPC"){ }; return pool; } int getNumThreads() { return pool.getNumThreads(); } } private class MyWebServer extends WebServer { protected ThreadPool pool; MyWebServer(int pPort) { super(pPort); } public ThreadPool newThreadPool(){ pool = new ThreadPool(getXmlRpcServer().getMaxThreads(), "XML-RPC"){ }; return pool; } int getNumThreads() { return pool.getNumThreads(); } } private static final int BASE = 1; private static final Integer THREE = new Integer(3); private static final Integer FIVE = new Integer(5); private static final Integer EIGHT = new Integer(8); private XmlRpcServlet servlet; private MyServletWebServer server; private MyWebServer webServer; private XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.addHandler("Adder", Adder.class); return mapping; } private void initServletWebServer() throws Exception { servlet = new XmlRpcServlet(){ private static final long serialVersionUID = -2040521497373327817L; protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { return ScalabilityTest.this.newXmlRpcHandlerMapping(); } }; server = new MyServletWebServer(servlet, 0); server.getXmlRpcServer().setMaxThreads(25); server.start(); } private void shutdownServletWebServer() { server.shutdown(); } private void initWebServer() throws Exception { webServer = new MyWebServer(0); webServer.getXmlRpcServer().setHandlerMapping(newXmlRpcHandlerMapping()); webServer.getXmlRpcServer().setMaxThreads(25); webServer.start(); } private void shutdownWebServer() { webServer.shutdown(); } /** * Runs the test with a single client. */ public void testSingleClient() throws Exception { initServletWebServer(); boolean ok = false; try { long now = System.currentTimeMillis(); servlet.getXmlRpcServletServer().setMaxThreads(1); new Client(100*BASE, server.getPort()).run(); System.out.println("Single client: " + (System.currentTimeMillis()-now) + ", " + server.getNumThreads()); shutdownServletWebServer(); ok = true; } finally { if (!ok) { try { shutdownServletWebServer(); } catch (Throwable t) {} } } } /** * Runs the web server test with a single client. */ public void testSingleWebServerClient() throws Exception { initWebServer(); boolean ok = false; try { long now = System.currentTimeMillis(); webServer.getXmlRpcServer().setMaxThreads(1); new Client(100*BASE, webServer.getPort()).run(); System.out.println("Single client: " + (System.currentTimeMillis()-now) + ", " + webServer.getNumThreads()); shutdownWebServer(); ok = true; } finally { if (!ok) { try { shutdownWebServer(); } catch (Throwable t) {} } } } private static class Client implements Runnable { private final int iterations; private final int port; Client(int pIterations, int pPort) { iterations = pIterations; port = pPort; } public void run() { try { XmlRpcClient client = new XmlRpcClient(); XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://127.0.0.1:" + port + "/")); client.setConfig(config); for (int i = 0; i < iterations; i++) { assertEquals(EIGHT, client.execute("Adder.add", new Object[]{THREE, FIVE})); } } catch (Throwable t) { t.printStackTrace(); } } } /** * Runs the test with ten clients. */ public void testTenClient() throws Exception { initServletWebServer(); boolean ok = false; try { final Thread[] threads = new Thread[10]; servlet.getXmlRpcServletServer().setMaxThreads(10); long now = System.currentTimeMillis(); for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Client(10*BASE, server.getPort())); threads[i].start(); } for (int i = 0; i < threads.length; i++) { threads[i].join(); } System.out.println("Ten clients: " + (System.currentTimeMillis() - now) + ", " + server.getNumThreads()); shutdownServletWebServer(); ok = false; } finally { if (!ok) { try { shutdownServletWebServer(); } catch (Throwable t) {} } } } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/SerializerTest.java100644 0 0 20247 11333307147 26312 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.StringReader; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; import javax.xml.parsers.SAXParserFactory; import junit.framework.TestCase; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfig; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcClientRequestImpl; import org.apache.xmlrpc.client.XmlRpcSunHttpTransportFactory; import org.apache.xmlrpc.common.TypeFactoryImpl; import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; import org.apache.xmlrpc.parser.XmlRpcRequestParser; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** A test case for the various serializers. */ public class SerializerTest extends TestCase { private final XmlRpcClient client; /** Creates a new instance. */ public SerializerTest() { client = new XmlRpcClient(); client.setTransportFactory(new XmlRpcSunHttpTransportFactory(client)); } protected XmlRpcClientConfigImpl getConfig() { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); return config; } protected XmlRpcStreamRequestConfig getExConfig() { XmlRpcClientConfigImpl config = getConfig(); config.setEnabledForExtensions(true); return config; } protected String writeRequest(XmlRpcStreamRequestConfig pConfig, XmlRpcRequest pRequest) throws SAXException { client.setConfig((XmlRpcClientConfig) pConfig); return XmlRpcTestCase.writeRequest(client, pRequest); } /** Test serialization of a byte parameter. * @throws Exception The test failed. */ public void testByteParam() throws Exception { XmlRpcStreamRequestConfig config = getExConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "byteParam", new Object[]{new Byte((byte)3)}); String got = writeRequest(config, request); String expect = "" + "" + "byteParam3"; assertEquals(expect, got); } /** Test serialization of an integer parameter. * @throws Exception The test failed. */ public void testIntParam() throws Exception { XmlRpcStreamRequestConfig config = getConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "intParam", new Object[]{new Integer(3)}); String got = writeRequest(config, request); String expect = "" + "" + "intParam3"; assertEquals(expect, got); } /** Test serialization of a byte array. * @throws Exception The test failed. */ public void testByteArrayParam() throws Exception { byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; XmlRpcStreamRequestConfig config = getConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "byteArrayParam", new Object[]{bytes}); String got = writeRequest(config, request); String expect = "" + "" + "byteArrayParamAAECAwQFBgcICQ=="; assertEquals(expect, got); } /** Test serialization of a map. * @throws Exception The test failed. */ public void testMapParam() throws Exception { final Map map = new HashMap(); map.put("2", new Integer(3)); map.put("3", new Integer(5)); final Object[] params = new Object[]{map}; XmlRpcStreamRequestConfig config = getConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "mapParam", params); String got = writeRequest(config, request); String expect = "" + "mapParam" + "" + "35" + "23" + ""; assertEquals(expect, got); } /** Tests serialization of a calendar instance. */ public void testCalendarParam() throws Exception { TimeZone tz = TimeZone.getTimeZone("GMT"); Calendar cal1 = Calendar.getInstance(tz); cal1.set(1933, 5, 12, 11, 7, 21); cal1.set(Calendar.MILLISECOND, 311); Calendar cal2 = Calendar.getInstance(TimeZone.getDefault()); cal2.set(1933, 5, 12, 11, 7, 21); cal2.set(Calendar.MILLISECOND, 311); XmlRpcStreamRequestConfig config = getExConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "dateParam", new Object[]{cal1, cal2.getTime()}); String got = writeRequest(config, request); String expect = "" + "" + "dateParam" + "1933-06-12T11:07:21.311Z" + "19330612T11:07:21" + ""; assertEquals(expect, got); } /** * Test for XMLRPC-127: Is it possible to transmit a * map with integers as the keys? */ public void testIntegerKeyMap() throws Exception { Map map = new HashMap(); map.put(new Integer(1), "one"); XmlRpcStreamRequestConfig config = getExConfig(); XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "integerKeyMap", new Object[]{map}); String got = writeRequest(config, request); String expect = "" + "" + "integerKeyMap" + "" + "1" + "one" + "" + ""; assertEquals(expect, got); XmlRpcServer server = new XmlRpcServer(); XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl(); serverConfig.setEnabledForExtensions(true); server.setConfig(serverConfig); XmlRpcRequestParser parser = new XmlRpcRequestParser(serverConfig, new TypeFactoryImpl(server)); SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setValidating(false); spf.setNamespaceAware(true); XMLReader xr = spf.newSAXParser().getXMLReader(); xr.setContentHandler(parser); xr.parse(new InputSource(new StringReader(expect))); assertEquals("integerKeyMap", parser.getMethodName()); List params = parser.getParams(); assertEquals(1, params.size()); Map paramMap = (Map) params.get(0); assertEquals(1, paramMap.size()); assertEquals("one", paramMap.get(new Integer(1))); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/ServletWebServerProvider.java100644 0 0 6370 11333307147 30306 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.net.URL; import javax.servlet.ServletException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcSunHttpTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.ServletWebServer; import org.apache.xmlrpc.webserver.XmlRpcServlet; /** A provider class for testing the {@link ServletWebServer}. */ public class ServletWebServerProvider extends ClientProviderImpl { protected final ServletWebServer webServer; protected final XmlRpcServlet servlet; private final boolean contentLength; private final int port; /** * Creates a new instance of {@link XmlRpcServlet}. */ protected XmlRpcServlet newXmlRpcServlet() { return new XmlRpcServlet(); } /** Creates a new instance. * @param pMapping The test servers handler mapping. * @throws ServletException * @throws IOException */ protected ServletWebServerProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) throws ServletException, IOException { super(pMapping); contentLength = pContentLength; servlet = newXmlRpcServlet(); webServer = new ServletWebServer(servlet, 0); XmlRpcServer server = servlet.getXmlRpcServletServer(); server.setHandlerMapping(mapping); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) server.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(!contentLength); serverConfig.setEnabledForExceptions(true); webServer.start(); port = webServer.getPort(); } public final XmlRpcClientConfigImpl getConfig() throws Exception { return getConfig(new URL("http://127.0.0.1:" + port + "/")); } protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws Exception { XmlRpcClientConfigImpl config = super.getConfig(); config.setServerURL(pServerURL); config.setContentLengthOptional(!contentLength); return config; } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { return new XmlRpcSunHttpTransportFactory(pClient); } public XmlRpcServer getServer() { return servlet.getXmlRpcServletServer(); } public void shutdown() { webServer.shutdown(); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/SunHttpTransportProvider.java100644 0 0 3203 11333307147 30347 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcSunHttpTransportFactory; import org.apache.xmlrpc.client.XmlRpcTransportFactory; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; /** Implementation of {@link BaseTest} for testing the * {@link org.apache.xmlrpc.client.XmlRpcSunHttpTransport}. */ public class SunHttpTransportProvider extends WebServerProvider { /** Creates a new instance. * @param pMapping The test servers handler mapping. * @param pContentLength Number of bytes being transmitted. */ public SunHttpTransportProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) { super(pMapping, pContentLength); } protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) { return new XmlRpcSunHttpTransportFactory(pClient); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/WebServerProvider.java100644 0 0 5107 11333307147 26736 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.net.URL; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.WebServer; /** Abstract base class for providers, which require a webserver. */ public abstract class WebServerProvider extends ClientProviderImpl { protected final WebServer webServer = new WebServer(0); private boolean isActive; private final boolean contentLength; /** Creates a new instance. * @param pMapping The test servers handler mapping. */ protected WebServerProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) { super(pMapping); contentLength = pContentLength; } public final XmlRpcClientConfigImpl getConfig() throws Exception { initWebServer(); return getConfig(new URL("http://127.0.0.1:" + webServer.getPort() + "/")); } protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws Exception { XmlRpcClientConfigImpl config = super.getConfig(); config.setServerURL(pServerURL); config.setContentLengthOptional(!contentLength); return config; } protected void initWebServer() throws Exception { if (!isActive) { XmlRpcServer server = webServer.getXmlRpcServer(); server.setHandlerMapping(mapping); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) server.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(!contentLength); serverConfig.setEnabledForExceptions(true); webServer.start(); isActive = true; } } public XmlRpcServer getServer() { return webServer.getXmlRpcServer(); } public void shutdown() { webServer.shutdown(); } } apache-xmlrpc-3.1.3-src/server/src/test/java/org/apache/xmlrpc/test/XmlRpcTestCase.java100644 0 0 10570 11333307147 26200 0ustar 0 0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.xmlrpc.test; import java.io.IOException; import java.io.StringWriter; import javax.servlet.ServletException; import junit.framework.TestCase; import org.apache.ws.commons.serialize.XMLWriter; import org.apache.ws.commons.serialize.XMLWriterImpl; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfig; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.common.TypeConverterFactory; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.common.XmlRpcStreamConfig; import org.apache.xmlrpc.serializer.XmlRpcWriter; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcHandlerMapping; import org.xml.sax.SAXException; /** Abstract base class for deriving test cases. */ public abstract class XmlRpcTestCase extends TestCase { protected ClientProvider[] providers; protected abstract XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException; protected XmlRpcClientConfigImpl getConfig(ClientProvider pProvider) throws Exception { return pProvider.getConfig(); } protected XmlRpcClientConfig getExConfig(ClientProvider pProvider) throws Exception { XmlRpcClientConfigImpl config = getConfig(pProvider); config.setEnabledForExtensions(true); config.setEnabledForExceptions(true); return config; } protected XmlRpcHandlerMapping getHandlerMapping(String pResource) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); mapping.setVoidMethodEnabled(true); mapping.load(getClass().getClassLoader(), getClass().getResource(pResource)); mapping.setTypeConverterFactory(getTypeConverterFactory()); return mapping; } protected ClientProvider[] initProviders(XmlRpcHandlerMapping pMapping) throws ServletException, IOException { return new ClientProvider[]{ new LocalTransportProvider(pMapping), new LocalStreamTransportProvider(pMapping), new LiteTransportProvider(pMapping, true), // new LiteTransportProvider(mapping, false), Doesn't support HTTP/1.1 new SunHttpTransportProvider(pMapping, true), new SunHttpTransportProvider(pMapping, false), new CommonsProvider(pMapping), new ServletWebServerProvider(pMapping, true), new ServletWebServerProvider(pMapping, false) }; } public void setUp() throws Exception { if (providers == null) { providers = initProviders(getHandlerMapping()); } } public void tearDown() throws Exception { if (providers != null) { for (int i = 0; i < providers.length; i++) { providers[i].shutdown(); } } } protected TypeConverterFactory getTypeConverterFactory() { return new TypeConverterFactoryImpl(); } static String writeRequest(XmlRpcClient pClient, XmlRpcRequest pRequest) throws SAXException { StringWriter sw = new StringWriter(); XMLWriter xw = new XMLWriterImpl(); xw.setEncoding("US-ASCII"); xw.setDeclarating(true); xw.setIndenting(false); xw.setWriter(sw); XmlRpcWriter xrw = new XmlRpcWriter((XmlRpcStreamConfig) pClient.getConfig(), xw, pClient.getTypeFactory()); xrw.write(pRequest); return sw.toString(); } } ././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/AuthenticationTest.propertiesapache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/AuthenticationTest.properti100644 0 0 1575 11333307151 31152 0ustar 0 0 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # org.apache.xmlrpc.test.AuthenticationTest$Adder=org.apache.xmlrpc.test.AuthenticationTest$AdderImpl apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/BaseTest.properties100644 0 0 1507 11333307151 27370 0ustar 0 0 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Remote=org.apache.xmlrpc.test.BaseTest$Remote ././@LongLink100644 0 0 145 11333313337 10253 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/DynamicProxyTest.propertiesapache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/DynamicProxyTest.properties100644 0 0 1571 11333307151 31145 0ustar 0 0 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # org.apache.xmlrpc.test.DynamicProxyTest$Adder=org.apache.xmlrpc.test.DynamicProxyTest$AdderImpl apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/test/JiraTest.properties100644 0 0 2436 11333307151 27405 0ustar 0 0 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # org.apache.xmlrpc.test.JiraTest$XMLRPC89Handler=org.apache.xmlrpc.test.JiraTest$XMLRPC89HandlerImpl org.apache.xmlrpc.test.JiraTest$XMLRPC96Handler=org.apache.xmlrpc.test.JiraTest$XMLRPC96Handler org.apache.xmlrpc.test.JiraTest$XMLRPC113Handler=org.apache.xmlrpc.test.JiraTest$XMLRPC113HandlerImpl org.apache.xmlrpc.test.JiraTest$XMLRPC115Handler=org.apache.xmlrpc.test.JiraTest$XMLRPC115Handler org.apache.xmlrpc.test.JiraTest$XMLRPC119Handler=org.apache.xmlrpc.test.JiraTest$XMLRPC119Handler ././@LongLink100644 0 0 147 11333313337 10255 Lustar 0 0 apache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/webserver/XmlRpcServlet.propertiesapache-xmlrpc-3.1.3-src/server/src/test/resources/org/apache/xmlrpc/webserver/XmlRpcServlet.properti100644 0 0 1507 11333307151 31125 0ustar 0 0 # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Remote=org.apache.xmlrpc.test.BaseTest$Remote apache-xmlrpc-3.1.3-src/src/changes/changes.xml100644 0 0 52720 11333307155 16536 0ustar 0 0 Changes in Apache XML-RPC The version number in the clients user agent string is now updated automatically. Fixed a deadlock in the ThreadPool. The ClientFactory is now supporting an empty remote class. Added support for configured timeouts to the XmlRpcSun15HttpTransport class. Fixed a potential security hole: The client has been able to include server side resources into the request by using external entities. Eliminated a possible race condition in the ThreadPool. The ThreadPool could create more threads than configured. Weakened the access control in the WebServer class in order to make subclassing easier. Improved the handling of HTTP status codes that indicate an error. Fixed a possible NPE in case of a malformed HTTP request in the WebServer. The webserver's connection timeout wasn't applied to the ServletWebServer. A client could prevent other clients from connecting by not sending any data. The platforms default encoding has been used at some point when decoding HTTP headers. The XmlRpcCommonsTransport is now always declaring its entities as repeatable. It is now possible to set the clients user-agent header in the client configuration. Ensured that the server replies with a spec compliant request, if the client uses the content-length header. The XmlRpcSunHttpTransportFactory wasn't thread safe. Added support for javax.net.ssl.SSLSocketFactory and javax.net.Proxy. Added some clarification on the handling of Object[] and java.util.List to the page on "XML-RPC Data Types". Minor grammar improvements. Added the XmlRpcErrorHandler, which allows to customize the error logging. This allows, for example, to minimize the logging for business exceptions. Documented, that called methods are choosen based on their signature. In particular, multiple methods with the same name are supported. Fixed the FAQ entry on how to obtain the clients IP address. Introduced the "enabledForExceptions" property. Added support for void methods, if extensions are turned on. Added PropertyHandlerMapping.load(ClassLoader, Map). The authentication handler, type converter and requestprocessor factories are now configurable as properties of the XmlRpcServlet. Atomic properties of XmlRpcServer are now configurable as init parameters in the XmlRpcServlet. Reworked the WebServer/ThreadPool framework in order to ensure a clean shutdown. The configuration framework, as introduced by XMLRPC-116, was applicable to the configuration only, and not to the XmlRpcServlet, or the XmlRpcServletServer. Introduced the method AbstractReflectiveHandlerMapping.isHandlerMethod(). This should allow users to prevent remote invocation of certain methods, for example initialization stuff. The ClientFactory is now able to use a custom name for the remote handler. So far, it was always using the interface name. It is now possible to have other objects than strings as map keys. Made extending the XmlRpcCommonsTransportFactory easier. Added support for redirects. Fixed an invalid example in the "advanced" document. An invalid dateTime value is now causing a more informative error message. The redirect handling (XMLRPC-132) wasn't actually working, because it treated an URI as a charset name. Address matching in the Webserver wasn't actually working, because casting of integers to bytes was implemented wrong. Make the HttpClient creation in XmlRpcCommonsTransport and the URLConnection creation in XmlRpcSunHttpTransport protected. This is required for cookie support. The WebServer was producing invalid error responses, if contentLengthOptional was set. If the server was throwing an XmlRpcException, then the fault code and fault string weren't given to the client. The WebServer replies with an HTTP error 401 now, if the client uses chunked encoding. The properties "Extension-Name", "Specification-Vendor", "Specification-Version", "Specification-Title", "Implementation-Vendor-Id", "Implementation-Vendor" and "Implementation-Version" are now present in the MANIFEST files. An NPE was thrown, if the clients request didn't contain a "params" element. The method TimingOutCallback.waitForResponse is now checking, whether a response has already arrived before waiting. Fixed a serious performance problem, if the XML parser was sending large content in small pieces. This could happen, for example, if the content contained a large number of character entities. The configuration of the reply timeout in the commons transport was wrong. The DateParser is now treating an empty string as null. Fixed a broken link referring to an "SSL with Jetty" HOW-TO. The XmlRpcRequestParser and XmlRpcResponseParser didn't reset their internal state within startDocument(). Consequently, they haven't been reusable. Fixed the spelling of CharSetXmlWriterFactory, which made the class basically useless. Fixed that the WebServer didn't wait before retrying to bind to the server socket. Fixed an endless loop, if the WebServer threw a BindException. A NullPointerException was triggered, if the BasicEncoding was set to null. Basic authentication didn't work, if the base64 encoded string with user name and password contained more than 72 characters. Basic authentication didn't work with the commons http transport, because the commons httpclient wasn't configured to send credentials by default. (It was waiting for a challenge.) Basic authentication didn't work with the commons http transport, if user name or password contained non-ASCII characters. The releaseWorker() method wasn't called for the server. Fixed a bug in the web servers thread pool, which caused that threads haven't been reused. Documentation improvements Added documentation on custom data types. The XmlRpcLiteHttpTransport is now creating a socket in a protected methods. This allows to switch to alternative socket implementations. More documentation fixes. Fixed an invalid FAQ example. Added a missing "synchronized" to the TimingOutCallback. Fixed an invalid index, that caused the ReflectiveXmlRpcHandler to fail detecting a method. Added documentation for accessing an SSL server. A null parameter list is now treated as an empty object array. The type long was missing in types.apt. Add connectionTimeout and replyTimeout in RPC clients. CommonsTransport support connection and reply timeout, liteHttpTransport only support reply timeout The value created by HttpUtil.encodeBasicAuthentication(...) was terminated with a line feed, which is invalid for use in HTTP headers. add support for BigDecimal and BigInteger in extensions. Nested object arrays could not be parsed. The "string" tag could not be parsed. Added the DynamicHandlerMapping. XmlRpcException.printStackTrace() was throwing an NPE, if no linked exception was present. The project is now splitted into three jar files: common, client, and server. The Base64 encoder doesn't accept buffers of length 0. Such a buffer was passed, if the byte array to encode has itself length 0. HTTP/1.0 requires a content-length header. The Lite HTTP transport doesn't support HTTP/1.1, so it refuses the "contentLengthOptional" setting from now on. Added support for initializable handlers. Added the TimingOutCallback, which allows to abort a request, if the server doesn't reply within a given time. Fixed that dateTime values must not include timezone values. The XmlRpcServlet allows to configure its "enabledForExtensions" value as an init parameter. It is now possible to create and initialize handler objects per request. Added partial support for automatic conversion of object arrays to lists, or vectors. Same for maps to hash tables, or properties. Complete rewrite, adding vendor extensions: Streaming mode, support for all primitive Java types, nulls, DOM elements, and JAXB objects. A missing increment in LiteXmlRpcTransport.initConnection() prevented, that the method could finally fail, resulting in a never ending loop. The Webserver class was unable to handle basic authentication, because the BASE64 codec wasn't initialized. The characters 0x20, 0xe000, and 0x10000 have been escaped without reason. The wrong version of commons-codec was downloaded by build.xml. Added the CommonsXmlRpcTransportFactory. Added the possibility to specify a timezone for interpreting incoming date values. Upgrade to commons-httpclient 3.0. apache-xmlrpc-3.1.3-src/src/site/apt/advanced.apt100644 0 0 30533 11333307154 16774 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ --------------------------- Advanced Programming Topics --------------------------- This page describes some advanced topics. Dynamic proxies Dynamic proxies are an extremely comfortable way of Client programming. Basically, the idea is as follows: All request processors on the server side are splitted into interface and implementation. The interfaces are shared between client and server, typically within some common jar file. Now, rather than using the {{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpcClient}} directly, the programmer creates an instance of {{{apidocs/org/apache/xmlrpc/client/util/ClientFactory.html}ClientFactory}}, which is configured with an {{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpcClient}}. The {{{apidocs/org/apache/xmlrpc/client/util/ClientFactory.html}factory}} can take an interface as input and returns an implementation, which internally calls the server by using the {{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpcClient}}. Perhaps some code shows more than words. First of all, let's create a request processor interface. ----------------------------------------------------------------------------------- package com.foo; public interface Adder { public int add(int pNum1, int pNum2); } ----------------------------------------------------------------------------------- The server contains the request processors implementation: ----------------------------------------------------------------------------------- package com.foo; public class AdderImpl implements Adder { public int add(int pNum1, int pNum2) { return pNum1 + pNum2; } } ----------------------------------------------------------------------------------- And here is how the client would use this: ----------------------------------------------------------------------------------- import com.foo.Adder; import java.net.URL; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.util.ClientFactory; XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://127.0.0.1:8080/xmlrpc")); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); ClientFactory factory = new ClientFactory(client); Adder adder = (Adder) factory.newInstance(Adder.class); int sum = adder.add(2, 4); ----------------------------------------------------------------------------------- * Exception handling Currently, exceptions are a problem: If the server throws an exception (for example an IOException), then the client receives an XmlRpcException. Consequently, the generated implementation will attempt to throw the XmlRpcException. Unfortunately, the method signature will of course contain an IOException, but rarely an XmlRpcException. As the XmlRpcException cannot be thrown, it is converted into an UndeclaredThrowableException. This is no problem, if you are prepared for runtime exceptions by enclosing your code with proper exception handlers. (Of course, the exception handlers may be in a calling method.) Only if you want to catch the exception (for example, because you expect an error at a certain point), then you need to consider, which exception is being trapped: If the method exposes XmlRpcException, then you'll need to catch the XmlRpcException. Otherwise, it's UndeclaredThrowableException. It is recommended to use the property enabledForExceptions. If this property is set, then the server will attempt to convert the exception into a byte array, which is transmitted to the client. The client will be able to convert the byte array back into an exception and throw that, as if it came right out of the client. Note, that this approach may cause security and privacy issues, because the serialized exception may, in theory, contain arbitrary objects. * Cookie handling Cookie has not yet been generalized. In other words, it depends on the transport. * The XmlRpcLiteHttpTransport doesn't have support for cookies. * The XmlRpcSunHttpTransport requires hand written code for setting and getting the cookies or using a cookie library. (The latter is recommended, of course.) In either way, you've got to use a custom transport and overwrite the methods newURLConnection(URL), initHttpHeaders(XmlRpcRequest), and close(): ----------------------------------------------------------------------------------- import java.net.URLConnection; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcSunHttpTransport; import org.apache.xmlrpc.client.XmlRpcTransport; import org.apache.xmlrpc.client.XmlRpcTransportFactory; final XmlRpcClient client = new XmlRpcClient(); XmlRpcTransportFactory factory = new XmlRpcTransportFactory(){ public XmlRpcTransport getTransport(){ private URLConnection conn; protected URLConnection newURLConnection(URL pURL) throws IOException { conn = super.newURLConnection(pURL); return conn; } protected void initHttpHeaders(XmlRpcRequest pRequest) { super.initHttpHeaders(pRequest); setCookies(conn); } protected void close() throws XmlRpcClientException { getCookies(conn); } private void setCookies(URLConnection pConn) { // Implement me ... } private void getCookies(URLConnection pConn) { // Implement me ... } } }; client.setTransportFactory(factory); ----------------------------------------------------------------------------------- * The XmlRpcCommonsHttpTransport requires that the HttpClient is being reused. (By default, a new HttpClient is created for any connection.) To reuse the HttpClient, set it on the transport factory: ----------------------------------------------------------------------------------- import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpState; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcCommonsTransport; import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; final XmlRpcClient client = new XmlRpcClient(); final HttpClient httpClient = new HttpClient(); final XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(client); factory.setHttpClient(httpClient); client.setTransportFactory(factory); final HttpState httpState = client.getState(); ----------------------------------------------------------------------------------- Cookies may now be read or set on the httpState object. Note, that this means losing the XmlRpcClients multithreading abilities! The factory above is obviously bound to the HttpClient, which must be bound to a thread. If you need to set cookies initially, overwrite the transport method initHttpHeaders(XmlRpcRequest) as well. * Custom data types Apache XML-RPC was built with extensibility in mind. In particular, it was written to support custom data types. The data type handling is completely left to the {{{apidocs/org/apache/xmlrpc/common/TypeFactory.html}TypeFactory}}. In other words, adding support for custom data types is as simple as providing your own type factory. This is typically done by subclassing {{{apidocs/org/apache/xmlrpc/common/TypeFactoryImpl.html}TypeFactoryImpl}}. We'll illustrate the concept by creating a type factory, which uses a non-standard date format for transmitting date values. First of all, we've got to implement the subclass: ----------------------------------------------------------------------------------- import java.text.DateFormat; import java.text.SimpleDateFormat; import org.apache.xmlrpc.common.TypeFactoryImpl; import org.apache.xmlrpc.common.XmlRpcController; import org.apache.xmlrpc.parser.DateParser; import org.apache.xmlrpc.parser.TypeParser; import org.apache.xmlrpc.serializer.DateSerializer; import org.apache.xmlrpc.serializer.TypeSerializer; import org.apache.ws.commons.util.NamespaceContextImpl; public class MyTypeFactory extends TypeFactoryImpl { public MyTypeFactory(XmlRpcController pController) { super(pController); } private DateFormat newFormat() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); } public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) { if (DateSerializer.DATE_TAG.equals(pLocalName)) { return new DateParser(pFormat); } else { return super.getParser(pConfig, pContext, pURI, pLocalName); } } public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException { if (pObject instanceof Date) { return new DateSerializer(newFormat()); } else { return super.getSerializer(pConfig, pObject); } } } ----------------------------------------------------------------------------------- On the client side, we've got to tell the {{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpcClient}} to use the new factory. That's as simple as typing ----------------------------------------------------------------------------------- XmlRpcClient client = new XmlRpcClient(); client.setTypeFactory(new MyTypeFactory()); ----------------------------------------------------------------------------------- Things are a little bit more difficult on the server side. Basically all we need to do is setting the type factory on the {{{apidocs/org/apache/xmlrpc/server/XmlRpcServer.html}XmlRpcServer}}. The question is, how to obtain the server object. That depends on the environment. If you are using the XmlRpcServlet, then you've got to derive a subclass: ----------------------------------------------------------------------------------- import org.apache.xmlrpc.webserver.XmlRpcServletServer; import org.apache.xmlrpc.webserver.XmlRpcServlet; public class MyXmlRpcServlet extends XmlRpcServlet { protected XmlRpcServletServer newXmlRpcServer(ServletConfig pConfig) { XmlRpcServletServer server = super.newXmlRpcServer(pConfig); server.setTypeFactory(new MyTypeFactory(server)); return server; } } ----------------------------------------------------------------------------------- And, if you are using the {{{apidocs/org/apache/xmlrpc/webserver/WebServer.html}WebServer}}, you've got to override a similar method: ----------------------------------------------------------------------------------- import java.net.InetAddress; import org.apache.xmlrpc.server.XmlRpcStreamServer; import org.apache.xmlrpc.webserver.WebServer; public class MyWebServer extends WebServer { public MyWebServer(int pPort) { super(pPort); } public MyWebServer(int pPort, InetAddress pAddr) { super(pPort, pAddr); } protected XmlRpcStreamServer newXmlRpcStreamServer() { XmlRpcStreamServer server = new ConnectionServer(); server.setTypeFactory(new MyTypeFactory()); return server; } } ----------------------------------------------------------------------------------- apache-xmlrpc-3.1.3-src/src/site/apt/client.apt100644 0 0 34342 11333307154 16507 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ ------------------------- The Apache XML-RPC Client ------------------------- The XmlRpcClient Before talking to an XML-RPC server, you need an instance of {{{apidocs/org/apache/xmlrpc/client/XmlRpcClient.html}XmlRpcClient}}. The XmlRpcClient is a stateless, thread safe object. The clients configuration occurs by setting the following objects: *------------------+--------------------------------------------------------------+ | Name | Description | *------------------+--------------------------------------------------------------+ | ClientConfig | This object is an instance of | | | {{{apidocs/org/apache/xmlrpc/client/XmlRpcClientConfig.html} | | | XmlRpcClientConfig}}. It has a lot of atomic properties, | | | that specify details like server URL, credentials, character | | | set, and the like. | *------------------+--------------------------------------------------------------+ | TransportFactory | The task of the transport factory is to create an object, | | | which uses the client configuration for talking to the | | | server. For example, there is a transport factory, which | | | uses the java.net classes. Another example is a transport | | | factory based on the Jakarta Commons Http Client. However, | | | transport factories don't need to use HTTP: An excellent | | | example is the local transport factory, which talks to an | | | embedded server. This last factory is, of course, very | | | useful for debugging. | *------------------+--------------------------------------------------------------+ | XmlWriterFactory | The XmlWriter is an object, which creates XML for you. | | | Typically, you do not need to care for this object, because | | | the defaults should be fine. However, it is useful, if you | | | need a special XML syntax. | *------------------+--------------------------------------------------------------+ So, let's have a look at a first example: ----------------------------------------------------------------------------------- import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://127.0.0.1:8080/xmlrpc")); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); Object[] params = new Object[]{new Integer(33), new Integer(9)}; Integer result = (Integer) client.execute("Calculator.add", params); ----------------------------------------------------------------------------------- In other words, we invoke the remote method , passing the arguments 2 and 3. Hopefully, we know . :-) The Transport Factory The above example uses the java.net.URLConnection classes to talk to the server. What, if you'd prefer to use the {{{http://jakarta.apache.org/commons/httpclient} Jakarta HTTP Client}}? There's basically just a single line, you'd need to add: ----------------------------------------------------------------------------------- import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://127.0.0.1:8080/XmlRpcServlet")); XmlRpcClient client = new XmlRpcClient(); client.setTransportFactory(new XmlRpcCommonsTransportFactory(client)); client.setConfig(config); Object[] params = new Object[]{new Integer(2), new Integer(3)}; Integer result = (Integer) client.execute("Calculator.add", params); ----------------------------------------------------------------------------------- In other words, the transport factory determines the way, how the client communicates with the server. The most important transport factories are: *--------------------------------+-------------------------------------------+ | Name | Description | *--------------------------------+-------------------------------------------+ | XmlRpcSunHttpTransportFactory | This is the default factory, connecting | | | to an HTTP server using the | | | <<>>. | *--------------------------------+-------------------------------------------+ | XmlRpcCommonsTransportFactory | Another HTTP transport factory, which | | | uses the Jakarta Commons HttpClient. | | | The main advantage over the default | | | factory is, that the Commons HttpClient | | | allows direct access to the result | | | document. This allows a much lower | | | memory profile. | *--------------------------------+-------------------------------------------+ | XmlRpcLiteHttpTransportFactory | Yet another HTTP transport factory, which | | | is based on an own and very lightweight | | | HTTP client. It is possibly the fastest | | | of the HTTP transport factories. On the | | | other hand, it doesn't support HTTP/1.1, | | | thus cannot use keepalive connections. | *--------------------------------+-------------------------------------------+ | XmlRpcLocalTransportFactory | This transport factory has an embedded | | | XML-RPC server, which is invoked via | | | direct Java calls. This is particularly | | | useful for debugging and development. | *--------------------------------+-------------------------------------------+ The Client Configuration The transport factory uses the clients configuration. Obviously, the clients configuration depends on the transport factory. In particular, different transport factories depend on different configuration types: * The HTTP transport factories need an instance of <<>>. * The local transport factory requires an instance of <<>>. For convenience, you can simply use the <<>>, which implements both interfaces. Let's have a look at the various properties, which HTTP client configurations accept: *-----------------------+---------------------------------------------------+ | Property Name | Description | *-----------------------+---------------------------------------------------+ | basicUserName | The user name and password, if your HTTP server | | basicPassword | requires basic authentication. | *-----------------------+---------------------------------------------------+ | basicEncoding | Specifies the encoding being used to create the | | | base 64 encoded Authorization header, which is | | | being used for basic authentication. | | | | | | By default, the value of the encoding property | | | is used. The encoding property itself defaults to | | | UTF-8. | *-----------------------+---------------------------------------------------+ | contentLengthOptional | Enables the faster and memory saving streaming | | | mode: The client will not set the content-length | | | header and the request is directly written to the | | | HTTP requests output stream. The XML-RPC | | | specification requires setting a content-length | | | header. For that reason, the streaming mode is | | | only available, if the property | | | enabledForExtensions is set was well. | *-----------------------+---------------------------------------------------+ | enabledForExceptions | Whether the client should request, that the | | | server returns exceptions as serializable objects.| | | If the server does, then the client will | | | deserialize such exceptions and throw them, as | | | if they had been cause within the clients code. | *-----------------------+---------------------------------------------------+ | enabledForExtensions | Whether the vendor extensions of Apache XML-RPC | | | should be enabled. By default, Apache XML-RPC is | | | strictly compliant to the XML-RPC specification. | | | Unfortunately, this specification has serious | | | limitations. For example, it requires setting a | | | content-length header. This enforces writing the | | | XML-RPC request and response to byte arrays, | | | before sending them over the net. | | | | | | Vendor extensions include the very fast and | | | memory saving streaming mode (by disabling the | | | content-length header), the compression of | | | request and/or response. In particular, a lot of | | | additional data types may be transmitted, when | | | extensions are enabled: longs, shorts, bytes, | | | floats, DOM nodes, instances of | | | java.io.Serializable, or JAXB objects. | *-----------------------+---------------------------------------------------+ | encoding | Sets the encoding, which is used for creating the | | | XML-RPC request. The default encoding is UTF-8. | | | | | | Typically, the encoding is also used for the | | | basic authentications, if any. However, you may | | | specify a different encoding for the credentials | | | using the basicEncoding property. | *-----------------------+---------------------------------------------------+ | gzipCompressing | Whether the XML-RPC request should be compressed. | | | Request compression is violating the XML-RPC | | | specification, that's why gzipCompressing is only | | | available, if the enabledForExtension property is | | | also set. For the same reason, you should not | | | assume, that the server is able to handle | | | compressed requests, unless you know, that the | | | server is itself running version 3 of | | | Apache XML-RPC. | *-----------------------+---------------------------------------------------+ | gzipRequesting | Requests, that the server will be compressing the | | | response. Response compression is violating the | | | XML-RPC specification. Therefore, this feature is | | | only available, if the enabledForExtension | | | property is set. Also, do not assume, that the | | | server will actually compress the response, | | | unless it is an Apache XML-RPC 3 server. | *-----------------------+---------------------------------------------------+ And these properties are for configuring the local transport factory: *-----------------------+---------------------------------------------------+ | Property Name | Description | *-----------------------+---------------------------------------------------+ | xmlRpcServer | This is the embedded XML-RPC server, which is | | | called to execute the clients requests. | | | Obviously, this is an extremely fast transport. | | | However, its main use is for debugging and | | | development. | *-----------------------+---------------------------------------------------+ apache-xmlrpc-3.1.3-src/src/site/apt/contributing.apt100644 0 0 3475 11333307154 17723 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ ------------ Contributing ------------ Contributing A great {{{http://jakarta.apache.org/site/contributing.html}description}} of contributing to Apache XML-RPC is available from the Jakarta project. Submitting Patches The preferred patch format is unidiff. The best way to generate a patch is by checking out the sources, applying your changes and running --------------------------------------------------------------------------------- svn diff --------------------------------------------------------------------------------- Emails containing patches should be sent to the mailing list xmlrpc-dev@ws.apache.org, and prefix their subject lines with <<[PATCH]>>. Patches are also accepted via the {{{http://issues.apache.org/jira/browse/XMLRPC}issue tracker}}. The Jakarta project provides a description of {{{http://jakarta.apache.org/site/source.html}life with ASF source code}} -- look for the <> section. apache-xmlrpc-3.1.3-src/src/site/apt/download.apt100644 0 0 2417 11333307154 17016 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ --------- Downloads --------- Downloading Apache XML-RPC You can download the current version of Apache XML-RPC from {{{http://www.apache.org/dyn/closer.cgi/ws/xmlrpc/} distribution directory}}. Alternatively, you can get the latest code snapshot via {{{http://svn.apache.org/repos/asf/webservices/xmlrpc/trunk}Subversion}}. Information on how to build and use the software is included in the package. apache-xmlrpc-3.1.3-src/src/site/apt/extensions.apt100644 0 0 17171 11333307154 17431 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ -------------------------------- Apache XML-RPC Vendor Extensions -------------------------------- Introduction The {{{http://www.xmlrpc.com/spec}XML-RPC specification}} has been published in 1999. In the past 6 years, it was subject to some minor corrections. Some things have been made clearer. However, it hasn't really changed or evolved. Dave Winer, the XML-RPC specifications author, has always rejected any suggestions in that direction. Of course, he did so with a good reason: One of XML-RPC's major targets was portability over arbitrary platforms and programming languages. Clearly, this target has been met and any further development would mean putting this at risk. On the other hand, this is most unfortunate: Obeying the specification means accepting really serious limitations. For example, one cannot even use all of Java's primitive data types, although nowadays they have equivalents in almost any programming language. Possibly even more important is the requirement to send a content-length header: HTTP/1.1 and its chunk encoding are the definite standard in 2005 for both HTTP clients and servers. Consequently, the content-length header is, at best, superfluos. Of course, having an additional header wouldn't be too much of a problem. But calculating the header value enforces, that request and response are written to byte arrays, before actually sending them. This is both slow and memory consuming. Version 3 of Apache XML-RPC is a compromise: By default it still meets the specification. However, you <> enable additional features, called vendor extensions. Of course, these features only work, if you have a streaming version of Apache XML-RPC on both sides. In practice, it occurs very frequently, that both sides are controlled by the same people. Besides, the vendor extensions are documented very clearly here: Adding these features to an existing XML-RPC library would mean almost no effort, so possibly someone does. You'r welcome. But the purpose of this document is more than documentation: It is also to receive feedback and discuss the extensions specification and implementation. Nothing is fixed, and everything can be changed. Enabling extensions Vendor extensions cannot be used, unless they are explicitly enabled. In some cases, you have to enable specific features, for example request compression. But in all cases, you need to enable the use of vendor extensions at all, because that is the step, where you knowingly say: "I know, I am now in violation of the original XML-RPC specification." For that reasons, both server and client have a property <<>> in their respective configuration. Setting this property to true enables the extensions. Streaming Mode Putting the client or the server into streaming mode means, that data being sent to the other side is almost directly written to the network connection. (Besides, of course, using a moderately sized <<>>, because one would not want to have a network connection for any <<>> call.) In particular, the request, or response, isn't written to a <<>> internally. Without streaming mode, this is always the case. But there is more: For example, the base64 encoder is also writing directly without internal buffering. (There are few other base64 encoders around, which support streaming mode.) To enable streaming mode on the client, set the properties <<>> and <<>>. This will take care for the request, which is being sent to the server. On the server, things are a little bit more complicated. Currently, the server behaves as follows: If streaming mode is disabled, then the server will always behave like a standard XML-RPC server. Otherwise, the server will verify, whether the client sends a content-length header. If so, then the server assumes that the client is able to accept a missing content-length header in the response as well. Otherwise, the server will still disable streaming for this particular requests. In other words, traditional clients will still receive a traditional response and one server can serve both data types. Compression HTTP Request compression is a standard HTTP feature and works by using the HTTP headers <<>> and <<>>. In other words, it is quite likely, that request compression is supported by your HTTP client or server library. For example, the Apache httpd does so by using the <<>> module. Of course, it's more convenient to have the XML-RPC library doing this. If the client should compress the response, then you need to set the properties <<>> and <<>>. The XML-RPC request will be compressed (on-the-fly in streaming mode, of course) and the HTTP header <<>> will be set to <<>>. Needless to say, you may only do so, if the server is ready to accept such requests. Compressing the request doesn't mean that the response is compressed as well. First of all, the server will only send a compressed response, if the server property <<>> is set. Additionally, the server will read the HTTP header <<>>: If it doesn't contain <<>> encoding, then compression cannot take place. In other words, the client must send this header. You need to set the client properties <<>> and <<>> to achieve that. Data Types Enabling vendor extensions means also, that several additional data types may be sent. (See {{{./types.html}Data Types}} for details.) These different data types require an extension of the XML-RPC network protocol. All of these data types are using a special XML namespace. Using this namespace is a clear indication, that these data types are in violation to the XML-RPC specification. For example, sending an integer value looks like the following: ---------------------------------------------------------------------------- 347 ---------------------------------------------------------------------------- 32 bit integers are valid data types in XML-RPC. So we do not need to use a separate namespace here. 64 bit integers aren't valid XML-RPC data types. So we need to use our namespace when sending them: ---------------------------------------------------------------------------- 78934 ---------------------------------------------------------------------------- Exception Handling If the server property "enabledForExceptions" is turned on, then the server will convert exceptions into a byte array and send them to the client within a "faultCause" message. apache-xmlrpc-3.1.3-src/src/site/apt/index.apt100644 0 0 3425 11333307154 16316 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ -------------- Apache XML-RPC -------------- About Apache XML-RPC Apache XML-RPC is a Java implementation of {{{http://www.xmlrpc.com/}XML-RPC}}, a popular protocol that uses XML over HTTP to implement remote procedure calls. Version 3 of Apache XML-RPC is still compliant to the {{{http://www.xmlrpc.com/spec}XML-RPC specification}}. However, the user may enable several vendor extensions are available, that greatly extend the power of XML-RPC: * All primitive Java types are supported, including long, byte, short, and double. * Calendar objects are supported. In particular, timezone settings, and milliseconds may be sent. * DOM nodes, or JAXB objects, can be transmitted. So are objects implementing the java.io.Serializable interface. * Both server and client can operate in a streaming mode, which preserves resources much better than the default mode, which is based on large internal byte arrays. apache-xmlrpc-3.1.3-src/src/site/apt/introspection.apt100644 0 0 6172 11333307154 20111 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ --------------------------- Advanced Programming Topics --------------------------- Apache XML-RPC supports XML-RPC introspection, as specified by {{{http://scripts.incutio.com/xmlrpc/introspection.html} http://scripts.incutio.com/xmlrpc/introspection.html}}. This page describes how to configure the XML-RPC server for introspection. What is introspection? Introspection is the servers ability to provide metadata to the client. The client may ask "What method names does the server offer?", "How do I invoke method 'foo'?", or "Can you give me help on method 'foo'?". The client does so by invoking the special methods "system.listMethods", "system.methodSignature" and "system.methodHelp". These are described in detail in the non-official specification for XML-RPC introspection, which you'll find at {{{http://scripts.incutio.com/xmlrpc/introspection.html} http://scripts.incutio.com/xmlrpc/introspection.html}}. How do I configure the server for introspection? The server requires a special mapping. Basically, you simply add a "system" handler, which is implemented by the class <<>>. Here's how you would do that in the <<>>: --------------------------------------------------------- public class MyXmlRpcServlet extends XmlRpcServlet { protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = (PropertyHandlerMapping) newXmlRpcHandlerMapping(); XmlRpcSystemImpl.addSystemHandler(mapping); } } --------------------------------------------------------- Quite similar, you would override a protected method, if you prefer using the <<>> class: --------------------------------------------------------- public class MyWebServer extends WebServer { public MyWebServer(int pPort) { super(pPort); } protected XmlRpcStreamServer newXmlRpcStreamServer(){ XmlRpcStreamServer xmlRpcStreamServer = new ConnectionServer(); PropertyHandlerMapping mapping = (PropertyHandlerMapping) xmlRpcStreamServer.getHandlerMapping(); XmlRpcSystemImpl.addSystemHandler(mapping); return xmlRpcStreamServer; } } --------------------------------------------------------- apache-xmlrpc-3.1.3-src/src/site/apt/links.apt100644 0 0 3006 11333307154 16322 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ -------------------------------- External Links -------------------------------- Below you'll find some links to external sources, that deal with Apache XML-RPC. Specifications * The {{{http://www.xmlrpc.com/spec}XML-RPC specification}} Examples and Tutorials * A simple, yet complete example of using the XmlRpcServlet by {{{http://radioae6rt.wordpress.com/2006/04/23/running-an-xml-rpc-server-as-a-java-servlet/}Mark Petrovic}} * An example of initializing handlers by using so-called persistent objects, written by {{{http://blog.buttermountain.co.uk/2006/11/06/accessing-persistent-objects-with-apache-ws-xmlrpc-30-a-documented-example/}Iain Bullard}}. apache-xmlrpc-3.1.3-src/src/site/apt/server.apt100644 0 0 37461 11333307154 16544 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ ------------------------- The Apache XML-RPC Server ------------------------- Server-side XML-RPC If you have read and understood the previous document about the {{{./client.html}Apache XML-RPC client}}, then the server isn't too much news. First of all, there is an object, called the XmlRpcServer. This objects purpose is to receive and execute XML-RPC calls by the clients. The XmlRpcServer <> be embedded into a servlet container, or another HTTP server (for example, the minimal web server, that comes with XML-RPC), but it doesn't need to. Take the local transport as an example: In that case the XML-RPC server is simply embedded into the client application. Like the XmlRpcClient, the XmlRpcServer needs a configuration, which is given by the XmlRpcServerConfigImpl object. The XML-RPC Servlet The easiest way to create an XML-RPC Server is the XmlRpcServlet, which has an automatically embedded instance of XmlRpcServer. This servlet allows you to create a server within 10 minutes or so: [[1]] Create a class, or a set of classes, which are implementing the remote procedure calls. Here's an example of such a class: ----------------------------------------------------------------------------------- package org.apache.xmlrpc.demo; public class Calculator { public int add(int i1, int i2) { return i1 + i2; } public int subtract(int i1, int i2) { return i1 - i2; } } ----------------------------------------------------------------------------------- This class has two public, non-static methods, which should be available to the clients. [[2]] Create a property file, which contains at least one property. The property name is arbitrary, and the property value is the fully qualified name of the Calculator class. For example, like that: ----------------------------------------------------------------------------------- Calculator=org.apache.xmlrpc.demo.Calculator ----------------------------------------------------------------------------------- The property file must be called <<>>, and it must be located in the package org.apache.xmlrpc.webserver. In other words, you would typically put it into the directory org/apache/xmlrpc/webserver and add it to your jar file. [[3]] Add entries like the following to your war files web.xml: ----------------------------------------------------------------------------------- XmlRpcServlet org.apache.xmlrpc.webserver.XmlRpcServlet enabledForExtensions true Sets, whether the servlet supports vendor extensions for XML-RPC. XmlRpcServlet /xmlrpc ----------------------------------------------------------------------------------- That's it! You have just created your first XML-RPC server. :-) The Server configuration Unlike in the case of the clients configuration, there isn't much to configure on the server. The reason is, that most things depend on the client and the HTTP headers, which are received by the client. There is one very important property to configure, though: *-----------------------+---------------------------------------------------+ | Property Name | Description | *-----------------------+---------------------------------------------------+ | enabledForExceptions | If the server catches an exception, and this | | | property is set, then the server will convert | | | the exception into a byte array (by using an | | | ObjectOutputStream) and return the exception to | | | the client. Note, that this may have privacy | | | or even security implications, because Exceptions | | | may contain arbitrary Java objects, which you | | | possibly do not want to be sent to the client. | *-----------------------+---------------------------------------------------+ | enabledForExtensions | Whether the vendor extensions of Apache XML-RPC | | | should be enabled. By default, Apache XML-RPC is | | | strictly compliant to the XML-RPC specification. | | | | | | Enabling this property doesn't indicate, that the | | | server is unable to serve requests by standard | | | clients: In contrary, the servers behaviour | | | depends on the client. Setting this property to | | | true will only advice the server, that it <> | | | accept requests, which ask for vendor extensions. | | | | | | For example, if a client sends a content-length | | | header, then the server assumes, that the client | | | <> a content-length header in the request | | | and disables the streaming mode. | *-----------------------+---------------------------------------------------+ Basic Authentication Basic authentication is frequently used to authenticate and authorize users. Within Apache XML-RPC, basic authentication is done by the {{{apidocs/org/apache/xmlrpc/XmlRpcHandler.html}XmlRpcHandler}}. The handler receives an instance of {{{apidocs/org/apache/xmlrpc/XmlRpcRequest.html}XmlRpcRequest}}. This object has a method <<>>, which returns an instance of {{{apidocs/org/apache/xmlrpc/XmlRpcRequestConfig.html}XmlRpcRequestConfig}}. If you are running within a HTTP server, then the request configuration may be casted to an instance of {{{apidocs/org/apache/xmlrpc/common/XmlRpcHttpRequestConfig.html}XmlRpcHttpRequestConfig}}. This object has methods <<>>, and <<>>, which provide the necessary details. In other words: Your task is to provide your own instance of {{{apidocs/org/apache/xmlrpc/server/XmlRpcHandlerMapping.html}XmlRpcHandlerMapping}}, which creates your own handlers. And your own handlers are responsible to validate the basic authentication details. Here's an example servlet, which overrides the default {{{apidocs/org/apache/xmlrpc/server/PropertyHandlerMapping.html}PropertyHandlerMapping}}. ----------------------------------------------------------------------------------- public class MyServlet extends XmlRpcServlet { private boolean isAuthenticated(String pUserName, String pPassword) { return "foo".equals(pUserName) && "bar".equals(pPassword); } protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = (PropertyHandlerMapping) super.newXmlRpcHandlerMapping(); AbstractReflectiveHandlerMapping.AuthenticationHandler handler = new AbstractReflectiveHandlerMapping.AuthenticationHandler(){ public boolean isAuthorized(XmlRpcRequest pRequest){ XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig(); return isAuthenticated(config.getBasicUserName(), config.getBasicPassword()); }; }; mapping.setAuthenticationHandler(handler); return mapping; } } ----------------------------------------------------------------------------------- The WebServer class The {{{apidocs/org/apache/xmlrpc/webserver/WebServer.html}WebServer}} is a minimal HTTP server, that might be used as an embedded web server. Use of the WebServer has grown very popular amongst users of Apache XML-RPC. Why this is the case, can hardly be explained, because the WebServer is at best a workaround, compared to full blown servlet engines like Tomcat or Jetty. For example, under heavy load it will almost definitely be slower than a real servlet engine, because it does neither support proper keepalive (multiple requests per physical connection) nor chunked mode (in other words, it cannot stream requests). If you still insist in using the WebServer, it is recommended to use its subclass, the {{{apidocs/org/apache/xmlrpc/webserver/ServletWebServer.html}ServletWebServer}} instead, which offers a minimal subset of the servlet API. In other words, you keep yourself the option to migrate to a real servlet engine later. Use of the WebServer goes roughly like this: First of all, create a property file (for example "MyHandlers.properties") and add it to your jar file. The property keys are handler names and the property values are the handler classes. Once that is done, create an instance of WebServer. ----------------------------------------------------------------------------------- package org.apache.xmlrpc.demo.webserver; import java.net.InetAddress; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.demo.webserver.proxy.impls.AdderImpl; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.WebServer; public class Server { private static final int port = 8080; public static void main(String[] args) throws Exception { WebServer webServer = new WebServer(port); XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); /* Load handler definitions from a property file. * The property file might look like: * Calculator=org.apache.xmlrpc.demo.Calculator * org.apache.xmlrpc.demo.proxy.Adder=org.apache.xmlrpc.demo.proxy.AdderImpl */ phm.load(Thread.currentThread().getContextClassLoader(), "MyHandlers.properties"); /* You may also provide the handler classes directly, * like this: * phm.addHandler("Calculator", * org.apache.xmlrpc.demo.Calculator.class); * phm.addHandler(org.apache.xmlrpc.demo.proxy.Adder.class.getName(), * org.apache.xmlrpc.demo.proxy.AdderImpl.class); */ xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); webServer.start(); } } ----------------------------------------------------------------------------------- The Calculator class can be found above. The Adder and AdderImpl classes can be found in the {{{advanced.html}proxy example}}. Jimisola Laursen, who provided the above example, has also supplied an example for the client: ----------------------------------------------------------------------------------- package org.apache.xmlrpc.demo.client; import java.net.MalformedURLException; import java.net.URL; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; import org.apache.xmlrpc.client.util.ClientFactory; import org.apache.xmlrpc.demo.proxy.Adder; public class Client { public static void main(String[] args) throws Exception { // create configuration XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://127.0.0.1:8080/xmlrpc")); config.setEnabledForExtensions(true); config.setConnectionTimeout(60 * 1000); config.setReplyTimeout(60 * 1000); XmlRpcClient client = new XmlRpcClient(); // use Commons HttpClient as transport client.setTransportFactory( new XmlRpcCommonsTransportFactory(client)); // set configuration client.setConfig(config); // make the a regular call Object[] params = new Object[] { new Integer(2), new Integer(3) }; Integer result = (Integer) client.execute("Calculator.add", params); System.out.println("2 + 3 = " + result); // make a call using dynamic proxy ClientFactory factory = new ClientFactory(client); Adder adder = (Adder) factory.newInstance(Adder.class); int sum = adder.add(2, 4); System.out.println("2 + 4 = " + sum); } } ----------------------------------------------------------------------------------- The ServletWebServer class This is a subclass of the standalone WebServer, which offers a minimal servlet API. It is recommended to use this class, rather than the WebServer, because it offers you a smooth migration path to a full blown servlet engine. Use of the {{{apidocs/org/apache/xmlrpc/webserver/ServletWebServer.html}ServletWebServer}} goes like this: First of all, create a servlet. It may be an instance of {@link XmlRpcServlet} or a subclass thereof. Note, that servlets are stateless: One servlet may be used by multiple threads (aka requests) concurrently. In other words, the servlet must not have any instance variables, other than those which are read only after the servlets initialization. The XmlRpcServlet is by default using a property file named <<>>. See the {{{apidocs/org/apache/xmlrpc/server/PropertyHandlerMapping.html}PropertyHandlerMapping}} for details on the property file. ----------------------------------------------------------------------------------- package org.apache.xmlrpc.demo.webserver; import java.net.InetAddress; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.demo.webserver.proxy.impls.AdderImpl; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.ServletWebServer; public class ServletServer { private static final int port = 8080; public static void main(String[] args) throws Exception { XmlRpcServlet servlet = new XmlRpcServlet(); ServletWebServer webServer = new ServletWebServer(servlet, port); webServer.start(); } } ----------------------------------------------------------------------------------- apache-xmlrpc-3.1.3-src/src/site/apt/ssl.apt100644 0 0 14602 11333307154 16027 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ --------- Using SSL --------- This page describes how to configure a client for using SSL (aka https). Server configuration is out of this documents scope, because it clearly depends on the webserver. We refer, for example, to the {{{http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html} Tomcat SSL HowTo}} or to the FAQ entry on {{{http://docs.codehaus.org/display/JETTY/How+to+configure+SSL} SSL with Jetty}}. Background Client configuration for SSL is not as simple as one might expect. This is surprising, because using SSL with a browser is as simple as typing in an https URL into the browsers input field. Thus, the first thing to keep in mind: Never start with Apache XML-RPC as a client. It is much better to create a simple static page and point your browser to the static pages URL. If you get this working, then you may assume that all remaining problems rest with the client. If you did that, you may have noticed, that the browser brings up a warning, that your web server is "not trusted". This is typically the case, if you did not buy a certificate: For the case of simplicity, developers are typically creating a so-called "self-signed certificate". And that's exactly your most likely problem: Like pressing the browsers button to "Accept the certificate" (temporarily or permanently), you've got to tell your Java client, that you want to accept the certificate. Choose the right URL Typically, your server may be accessible with multiple URL's. For example, on my machine the following URL's will all reach the same servlet: https://mcjwi.eur.ad.sag/xmlrpc https://localhost/xmlrpc https://127.0.0.1/xmlrpc Unfortunately, at most one will work in the most cases. The question is: How do I choose the right one? The answer is given by the certificate field CN. For example, my self certified key looks like this: Owner: CN=mcjwi.eur.ad.sag, OU=-, O=-, L=-, ST=-, C=- Issuer: CN=mcjwi.eur.ad.sag, OU=-, O=-, L=-, ST=-, C=- Note, that you've got to pick a proper CN when generating the certificate! If you are self-certifying the key and the keytool asks you for your own name: Ignore it. In your case the proper reply is the host name. The quick and dirty solution Yes, there is a quick and dirty solution: Just tell your client, that you want to accept any certificate, regardless of issuer and host. This can be done by installing a custom TrustManager and a HostnameVerifier. Add the following code to your clients initialization: ----------------------------------------------------------------------------------- import java.security.cert.X509Certificate; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { // Trust always } public void checkServerTrusted(X509Certificate[] certs, String authType) { // Trust always } } }; // Install the all-trusting trust manager SSLContext sc = SSLContext.getInstance("SSL"); // Create empty HostnameVerifier HostnameVerifier hv = new HostnameVerifier() { public boolean verify(String arg0, SSLSession arg1) { return true; } }; sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hv); ----------------------------------------------------------------------------------- The recommended solution Needless to say, the quick and dirty solution may is insecure, because it can your requests can be intercepted by a man-in-the-middle attack. Fortunately, there is also a clean solution: Import the servers public key into your truststore. As a first step, you've got to obtain the servers public key. Assuming, that the key is in your keystore, you may export it by running ----------------------------------------------------------------------------------- keytool -export -alias tomcat -rfc -file tomcat.crt ----------------------------------------------------------------------------------- This example would export the public key named "tomcat" (which is used by Tomcat) into the file "tomcat.crt". The key would be read from your default keystore, which is the file .keystore in your home directory (something like "c:\Documents and Settings\jwi\.keystore" on windows or "/home/jwi/.keystore" on Linux/Unix). Obviously, this first step must be done on the server. The second step would be to create a truststore on your client by importing the file "tomcat.crt": ----------------------------------------------------------------------------------- keytool -import -alias servercert -file tomcat.crt -keystore truststore ----------------------------------------------------------------------------------- The option "-keystore truststore" specifies a file name. Of course, this may as well be an absolute path. apache-xmlrpc-3.1.3-src/src/site/apt/types.apt100644 0 0 16561 11333307154 16400 0ustar 0 0 ~~ ~~ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ ------------------ XML-RPC Data Types ------------------ Data Types The {{{http://www.xmlrpc.com/spec}XML-RPC specification}} defines the following available data types: *--------------------+--------------------+-------------------------------------+ | Java Type | XML Tag Name | Description | *--------------------+--------------------+-------------------------------------+ | Integer | , or | A 32-bit, signed, and non-null, | | | | integer value. | *--------------------+--------------------+-------------------------------------+ | Boolean | | A non-null, boolean value (0, or | | | | 1). | *--------------------+--------------------+-------------------------------------+ | String | | A string, non-null. | *--------------------+--------------------+-------------------------------------+ | Double | | A signed, non-null, double | | | | precision, floating point number. | | | | (64 bit) | *--------------------+--------------------+-------------------------------------+ | java.util.Date | | A pseudo ISO8601 timestamp, like | | | | 19980717T14:08:55. However, | | | | compared to a true ISO8601 value, | | | | milliseconds, and time zone | | | | informations are missing. | *--------------------+--------------------+-------------------------------------+ | byte[] | | A base64 encoded byte array. | *--------------------+--------------------+-------------------------------------+ | java.util.Map | | A key value pair. The keys are | | | | strings. The values may be any | | | | valid data type, including another | | | | map. | *--------------------+--------------------+-------------------------------------+ | Object[] | | An array of objects. The array | | java.util.List | | elements may be any valid data | | | | type, including another array. | | | | | | | | The server may return other arrays (for | | | example String[]) or lists (using | | | | generics). However, the client will | | | | always return an Object[], because | | | | the XML-RPC protocol doesn't include| | | | between different array types. | *--------------------+--------------------+-------------------------------------+ If the property <<>> is set, then additional data types become valid. (Both client and server do support this property.) *----------------------+--------------------+-------------------------------------+ | Java Type | XML Tag Name | Description | *----------------------+--------------------+-------------------------------------+ | None | | A typeless null value. | *----------------------+--------------------+-------------------------------------+ | Byte | | A 8-bit, signed, and non-null, | | | | integer value. | *----------------------+--------------------+-------------------------------------+ | Float | | A signed, non-null, double | | | | precision, floating point number. | | | | (32 bit) | *----------------------+--------------------+-------------------------------------+ | Long | | A 64-bit, signed, and non-null, | | | | integer value. | *----------------------+--------------------+-------------------------------------+ | org.w3c.dom.Node | | A DOM node, which is being | | | | transmitted as an embedded XML | | | | fragment. | *----------------------+--------------------+-------------------------------------+ | Short | | A 16-bit, signed, and non-null, | | | | integer value. | *----------------------+--------------------+-------------------------------------+ | java.io.Serializable | | An object, which is converted into | | | | a serialized representation and | | | | transmitted as a base 64 encoded | | | | byte array. | *----------------------+--------------------+-------------------------------------+ | BigDecimal | | A BigDecimal | *----------------------+--------------------+-------------------------------------+ | BigInteger | | A BigInteger | *----------------------+--------------------+-------------------------------------+ | java.util.Calendar | | Unlike the dateTime.iso8601 type, | | | | this is a full blown xs:dateTime | | | | value. In particular, it includes | | | | milliseconds, and timezone settings.| *----------------------+--------------------+-------------------------------------+ In the above table, the prefix <<>> refers to the namespace URI <<>>. apache-xmlrpc-3.1.3-src/src/site/fml/faq.fml100644 0 0 26627 11333307155 15774 0ustar 0 0 Why do I receive a ClassCastException, if the server returns an array?

The problem is typically caused by code like the following:

The problem is in the fact, that the XML-RPC response tells the client, that the server returns an array. It doesn't tell what type the array has. In other words, the client will always receive an object array. The workaround is to use code like the following:

How do I enable request compression?

That's simple: Set the properties "enabledForExtensions" and "gzipCompressing". That said, note the following hints:

  • Setting these properties will only work, if the XML-RPC server is aware of request compression. Compression is a violation of the XML-RPC specification, so typically the server will refuse the request, unless it is an Apache XML-RPC server with version 2 or later. (Apache XML-RPC 2 supports request compression, although it was officially designed to be strictly compliant to the XML-RPC specification. However, noone was aware, that compression violates the specification. :-)
  • Compressing the request doesn't mean that the response will also be compressed. You need to request response compression to achieve that.
  • Additionally, be aware of the following: Compression depends on HTTP/1.1 features. In particular, you must not use the LiteHttpTransport.
How do I enable response compression?

That's as simple as enabling request compression: Set the properties "enabledForExtensions" and "gzipRequesting". That said, note the following hints:

  • Requesting gzip compression is a standard HTTP feature. In other words, you may safely request compression from any XML-RPC server, even if it doesn't run Apache XML-RPC.
  • However, requesting compression doesn't necessarily mean, that the response *is* compressed. It depends on the server.
  • Additionally, be aware of the following: Compression depends on HTTP/1.1 features. In particular, you must not use the LiteHttpTransport.
Is it possible to specify a timeout, after which the client stops waiting for the servers response?

Yes, use the class TimingOutCallback.

I've got a server, which is expecting a non-standard date format. How can I ensure, that my date values have the right format?

You've got to use a special type factory. An example is contained in the documentation on {{{advanced.html}advanced topics}}.

I've got a server, which is expecting a non-standard double format. How can I ensure, that my double values have the right format?

You've got to use a special type factory. An example is contained in the documentation on {{{advanced.html}advanced topics}}.

I am using Java 1.4 (or Java 1.5, or later). Can I use javax.net.ssl.SSLSocketFactory? (Or the java.net.Proxy?)

Yes, you can. Use the org.apache.xmlrpc.client.XmlRpcSun14HttpTransportFactory. (Or the org.apache.xmlrpc.client.XmlRpcSun15HttpTransportFactory.)

The XmlRpcClient will detect the Java version you are using and automatically create the respective factory. In other words, all you need to do is cast the XmlRpcTransportFactory to the proper class. For example:

XmlRpcClient myClient; XmlRpcTransportFactory factory = myClient.getTransportFactory(); ((XmlRpcSun15HttpTransportFactory) factory).setProxy(String pHost, int pPort);

With the Lite HTTP transport factory, things are slightly different: You have to explicitly create an instance of XmlRpcLite14HttpTransportFactory.

How do I reduce the servers error logging? Create a subclass of XmlRpcErrorLogger and set it on the XmlRpcStreamServer. How do I enable streaming mode?

Set the property "enabledForExtensions". Note, that enabling the streaming mode doesn't mean, that all responses are served in streaming mode. It depends on the clients:

  • If a client sends a content-length header, then the server assumes, that the client is a traditional XML-RPC application and doesn't support the vendor extensions from Apache XML-RPC. Consequently, the server assumes, that it needs to set the content-length header itself and disables the streaming mode for that particular request.
  • However, if the client doesn't send a content-length header, then the server assumes that it will be able to accept any standard HTTP/1.1 request and enable the streaming mode. Streaming mode means, in particular, that the response will not contain a content-length header.
How do I configure the server for basic authentication?

Basically you've got to provide an AuthenticationHandler. See the {{{server.html}server documentation}} for an example.

How do I initalize the request processors?

The PropertyHandlerMapping assumes, that request processors are POJO's (plain old java objects). However, this is not always desirable. For example, sometimes it is assumed that handlers need to be initialized by the servlet, which is configured through parameters.

The recommended solution is to configure your server with a special request processor factory.

public interface InitializableRequestProcessor { void init(HttpServlet pServlet) throws XmlRpcException; } public class MyXmlRpcServlet extends XmlRpcServlet { protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException { PropertyHandlerMapping mapping = new PropertyHandlerMapping(); RequestProcessorFactoryFactory factory = new RequestSpecificProcessorFactoryFactory(){ protected Object newRequestProcessor(Class pClass, XmlRpcRequest pRequest) { InitializableRequestProcessor proc = super.newRequestProcessor(pClass, pRequest); proc.init(MyXmlRpcServlet.this); return proc; } }; mapping.setRequestProcessorFactoryFactory(mapping); mapping.load(Thread.currentThread().getContextClassLoader(), url); return mapping; } }
How to I get the clients IP address in a handler?

That's a similar question than the question on initializing handlers. The main difference is, that in this case you want to initialize the handler with any request. In other words, you might achieve the goal by creating a RequestProcessorFactoryFactory, that provides the necessary details. However, there is an easier solution, which we will demonstrate here: Use a ThreadLocal.

The class ThreadLocal allows to create information at some point in the source code and use this information at one or more completely different and decoupled places. The only assumption is, that you are in the same thread. This is exactly our situation: We create the information when processing of the XML-RPC request starts and read it within the handler.

In the example below, you'd obtain the clients IP address by writing ClientInfoServlet.getClientIpAddress().

How to I get the clients IP address in a handler when using the WebServer class? Use the ServletWebServer class and see the answer to the previous question.
apache-xmlrpc-3.1.3-src/src/site/site.xml100644 0 0 4502 11333307155 15401 0ustar 0 0 Apache XML-RPC http://ws.apache.org/xmlrpc/images/xmlrpc-logo.gif http://ws.apache.org/xmlrpc/ ${reports} apache-xmlrpc-3.1.3-src/src/site/xdoc/images/feather.gif100644 0 0 7576 11333307155 20240 0ustar 0 0 GIF89a5!!!111999BBBcccsss{{{籠ބJB!ƵZ9RBk1B{RRk1R֜{{9絔sc{B{JkcskcRƽZνƭkcZJ֥{֭B)΄sZ)έέ޽c{{s{sBc99c)B!Z9kkޜ)scJkcΌ{{k1{c{ZJ!{99RRRk1!{1!"Apache Software Foundation feather,5 . B B . 0*Bđ 0B *0EC ++1-4+ܧ..B03Dɵ$/$&..1*D@B $CFaa=}%+tHH3|QsS$>2dqĈ"Q+OTf%HYq*Z`N;t̉ P m$?h )pN6jҬyƍNgB13x=q J!lgRfeƠA3F̙1iԬq:x1P$r0qC' 'b@eP30U1cƀ17uܸR>'zÇpP@ +W|ewZxw,DpՃ}D$ YԖ CW_QgNLZPZEvk&y|GT@pP’1ԡ>Ĝ 3ԇ 9L4!Mh"i]vcF >SOfLo ,ܓŴuB`E["QL!TxaWaї_mq_UPud"`}'s.@q&1ŢRd1Wg8jzkz$@84 sH*/H$+J$B]Goigx7u7jF` -pm*(@ PnDn*+`\a)αmD bB p'@HL,`MaG 2尐E[ᅀiY>V0W< 2pB @3$ = бZQDM?=ӈ Q|ݍh֝ƒKchA5C58@Dl7GB`I]D, tTJ(.a5G,C:[|zA~!jNݑGC9? l74ӶN|LOQseڋ(v1 G0ޠ0t+ MVU arD! ox0B 2Mc*R?>V ` z!wl[v()kQM8T%Y-T';h9pQ<} ,6)L 6z|j˔zp-GlX+/x2\@+9R#^"`/5ʈ%;d$;Y̤g mmp: !hA "Gەacޠ4Rze/5]G0׹E*]V󒋬`A+^*M3К6%7 rC`FXQRlC/b P ӠA{#7A)t) Qx0s-qJҗ 2.T [Y4Ն[^ ba2Dht€\@J-mJ%_YiHaѧЃ@4D=1 +hlA f`<ɠ>[G8ԇ`@+X0d(pI5;h82Y[p&ЁVFM"D`Ek Cԉ h#:t$|U`jA@ !*4TG@P׸*@zOX"Que (ʙ 1xwx4"ІZo"AALC^땲| _Z2>tAإY- M@D3z`P449ҤW'Pz`[15?)%)ذܫMAE]8TScJ$6L V \FVdڬAH `6@Q+G؀P/b | DdXa?`% W(@!ʟZak/A7 |A pAr`n@ PMF>a6#956Ffhr]0<)Tէ0'dA x_BKV,su9xs  3 AIQ- H҆+AC-/I{`P2| e&* i-6X>9~|pg]|S0Ul}ȄN a7hxI_/w'a Wsd1r|N`x$2P8:}y}y;0~ @n8jzZ &o@0jQs0ga)A "3rbp)%mBYR2Yw^dpt1:yܶy5z '~0"$@-Z0,2тYAk}aq2,DcfT"m` mTkXwht$2pu=6PZ0e80#BQ:Z^jbbr@0mWwܡwbPKibQaA6#tvcp_'qu/q> f( 9mAjEV /b5jF4($y0C$b?'/Q%ju9E'ӨaP ayuuyf(㶏&6+Bsn&PE!q*0eb iq{1-jpRBrsfPf4kWuw6r}+ym$VN`.p@p*}8BS3bzc~}Qɕ0b,8ؒ`'64s+uyh  '3oc{*}BsQ-&>Q}EH.r(ofP2iyy 76R2-g^Q"% *!p0 aZq# 9WIULyctkpf?X?DP|/E^vGKB=<^d]gQLc( rGjmoAzlvĐh(n/laZQC)D`>Bot7N*Eb)Db)')JD@x)B^s))Eb[2//4%$&,D^2Ha,Fb%(/0,-q/utA 0LTm|զ -L_VR.GbnzE` @PQ@<(+*jE*h@3@ da!ΰC9{ dz?`B!_h3eXJCR*"Lx9WFz1Bj84@8 D8#/H  FA"C's;:5iH"5U< ՘6ƅPlP$F9xDQJ|@4,3KBQ 8z+P<|Pr&u|X!1spN 4)C^$@ 2dP4 0 .p;"<,9[x#XPN?x9"IBj0hgj=B -9!q4L5! aVH, pM.Q $,5-a Ҫ{ #t3 Rs֋ s.j/P9; !s9buNyIL]}D FQV,`BB7:g#`9(G3d~su9gD=u0@)s@pdāU5U> 3׽ @$N pk'l *a8#fj6qA  P )HAyc+)F!(.Z, ae_u 0x@2D[0t'0^0*BL`p#I",#Lz9 4B r^c[c5 2 }<'"vbtGʀ$ e! a5h LR L bWx@4s 0;g,'ƥ835D&B=b4h7P4H=la 0у[h`b_nH܌ȎKoڝP Z j@t o Ȃ^ =8)֐](%C_g̳ 0A60@5Cf +0 04ܠ xluUwNZZpMì<[~u v8 [֬L/( XdphOd*Lߖva*Ya H(X 5܀mX#8tr Pa k#pueYF,0W"  p0J~fErcs=]#a/P @ 2%_4:΀Xc3V6Xy >6cK@?) py1 ŰyVp(8 4o@\[- * PPzL%gZԛj  pyd O~*ۄe~&yj-uU~Z  !PNގ.bP,m҉p3+@Oo`2  }9"` eJF ,Np ڴp ȯ lfȃ İkٽP3(μؾP7ߠa %0JP>60 <0 ?m꺚FpW r~@fmGwGʋ<"wP@〭P%b`. tCn p36 n j)"Ȁ " pE Ȁ$ȑ$ ,u fV1ʔ $!D fA#V;WG9zKG 3t蘑 ^z8sQj.eSQN:Zk$R.,pUxbI"]X]v%HjF؉7_@NJ#E 6 @!cIz|YE0S2 cC'g `V=pÑ]*Sd0}`+6aY!Z`a^~XIdYzVH9kgQ ) %p kl$Κ`U#46dŒ. d@̔ Ѧ\oH]'! Xࡄ"~)_xIDuyqRJ+%@bӭL0F.Pděl Tl!-M2N2h-0 u&TЄ]"$1Stxtx`2bk,w\rmM9%#: ,UD6Y ]4,op \y3XopJVmxP@*&rCyL,F$eMptrka[0EuLRVziviҀ;apache-xmlrpc-3.1.3-src/src/site/xdoc/images/project-logo.jpg100644 0 0 27721 11333307155 21253 0ustar 0 0 JFIFHH BPhotoshop 3.08BIM ResolutionHH8BIM FX Global Lighting Anglex8BIMFX Global Altitude8BIM Print Flags 8BIM Copyright Flag8BIM'Japanese Print Flags 8BIMColor Halftone SettingsH/fflff/ff2Z5-8BIMColor Transfer Settingsp8BIM Layer State8BIM Layer Groups8BIMGuides@@8BIM URL overrides8BIMSlicesqZapachewsZ8BIMICC Untagged Flag8BIMLayer ID Generator Base8BIM New Windows ThumbnailipP0MJFIFHHAdobed            p"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?zU}'vPn_N SEή\O齟\oCZ ^Uf/E:U4l8ZW 7mۻ} A{{^uIewZsQb12?6(,~K eLJӈc ۜr7oO[[lð4Vo7WYd72Zo^g{mxǵ ~>77}UCK, }KG_:H-rH`G0~s/ }{k1[)$kv75?ŝ%oqMUՔ\nٵӱK qPS|Y#3p BR)s .4}V~}A?9QV:c7녇!E-=~k-?thOSDm'!?]?/q?}Y܆2[v1--e5ݡ~o/w$;] ӌ}{mC?W>b;w F},'3tzc8&,id΃g颳>̊k-`p$Q?s.>hfƘb{[_r~^ߟMsXg=_B\G5DDDy}X"?Tʩ$z]p4aݞ@#%̻k~zr}J| ?IfzEYU{=]6D nci̇GnOuxI)CtjeW궧 nBf?Le:sy.}/ ߑuzm+礒S[~!2E8f+C[1_uug=l[FVVuFc~[4ь}&Q,ɳd[W$_uK7lusJS6Ԫԫ~?kqÞd[?OkS}' Q]h{ڭ[c?MWwY*Jt~NM9a\浍6){!k|J}#ˀf1.׹dVIv?O{21?ޞ?K?cbuvd4r n8[?V_98BIM!Version compatibility infoUAdobe PhotoshopAdobe Photoshop 6.08BIM JPEG QualityAdobed            Z"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?T-i-0a$yۚ{UҲ/]Hksv? %_ ? c'hVXv 8&;?G)IbWc3oYgft0>P&[\:n͋͘^8z'OyEnck{:paef5?Ku*627C3 jQ`3'^ 'I&uA[kq,}N$Ik9x=Ѡv?C)--o~_O : es53Ƽ.5pk=y:Qfə]]icy2R,o}gycXagOin#P&C>QZYV>VFY`u8>a52|p8|$՟#4Rx;~sf[\a@ԋ{c֟9ȋՔ^%a'B ~\T"Ky p$wNcS//1͔I%$I)I$JRI$I$$I)I$JRI$I$$I)I$JRI,O ˷tzo3ߑhuChǼk=)IpS7aZsoYؙ/ WM~.^t\qu창1Yw=SդnMX#e< N8"nUeï~N55uC&*}kikkZ2_Szw\MzX$Qks*yqʷ ;kߏU_g~Z|V*ө-Ʋ{ɹdmت %No9yvgS2_鲻}oVS߫.:e\jdzOͪ1[qwӿDIatԿc ڋz{kO]l`]Ule~=k-Ư%K mn&=ͳ?KL%.cf]mUMvmslCc=L[?]bJUGnym{۽^wh{oҳۦ_Wz^{mVkϠ~r9gB9 <5R/6=fJų[/_uW,?mw GK]QM(A/olΫzPoXMAԙ{eMeO g'VrN\j?_TF#[zO0}[V??_Nk,'n'kbqLzghroLĵ,,@75mُˋ|Aunal6 oKcZ7wdz}P0cM1r\ɒ+\KǧWCZ"s(pk@XQ1n^_ ^,G1Q cS`9vυxcA?/Dz][\O2N u$ۈޫ/ +Ee{^ v1Hervr||4Ѱ Cpm6Xik"{-CA.m?F ~{6Mvdq676T,3_g#jFY1䮿? oGNV?HzA #78WޕhqK{1{pUuw~_U?oR W^un쨙C[>kӔd2y<'~Hf?Zٿ_җ;V6oWz?mw GZ߁D?_7۫zRޕo+j?_t.7Qq=;V6oWկm+Wt5]/oD?{wlnK_7۫zWOo+j?_߁D?ǗZٿ_җ;V6oW]QWtѿڈ+/o?q/wln\?6]?KO~!W^߃kfuJ_Zٿ_Ҹmw GK]QFCj!|<ޔqpt.6]?K(C\y{~qկm*/?U^X<>Mn5RKI,w=틉Wt5]/oD?z-/wXN>9~㗷ߵo?UpC˷.y6|ph S~و{5Oo+j?_߁D?ǗfJ-^[s^A{ls~ۭm)4~M5Cdz˲?c}JOo+j?_߁D?Ǘ/>W}f3c"?y&_QuY]*{W|wFU}n#Oo+j?_߁D?Ǘ ̦_gKVݍkk4ߵwV.P]"r`7~6;rt.6]?K(C\y{~ZGW]nCMӏX4~d E;&{]as1Ho+j?_t.7Qq=?f3*R'mtPOk/؇OClm&{c=;eor5]/mw GK?QUU]VdM~Í獄;ӧ-'~K*\kztO^޲~/r8N/N.?s$spp|//doSTI%)$IJLZ"Sy3C5XYS1nu)$2~f XD;xNѷ~ϣo*6^)ӹsAAݺ}r뾸l񛏈sr=KHvݴPvVAv6ݫo\j{enk;ҚaA9rFg("=-Yhڠ:*2tGa㻖'7,r\ُĹT+#-x,i凱+uci{^$=nvWg|^3}/{ce&aMolXw$DqgmnaƟ8w}U =V]YX؝L*UbLڈscx炷{x~"'6ItcC;67k]Z/ Bq3 ghK_/|cǧk *h7ԮA`GFGߝ}UzYwC> YmgUq3&d;59yA .G/w[>:\`C5{YgGg:D-;=?`#^wجey559|߶Z魞7D `}X8jd»cP↱XGrbo[FX?S_,[E۷mױZkNΩ( OM9fz.~kK}`~g^!m͸:KzڳodJvIV97mŭF'?9ԔIqf뗊ާ~`XeTْ׵617VNҩxeǴU)I$RI %Wkk$7{WowrJJnͿs&[7c=VRRI$I%)%כG F֊#r^-?!9A )t\Ϭy0ۛԯ=uHn"[ .?+_Cr,ec?:GobeQN^3ѐSvoa4$JRJMꗿ,u 1گ}x6ZIϩy%)$IJIftq2q}uYH|4kw9iTI%)$IJI$RIVLOgNswHcl#kcA%>|߭W~>=_0Xʬngn-oay]"g]x-{.c^n-諾 tk{$:ןR:nZϮ4u'{qԪypsNkikX9w_S}E837g>Y4RfI{ZC_C½y=P繵<sl̯ggߪ¿ o\SƧO]vSmWAGdad78]x& BWBٹwu!q̪_[slvFYo]Y]?c!M5{5EwUՏ?XPчO>22,Yeu~{ۧdz7Uԫ]wIMag#|.aZh¸S`w<4b1ur1,1]]Tͬ۱>cwTo.a }:Swz3l ޤF=MIO3&N]_W:~[7P?oK6C(Lt}>ؽZGPΪKCʦ]gw {/TnB5cޅ`v=,7o/ћ2CGʲg浩)\KD$:u Í;'vڱqX'@[f8.u7jx?{\V\:=uWMkm/_g7\S,bf0/G{mn궎Zn;wc _{+.s}I[T:} ./̣[湍ccS&WB~a پ,o+ޥU*їԺZ]m~c+>WÁCze=\WVlV_F=Q# {q:A Meokeޝ)si}k[kMײUv; :g} >UW]x^k]V)m3~طq0~gu[V.# B(OUr~k>km5 k+}c[*G?S/iYsfN4יnq{k;ݳ{FV?W9 5[umA-ƿwYV>u,ԋEE5UXwIf\oip>k^^{u vS]N@lk[%*Kԛz>1y91}?=`շO+37SwL̪οmmiX_{/w|s9 s?Av۟ͤʷ f}^-{oȪײ[97wb4[׾|;71V η~s?IS:vNn]Ա}C4xm5gEo}om kq{\ o~%9cv1 6׹r1)_dK>uUfew`4Enn½?z{3tMO";%ka[lw}==ŝ/a sSev}OMoͤG/V]ǭ*i,}up~uX cQ½ﹶ춽wD >uwQUkf5]Ygo6'GԺ'P~66/Oa~Sͭ%C*68h~g3,d)Eޛ.ZX}ձvprzU:j}FُusGڷ-w՘ul>\gݿk}dTU{gPqf_Ly-?:W##5}c=>L ِqu豎~?.(dkF)h,w_w_)~cceV۱rS%V6jγL3d:IӟLl9gګغ΍n? /aי a6eEve{Z?t@?2'$}i7[5sv*;_c[Ngջq(^K:uX~}Wܻee\Ι2oXѫcؒtKz]-uݙU=;bv79TҬķ@ʷĶڜXVe~}6^zB]gWKok˃׵okV>7Ԯӳ Y6W{V7k7G+"z+ kCE&ӹs7d`n^cMV2{{?}_Xn-uZmx,ѱSJp?tYXdS;{m-?5ś0WL ~VβKl{S ]ٳ[V>/ 6C/`6ڭgc2߆ސ kEgnm^ӷ=%5P}+D}tu\we1Q5:+]m}Fia}G`3౷n~/guGQvH.e{};(tΑ/S>QMxu.X6[)}#?9321vV>Ww:B5.Ǻ[}gzc$TI%)$IJI$RI$I%5:gK8mԌ|f[[I eJI$$I)I$JRI$I$$I)I$JRI$I$$I)I$JRI$I$$I)I$JRI$I$$I)J~/Qû16CK-\i,{a$=l6\L^OrI)I$JRI$apache-xmlrpc-3.1.3-src/src/site/xdoc/images/xml-logo.gif100644 0 0 3253 11333307155 20344 0ustar 0 0 GIF89ai*d7`xf Q.Ib)Ea@?Z[b@(<13W>Y+O_Yjzh dz_2cEN5vYpA[tf0 ?x'C-*?Cm mHQ/4?C[=4PjC ZfffnI09TlsJXN=0?zgPR MtWfS ry Z2)/ Jbw333:uxpyr|GOd82SYk [!rC9 KU P/ e<@B>b\pjd)ui?f K/wq\LMA!,i*@+&&>>&&&0!&!&!<+&!**4Mww!9gzz:CU,fƺ@M샹 ġdJt<87H -$$0 '!J-Q\ӪSfNL,DaB\gܙ7$,_wJ@)A52jxB7#2093e"H@DsoTkm׀Hci"ՠ/2<5rL9bp `.\ %O|Ha48Sb/:6.1 ^D{v9S/ m&L*_8 0a++~@&`_aф,ET~a{'TmqLLa IJv"|2L~)ϙ 0#pE <rOqgHV^ =lP5DGE 0Jz :R! \T E5䡅h~X`,pA뮼I JR_}yi}h_ògONVk-~&p\<V' L+H6&s!4( >ؖ}D'h* M W&U&r| &{Y}9`6H/ŢيYM' I`:1\ #V ƈS|;K #‡x3m. oA| Hjaf7"!q!P  AEdLI ń. JىPa`AitaCLxEJ`&|OI&O;@LQpO1B< 3@B & :]I&moD0 M"HPЂ RؐE$T0Rc }0 h =B>㓅-" $ D|QЅ  \0`5XUSl0u Pv-E ;03  +xd/Av@ "< Ȃ$"*8dC`ĩSȣ3`#PRpF NS҄F 7A C%(APv\e (;apache-xmlrpc-3.1.3-src/src/site/xdoc/images/xmlrpc-logo.gif100644 0 0 4011 11333307155 21042 0ustar 0 0 GIF89aHf3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f3!,H@H*\ȰÇ#JHŋ3jȱ#k C^ TȐM\R%k̗,W΄z&̒/S&hF)eYaԂM[N]i0+ׁA+K 2u ui[UdENVFIЬȧ W~CɈt#KLZ4 xs`㇛[[ωA.,0q5RM3h+{6=[=as,7Kn-n<سkνËO^ۇN}mV&5X9}pI7UXt칇~rǚ!U7QDeG\tאP8Ex'8Ponñ X$ф8n T]fTCDEWޔTViXf\v`)X:GIAjFV^tjP瑖О| q+YA—Y$ ]ؓ6zYZZ9 R}JxR)w錅wRa7db~1" kH&JЮ a*`%xwVcA8^ M -Aզ lBtkn>ъF=Q6.XҞF롵;BZdԪˣ]*'BΚۨQ2C!;0{ i+#^g/x qݛPG-TWmXg\w`-dmh*r ·v)eO27AQ됲 2]#5KS6{W~y+$cטd)9{=RwZ^.6ȡ_W-rҼjz2k>Ӟ{7Yk3Utvd'ߤB\v7۴ke%&4/:LOc[89N w9U5-ήh.u ,S1SP:(atsȥ+oQEvE(QPW Dz2m+ e Mo!R4B0DD}0<4  BufS5qDAq̸ۣ#3 ׈G8;dbRE>jb8&ht$[$CDRo#> qO*I X,uKCLj$ʉiojV>Ӎ)D*gzǶj85nz 8Ir_ ;G F֊#r^-?!9A )t\Ϭy0ۛԯ=uHn"[ .?+_Cr,ec?:GobeQN^3ѐSvoa4$JRJMꗿ,u 1گ}x6ZIϩy%)$IJIftq2q}uYH|4kw9iTI%)$IJI$RIVLOgNswHcl#kcA%>|߭W~>=_0Xʬngn-oay]"g]x-{.c^n-諾 tk{$:ןR:nZϮ4u'{qԪypsNkikX9w_S}E837g>Y4RfI{ZC_C½y=P繵<sl̯ggߪ¿ o\SƧO]vSmWAGdad78]x& BWBٹwu!q̪_[slvFYo]Y]?c!M5{5EwUՏ?XPчO>22,Yeu~{ۧdz7Uԫ]wIMag#|.aZh¸S`w<4b1ur1,1]]Tͬ۱>cwTo.a }:Swz3l ޤF=MIO3&N]_W:~[7P?oK6C(Lt}>ؽZGPΪKCʦ]gw {/TnB5cޅ`v=,7o/ћ2CGʲg浩)\KD$:u Í;'vڱqX'@[f8.u7jx?{\V\:=uWMkm/_g7\S,bf0/G{mn궎Zn;wc _{+.s}I[T:} ./̣[湍ccS&WB~a پ,o+ޥU*їԺZ]m~c+>WÁCze=\WVlV_F=Q# {q:A Meokeޝ)si}k[kMײUv; :g} >UW]x^k]V)m3~طq0~gu[V.# B(OUr~k>km5 k+}c[*G?S/iYsfN4יnq{k;ݳ{FV?W9 5[umA-ƿwYV>u,ԋEE5UXwIf\oip>k^^{u vS]N@lk[%*Kԛz>1y91}?=`շO+37SwL̪οmmiX_{/w|s9 s?Av۟ͤʷ f}^-{oȪײ[97wb4[׾|;71V η~s?IS:vNn]Ա}C4xm5gEo}om kq{\ o~%9cv1 6׹r1)_dK>uUfew`4Enn½?z{3tMO";%ka[lw}==ŝ/a sSev}OMoͤG/V]ǭ*i,}up~uX cQ½ﹶ춽wD >uwQUkf5]Ygo6'GԺ'P~66/Oa~Sͭ%C*68h~g3,d)Eޛ.ZX}ձvprzU:j}FُusGڷ-w՘ul>\gݿk}dTU{gPqf_Ly-?:W##5}c=>L ِqu豎~?.(dkF)h,w_w_)~cceV۱rS%V6jγL3d:IӟLl9gګغ΍n? /aי a6eEve{Z?t@?2'$}i7[5sv*;_c[Ngջq(^K:uX~}Wܻee\Ι2oXѫcؒtKz]-uݙU=;bv79TҬķ@ʷĶڜXVe~}6^zB]gWKok˃׵okV>7Ԯӳ Y6W{V7k7G+"z+ kCE&ӹs7d`n^cMV2{{?}_Xn-uZmx,ѱSJp?tYXdS;{m-?5ś0WL ~VβKl{S ]ٳ[V>/ 6C/`6ڭgc2߆ސ kEgnm^ӷ=%5P}+D}tu\we1Q5:+]m}Fia}G`3౷n~/guGQvH.e{};(tΑ/S>QMxu.X6[)}#?9321vV>Ww:B5.Ǻ[}gzc$TI%)$IJI$RI$I%5:gK8mԌ|f[[I eJI$$I)I$JRI$I$$I)I$JRI$I$$I)I$JRI$I$$I)I$JRI$I$$I)J~/Qû16CK-\i,{a$=l6\L^OrI)I$JRI$apache-xmlrpc-3.1.3-src/src/site/xdoc/images/xml-logo.gif100644 0 0 3253 11333307155 20344 0ustar 0 0 GIF89ai*d7`xf Q.Ib)Ea@?Z[b@(<13W>Y+O_Yjzh dz_2cEN5vYpA[tf0 ?x'C-*?Cm mHQ/4?C[=4PjC ZfffnI09TlsJXN=0?zgPR MtWfS ry Z2)/ Jbw333:uxpyr|GOd82SYk [!rC9 KU P/ e<@B>b\pjd)ui?f K/wq\LMA!,i*@+&&>>&&&0!&!&!<+&!**4Mww!9gzz:CU,fƺ@M샹 ġdJt<87H -$$0 '!J-Q\ӪSfNL,DaB\gܙ7$,_wJ@)A52jxB7#2093e"H@DsoTkm׀Hci"ՠ/2<5rL9bp `.\ %O|Ha48Sb/:6.1 ^D{v9S/ m&L*_8 0a++~@&`_aф,ET~a{'TmqLLa IJv"|2L~)ϙ 0#pE <rOqgHV^ =lP5DGE 0Jz :R! \T E5䡅h~X`,pA뮼I JR_}yi}h_ògONVk-~&p\<V' L+H6&s!4( >ؖ}D'h* M W&U&r| &{Y}9`6H/ŢيYM' I`:1\ #V ƈS|;K #‡x3m. oA| Hjaf7"!q!P  AEdLI ń. JىPa`AitaCLxEJ`&|OI&O;@LQpO1B< 3@B & :]I&moD0 M"HPЂ RؐE$T0Rc }0 h =B>㓅-" $ D|QЅ  \