From d63014c9ee5000419c5d567de21b9f0018a8a226 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 11:32:52 -0800 Subject: [PATCH 1/8] Format POM to use tabs rather than spaces --- pom.xml | 140 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/pom.xml b/pom.xml index 6a62acd8..8ab7d93d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,22 +1,22 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.springframework.cloud - spring-cloud-commons - 1.0.0.BUILD-SNAPSHOT - jar - Spring Cloud Commons - Spring Cloud Commons + org.springframework.cloud + spring-cloud-commons + 1.0.0.BUILD-SNAPSHOT + jar + Spring Cloud Commons + Spring Cloud Commons - - org.springframework.cloud - spring-cloud-build - 1.0.0.BUILD-SNAPSHOT - - - + + org.springframework.cloud + spring-cloud-build + 1.0.0.BUILD-SNAPSHOT + + + https://github.com/spring-cloud/spring-cloud-commons @@ -25,65 +25,65 @@ HEAD - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + - - - - org.projectlombok - lombok - 1.12.6 - - - com.google.guava - guava - 18.0 - - - + + + + org.projectlombok + lombok + 1.12.6 + + + com.google.guava + guava + 18.0 + + + - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.boot - spring-boot-starter-web - true - - - org.projectlombok - lombok + + + org.springframework.boot + spring-boot-starter-actuator + true + + + org.springframework.boot + spring-boot-starter-web + true + + + org.projectlombok + lombok compile true - - - com.google.guava - guava - - - org.springframework.boot - spring-boot-starter-test - test - - + + + com.google.guava + guava + + + org.springframework.boot + spring-boot-starter-test + test + + - - - true - + + + true + From d1201469e6a395f2841455e940f56aa85f340dab Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 11:35:36 -0800 Subject: [PATCH 2/8] Polish POM --- pom.xml | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 8ab7d93d..10fddf00 100644 --- a/pom.xml +++ b/pom.xml @@ -3,28 +3,27 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.cloud - spring-cloud-commons - 1.0.0.BUILD-SNAPSHOT - jar - Spring Cloud Commons - Spring Cloud Commons - org.springframework.cloud spring-cloud-build 1.0.0.BUILD-SNAPSHOT - - + spring-cloud-commons + 1.0.0.BUILD-SNAPSHOT + jar + Spring Cloud Commons + Spring Cloud Commons https://github.com/spring-cloud/spring-cloud-commons scm:git:git://github.com/spring-cloud/spring-cloud-commons.git scm:git:ssh://git@github.com/spring-cloud/spring-cloud-commons.git HEAD - + + + true + @@ -37,7 +36,6 @@ - @@ -52,7 +50,6 @@ - org.springframework.boot @@ -80,10 +77,4 @@ test - - - - true - - From 8ac6edc577c14b2424c792eb0b3f32c89df29879 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 11:42:07 -0800 Subject: [PATCH 3/8] Add eclipse code conventions --- eclipse/eclipse-code-formatter.xml | 295 ++++++++++++++++++++++ eclipse/org.eclipse.jdt.core.prefs | 389 +++++++++++++++++++++++++++++ eclipse/org.eclipse.jdt.ui.prefs | 125 +++++++++ pom.xml | 18 ++ 4 files changed, 827 insertions(+) create mode 100644 eclipse/eclipse-code-formatter.xml create mode 100644 eclipse/org.eclipse.jdt.core.prefs create mode 100644 eclipse/org.eclipse.jdt.ui.prefs diff --git a/eclipse/eclipse-code-formatter.xml b/eclipse/eclipse-code-formatter.xml new file mode 100644 index 00000000..4694d7f2 --- /dev/null +++ b/eclipse/eclipse-code-formatter.xml @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse/org.eclipse.jdt.core.prefs b/eclipse/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..63d59166 --- /dev/null +++ b/eclipse/org.eclipse.jdt.core.prefs @@ -0,0 +1,389 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=default +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=false +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=90 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=8 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=90 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/eclipse/org.eclipse.jdt.ui.prefs b/eclipse/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..fb4753fe --- /dev/null +++ b/eclipse/org.eclipse.jdt.ui.prefs @@ -0,0 +1,125 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=true +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=false +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=false +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=false +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=false +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_type_arguments=false +cleanup_profile=_Spring Cloud Cleanup Conventions +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spring Cloud Java Conventions +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com;\#; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=9999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=9999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=true +sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/pom.xml b/pom.xml index 10fddf00..5743f833 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ HEAD + . true @@ -34,6 +35,23 @@ 1.7 + + org.apache.maven.plugins + maven-eclipse-plugin + + false + + + .settings/org.eclipse.jdt.ui.prefs + ${main.basedir}/eclipse/org.eclipse.jdt.ui.prefs + + + .settings/org.eclipse.jdt.core.prefs + ${main.basedir}/eclipse/org.eclipse.jdt.core.prefs + + + + From 4d941e1c0a3d7dbd7d102554371f4ec1c1427a36 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 11:42:42 -0800 Subject: [PATCH 4/8] Apply formatting and code cleanup rules --- .../CommonsClientAutoConfiguration.java | 10 +- .../cloud/client/DefaultServiceInstance.java | 6 +- .../cloud/client/ServiceInstance.java | 12 +- .../SingleImplementationImportSelector.java | 14 +- .../circuitbreaker/EnableCircuitBreaker.java | 9 +- .../EnableCircuitBreakerImportSelector.java | 6 +- .../discovery/AbstractDiscoveryLifecycle.java | 160 +++++++++--------- .../client/discovery/DiscoveryClient.java | 36 ++-- .../DiscoveryClientHealthIndicator.java | 19 ++- .../DiscoveryCompositeHealthIndicator.java | 5 +- .../discovery/DiscoveryHeartbeatEvent.java | 2 +- .../discovery/EnableDiscoveryClient.java | 7 +- .../discovery/InstanceRegisteredEvent.java | 27 +-- .../discovery/ManagementServerPortUtils.java | 90 +++++----- .../client/discovery/NoopDiscoveryClient.java | 4 +- .../NoopDiscoveryClientConfiguration.java | 20 ++- .../loadbalancer/LoadBalancerClient.java | 35 ++-- .../loadbalancer/LoadBalancerRequest.java | 2 +- ...ngleImplementationImportSelectorTests.java | 30 ++-- ...iscoveryCompositeHealthIndicatorTests.java | 19 ++- 20 files changed, 276 insertions(+), 237 deletions(-) diff --git a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java index a061c6d9..54f39296 100644 --- a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java @@ -1,5 +1,7 @@ package org.springframework.cloud.client; +import java.util.List; + import org.springframework.boot.actuate.health.HealthAggregator; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -13,8 +15,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; -import java.util.List; - /** * @author Spencer Gibb */ @@ -28,12 +28,14 @@ public class CommonsClientAutoConfiguration { @ConditionalOnExpression("${spring.cloud.discovery.enabled:true}") protected static class HealthConfiguration { @Bean - public DiscoveryClientHealthIndicator instancesHealthIndicator(DiscoveryClient discoveryClient) { + public DiscoveryClientHealthIndicator instancesHealthIndicator( + DiscoveryClient discoveryClient) { return new DiscoveryClientHealthIndicator(discoveryClient); } @Bean - public DiscoveryCompositeHealthIndicator discoveryHealthIndicator(HealthAggregator aggregator, List indicators) { + public DiscoveryCompositeHealthIndicator discoveryHealthIndicator( + HealthAggregator aggregator, List indicators) { return new DiscoveryCompositeHealthIndicator(aggregator, indicators); } } diff --git a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java index 32cf1a79..860e8f34 100644 --- a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java @@ -7,7 +7,7 @@ import lombok.Data; */ @Data public class DefaultServiceInstance implements ServiceInstance { - private final String serviceId; - private final String host; - private final int port; + private final String serviceId; + private final String host; + private final int port; } diff --git a/src/main/java/org/springframework/cloud/client/ServiceInstance.java b/src/main/java/org/springframework/cloud/client/ServiceInstance.java index 2480f2a3..4be95769 100644 --- a/src/main/java/org/springframework/cloud/client/ServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/ServiceInstance.java @@ -1,12 +1,12 @@ package org.springframework.cloud.client; - /** - * @author Spencer Gibb - * TODO: name? Server? HostAndPort? Instance? + * @author Spencer Gibb TODO: name? Server? HostAndPort? Instance? */ public interface ServiceInstance { - public String getServiceId(); - public String getHost(); - public int getPort(); + public String getServiceId(); + + public String getHost(); + + public int getPort(); } diff --git a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java index 407cfc07..6d814704 100644 --- a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java @@ -33,7 +33,7 @@ public abstract class SingleImplementationImportSelector implements @SuppressWarnings("unchecked") protected SingleImplementationImportSelector() { - annotationClass = (Class) GenericTypeResolver.resolveTypeArgument( + this.annotationClass = (Class) GenericTypeResolver.resolveTypeArgument( this.getClass(), SingleImplementationImportSelector.class); } @@ -43,14 +43,14 @@ public abstract class SingleImplementationImportSelector implements return new String[0]; } AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata - .getAnnotationAttributes(annotationClass.getName(), true)); + .getAnnotationAttributes(this.annotationClass.getName(), true)); Assert.notNull(attributes, "No " + getSimpleName() + " attributes found. Is " + metadata.getClassName() + " annotated with @" + getSimpleName() + "?"); // Find all possible auto configuration classes, filtering duplicates List factories = new ArrayList<>(new LinkedHashSet<>( - SpringFactoriesLoader.loadFactoryNames(annotationClass, + SpringFactoriesLoader.loadFactoryNames(this.annotationClass, this.beanClassLoader))); if (factories.size() > 1) { @@ -69,15 +69,15 @@ public abstract class SingleImplementationImportSelector implements protected abstract boolean isEnabled(); protected String getSimpleName() { - return annotationClass.getSimpleName(); + return this.annotationClass.getSimpleName(); } - + protected Class getAnnotationClass() { - return annotationClass; + return this.annotationClass; } protected Environment getEnvironment() { - return environment; + return this.environment; } @Override diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java index a4a66e3a..3e18c39c 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java @@ -1,8 +1,13 @@ package org.springframework.cloud.client.circuitbreaker; -import org.springframework.context.annotation.Import; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; -import java.lang.annotation.*; +import org.springframework.context.annotation.Import; /** * @author Spencer Gibb diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java index 55c9312e..fb5604b3 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java @@ -9,10 +9,12 @@ import org.springframework.core.annotation.Order; * @author Spencer Gibb */ @Order(Ordered.LOWEST_PRECEDENCE - 100) -public class EnableCircuitBreakerImportSelector extends SingleImplementationImportSelector { +public class EnableCircuitBreakerImportSelector extends + SingleImplementationImportSelector { @Override protected boolean isEnabled() { - return new RelaxedPropertyResolver(getEnvironment()).getProperty("spring.cloud.circuit.breaker.enabled", Boolean.class, Boolean.TRUE); + return new RelaxedPropertyResolver(getEnvironment()).getProperty( + "spring.cloud.circuit.breaker.enabled", Boolean.class, Boolean.TRUE); } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java index 2397ca7f..25e05ac6 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java +++ b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java @@ -1,109 +1,117 @@ package org.springframework.cloud.client.discovery; +import javax.annotation.PreDestroy; + import org.springframework.beans.BeansException; import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.env.Environment; -import javax.annotation.PreDestroy; - /** * @author Spencer Gibb */ -public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, ApplicationContextAware { +public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, + ApplicationContextAware { - protected boolean autoStartup = true; - protected boolean running; - protected int order = 0; - protected ApplicationContext context; - protected Environment environment; + protected boolean autoStartup = true; + protected boolean running; + protected int order = 0; + protected ApplicationContext context; + protected Environment environment; - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.context = applicationContext; - environment = context.getEnvironment(); - } + @Override + public void setApplicationContext(ApplicationContext applicationContext) + throws BeansException { + this.context = applicationContext; + this.environment = this.context.getEnvironment(); + } - @Override - public boolean isAutoStartup() { - return autoStartup; - } + @Override + public boolean isAutoStartup() { + return this.autoStartup; + } - @Override - public void stop(Runnable callback) { - stop(); - callback.run(); - } + @Override + public void stop(Runnable callback) { + stop(); + callback.run(); + } - @Override - public void start() { - if (!isEnabled()) return; + @Override + public void start() { + if (!isEnabled()) { + return; + } - register(); - if (ManagementServerPortUtils.isDifferent(context)) { - registerManagement(); - } - context.publishEvent(new InstanceRegisteredEvent<>(this, getConfiguration())); - running = true; - } + register(); + if (ManagementServerPortUtils.isDifferent(this.context)) { + registerManagement(); + } + this.context + .publishEvent(new InstanceRegisteredEvent<>(this, getConfiguration())); + this.running = true; + } - protected abstract Object getConfiguration(); + protected abstract Object getConfiguration(); - protected abstract void register(); + protected abstract void register(); - protected void registerManagement() {} + protected void registerManagement() { + } - protected abstract void deregister(); + protected abstract void deregister(); - protected void deregisterManagement() {} + protected void deregisterManagement() { + } - protected abstract boolean isEnabled(); + protected abstract boolean isEnabled(); - protected String getManagementServiceId() { - return context.getId() + ":management"; //TODO: configurable management suffix - } + protected String getManagementServiceId() { + return this.context.getId() + ":management"; // TODO: configurable management + // suffix + } - protected String getManagementServiceName() { - return getAppName() + ":management"; //TODO: configurable management suffix - } + protected String getManagementServiceName() { + return getAppName() + ":management"; // TODO: configurable management suffix + } - protected Integer getManagementPort() { - return context.getBean(ManagementServerProperties.class).getPort(); - } + protected Integer getManagementPort() { + return this.context.getBean(ManagementServerProperties.class).getPort(); + } - protected String getAppName() { - return environment.getProperty("spring.application.name"); - } + protected String getAppName() { + return this.environment.getProperty("spring.application.name"); + } - @Override - public void stop() { - if (isEnabled()) { - deregister(); - if (getManagementPort() != null) { - deregisterManagement(); - } - } - running = false; - } + @Override + public void stop() { + if (isEnabled()) { + deregister(); + if (getManagementPort() != null) { + deregisterManagement(); + } + } + this.running = false; + } - @PreDestroy - public void destroy() { - stop(); - } + @PreDestroy + public void destroy() { + stop(); + } - @Override - public boolean isRunning() { - return running; - } + @Override + public boolean isRunning() { + return this.running; + } - @Override - public int getOrder() { - return order; - } + @Override + public int getOrder() { + return this.order; + } - @Override - public int getPhase() { - return 0; - } + @Override + public int getPhase() { + return 0; + } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java index 2d4d0803..16a49694 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java @@ -1,32 +1,32 @@ package org.springframework.cloud.client.discovery; -import org.springframework.cloud.client.ServiceInstance; - import java.util.List; +import org.springframework.cloud.client.ServiceInstance; + /** * @author Spencer Gibb */ -//TODO: merge with LoadBalancerClient? +// TODO: merge with LoadBalancerClient? public interface DiscoveryClient { public String description(); - /** - * @return ServiceInstance with information used to register the local service - */ - public ServiceInstance getLocalServiceInstance(); + /** + * @return ServiceInstance with information used to register the local service + */ + public ServiceInstance getLocalServiceInstance(); - /** - * Get all ServiceInstance's associated with a particular serviceId - * @param serviceId the serviceId to query - * @return a List of ServiceInstance - */ - public List getInstances(String serviceId); + /** + * Get all ServiceInstance's associated with a particular serviceId + * @param serviceId the serviceId to query + * @return a List of ServiceInstance + */ + public List getInstances(String serviceId); - public List getAllInstances(); + public List getAllInstances(); - /** - * @return all known service id's - */ - public List getServices(); + /** + * @return all known service id's + */ + public List getServices(); } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java index 80c72954..578ff262 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java @@ -24,16 +24,17 @@ public class DiscoveryClientHealthIndicator implements DiscoveryHealthIndicator, @Override public Health health() { Health.Builder builder = new Health.Builder(); - try { - List services = discoveryClient.getServices(); - builder.status(new Status("UP", discoveryClient.description())) + try { + List services = this.discoveryClient.getServices(); + builder.status(new Status("UP", this.discoveryClient.description())) .withDetail("services", services); - } catch (Exception e) { - log.error("Error", e); - builder.down(e); - } + } + catch (Exception e) { + log.error("Error", e); + builder.down(e); + } return builder.build(); - } + } @Override public String getName() { @@ -42,7 +43,7 @@ public class DiscoveryClientHealthIndicator implements DiscoveryHealthIndicator, @Override public int getOrder() { - return order; + return this.order; } public void setOrder(int order) { diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java index 91d86f4e..9c18e1e1 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java @@ -14,7 +14,8 @@ import org.springframework.boot.actuate.health.HealthIndicator; public class DiscoveryCompositeHealthIndicator extends CompositeHealthIndicator { @Autowired - public DiscoveryCompositeHealthIndicator(HealthAggregator healthAggregator, List indicators) { + public DiscoveryCompositeHealthIndicator(HealthAggregator healthAggregator, + List indicators) { super(healthAggregator); for (DiscoveryHealthIndicator indicator : indicators) { addHealthIndicator(indicator.getName(), new Holder(indicator)); @@ -30,7 +31,7 @@ public class DiscoveryCompositeHealthIndicator extends CompositeHealthIndicator @Override public Health health() { - return delegate.health(); + return this.delegate.health(); } } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java index 32f93cc6..8a8cd03a 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java @@ -16,6 +16,6 @@ public class DiscoveryHeartbeatEvent extends ApplicationEvent { } public Object getValue() { - return value; + return this.value; } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java index 4b6ab16a..fb4f2763 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java @@ -4,7 +4,12 @@ package org.springframework.cloud.client.discovery; * @author Spencer Gibb */ -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.context.annotation.Import; diff --git a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java index c459b68e..774b0b59 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java @@ -3,23 +3,24 @@ package org.springframework.cloud.client.discovery; import org.springframework.context.ApplicationEvent; /** - * Event to be published after the local service instance registers itself with a discovery service + * Event to be published after the local service instance registers itself with a + * discovery service * @author Spencer Gibb */ @SuppressWarnings("serial") public class InstanceRegisteredEvent extends ApplicationEvent { - private T config; + private T config; - /** - * @param source the component that published the event (never {@code null}) - * @param config the configuration of the instance - */ - public InstanceRegisteredEvent(Object source, T config) { - super(source); - this.config = config; - } + /** + * @param source the component that published the event (never {@code null}) + * @param config the configuration of the instance + */ + public InstanceRegisteredEvent(Object source, T config) { + super(source); + this.config = config; + } - public T getConfig() { - return config; - } + public T getConfig() { + return this.config; + } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java index 5861dde7..9d5c9148 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java +++ b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java @@ -11,58 +11,58 @@ import org.springframework.web.context.WebApplicationContext; */ public class ManagementServerPortUtils { - //TODO: copied from EndpointWebMvcAutoConfiguration.ManagementServerPort - public static enum ManagementServerPort { + // TODO: copied from EndpointWebMvcAutoConfiguration.ManagementServerPort + public static enum ManagementServerPort { - DISABLE, SAME, DIFFERENT; + DISABLE, SAME, DIFFERENT; - public static ManagementServerPort get(BeanFactory beanFactory) { + public static ManagementServerPort get(BeanFactory beanFactory) { - ServerProperties serverProperties; - try { - serverProperties = beanFactory.getBean(ServerProperties.class); - } - catch (NoSuchBeanDefinitionException ex) { - serverProperties = new ServerProperties(); - } + ServerProperties serverProperties; + try { + serverProperties = beanFactory.getBean(ServerProperties.class); + } + catch (NoSuchBeanDefinitionException ex) { + serverProperties = new ServerProperties(); + } - ManagementServerProperties managementServerProperties; - try { - managementServerProperties = beanFactory - .getBean(ManagementServerProperties.class); - } - catch (NoSuchBeanDefinitionException ex) { - managementServerProperties = new ManagementServerProperties(); - } + ManagementServerProperties managementServerProperties; + try { + managementServerProperties = beanFactory + .getBean(ManagementServerProperties.class); + } + catch (NoSuchBeanDefinitionException ex) { + managementServerProperties = new ManagementServerProperties(); + } - Integer port = managementServerProperties.getPort(); - if (port != null && port < 0) { - return DISABLE; - } - if (!(beanFactory instanceof WebApplicationContext)) { - // Current context is not a webapp - return DIFFERENT; - } - return ((port == null) - || (serverProperties.getPort() == null && port.equals(8080)) - || (port != 0 && port.equals(serverProperties.getPort())) ? SAME - : DIFFERENT); - } - }; + Integer port = managementServerProperties.getPort(); + if (port != null && port < 0) { + return DISABLE; + } + if (!(beanFactory instanceof WebApplicationContext)) { + // Current context is not a webapp + return DIFFERENT; + } + return ((port == null) + || (serverProperties.getPort() == null && port.equals(8080)) + || (port != 0 && port.equals(serverProperties.getPort())) ? SAME + : DIFFERENT); + } + }; - public static ManagementServerPort get(BeanFactory beanFactory) { - return ManagementServerPort.get(beanFactory); - } + public static ManagementServerPort get(BeanFactory beanFactory) { + return ManagementServerPort.get(beanFactory); + } - public static boolean isDifferent(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.DIFFERENT; - } + public static boolean isDifferent(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.DIFFERENT; + } - public static boolean isDisabled(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.DISABLE; - } + public static boolean isDisabled(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.DISABLE; + } - public static boolean isSame(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.SAME; - } + public static boolean isSame(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.SAME; + } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java index 6bcf8a2a..0d14f52d 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java @@ -27,7 +27,7 @@ import org.springframework.cloud.client.ServiceInstance; public class NoopDiscoveryClient implements DiscoveryClient { private final ServiceInstance instance; - + public NoopDiscoveryClient(ServiceInstance instance) { this.instance = instance; } @@ -39,7 +39,7 @@ public class NoopDiscoveryClient implements DiscoveryClient { @Override public ServiceInstance getLocalServiceInstance() { - return instance; + return this.instance; } @Override diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java index 88786c6b..7b15b80c 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java @@ -45,7 +45,8 @@ import org.springframework.core.env.Environment; @EnableConfigurationProperties @ConditionalOnMissingClass(name = "com.netflix.discovery.EurekaClientConfig") @ConditionalOnExpression("!${eureka.client.enabled:false}") -public class NoopDiscoveryClientConfiguration implements ApplicationListener { +public class NoopDiscoveryClientConfiguration implements + ApplicationListener { private static final Logger logger = LoggerFactory .getLogger(NoopDiscoveryClientConfiguration.class); @@ -71,29 +72,30 @@ public class NoopDiscoveryClientConfiguration implements ApplicationListener(this, environment)); + this.context.publishEvent(new InstanceRegisteredEvent(this, + this.environment)); } @Bean public DiscoveryClient discoveryClient() { - return new NoopDiscoveryClient(serviceInstance); + return new NoopDiscoveryClient(this.serviceInstance); } } diff --git a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java index 19ed6fc0..b43aa034 100644 --- a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java +++ b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java @@ -1,28 +1,31 @@ package org.springframework.cloud.client.loadbalancer; -import org.springframework.cloud.client.ServiceInstance; - import java.net.URI; +import org.springframework.cloud.client.ServiceInstance; + /** * @author Spencer Gibb */ public interface LoadBalancerClient { - /** - * Choose a ServiceInstance from the LoadBalancer for the specified service - * @param serviceId the service id to look up the LoadBalancer - * @return a ServiceInstance that matches the serviceId - */ - public ServiceInstance choose(String serviceId); + /** + * Choose a ServiceInstance from the LoadBalancer for the specified service + * @param serviceId the service id to look up the LoadBalancer + * @return a ServiceInstance that matches the serviceId + */ + public ServiceInstance choose(String serviceId); - /** - * execute request using a ServiceInstance from the LoadBalancer for the specified service - * @param serviceId the service id to look up the LoadBalancer - * @param request allows implementations to execute pre and post actions such as incrementing metrics - * @return the result of the LoadBalancerRequest callback on the selected ServiceInstance - */ - public T execute(String serviceId, LoadBalancerRequest request); + /** + * execute request using a ServiceInstance from the LoadBalancer for the specified + * service + * @param serviceId the service id to look up the LoadBalancer + * @param request allows implementations to execute pre and post actions such as + * incrementing metrics + * @return the result of the LoadBalancerRequest callback on the selected + * ServiceInstance + */ + public T execute(String serviceId, LoadBalancerRequest request); - public URI reconstructURI(ServiceInstance instance, URI original); + public URI reconstructURI(ServiceInstance instance, URI original); } diff --git a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java index 7c6cbc60..bb82f31d 100644 --- a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java +++ b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java @@ -6,5 +6,5 @@ import org.springframework.cloud.client.ServiceInstance; * @author Spencer Gibb */ public interface LoadBalancerRequest { - public T apply(ServiceInstance instance) throws Exception; + public T apply(ServiceInstance instance) throws Exception; } diff --git a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java index cd88ffbd..6d6b5214 100644 --- a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java +++ b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java @@ -2,25 +2,29 @@ package org.springframework.cloud.client; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * @author Spencer Gibb */ public class SingleImplementationImportSelectorTests { - @Test - public void testFindAnnotation() { - MyAnnotationImportSelector selector = new MyAnnotationImportSelector(); - assertEquals("annotationClass was wrong", MyAnnotation.class, selector.getAnnotationClass()); - } + @Test + public void testFindAnnotation() { + MyAnnotationImportSelector selector = new MyAnnotationImportSelector(); + assertEquals("annotationClass was wrong", MyAnnotation.class, + selector.getAnnotationClass()); + } - public static @interface MyAnnotation {} - public static class MyAnnotationImportSelector extends SingleImplementationImportSelector { - @Override - protected boolean isEnabled() { - return true; - } + public static @interface MyAnnotation { + } - } + public static class MyAnnotationImportSelector extends + SingleImplementationImportSelector { + @Override + protected boolean isEnabled() { + return true; + } + + } } diff --git a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java index 58a04ee7..98ecf7ff 100644 --- a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java +++ b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java @@ -1,6 +1,5 @@ package org.springframework.cloud.client.discovery; -import com.google.common.collect.Lists; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -14,14 +13,19 @@ import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.mockito.Mockito.*; -import static org.junit.Assert.*; +import com.google.common.collect.Lists; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author Spencer Gibb */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {DiscoveryCompositeHealthIndicatorTests.Config.class, CommonsClientAutoConfiguration.class}) +@ContextConfiguration(classes = { DiscoveryCompositeHealthIndicatorTests.Config.class, + CommonsClientAutoConfiguration.class }) public class DiscoveryCompositeHealthIndicatorTests { @Autowired @@ -60,12 +64,13 @@ public class DiscoveryCompositeHealthIndicatorTests { @Test public void testHealthIndicator() { - assertNotNull("healthIndicator was null", healthIndicator); - Health health = healthIndicator.health(); + assertNotNull("healthIndicator was null", this.healthIndicator); + Health health = this.healthIndicator.health(); assertNotNull("health was null", health); Status status = health.getStatus(); assertNotNull("status was null", status); assertEquals("status code was wrong", "UP", status.getCode()); - assertEquals("status desciption was wrong", "TestDiscoveryClient", status.getDescription()); + assertEquals("status desciption was wrong", "TestDiscoveryClient", + status.getDescription()); } } From 903d6738ab88e2cabdbeb99f85c78710784dd623 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 11:47:56 -0800 Subject: [PATCH 5/8] Add copyright headers --- .../client/CommonsClientAutoConfiguration.java | 16 ++++++++++++++++ .../cloud/client/DefaultServiceInstance.java | 16 ++++++++++++++++ .../cloud/client/ServiceInstance.java | 16 ++++++++++++++++ .../SingleImplementationImportSelector.java | 16 ++++++++++++++++ .../circuitbreaker/EnableCircuitBreaker.java | 16 ++++++++++++++++ .../EnableCircuitBreakerImportSelector.java | 16 ++++++++++++++++ .../discovery/AbstractDiscoveryLifecycle.java | 16 ++++++++++++++++ .../cloud/client/discovery/DiscoveryClient.java | 16 ++++++++++++++++ .../DiscoveryClientHealthIndicator.java | 16 ++++++++++++++++ .../DiscoveryCompositeHealthIndicator.java | 16 ++++++++++++++++ .../discovery/DiscoveryHealthIndicator.java | 16 ++++++++++++++++ .../discovery/DiscoveryHeartbeatEvent.java | 16 ++++++++++++++++ .../client/discovery/DiscoveryLifecycle.java | 16 ++++++++++++++++ .../client/discovery/EnableDiscoveryClient.java | 16 ++++++++++++++++ .../EnableDiscoveryClientImportSelector.java | 16 ++++++++++++++++ .../discovery/InstanceRegisteredEvent.java | 16 ++++++++++++++++ .../discovery/ManagementServerPortUtils.java | 16 ++++++++++++++++ .../client/discovery/NoopDiscoveryClient.java | 1 + .../NoopDiscoveryClientConfiguration.java | 1 + .../client/loadbalancer/LoadBalancerClient.java | 16 ++++++++++++++++ .../client/loadbalancer/LoadBalancerRequest.java | 16 ++++++++++++++++ .../SingleImplementationImportSelectorTests.java | 16 ++++++++++++++++ .../DiscoveryCompositeHealthIndicatorTests.java | 16 ++++++++++++++++ 23 files changed, 338 insertions(+) diff --git a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java index 54f39296..901082d2 100644 --- a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client; import java.util.List; diff --git a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java index 860e8f34..537246f1 100644 --- a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client; import lombok.Data; diff --git a/src/main/java/org/springframework/cloud/client/ServiceInstance.java b/src/main/java/org/springframework/cloud/client/ServiceInstance.java index 4be95769..778c78ad 100644 --- a/src/main/java/org/springframework/cloud/client/ServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/ServiceInstance.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client; /** diff --git a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java index 6d814704..98f6c0ee 100644 --- a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client; import java.util.ArrayList; diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java index 3e18c39c..355e5f2a 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.circuitbreaker; import java.lang.annotation.Documented; diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java index fb5604b3..be49854c 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.circuitbreaker; import org.springframework.boot.bind.RelaxedPropertyResolver; diff --git a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java index 25e05ac6..8df45ec3 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java +++ b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import javax.annotation.PreDestroy; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java index 16a49694..5e7c96cd 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import java.util.List; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java index 578ff262..7d2bb2f3 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import java.util.List; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java index 9c18e1e1..f4f09984 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import java.util.List; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java index 3db0bf40..0bc96ef2 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.boot.actuate.health.Health; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java index 8a8cd03a..3865f5d3 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.context.ApplicationEvent; diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryLifecycle.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryLifecycle.java index c6a43026..d7a8f4e3 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryLifecycle.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryLifecycle.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.context.SmartLifecycle; diff --git a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java index fb4f2763..b61631ad 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; /** diff --git a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java index 99f9fcca..48873973 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.boot.bind.RelaxedPropertyResolver; diff --git a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java index 774b0b59..61466820 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.context.ApplicationEvent; diff --git a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java index 9d5c9148..5834ac0c 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java +++ b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.springframework.beans.factory.BeanFactory; diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java index 0d14f52d..c6dabf1f 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.client.discovery; import java.util.Collections; diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java index 7b15b80c..8837e2e1 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.cloud.client.discovery; import java.net.InetAddress; diff --git a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java index b43aa034..cf46fe6b 100644 --- a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java +++ b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerClient.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.loadbalancer; import java.net.URI; diff --git a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java index bb82f31d..02ebc496 100644 --- a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java +++ b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.loadbalancer; import org.springframework.cloud.client.ServiceInstance; diff --git a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java index 6d6b5214..48e0cea3 100644 --- a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java +++ b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client; import org.junit.Test; diff --git a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java index 98ecf7ff..f852b647 100644 --- a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java +++ b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cloud.client.discovery; import org.junit.Test; From 5168937f933a3913f6cdf85c8481cdfcef2b8ee7 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 12:11:18 -0800 Subject: [PATCH 6/8] Polish --- .../CommonsClientAutoConfiguration.java | 5 +++ .../cloud/client/DefaultServiceInstance.java | 6 ++++ .../cloud/client/ServiceInstance.java | 5 ++- .../SingleImplementationImportSelector.java | 10 +++--- .../circuitbreaker/EnableCircuitBreaker.java | 1 + .../EnableCircuitBreakerImportSelector.java | 1 + .../discovery/AbstractDiscoveryLifecycle.java | 12 +++++-- .../client/discovery/DiscoveryClient.java | 5 ++- .../DiscoveryClientHealthIndicator.java | 2 ++ .../DiscoveryCompositeHealthIndicator.java | 1 + .../discovery/DiscoveryHealthIndicator.java | 4 ++- .../discovery/DiscoveryHeartbeatEvent.java | 1 + .../discovery/EnableDiscoveryClient.java | 8 ++--- .../EnableDiscoveryClientImportSelector.java | 1 + .../discovery/InstanceRegisteredEvent.java | 6 +++- .../discovery/ManagementServerPortUtils.java | 32 +++++++++---------- .../client/discovery/NoopDiscoveryClient.java | 1 - .../NoopDiscoveryClientConfiguration.java | 1 - .../loadbalancer/LoadBalancerRequest.java | 2 ++ ...ngleImplementationImportSelectorTests.java | 1 + ...iscoveryCompositeHealthIndicatorTests.java | 1 + 21 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java index 901082d2..a2da7c3c 100644 --- a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java @@ -20,6 +20,7 @@ import java.util.List; import org.springframework.boot.actuate.health.HealthAggregator; import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; @@ -32,6 +33,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; /** + * {@link EnableAutoConfiguration Auto-configuration} for Spring Cloud Commons Client. + * * @author Spencer Gibb */ @Configuration @@ -43,6 +46,7 @@ public class CommonsClientAutoConfiguration { @ConditionalOnBean(DiscoveryClient.class) @ConditionalOnExpression("${spring.cloud.discovery.enabled:true}") protected static class HealthConfiguration { + @Bean public DiscoveryClientHealthIndicator instancesHealthIndicator( DiscoveryClient discoveryClient) { @@ -54,5 +58,6 @@ public class CommonsClientAutoConfiguration { HealthAggregator aggregator, List indicators) { return new DiscoveryCompositeHealthIndicator(aggregator, indicators); } + } } diff --git a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java index 537246f1..160324d9 100644 --- a/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java @@ -19,11 +19,17 @@ package org.springframework.cloud.client; import lombok.Data; /** + * Default implementation of {@link ServiceInstance}. + * * @author Spencer Gibb */ @Data public class DefaultServiceInstance implements ServiceInstance { + private final String serviceId; + private final String host; + private final int port; + } diff --git a/src/main/java/org/springframework/cloud/client/ServiceInstance.java b/src/main/java/org/springframework/cloud/client/ServiceInstance.java index 778c78ad..80877212 100644 --- a/src/main/java/org/springframework/cloud/client/ServiceInstance.java +++ b/src/main/java/org/springframework/cloud/client/ServiceInstance.java @@ -17,9 +17,12 @@ package org.springframework.cloud.client; /** - * @author Spencer Gibb TODO: name? Server? HostAndPort? Instance? + * @author Spencer Gibb */ public interface ServiceInstance { + + // TODO: name? Server? HostAndPort? Instance? + public String getServiceId(); public String getHost(); diff --git a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java index 98f6c0ee..6ec50eba 100644 --- a/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/SingleImplementationImportSelector.java @@ -35,6 +35,7 @@ import org.springframework.util.Assert; /** * Selects a single configuration to load defined by the generic type T. + * * @author Spencer Gibb * @author Dave Syer */ @@ -45,6 +46,7 @@ public abstract class SingleImplementationImportSelector implements private ClassLoader beanClassLoader; private Class annotationClass; + private Environment environment; @SuppressWarnings("unchecked") @@ -72,14 +74,13 @@ public abstract class SingleImplementationImportSelector implements if (factories.size() > 1) { String factory = factories.get(0); // there should only every be one DiscoveryClient - log.warn( - "More than one implementation of @{}. Using {} out of available {}", - getSimpleName(), factory, factories); + log.warn("More than one implementation " + + "of @{}. Using {} out of available {}", getSimpleName(), factory, + factories); factories = Collections.singletonList(factory); } return factories.toArray(new String[factories.size()]); - } protected abstract boolean isEnabled(); @@ -105,4 +106,5 @@ public abstract class SingleImplementationImportSelector implements public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } + } diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java index 355e5f2a..d180b91f 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreaker.java @@ -34,4 +34,5 @@ import org.springframework.context.annotation.Import; @Inherited @Import(EnableCircuitBreakerImportSelector.class) public @interface EnableCircuitBreaker { + } diff --git a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java index be49854c..06b76a5b 100644 --- a/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/circuitbreaker/EnableCircuitBreakerImportSelector.java @@ -33,4 +33,5 @@ public class EnableCircuitBreakerImportSelector extends return new RelaxedPropertyResolver(getEnvironment()).getProperty( "spring.cloud.circuit.breaker.enabled", Boolean.class, Boolean.TRUE); } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java index 8df45ec3..db0f4d30 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java +++ b/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java @@ -31,9 +31,13 @@ public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, ApplicationContextAware { protected boolean autoStartup = true; + protected boolean running; + protected int order = 0; + protected ApplicationContext context; + protected Environment environment; @Override @@ -84,12 +88,13 @@ public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, protected abstract boolean isEnabled(); protected String getManagementServiceId() { - return this.context.getId() + ":management"; // TODO: configurable management - // suffix + return this.context.getId() + ":management"; + // TODO: configurable management suffix } protected String getManagementServiceName() { - return getAppName() + ":management"; // TODO: configurable management suffix + return getAppName() + ":management"; + // TODO: configurable management suffix } protected Integer getManagementPort() { @@ -130,4 +135,5 @@ public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, public int getPhase() { return 0; } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java index 5e7c96cd..a5ea9756 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java @@ -23,8 +23,10 @@ import org.springframework.cloud.client.ServiceInstance; /** * @author Spencer Gibb */ -// TODO: merge with LoadBalancerClient? public interface DiscoveryClient { + + // TODO: merge with LoadBalancerClient? + public String description(); /** @@ -45,4 +47,5 @@ public interface DiscoveryClient { * @return all known service id's */ public List getServices(); + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java index 7d2bb2f3..1ab6d367 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClientHealthIndicator.java @@ -31,6 +31,7 @@ import org.springframework.core.Ordered; public class DiscoveryClientHealthIndicator implements DiscoveryHealthIndicator, Ordered { private int order = Ordered.HIGHEST_PRECEDENCE; + private DiscoveryClient discoveryClient; public DiscoveryClientHealthIndicator(DiscoveryClient discoveryClient) { @@ -65,4 +66,5 @@ public class DiscoveryClientHealthIndicator implements DiscoveryHealthIndicator, public void setOrder(int order) { this.order = order; } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java index f4f09984..8ca2c899 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicator.java @@ -50,4 +50,5 @@ public class DiscoveryCompositeHealthIndicator extends CompositeHealthIndicator return this.delegate.health(); } } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java index 0bc96ef2..9a93dcbc 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHealthIndicator.java @@ -22,10 +22,12 @@ import org.springframework.boot.actuate.health.Health; * @author Spencer Gibb */ public interface DiscoveryHealthIndicator { - public String getName(); + + String getName(); /** * @return an indication of health */ Health health(); + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java index 3865f5d3..caa58a47 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/DiscoveryHeartbeatEvent.java @@ -34,4 +34,5 @@ public class DiscoveryHeartbeatEvent extends ApplicationEvent { public Object getValue() { return this.value; } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java index b61631ad..2c503a2a 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClient.java @@ -16,10 +16,6 @@ package org.springframework.cloud.client.discovery; -/** - * @author Spencer Gibb - */ - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; @@ -29,10 +25,14 @@ import java.lang.annotation.Target; import org.springframework.context.annotation.Import; +/** + * @author Spencer Gibb + */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @Import(EnableDiscoveryClientImportSelector.class) public @interface EnableDiscoveryClient { + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java index 48873973..e23e96ef 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java +++ b/src/main/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientImportSelector.java @@ -33,4 +33,5 @@ public class EnableDiscoveryClientImportSelector extends return new RelaxedPropertyResolver(getEnvironment()).getProperty( "spring.cloud.discovery.enabled", Boolean.class, Boolean.TRUE); } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java index 61466820..6bf3ed3e 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java +++ b/src/main/java/org/springframework/cloud/client/discovery/InstanceRegisteredEvent.java @@ -20,14 +20,17 @@ import org.springframework.context.ApplicationEvent; /** * Event to be published after the local service instance registers itself with a - * discovery service + * discovery service. + * * @author Spencer Gibb */ @SuppressWarnings("serial") public class InstanceRegisteredEvent extends ApplicationEvent { + private T config; /** + * Create a new {@link InstanceRegisteredEvent} instance. * @param source the component that published the event (never {@code null}) * @param config the configuration of the instance */ @@ -39,4 +42,5 @@ public class InstanceRegisteredEvent extends ApplicationEvent { public T getConfig() { return this.config; } + } diff --git a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java index 5834ac0c..e0a3564e 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java +++ b/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java @@ -27,13 +27,28 @@ import org.springframework.web.context.WebApplicationContext; */ public class ManagementServerPortUtils { + public static ManagementServerPort get(BeanFactory beanFactory) { + return ManagementServerPort.get(beanFactory); + } + + public static boolean isDifferent(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.DIFFERENT; + } + + public static boolean isDisabled(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.DISABLE; + } + + public static boolean isSame(BeanFactory beanFactory) { + return get(beanFactory) == ManagementServerPort.SAME; + } + // TODO: copied from EndpointWebMvcAutoConfiguration.ManagementServerPort public static enum ManagementServerPort { DISABLE, SAME, DIFFERENT; public static ManagementServerPort get(BeanFactory beanFactory) { - ServerProperties serverProperties; try { serverProperties = beanFactory.getBean(ServerProperties.class); @@ -66,19 +81,4 @@ public class ManagementServerPortUtils { } }; - public static ManagementServerPort get(BeanFactory beanFactory) { - return ManagementServerPort.get(beanFactory); - } - - public static boolean isDifferent(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.DIFFERENT; - } - - public static boolean isDisabled(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.DISABLE; - } - - public static boolean isSame(BeanFactory beanFactory) { - return get(beanFactory) == ManagementServerPort.SAME; - } } diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java index c6dabf1f..8e59d434 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClient.java @@ -23,7 +23,6 @@ import org.springframework.cloud.client.ServiceInstance; /** * @author Dave Syer - * */ public class NoopDiscoveryClient implements DiscoveryClient { diff --git a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java index 8837e2e1..b381cb77 100644 --- a/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java @@ -40,7 +40,6 @@ import org.springframework.core.env.Environment; /** * @author Dave Syer - * */ @Configuration @EnableConfigurationProperties diff --git a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java index 02ebc496..4d0b4c31 100644 --- a/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java +++ b/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerRequest.java @@ -22,5 +22,7 @@ import org.springframework.cloud.client.ServiceInstance; * @author Spencer Gibb */ public interface LoadBalancerRequest { + public T apply(ServiceInstance instance) throws Exception; + } diff --git a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java index 48e0cea3..0a616491 100644 --- a/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java +++ b/src/test/java/org/springframework/cloud/client/SingleImplementationImportSelectorTests.java @@ -37,6 +37,7 @@ public class SingleImplementationImportSelectorTests { public static class MyAnnotationImportSelector extends SingleImplementationImportSelector { + @Override protected boolean isEnabled() { return true; diff --git a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java index f852b647..d84d2cfc 100644 --- a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java +++ b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java @@ -89,4 +89,5 @@ public class DiscoveryCompositeHealthIndicatorTests { assertEquals("status desciption was wrong", "TestDiscoveryClient", status.getDescription()); } + } From b9759f42f576915460750c27f66ad82c41e79bd8 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 12:13:10 -0800 Subject: [PATCH 7/8] Replace @ConditionalOnExpression with OnProperty Replace @ConditionalOnExpression with @ConditionalOnProperty which is usually faster. --- .../cloud/client/CommonsClientAutoConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java index a2da7c3c..0af0afa1 100644 --- a/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java +++ b/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java @@ -23,7 +23,7 @@ import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.DiscoveryClientHealthIndicator; import org.springframework.cloud.client.discovery.DiscoveryCompositeHealthIndicator; @@ -44,7 +44,7 @@ public class CommonsClientAutoConfiguration { @Configuration @ConditionalOnBean(DiscoveryClient.class) - @ConditionalOnExpression("${spring.cloud.discovery.enabled:true}") + @ConditionalOnProperty(prefix = "spring.cloud.discovery", name = "enabled", matchIfMissing = true) protected static class HealthConfiguration { @Bean From 17f55470f36030cbeb830fa68b21bbaf66278357 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 14 Jan 2015 12:15:08 -0800 Subject: [PATCH 8/8] Use BDD Mockito methods --- .../discovery/DiscoveryCompositeHealthIndicatorTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java index d84d2cfc..7d0cd5b6 100644 --- a/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java +++ b/src/test/java/org/springframework/cloud/client/discovery/DiscoveryCompositeHealthIndicatorTests.java @@ -33,8 +33,8 @@ import com.google.common.collect.Lists; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * @author Spencer Gibb @@ -57,8 +57,8 @@ public class DiscoveryCompositeHealthIndicatorTests { @Bean public DiscoveryClient discoveryClient() { DiscoveryClient mock = mock(DiscoveryClient.class); - when(mock.description()).thenReturn("TestDiscoveryClient"); - when(mock.getServices()).thenReturn(Lists.newArrayList("TestService1")); + given(mock.description()).willReturn("TestDiscoveryClient"); + given(mock.getServices()).willReturn(Lists.newArrayList("TestService1")); return mock; }