Yet another round of formatting.

Added Eclipse formatter settings.
This commit is contained in:
Oliver Gierke
2011-08-26 20:26:06 +02:00
parent ce5046c35f
commit da23133327
58 changed files with 768 additions and 553 deletions

View File

@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Spring Data" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
</profile>
</profiles>

View File

@@ -22,10 +22,10 @@ public class InvalidMongoDbApiUsageException extends InvalidDataAccessApiUsageEx
private static final long serialVersionUID = 2034770973290508041L;
public InvalidMongoDbApiUsageException(String msg) {
super(msg);
}
super(msg);
}
public InvalidMongoDbApiUsageException(String msg, Throwable cause) {
super(msg, cause);
}
public InvalidMongoDbApiUsageException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@@ -18,14 +18,12 @@ package org.springframework.data.mongodb;
import org.springframework.util.StringUtils;
/**
* Helper class featuring helper methods for working with MongoDb collections.
* <p/>
* <p/>
* Mainly intended for internal use within the framework.
*
*
* @author Thomas Risberg
* @since 1.0
*/
@@ -40,7 +38,7 @@ public abstract class MongoCollectionUtils {
/**
* Obtains the collection name to use for the provided class
*
*
* @param entityClass The class to determine the preferred collection name for
* @return The preferred collection name
*/

View File

@@ -6,7 +6,7 @@ import com.mongodb.DB;
/**
* Interface for factories creating {@link DB} instances.
*
*
* @author Mark Pollack
*/
public interface MongoDbFactory {
@@ -18,7 +18,7 @@ public interface MongoDbFactory {
* @throws DataAccessException
*/
DB getDb() throws DataAccessException;
/**
* Creates a {@link DB} instance to access the database with the given name.
*

View File

@@ -22,6 +22,6 @@ public class UncategorizedMongoDbException extends UncategorizedDataAccessExcept
private static final long serialVersionUID = -2336595514062364929L;
public UncategorizedMongoDbException(String msg, Throwable cause) {
super(msg, cause);
}
super(msg, cause);
}
}

View File

@@ -46,24 +46,24 @@ public abstract class AbstractMongoConfiguration {
@Bean
public MongoTemplate mongoTemplate() throws Exception {
return new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
return new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
}
@Bean
public MongoDbFactory mongoDbFactory() throws Exception {
if (getUserCredentials() == null) {
return new SimpleMongoDbFactory(mongo(), getDatabaseName());
} else {
return new SimpleMongoDbFactory(mongo(), getDatabaseName(), getUserCredentials());
}
public MongoDbFactory mongoDbFactory() throws Exception {
if (getUserCredentials() == null) {
return new SimpleMongoDbFactory(mongo(), getDatabaseName());
} else {
return new SimpleMongoDbFactory(mongo(), getDatabaseName(), getUserCredentials());
}
}
public String getMappingBasePackage() {
return "";
}
public UserCredentials getUserCredentials() {
return null;
return null;
}
@Bean
@@ -71,13 +71,15 @@ public abstract class AbstractMongoConfiguration {
MongoMappingContext mappingContext = new MongoMappingContext();
String basePackage = getMappingBasePackage();
if (StringUtils.hasText(basePackage)) {
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(), mappingContext.getClass().getClassLoader()));
initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(), mappingContext.getClass()
.getClassLoader()));
}
mappingContext.setInitialEntitySet(initialEntitySet);
}
@@ -93,7 +95,7 @@ public abstract class AbstractMongoConfiguration {
/**
* Hook that allows post-processing after the MappingMongoConverter has been successfully created.
*
*
* @param converter
*/
protected void afterMappingMongoConverterCreation(MappingMongoConverter converter) {

View File

@@ -66,7 +66,7 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser {
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionRegistry registry = parserContext.getRegistry();
BeanDefinition conversionsDefinition = getCustomConversions(element, parserContext);
String ctxRef = potentiallyCreateMappingContext(element, parserContext, conversionsDefinition);
@@ -100,7 +100,8 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser {
if (!StringUtils.hasText(dbFactoryRef)) {
dbFactoryRef = DB_FACTORY;
}
BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder.genericBeanDefinition(MongoPersistentEntityIndexCreator.class);
BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder
.genericBeanDefinition(MongoPersistentEntityIndexCreator.class);
indexHelperBuilder.addConstructorArgValue(new RuntimeBeanReference(ctxRef));
indexHelperBuilder.addConstructorArgValue(new RuntimeBeanReference(dbFactoryRef));
registry.registerBeanDefinition(INDEX_HELPER, indexHelperBuilder.getBeanDefinition());
@@ -108,9 +109,10 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser {
return converterBuilder.getBeanDefinition();
}
private String potentiallyCreateMappingContext(Element element, ParserContext parserContext, BeanDefinition conversionsDefinition) {
private String potentiallyCreateMappingContext(Element element, ParserContext parserContext,
BeanDefinition conversionsDefinition) {
String ctxRef = element.getAttribute("mapping-context-ref");
if (!StringUtils.hasText(ctxRef)) {
BeanDefinitionBuilder mappingContextBuilder = BeanDefinitionBuilder
@@ -120,26 +122,26 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser {
if (classesToAdd != null) {
mappingContextBuilder.addPropertyValue("initialEntitySet", classesToAdd);
}
if (conversionsDefinition != null) {
AbstractBeanDefinition simpleTypesDefinition = new GenericBeanDefinition();
simpleTypesDefinition.setFactoryBeanName("customConversions");
simpleTypesDefinition.setFactoryMethodName("getSimpleTypeHolder");
mappingContextBuilder.addPropertyValue("simpleTypeHolder", simpleTypesDefinition);
}
parserContext.getRegistry().registerBeanDefinition(MAPPING_CONTEXT, mappingContextBuilder.getBeanDefinition());
ctxRef = MAPPING_CONTEXT;
}
return ctxRef;
}
private BeanDefinition getCustomConversions(Element element, ParserContext parserContext) {
List<Element> customConvertersElements = DomUtils.getChildElementsByTagName(element, "custom-converters");
if (customConvertersElements.size() == 1) {
Element customerConvertersElement = customConvertersElements.get(0);
ManagedList<BeanMetadataElement> converterBeans = new ManagedList<BeanMetadataElement>();
@@ -149,18 +151,18 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser {
converterBeans.add(parseConverter(listenerElement, parserContext));
}
}
BeanDefinitionBuilder conversionsBuilder = BeanDefinitionBuilder.rootBeanDefinition(CustomConversions.class);
conversionsBuilder.addConstructorArgValue(converterBeans);
AbstractBeanDefinition conversionsBean = conversionsBuilder.getBeanDefinition();
conversionsBean.setSource(parserContext.extractSource(element));
parserContext.getRegistry().registerBeanDefinition("customConversions", conversionsBean);
return conversionsBean;
}
return null;
}

View File

@@ -74,7 +74,7 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
if (userCredentials != null) {
dbFactoryBuilder.addConstructorArgValue(userCredentials);
}
ParsingUtils.setPropertyValue(element, dbFactoryBuilder, "write-concern", "writeConcern");
return dbFactoryBuilder.getBeanDefinition();

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Element;
/**
* Parser for &lt;mongo;gt; definitions. If no name
*
*
* @author Mark Pollack
*/
public class MongoParser extends AbstractSingleBeanDefinitionParser {

View File

@@ -19,7 +19,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
* {@link org.springframework.beans.factory.xml.NamespaceHandler} for Mongo DB based repositories.
*
*
* @author Oliver Gierke
*/
public class MongoRepositoryNamespaceHandler extends NamespaceHandlerSupport {

View File

@@ -28,75 +28,74 @@ import com.mongodb.ServerAddress;
abstract class ParsingUtils {
/**
* Parses the mongo replica-set element.
* @param parserContext the parser context
* @param element the mongo element
* @param mongoBuilder the bean definition builder to populate
* @return true if parsing actually occured, false otherwise
*/
static boolean parseReplicaSet(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) {
String replicaSetString = element.getAttribute("replica-set");
if (StringUtils.hasText(replicaSetString)) {
ManagedList<Object> serverAddresses = new ManagedList<Object>();
String[] replicaSetStringArray = StringUtils.commaDelimitedListToStringArray(replicaSetString);
for (String element2 : replicaSetStringArray) {
String[] hostAndPort = StringUtils.delimitedListToStringArray(element2, ":");
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(ServerAddress.class);
defBuilder.addConstructorArgValue(hostAndPort[0]);
defBuilder.addConstructorArgValue(hostAndPort[1]);
serverAddresses.add(defBuilder.getBeanDefinition());
}
if (!serverAddresses.isEmpty()) {
mongoBuilder.addPropertyValue("replicaSetSeeds", serverAddresses);
}
}
return true;
}
/**
* Parses the mongo:options sub-element. Populates the given attribute factory with the proper attributes.
*
* @return true if parsing actually occured, false otherwise
*/
static boolean parseMongoOptions(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) {
Element optionsElement = DomUtils.getChildElementByTagName(element, "options");
if (optionsElement == null) {
/**
* Parses the mongo replica-set element.
*
* @param parserContext the parser context
* @param element the mongo element
* @param mongoBuilder the bean definition builder to populate
* @return true if parsing actually occured, false otherwise
*/
static boolean parseReplicaSet(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) {
String replicaSetString = element.getAttribute("replica-set");
if (StringUtils.hasText(replicaSetString)) {
ManagedList<Object> serverAddresses = new ManagedList<Object>();
String[] replicaSetStringArray = StringUtils.commaDelimitedListToStringArray(replicaSetString);
for (String element2 : replicaSetStringArray) {
String[] hostAndPort = StringUtils.delimitedListToStringArray(element2, ":");
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(ServerAddress.class);
defBuilder.addConstructorArgValue(hostAndPort[0]);
defBuilder.addConstructorArgValue(hostAndPort[1]);
serverAddresses.add(defBuilder.getBeanDefinition());
}
if (!serverAddresses.isEmpty()) {
mongoBuilder.addPropertyValue("replicaSetSeeds", serverAddresses);
}
}
return true;
}
/**
* Parses the mongo:options sub-element. Populates the given attribute factory with the proper attributes.
*
* @return true if parsing actually occured, false otherwise
*/
static boolean parseMongoOptions(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) {
Element optionsElement = DomUtils.getChildElementByTagName(element, "options");
if (optionsElement == null) {
return false;
}
BeanDefinitionBuilder optionsDefBuilder = BeanDefinitionBuilder
.genericBeanDefinition(MongoOptionsFactoryBean.class);
BeanDefinitionBuilder optionsDefBuilder = BeanDefinitionBuilder
.genericBeanDefinition(MongoOptionsFactoryBean.class);
setPropertyValue(optionsElement, optionsDefBuilder, "connections-per-host", "connectionsPerHost");
setPropertyValue(optionsElement, optionsDefBuilder, "threads-allowed-to-block-for-connection-multiplier",
"threadsAllowedToBlockForConnectionMultiplier");
setPropertyValue(optionsElement, optionsDefBuilder, "max-wait-time", "maxWaitTime");
setPropertyValue(optionsElement, optionsDefBuilder, "connect-timeout", "connectTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "socket-timeout", "socketTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "socket-keep-alive", "socketKeepAlive");
setPropertyValue(optionsElement, optionsDefBuilder, "auto-connect-retry", "autoConnectRetry");
setPropertyValue(optionsElement, optionsDefBuilder, "write-number", "writeNumber");
setPropertyValue(optionsElement, optionsDefBuilder, "write-timeout", "writeTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "write-fsync", "writeFsync");
setPropertyValue(optionsElement, optionsDefBuilder, "slave-ok", "slaveOk");
setPropertyValue(optionsElement, optionsDefBuilder, "connections-per-host", "connectionsPerHost");
setPropertyValue(optionsElement, optionsDefBuilder, "threads-allowed-to-block-for-connection-multiplier",
"threadsAllowedToBlockForConnectionMultiplier");
setPropertyValue(optionsElement, optionsDefBuilder, "max-wait-time", "maxWaitTime");
setPropertyValue(optionsElement, optionsDefBuilder, "connect-timeout", "connectTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "socket-timeout", "socketTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "socket-keep-alive", "socketKeepAlive");
setPropertyValue(optionsElement, optionsDefBuilder, "auto-connect-retry", "autoConnectRetry");
setPropertyValue(optionsElement, optionsDefBuilder, "write-number", "writeNumber");
setPropertyValue(optionsElement, optionsDefBuilder, "write-timeout", "writeTimeout");
setPropertyValue(optionsElement, optionsDefBuilder, "write-fsync", "writeFsync");
setPropertyValue(optionsElement, optionsDefBuilder, "slave-ok", "slaveOk");
mongoBuilder.addPropertyValue("mongoOptions", optionsDefBuilder.getBeanDefinition());
return true;
}
static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName, String propertyName) {
String attr = element.getAttribute(attrName);
if (StringUtils.hasText(attr)) {
builder.addPropertyValue(propertyName, attr);
}
}
/**
mongoBuilder.addPropertyValue("mongoOptions", optionsDefBuilder.getBeanDefinition());
return true;
}
static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName, String propertyName) {
String attr = element.getAttribute(attrName);
if (StringUtils.hasText(attr)) {
builder.addPropertyValue(propertyName, attr);
}
}
/**
* Sets the property with the given attribute name on the given {@link BeanDefinitionBuilder} to the value of the
* attribute with the given name.
*
@@ -104,10 +103,10 @@ abstract class ParsingUtils {
* @param builder must not be {@literal null}.
* @param attrName must not be {@literal null} or empty.
*/
static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName) {
String attr = element.getAttribute(attrName);
if (StringUtils.hasText(attr)) {
builder.addPropertyValue(attrName, attr);
}
}
static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName) {
String attr = element.getAttribute(attrName);
if (StringUtils.hasText(attr)) {
builder.addPropertyValue(attrName, attr);
}
}
}

View File

@@ -88,7 +88,7 @@ public class SimpleMongoRepositoryConfiguration
public String getNamedQueriesLocation() {
return "classpath*:META-INF/mongo-named-queries.properties";
}
/*
* (non-Javadoc)
*
@@ -110,7 +110,7 @@ public class SimpleMongoRepositoryConfiguration
SingleRepositoryConfigInformation<SimpleMongoRepositoryConfiguration> {
String getMongoTemplateRef();
boolean getCreateQueryIndexes();
}
@@ -144,12 +144,12 @@ public class SimpleMongoRepositoryConfiguration
return getAttribute(MONGO_TEMPLATE_REF);
}
/* (non-Javadoc)
* @see org.springframework.data.mongodb.config.SimpleMongoRepositoryConfiguration.MongoRepositoryConfiguration#getCreateQueryIndexes()
*/
public boolean getCreateQueryIndexes() {
String attribute = getAttribute(CREATE_QUERY_INDEXES);
return attribute == null ? false : Boolean.parseBoolean(attribute);
}
@@ -185,7 +185,7 @@ public class SimpleMongoRepositoryConfiguration
return getParent().getMongoTemplateRef();
}
/* (non-Javadoc)
* @see org.springframework.data.mongodb.config.SimpleMongoRepositoryConfiguration.MongoRepositoryConfiguration#getCreateQueryIndexes()
*/

View File

@@ -31,13 +31,10 @@ public class CollectionOptions {
/**
* Constructs a new <code>CollectionOptions</code> instance.
*
* @param size
* the collection size in bytes, this data space is preallocated
* @param maxDocuments
* the maximum number of documents in the collection.
* @param capped
* true to created a "capped" collection (fixed size with auto-FIFO behavior based on insertion order), false
* otherwise.
* @param size the collection size in bytes, this data space is preallocated
* @param maxDocuments the maximum number of documents in the collection.
* @param capped true to created a "capped" collection (fixed size with auto-FIFO behavior based on insertion order),
* false otherwise.
*/
public CollectionOptions(Integer size, Integer maxDocuments, Boolean capped) {
super();

View File

@@ -71,8 +71,7 @@ public class MongoAdmin implements MongoAdminOperations {
/**
* Sets the username to use to connect to the Mongo database
*
* @param username
* The username to use
* @param username The username to use
*/
public void setUsername(String username) {
this.username = username;
@@ -81,8 +80,7 @@ public class MongoAdmin implements MongoAdminOperations {
/**
* Sets the password to use to authenticate with the Mongo database.
*
* @param password
* The password to use
* @param password The password to use
*/
public void setPassword(String password) {

View File

@@ -48,10 +48,8 @@ public abstract class MongoDbUtils {
/**
* Obtains a {@link DB} connection for the given {@link Mongo} instance and database name
*
* @param mongo
* The {@link Mongo} instance
* @param databaseName
* The database name
* @param mongo The {@link Mongo} instance
* @param databaseName The database name
* @return The {@link DB} connection
*/
public static DB getDB(Mongo mongo, String databaseName) {
@@ -61,14 +59,10 @@ public abstract class MongoDbUtils {
/**
* Obtains a {@link DB} connection for the given {@link Mongo} instance and database name
*
* @param mongo
* The {@link Mongo} instance
* @param databaseName
* The database name
* @param username
* The username to authenticate with
* @param password
* The password to authenticate with
* @param mongo The {@link Mongo} instance
* @param databaseName The database name
* @param username The username to authenticate with
* @param password The password to authenticate with
* @return The {@link DB} connection
*/
public static DB getDB(Mongo mongo, String databaseName, String username, char[] password) {
@@ -140,10 +134,8 @@ public abstract class MongoDbUtils {
* Return whether the given DB instance is transactional, that is, bound to the current thread by Spring's transaction
* facilities.
*
* @param db
* the DB to check
* @param mongo
* the Mongo instance that the DB was created with (may be <code>null</code>)
* @param db the DB to check
* @param mongo the Mongo instance that the DB was created with (may be <code>null</code>)
* @return whether the DB is transactional
*/
public static boolean isDBTransactional(DB db, Mongo mongo) {
@@ -157,8 +149,7 @@ public abstract class MongoDbUtils {
/**
* Perform actual closing of the Mongo DB object, catching and logging any cleanup exceptions thrown.
*
* @param db
* the DB to close (may be <code>null</code>)
* @param db the DB to close (may be <code>null</code>)
*/
public static void closeDB(DB db) {
if (db != null) {

View File

@@ -91,18 +91,18 @@ public class MongoFactoryBean implements FactoryBean<Mongo>, PersistenceExceptio
Mongo mongo;
if (host == null) {
logger.debug("Property host not specified. Using default configuration");
mongo = new Mongo();
} else {
ServerAddress defaultOptions = new ServerAddress();
if (mongoOptions == null) {
mongoOptions = new MongoOptions();
}
if (replicaPair != null) {
if (replicaPair.size() < 2) {
throw new CannotGetMongoDbConnectionException("A replica pair must have two server entries");

View File

@@ -55,8 +55,7 @@ public interface MongoOperations {
* MongoDB driver to convert the JSON string to a DBObject. Any errors that result from executing this command will be
* converted into Spring's DAO exception hierarchy.
*
* @param jsonCommand
* a MongoDB command expressed as a JSON string.
* @param jsonCommand a MongoDB command expressed as a JSON string.
*/
CommandResult executeCommand(String jsonCommand);
@@ -64,8 +63,7 @@ public interface MongoOperations {
* Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO
* exception hierarchy.
*
* @param command
* a MongoDB command
* @param command a MongoDB command
*/
CommandResult executeCommand(DBObject command);
@@ -74,10 +72,8 @@ public interface MongoOperations {
* <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects.
*
* @param <T>
* return type
* @param action
* callback object that specifies the MongoDB actions to perform on the passed in DB instance.
* @param <T> return type
* @param action callback object that specifies the MongoDB actions to perform on the passed in DB instance.
* @return a result object returned by the action or <tt>null</tt>
*/
<T> T execute(DbCallback<T> action);
@@ -87,12 +83,9 @@ public interface MongoOperations {
* <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects.
*
* @param entityClass
* class that determines the collection to use
* @param <T>
* return type
* @param action
* callback object that specifies the MongoDB action
* @param entityClass class that determines the collection to use
* @param <T> return type
* @param action callback object that specifies the MongoDB action
* @return a result object returned by the action or <tt>null</tt>
*/
<T> T execute(Class<?> entityClass, CollectionCallback<T> action);
@@ -102,12 +95,9 @@ public interface MongoOperations {
* <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects.
*
* @param <T>
* return type
* @param collectionName
* the name of the collection that specifies which DBCollection instance will be passed into
* @param action
* callback object that specifies the MongoDB action the callback action.
* @param <T> return type
* @param collectionName the name of the collection that specifies which DBCollection instance will be passed into
* @param action callback object that specifies the MongoDB action the callback action.
* @return a result object returned by the action or <tt>null</tt>
*/
<T> T execute(String collectionName, CollectionCallback<T> action);
@@ -119,10 +109,8 @@ public interface MongoOperations {
* <p/>
* Allows for returning a result object, that is a domain object or a collection of domain objects.
*
* @param <T>
* return type
* @param action
* callback that specified the MongoDB actions to perform on the DB instance
* @param <T> return type
* @param action callback that specified the MongoDB actions to perform on the DB instance
* @return a result object returned by the action or <tt>null</tt>
*/
<T> T executeInSession(DbCallback<T> action);
@@ -130,8 +118,7 @@ public interface MongoOperations {
/**
* Create an uncapped collection with a name based on the provided entity class.
*
* @param entityClass
* class that determines the collection to create
* @param entityClass class that determines the collection to create
* @return the created collection
*/
<T> DBCollection createCollection(Class<T> entityClass);
@@ -139,10 +126,8 @@ public interface MongoOperations {
/**
* Create a collect with a name based on the provided entity class using the options.
*
* @param entityClass
* class that determines the collection to create
* @param collectionOptions
* options to use when creating the collection.
* @param entityClass class that determines the collection to create
* @param collectionOptions options to use when creating the collection.
* @return the created collection
*/
<T> DBCollection createCollection(Class<T> entityClass, CollectionOptions collectionOptions);
@@ -150,8 +135,7 @@ public interface MongoOperations {
/**
* Create an uncapped collection with the provided name.
*
* @param collectionName
* name of the collection
* @param collectionName name of the collection
* @return the created collection
*/
DBCollection createCollection(String collectionName);
@@ -159,10 +143,8 @@ public interface MongoOperations {
/**
* Create a collect with the provided name and options.
*
* @param collectionName
* name of the collection
* @param collectionOptions
* options to use when creating the collection.
* @param collectionName name of the collection
* @param collectionOptions options to use when creating the collection.
* @return the created collection
*/
DBCollection createCollection(String collectionName, CollectionOptions collectionOptions);
@@ -179,8 +161,7 @@ public interface MongoOperations {
* <p/>
* Translate any exceptions as necessary.
*
* @param collectionName
* name of the collection
* @param collectionName name of the collection
* @return an existing collection or a newly created one.
*/
DBCollection getCollection(String collectionName);
@@ -190,8 +171,7 @@ public interface MongoOperations {
* <p/>
* Translate any exceptions as necessary.
*
* @param entityClass
* class that determines the name of the collection
* @param entityClass class that determines the name of the collection
* @return true if a collection with the given name is found, false otherwise.
*/
<T> boolean collectionExists(Class<T> entityClass);
@@ -201,8 +181,7 @@ public interface MongoOperations {
* <p/>
* Translate any exceptions as necessary.
*
* @param collectionName
* name of the collection
* @param collectionName name of the collection
* @return true if a collection with the given name is found, false otherwise.
*/
boolean collectionExists(String collectionName);
@@ -212,8 +191,7 @@ public interface MongoOperations {
* <p/>
* Translate any exceptions as necessary.
*
* @param entityClass
* class that determines the collection to drop/delete.
* @param entityClass class that determines the collection to drop/delete.
*/
<T> void dropCollection(Class<T> entityClass);
@@ -222,8 +200,7 @@ public interface MongoOperations {
* <p/>
* Translate any exceptions as necessary.
*
* @param collectionName
* name of the collection to drop/delete.
* @param collectionName name of the collection to drop/delete.
*/
void dropCollection(String collectionName);
@@ -236,8 +213,7 @@ public interface MongoOperations {
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
* to map objects since the test for class type is done in the client and not on the server.
*
* @param entityClass
* the parameterized type of the returned list
* @param entityClass the parameterized type of the returned list
* @return the converted collection
*/
<T> List<T> findAll(Class<T> entityClass);
@@ -251,14 +227,12 @@ public interface MongoOperations {
* If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
* to map objects since the test for class type is done in the client and not on the server.
*
* @param entityClass
* the parameterized type of the returned list.
* @param collectionName
* name of the collection to retrieve the objects from
* @param entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from
* @return the converted collection
*/
<T> List<T> findAll(Class<T> entityClass, String collectionName);
/**
* Returns {@link GeoResult} for all entities matching the given {@link NearQuery}. Will consider entity mapping
* information to determine the collection the query is ran against.
@@ -268,24 +242,24 @@ public interface MongoOperations {
* @return
*/
<T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass);
/**
* Returns {@link GeoResult} for all entities matching the given {@link NearQuery}.
*
* @param near must not be {@literal null}.
* @param entityClass must not be {@literal null}.
* @param collectionName the collection to trigger the query against. If no collection name is given the entity class will be inspected.
* @param collectionName the collection to trigger the query against. If no collection name is given the entity class
* will be inspected.
* @return
*/
<T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass, String collectionName);
/**
* Ensure that an index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class.
* If not it will be created.
* Ensure that an index for the provided {@link IndexDefinition} exists for the collection indicated by the entity
* class. If not it will be created.
*
* @param indexDefinition
* @param entityClass
* class that determines the collection to use
* @param entityClass class that determines the collection to use
*/
void ensureIndex(IndexDefinition indexDefinition, Class<?> entityClass);
@@ -298,8 +272,8 @@ public interface MongoOperations {
void ensureIndex(IndexDefinition indexDefinition, String collectionName);
/**
* Map the results of an ad-hoc query on the collection for the entity class to a single instance of an object
* of the specified type.
* Map the results of an ad-hoc query on the collection for the entity class to a single instance of an object of the
* specified type.
* <p/>
* The object is converted from the MongoDB native representation using an instance of {@see MongoConverter}. Unless
* configured otherwise, an instance of SimpleMongoConverter will be used.
@@ -307,11 +281,9 @@ public interface MongoOperations {
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
*
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param entityClass the parameterized type of the returned list.
* @return the converted object
*/
<T> T findOne(Query query, Class<T> entityClass);
@@ -325,13 +297,11 @@ public interface MongoOperations {
* <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
*
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param collectionName
* name of the collection to retrieve the objects from
* @param entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from
*
* @return the converted object
*/
@@ -346,11 +316,9 @@ public interface MongoOperations {
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
*
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param entityClass the parameterized type of the returned list.
* @return the List of converted objects
*/
<T> List<T> find(Query query, Class<T> entityClass);
@@ -363,13 +331,11 @@ public interface MongoOperations {
* <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
*
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param collectionName
* name of the collection to retrieve the objects from
* @param entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from
*
* @return the List of converted objects
*/
@@ -383,16 +349,13 @@ public interface MongoOperations {
* <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
*
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param preparer
* allows for customization of the DBCursor used when iterating over the result set, (apply limits, skips and
* so on).
* @param collectionName
* name of the collection to retrieve the objects from
* @param entityClass the parameterized type of the returned list.
* @param preparer allows for customization of the DBCursor used when iterating over the result set, (apply limits,
* skips and so on).
* @param collectionName name of the collection to retrieve the objects from
*
* @return the List of converted objects.
*/
@@ -408,9 +371,10 @@ public interface MongoOperations {
* @return the document with the given id mapped onto the given target class.
*/
<T> T findById(Object id, Class<T> entityClass);
/**
* Returns the document with the given id from the given collection mapped onto the given target class.
*
* @param id the id of the document to return
* @param entityClass the type to convert the document to
* @param collectionName the collection to query for the document
@@ -421,20 +385,18 @@ public interface MongoOperations {
<T> T findById(Object id, Class<T> entityClass, String collectionName);
/**
* Map the results of an ad-hoc query on the collection for the entity type to a single instance of an
* object of the specified type. The first document that matches the query is returned and also removed from
* the collection in the database.
* Map the results of an ad-hoc query on the collection for the entity type to a single instance of an object of the
* specified type. The first document that matches the query is returned and also removed from the collection in the
* database.
* <p/>
* The object is converted from the MongoDB native representation using an instance of {@see MongoConverter}.
* <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
*
* @param query
* the query class that specifies the criteria used to find a
* record and also an optional fields specification
* @param entityClass
* the parameterized type of the returned list.
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass the parameterized type of the returned list.
* @return the converted object
*/
<T> T findAndRemove(Query query, Class<T> entityClass);
@@ -448,13 +410,11 @@ public interface MongoOperations {
* <p/>
* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more
* feature rich {@link Query}.
* @param query
* the query class that specifies the criteria used to find a record and also an optional fields
*
* @param query the query class that specifies the criteria used to find a record and also an optional fields
* specification
* @param entityClass
* the parameterized type of the returned list.
* @param collectionName
* name of the collection to retrieve the objects from
* @param entityClass the parameterized type of the returned list.
* @param collectionName name of the collection to retrieve the objects from
*
* @return the converted object
*/
@@ -474,8 +434,7 @@ public interface MongoOperations {
* <p/>
* Insert is used to initially store the object into the database. To update an existing object use the save method.
*
* @param objectToSave
* the object to store in the collection.
* @param objectToSave the object to store in the collection.
*/
void insert(Object objectToSave);
@@ -486,44 +445,39 @@ public interface MongoOperations {
* configured otherwise, an instance of SimpleMongoConverter will be used.
* <p/>
* Insert is used to initially store the object into the database. To update an existing object use the save method.
* @param objectToSave
* the object to store in the collection
* @param collectionName
* name of the collection to store the object in
*
* @param objectToSave the object to store in the collection
* @param collectionName name of the collection to store the object in
*/
void insert(Object objectToSave, String collectionName);
/**
* Insert a Collection of objects into a collection in a single batch write to the database.
*
* @param batchToSave
* the list of objects to save.
* @param entityClass
* class that determines the collection to use
* @param batchToSave the list of objects to save.
* @param entityClass class that determines the collection to use
*/
void insert(Collection<? extends Object> batchToSave, Class<?> entityClass);
/**
* Insert a list of objects into the specified collection in a single batch write to the database.
* @param batchToSave
* the list of objects to save.
* @param collectionName
* name of the collection to store the object in
*
* @param batchToSave the list of objects to save.
* @param collectionName name of the collection to store the object in
*/
void insert(Collection<? extends Object> batchToSave, String collectionName);
/**
* Insert a mixed Collection of objects into a database collection determining the
* collection name to use based on the class.
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
* class.
*
* @param collectionToSave
* the list of objects to save.
* @param collectionToSave the list of objects to save.
*/
void insertAll(Collection<? extends Object> objectsToSave);
/**
* Save the object to the collection for the entity type of the object to save. This will perform an
* insert if the object is not already present, that is an 'upsert'.
* Save the object to the collection for the entity type of the object to save. This will perform an insert if the
* object is not already present, that is an 'upsert'.
* <p/>
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
* configured otherwise, an instance of SimpleMongoConverter will be used.
@@ -534,8 +488,7 @@ public interface MongoOperations {
* See <a href="http://static.springsource.org/spring/docs/3.0.x/reference/validation.html#core-convert">Spring 3 Type
* Conversion"</a> for more details.
*
* @param objectToSave
* the object to store in the collection
* @param objectToSave the object to store in the collection
*/
void save(Object objectToSave);
@@ -551,58 +504,53 @@ public interface MongoOperations {
* property type will be handled by Spring's BeanWrapper class that leverages Spring 3.0's new Type Cobnversion API.
* See <a href="http://static.springsource.org/spring/docs/3.0.x/reference/validation.html#core-convert">Spring 3 Type
* Conversion"</a> for more details.
* @param objectToSave
* the object to store in the collection
* @param collectionName
* name of the collection to store the object in
*
* @param objectToSave the object to store in the collection
* @param collectionName name of the collection to store the object in
*/
void save(Object objectToSave, String collectionName);
/**
* Updates the first object that is found in the collection of the entity class that matches the query document with
* the provided update document.
* @param query
* the query document that specifies the criteria used to select a record to be updated
* @param update
* the update document that contains the updated object or $ operators to manipulate the existing object.
* @param entityClass
* class that determines the collection to use
*
* @param query the query document that specifies the criteria used to select a record to be updated
* @param update the update document that contains the updated object or $ operators to manipulate the existing
* object.
* @param entityClass class that determines the collection to use
*/
WriteResult updateFirst(Query query, Update update, Class<?> entityClass);
/**
* Updates the first object that is found in the specified collection that matches the query document criteria with
* the provided updated document.
* @param query
* the query document that specifies the criteria used to select a record to be updated
* @param update
* the update document that contains the updated object or $ operators to manipulate the existing object.
* @param collectionName
* name of the collection to update the object in
*
* @param query the query document that specifies the criteria used to select a record to be updated
* @param update the update document that contains the updated object or $ operators to manipulate the existing
* object.
* @param collectionName name of the collection to update the object in
*/
WriteResult updateFirst(Query query, Update update, String collectionName);
/**
* Updates all objects that are found in the collection for the entity class that matches the query document criteria
* with the provided updated document.
* @param query
* the query document that specifies the criteria used to select a record to be updated
* @param update
* the update document that contains the updated object or $ operators to manipulate the existing object.
* @param entityClass
* class that determines the collection to use
*
* @param query the query document that specifies the criteria used to select a record to be updated
* @param update the update document that contains the updated object or $ operators to manipulate the existing
* object.
* @param entityClass class that determines the collection to use
*/
WriteResult updateMulti(Query query, Update update, Class<?> entityClass);
/**
* Updates all objects that are found in the specified collection that matches the query document criteria with the
* provided updated document.
* @param query
* the query document that specifies the criteria used to select a record to be updated
* @param update
* the update document that contains the updated object or $ operators to manipulate the existing object.
* @param collectionName
* name of the collection to update the object in
*
* @param query the query document that specifies the criteria used to select a record to be updated
* @param update the update document that contains the updated object or $ operators to manipulate the existing
* object.
* @param collectionName name of the collection to update the object in
*/
WriteResult updateMulti(Query query, Update update, String collectionName);
@@ -614,10 +562,8 @@ public interface MongoOperations {
void remove(Object object);
/**
* Remove all documents that match the provided query document criteria from
* the the collection used to store the entityClass. The Class parameter is
* also used to help convert the Id of the object if it is present in the
* query.
* Remove all documents that match the provided query document criteria from the the collection used to store the
* entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query.
*
* @param <T>
* @param query
@@ -626,12 +572,11 @@ public interface MongoOperations {
<T> void remove(Query query, Class<T> entityClass);
/**
* Remove all documents from the specified collection that match the provided query document criteria.
* There is no conversion/mapping done for any criteria using the id field.
* @param query
* the query document that specifies the criteria used to remove a record
* @param collectionName
* name of the collection where the objects will removed
* Remove all documents from the specified collection that match the provided query document criteria. There is no
* conversion/mapping done for any criteria using the id field.
*
* @param query the query document that specifies the criteria used to remove a record
* @param collectionName name of the collection where the objects will removed
*/
void remove(Query query, String collectionName);

View File

@@ -55,47 +55,44 @@ public class MongoOptionsFactoryBean implements FactoryBean<MongoOptions>, Initi
* socket timeout. 0 is default and infinite
*/
private int socketTimeout = MONGO_OPTIONS.socketTimeout;
/**
* This controls whether or not to have socket keep alive
* turned on (SO_KEEPALIVE).
*
* defaults to false
*/
public boolean socketKeepAlive = MONGO_OPTIONS.socketKeepAlive;
/**
* This controls whether or not to have socket keep alive turned on (SO_KEEPALIVE).
*
* defaults to false
*/
public boolean socketKeepAlive = MONGO_OPTIONS.socketKeepAlive;
/**
* this controls whether or not on a connect, the system retries automatically
*/
private boolean autoConnectRetry = MONGO_OPTIONS.autoConnectRetry;
/**
* This specifies the number of servers to wait for on the write operation, and exception raising behavior.
*
* Defaults to 0.
*/
private int writeNumber;
/**
* This controls timeout for write operations in milliseconds.
*
* Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait.
*/
private int writeTimeout;
/**
* This controls whether or not to fsync.
*
* Defaults to false.
*/
private boolean writeFsync;
/**
* Specifies if the driver is allowed to read from secondaries
* or slaves.
*
* Defaults to false
* This specifies the number of servers to wait for on the write operation, and exception raising behavior.
*
* Defaults to 0.
*/
private int writeNumber;
/**
* This controls timeout for write operations in milliseconds.
*
* Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait.
*/
private int writeTimeout;
/**
* This controls whether or not to fsync.
*
* Defaults to false.
*/
private boolean writeFsync;
/**
* Specifies if the driver is allowed to read from secondaries or slaves.
*
* Defaults to false
*/
private boolean slaveOk = MONGO_OPTIONS.slaveOk;
@@ -135,60 +132,64 @@ public class MongoOptionsFactoryBean implements FactoryBean<MongoOptions>, Initi
public void setSocketTimeout(int socketTimeout) {
this.socketTimeout = socketTimeout;
}
/**
* This controls whether or not to have socket keep alive
*
* @param socketKeepAlive
*/
public void setSocketKeepAlive(boolean socketKeepAlive) {
this.socketKeepAlive = socketKeepAlive;
}
/**
* This specifies the number of servers to wait for on the write operation, and exception raising behavior.
* The 'w' option to the getlasterror command. Defaults to 0.
* <ul>
* <li>-1 = don't even report network errors </li>
* <li> 0 = default, don't call getLastError by default </li>
* <li> 1 = basic, call getLastError, but don't wait for slaves</li>
* <li> 2+= wait for slaves </li>
* </ul>
* @param writeNumber the number of servers to wait for on the write operation, and exception raising behavior.
*/
public void setWriteNumber(int writeNumber) {
this.writeNumber = writeNumber;
}
public void setSocketKeepAlive(boolean socketKeepAlive) {
this.socketKeepAlive = socketKeepAlive;
}
/**
* This controls timeout for write operations in milliseconds. The 'wtimeout' option to the getlasterror command.
*
* @param writeTimeout Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait.
* This specifies the number of servers to wait for on the write operation, and exception raising behavior. The 'w'
* option to the getlasterror command. Defaults to 0.
* <ul>
* <li>-1 = don't even report network errors</li>
* <li>0 = default, don't call getLastError by default</li>
* <li>1 = basic, call getLastError, but don't wait for slaves</li>
* <li>2+= wait for slaves</li>
* </ul>
*
* @param writeNumber the number of servers to wait for on the write operation, and exception raising behavior.
*/
public void setWriteTimeout(int writeTimeout) {
this.writeTimeout = writeTimeout;
}
public void setWriteNumber(int writeNumber) {
this.writeNumber = writeNumber;
}
/**
* This controls whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false.
* @param writeFsync to fsync on write (true), otherwise false.
*/
public void setWriteFsync(boolean writeFsync) {
this.writeFsync = writeFsync;
}
/**
* This controls timeout for write operations in milliseconds. The 'wtimeout' option to the getlasterror command.
*
* @param writeTimeout Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait.
*/
public void setWriteTimeout(int writeTimeout) {
this.writeTimeout = writeTimeout;
}
/**
/**
* This controls whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false.
*
* @param writeFsync to fsync on write (true), otherwise false.
*/
public void setWriteFsync(boolean writeFsync) {
this.writeFsync = writeFsync;
}
/**
* this controls whether or not on a connect, the system retries automatically
*/
public void setAutoConnectRetry(boolean autoConnectRetry) {
this.autoConnectRetry = autoConnectRetry;
}
/**
* Specifies if the driver is allowed to read from secondaries or slaves. Defaults to false.
* Specifies if the driver is allowed to read from secondaries or slaves. Defaults to false.
*
* @param slaveOk true if the driver should read from secondaries or slaves.
*/
public void setSlaveOk(boolean slaveOk) {
this.slaveOk = slaveOk;
this.slaveOk = slaveOk;
}
public void afterPropertiesSet() {
@@ -198,8 +199,8 @@ public class MongoOptionsFactoryBean implements FactoryBean<MongoOptions>, Initi
MONGO_OPTIONS.connectTimeout = connectTimeout;
MONGO_OPTIONS.socketTimeout = socketTimeout;
MONGO_OPTIONS.socketKeepAlive = socketKeepAlive;
MONGO_OPTIONS.autoConnectRetry = autoConnectRetry;
MONGO_OPTIONS.slaveOk = slaveOk;
MONGO_OPTIONS.autoConnectRetry = autoConnectRetry;
MONGO_OPTIONS.slaveOk = slaveOk;
MONGO_OPTIONS.w = writeNumber;
MONGO_OPTIONS.wtimeout = writeTimeout;
MONGO_OPTIONS.fsync = writeFsync;

View File

@@ -440,27 +440,27 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
public <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass) {
return geoNear(near, entityClass, determineCollectionName(entityClass));
}
public <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass, String collectionName) {
String collection = StringUtils.hasText(collectionName) ? collectionName : determineCollectionName(entityClass);
BasicDBObject command = new BasicDBObject("geoNear", collection);
command.putAll(near.toDBObject());
CommandResult commandResult = executeCommand(command);
BasicDBList results = (BasicDBList) commandResult.get("results");
DbObjectCallback<GeoResult<T>> callback = new GeoNearResultDbObjectCallback<T>(new ReadDbObjectCallback<T>(mongoConverter, entityClass), near.getMetric());
DbObjectCallback<GeoResult<T>> callback = new GeoNearResultDbObjectCallback<T>(new ReadDbObjectCallback<T>(
mongoConverter, entityClass), near.getMetric());
List<GeoResult<T>> result = new ArrayList<GeoResult<T>>(results.size());
for (Object element : results) {
result.add(callback.doWith((DBObject) element));
}
double averageDistance = (Double) ((DBObject) commandResult.get("stats")).get("avgDistance");
return new GeoResults<T>(result, new Distance(averageDistance, near.getMetric()));
}
// Find methods that take a Query to express the query and that return a single object that is also removed from the
// collection in the database.
@@ -707,10 +707,11 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
return execute(collectionName, new CollectionCallback<WriteResult>() {
public WriteResult doInCollection(DBCollection collection) throws MongoException, DataAccessException {
MongoPersistentEntity<?> entity = entityClass == null ? null : getPersistentEntity(entityClass);
DBObject queryObj = query == null ? new BasicDBObject() : mapper.getMappedObject(query.getQueryObject(), entity);
DBObject queryObj = query == null ? new BasicDBObject()
: mapper.getMappedObject(query.getQueryObject(), entity);
DBObject updateObj = update.getUpdateObject();
for (String key : updateObj.keySet()) {

View File

@@ -33,7 +33,7 @@ import com.mongodb.DBObject;
/**
* A helper class to encapsulate any modifications of a Query object before it gets submitted to the database.
*
*
* @author Jon Brisbin <jbrisbin@vmware.com>
* @author Oliver Gierke
*/
@@ -43,7 +43,7 @@ public class QueryMapper {
/**
* Creates a new {@link QueryMapper} with the given {@link ConversionService}.
*
*
* @param conversionService must not be {@literal null}.
*/
public QueryMapper(ConversionService conversionService) {
@@ -54,7 +54,7 @@ public class QueryMapper {
/**
* Replaces the property keys used in the given {@link DBObject} with the appropriate keys by using the
* {@link PersistentEntity} metadata.
*
*
* @param query
* @param entity
* @return
@@ -87,7 +87,7 @@ public class QueryMapper {
value = getMappedObject((DBObject) value, entity);
}
} else {
value = convertId(value);
}
newKey = "_id";
@@ -116,20 +116,20 @@ public class QueryMapper {
*/
@SuppressWarnings("unchecked")
public Object convertId(Object id) {
for (Class<?> type : Arrays.asList(ObjectId.class, String.class)) {
if (id.getClass().isAssignableFrom(type)) {
return id;
}
try {
return conversionService.convert(id, type);
} catch (ConversionException e) {
// Ignore
}
}
return id;
}
}

View File

@@ -91,15 +91,15 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory {
* @see org.springframework.data.mongodb.MongoDbFactory#getDb(java.lang.String)
*/
public DB getDb(String dbName) throws DataAccessException {
Assert.hasText(dbName, "Database name must not be empty.");
DB db = MongoDbUtils.getDB(mongo, dbName, username, password == null ? null : password.toCharArray());
if (writeConcern != null) {
db.setWriteConcern(writeConcern);
}
return db;
}

View File

@@ -86,11 +86,10 @@ public abstract class AbstractMongoConverter implements MongoConverter, Initiali
if (!conversionService.canConvert(String.class, BigInteger.class)) {
conversionService.addConverter(StringToBigIntegerConverter.INSTANCE);
}
conversions.registerConvertersIn(conversionService);
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getConversionService()

View File

@@ -24,7 +24,7 @@ import org.springframework.data.util.TypeInformation;
import org.springframework.util.Assert;
/**
* {@link TypeMapper} allowing to configure a {@link Map} containing {@link String} to {@link Class} mappings that will
* {@link TypeMapper} allowing to configure a {@link Map} containing {@link Class} to {@link String} mappings that will
* be used to map the values found under the configured type key (see {@link DefaultTypeMapper#setTypeKey(String)}. This
* allows declarative type mapping in a Spring config file for example.
*
@@ -81,7 +81,7 @@ public class ConfigurableTypeMapper extends DefaultTypeMapper {
return entry.getKey();
}
}
return handleUnmappedClasses ? super.getTypeInformation(value) : null;
}

View File

@@ -49,10 +49,10 @@ import com.mongodb.DBObject;
* @author Oliver Gierke
*/
public class CustomConversions {
@SuppressWarnings({ "unchecked" })
private static final List<Class<?>> MONGO_TYPES = Arrays.asList(Number.class, Date.class, ObjectId.class, String.class,
DBObject.class);
private static final List<Class<?>> MONGO_TYPES = Arrays.asList(Number.class, Date.class, ObjectId.class,
String.class, DBObject.class);
private final Set<ConvertiblePair> readingPairs;
private final Set<ConvertiblePair> writingPairs;

View File

@@ -98,13 +98,13 @@ public class DefaultTypeMapper implements TypeMapper {
public void writeType(TypeInformation<?> info, DBObject dbObject) {
Assert.notNull(info);
if (typeKey == null) {
return;
}
String string = getTypeString(info);
if (string != null) {
dbObject.put(typeKey, getTypeString(info));
}
@@ -133,11 +133,11 @@ public class DefaultTypeMapper implements TypeMapper {
* class cannot be loaded.
*/
protected TypeInformation<?> getTypeInformation(String value) {
if (!StringUtils.hasText(value)) {
return null;
}
try {
return ClassTypeInformation.from(ClassUtils.forName(value, null));
} catch (ClassNotFoundException e) {

View File

@@ -72,7 +72,8 @@ import org.springframework.util.StringUtils;
* @author Jon Brisbin <jbrisbin@vmware.com>
* @author Oliver Gierke
*/
public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware, TypeMapperProvider {
public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware,
TypeMapperProvider {
@SuppressWarnings("rawtypes")
private static final TypeInformation<Map> MAP_TYPE_INFORMATION = ClassTypeInformation.from(Map.class);
@@ -116,7 +117,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
public void setTypeMapper(TypeMapper typeMapper) {
this.typeMapper = typeMapper == null ? new DefaultTypeMapper() : typeMapper;
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.convert.MongoConverter#getTypeMapper()
@@ -124,7 +125,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
public TypeMapper getTypeMapper() {
return this.typeMapper;
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getMappingContext()
@@ -143,7 +144,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
public void setUseFieldAccessOnly(boolean useFieldAccessOnly) {
this.useFieldAccessOnly = useFieldAccessOnly;
}
/*
* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
@@ -785,7 +786,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
protected Map<Object, Object> readMap(TypeInformation<?> type, DBObject dbObject) {
Assert.notNull(dbObject);
Class<?> mapType = getMoreConcreteTargetType(dbObject, type).getType();
Map<Object, Object> map = CollectionFactory.createMap(mapType, dbObject.keySet().size());
Map<String, Object> sourceMap = dbObject.toMap();
@@ -829,15 +830,15 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
protected TypeInformation<?> findTypeToBeUsed(DBObject dbObject) {
return typeMapper.readType(dbObject);
}
private Class<?> getDefaultedTypeToBeUsed(DBObject dbObject) {
TypeInformation<?> result = findTypeToBeUsed(dbObject);
if (result != null) {
return result.getType();
}
return dbObject instanceof BasicDBList ? List.class : Map.class;
TypeInformation<?> result = findTypeToBeUsed(dbObject);
if (result != null) {
return result.getType();
}
return dbObject instanceof BasicDBList ? List.class : Map.class;
}
/**
@@ -854,7 +855,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
Class<?> documentsTargetType = getDefaultedTypeToBeUsed(dbObject);
Class<S> rawType = basicType == null ? null : basicType.getType();
boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType);
boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType)
&& !rawType.equals(documentsTargetType);
return isMoreConcreteCustomType ? (TypeInformation<? extends S>) ClassTypeInformation.from(documentsTargetType)
: basicType;
}

View File

@@ -22,7 +22,7 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
/**
* Central Mongo specific converter interface which combines {@link MongoWriter} and {@link MongoReader}.
*
*
* @author Oliver Gierke
*/
public interface MongoConverter extends MongoWriter<Object>, MongoReader<Object> {
@@ -33,7 +33,7 @@ public interface MongoConverter extends MongoWriter<Object>, MongoReader<Object>
* @return never {@literal null}
*/
MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> getMappingContext();
/**
* Returns the underlying {@link ConversionService} used by the converter.
*

View File

@@ -88,7 +88,6 @@ abstract class MongoConverters {
}
}
public static enum BigDecimalToStringConverter implements Converter<BigDecimal, String> {
INSTANCE;
@@ -96,10 +95,10 @@ abstract class MongoConverters {
return source == null ? null : source.toString();
}
}
public static enum StringToBigDecimalConverter implements Converter<String, BigDecimal> {
INSTANCE;
public BigDecimal convert(String source) {
return StringUtils.hasText(source) ? new BigDecimal(source) : null;
}
@@ -112,10 +111,10 @@ abstract class MongoConverters {
return source == null ? null : source.toString();
}
}
public static enum StringToBigIntegerConverter implements Converter<String, BigInteger> {
INSTANCE;
public BigInteger convert(String source) {
return StringUtils.hasText(source) ? new BigInteger(source) : null;
}

View File

@@ -30,13 +30,11 @@ public interface MongoWriter<T> {
/**
* Write the given object of type T to the native MongoDB object representation DBObject.
*
* @param t
* The object to convert to a DBObject
* @param dbo
* The DBObject to use for writing.
* @param t The object to convert to a DBObject
* @param dbo The DBObject to use for writing.
*/
void write(T t, DBObject dbo);
/**
* Converts the given object into one Mongo will be able to store natively. If the given object can already be stored
* as is, no conversion will happen.

View File

@@ -21,7 +21,7 @@ import com.mongodb.DBObject;
/**
* Interface to define strategies how to store type information in a {@link DBObject}.
*
*
* @author Oliver Gierke
*/
public interface TypeMapper {
@@ -33,7 +33,7 @@ public interface TypeMapper {
* @return
*/
boolean isTypeKey(String key);
/**
* Reads the {@link TypeInformation} from the given {@link DBObject}.
*
@@ -41,7 +41,7 @@ public interface TypeMapper {
* @return
*/
TypeInformation<?> readType(DBObject dbObject);
/**
* Writes type information for the given type into the given {@link DBObject}.
*
@@ -49,7 +49,7 @@ public interface TypeMapper {
* @param dbObject must not be {@literal null}.
*/
void writeType(Class<?> type, DBObject dbObject);
/**
* Writes type information for the given {@link TypeInformation} into the given {@link DBObject}.
*

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.convert;
/**
* Interfaces for components being able to provide a {@link TypeMapper}.
*
*
* @author Oliver Gierke
*/
public interface TypeMapperProvider {

View File

@@ -42,7 +42,7 @@ public class GeoResults<T> implements Iterable<GeoResult<T>> {
public GeoResults(List<GeoResult<T>> results) {
this(results, (Metric) null);
}
public GeoResults(List<GeoResult<T>> results, Metric metric) {
this(results, calculateAverageDistance(results, metric));
}
@@ -117,7 +117,7 @@ public class GeoResults<T> implements Iterable<GeoResult<T>> {
result += 31 * averageDistance.hashCode();
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()

View File

@@ -4,7 +4,7 @@ import org.springframework.data.mongodb.core.query.NearQuery;
/**
* Commonly used {@link Metrics} for {@link NearQuery}s.
*
*
* @author Oliver Gierke
*/
public enum Metrics implements Metric {

View File

@@ -58,7 +58,7 @@ public class Point {
public double[] asArray() {
return new double[] { x, y };
}
public List<Double> asList() {
return Arrays.asList(x, y);
}

View File

@@ -22,7 +22,7 @@ import com.mongodb.DBObject;
/**
* Value object to capture data to create a geo index.
*
*
* @author Jon Brisbin
* @author Oliver Gierke
*/

View File

@@ -40,11 +40,12 @@ import org.springframework.util.StringUtils;
/**
* Component that inspects {@link BasicMongoPersistentEntity} instances contained in the given
* {@link MongoMappingContext} for indexing metadata and ensures the indexes to be available.
*
*
* @author Jon Brisbin <jbrisbin@vmware.com>
* @author Oliver Gierke
*/
public class MongoPersistentEntityIndexCreator implements ApplicationListener<MappingContextEvent<MongoPersistentEntity<MongoPersistentProperty>, MongoPersistentProperty>> {
public class MongoPersistentEntityIndexCreator implements
ApplicationListener<MappingContextEvent<MongoPersistentEntity<MongoPersistentProperty>, MongoPersistentProperty>> {
private static final Log log = LogFactory.getLog(MongoPersistentEntityIndexCreator.class);
@@ -52,7 +53,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener<Ma
private final MongoDbFactory mongoDbFactory;
/**
* Creats a new {@link MongoPersistentEntityIndexCreator} for the given {@link MongoMappingContext} and {@link MongoDbFactory}.
* Creats a new {@link MongoPersistentEntityIndexCreator} for the given {@link MongoMappingContext} and
* {@link MongoDbFactory}.
*
* @param mappingContext must not be {@@iteral null}
* @param mongoDbFactory must not be {@@iteral null}
@@ -72,7 +74,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener<Ma
* (non-Javadoc)
* @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
*/
public void onApplicationEvent(MappingContextEvent<MongoPersistentEntity<MongoPersistentProperty>, MongoPersistentProperty> event) {
public void onApplicationEvent(
MappingContextEvent<MongoPersistentEntity<MongoPersistentProperty>, MongoPersistentProperty> event) {
checkForIndexes(event.getPersistentEntity());
}
@@ -130,7 +133,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener<Ma
indexObject.named(StringUtils.hasText(index.name()) ? index.name() : field.getName());
String collection = StringUtils.hasText(index.collection()) ? index.collection() : entity.getCollection();
mongoDbFactory.getDb().getCollection(collection).ensureIndex(indexObject.getIndexKeys(), indexObject.getIndexOptions());
mongoDbFactory.getDb().getCollection(collection)
.ensureIndex(indexObject.getIndexKeys(), indexObject.getIndexOptions());
if (log.isDebugEnabled()) {
log.debug(String.format("Created %s for entity %s in collection %s! ", indexObject, entity.getType(),
@@ -144,13 +148,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener<Ma
}
}
protected void ensureIndex(String collection,
final String name,
final String def,
final IndexDirection direction,
final boolean unique,
final boolean dropDups,
final boolean sparse) {
protected void ensureIndex(String collection, final String name, final String def, final IndexDirection direction,
final boolean unique, final boolean dropDups, final boolean sparse) {
DBObject defObj;
if (null != def) {
defObj = (DBObject) JSON.parse(def);

View File

@@ -65,14 +65,14 @@ public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, Mong
public String getCollection() {
return collection;
}
/**
* {@link Comparator} implementation inspecting the {@link MongoPersistentProperty}'s order.
*
*
* @author Oliver Gierke
*/
static enum MongoPersistentPropertyComparator implements Comparator<MongoPersistentProperty> {
INSTANCE;
/*
@@ -80,15 +80,15 @@ public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, Mong
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(MongoPersistentProperty o1, MongoPersistentProperty o2) {
if (o1.getFieldOrder() == Integer.MAX_VALUE) {
return 1;
}
if (o2.getFieldOrder() == Integer.MAX_VALUE) {
return -1;
}
return o1.getFieldOrder() - o2.getFieldOrder();
}
}

View File

@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
/**
* Annotation to define custom metadata for document fields.
*
*
* @author Oliver Gierke
*/
@Documented
@@ -15,12 +15,14 @@ public @interface Field {
/**
* The key to be used to store the field inside the document.
*
* @return
*/
String value() default "";
/**
* The order in which various fields shall be stored. Has to be a positive integer.
*
* @return the order the field shall have in the document or -1 if undefined.
*/
int order() default Integer.MAX_VALUE;

View File

@@ -28,7 +28,7 @@ import org.springframework.data.util.TypeInformation;
* @author Oliver Gierke ogierke@vmware.com
*/
public class MongoMappingContext extends AbstractMappingContext<BasicMongoPersistentEntity<?>, MongoPersistentProperty> {
/**
* Creates a new {@link MongoMappingContext}.
*/

View File

@@ -23,14 +23,14 @@ import org.springframework.data.mapping.PersistentProperty;
* @author Oliver Gierke
*/
public interface MongoPersistentProperty extends PersistentProperty<MongoPersistentProperty> {
/**
* Returns the name of the field a property is persisted to.
*
* @return
*/
String getFieldName();
/**
* Returns the order of the field if defined. Will return -1 if undefined.
*
@@ -45,7 +45,7 @@ public interface MongoPersistentProperty extends PersistentProperty<MongoPersist
* @return
*/
boolean isDbReference();
/**
* Returns the {@link DBRef} if the property is a reference.
*

View File

@@ -30,7 +30,7 @@ import com.mongodb.DBRef;
* @author Oliver Gierke
*/
public abstract class MongoSimpleTypes {
private static final Set<Class<?>> MONGO_SIMPLE_TYPES = new HashSet<Class<?>>();
static {
@@ -38,7 +38,7 @@ public abstract class MongoSimpleTypes {
MONGO_SIMPLE_TYPES.add(ObjectId.class);
MONGO_SIMPLE_TYPES.add(CodeWScope.class);
}
public static final SimpleTypeHolder HOLDER = new SimpleTypeHolder(MONGO_SIMPLE_TYPES, true);
private MongoSimpleTypes() {

View File

@@ -64,7 +64,8 @@ public class SimpleMongoMappingContext extends
* @param propertyDescriptor
* @param information
*/
public SimplePersistentProperty(Field field, PropertyDescriptor propertyDescriptor, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
public SimplePersistentProperty(Field field, PropertyDescriptor propertyDescriptor, MongoPersistentEntity<?> owner,
SimpleTypeHolder simpleTypeHolder) {
super(field, propertyDescriptor, owner, simpleTypeHolder);
}
@@ -81,7 +82,7 @@ public class SimpleMongoMappingContext extends
public String getFieldName() {
return isIdProperty() ? "_id" : getName();
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#getFieldOrder()
@@ -97,14 +98,14 @@ public class SimpleMongoMappingContext extends
protected Association<MongoPersistentProperty> createAssociation() {
return new Association<MongoPersistentProperty>(this, null);
}
/* (non-Javadoc)
* @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#isDbReference()
*/
public boolean isDbReference() {
return false;
}
/* (non-Javadoc)
* @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#getDBRef()
*/

View File

@@ -21,7 +21,7 @@ import com.mongodb.util.JSON;
/**
* Custom {@link Query} implementation to setup a basic query from some arbitrary JSON query string.
*
*
* @author Thomas Risberg
* @author Oliver Gierke
*/
@@ -67,17 +67,17 @@ public class BasicQuery extends Query {
@Override
public DBObject getSortObject() {
BasicDBObject result = new BasicDBObject();
if (sortObject != null) {
result.putAll(sortObject);
}
DBObject overrides = super.getSortObject();
if (overrides != null) {
result.putAll(overrides);
}
return result;
}

View File

@@ -89,8 +89,7 @@ public class Criteria implements CriteriaDefinition {
"Multiple 'is' values declared. You need to use 'and' with multiple criteria");
}
if (this.criteria.size() > 0 && "$not".equals(this.criteria.keySet().toArray()[this.criteria.size() - 1])) {
throw new InvalidMongoDbApiUsageException(
"Invalid query: 'not' can't be used with 'is' - use 'ne' instead.");
throw new InvalidMongoDbApiUsageException("Invalid query: 'not' can't be used with 'is' - use 'ne' instead.");
}
this.isValue = o;
return this;
@@ -154,8 +153,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a criterion using the $in operator
*
* @param o
* the values to match against
* @param o the values to match against
* @return
*/
public Criteria in(Object... o) {
@@ -170,8 +168,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a criterion using the $in operator
*
* @param c
* the collection containing the values to match against
* @param c the collection containing the values to match against
* @return
*/
public Criteria in(Collection<?> c) {
@@ -288,8 +285,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a geospatial criterion using a $within $center operation
*
* @param circle
* must not be {@literal null}
* @param circle must not be {@literal null}
* @return
*/
public Criteria withinCenter(Circle circle) {
@@ -304,8 +300,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a geospatial criterion using a $within $center operation. This is only available for Mongo 1.7 and higher.
*
* @param circle
* must not be {@literal null}
* @param circle must not be {@literal null}
* @return
*/
public Criteria withinCenterSphere(Circle circle) {
@@ -335,8 +330,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a geospatial criterion using a $near operation
*
* @param point
* must not be {@literal null}
* @param point must not be {@literal null}
* @return
*/
public Criteria near(Point point) {
@@ -348,8 +342,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a geospatial criterion using a $nearSphere operation. This is only available for Mongo 1.7 and higher.
*
* @param point
* must not be {@literal null}
* @param point must not be {@literal null}
* @return
*/
public Criteria nearSphere(Point point) {

View File

@@ -103,7 +103,7 @@ public class NearQuery {
Assert.notNull(point);
return new NearQuery(point, metric);
}
/**
* Returns the {@link Metric} underlying the actual query.
*
@@ -149,7 +149,7 @@ public class NearQuery {
this.spherical(true);
return maxDistance(getNormalizedDistance(maxDistance, metric));
}
/**
* Sets the maximum distance to the given {@link Distance}.
*
@@ -259,7 +259,7 @@ public class NearQuery {
return dbObject;
}
private double getNormalizedDistance(double distance, Metric metric) {
return metric == null ? distance : distance / metric.getMultiplier();
}

View File

@@ -39,8 +39,7 @@ public abstract class AbstractMonitor {
/**
* Sets the username to use to connect to the Mongo database
*
* @param username
* The username to use
* @param username The username to use
*/
public void setUsername(String username) {
this.username = username;
@@ -49,8 +48,7 @@ public abstract class AbstractMonitor {
/**
* Sets the password to use to authenticate with the Mongo database.
*
* @param password
* The password to use
* @param password The password to use
*/
public void setPassword(String password) {

View File

@@ -188,7 +188,7 @@ public abstract class AbstractMongoQuery implements RepositoryQuery {
*/
@Override
Object execute(Query query) {
MongoEntityInformation<?, ?> entityInformation = method.getEntityInformation();
return template.findOne(query, entityInformation.getJavaType());
}

View File

@@ -82,7 +82,7 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor {
return getConvertedValue(delegate.getBindableValue(index));
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoParameterAccessor#getMaxDistance()
@@ -98,15 +98,15 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor {
* @return
*/
private Object getConvertedValue(Object value) {
if (!(writer instanceof TypeMapperProvider)) {
return value;
}
TypeMapper mapper = ((TypeMapperProvider) writer).getTypeMapper();
return removeTypeInfoRecursively(writer.convertToMongoType(value), mapper);
}
/**
* Removes the type information from the conversion result.
*
@@ -114,19 +114,19 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor {
* @return
*/
private Object removeTypeInfoRecursively(Object object, TypeMapper mapper) {
if (!(object instanceof DBObject) || mapper == null) {
return object;
}
DBObject dbObject = (DBObject) object;
String keyToRemove = null;
for (String key : dbObject.keySet()) {
if (mapper.isTypeKey(key)) {
keyToRemove = key;
}
Object value = dbObject.get(key);
if (value instanceof BasicDBList) {
for (Object element : (BasicDBList) value) {
@@ -136,11 +136,11 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor {
removeTypeInfoRecursively(value, mapper);
}
}
if (keyToRemove != null) {
dbObject.removeField(keyToRemove);
}
return dbObject;
}

View File

@@ -42,7 +42,7 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends A
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity) {
this(entity, null);
}
/**
* Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity} and custom
* collection name.

View File

@@ -25,19 +25,19 @@ import org.springframework.data.repository.query.Parameters;
/**
* Custom extension of {@link Parameters} discovering additional
*
*
* @author Oliver Gierke
*/
public class MongoParameters extends Parameters {
private int distanceIndex = -1;
public MongoParameters(Method method) {
super(method);
this.distanceIndex = Arrays.asList(method.getParameterTypes()).indexOf(Distance.class);
}
/* (non-Javadoc)
* @see org.springframework.data.repository.query.Parameters#createParameter(org.springframework.core.MethodParameter)
*/
@@ -49,14 +49,14 @@ public class MongoParameters extends Parameters {
public int getDistanceIndex() {
return distanceIndex;
}
/**
* Custom {@link Parameter} implementation adding parameters of type {@link Distance} to the special ones.
*
*
* @author Oliver Gierke
*/
static class MongoParameter extends Parameter {
/**
*
* @param parameter
@@ -65,7 +65,7 @@ public class MongoParameters extends Parameters {
MongoParameter(MethodParameter parameter, Parameters parameters) {
super(parameter, parameters);
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.Parameter#isSpecialParameter()

View File

@@ -20,13 +20,13 @@ import org.springframework.data.repository.query.ParametersParameterAccessor;
/**
* Mongo-specific {@link ParametersParameterAccessor} to allow access to the {@link Distance} parameter.
*
*
* @author Oliver Gierke
*/
public class MongoParametersParameterAccessor extends ParametersParameterAccessor implements MongoParameterAccessor {
private final MongoParameters parameters;
/**
* @param parameters
* @param values
@@ -35,7 +35,7 @@ public class MongoParametersParameterAccessor extends ParametersParameterAccesso
super(parameters, values);
this.parameters = parameters;
}
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoParameterAccessor#getMaxDistance()

View File

@@ -109,7 +109,7 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Query> {
protected Query complete(Query query, Sort sort) {
QueryUtils.applySorting(query, sort);
if (LOG.isDebugEnabled()) {
LOG.debug("Created query " + query.getQueryObject());
}
@@ -146,10 +146,10 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Query> {
String value = parameters.next().toString();
return criteria.is(toLikeRegex(value));
case NEAR:
Distance distance = accessor.getMaxDistance();
Point point = nextAs(parameters, Point.class);
if (distance == null) {
return criteria.near(point);
} else {
@@ -161,7 +161,7 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Query> {
criteria.maxDistance(distance.getNormalizedValue());
}
return criteria;
case WITHIN:
Object parameter = parameters.next();
if (parameter instanceof Box) {
@@ -185,8 +185,7 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Query> {
* @param <T>
* @param iterator
* @param type
* @throws IllegalArgumentException
* in case the next element in the iterator is not of the given type.
* @throws IllegalArgumentException in case the next element in the iterator is not of the given type.
* @return
*/
@SuppressWarnings("unchecked")

View File

@@ -44,10 +44,10 @@ class MongoQueryMethod extends QueryMethod {
public MongoQueryMethod(Method method, RepositoryMetadata metadata, EntityInformationCreator entityInformationCreator) {
super(method, metadata);
this.method = method;
this.entityInformation = entityInformationCreator.getEntityInformation(
ClassUtils.getReturnedDomainClass(method), getDomainClass());
this.entityInformation = entityInformationCreator.getEntityInformation(ClassUtils.getReturnedDomainClass(method),
getDomainClass());
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryMethod#getParameters(java.lang.reflect.Method)
@@ -98,7 +98,7 @@ class MongoQueryMethod extends QueryMethod {
return entityInformation;
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryMethod#getParameters()

View File

@@ -154,7 +154,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* @return
*/
private MongodbQuery<T> createQueryFor(Predicate predicate) {
DBCollection collection = getMongoOperations().getCollection(getEntityInformation().getCollectionName());
MongodbQuery<T> query = new MongodbQuery<T>(collection, new Transformer<DBObject, T>() {
public T transform(DBObject input) {

View File

@@ -73,7 +73,7 @@ abstract class QueryUtils {
return query;
}
public static org.springframework.data.mongodb.core.query.Order toOrder(Order order) {
return order.isAscending() ? org.springframework.data.mongodb.core.query.Order.ASCENDING
: org.springframework.data.mongodb.core.query.Order.DESCENDING;

View File

@@ -71,7 +71,7 @@ public abstract class QuerydslRepositorySupport {
* @return
*/
protected <T> MongodbQuery<T> from(final EntityPath<T> path, String collection) {
Assert.notNull(path);
Assert.hasText(collection);

View File

@@ -114,7 +114,7 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements Paging
* )
*/
public boolean exists(final ID id) {
return template.findOne(new Query(Criteria.where("_id").is(id)), Object.class,
entityInformation.getCollectionName()) != null;
}

View File

@@ -49,7 +49,7 @@ public class StringBasedMongoQuery extends AbstractMongoQuery {
this.query = query;
this.fieldSpec = method.getFieldSpecification();
}
public StringBasedMongoQuery(MongoQueryMethod method, MongoTemplate template) {
this(method.getAnnotatedQuery(), method, template);
}