diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.util')
274 files changed, 0 insertions, 24153 deletions
diff --git a/plugins/org.eclipse.net4j.util/.classpath b/plugins/org.eclipse.net4j.util/.classpath deleted file mode 100644 index 64c5e31b7a..0000000000 --- a/plugins/org.eclipse.net4j.util/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/plugins/org.eclipse.net4j.util/.cvsignore b/plugins/org.eclipse.net4j.util/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- a/plugins/org.eclipse.net4j.util/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/plugins/org.eclipse.net4j.util/.options b/plugins/org.eclipse.net4j.util/.options deleted file mode 100644 index e9f60751c1..0000000000 --- a/plugins/org.eclipse.net4j.util/.options +++ /dev/null @@ -1,8 +0,0 @@ -# Debugging and tracing options - -org.eclipse.net4j.util/debug = true -org.eclipse.net4j.util/debug.lifecycle = true -org.eclipse.net4j.util/debug.lifecycle.dump = true -org.eclipse.net4j.util/debug.concurrency = true -org.eclipse.net4j.util/debug.registry = true -org.eclipse.net4j.util/debug.om = true diff --git a/plugins/org.eclipse.net4j.util/.project b/plugins/org.eclipse.net4j.util/.project deleted file mode 100644 index b52e9e4cf3..0000000000 --- a/plugins/org.eclipse.net4j.util/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.net4j.util</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8cd72edec0..0000000000 --- a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,272 +0,0 @@ -#Sat Feb 23 10:44:51 CET 2008 -eclipse.preferences.version=1 -instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true -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.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=1 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_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=next_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=next_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true -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=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=2 -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_member=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_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=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=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_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_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=120 -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=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index ee9f8ba771..0000000000 --- a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,65 +0,0 @@ -#Sat Feb 23 10:44:51 CET 2008 -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_serial_version_id=true -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=true -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -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=false -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=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=true -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_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=true -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=_EMFT -cleanup_settings_version=2 -eclipse.preferences.version=1 -formatter_profile=_EMFT -formatter_settings_version=11 -org.eclipse.jdt.ui.exception.name=ex -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java; -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/***************************************************************************\r\n * Copyright (c) 2004 - 2008 Eike Stepper, Germany.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n **************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.tasks.ui.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.tasks.ui.prefs deleted file mode 100644 index 7f1832044c..0000000000 --- a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.tasks.ui.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Sun Mar 09 19:15:26 CET 2008 -eclipse.preferences.version=1 -project.repository.kind=bugzilla -project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.team.ui.prefs b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.team.ui.prefs deleted file mode 100644 index e72b02b02f..0000000000 --- a/plugins/org.eclipse.net4j.util/.settings/org.eclipse.mylyn.team.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun Mar 09 19:15:26 CET 2008 -commit.comment.template=[${task.id}] ${task.description} \r\n${task.url} -eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF deleted file mode 100644 index 1dbb4473e8..0000000000 --- a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF +++ /dev/null @@ -1,53 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: org.eclipse.net4j.util;singleton:=true -Bundle-Version: 0.8.0.qualifier -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-Activator: org.eclipse.net4j.internal.util.bundle.OM$Activator -Bundle-ClassPath: . -Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional -Import-Package: org.eclipse.osgi.service.debug;version="1.0.0";resolution:=optional, - org.osgi.framework;version="1.3.0";resolution:=optional, - org.osgi.service.log;version="1.3.0";resolution:=optional, - org.osgi.util.tracker;version="1.3.0";resolution:=optional -Export-Package: org.eclipse.net4j.internal.util.bundle;version="0.8.0";x-internal:=true, - org.eclipse.net4j.internal.util.cache;version="0.8.0", - org.eclipse.net4j.internal.util.collection;version="0.8.0", - org.eclipse.net4j.internal.util.concurrent;version="0.8.0", - org.eclipse.net4j.internal.util.container;version="0.8.0", - org.eclipse.net4j.internal.util.container.delegate;version="0.8.0", - org.eclipse.net4j.internal.util.event;version="0.8.0", - org.eclipse.net4j.internal.util.factory;version="0.8.0", - org.eclipse.net4j.internal.util.lifecycle;version="0.8.0", - org.eclipse.net4j.internal.util.om;version="0.8.0", - org.eclipse.net4j.internal.util.om.log;version="0.8.0", - org.eclipse.net4j.internal.util.om.monitor;version="0.8.0", - org.eclipse.net4j.internal.util.om.pref;version="0.8.0", - org.eclipse.net4j.internal.util.om.trace;version="0.8.0", - org.eclipse.net4j.internal.util.registry;version="0.8.0", - org.eclipse.net4j.internal.util.security;version="0.8.0", - org.eclipse.net4j.internal.util.transaction;version="0.8.0", - org.eclipse.net4j.util;version="0.8.0", - org.eclipse.net4j.util.cache;version="0.8.0", - org.eclipse.net4j.util.collection;version="0.8.0", - org.eclipse.net4j.util.concurrent;version="0.8.0", - org.eclipse.net4j.util.container;version="0.8.0", - org.eclipse.net4j.util.container.delegate;version="0.8.0", - org.eclipse.net4j.util.event;version="0.8.0", - org.eclipse.net4j.util.factory;version="0.8.0", - org.eclipse.net4j.util.fsm;version="0.8.0", - org.eclipse.net4j.util.io;version="0.8.0", - org.eclipse.net4j.util.lifecycle;version="0.8.0", - org.eclipse.net4j.util.om;version="0.8.0", - org.eclipse.net4j.util.om.log;version="0.8.0", - org.eclipse.net4j.util.om.monitor;version="0.8.0", - org.eclipse.net4j.util.om.pref;version="0.8.0", - org.eclipse.net4j.util.om.trace;version="0.8.0", - org.eclipse.net4j.util.ref;version="0.8.0", - org.eclipse.net4j.util.registry;version="0.8.0", - org.eclipse.net4j.util.security;version="0.8.0", - org.eclipse.net4j.util.transaction;version="0.8.0" -Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.net4j.util/about.html b/plugins/org.eclipse.net4j.util/about.html deleted file mode 100644 index d35d5aed64..0000000000 --- a/plugins/org.eclipse.net4j.util/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> -<title>About</title> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>June 5, 2007</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/build.properties b/plugins/org.eclipse.net4j.util/build.properties deleted file mode 100644 index e87d00dfbb..0000000000 --- a/plugins/org.eclipse.net4j.util/build.properties +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2004 - 2008 Eike Stepper, Germany. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR - -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - .options,\ - about.html,\ - copyright.txt,\ - epl-v10.html,\ - license.html,\ - plugin.properties,\ - plugin.xml,\ - schema/ diff --git a/plugins/org.eclipse.net4j.util/copyright.txt b/plugins/org.eclipse.net4j.util/copyright.txt deleted file mode 100644 index 529118d99e..0000000000 --- a/plugins/org.eclipse.net4j.util/copyright.txt +++ /dev/null @@ -1,8 +0,0 @@ -Copyright (c) 2004 - 2008 Eike Stepper, Germany. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html - -Contributors: - Eike Stepper - initial API and implementation
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/epl-v10.html b/plugins/org.eclipse.net4j.util/epl-v10.html deleted file mode 100644 index d7b88e9416..0000000000 --- a/plugins/org.eclipse.net4j.util/epl-v10.html +++ /dev/null @@ -1,319 +0,0 @@ -<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> -<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> -<meta name="ProgId" content="Word.Document"> -<meta name="Generator" content="Microsoft Word 9"> -<meta name="Originator" content="Microsoft Word 9"> -<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> - <o:DocumentProperties> - <o:Revision>2</o:Revision> - <o:TotalTime>3</o:TotalTime> - <o:Created>2004-03-05T23:03:00Z</o:Created> - <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> - <o:Pages>4</o:Pages> - <o:Words>1626</o:Words> - <o:Characters>9270</o:Characters> - <o:Lines>77</o:Lines> - <o:Paragraphs>18</o:Paragraphs> - <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> - <o:Version>9.4402</o:Version> - </o:DocumentProperties> -</xml><![endif]--><!--[if gte mso 9]><xml> - <w:WordDocument> - <w:TrackRevisions/> - </w:WordDocument> -</xml><![endif]--> - - -<style> -<!-- - /* Font Definitions */ -@font-face - {font-family:Tahoma; - panose-1:2 11 6 4 3 5 4 4 2 4; - mso-font-charset:0; - mso-generic-font-family:swiss; - mso-font-pitch:variable; - mso-font-signature:553679495 -2147483648 8 0 66047 0;} - /* Style Definitions */ -p.MsoNormal, li.MsoNormal, div.MsoNormal - {mso-style-parent:""; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:"Times New Roman"; - mso-fareast-font-family:"Times New Roman";} -p - {margin-right:0in; - mso-margin-top-alt:auto; - mso-margin-bottom-alt:auto; - margin-left:0in; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:"Times New Roman"; - mso-fareast-font-family:"Times New Roman";} -p.BalloonText, li.BalloonText, div.BalloonText - {mso-style-name:"Balloon Text"; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:8.0pt; - font-family:Tahoma; - mso-fareast-font-family:"Times New Roman";} -@page Section1 - {size:8.5in 11.0in; - margin:1.0in 1.25in 1.0in 1.25in; - mso-header-margin:.5in; - mso-footer-margin:.5in; - mso-paper-source:0;} -div.Section1 - {page:Section1;} ---> -</style></head> - -<body style="" lang="EN-US"> - -<div class="Section1"> - -<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> -</p> - -<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.</span> </p> - -<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> - -<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and<br clear="left"> -b) in the case of each subsequent Contributor:</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) -changes to the Program, and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) -additions to the Program;</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program. </span></p> - -<p><span style="font-size: 10pt;">"Contributor" means any person or -entity that distributes the Program.</span> </p> - -<p><span style="font-size: 10pt;">"Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program. </span></p> - -<p><span style="font-size: 10pt;">"Program" means the Contributions -distributed in accordance with this Agreement.</span> </p> - -<p><span style="font-size: 10pt;">"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.</span> </p> - -<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder. </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. </span></p> - -<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> - -<p><span style="font-size: 10pt;">A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that:</span> -</p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -it complies with the terms and conditions of this Agreement; and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) -its license agreement:</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose; </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits; </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> - -<p><span style="font-size: 10pt;">When the Program is made available in source -code form:</span> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -it must be made available under this Agreement; and </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a -copy of this Agreement must be included with each copy of the Program. </span></p> - -<p><span style="font-size: 10pt;">Contributors may not remove or alter any -copyright notices contained within the Program. </span></p> - -<p><span style="font-size: 10pt;">Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution. </span></p> - -<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> - -<p><span style="font-size: 10pt;">Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.</span> </p> - -<p><span style="font-size: 10pt;">For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.</span> </p> - -<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> - -<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations. </span></p> - -<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> - -<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.</span> </p> - -<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> - -<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.</span> </p> - -<p><span style="font-size: 10pt;">If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed. </span></p> - -<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive. </span></p> - -<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.</span> </p> - -<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.</span> </p> - -<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> - -</div> - -</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/license.html b/plugins/org.eclipse.net4j.util/license.html deleted file mode 100644 index d7b88e9416..0000000000 --- a/plugins/org.eclipse.net4j.util/license.html +++ /dev/null @@ -1,319 +0,0 @@ -<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head> -<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> -<meta name="ProgId" content="Word.Document"> -<meta name="Generator" content="Microsoft Word 9"> -<meta name="Originator" content="Microsoft Word 9"> -<link rel="File-List" href="http://www.eclipse.org/org/documents/Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"><title>Eclipse Public License - Version 1.0</title><!--[if gte mso 9]><xml> - <o:DocumentProperties> - <o:Revision>2</o:Revision> - <o:TotalTime>3</o:TotalTime> - <o:Created>2004-03-05T23:03:00Z</o:Created> - <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> - <o:Pages>4</o:Pages> - <o:Words>1626</o:Words> - <o:Characters>9270</o:Characters> - <o:Lines>77</o:Lines> - <o:Paragraphs>18</o:Paragraphs> - <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> - <o:Version>9.4402</o:Version> - </o:DocumentProperties> -</xml><![endif]--><!--[if gte mso 9]><xml> - <w:WordDocument> - <w:TrackRevisions/> - </w:WordDocument> -</xml><![endif]--> - - -<style> -<!-- - /* Font Definitions */ -@font-face - {font-family:Tahoma; - panose-1:2 11 6 4 3 5 4 4 2 4; - mso-font-charset:0; - mso-generic-font-family:swiss; - mso-font-pitch:variable; - mso-font-signature:553679495 -2147483648 8 0 66047 0;} - /* Style Definitions */ -p.MsoNormal, li.MsoNormal, div.MsoNormal - {mso-style-parent:""; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:"Times New Roman"; - mso-fareast-font-family:"Times New Roman";} -p - {margin-right:0in; - mso-margin-top-alt:auto; - mso-margin-bottom-alt:auto; - margin-left:0in; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:"Times New Roman"; - mso-fareast-font-family:"Times New Roman";} -p.BalloonText, li.BalloonText, div.BalloonText - {mso-style-name:"Balloon Text"; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:8.0pt; - font-family:Tahoma; - mso-fareast-font-family:"Times New Roman";} -@page Section1 - {size:8.5in 11.0in; - margin:1.0in 1.25in 1.0in 1.25in; - mso-header-margin:.5in; - mso-footer-margin:.5in; - mso-paper-source:0;} -div.Section1 - {page:Section1;} ---> -</style></head> - -<body style="" lang="EN-US"> - -<div class="Section1"> - -<p style="text-align: center;" align="center"><b>Eclipse Public License - v 1.0</b> -</p> - -<p><span style="font-size: 10pt;">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.</span> </p> - -<p><b><span style="font-size: 10pt;">1. DEFINITIONS</span></b> </p> - -<p><span style="font-size: 10pt;">"Contribution" means:</span> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and<br clear="left"> -b) in the case of each subsequent Contributor:</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) -changes to the Program, and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) -additions to the Program;</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program. </span></p> - -<p><span style="font-size: 10pt;">"Contributor" means any person or -entity that distributes the Program.</span> </p> - -<p><span style="font-size: 10pt;">"Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program. </span></p> - -<p><span style="font-size: 10pt;">"Program" means the Contributions -distributed in accordance with this Agreement.</span> </p> - -<p><span style="font-size: 10pt;">"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.</span> </p> - -<p><b><span style="font-size: 10pt;">2. GRANT OF RIGHTS</span></b> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to<span style="color: red;"> </span>reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide,<span style="color: green;"> </span>royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder. </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. </span></p> - -<p><b><span style="font-size: 10pt;">3. REQUIREMENTS</span></b> </p> - -<p><span style="font-size: 10pt;">A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that:</span> -</p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -it complies with the terms and conditions of this Agreement; and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) -its license agreement:</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose; </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits; </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and</span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.<span style="color: blue;"> </span></span></p> - -<p><span style="font-size: 10pt;">When the Program is made available in source -code form:</span> </p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">a) -it must be made available under this Agreement; and </span></p> - -<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt;">b) a -copy of this Agreement must be included with each copy of the Program. </span></p> - -<p><span style="font-size: 10pt;">Contributors may not remove or alter any -copyright notices contained within the Program. </span></p> - -<p><span style="font-size: 10pt;">Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution. </span></p> - -<p><b><span style="font-size: 10pt;">4. COMMERCIAL DISTRIBUTION</span></b> </p> - -<p><span style="font-size: 10pt;">Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.</span> </p> - -<p><span style="font-size: 10pt;">For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.</span> </p> - -<p><b><span style="font-size: 10pt;">5. NO WARRANTY</span></b> </p> - -<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations. </span></p> - -<p><b><span style="font-size: 10pt;">6. DISCLAIMER OF LIABILITY</span></b> </p> - -<p><span style="font-size: 10pt;">EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.</span> </p> - -<p><b><span style="font-size: 10pt;">7. GENERAL</span></b> </p> - -<p><span style="font-size: 10pt;">If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.</span> </p> - -<p><span style="font-size: 10pt;">If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed. </span></p> - -<p><span style="font-size: 10pt;">All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive. </span></p> - -<p><span style="font-size: 10pt;">Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.</span> </p> - -<p><span style="font-size: 10pt;">This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.</span> </p> - -<p class="MsoNormal"><!--[if !supportEmptyParas]--> <!--[endif]--><o:p></o:p></p> - -</div> - -</body></html>
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/plugin.properties b/plugins/org.eclipse.net4j.util/plugin.properties deleted file mode 100644 index e872a4035d..0000000000 --- a/plugins/org.eclipse.net4j.util/plugin.properties +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2004 - 2008 Eike Stepper, Germany. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR - -# ============================================================================== -# Do not change the properties between this line and the last line containing: -# %%% END OF TRANSLATED PROPERTIES %%% -# Instead, either redefine an existing property, or create a new property, -# append it to the end of the file, and change the code to use the new name. -# ============================================================================== - -pluginName = Net4j Utilities (Incubation) -providerName = Eclipse.org - -# ============================================================================== -# %%% END OF TRANSLATED PROPERTIES %%% -# The above properties have been shipped for translation. -# ============================================================================== diff --git a/plugins/org.eclipse.net4j.util/plugin.xml b/plugins/org.eclipse.net4j.util/plugin.xml deleted file mode 100644 index 93c3cf6119..0000000000 --- a/plugins/org.eclipse.net4j.util/plugin.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.3"?> -<!-- - <copyright> - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - - </copyright> ---> - -<plugin> - - <extension-point id="factories" name="Factories" schema="schema/factories.exsd"/> - <extension-point id="elementProcessors" name="Element Processors" schema="schema/elementProcessors.exsd"/> - - <extension - point="org.eclipse.net4j.util.factories"> - <factory - productGroup="org.eclipse.net4j.randomizers" - type="default" - class="org.eclipse.net4j.internal.util.security.RandomizerFactory"/> - <factory - productGroup="org.eclipse.net4j.userManagers" - type="file" - class="org.eclipse.net4j.internal.util.security.FileUserManagerFactory"/> - </extension> - -</plugin> diff --git a/plugins/org.eclipse.net4j.util/schema/elementProcessors.exsd b/plugins/org.eclipse.net4j.util/schema/elementProcessors.exsd deleted file mode 100644 index 12f3cef7b1..0000000000 --- a/plugins/org.eclipse.net4j.util/schema/elementProcessors.exsd +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.net4j.util"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.net4j.util" id="elementProcessors" name="Element Processors"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="elementProcessor" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="elementProcessor"> - <complexType> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - -</schema> diff --git a/plugins/org.eclipse.net4j.util/schema/factories.exsd b/plugins/org.eclipse.net4j.util/schema/factories.exsd deleted file mode 100644 index 40fe74a3d2..0000000000 --- a/plugins/org.eclipse.net4j.util/schema/factories.exsd +++ /dev/null @@ -1,124 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.eclipse.net4j.util"> -<annotation> - <appInfo> - <meta.schema plugin="org.eclipse.net4j.util" id="factories" name="Factories"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <element name="extension"> - <complexType> - <sequence> - <element ref="factory" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="factory"> - <annotation> - <appInfo> - <meta.element labelAttribute="class"/> - </appInfo> - </annotation> - <complexType> - <attribute name="productGroup" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="type" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="class" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn="org.eclipse.net4j.util.factory.IFactory"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiInfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="copyright"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - -</schema> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java deleted file mode 100644 index 8cb775704a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractBundle.java +++ /dev/null @@ -1,409 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.bundle; - -import org.eclipse.net4j.internal.util.om.log.Logger; -import org.eclipse.net4j.internal.util.om.pref.Preferences; -import org.eclipse.net4j.internal.util.om.trace.Tracer; -import org.eclipse.net4j.util.ReflectUtil; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Eike Stepper - */ -public abstract class AbstractBundle implements OMBundle, OMBundle.DebugSupport, OMBundle.TranslationSupport -{ - private AbstractPlatform platform; - - private String bundleID; - - private Class<?> accessor; - - private Object bundleContext; - - private boolean debugging; - - private boolean debuggingInitialized; - - private Map<String, Tracer> tracers = new ConcurrentHashMap<String, Tracer>(0); - - private OMLogger logger; - - private Preferences preferences; - - private ResourceBundle resourceBundle; - - private ResourceBundle untranslatedResourceBundle; - - private Map<String, String> strings = new HashMap<String, String>(0); - - private Map<String, String> untranslatedStrings = new HashMap<String, String>(0); - - private boolean shouldTranslate = true; - - public AbstractBundle(AbstractPlatform platform, String bundleID, Class<?> accessor) - { - this.platform = platform; - this.bundleID = bundleID; - this.accessor = accessor; - } - - public OMPlatform getPlatform() - { - return platform; - } - - public String getBundleID() - { - return bundleID; - } - - public Class<?> getAccessor() - { - return accessor; - } - - public Object getBundleContext() - { - return bundleContext; - } - - public void setBundleContext(Object bundleContext) - { - this.bundleContext = bundleContext; - } - - public DebugSupport getDebugSupport() - { - return this; - } - - public TranslationSupport getTranslationSupport() - { - return this; - } - - public boolean isDebugging() - { - if (!platform.isDebugging()) - { - return false; - } - - if (!debuggingInitialized) - { - debugging = getDebugOption("debug", false); //$NON-NLS-1$ - debuggingInitialized = true; - } - - return debugging; - } - - public void setDebugging(boolean debugging) - { - this.debugging = debugging; - } - - public String getDebugOption(String option, String defaultValue) - { - String value = getDebugOption(option); - return value == null ? defaultValue : value; - } - - public boolean getDebugOption(String option, boolean defaultValue) - { - String value = getDebugOption(option); - return value == null ? defaultValue : Boolean.parseBoolean(value); - } - - public void setDebugOption(String option, boolean value) - { - setDebugOption(option, Boolean.toString(value)); - } - - public int getDebugOption(String option, int defaultValue) - { - try - { - String value = getDebugOption(option); - return value == null ? defaultValue : Integer.parseInt(value); - } - catch (NumberFormatException e) - { - return defaultValue; - } - } - - public void setDebugOption(String option, int value) - { - setDebugOption(option, Integer.toString(value)); - } - - public String getDebugOption(String option) - { - return platform.getDebugOption(bundleID, option); - } - - public void setDebugOption(String option, String value) - { - platform.setDebugOption(bundleID, option, value); - } - - public synchronized OMTracer tracer(String name) - { - OMTracer tracer = tracers.get(name); - if (tracer == null) - { - tracer = createTracer(name); - } - - return tracer; - } - - public synchronized OMLogger logger() - { - if (logger == null) - { - logger = createLogger(); - } - - return logger; - } - - public File getConfigFile() - { - return platform.getConfigFile(getConfigFileName()); - } - - public Properties getConfigProperties() - { - return platform.getConfigProperties(getConfigFileName()); - } - - public synchronized Preferences preferences() - { - if (preferences == null) - { - preferences = new Preferences(this); - } - - return preferences; - } - - public InputStream getInputStream(String path) throws IOException - { - String base = getBaseURL().toString(); - if (!path.startsWith("/")) - { - base += "/"; - } - - URL url = new URL(base + path); - return url.openStream(); - } - - public boolean shouldTranslate() - { - return shouldTranslate; - } - - public void setShouldTranslate(boolean shouldTranslate) - { - this.shouldTranslate = shouldTranslate; - } - - public String getString(String key, boolean translate) - { - Map<String, String> stringMap = translate ? strings : untranslatedStrings; - String result = stringMap.get(key); - if (result == null) - { - - ResourceBundle bundle = translate ? resourceBundle : untranslatedResourceBundle; - if (bundle == null) - { - String packageName = ReflectUtil.getPackageName(accessor); - if (translate) - { - try - { - bundle = resourceBundle = ResourceBundle.getBundle(packageName + ".plugin"); //$NON-NLS-1$ - } - catch (MissingResourceException exception) - { - // If the bundle can't be found the normal way, try to find it as - // the base URL. If that also doesn't work, rethrow the original - // exception. - InputStream inputStream = null; - try - { - inputStream = getInputStream("plugin.properties"); //$NON-NLS-1$ - bundle = new PropertyResourceBundle(inputStream); - untranslatedResourceBundle = resourceBundle = bundle; - inputStream.close(); - } - catch (IOException ignore) - { - ; - } - finally - { - IOUtil.closeSilent(inputStream); - } - - if (resourceBundle == null) - { - throw exception; - } - } - } - else - { - InputStream inputStream = null; - - try - { - inputStream = getInputStream("plugin.properties"); //$NON-NLS-1$ - bundle = untranslatedResourceBundle = new PropertyResourceBundle(inputStream); - inputStream.close(); - } - catch (IOException ioException) - { - throw new MissingResourceException("Missing resource: plugin.properties", accessor //$NON-NLS-1$ - .getName(), key); - } - finally - { - IOUtil.closeSilent(inputStream); - } - } - } - - result = bundle.getString(key); - stringMap.put(key, result); - } - - return result; - } - - public String getString(String key) - { - return getString(key, shouldTranslate()); - } - - public String getString(String key, Object... args) - { - return getString(key, shouldTranslate(), args); - } - - public String getString(String key, boolean translate, Object... args) - { - return MessageFormat.format(getString(key, translate), args); - } - - @Override - public String toString() - { - return bundleID; - } - - public void start() throws Exception - { - invokeMethod("start"); - } - - public void stop() throws Exception - { - try - { - if (preferences != null) - { - preferences.save(); - } - } - catch (RuntimeException ex) - { - OM.LOG.error(ex); - } - - invokeMethod("stop"); - } - - protected OMTracer createTracer(String name) - { - return new Tracer(this, name); - } - - protected OMLogger createLogger() - { - return new Logger(this); - } - - protected String getConfigFileName() - { - return bundleID + ".properties"; - } - - private void invokeMethod(String name) throws Exception - { - try - { - Method method = accessor.getDeclaredMethod(name, ReflectUtil.NO_PARAMETERS); - if (!method.isAccessible()) - { - method.setAccessible(true); - } - - method.invoke(null, ReflectUtil.NO_ARGUMENTS); - } - catch (NoSuchMethodException ignore) - { - } - catch (IllegalAccessException ignore) - { - } - catch (InvocationTargetException ex) - { - Throwable targetException = ex.getTargetException(); - if (targetException instanceof Exception) - { - throw (Exception)targetException; - } - else if (targetException instanceof Error) - { - throw (Error)targetException; - } - else - { - OM.LOG.error(targetException); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java deleted file mode 100644 index 172927f6f8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/AbstractPlatform.java +++ /dev/null @@ -1,285 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.bundle; - -import org.eclipse.net4j.internal.util.om.LegacyPlatform; -import org.eclipse.net4j.internal.util.om.OSGiPlatform; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.log.OMLogHandler; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.log.OMLogger.Level; -import org.eclipse.net4j.util.om.trace.OMTraceHandler; -import org.eclipse.net4j.util.om.trace.OMTraceHandlerEvent; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Map; -import java.util.Properties; -import java.util.Queue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @author Eike Stepper - */ -public abstract class AbstractPlatform implements OMPlatform -{ - public static final String SYSTEM_PROPERTY_OSGI_STATE = "osgi.instance.area"; //$NON-NLS-1$ - - public static final String SYSTEM_PROPERTY_NET4J_STATE = "net4j.state"; //$NON-NLS-1$ - - public static final String SYSTEM_PROPERTY_NET4J_CONFIG = "net4j.config"; //$NON-NLS-1$ - - static Object systemContext; - - private static ContextTracer __TRACER__; - - private Map<String, AbstractBundle> bundles = new ConcurrentHashMap<String, AbstractBundle>(0); - - private Queue<OMLogHandler> logHandlers = new ConcurrentLinkedQueue<OMLogHandler>(); - - private Queue<OMTraceHandler> traceHandlers = new ConcurrentLinkedQueue<OMTraceHandler>(); - - private boolean debugging; - - protected AbstractPlatform() - { - debugging = Boolean.parseBoolean(System.getProperty("debug", "false")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public synchronized OMBundle bundle(String bundleID, Class<?> accessor) - { - OMBundle bundle = bundles.get(bundleID); - if (bundle == null) - { - bundle = createBundle(bundleID, accessor); - } - - return bundle; - } - - public void addLogHandler(OMLogHandler logHandler) - { - if (!logHandlers.contains(logHandler)) - { - logHandlers.add(logHandler); - } - } - - public void removeLogHandler(OMLogHandler logHandler) - { - logHandlers.remove(logHandler); - } - - public void addTraceHandler(OMTraceHandler traceHandler) - { - if (!traceHandlers.contains(traceHandler)) - { - traceHandlers.add(traceHandler); - } - } - - public void removeTraceHandler(OMTraceHandler traceHandler) - { - traceHandlers.remove(traceHandler); - } - - public boolean isDebugging() - { - return debugging; - } - - public void setDebugging(boolean debugging) - { - this.debugging = debugging; - } - - public File getStateFolder() - { - String state = System.getProperty(SYSTEM_PROPERTY_NET4J_STATE); - if (state == null) - { - state = System.getProperty(SYSTEM_PROPERTY_OSGI_STATE); - if (state == null) - { - state = "state"; - } - else - { - state += ".metadata"; - } - } - - File stateFolder = new File(state); - if (!stateFolder.exists()) - { - if (!stateFolder.mkdirs()) - { - OM.LOG.error("State folder " + stateFolder.getAbsolutePath() + " could not be created"); - return null; - } - } - - if (!stateFolder.isDirectory()) - { - OM.LOG.error("State folder " + stateFolder.getAbsolutePath() + " is not a directoy"); - return null; - } - - return stateFolder; - } - - public File getConfigFolder() - { - String config = System.getProperty(SYSTEM_PROPERTY_NET4J_CONFIG, "config"); - File configFolder = new File(config); - if (!configFolder.exists()) - { - if (!configFolder.mkdirs()) - { - OM.LOG.error("Config folder " + configFolder.getAbsolutePath() + " could not be created"); - return null; - } - } - - if (!configFolder.isDirectory()) - { - OM.LOG.error("Config folder " + configFolder.getAbsolutePath() + " is not a directoy"); - return null; - } - - return configFolder; - } - - public File getConfigFile(String name) - { - File configFolder = getConfigFolder(); - if (configFolder == null) - { - return null; - } - - return new File(configFolder, name); - } - - public Properties getConfigProperties(String name) - { - File configFile = getConfigFile(name); - if (configFile == null) - { - return null; - } - - FileInputStream fis = null; - try - { - fis = new FileInputStream(configFile); - Properties properties = new Properties(); - properties.load(fis); - return properties; - } - catch (IOException ex) - { - OM.LOG.error("Config file " + configFile.getAbsolutePath() + " could not be read"); - return null; - } - finally - { - IOUtil.closeSilent(fis); - } - } - - public void log(OMLogger logger, Level level, String msg, Throwable t) - { - for (OMLogHandler logHandler : logHandlers) - { - try - { - logHandler.logged(logger, level, msg, t); - } - catch (Exception ex) - { - if (TRACER().isEnabled()) - { - TRACER().trace(ex); - } - } - } - } - - public void trace(OMTraceHandlerEvent event) - { - for (OMTraceHandler traceHandler : traceHandlers) - { - try - { - traceHandler.traced(event); - } - catch (Exception ex) - { - if (TRACER().isEnabled()) - { - TRACER().trace(ex); - } - } - } - } - - protected Map<String, AbstractBundle> getBundles() - { - return bundles; - } - - protected abstract OMBundle createBundle(String bundleID, Class<?> accessor); - - protected abstract String getDebugOption(String bundleID, String option); - - protected abstract void setDebugOption(String bundleID, String option, String value); - - /** - * TODO Make configurable via system property - */ - public static synchronized OMPlatform createPlatform() - { - try - { - if (systemContext != null) - { - return new OSGiPlatform(systemContext); - } - - return new LegacyPlatform(); - } - catch (Exception ex) - { - if (TRACER().isEnabled()) - { - TRACER().trace(ex); - } - } - - return null; - } - - private static ContextTracer TRACER() - { - if (__TRACER__ == null) - { - __TRACER__ = new ContextTracer(OM.DEBUG_OM, AbstractPlatform.class); - } - - return __TRACER__; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java deleted file mode 100644 index 9aa054abcf..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/bundle/OM.java +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.bundle; - -import org.eclipse.net4j.internal.util.container.PluginContainer; -import org.eclipse.net4j.internal.util.om.OSGiBundle; -import org.eclipse.net4j.internal.util.om.log.EclipseLoggingBridge; -import org.eclipse.net4j.internal.util.om.log.PrintLogHandler; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.internal.util.om.trace.PrintTraceHandler; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -/** - * The <em>Operations & Maintenance</em> class of this bundle. - * - * @author Eike Stepper - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.net4j.util"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_LIFECYCLE = DEBUG.tracer("lifecycle"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_LIFECYCLE_DUMP = DEBUG_LIFECYCLE.tracer("dump"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_CONCURRENCY = DEBUG.tracer("concurrency"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_REGISTRY = DEBUG.tracer("registry"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_OM = DEBUG.tracer("om"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OM, OM.class); - - static void stop() throws Exception - { - PluginContainer.dispose(); - } - - /** - * @author Eike Stepper - */ - public static final class Activator implements BundleActivator - { - public void start(BundleContext context) throws Exception - { - AbstractPlatform.systemContext = context; - OM.BUNDLE.setBundleContext(context); - ((OSGiBundle)OM.BUNDLE).start(); - - // TODO Make configurable - PrintTraceHandler.CONSOLE.setPattern("{6} [{0}] {5}"); - AbstractPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE); - AbstractPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE); - - try - { - AbstractPlatform.INSTANCE.addLogHandler(EclipseLoggingBridge.INSTANCE); - } - catch (Exception ignore) - { - } - - traceStart(context); - IPluginContainer container = IPluginContainer.INSTANCE; - if (TRACER.isEnabled()) TRACER.format("Plugin container created: {0}", container); - } - - public void stop(BundleContext context) throws Exception - { - traceStop(context); - ((OSGiBundle)OM.BUNDLE).stop(); - OM.BUNDLE.setBundleContext(null); - AbstractPlatform.systemContext = null; - } - - public static void traceStart(BundleContext context) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Starting bundle {0}", context.getBundle().getSymbolicName()); - } - } - catch (RuntimeException ignore) - { - } - } - - public static void traceStop(BundleContext context) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Stopping bundle {0}", context.getBundle().getSymbolicName()); - } - } - catch (RuntimeException ignore) - { - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/Cache.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/Cache.java deleted file mode 100644 index 5f8f84a93d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/Cache.java +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.cache; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Worker; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.cache.ICache; -import org.eclipse.net4j.util.cache.ICacheMonitor; -import org.eclipse.net4j.util.cache.ICacheProbe; - -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; - -/** - * @author Eike Stepper - */ -public abstract class Cache<E> extends Worker implements ICache -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, Cache.class); - - private ICacheMonitor cacheMonitor; - - private ICacheProbe cacheProbe; - - private ReferenceQueue<E> referenceQueue = new ReferenceQueue<E>(); - - public Cache() - { - } - - public ICacheMonitor getCacheMonitor() - { - return cacheMonitor; - } - - public void setCacheMonitor(ICacheMonitor cacheMonitor) - { - this.cacheMonitor = cacheMonitor; - } - - protected ICacheProbe getCacheProbe() - { - return cacheProbe; - } - - protected ReferenceQueue<E> getReferenceQueue() - { - return referenceQueue; - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (cacheMonitor == null) - { - throw new IllegalStateException("cacheMonitor == null"); - } - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - cacheProbe = cacheMonitor.registerCache(this); - } - - @Override - protected void doDeactivate() throws Exception - { - cacheMonitor.deregisterCache(this); - cacheProbe = null; - super.doDeactivate(); - } - - @Override - protected void work(WorkContext context) throws Exception - { - Reference<? extends E> reference = referenceQueue.remove(200); - if (reference != null) - { - unreachableElement(reference); - } - } - - protected void unreachableElement(Reference<? extends E> reference) - { - E element = reference.get(); - if (element != null) - { - unreachableElement(element); - } - } - - protected void unreachableElement(E element) - { - if (TRACER.isEnabled()) TRACER.trace("Unreachable: " + element); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheMonitor.java deleted file mode 100644 index 36b6337fe2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheMonitor.java +++ /dev/null @@ -1,242 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.cache; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.event.Event; -import org.eclipse.net4j.internal.util.lifecycle.Worker; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.ImplementationError; -import org.eclipse.net4j.util.cache.ICache; -import org.eclipse.net4j.util.cache.ICacheMonitor; -import org.eclipse.net4j.util.cache.ICacheMonitorEvent; -import org.eclipse.net4j.util.cache.ICacheRegistration; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class CacheMonitor extends Worker implements ICacheMonitor -{ - // percentFreeAllocated = Round((freeMemory / totalMemory) * 100); - // percentAllocated = Round((totalMemory / maxMemory ) * 100); - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CacheMonitor.class); - - private static final long DEFAULT_PAUSE_GREEN = 60L * 1000L; // 1 minute - - private static final long DEFAULT_PAUSE_YELLOW = 5L * 1000L; // 5 seconds - - private static final long DEFAULT_PAUSE_RED = 100L; // 100 milliseconds - - private long pauseGREEN = DEFAULT_PAUSE_GREEN; - - private long pauseYELLOW = DEFAULT_PAUSE_YELLOW; - - private long pauseRED = DEFAULT_PAUSE_RED; - - private ConditionPolicy conditionPolicy; - - private Condition condition; - - private Map<ICache, ICacheRegistration> registrations = new HashMap<ICache, ICacheRegistration>(); - - public CacheMonitor() - { - } - - public long getPauseGREEN() - { - return pauseGREEN; - } - - public void setPauseGREEN(long pauseGREEN) - { - this.pauseGREEN = pauseGREEN; - } - - public long getPauseYELLOW() - { - return pauseYELLOW; - } - - public void setPauseYELLOW(long pauseYELLOW) - { - this.pauseYELLOW = pauseYELLOW; - } - - public long getPauseRED() - { - return pauseRED; - } - - public void setPauseRED(long pauseRED) - { - this.pauseRED = pauseRED; - } - - public ConditionPolicy getConditionPolicy() - { - return conditionPolicy; - } - - public void setConditionPolicy(ConditionPolicy conditionPolicy) - { - this.conditionPolicy = conditionPolicy; - } - - public Condition getCondition() - { - return condition; - } - - public ICacheRegistration[] getRegistrations() - { - synchronized (registrations) - { - return registrations.values().toArray(new ICacheRegistration[registrations.size()]); - } - } - - public ICacheRegistration registerCache(ICache cache) - { - if (TRACER.isEnabled()) TRACER.trace("Registering cache " + cache); - ICacheRegistration registration = new CacheRegistration(this, cache); - ICacheRegistration oldRegistration; - synchronized (registrations) - { - oldRegistration = registrations.put(cache, registration); - } - - if (oldRegistration != null) - { - oldRegistration.dispose(); - } - - return registration; - } - - public void deregisterCache(ICache cache) - { - ICacheRegistration registration; - synchronized (registrations) - { - registration = registrations.remove(cache); - } - - if (registration != null) - { - registration.dispose(); - if (TRACER.isEnabled()) TRACER.trace("Deregistered cache " + cache); - } - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (conditionPolicy == null) - { - throw new IllegalStateException("conditionPolicy == null"); - } - } - - @Override - protected void doDeactivate() throws Exception - { - for (ICacheRegistration registration : getRegistrations()) - { - registration.dispose(); - } - - registrations.clear(); - super.doDeactivate(); - } - - @Override - protected void work(WorkContext context) throws Exception - { - Condition newCondition = conditionPolicy.getNewCondition(condition); - setCondition(newCondition); - - switch (newCondition) - { - case GREEN: - context.nextWork(pauseGREEN); - break; - - case YELLOW: - context.nextWork(pauseYELLOW); - break; - - case RED: - handleConditionRED(); - context.nextWork(pauseRED); - break; - } - } - - protected void setCondition(Condition newCondition) - { - if (newCondition == null) - { - throw new ImplementationError("newCondition == null"); - } - - Condition oldCondition = condition; - if (newCondition != oldCondition) - { - condition = newCondition; - fireEvent(new CacheMonitorEvent(oldCondition, newCondition)); - } - } - - protected void handleConditionRED() - { - System.err.println("CONDITION RED"); - } - - /** - * @author Eike Stepper - */ - private final class CacheMonitorEvent extends Event implements ICacheMonitorEvent - { - private static final long serialVersionUID = 1L; - - private Condition oldCondition; - - private Condition newCondition; - - public CacheMonitorEvent(Condition oldCondition, Condition newCondition) - { - super(CacheMonitor.this); - this.oldCondition = oldCondition; - this.newCondition = newCondition; - } - - public ICacheMonitor getCacheMonitor() - { - return CacheMonitor.this; - } - - public Condition getOldCondition() - { - return oldCondition; - } - - public Condition getNewCondition() - { - return newCondition; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheRegistration.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheRegistration.java deleted file mode 100644 index 5323b42a28..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/CacheRegistration.java +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.cache; - -import org.eclipse.net4j.util.cache.ICache; -import org.eclipse.net4j.util.cache.ICacheMonitor; -import org.eclipse.net4j.util.cache.ICacheRegistration; - -/** - * @author Eike Stepper - */ -public class CacheRegistration implements ICacheRegistration -{ - public static final float DEFAULT_RECONSTRUCTION_COST_DECAY_FACTOR = 0.1f; - - private ICacheMonitor cacheMonitor; - - private ICache cache; - - private int elementCount; - - private long cacheSize; - - private long reconstructionCost; - - public CacheRegistration(ICacheMonitor cacheMonitor, ICache cache) - { - this.cacheMonitor = cacheMonitor; - this.cache = cache; - } - - public void dispose() - { - cacheMonitor = null; - cache = null; - } - - public boolean isDisposed() - { - return cacheMonitor == null || cache == null; - } - - public ICacheMonitor getCacheMonitor() - { - return cacheMonitor; - } - - public ICache getCache() - { - return cache; - } - - public int getElementCount() - { - return elementCount; - } - - public long getCacheSize() - { - return cacheSize; - } - - public long getAverageElementSize() - { - return cacheSize / elementCount; - } - - public long getReconstructionCost() - { - return reconstructionCost; - } - - public void elementCached(int elementSize) - { - checkDisposal(); - ++elementCount; - cacheSize += elementSize; - } - - public void elementEvicted(int elementSize) - { - checkDisposal(); - --elementCount; - cacheSize -= elementSize; - } - - public void elementReconstructed(long reconstructionTime) - { - checkDisposal(); - float decayFactor = getReconstructionCostDecayFactor(); - this.reconstructionCost = (long)(decayFactor * this.reconstructionCost + (1 - decayFactor) * reconstructionTime); - } - - protected float getReconstructionCostDecayFactor() - { - return DEFAULT_RECONSTRUCTION_COST_DECAY_FACTOR; - } - - private void checkDisposal() - { - if (isDisposed()) - { - throw new IllegalStateException("disposed"); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/HysteresisConditionPolicy.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/HysteresisConditionPolicy.java deleted file mode 100644 index 3e420cc455..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/HysteresisConditionPolicy.java +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.cache; - -import org.eclipse.net4j.util.cache.ICacheMonitor.Condition; - -/** - * @author Eike Stepper - */ -public class HysteresisConditionPolicy extends ThresholdConditionPolicy -{ - private long thresholdYellowRed; - - private long thresholdGreenYellow; - - public HysteresisConditionPolicy(long thresholdYellowRed, long thresholdRedYellow, long thresholdGreenYellow, - long thresholdYellowGreen) - { - super(thresholdRedYellow, thresholdYellowGreen); - if (thresholdYellowRed > thresholdRedYellow) - { - throw new IllegalArgumentException("thresholdYellowRed > thresholdRedYellow"); - } - - if (thresholdRedYellow > thresholdGreenYellow) - { - throw new IllegalArgumentException("thresholdRedYellow > thresholdGreenYellow"); - } - - if (thresholdGreenYellow > thresholdYellowGreen) - { - throw new IllegalArgumentException("thresholdGreenYellow > thresholdYellowGreen"); - } - - this.thresholdGreenYellow = thresholdGreenYellow; - this.thresholdYellowRed = thresholdYellowRed; - } - - public long getThresholdYellowRed() - { - return thresholdYellowRed; - } - - public long getThresholdGreenYellow() - { - return thresholdGreenYellow; - } - - @Override - protected Condition getNewCondition(Condition oldCondition, long freeMemory) - { - switch (oldCondition) - { - case GREEN: - if (freeMemory < thresholdYellowRed) - { - return Condition.RED; - } - - if (freeMemory < thresholdGreenYellow) - { - return Condition.YELLOW; - } - - return Condition.GREEN; - - case YELLOW: - if (freeMemory < thresholdYellowRed) - { - return Condition.RED; - } - - if (freeMemory > getThresholdYellowGreen()) - { - return Condition.GREEN; - } - - return Condition.YELLOW; - - case RED: - if (freeMemory > getThresholdYellowGreen()) - { - return Condition.GREEN; - } - - if (freeMemory > getThresholdRedYellow()) - { - return Condition.YELLOW; - } - - return Condition.RED; - - default: - throw new IllegalArgumentException("oldCondition == " + oldCondition); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/ThresholdConditionPolicy.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/ThresholdConditionPolicy.java deleted file mode 100644 index 6342d7159b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/cache/ThresholdConditionPolicy.java +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.cache; - -import org.eclipse.net4j.util.cache.ICacheMonitor; -import org.eclipse.net4j.util.cache.ICacheMonitor.Condition; - -/** - * @author Eike Stepper - */ -public class ThresholdConditionPolicy implements ICacheMonitor.ConditionPolicy -{ - private long thresholdRedYellow; - - private long thresholdYellowGreen; - - public ThresholdConditionPolicy(long thresholdRedYellow, long thresholdYellowGreen) - { - if (thresholdRedYellow > thresholdYellowGreen) - { - throw new IllegalArgumentException("thresholdRedYellow > thresholdYellowGreen"); - } - - this.thresholdRedYellow = thresholdRedYellow; - this.thresholdYellowGreen = thresholdYellowGreen; - } - - public long getThresholdRedYellow() - { - return thresholdRedYellow; - } - - public long getThresholdYellowGreen() - { - return thresholdYellowGreen; - } - - public Condition getNewCondition(Condition oldCondition) - { - return getNewCondition(oldCondition, Runtime.getRuntime().freeMemory()); - } - - protected Condition getNewCondition(Condition oldCondition, long freeMemory) - { - if (freeMemory > thresholdYellowGreen) - { - return Condition.GREEN; - } - - if (freeMemory > thresholdRedYellow) - { - return Condition.YELLOW; - } - - return Condition.RED; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HashBag.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HashBag.java deleted file mode 100644 index f541ab5676..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HashBag.java +++ /dev/null @@ -1,172 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.collection; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public final class HashBag<T> implements Set<T> -{ - private Map<T, HashBag.Counter> map; - - public HashBag() - { - map = new HashMap<T, Counter>(); - } - - public HashBag(int initialCapacity, float loadFactor) - { - map = new HashMap<T, Counter>(initialCapacity, loadFactor); - } - - public HashBag(int initialCapacity) - { - map = new HashMap<T, Counter>(initialCapacity); - } - - public HashBag(Map<? extends T, ? extends HashBag.Counter> m) - { - map = new HashMap<T, Counter>(m); - } - - public boolean add(T o) - { - HashBag.Counter counter = map.get(o); - if (counter == null) - { - counter = new Counter(); - map.put(o, counter); - return true; - } - - counter.incValue(); - return false; - } - - public boolean addAll(Collection<? extends T> c) - { - for (T t : c) - { - add(t); - } - - return true; - } - - public void clear() - { - map.clear(); - } - - public boolean contains(Object o) - { - return map.containsKey(o); - } - - public boolean containsAll(Collection<?> c) - { - return map.keySet().containsAll(c); - } - - public boolean isEmpty() - { - return map.isEmpty(); - } - - public Iterator<T> iterator() - { - return map.keySet().iterator(); - } - - public boolean remove(Object o) - { - HashBag.Counter counter = map.get(o); - if (counter == null) - { - return false; - } - - if (counter.decValue() == 0) - { - map.remove(o); - } - - return true; - } - - public boolean removeAll(Collection<?> c) - { - boolean changed = false; - for (Object object : c) - { - if (remove(object)) - { - changed = true; - } - } - - return changed; - } - - public boolean retainAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - public int size() - { - return map.size(); - } - - public Object[] toArray() - { - return map.keySet().toArray(); - } - - @SuppressWarnings("hiding") - public <T> T[] toArray(T[] a) - { - return map.keySet().toArray(a); - } - - /** - * @author Eike Stepper - */ - private static final class Counter - { - private int value = 1; - - public Counter() - { - } - - public int getValue() - { - return value; - } - - public int incValue() - { - return ++value; - } - - public int decValue() - { - return --value; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java deleted file mode 100644 index f6d3f61d9a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java +++ /dev/null @@ -1,214 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.collection; - -import org.eclipse.net4j.internal.util.event.Notifier; -import org.eclipse.net4j.util.collection.IHistory; -import org.eclipse.net4j.util.collection.IHistoryChangeEvent; -import org.eclipse.net4j.util.collection.IHistoryElement; -import org.eclipse.net4j.util.event.INotifier; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class History<T> extends Notifier implements IHistory<T> -{ - protected List<IHistoryElement<T>> elements = new ArrayList<IHistoryElement<T>>(0); - - private boolean loaded; - - public History() - { - } - - public List<IHistoryElement<T>> getElements() - { - lazyLoad(); - return elements; - } - - public void setElements(List<IHistoryElement<T>> newElements) - { - if (newElements == null) - { - newElements = new ArrayList<IHistoryElement<T>>(0); - } - - if (!elements.equals(newElements)) - { - elements = newElements; - changed(); - } - } - - public boolean isEmpty() - { - lazyLoad(); - return elements.isEmpty(); - } - - public int size() - { - lazyLoad(); - return elements.size(); - } - - public int indexOf(T data) - { - lazyLoad(); - for (int i = 0; i < elements.size(); i++) - { - if (elements.get(i).getData().equals(data)) - { - return i; - } - } - - return -1; - } - - public IHistoryElement<T> get(int index) - { - lazyLoad(); - return elements.get(index); - } - - public boolean add(T data) - { - lazyLoad(); - int index = indexOf(data); - IHistoryElement<T> element = index != -1 ? elements.remove(index) : createElement(data); - elements.add(0, element); - - boolean changed = index != 0; - if (changed) - { - changed(); - } - - return changed; - } - - public IHistoryElement<T> remove(int index) - { - lazyLoad(); - IHistoryElement<T> element = elements.remove(index); - if (element != null) - { - changed(); - } - - return element; - } - - public boolean clear() - { - if (elements.isEmpty()) - { - return false; - } - - elements.clear(); - changed(); - return true; - } - - public T getMostRecent() - { - lazyLoad(); - if (isEmpty()) - { - return null; - } - - return elements.get(0).getData(); - } - - @SuppressWarnings("unchecked") - public <D> D[] getData(D[] a) - { - lazyLoad(); - int size = elements.size(); - if (a.length < size) - { - a = (D[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size); - } - - for (int i = 0; i < size; i++) - { - a[i] = (D)elements.get(i).getData(); - } - - if (a.length > size) - { - a[size] = null; - } - - return a; - } - - @SuppressWarnings("unchecked") - public IHistoryElement<T>[] toArray() - { - lazyLoad(); - return elements.toArray(new IHistoryElement[elements.size()]); - } - - public Iterator<IHistoryElement<T>> iterator() - { - lazyLoad(); - return elements.iterator(); - } - - @SuppressWarnings("unchecked") - protected IHistoryElement<T> createElement(T data) - { - return new HistoryElement(this, data); - } - - protected void load() - { - } - - protected void save() - { - } - - protected final void changed() - { - save(); - fireChangedEvent(); - } - - private void lazyLoad() - { - if (!loaded) - { - loaded = true; - load(); - } - } - - private void fireChangedEvent() - { - fireEvent(new IHistoryChangeEvent() - { - public INotifier getSource() - { - return History.this; - } - }); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HistoryElement.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HistoryElement.java deleted file mode 100644 index d1759e4343..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/HistoryElement.java +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.collection; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.collection.IHistory; -import org.eclipse.net4j.util.collection.IHistoryElement; - -/** - * @author Eike Stepper - */ -public class HistoryElement<T> implements IHistoryElement<T> -{ - private IHistory<IHistoryElement<T>> history; - - private T data; - - public HistoryElement(IHistory<IHistoryElement<T>> history, T data) - { - this.history = history; - this.data = data; - } - - public IHistory<IHistoryElement<T>> getHistory() - { - return history; - } - - public T getData() - { - return data; - } - - public String getText() - { - return data.toString(); - } - - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof IHistoryElement) - { - IHistoryElement<T> that = (IHistoryElement<T>)obj; - return ObjectUtil.equals(history, that.getHistory()) && ObjectUtil.equals(data, that.getData()); - } - - return false; - } - - @Override - public int hashCode() - { - return history.hashCode() ^ data.hashCode(); - } - - @Override - public String toString() - { - return getText(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/MoveableArrayList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/MoveableArrayList.java deleted file mode 100644 index b17f949865..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/MoveableArrayList.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.eclipse.net4j.internal.util.collection; - -import org.eclipse.net4j.util.collection.MoveableList; - -import java.util.ArrayList; - -/** - * A list with O(1) effort for random access. - * - * @author Eike Stepper - */ -public final class MoveableArrayList<E> extends ArrayList<E> implements MoveableList<E> -{ - private static final long serialVersionUID = 1L; - - public MoveableArrayList(int initialCapacity) - { - super(initialCapacity); - - } - - public E move(int targetIndex, int sourceIndex) - { - int size = size(); - if (sourceIndex >= size) - { - throw new IndexOutOfBoundsException("sourceIndex=" + sourceIndex + ", size=" + size); - } - - if (targetIndex >= size) - { - throw new IndexOutOfBoundsException("targetIndex=" + targetIndex + ", size=" + size); - } - - E object = get(sourceIndex); - if (targetIndex == sourceIndex) - { - return object; - } - - if (targetIndex < sourceIndex) - { - moveUp1(targetIndex, sourceIndex - targetIndex); - } - else - { - moveDown1(targetIndex, targetIndex - sourceIndex); - } - - set(targetIndex, object); - return object; - } - - private void moveUp1(int index, int count) - { - for (int i = count; i > 0; i--) - { - set(index + i, get(index + i - 1)); - } - } - - private void moveDown1(int index, int count) - { - for (int i = count; i > 0; i--) - { - set(index - i, get(index - i + 1)); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/PreferenceHistory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/PreferenceHistory.java deleted file mode 100644 index 70676982c9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/PreferenceHistory.java +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.collection; - -import org.eclipse.net4j.util.collection.IHistoryElement; -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public class PreferenceHistory extends History<String> -{ - private OMPreference<String[]> preference; - - public PreferenceHistory(OMPreference<String[]> preference) - { - this.preference = preference; - } - - public OMPreference<String[]> getPreference() - { - return preference; - } - - @Override - protected void load() - { - String[] value = preference.getValue(); - for (String data : value) - { - IHistoryElement<String> element = createElement(data); - elements.add(element); - } - } - - @Override - protected void save() - { - String[] array = getData(new String[size()]); - preference.setValue(array); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java deleted file mode 100644 index b75f513572..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/AsynchronousWorkSerializer.java +++ /dev/null @@ -1,162 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.concurrent.IWorkSerializer; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutorService; - -/** - * @author Eike Stepper - */ -public class AsynchronousWorkSerializer implements IWorkSerializer, Runnable -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_CONCURRENCY, AsynchronousWorkSerializer.class); - - private ExecutorService executorService; - - private Queue<Runnable> workQueue; - - private Occupation occupation = new Occupation(); - - // private Object newElementLock = new Object(); - - public AsynchronousWorkSerializer(ExecutorService executorService, Queue<Runnable> workQueue) - { - if (executorService == null) - { - throw new IllegalArgumentException("executorService == null"); //$NON-NLS-1$ - } - - this.executorService = executorService; - this.workQueue = workQueue; - } - - public AsynchronousWorkSerializer(ExecutorService executorService) - { - this(executorService, new ConcurrentLinkedQueue<Runnable>()); - } - - public ExecutorService getExecutorService() - { - return executorService; - } - - public boolean addWork(Runnable work) - { - // Need to be a block of execution. Cannot add when doing last check - // XXX synchronized (newElementLock) - { - workQueue.add(work); - - // isOccupied can (and must) be called unsynchronized here - if (!occupation.isOccupied()) - { - synchronized (occupation) - { - occupation.setOccupied(true); - } - - if (TRACER.isEnabled()) - { - TRACER.trace("Notifying executor service"); //$NON-NLS-1$ - } - - executorService.execute(this); - } - } - - return true; - } - - /** - * Executed in the context of the {@link #getExecutorService() executor service}. - * <p> - */ - public void run() - { - // XXX synchronized (occupation) - { - Runnable work; - // for (;;) - { - while (occupation.isOccupied() && (work = workQueue.poll()) != null) - { - try - { - work.run(); - } - catch (RuntimeException ex) - { - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - } - } - - // ConcurrencyUtil.sleep(500); - - // Could put the sync in the while loop... but not efficient. - // Doing a last check to make sure that no one added something in the - // queue - // synchronized (newElementLock) - // { - // if (!occupation.isOccupied() || (work = workQueue.peek()) == null) - // { - // occupation.setOccupied(false); - // break; - // } - // } - } - } - } - - public void dispose() - { - if (occupation.isOccupied()) - { - occupation.setOccupied(false); - } - - workQueue.clear(); - workQueue = null; - executorService = null; - } - - @Override - public String toString() - { - return AsynchronousWorkSerializer.class.getSimpleName(); - } - - /** - * @author Eike Stepper - */ - private static final class Occupation - { - private boolean occupied = false; - - public boolean isOccupied() - { - return occupied; - } - - public void setOccupied(boolean occupied) - { - this.occupied = occupied; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java deleted file mode 100644 index 4fa6541818..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/CompletionWorkSerializer.java +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.util.concurrent.IWorkSerializer; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CompletionService; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.Future; - -/** - * @author Eike Stepper - */ -public class CompletionWorkSerializer implements IWorkSerializer -{ - private CompletionService<Object> completionService; - - public CompletionWorkSerializer(CompletionService<Object> completionService) - { - this.completionService = completionService; - } - - public CompletionWorkSerializer(Executor executor, BlockingQueue<Future<Object>> completionQueue) - { - this(new ExecutorCompletionService<Object>(executor, completionQueue)); - } - - public CompletionWorkSerializer(Executor executor) - { - this(new ExecutorCompletionService<Object>(executor)); - } - - public CompletionWorkSerializer() - { - this(new OnePendingExecutor()); - } - - public CompletionService<Object> getCompletionService() - { - return completionService; - } - - public void dispose() - { - } - - public boolean addWork(Runnable work) - { - completionService.submit(work, true); - return true; - } - - @Override - public String toString() - { - return CompletionWorkSerializer.class.getSimpleName(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/OnePendingExecutor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/OnePendingExecutor.java deleted file mode 100644 index 30be501195..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/OnePendingExecutor.java +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import java.util.concurrent.Executor; - -public class OnePendingExecutor implements Executor -{ - private Runnable command; - - private Thread thread; - - public OnePendingExecutor() - { - } - - public synchronized void execute(Runnable command) - { - if (this.command != null) - { - throw new IllegalStateException("One command already pending"); - } - - this.command = command; - if (thread == null) - { - thread = new Thread() - { - @Override - public void run() - { - for (;;) - { - Runnable command; - synchronized (OnePendingExecutor.this) - { - if (OnePendingExecutor.this.command == null) - { - thread = null; - return; - } - - command = OnePendingExecutor.this.command; - OnePendingExecutor.this.command = null; - } - - command.run(); - } - } - }; - - thread.setDaemon(true); - thread.start(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java deleted file mode 100644 index 6a1c2b6dc3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/QueueWorkerWorkSerializer.java +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.internal.util.lifecycle.QueueWorker; -import org.eclipse.net4j.util.concurrent.IWorkSerializer; - -/** - * @author Eike Stepper - */ -public class QueueWorkerWorkSerializer extends QueueWorker<Runnable> implements IWorkSerializer -{ - public QueueWorkerWorkSerializer() - { - activate(); - } - - public void dispose() - { - deactivate(); - } - - @Override - protected void work(WorkContext context, Runnable element) - { - element.run(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/ResultSynchronizer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/ResultSynchronizer.java deleted file mode 100644 index 48e9010856..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/ResultSynchronizer.java +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.util.concurrent.ISynchronizer; -import org.eclipse.net4j.util.om.monitor.MonitorUtil; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public final class ResultSynchronizer<RESULT> implements ISynchronizer<RESULT> -{ - private RESULT result; - - private Object consumerLock = new Object(); - - private CountDownLatch producerLatch = new CountDownLatch(1); - - public ResultSynchronizer() - { - } - - public RESULT get(long timeout) - { - try - { - final long stop = System.currentTimeMillis() + timeout; - synchronized (consumerLock) - { - while (result == null) - { - try - { - final long remaining = stop - System.currentTimeMillis(); - if (remaining <= 0) - { - return null; - } - - if (MonitorUtil.isCanceled()) - { - return null; - } - - consumerLock.wait(Math.min(remaining, 100L)); - } - catch (InterruptedException ex) - { - return null; - } - } - - return result; - } - } - finally - { - producerLatch.countDown(); - } - } - - public void put(RESULT result) - { - synchronized (consumerLock) - { - this.result = result; - consumerLock.notifyAll(); - } - } - - public boolean put(RESULT result, long timeout) - { - synchronized (consumerLock) - { - this.result = result; - consumerLock.notifyAll(); - } - - try - { - if (!producerLatch.await(timeout, TimeUnit.MILLISECONDS)) - { - return false; - } - } - catch (InterruptedException ex) - { - return false; - } - - return true; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/RoundRobinList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/RoundRobinList.java deleted file mode 100644 index cdf7235904..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/RoundRobinList.java +++ /dev/null @@ -1,512 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * @author Eike Stepper - */ -public final class RoundRobinList<E> extends LinkedList<E> -{ - private static final long serialVersionUID = 1L; - - private ReadWriteLock lock = new ReentrantReadWriteLock(); - - private Iterator<E> it; - - public RoundRobinList() - { - } - - public RoundRobinList(Collection<? extends E> c) - { - super(c); - } - - public void executeReads(Runnable runnable) - { - try - { - lock.readLock().lock(); - runnable.run(); - } - finally - { - lock.readLock().unlock(); - } - } - - public void executeWrites(Runnable runnable) - { - try - { - lock.writeLock().lock(); - runnable.run(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public void add(int index, E element) - { - try - { - lock.writeLock().lock(); - super.add(index, element); - it = null; - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean add(E o) - { - try - { - lock.writeLock().lock(); - it = null; - return super.add(o); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean addAll(Collection<? extends E> c) - { - try - { - lock.writeLock().lock(); - it = null; - return super.addAll(c); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean addAll(int index, Collection<? extends E> c) - { - try - { - lock.writeLock().lock(); - it = null; - return super.addAll(index, c); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public void addFirst(E o) - { - try - { - lock.writeLock().lock(); - it = null; - super.addFirst(o); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public void addLast(E o) - { - try - { - lock.writeLock().lock(); - it = null; - super.addLast(o); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public void clear() - { - try - { - lock.writeLock().lock(); - it = null; - super.clear(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public Object clone() - { - try - { - lock.readLock().lock(); - return super.clone(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public boolean contains(Object o) - { - try - { - lock.readLock().lock(); - return super.contains(o); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public boolean containsAll(Collection<?> c) - { - try - { - lock.readLock().lock(); - return super.containsAll(c); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public E element() - { - try - { - lock.readLock().lock(); - if (isEmpty()) - { - return null; - } - - if (it == null || !it.hasNext()) - { - it = iterator(); - } - - return it.next(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public E get(int index) - { - try - { - lock.readLock().lock(); - return super.get(index); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public E getFirst() - { - try - { - lock.readLock().lock(); - return super.getFirst(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public E getLast() - { - try - { - lock.readLock().lock(); - return super.getLast(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public int indexOf(Object o) - { - try - { - lock.readLock().lock(); - return super.indexOf(o); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public int lastIndexOf(Object o) - { - try - { - lock.readLock().lock(); - return super.lastIndexOf(o); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public boolean offer(E o) - { - try - { - lock.writeLock().lock(); - it = null; - return super.offer(o); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E peek() - { - try - { - lock.readLock().lock(); - return super.peek(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public E poll() - { - try - { - lock.writeLock().lock(); - it = null; - return super.poll(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E remove() - { - try - { - lock.writeLock().lock(); - it = null; - return super.remove(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E remove(int index) - { - try - { - lock.writeLock().lock(); - it = null; - return super.remove(index); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean remove(Object o) - { - try - { - lock.writeLock().lock(); - it = null; - return super.remove(o); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean removeAll(Collection<?> c) - { - try - { - lock.writeLock().lock(); - it = null; - return super.removeAll(c); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E removeFirst() - { - try - { - lock.writeLock().lock(); - it = null; - return super.removeFirst(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E removeLast() - { - try - { - lock.writeLock().lock(); - it = null; - return super.removeLast(); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public boolean retainAll(Collection<?> c) - { - try - { - lock.writeLock().lock(); - it = null; - return super.retainAll(c); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public E set(int index, E element) - { - try - { - lock.writeLock().lock(); - it = null; - return super.set(index, element); - } - finally - { - lock.writeLock().unlock(); - } - } - - @Override - public List<E> subList(int fromIndex, int toIndex) - { - try - { - lock.readLock().lock(); - return super.subList(fromIndex, toIndex); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public Object[] toArray() - { - try - { - lock.readLock().lock(); - return super.toArray(); - } - finally - { - lock.readLock().unlock(); - } - } - - @Override - public <T> T[] toArray(T[] a) - { - try - { - lock.readLock().lock(); - return super.toArray(a); - } - finally - { - lock.readLock().unlock(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronizingCorrelator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronizingCorrelator.java deleted file mode 100644 index 31d26540d9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronizingCorrelator.java +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.util.concurrent.ICorrelator; -import org.eclipse.net4j.util.concurrent.ISynchronizer; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class SynchronizingCorrelator<CORRELATION, RESULT> implements ICorrelator<CORRELATION, ISynchronizer<RESULT>> -{ - private ConcurrentMap<CORRELATION, ISynchronizer<RESULT>> map = new ConcurrentHashMap<CORRELATION, ISynchronizer<RESULT>>( - 0); - - public boolean isCorrelated(CORRELATION correlation) - { - return map.containsKey(correlation); - } - - public ISynchronizer<RESULT> correlate(CORRELATION correlation) - { - ISynchronizer<RESULT> synchronizer = map.get(correlation); - if (synchronizer == null) - { - synchronizer = createSynchronizer(correlation); - map.put(correlation, synchronizer); - } - - return synchronizer; - } - - public ISynchronizer<RESULT> correlateUnique(CORRELATION correlation) - { - ISynchronizer<RESULT> synchronizer = createSynchronizer(correlation); - if (map.putIfAbsent(correlation, synchronizer) != null) - { - throw new IllegalStateException("Already correlated: " + correlation); //$NON-NLS-1$ - } - - return synchronizer; - } - - public ISynchronizer<RESULT> uncorrelate(CORRELATION correlation) - { - return map.remove(correlation); - } - - public RESULT get(CORRELATION correlation, long timeout) - { - return correlate(correlation).get(timeout); - } - - public void put(CORRELATION correlation, RESULT result) - { - correlate(correlation).put(result); - } - - public boolean put(CORRELATION correlation, RESULT result, long timeout) - { - return correlate(correlation).put(result, timeout); - } - - protected ISynchronizer<RESULT> createSynchronizer(final CORRELATION correlation) - { - // TODO Make top level class - return new ISynchronizer<RESULT>() - { - private ISynchronizer<RESULT> delegate = new ResultSynchronizer<RESULT>(); - - public RESULT get(long timeout) - { - RESULT result = delegate.get(timeout); - uncorrelate(correlation); - return result; - } - - public void put(RESULT result) - { - delegate.put(result); - } - - public boolean put(RESULT result, long timeout) - { - return delegate.put(result, timeout); - } - }; - } - - @Override - public String toString() - { - return "SynchronizingCorrelator" + map; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java deleted file mode 100644 index dbebe7bf8f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/concurrent/SynchronousWorkSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.concurrent; - -import org.eclipse.net4j.util.concurrent.IWorkSerializer; - -/** - * @author Eike Stepper - */ -public class SynchronousWorkSerializer implements IWorkSerializer -{ - public SynchronousWorkSerializer() - { - } - - public boolean addWork(Runnable work) - { - work.run(); - return true; - } - - public void dispose() - { - } - - @Override - public String toString() - { - return SynchronousWorkSerializer.class.getSimpleName(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java deleted file mode 100644 index f94f5dfc0e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/Container.java +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public abstract class Container<E> extends Lifecycle implements IContainer<E> -{ - public Container() - { - } - - public boolean isEmpty() - { - E[] elements = getElements(); - return elements == null || elements.length == 0; - } - - public void fireElementAddedEvent(E element) - { - fireContainerEvent(element, IContainerDelta.Kind.ADDED); - } - - public void fireElementRemovedEvent(E element) - { - fireContainerEvent(element, IContainerDelta.Kind.REMOVED); - } - - public void fireContainerEvent(E element, Kind kind) - { - fireEvent(newContainerEvent(element, kind)); - } - - public void fireContainerEvent(List<IContainerDelta<E>> deltas) - { - fireEvent(new ContainerEvent<E>(this, deltas)); - } - - protected SingleDeltaContainerEvent<E> newContainerEvent(E element, Kind kind) - { - return new SingleDeltaContainerEvent<E>(this, element, kind); - } - - protected ContainerEvent<E> newContainerEvent() - { - return new ContainerEvent<E>(this); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerDelta.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerDelta.java deleted file mode 100644 index 4889bb8164..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerDelta.java +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.util.container.IContainerDelta; - -/** - * @author Eike Stepper - */ -public class ContainerDelta<E> implements IContainerDelta<E> -{ - private E element; - - private Kind kind; - - public ContainerDelta(E element, Kind kind) - { - this.element = element; - this.kind = kind; - } - - public E getElement() - { - return element; - } - - public E setValue(E value) - { - throw new UnsupportedOperationException(); - } - - public Kind getKind() - { - return kind; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java deleted file mode 100644 index af80c3f59e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEvent.java +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.event.Event; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IContainerEventVisitor; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; -import org.eclipse.net4j.util.container.IContainerEventVisitor.Filtered; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class ContainerEvent<E> extends Event implements IContainerEvent<E> -{ - private static final long serialVersionUID = 1L; - - private List<IContainerDelta<E>> deltas; - - public ContainerEvent(IContainer<E> container) - { - super(container); - deltas = new ArrayList<IContainerDelta<E>>(); - } - - public ContainerEvent(IContainer<E> container, List<IContainerDelta<E>> deltas) - { - super(container); - this.deltas = deltas; - } - - @SuppressWarnings("unchecked") - public IContainer<E> getContainer() - { - return (IContainer<E>)getSource(); - } - - public boolean isEmpty() - { - return deltas.isEmpty(); - } - - @SuppressWarnings("unchecked") - public IContainerDelta<E>[] getDeltas() - { - return deltas.toArray(new IContainerDelta[deltas.size()]); - } - - public IContainerDelta<E> getDelta() throws IllegalStateException - { - if (deltas.size() != 1) - { - throw new IllegalStateException("deltas.size() != 1"); - } - - return deltas.get(0); - } - - public E getDeltaElement() throws IllegalStateException - { - return getDelta().getElement(); - } - - public Kind getDeltaKind() throws IllegalStateException - { - return getDelta().getKind(); - } - - public void addDelta(E element, Kind kind) - { - addDelta(new ContainerDelta<E>(element, kind)); - } - - public void addDelta(IContainerDelta<E> delta) - { - deltas.add(delta); - } - - public void accept(IContainerEventVisitor<E> visitor) - { - for (IContainerDelta<E> delta : deltas) - { - E element = delta.getElement(); - - boolean filtered = true; - if (visitor instanceof Filtered) - { - filtered = ((Filtered<E>)visitor).filter(element); - } - - if (filtered) - { - switch (delta.getKind()) - { - case ADDED: - visitor.added(element); - break; - case REMOVED: - visitor.removed(element); - break; - } - } - } - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - for (IContainerDelta<E> delta : getDeltas()) - { - builder.append(", "); - builder.append(delta.getKind()); - builder.append("="); - builder.append(delta.getElement()); - } - - return MessageFormat.format("ContainerEvent[source={0}{1}]", getSource(), builder.toString()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEventAdapter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEventAdapter.java deleted file mode 100644 index cb2b42e3c8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ContainerEventAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IContainerEventVisitor; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; - -/** - * @author Eike Stepper - */ -public class ContainerEventAdapter<E> implements IListener -{ - public ContainerEventAdapter() - { - } - - @SuppressWarnings("unchecked") - public final void notifyEvent(IEvent event) - { - if (event instanceof IContainerEvent) - { - IContainerEvent<E> e = (IContainerEvent<E>)event; - notifyContainerEvent(e); - } - else - { - notifyOtherEvent(event); - } - } - - protected void notifyContainerEvent(IContainerEvent<E> event) - { - final IContainer<E> container = event.getContainer(); - event.accept(new IContainerEventVisitor<E>() - { - public void added(E element) - { - onAdded(container, element); - } - - public void removed(E element) - { - onRemoved(container, element); - } - }); - } - - protected void notifyOtherEvent(IEvent event) - { - } - - protected void onAdded(IContainer<E> container, E element) - { - } - - protected void onRemoved(IContainer<E> container, E element) - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/LifecycleEventConverter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/LifecycleEventConverter.java deleted file mode 100644 index 0ae34b5c92..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/LifecycleEventConverter.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.event.Notifier; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.event.INotifier; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; - -/** - * Is registered with each {@link IChannel} of this {@link IConnector}. - * <p> - * - * @author Eike Stepper - */ -public class LifecycleEventConverter<E> implements IListener -{ - private Notifier owner; - - public LifecycleEventConverter(Notifier owner) - { - this.owner = owner; - } - - public INotifier getOwner() - { - return owner; - } - - public void notifyEvent(IEvent event) - { - if (event instanceof ILifecycleEvent) - { - ILifecycleEvent e = (ILifecycleEvent)event; - switch (e.getKind()) - { - case ACTIVATED: - added(e); - break; - - case DEACTIVATED: - removed(e); - break; - } - } - } - - protected void added(ILifecycleEvent e) - { - fireContainerEvent(e, IContainerDelta.Kind.ADDED); - } - - protected void removed(ILifecycleEvent e) - { - fireContainerEvent(e, IContainerDelta.Kind.REMOVED); - } - - @SuppressWarnings("unchecked") - protected void fireContainerEvent(ILifecycleEvent e, IContainerDelta.Kind kind) - { - E element = (E)e.getLifecycle(); - if (element != null) - { - IContainerEvent<E> event = createContainerEvent((IContainer<E>)owner, element, kind); - owner.fireEvent(event); - } - } - - protected IContainerEvent<E> createContainerEvent(IContainer<E> container, E element, Kind kind) - { - ContainerEvent<E> event = new ContainerEvent<E>(container); - event.addDelta(new ContainerDelta<E>(element, kind)); - return event; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java deleted file mode 100644 index a83ab176a5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java +++ /dev/null @@ -1,559 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.factory.FactoryKey; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter; -import org.eclipse.net4j.internal.util.registry.HashMapRegistry; -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.container.FactoryNotFoundException; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.event.EventUtil; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; -import org.eclipse.net4j.util.registry.IRegistry; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Map.Entry; - -/** - * @author Eike Stepper - */ -public class ManagedContainer extends Lifecycle implements IManagedContainer -{ - private IRegistry<IFactoryKey, IFactory> factoryRegistry; - - private List<IElementProcessor> postProcessors; - - private IRegistry<ElementKey, Object> elementRegistry = new HashMapRegistry<ElementKey, Object>(); - - private long maxElementID; - - private IListener elementListener = new LifecycleEventAdapter() - { - @Override - protected void onDeactivated(ILifecycle lifecycle) - { - for (Entry<ElementKey, Object> entry : elementRegistry.entrySet()) - { - if (lifecycle == entry.getValue()) - { - removeElement(entry.getKey()); - return; - } - } - } - }; - - public ManagedContainer() - { - } - - public synchronized IRegistry<IFactoryKey, IFactory> getFactoryRegistry() - { - if (factoryRegistry == null) - { - factoryRegistry = createFactoryRegistry(); - } - - return factoryRegistry; - } - - public ManagedContainer registerFactory(IFactory factory) - { - getFactoryRegistry().put(factory.getKey(), factory); - return this; - } - - public synchronized List<IElementProcessor> getPostProcessors() - { - if (postProcessors == null) - { - postProcessors = createPostProcessors(); - } - - return postProcessors; - } - - public synchronized void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements) - { - if (processExistingElements) - { - ContainerEvent<Object> event = new ContainerEvent<Object>(this); - for (Entry<ElementKey, Object> entry : elementRegistry.entrySet()) - { - ElementKey key = entry.getKey(); - Object element = entry.getValue(); - - String productGroup = key.getProductGroup(); - String factoryType = key.getFactoryType(); - String description = key.getDescription(); - Object newElement = postProcessor.process(this, productGroup, factoryType, description, element); - if (newElement != element) - { - elementRegistry.put(key, newElement); - event.addDelta(element, IContainerDelta.Kind.REMOVED); - event.addDelta(newElement, IContainerDelta.Kind.ADDED); - } - } - - fireEvent(event); - } - - getPostProcessors().add(postProcessor); - } - - public void addPostProcessor(IElementProcessor postProcessor) - { - getPostProcessors().add(postProcessor); - } - - public void removePostProcessor(IElementProcessor postProcessor) - { - getPostProcessors().remove(postProcessor); - } - - public Set<String> getProductGroups() - { - Set<String> result = new HashSet<String>(); - for (IFactoryKey key : factoryRegistry.keySet()) - { - result.add(key.getProductGroup()); - } - - for (ElementKey key : elementRegistry.keySet()) - { - result.add(key.getProductGroup()); - } - - return result; - } - - public Set<String> getFactoryTypes(String productGroup) - { - Set<String> result = new HashSet<String>(); - for (IFactoryKey key : factoryRegistry.keySet()) - { - if (ObjectUtil.equals(key.getProductGroup(), productGroup)) - { - result.add(key.getType()); - } - } - - for (ElementKey key : elementRegistry.keySet()) - { - if (ObjectUtil.equals(key.getProductGroup(), productGroup)) - { - result.add(key.getFactoryType()); - } - } - - return result; - } - - public IFactory getFactory(String productGroup, String factoryType) - { - FactoryKey key = new FactoryKey(productGroup, factoryType); - IFactory factory = getFactoryRegistry().get(key); - if (factory == null) - { - throw new FactoryNotFoundException("Factory not found: " + key); - } - - return factory; - } - - public boolean isEmpty() - { - return elementRegistry.isEmpty(); - } - - public String[] getElementKey(Object element) - { - for (Entry<ElementKey, Object> entry : elementRegistry.entrySet()) - { - if (entry.getValue() == element) - { - ElementKey key = entry.getKey(); - String[] result = { key.getProductGroup(), key.getFactoryType(), key.getDescription() }; - return result; - } - } - - return null; - } - - public Object[] getElements() - { - return elementRegistry.values().toArray(); - } - - public Object[] getElements(String productGroup) - { - List<Object> result = new ArrayList<Object>(); - for (Entry<ElementKey, Object> entry : elementRegistry.entrySet()) - { - ElementKey key = entry.getKey(); - if (ObjectUtil.equals(key.getProductGroup(), productGroup)) - { - result.add(entry.getValue()); - } - } - - return result.toArray(); - } - - public Object[] getElements(String productGroup, String factoryType) - { - List<Object> result = new ArrayList<Object>(); - for (Entry<ElementKey, Object> entry : elementRegistry.entrySet()) - { - ElementKey key = entry.getKey(); - if (ObjectUtil.equals(key.getProductGroup(), productGroup) - && ObjectUtil.equals(key.getFactoryType(), factoryType)) - { - result.add(entry.getValue()); - } - } - - return result.toArray(); - } - - public Object getElement(String productGroup, String factoryType, String description) - { - ElementKey key = new ElementKey(productGroup, factoryType, description); - Object element = elementRegistry.get(key); - if (element == null) - { - element = createElement(productGroup, factoryType, description); - element = postProcessElement(productGroup, factoryType, description, element); - LifecycleUtil.activate(element); - putElement(key, element); - } - - return element; - } - - public Object putElement(String productGroup, String factoryType, String description, Object element) - { - ElementKey key = new ElementKey(productGroup, factoryType, description); - return putElement(key, element); - } - - protected Object putElement(ElementKey key, Object element) - { - ContainerEvent<Object> event = new ContainerEvent<Object>(this); - key.setID(++maxElementID); - Object oldElement = elementRegistry.put(key, element); - if (oldElement != null) - { - EventUtil.removeListener(oldElement, elementListener); - event.addDelta(oldElement, IContainerDelta.Kind.REMOVED); - } - - event.addDelta(element, IContainerDelta.Kind.ADDED); - fireEvent(event); - EventUtil.addListener(element, elementListener); - return oldElement; - } - - public Object removeElement(String productGroup, String factoryType, String description) - { - ElementKey key = new ElementKey(productGroup, factoryType, description); - return removeElement(key); - } - - protected Object removeElement(ElementKey key) - { - Object element = elementRegistry.remove(key); - if (element != null) - { - EventUtil.removeListener(element, elementListener); - fireEvent(new SingleDeltaContainerEvent<Object>(this, element, IContainerDelta.Kind.REMOVED)); - } - - return element; - } - - public void clearElements() - { - if (!elementRegistry.isEmpty()) - { - ContainerEvent<Object> event = new ContainerEvent<Object>(this); - for (Object element : elementRegistry.values()) - { - EventUtil.removeListener(element, elementListener); - event.addDelta(element, IContainerDelta.Kind.REMOVED); - } - - elementRegistry.clear(); - fireEvent(event); - } - } - - public void loadElements(InputStream stream) throws IOException - { - clearElements(); - ObjectInputStream ois = new ObjectInputStream(stream); - int size = ois.readInt(); - for (int i = 0; i < size; i++) - { - try - { - ElementKey key = (ElementKey)ois.readObject(); - Object element = getElement(key.getProductGroup(), key.getFactoryType(), key.getDescription()); - - boolean active = ois.readBoolean(); - if (active) - { - // TODO Reconsider activation - LifecycleUtil.activate(element); - } - } - catch (ClassNotFoundException cannotHappen) - { - } - } - - initMaxElementID(); - } - - public void saveElements(OutputStream stream) throws IOException - { - ObjectOutputStream oos = new ObjectOutputStream(stream); - List<Entry<ElementKey, Object>> entries = new ArrayList<Entry<ElementKey, Object>>(elementRegistry.entrySet()); - Collections.sort(entries, new EntryComparator()); - - oos.writeInt(entries.size()); - for (Entry<ElementKey, Object> entry : entries) - { - oos.writeObject(entry.getKey()); - oos.writeBoolean(LifecycleUtil.isActive(entry.getValue())); - } - } - - @SuppressWarnings("unchecked") - @Override - public void fireEvent(IEvent event) - { - if (event instanceof IContainerEvent) - { - IContainerEvent<Object> containerEvent = (IContainerEvent<Object>)event; - if (containerEvent.isEmpty()) - { - return; - } - } - - super.fireEvent(event); - } - - @Override - public String toString() - { - return "ManagedContainer"; - } - - protected IRegistry<IFactoryKey, IFactory> createFactoryRegistry() - { - return new HashMapRegistry<IFactoryKey, IFactory>(); - } - - protected List<IElementProcessor> createPostProcessors() - { - return new ArrayList<IElementProcessor>(); - } - - protected Object createElement(String productGroup, String factoryType, String description) - { - IFactory factory = getFactory(productGroup, factoryType); - return factory.create(description); - } - - protected Object postProcessElement(String productGroup, String factoryType, String description, Object element) - { - for (IElementProcessor processor : getPostProcessors()) - { - element = processor.process(this, productGroup, factoryType, description, element); - } - - return element; - } - - protected void initMaxElementID() - { - maxElementID = 0L; - for (ElementKey key : elementRegistry.keySet()) - { - long id = key.getID(); - if (maxElementID < id) - { - maxElementID = id; - } - } - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - LifecycleUtil.activate(getFactoryRegistry()); - LifecycleUtil.activate(getPostProcessors()); - } - - @Override - protected void doDeactivate() throws Exception - { - Collection<Object> values = elementRegistry.values(); - for (Object element : values.toArray()) - { - try - { - LifecycleUtil.deactivateNoisy(element); - EventUtil.removeListener(element, elementListener); - } - catch (RuntimeException ex) - { - OM.LOG.warn(ex); - } - } - - LifecycleUtil.deactivate(factoryRegistry); - LifecycleUtil.deactivate(postProcessors); - super.doDeactivate(); - } - - /** - * @author Eike Stepper - */ - private static final class ElementKey implements Serializable, Comparable<ElementKey> - { - private static final long serialVersionUID = 1L; - - private long id; - - private String productGroup; - - private String factoryType; - - private String description; - - public ElementKey(String productGroup, String factoryType, String description) - { - this.productGroup = productGroup; - this.factoryType = factoryType; - this.description = description; - } - - public long getID() - { - return id; - } - - public void setID(long id) - { - this.id = id; - } - - public String getProductGroup() - { - return productGroup; - } - - public String getFactoryType() - { - return factoryType; - } - - public String getDescription() - { - return description; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof ElementKey) - { - ElementKey key = (ElementKey)obj; - return ObjectUtil.equals(productGroup, key.productGroup) && ObjectUtil.equals(factoryType, key.factoryType) - && ObjectUtil.equals(description, key.description); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(productGroup) ^ ObjectUtil.hashCode(factoryType) ^ ObjectUtil.hashCode(description); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}[{1}, {2}]", productGroup, factoryType, description); - } - - public int compareTo(ElementKey key) - { - if (id < key.id) - { - return -1; - } - - if (id > key.id) - { - return 1; - } - - return 0; - } - } - - /** - * @author Eike Stepper - */ - private static final class EntryComparator implements Comparator<Entry<ElementKey, Object>> - { - public int compare(Entry<ElementKey, Object> entry1, Entry<ElementKey, Object> entry2) - { - return entry1.getKey().compareTo(entry2.getKey()); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java deleted file mode 100644 index 0fa7cb7756..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.factory.PluginFactoryRegistry; -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; -import org.eclipse.net4j.util.registry.IRegistry; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public class PluginContainer extends ManagedContainer implements IPluginContainer -{ - private static PluginContainer instance; - - private PluginContainer() - { - } - - @Override - protected IRegistry<IFactoryKey, IFactory> createFactoryRegistry() - { - return new PluginFactoryRegistry(); - } - - @Override - protected List<IElementProcessor> createPostProcessors() - { - return new PluginElementProcessorList(); - } - - public static void dispose() - { - if (instance != null) - { - instance.deactivate(); - instance = null; - } - } - - public static synchronized PluginContainer getInstance() - { - if (instance == null) - { - instance = new PluginContainer(); - - try - { - instance.activate(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - instance = null; - } - } - - return instance; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginElementProcessorList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginElementProcessorList.java deleted file mode 100644 index 0ec19a7e94..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginElementProcessorList.java +++ /dev/null @@ -1,216 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.util.container.IElementProcessor; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionDelta; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IRegistryChangeEvent; -import org.eclipse.core.runtime.IRegistryChangeListener; -import org.eclipse.core.runtime.Platform; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -/** - * @author Eike Stepper - */ -public class PluginElementProcessorList extends Lifecycle implements List<IElementProcessor> -{ - private static final String ATTR_CLASS = "class"; - - public static final String NAMESPACE = OM.BUNDLE_ID; - - public static final String EXT_POINT = "elementProcessors"; - - private List<IElementProcessor> processors = new ArrayList<IElementProcessor>(); - - private IRegistryChangeListener extensionRegistryListener = new IRegistryChangeListener() - { - public void registryChanged(IRegistryChangeEvent event) - { - IExtensionDelta[] deltas = event.getExtensionDeltas(NAMESPACE, EXT_POINT); - for (IExtensionDelta delta : deltas) - { - // TODO Handle ExtensionDelta - OM.LOG.warn("ExtensionDelta not handled: " + delta); - } - } - }; - - public PluginElementProcessorList() - { - } - - public boolean add(IElementProcessor o) - { - return processors.add(o); - } - - public void add(int index, IElementProcessor element) - { - processors.add(index, element); - } - - public boolean addAll(Collection<? extends IElementProcessor> c) - { - return processors.addAll(c); - } - - public boolean addAll(int index, Collection<? extends IElementProcessor> c) - { - return processors.addAll(index, c); - } - - public void clear() - { - processors.clear(); - } - - public boolean contains(Object o) - { - return processors.contains(o); - } - - public boolean containsAll(Collection<?> c) - { - return processors.containsAll(c); - } - - @Override - public boolean equals(Object o) - { - return processors.equals(o); - } - - public IElementProcessor get(int index) - { - return processors.get(index); - } - - @Override - public int hashCode() - { - return processors.hashCode(); - } - - public int indexOf(Object o) - { - return processors.indexOf(o); - } - - public boolean isEmpty() - { - return processors.isEmpty(); - } - - public Iterator<IElementProcessor> iterator() - { - return processors.iterator(); - } - - public int lastIndexOf(Object o) - { - return processors.lastIndexOf(o); - } - - public ListIterator<IElementProcessor> listIterator() - { - return processors.listIterator(); - } - - public ListIterator<IElementProcessor> listIterator(int index) - { - return processors.listIterator(index); - } - - public IElementProcessor remove(int index) - { - return processors.remove(index); - } - - public boolean remove(Object o) - { - return processors.remove(o); - } - - public boolean removeAll(Collection<?> c) - { - return processors.removeAll(c); - } - - public boolean retainAll(Collection<?> c) - { - return processors.retainAll(c); - } - - public IElementProcessor set(int index, IElementProcessor element) - { - return processors.set(index, element); - } - - public int size() - { - return processors.size(); - } - - public List<IElementProcessor> subList(int fromIndex, int toIndex) - { - return processors.subList(fromIndex, toIndex); - } - - public Object[] toArray() - { - return processors.toArray(); - } - - public <T> T[] toArray(T[] a) - { - return processors.toArray(a); - } - - @Override - public String toString() - { - return processors.toString(); - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = extensionRegistry.getConfigurationElementsFor(NAMESPACE, EXT_POINT); - for (IConfigurationElement element : elements) - { - IElementProcessor processor = (IElementProcessor)element.createExecutableExtension(ATTR_CLASS); - processors.add(processor); - } - - extensionRegistry.addRegistryChangeListener(extensionRegistryListener, NAMESPACE); - } - - @Override - protected void doDeactivate() throws Exception - { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - extensionRegistry.removeRegistryChangeListener(extensionRegistryListener); - processors.clear(); - super.doDeactivate(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java deleted file mode 100644 index 0d8127afe7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/SingleDeltaContainerEvent.java +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container; - -import org.eclipse.net4j.internal.util.event.Event; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IContainerEventVisitor; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; -import org.eclipse.net4j.util.container.IContainerEventVisitor.Filtered; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class SingleDeltaContainerEvent<E> extends Event implements IContainerEvent<E> -{ - private static final long serialVersionUID = 1L; - - private IContainerDelta<E>[] deltas; - - @SuppressWarnings("unchecked") - public SingleDeltaContainerEvent(IContainer<E> container, E element, Kind kind) - { - super(container); - deltas = new IContainerDelta[] { new ContainerDelta<E>(element, kind) }; - } - - @SuppressWarnings("unchecked") - public IContainer<E> getContainer() - { - return (IContainer<E>)getSource(); - } - - public boolean isEmpty() - { - return false; - } - - public IContainerDelta<E>[] getDeltas() - { - return deltas; - } - - public IContainerDelta<E> getDelta() throws IllegalStateException - { - return deltas[0]; - } - - public E getDeltaElement() throws IllegalStateException - { - return deltas[0].getElement(); - } - - public Kind getDeltaKind() throws IllegalStateException - { - return deltas[0].getKind(); - } - - public void accept(IContainerEventVisitor<E> visitor) - { - E element = deltas[0].getElement(); - - boolean filtered = true; - if (visitor instanceof Filtered) - { - filtered = ((Filtered<E>)visitor).filter(element); - } - - if (filtered) - { - switch (deltas[0].getKind()) - { - case ADDED: - visitor.added(element); - break; - case REMOVED: - visitor.removed(element); - break; - } - } - } - - @Override - public String toString() - { - return MessageFormat.format("ContainerEvent[source={0}, {1}={2}]", getSource(), getDeltaElement(), getDeltaKind()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/AbstractDelegator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/AbstractDelegator.java deleted file mode 100644 index 7be676af7c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/AbstractDelegator.java +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.internal.util.container.SingleDeltaContainerEvent; -import org.eclipse.net4j.internal.util.event.Notifier; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; - -import java.util.Collection; -import java.util.Iterator; - -/** - * @author Eike Stepper - */ -public abstract class AbstractDelegator<E> extends Notifier implements IContainer<E> -{ - public AbstractDelegator() - { - } - - protected void fireAddedEvent(E o) - { - fireEvent(new SingleDeltaContainerEvent<E>(this, o, IContainerDelta.Kind.ADDED)); - } - - @SuppressWarnings("unchecked") - protected void fireRemovedEvent(Object o) - { - fireEvent(new SingleDeltaContainerEvent<E>(this, (E)o, IContainerDelta.Kind.REMOVED)); - } - - @SuppressWarnings("unchecked") - protected ContainerEvent<E> createEvent(Collection<? super E> c, Kind kind) - { - ContainerEvent<E> event = new ContainerEvent<E>(this); - for (Object o : c) - { - event.addDelta((E)o, kind); - } - - return event; - } - - protected boolean dispatchEvent(ContainerEvent<E> event) - { - if (event.isEmpty()) - { - return false; - } - - fireEvent(event); - return true; - } - - /** - * @author Eike Stepper - */ - public class DelegatingIterator implements Iterator<E> - { - private Iterator<E> delegate; - - protected E last; - - public DelegatingIterator(Iterator<E> delegate) - { - this.delegate = delegate; - } - - public Iterator<E> getDelegate() - { - return delegate; - } - - /** - * @category READ - */ - public boolean hasNext() - { - return getDelegate().hasNext(); - } - - /** - * @category READ - */ - public E next() - { - return last = getDelegate().next(); - } - - /** - * @category WRITE - */ - public void remove() - { - getDelegate().remove(); - fireRemovedEvent(last); - last = null; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerBlockingQueue.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerBlockingQueue.java deleted file mode 100644 index f2571d25b3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerBlockingQueue.java +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.delegate.IContainerBlockingQueue; - -import java.util.Collection; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public class ContainerBlockingQueue<E> extends ContainerQueue<E> implements IContainerBlockingQueue<E> -{ - public ContainerBlockingQueue(BlockingQueue<E> delegate) - { - super(delegate); - } - - @Override - public BlockingQueue<E> getDelegate() - { - return (BlockingQueue<E>)super.getDelegate(); - } - - /** - * @category WRITE - */ - public int drainTo(Collection<? super E> c) - { - int drainTo = getDelegate().drainTo(c); - ContainerEvent<E> event = createEvent(c, IContainerDelta.Kind.REMOVED); - fireEvent(event); - return drainTo; - } - - /** - * @category WRITE - */ - public int drainTo(Collection<? super E> c, int maxElements) - { - int drainTo = getDelegate().drainTo(c, maxElements); - ContainerEvent<E> event = createEvent(c, IContainerDelta.Kind.REMOVED); - fireEvent(event); - return drainTo; - } - - /** - * @category WRITE - */ - public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException - { - boolean modified = getDelegate().offer(o, timeout, unit); - if (modified) - { - fireAddedEvent(o); - } - - return modified; - } - - /** - * @category WRITE - */ - public E poll(long timeout, TimeUnit unit) throws InterruptedException - { - E removed = getDelegate().poll(timeout, unit); - if (removed != null) - { - fireRemovedEvent(removed); - } - - return removed; - } - - /** - * @category WRITE - */ - public void put(E o) throws InterruptedException - { - getDelegate().put(o); - fireAddedEvent(o); - } - - /** - * @category READ - */ - public int remainingCapacity() - { - return getDelegate().remainingCapacity(); - } - - /** - * @category WRITE - */ - public E take() throws InterruptedException - { - E element = getDelegate().take(); - fireRemovedEvent(element); - return element; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerCollection.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerCollection.java deleted file mode 100644 index 20559fbf4c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerCollection.java +++ /dev/null @@ -1,213 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.delegate.IContainerCollection; - -import java.util.Collection; -import java.util.Iterator; - -/** - * @author Eike Stepper - */ -public class ContainerCollection<E> extends AbstractDelegator<E> implements IContainerCollection<E> -{ - private Collection<E> delegate; - - public ContainerCollection(Collection<E> delegate) - { - this.delegate = delegate; - } - - public Collection<E> getDelegate() - { - return delegate; - } - - @SuppressWarnings("unchecked") - public E[] getElements() - { - return (E[])toArray(); - } - - /** - * @category WRITE - */ - public boolean add(E o) - { - boolean modified = getDelegate().add(o); - if (modified) - { - fireAddedEvent(o); - } - - return modified; - } - - /** - * @category WRITE - */ - public boolean addAll(Collection<? extends E> c) - { - ContainerEvent<E> event = new ContainerEvent<E>(this); - for (E e : c) - { - boolean modified = getDelegate().add(e); - if (modified) - { - event.addDelta(e, IContainerDelta.Kind.ADDED); - } - } - - return dispatchEvent(event); - } - - /** - * @category WRITE - */ - public void clear() - { - if (!isEmpty()) - { - ContainerEvent<E> event = createEvent(getDelegate(), IContainerDelta.Kind.REMOVED); - getDelegate().clear(); - fireEvent(event); - } - } - - /** - * @category WRITE - */ - public boolean remove(Object o) - { - boolean modified = getDelegate().remove(o); - if (modified) - { - fireRemovedEvent(o); - } - - return modified; - } - - /** - * @category WRITE - */ - @SuppressWarnings("unchecked") - public boolean removeAll(Collection<?> c) - { - ContainerEvent<E> event = new ContainerEvent<E>(this); - for (Object o : c) - { - boolean modified = getDelegate().remove(o); - if (modified) - { - event.addDelta((E)o, IContainerDelta.Kind.REMOVED); - } - } - - return dispatchEvent(event); - } - - /** - * @category WRITE - */ - @SuppressWarnings("unchecked") - public boolean retainAll(Collection<?> c) - { - ContainerEvent<E> event = new ContainerEvent<E>(this); - for (Object o : getDelegate()) - { - if (!c.contains(o)) - { - getDelegate().remove(o); - event.addDelta((E)o, IContainerDelta.Kind.REMOVED); - } - } - - return dispatchEvent(event); - } - - /** - * @category READ - */ - public boolean contains(Object o) - { - return getDelegate().contains(o); - } - - /** - * @category READ - */ - public boolean containsAll(Collection<?> c) - { - return getDelegate().containsAll(c); - } - - /** - * @category READ - */ - @Override - public boolean equals(Object o) - { - return getDelegate().equals(o); - } - - /** - * @category READ - */ - @Override - public int hashCode() - { - return getDelegate().hashCode(); - } - - /** - * @category READ - */ - public boolean isEmpty() - { - return getDelegate().isEmpty(); - } - - /** - * @category READ - */ - public Iterator<E> iterator() - { - return new DelegatingIterator(getDelegate().iterator()); - } - - /** - * @category READ - */ - public int size() - { - return getDelegate().size(); - } - - /** - * @category READ - */ - public Object[] toArray() - { - return getDelegate().toArray(); - } - - /** - * @category READ - */ - public <T> T[] toArray(T[] a) - { - return getDelegate().toArray(a); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerList.java deleted file mode 100644 index 072da17153..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerList.java +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.delegate.IContainerList; - -import java.util.Collection; -import java.util.List; -import java.util.ListIterator; - -/** - * @author Eike Stepper - */ -public class ContainerList<E> extends ContainerCollection<E> implements IContainerList<E> -{ - public ContainerList(List<E> delegate) - { - super(delegate); - } - - @Override - public List<E> getDelegate() - { - return (List<E>)super.getDelegate(); - } - - /** - * @category WRITE - */ - public void add(int index, E element) - { - getDelegate().add(index, element); - fireAddedEvent(element); - } - - /** - * @category WRITE - */ - public boolean addAll(int index, Collection<? extends E> c) - { - ContainerEvent<E> event = createEvent(getDelegate(), IContainerDelta.Kind.ADDED); - getDelegate().addAll(index, c); - return dispatchEvent(event); - } - - /** - * @category READ - */ - public E get(int index) - { - return getDelegate().get(index); - } - - /** - * @category READ - */ - public int indexOf(Object o) - { - return getDelegate().indexOf(o); - } - - /** - * @category READ - */ - public int lastIndexOf(Object o) - { - return getDelegate().lastIndexOf(o); - } - - /** - * @category READ - */ - public ListIterator<E> listIterator() - { - return new DelegatingListIterator(getDelegate().listIterator()); - } - - /** - * @category READ - */ - public ListIterator<E> listIterator(int index) - { - return new DelegatingListIterator(getDelegate().listIterator(index)); - } - - /** - * @category WRITE - */ - public E remove(int index) - { - E removed = getDelegate().remove(index); - if (removed != null) - { - fireRemovedEvent(removed); - } - - return removed; - } - - /** - * @category WRITE - */ - public E set(int index, E element) - { - E removed = getDelegate().set(index, element); - ContainerEvent<E> event = new ContainerEvent<E>(ContainerList.this); - event.addDelta(removed, IContainerDelta.Kind.REMOVED); - event.addDelta(element, IContainerDelta.Kind.ADDED); - fireEvent(event); - return removed; - } - - /** - * @category READ - */ - public List<E> subList(int fromIndex, int toIndex) - { - return getDelegate().subList(fromIndex, toIndex); - } - - /** - * @author Eike Stepper - */ - public class DelegatingListIterator extends DelegatingIterator implements ListIterator<E> - { - public DelegatingListIterator(ListIterator<E> delegate) - { - super(delegate); - } - - @Override - public ListIterator<E> getDelegate() - { - return (ListIterator<E>)super.getDelegate(); - } - - /** - * @category WRITE - */ - public void add(E o) - { - getDelegate().add(o); - fireAddedEvent(o); - last = o; - } - - /** - * @category WRITE - */ - public void set(E o) - { - getDelegate().set(o); - ContainerEvent<E> event = new ContainerEvent<E>(ContainerList.this); - event.addDelta(last, IContainerDelta.Kind.REMOVED); - event.addDelta(o, IContainerDelta.Kind.ADDED); - fireEvent(event); - last = o; - } - - /** - * @category READ - */ - public boolean hasPrevious() - { - return getDelegate().hasPrevious(); - } - - /** - * @category READ - */ - public int nextIndex() - { - return getDelegate().nextIndex(); - } - - /** - * @category READ - */ - public E previous() - { - return getDelegate().previous(); - } - - /** - * @category READ - */ - public int previousIndex() - { - return getDelegate().previousIndex(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerMap.java deleted file mode 100644 index ea033de411..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerMap.java +++ /dev/null @@ -1,197 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.util.collection.MapEntry; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.delegate.IContainerMap; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class ContainerMap<K, V> extends AbstractDelegator<Map.Entry<K, V>> implements IContainerMap<K, V> -{ - private Map<K, V> delegate; - - public ContainerMap(Map<K, V> delegate) - { - this.delegate = delegate; - } - - public Map<K, V> getDelegate() - { - return delegate; - } - - /** - * @category WRITE - */ - public void clear() - { - if (!isEmpty()) - { - ContainerEvent<Map.Entry<K, V>> event = createEvent(getDelegate().entrySet(), IContainerDelta.Kind.REMOVED); - getDelegate().clear(); - fireEvent(event); - } - } - - /** - * @category WRITE - */ - public V put(K key, V value) - { - ContainerEvent<Map.Entry<K, V>> event = new ContainerEvent<Map.Entry<K, V>>(this); - V removed = getDelegate().put(key, value); - if (removed != null) - { - event.addDelta(new ContainerMapEntry<K, V>(key, removed), IContainerDelta.Kind.REMOVED); - } - - event.addDelta(new ContainerMapEntry<K, V>(key, value), IContainerDelta.Kind.ADDED); - fireEvent(event); - return removed; - } - - /** - * @category WRITE - */ - public void putAll(Map<? extends K, ? extends V> t) - { - ContainerEvent<Map.Entry<K, V>> event = new ContainerEvent<Map.Entry<K, V>>(this); - Iterator<? extends Entry<? extends K, ? extends V>> i = t.entrySet().iterator(); - while (i.hasNext()) - { - Entry<? extends K, ? extends V> entry = i.next(); - K key = entry.getKey(); - V value = entry.getValue(); - V removed = getDelegate().put(key, value); - if (removed != null) - { - event.addDelta(new ContainerMapEntry<K, V>(key, removed), IContainerDelta.Kind.REMOVED); - } - - event.addDelta(new ContainerMapEntry<K, V>(key, value), IContainerDelta.Kind.ADDED); - } - - dispatchEvent(event); - } - - /** - * @category WRITE - */ - public V remove(Object key) - { - V removed = getDelegate().remove(key); - if (removed != null) - { - fireRemovedEvent(new ContainerMapEntry<Object, V>(key, removed)); - } - - return removed; - } - - /** - * @category READ - */ - public boolean containsKey(Object key) - { - return getDelegate().containsKey(key); - } - - /** - * @category READ - */ - public boolean containsValue(Object value) - { - return getDelegate().containsValue(value); - } - - /** - * @category READ - */ - public V get(Object key) - { - return getDelegate().get(key); - } - - /** - * @category READ - */ - public int size() - { - return getDelegate().size(); - } - - /** - * @category READ - */ - @SuppressWarnings("unchecked") - public Map.Entry<K, V>[] getElements() - { - return (Entry<K, V>[])getDelegate().entrySet().toArray(); - } - - /** - * @category READ - */ - public boolean isEmpty() - { - return getDelegate().isEmpty(); - } - - /** - * @category READ - */ - public Set<Map.Entry<K, V>> entrySet() - { - return new ContainerSet<Map.Entry<K, V>>(getDelegate().entrySet()); - } - - /** - * @category READ - */ - public Set<K> keySet() - { - return new ContainerSet<K>(getDelegate().keySet()); - } - - /** - * @category READ - */ - public Collection<V> values() - { - return new ContainerCollection<V>(getDelegate().values()); - } - - /** - * @author Eike Stepper - */ - private static final class ContainerMapEntry<K, V> extends MapEntry<K, V> - { - public ContainerMapEntry(K key, V value) - { - super(key, value); - } - - @Override - public V setValue(V value) - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerQueue.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerQueue.java deleted file mode 100644 index bb9568afc1..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerQueue.java +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.util.container.delegate.IContainerQueue; - -import java.util.Queue; - -/** - * @author Eike Stepper - */ -public class ContainerQueue<E> extends ContainerCollection<E> implements IContainerQueue<E> -{ - public ContainerQueue(Queue<E> delegate) - { - super(delegate); - } - - @Override - public Queue<E> getDelegate() - { - return (Queue<E>)super.getDelegate(); - } - - /** - * @category READ - */ - public E element() - { - return getDelegate().element(); - } - - /** - * @category WRITE - */ - public boolean offer(E o) - { - boolean modified = getDelegate().offer(o); - if (modified) - { - fireAddedEvent(o); - } - - return modified; - } - - /** - * @category READ - */ - public E peek() - { - return getDelegate().element(); - } - - /** - * @category WRITE - */ - public E poll() - { - E removed = getDelegate().poll(); - if (removed != null) - { - fireRemovedEvent(removed); - } - - return removed; - } - - /** - * @category WRITE - */ - public E remove() - { - E removed = getDelegate().remove(); - if (removed != null) - { - fireRemovedEvent(removed); - } - - return removed; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSet.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSet.java deleted file mode 100644 index 309ee30586..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSet.java +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.util.container.delegate.IContainerSet; - -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class ContainerSet<E> extends ContainerCollection<E> implements IContainerSet<E> -{ - public ContainerSet(Set<E> delegate) - { - super(delegate); - } - - @Override - public Set<E> getDelegate() - { - return (Set<E>)super.getDelegate(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSortedSet.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSortedSet.java deleted file mode 100644 index 1e00c6c7dd..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/delegate/ContainerSortedSet.java +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.container.delegate; - -import org.eclipse.net4j.util.container.delegate.IContainerSortedSet; - -import java.util.Comparator; -import java.util.SortedSet; - -/** - * @author Eike Stepper - */ -public class ContainerSortedSet<E> extends ContainerSet<E> implements IContainerSortedSet<E> -{ - public ContainerSortedSet(SortedSet<E> delegate) - { - super(delegate); - } - - @Override - public SortedSet<E> getDelegate() - { - return (SortedSet<E>)super.getDelegate(); - } - - /** - * @category READ - */ - public Comparator<? super E> comparator() - { - return getDelegate().comparator(); - } - - /** - * @category READ - */ - public E first() - { - return getDelegate().first(); - } - - /** - * @category READ - */ - public E last() - { - return getDelegate().last(); - } - - /** - * @category READ - */ - public SortedSet<E> headSet(E toElement) - { - return getDelegate().headSet(toElement); - } - - /** - * @category READ - */ - public SortedSet<E> subSet(E fromElement, E toElement) - { - return getDelegate().subSet(fromElement, toElement); - } - - /** - * @category READ - */ - public SortedSet<E> tailSet(E fromElement) - { - return getDelegate().tailSet(fromElement); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Event.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Event.java deleted file mode 100644 index 9e70cbbdef..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Event.java +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.event; - -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -import java.util.EventObject; - -/** - * @author Eike Stepper - */ -public class Event extends EventObject implements IEvent -{ - private static final long serialVersionUID = 1L; - - public Event(INotifier notifier) - { - super(notifier); - } - - public INotifier getSource() - { - return (INotifier)source; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Notifier.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Notifier.java deleted file mode 100644 index c7df10f312..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/event/Notifier.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.event; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.event.INotifier; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class Notifier implements INotifier.Introspection -{ - /** - * TODO Optimize by storing an array - */ - private List<IListener> listeners = new ArrayList<IListener>(0); - - public Notifier() - { - } - - public void addListener(IListener listener) - { - synchronized (listeners) - { - listeners.add(listener); - } - } - - public void removeListener(IListener listener) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - - public boolean hasListeners() - { - return !listeners.isEmpty(); - } - - public IListener[] getListeners() - { - synchronized (listeners) - { - return listeners.toArray(new IListener[listeners.size()]); - } - } - - public void fireEvent(IEvent event) - { - for (IListener listener : getListeners()) - { - try - { - listener.notifyEvent(event); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/Factory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/Factory.java deleted file mode 100644 index a64ed8747a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/Factory.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.factory; - -import org.eclipse.net4j.util.factory.IFactory; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public abstract class Factory implements IFactory -{ - private FactoryKey key; - - public Factory(FactoryKey key) - { - this.key = key; - } - - public Factory(String productGroup, String type) - { - this(new FactoryKey(productGroup, type)); - } - - public FactoryKey getKey() - { - return key; - } - - public String getProductGroup() - { - return key.getProductGroup(); - } - - public String getType() - { - return key.getType(); - } - - public String getDescriptionFor(Object product) - { - return null; - } - - @Override - public String toString() - { - return MessageFormat.format("Factory[{0}, {1}]", getProductGroup(), getType()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryCreationException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryCreationException.java deleted file mode 100644 index 56369be7c4..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryCreationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.factory; - -/** - * @author Eike Stepper - */ -public class FactoryCreationException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public FactoryCreationException() - { - } - - public FactoryCreationException(String message) - { - super(message); - } - - public FactoryCreationException(Throwable cause) - { - super(cause); - } - - public FactoryCreationException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryDescriptor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryDescriptor.java deleted file mode 100644 index 0e5d2e19c7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryDescriptor.java +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.factory; - -import org.eclipse.net4j.util.factory.IFactory; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -/** - * @author Eike Stepper - */ -public class FactoryDescriptor extends Factory -{ - private static final String ATTR_PRODUCT_GROUP = "productGroup"; - - private static final String ATTR_TYPE = "type"; - - private static final String ATTR_CLASS = "class"; - - private IConfigurationElement configurationElement; - - public FactoryDescriptor(IConfigurationElement configurationElement) - { - super(createFactoryKey(configurationElement)); - this.configurationElement = configurationElement; - } - - public IConfigurationElement getConfigurationElement() - { - return configurationElement; - } - - public IFactory createFactory() - { - try - { - return (IFactory)configurationElement.createExecutableExtension(ATTR_CLASS); - } - catch (CoreException ex) - { - throw new FactoryCreationException(ex); - } - } - - public Object create(String description) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getDescriptionFor(Object product) - { - throw new UnsupportedOperationException(); - } - - private static FactoryKey createFactoryKey(IConfigurationElement element) - { - String productGroup = element.getAttribute(ATTR_PRODUCT_GROUP); - String type = element.getAttribute(ATTR_TYPE); - return new FactoryKey(productGroup, type); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryKey.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryKey.java deleted file mode 100644 index b6d9bc83f9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/FactoryKey.java +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.factory; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.factory.IFactoryKey; - -import java.io.Serializable; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public final class FactoryKey implements IFactoryKey, Serializable, Comparable<FactoryKey> -{ - private static final long serialVersionUID = 1L; - - private String productGroup; - - private String type; - - public FactoryKey(String productGroup, String type) - { - this.productGroup = productGroup; - this.type = type; - } - - public String getProductGroup() - { - return productGroup; - } - - public void setProductGroup(String productGroup) - { - this.productGroup = productGroup; - } - - public String getType() - { - return type; - } - - public void setType(String type) - { - this.type = type; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof FactoryKey) - { - FactoryKey key = (FactoryKey)obj; - return ObjectUtil.equals(productGroup, key.productGroup) && ObjectUtil.equals(type, key.type); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(productGroup) ^ ObjectUtil.hashCode(type); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}[{1}]", productGroup, type); - } - - public int compareTo(FactoryKey key) - { - int result = StringUtil.compare(productGroup, key.productGroup); - if (result == 0) - { - result = StringUtil.compare(type, key.type); - } - - return result; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/PluginFactoryRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/PluginFactoryRegistry.java deleted file mode 100644 index bb3fd0ab4f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/factory/PluginFactoryRegistry.java +++ /dev/null @@ -1,91 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.factory; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.registry.HashMapRegistry; -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionDelta; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IRegistryChangeEvent; -import org.eclipse.core.runtime.IRegistryChangeListener; -import org.eclipse.core.runtime.Platform; - -/** - * @author Eike Stepper - */ -public class PluginFactoryRegistry extends HashMapRegistry<IFactoryKey, IFactory> -{ - public static final String NAMESPACE = OM.BUNDLE_ID; - - public static final String EXT_POINT = "factories"; - - private IRegistryChangeListener extensionRegistryListener = new IRegistryChangeListener() - { - public void registryChanged(IRegistryChangeEvent event) - { - IExtensionDelta[] deltas = event.getExtensionDeltas(NAMESPACE, EXT_POINT); - for (IExtensionDelta delta : deltas) - { - // TODO Handle ExtensionDelta - OM.LOG.warn("ExtensionDelta not handled: " + delta); - } - } - }; - - public PluginFactoryRegistry() - { - } - - @Override - public IFactory get(Object key) - { - IFactory factory = super.get(key); - if (factory instanceof FactoryDescriptor) - { - FactoryDescriptor descriptor = (FactoryDescriptor)factory; - factory = descriptor.createFactory(); - } - - return factory; - } - - public void registerFactory(FactoryDescriptor factory) - { - put(factory.getKey(), factory); - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = extensionRegistry.getConfigurationElementsFor(NAMESPACE, EXT_POINT); - for (IConfigurationElement element : elements) - { - registerFactory(new FactoryDescriptor(element)); - } - - extensionRegistry.addRegistryChangeListener(extensionRegistryListener, NAMESPACE); - } - - @Override - protected void doDeactivate() throws Exception - { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - extensionRegistry.removeRegistryChangeListener(extensionRegistryListener); - clear(); - super.doDeactivate(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java deleted file mode 100644 index 7d6409e8ac..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Lifecycle.java +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.lifecycle; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.event.Notifier; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.CheckUtil; -import org.eclipse.net4j.util.ReflectUtil; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; -import org.eclipse.net4j.util.lifecycle.ILifecycleState; -import org.eclipse.net4j.util.lifecycle.LifecycleException; - -/** - * @author Eike Stepper - */ -public class Lifecycle extends Notifier implements ILifecycle.Introspection -{ - public static boolean USE_LABEL = true; - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_LIFECYCLE, Lifecycle.class); - - private static final ContextTracer DUMPER = new ContextTracer(OM.DEBUG_LIFECYCLE_DUMP, Lifecycle.class); - - private static final boolean TRACE_IGNORING = false; - - private ILifecycleState lifecycleState = ILifecycleState.INACTIVE; - - protected Lifecycle() - { - } - - public final void activate() throws LifecycleException - { - if (lifecycleState == ILifecycleState.INACTIVE) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Activating " + this);//$NON-NLS-1$ - } - - lifecycleState = ILifecycleState.ACTIVATING; - fireEvent(new LifecycleEvent(this, ILifecycleEvent.Kind.ABOUT_TO_ACTIVATE)); - - try - { - doBeforeActivate(); - doActivate(); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new LifecycleException(ex); - } - - if (!isDeferredActivation()) - { - deferredActivate(); - } - } - else - { - if (TRACE_IGNORING && TRACER.isEnabled()) - { - TRACER.format("Ignoring activation in state {0} for {1}", lifecycleState, this);//$NON-NLS-1$ - } - } - } - - public final Exception deactivate() - { - if (lifecycleState == ILifecycleState.ACTIVE || lifecycleState == ILifecycleState.ACTIVATING) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Deactivating " + this);//$NON-NLS-1$ - } - - try - { - lifecycleState = ILifecycleState.DEACTIVATING; - doBeforeDeactivate(); - fireEvent(new LifecycleEvent(this, ILifecycleEvent.Kind.ABOUT_TO_DEACTIVATE)); - - if (!isDeferredDeactivation()) - { - deferredDeactivate(); - } - } - catch (Exception ex) - { - OM.LOG.error(ex); - return ex; - } - } - else - { - if (TRACE_IGNORING && TRACER.isEnabled()) - { - TRACER.format("Ignoring deactivation in state {0} for {1}", lifecycleState, this);//$NON-NLS-1$ - } - } - - return null; - } - - public final ILifecycleState getLifecycleState() - { - return lifecycleState; - } - - public final boolean isActive() - { - return lifecycleState == ILifecycleState.ACTIVE; - } - - @Override - public String toString() - { - if (USE_LABEL) - { - return ReflectUtil.getLabel(this); - } - - return super.toString(); - } - - protected final void dump() - { - if (DUMPER.isEnabled()) - { - DUMPER.trace("DUMP" + ReflectUtil.toString(this)); //$NON-NLS-1$ - } - } - - protected final void checkActive() - { - if (lifecycleState != ILifecycleState.ACTIVE) - { - throw new IllegalStateException("Not active: " + this); - } - } - - protected final void checkInactive() - { - if (lifecycleState != ILifecycleState.INACTIVE) - { - throw new IllegalStateException("Not inactive: " + this); - } - } - - protected final void checkNull(Object handle, String msg) throws NullPointerException - { - CheckUtil.checkNull(handle, msg); - } - - protected final void checkArg(boolean expr, String msg) throws IllegalArgumentException - { - CheckUtil.checkArg(expr, msg); - } - - protected final void checkArg(Object handle, String handleName) throws IllegalArgumentException - { - CheckUtil.checkArg(handle, handleName); - } - - protected final void checkState(boolean expr, String msg) throws IllegalStateException - { - CheckUtil.checkState(expr, msg); - } - - protected final void checkState(Object handle, String handleName) throws IllegalStateException - { - CheckUtil.checkState(handle, handleName); - } - - protected final void deferredActivate() - { - lifecycleState = ILifecycleState.ACTIVE; - fireEvent(new LifecycleEvent(this, ILifecycleEvent.Kind.ACTIVATED)); - dump(); - } - - protected final void deferredDeactivate() throws Exception - { - doDeactivate(); - lifecycleState = ILifecycleState.INACTIVE; - fireEvent(new LifecycleEvent(this, ILifecycleEvent.Kind.DEACTIVATED)); - } - - protected boolean isDeferredActivation() - { - return false; - } - - protected boolean isDeferredDeactivation() - { - return false; - } - - protected void doBeforeActivate() throws Exception - { - } - - protected void doActivate() throws Exception - { - } - - protected void doBeforeDeactivate() throws Exception - { - } - - protected void doDeactivate() throws Exception - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEvent.java deleted file mode 100644 index 98083141f6..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.lifecycle; - -import org.eclipse.net4j.internal.util.event.Event; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; - -/** - * @author Eike Stepper - */ -public class LifecycleEvent extends Event implements ILifecycleEvent -{ - private static final long serialVersionUID = 1L; - - private Kind kind; - - public LifecycleEvent(Lifecycle lifecycle, Kind kind) - { - super(lifecycle); - this.kind = kind; - } - - public ILifecycle getLifecycle() - { - return (ILifecycle)getSource(); - } - - public Kind getKind() - { - return kind; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEventAdapter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEventAdapter.java deleted file mode 100644 index 05e8bd6a45..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/LifecycleEventAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.lifecycle; - -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; - -/** - * @author Eike Stepper - */ -public class LifecycleEventAdapter implements IListener -{ - public LifecycleEventAdapter() - { - } - - public final void notifyEvent(IEvent event) - { - if (event instanceof ILifecycleEvent) - { - ILifecycleEvent e = (ILifecycleEvent)event; - notifyLifecycleEvent(e); - } - else - { - notifyOtherEvent(event); - } - } - - protected void notifyLifecycleEvent(ILifecycleEvent event) - { - switch (event.getKind()) - { - case ABOUT_TO_ACTIVATE: - onAboutToActivate(event.getLifecycle()); - break; - case ACTIVATED: - onActivated(event.getLifecycle()); - break; - case ABOUT_TO_DEACTIVATE: - onAboutToDeactivate(event.getLifecycle()); - break; - case DEACTIVATED: - onDeactivated(event.getLifecycle()); - break; - } - } - - protected void notifyOtherEvent(IEvent event) - { - } - - protected void onAboutToActivate(ILifecycle lifecycle) - { - } - - protected void onActivated(ILifecycle lifecycle) - { - } - - protected void onAboutToDeactivate(ILifecycle lifecycle) - { - } - - protected void onDeactivated(ILifecycle lifecycle) - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/QueueWorker.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/QueueWorker.java deleted file mode 100644 index 6aea5c6bf4..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/QueueWorker.java +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.lifecycle; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public abstract class QueueWorker<E> extends Worker -{ - private BlockingQueue<E> queue; - - private long pollMillis; - - public QueueWorker() - { - setPollMillis(100); - } - - public long getPollMillis() - { - return pollMillis; - } - - public void setPollMillis(long pollMillis) - { - this.pollMillis = pollMillis; - } - - public boolean addWork(E element) - { - if (queue != null) - { - return queue.offer(element); - } - - return false; - } - - @Override - protected final void work(WorkContext context) throws Exception - { - E element = queue.poll(pollMillis, TimeUnit.MILLISECONDS); - if (element != null) - { - work(context, element); - } - } - - protected abstract void work(WorkContext context, E element); - - protected BlockingQueue<E> createQueue() - { - return new LinkedBlockingQueue<E>(); - } - - @Override - protected void doActivate() throws Exception - { - queue = createQueue(); - super.doActivate(); - } - - @Override - protected void doDeactivate() throws Exception - { - super.doDeactivate(); - if (queue != null) - { - queue.clear(); - queue = null; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Worker.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Worker.java deleted file mode 100644 index be6d38efd8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/lifecycle/Worker.java +++ /dev/null @@ -1,250 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.lifecycle; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * @author Eike Stepper - */ -public abstract class Worker extends Lifecycle -{ - public static final int DEFAULT_TIMEOUT = 2000; - - private boolean daemon; - - private long activationTimeout = DEFAULT_TIMEOUT; - - private long deactivationTimeout = DEFAULT_TIMEOUT; - - private transient CountDownLatch activationLatch; - - private transient WorkerThread workerThread; - - public Worker() - { - } - - public boolean isDaemon() - { - return daemon; - } - - public void setDaemon(boolean daemon) - { - this.daemon = daemon; - } - - public long getActivationTimeout() - { - return activationTimeout; - } - - public void setActivationTimeout(long activationTimeout) - { - this.activationTimeout = activationTimeout; - } - - public long getDeactivationTimeout() - { - return deactivationTimeout; - } - - public void setDeactivationTimeout(long deactivationTimeout) - { - this.deactivationTimeout = deactivationTimeout; - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - activationLatch = new CountDownLatch(1); - String threadName = getThreadName(); - workerThread = threadName == null ? new WorkerThread() : new WorkerThread(threadName); - workerThread.start(); - if (!activationLatch.await(activationTimeout, TimeUnit.MILLISECONDS)) - { - try - { - workerThread.stopRunning(); - workerThread.interrupt(); - } - catch (RuntimeException ignore) - { - } - - throw new TimeoutException("Worker thread activation timed out after " + activationTimeout + " millis"); - } - } - - @Override - protected void doDeactivate() throws Exception - { - try - { - workerThread.stopRunning(); - workerThread.interrupt(); - workerThread.join(deactivationTimeout); - } - catch (RuntimeException ignore) - { - } - - super.doDeactivate(); - } - - protected String getThreadName() - { - return null; - } - - protected abstract void work(WorkContext context) throws Exception; - - /** - * @author Eike Stepper - */ - private final class WorkerThread extends Thread - { - private boolean running = true; - - public WorkerThread() - { - setDaemon(daemon); - } - - public WorkerThread(String threadName) - { - super(threadName); - setDaemon(daemon); - } - - public void stopRunning() - { - running = false; - } - - @Override - public void run() - { - WorkContext context = new WorkContext(); - activationLatch.countDown(); - while (running && !isInterrupted()) - { - try - { - context.increaseCount(); - work(context); - } - catch (NextWork nextWork) - { - nextWork.pause(); - } - catch (Terminate terminate) - { - break; - } - catch (InterruptedException ex) - { - break; - } - catch (Exception ex) - { - OM.LOG.error(ex); - break; - } - } - - deactivate(); - } - } - - /** - * @author Eike Stepper - */ - public final class WorkContext - { - private long count; - - public WorkContext() - { - } - - public long getCount() - { - return count; - } - - public void nextWork() - { - throw new NextWork(); - } - - public void nextWork(long pauseMillis) - { - throw new NextWork(pauseMillis); - } - - public void terminate() - { - throw new Terminate(); - } - - private void increaseCount() - { - ++count; - } - } - - /** - * @author Eike Stepper - */ - private static final class NextWork extends RuntimeException - { - private static final long serialVersionUID = 1L; - - private long pauseMillis; - - public NextWork() - { - } - - public NextWork(long pauseMillis) - { - this.pauseMillis = pauseMillis; - } - - public void pause() - { - if (pauseMillis > 0) - { - ConcurrencyUtil.sleep(pauseMillis); - } - } - } - - /** - * @author Eike Stepper - */ - private static final class Terminate extends RuntimeException - { - private static final long serialVersionUID = 1L; - - public Terminate() - { - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java deleted file mode 100644 index 5c5a6a06fb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyBundle.java +++ /dev/null @@ -1,224 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om; - -import org.eclipse.net4j.internal.util.bundle.AbstractBundle; -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.ReflectUtil; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.io.IOUtil; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.Map.Entry; - -/** - * @author Eike Stepper - */ -public class LegacyBundle extends AbstractBundle -{ - private URL baseURL; - - public LegacyBundle(AbstractPlatform platform, String bundleID, Class<?> accessor) - { - super(platform, bundleID, accessor); - - try - { - computeBaseURL(accessor); - loadOptions(); - } - catch (Exception ex) - { - IOUtil.print(ex); - } - } - - public String getStateLocation() - { - return new File(getPlatform().getStateFolder(), ".plugins/" + getBundleID()).getAbsolutePath(); - } - - public URL getBaseURL() - { - return baseURL; - } - - private void loadOptions() - { - InputStream inputStream = null; - Properties properties = new Properties(); - - try - { - final String prefix = getBundleID() + "/"; //$NON-NLS-1$ - final int length = prefix.length(); - - inputStream = getInputStream(".options"); //$NON-NLS-1$ - properties.load(inputStream); - - for (Entry<Object, Object> entry : properties.entrySet()) - { - try - { - String key = (String)entry.getKey(); - if (key.startsWith(prefix)) - { - String value = (String)entry.getValue(); - setDebugOption(key.substring(length), value); - } - } - catch (RuntimeException ignore) - { - ; - } - } - } - catch (IOException ignore) - { - ; - } - finally - { - IOUtil.closeSilent(inputStream); - } - } - - private void computeBaseURL(Class<?> accessor) throws MalformedURLException - { - // Determine the URL for the class itself. The URL will be of one of the - // following forms, so there are a few good places to consider looking for - // the plugin.properties. - // - // For a plugin.xml with runtime="common.jar": - // jar:file:/D:/sandbox/unpackage1-3.1M7/eclipse/plugins/org.eclipse.emf.common/common.jar!/org/eclipse/common/CommonPlugin.class - // - // For a plugin.xml with runtime="runtime/common.jar": - // jar:file:/D:/sandbox/unpackage1-3.1M7/eclipse/plugins/org.eclipse.emf.common/runtime/common.jar!/org/eclipse/common/CommonPlugin.class - // - // For a plugin.xml with runtime="." where the plugin is jarred: - // jar:file:/D:/sandbox/unpackage1-3.1M7/eclipse/plugins/org.eclipse.emf.common.jar!/org/eclipse/common/CommonPlugin.class - // - // For a plugin.xml with runtime="." where the plugin is not jarred. - // file:/D:/sandbox/unpackage1-3.1M7/eclipse/plugins/org.eclipse.emf.common/org/eclipse/emf/common/CommonPlugin.class - // - // Running in PDE with bin on classpath: - // file:/D:/sandbox/unpackage1-3.1M7/eclipse/plugins/org.eclipse.emf.common/bin/org/eclipse/emf/common/CommonPlugin.class - - String className = accessor.getName(); - URL url = accessor.getResource(ReflectUtil.getSimpleName(accessor) + ".class"); //$NON-NLS-1$ - - int segmentsToTrim = 1 + StringUtil.occurrences(className, '.'); - url = trimSegments(url, segmentsToTrim); - - // For an archive URI, check for the plugin.properties in the archive. - if (isArchiveProtocol(url.getProtocol())) - { - try - { - // If we can open an input stream, then the plugin.properties is there, - // and we have a good base URL. - InputStream inputStream = new URL(url.toString() + "plugin.properties").openStream(); //$NON-NLS-1$ - inputStream.close(); - baseURL = url; - } - catch (IOException exception) - { - // If the plugin.properties isn't within the root of the archive, create - // a new URI for the folder location of the archive, so we can look in - // the folder that contains it. - url = trimSegments(new URL(url.getFile()), 1); - } - } - - // If we didn't find the plugin.properties in the usual place nor in the - // archive... - if (baseURL == null) - { - // Trim off the "bin" or "runtime" segment. - String lastSegment = lastSegment(url); - if ("bin".equals(lastSegment) || "runtime".equals(lastSegment)) //$NON-NLS-1$ //$NON-NLS-2$ - { - url = trimSegments(url, 1); - } - - try - { - // If we can open an input stream, then the plugin.properties is in the - // folder, and we have a good base URL. - InputStream inputStream = new URL(url.toString() + "plugin.properties").openStream(); //$NON-NLS-1$ - inputStream.close(); - baseURL = url; - } - catch (IOException exception) - { - } - } - - // If we still don't have a good base URL, complain about it. - if (baseURL == null) - { - String resourceName = ReflectUtil.getPackageName(className).replace('.', '/') + "/plugin.properties"; //$NON-NLS-1$ - throw new MissingResourceException("Missing properties: " + resourceName, accessor.getName(), //$NON-NLS-1$ - "plugin.properties"); //$NON-NLS-1$ - } - } - - private static String lastSegment(URL url) - { - String path = url.getPath(); - if (path.endsWith("/")) //$NON-NLS-1$ - { - path = path.substring(0, path.length() - 1); - } - - int pos = path.lastIndexOf('/'); - return pos == -1 ? path : path.substring(pos + 1); - } - - private static URL trimSegments(URL url, int count) throws MalformedURLException - { - String path = url.getPath(); - if (path.endsWith("/")) //$NON-NLS-1$ - { - ++count; - } - - for (int i = 0; i < count; i++) - { - int pos = path.lastIndexOf('/'); - if (pos == -1) - { - break; - } - - // TODO Optimize - path = path.substring(0, pos); - } - - return new URL(url.getProtocol() + ":" + path + "/"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * TODO Make configurable - * - * @see org.eclipse.emf.common.util.URI#isArchiveScheme(String) - */ - private static boolean isArchiveProtocol(String scheme) - { - return "jar".equalsIgnoreCase(scheme); //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyPlatform.java deleted file mode 100644 index c05bef1fda..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/LegacyPlatform.java +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om; - -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.om.OMBundle; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author Eike Stepper - */ -public class LegacyPlatform extends AbstractPlatform -{ - private Map<String, String> debugOptions = new ConcurrentHashMap<String, String>(0); - - public LegacyPlatform() - { - } - - public boolean isOSGiRunning() - { - return false; - } - - @Override - protected OMBundle createBundle(String bundleID, Class<?> accessor) - { - return new LegacyBundle(this, bundleID, accessor); - } - - @Override - protected String getDebugOption(String bundleID, String option) - { - return debugOptions.get(bundleID + "/" + option); //$NON-NLS-1$ - } - - @Override - protected void setDebugOption(String bundleID, String option, String value) - { - debugOptions.put(bundleID + "/" + option, value); //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java deleted file mode 100644 index 1d0ba0ab42..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiBundle.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om; - -import org.eclipse.net4j.internal.util.bundle.AbstractBundle; -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.io.IOUtil; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Platform; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -import java.io.IOException; -import java.net.URL; - -/** - * @author Eike Stepper - */ -public class OSGiBundle extends AbstractBundle -{ - public OSGiBundle(AbstractPlatform platform, String bundleID, Class<?> accessor) - { - super(platform, bundleID, accessor); - } - - @Override - public BundleContext getBundleContext() - { - return (BundleContext)super.getBundleContext(); - } - - public URL getBaseURL() - { - try - { - URL entry = getBundleContext().getBundle().getEntry("."); //$NON-NLS-1$ - return FileLocator.resolve(entry); - } - catch (IOException ex) - { - IOUtil.print(ex); - return null; - } - } - - public String getStateLocation() - { - Bundle bundle = getBundleContext().getBundle(); - return Platform.getStateLocation(bundle).toString(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiPlatform.java deleted file mode 100644 index a83c568d69..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/OSGiPlatform.java +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om; - -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.om.OMBundle; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.osgi.service.debug.DebugOptions; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * @author Eike Stepper - */ -public class OSGiPlatform extends AbstractPlatform -{ - BundleContext systemContext; - - public OSGiPlatform(Object systemContext) - { - this.systemContext = (BundleContext)systemContext; - - try - { - setDebugging(Platform.inDebugMode()); - } - catch (Throwable ignore) - { - ; - } - } - - public boolean isOSGiRunning() - { - return true; - } - - @Override - protected OMBundle createBundle(String bundleID, Class<?> accessor) - { - return new OSGiBundle(this, bundleID, accessor); - } - - @Override - protected String getDebugOption(String bundleID, String option) - { - try - { - DebugOptions debugOptions = getDebugOptions(); - return debugOptions.getOption(bundleID + "/" + option); //$NON-NLS-1$ - } - catch (Exception ex) - { - return null; - } - } - - @Override - protected void setDebugOption(String bundleID, String option, String value) - { - try - { - DebugOptions debugOptions = getDebugOptions(); - debugOptions.setOption(bundleID + "/" + option, value); //$NON-NLS-1$ - } - catch (Exception ex) - { - } - } - - protected DebugOptions getDebugOptions() throws NoClassDefFoundError, NullPointerException - { - ServiceReference ref = systemContext.getServiceReference(DebugOptions.class.getName()); - return (DebugOptions)systemContext.getService(ref); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/EclipseLoggingBridge.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/EclipseLoggingBridge.java deleted file mode 100644 index e9b36517a3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/EclipseLoggingBridge.java +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.log; - -import org.eclipse.net4j.internal.util.om.OSGiBundle; -import org.eclipse.net4j.util.om.log.OMLogHandler; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.log.OMLogger.Level; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; - -/** - * @author Eike Stepper - */ -public class EclipseLoggingBridge implements OMLogHandler -{ - /** - * @Singleton - */ - public static final EclipseLoggingBridge INSTANCE = new EclipseLoggingBridge(); - - protected EclipseLoggingBridge() - { - } - - public void logged(OMLogger logger, Level level, String msg, Throwable t) - { - try - { - OSGiBundle bundle = (OSGiBundle)logger.getBundle(); - ILog log = Platform.getLog(bundle.getBundleContext().getBundle()); - log.log(new Status(toEclipse(level), bundle.getBundleID(), IStatus.OK, msg, t)); - } - catch (RuntimeException ignore) - { - } - } - - public static int toEclipse(Level level) - { - switch (level) - { - case ERROR: - return IStatus.ERROR; - case WARN: - return IStatus.WARNING; - case INFO: - return IStatus.INFO; - case DEBUG: - return IStatus.OK; - default: - throw new IllegalArgumentException("Illegal log level: " + level); //$NON-NLS-1$ - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java deleted file mode 100644 index 72737ceebb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/Logger.java +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.log; - -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.log.OMLogger; - -/** - * @author Eike Stepper - */ -public class Logger implements OMLogger -{ - private OMBundle bundle; - - public Logger(OMBundle bundle) - { - this.bundle = bundle; - } - - public OMBundle getBundle() - { - return bundle; - } - - public void log(Level level, String msg, Throwable t) - { - ((AbstractPlatform)bundle.getPlatform()).log(this, level, msg, t); - } - - public void error(String msg, Throwable t) - { - log(Level.ERROR, msg, t); - } - - public void warn(String msg, Throwable t) - { - log(Level.WARN, msg, t); - } - - public void info(String msg, Throwable t) - { - log(Level.INFO, msg, t); - } - - public void debug(String msg, Throwable t) - { - log(Level.DEBUG, msg, t); - } - - public void log(Level level, String msg) - { - log(level, msg, null); - } - - public void error(String msg) - { - log(Level.ERROR, msg); - } - - public void warn(String msg) - { - log(Level.WARN, msg); - } - - public void info(String msg) - { - log(Level.INFO, msg); - } - - public void debug(String msg) - { - log(Level.DEBUG, msg); - } - - public void log(Level level, Throwable t) - { - String msg = t.getMessage(); - if (msg == null) - { - msg = t.getClass().getSimpleName(); - } - - log(level, msg, t); - } - - public void error(Throwable t) - { - log(Level.ERROR, t); - } - - public void warn(Throwable t) - { - log(Level.WARN, t); - } - - public void info(Throwable t) - { - log(Level.INFO, t); - } - - public void debug(Throwable t) - { - log(Level.DEBUG, t); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/OSGiLoggingBridge.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/OSGiLoggingBridge.java deleted file mode 100644 index e84a649328..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/OSGiLoggingBridge.java +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.log; - -import org.eclipse.net4j.internal.util.om.OSGiBundle; -import org.eclipse.net4j.util.om.log.OMLogHandler; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.log.OMLogger.Level; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.log.LogService; - -/** - * @author Eike Stepper - */ -public class OSGiLoggingBridge implements OMLogHandler -{ - // @Singleton - public static final OSGiLoggingBridge INSTANCE = new OSGiLoggingBridge(); - - protected OSGiLoggingBridge() - { - } - - public void logged(OMLogger logger, Level level, String msg, Throwable t) - { - try - { - BundleContext bundleContext = ((OSGiBundle)logger.getBundle()).getBundleContext(); - logged(bundleContext, level, msg, t); - } - catch (RuntimeException ignore) - { - } - } - - public void logged(BundleContext bundleContext, Level level, String msg, Throwable t) - { - LogService logService = getLogService(bundleContext); - logService.log(toOSGi(level), msg, t); - } - - protected LogService getLogService(BundleContext bundleContext) - { - try - { - ServiceReference ref = bundleContext.getServiceReference(LogService.class.getName()); - LogService logService = (LogService)bundleContext.getService(ref); - return logService; - } - catch (RuntimeException ex) - { - throw new IllegalStateException("Log service not found", ex); //$NON-NLS-1$ - } - } - - public static int toOSGi(Level level) - { - switch (level) - { - case ERROR: - return LogService.LOG_ERROR; - case WARN: - return LogService.LOG_WARNING; - case INFO: - return LogService.LOG_INFO; - case DEBUG: - return LogService.LOG_DEBUG; - default: - throw new IllegalArgumentException("Illegal log level: " + level); //$NON-NLS-1$ - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/PrintLogHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/PrintLogHandler.java deleted file mode 100644 index 753494a628..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/log/PrintLogHandler.java +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.log; - -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.log.OMLogHandler; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.log.OMLogger.Level; - -import java.io.PrintStream; - -/** - * @author Eike Stepper - */ -public class PrintLogHandler implements OMLogHandler -{ - public static final PrintLogHandler CONSOLE = new PrintLogHandler(); - - private PrintStream out; - - private PrintStream err; - - public PrintLogHandler(PrintStream out, PrintStream err) - { - this.out = out; - this.err = err; - } - - protected PrintLogHandler() - { - this(IOUtil.OUT(), IOUtil.ERR()); - } - - public void logged(OMLogger logger, Level level, String msg, Throwable t) - { - try - { - PrintStream stream = level == Level.ERROR ? err : out; - stream.println(toString(level) + " " + msg); //$NON-NLS-1$ - if (t != null) - { - IOUtil.print(t, stream); - } - } - catch (RuntimeException ignore) - { - } - } - - public static String toString(Level level) - { - switch (level) - { - case ERROR: - return "[ERROR]"; //$NON-NLS-1$ - case WARN: - return "[WARN]"; //$NON-NLS-1$ - case INFO: - return "[INFO]"; //$NON-NLS-1$ - case DEBUG: - return "[DEBUG]"; //$NON-NLS-1$ - default: - throw new IllegalArgumentException("Illegal log level: " + level); //$NON-NLS-1$ - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java deleted file mode 100644 index 03f8cafb62..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/EclipseMonitor.java +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.monitor; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; - -/** - * @author Eike Stepper - */ -public class EclipseMonitor extends Monitor -{ - private IProgressMonitor progressMonitor; - - public EclipseMonitor(IProgressMonitor progressMonitor) - { - super(null, 0); - if (progressMonitor == null) - { - throw new IllegalArgumentException("progressMonitor == null"); - } - - this.progressMonitor = new DelegatingProgressMonitor(progressMonitor); - } - - private EclipseMonitor(EclipseMonitor parent, int workFromParent) - { - super(parent, workFromParent); - progressMonitor = new SubProgressMonitor(new SubProgressMonitor(parent.getProgressMonitor(), workFromParent), - workFromParent); - } - - public IProgressMonitor getProgressMonitor() - { - return progressMonitor; - } - - @Override - public void setTask(String task) - { - super.setTask(task); - progressMonitor.setTaskName(task); - } - - @Override - public void worked(int work, String msg) - { - super.worked(work, msg); - progressMonitor.worked(work); - if (msg != null) - { - progressMonitor.subTask(msg); - } - } - - @Override - protected void begin(int totalWork, String task) - { - super.begin(totalWork, task); - progressMonitor.beginTask(task == null ? "" : task, totalWork); - } - - @Override - protected void done() - { - super.done(); - progressMonitor.done(); - } - - @Override - protected void message(String msg, int level) - { - super.message(msg, level); - progressMonitor.subTask(msg); - } - - @Override - protected EclipseMonitor subMonitor(int workFromParent) - { - return new EclipseMonitor(this, workFromParent); - } - - /** - * @author Eike Stepper - */ - private final class DelegatingProgressMonitor implements IProgressMonitor - { - private IProgressMonitor delegate; - - public DelegatingProgressMonitor(IProgressMonitor delegate) - { - this.delegate = delegate; - } - - public IProgressMonitor getDelegate() - { - return delegate; - } - - public void beginTask(String name, int totalWork) - { - delegate.beginTask(name, totalWork); - } - - public void done() - { - delegate.done(); - } - - public void internalWorked(double work) - { - delegate.internalWorked(work); - } - - public boolean isCanceled() - { - return delegate.isCanceled(); - } - - public void setCanceled(boolean value) - { - EclipseMonitor.this.setCanceled(value); - delegate.setCanceled(value); - } - - public void setTaskName(String name) - { - delegate.setTaskName(name); - } - - public void subTask(String name) - { - delegate.subTask(name); - } - - public void worked(int work) - { - delegate.worked(work); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java deleted file mode 100644 index cb5e8ddb18..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/LegacyMonitor.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class LegacyMonitor extends Monitor -{ - public LegacyMonitor() - { - super(null, 0); - } - - private LegacyMonitor(LegacyMonitor parent, int workFromParent) - { - super(parent, workFromParent); - } - - @Override - public LegacyMonitor subMonitor(int workFromParent) - { - return new LegacyMonitor(this, workFromParent); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java deleted file mode 100644 index 430a74572e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/MON.java +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.monitor; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.om.monitor.IllegalMonitorNestingException; -import org.eclipse.net4j.util.om.monitor.MonitorAlreadyBegunException; -import org.eclipse.net4j.util.om.monitor.MonitorException; -import org.eclipse.net4j.util.om.monitor.OMMonitor; - -/** - * @author Eike Stepper - */ -public final class MON -{ - public static final int UNKNOWN = -1; - - private static final ThreadLocal<Monitor> CURRENT = new ThreadLocal<Monitor>(); - - private MON() - { - } - - public static boolean isCanceled() - { - Monitor current = CURRENT.get(); - if (current == null) - { - return false; - } - - return current.isCanceled(); - } - - public static void setCanceled(boolean canceled) - { - Monitor current = CURRENT.get(); - if (current != null) - { - current.setCanceled(canceled); - } - } - - public static void startMonitoring(Monitor rootMonitor) - { - Monitor current = CURRENT.get(); - if (current != null) - { - throw new IllegalMonitorNestingException("Monitoring has already been started"); - } - - CURRENT.set(rootMonitor); - } - - public static void stopMonitoring() - { - try - { - Monitor current = CURRENT.get(); - if (current == null) - { - OM.LOG.warn("Monitoring has not been started"); - } - else - { - if (current.getParent() != null) - { - OM.LOG.warn("Illegal monitor nesting"); - } - - current.done(); - } - } - finally - { - CURRENT.set(null); - } - } - - public static OMMonitor begin(int totalWork, String task) - { - Monitor current = CURRENT.get(); - if (current == null) - { - return NullMonitor.INSTANCE; - } - - if (current.hasBegun()) - { - throw new MonitorAlreadyBegunException("Monitor has already begun"); - } - - current.begin(totalWork, task); - return current; - } - - static void checkMonitor(Monitor monitor) throws MonitorException - { - Monitor current = CURRENT.get(); - if (current != monitor) - { - throw new IllegalMonitorNestingException("Illegal monitor nesting\n" + // - "Current monitor stack:\n" + current.dump() + // - "Used monitor stack:\n" + monitor.dump()); - } - - monitor.checkCanceled(); - } - - static void setMonitor(Monitor monitor) - { - CURRENT.set(monitor); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java deleted file mode 100644 index f83d3d0564..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/Monitor.java +++ /dev/null @@ -1,291 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.monitor; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.om.monitor.MonitorCanceledException; -import org.eclipse.net4j.util.om.monitor.MonitorNotBegunException; -import org.eclipse.net4j.util.om.monitor.OMMonitor; -import org.eclipse.net4j.util.om.monitor.OMSubMonitor; -import org.eclipse.net4j.util.om.monitor.TotalWorkExceededException; - -/** - * @author Eike Stepper - */ -public abstract class Monitor implements OMMonitor, OMSubMonitor -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, Monitor.class); - - private static final int UNINITIALIZED = 0; - - private Monitor parent; - - private int workFromParent; - - private int totalWork = UNINITIALIZED; - - private int work; - - private String task; - - private Monitor child; - - private boolean canceled; - - public Monitor(Monitor parent, int workFromParent) - { - this.parent = parent; - this.workFromParent = workFromParent; - } - - public boolean isCanceled() - { - return canceled; - } - - public void checkCanceled() throws MonitorCanceledException - { - if (canceled) - { - throw new MonitorCanceledException(); - } - } - - public String getTask() - { - return task; - } - - public void setTask(String task) - { - this.task = task; - taskChanged(task, 0); - } - - public int getTotalWork() - { - return totalWork; - } - - public boolean hasBegun() - { - return totalWork != UNINITIALIZED; - } - - public void message(String msg) - { - if (msg != null) - { - message(msg, 0); - } - } - - public void worked(int work, String msg) throws MonitorCanceledException - { - MON.checkMonitor(this); - checkWork(work); - - this.work += work; - message(msg); - } - - public void worked(int work) throws MonitorCanceledException - { - worked(work, null); - } - - public void worked(String msg) throws MonitorCanceledException - { - worked(1, msg); - } - - public void worked() throws MonitorCanceledException - { - worked(1, null); - } - - public void fork(int workFromParent, Runnable runnable, String msg) throws MonitorCanceledException - { - MON.checkMonitor(this); - checkWork(workFromParent); - - child = subMonitor(workFromParent); - MON.setMonitor(child); - - try - { - runnable.run(); - } - finally - { - MON.checkMonitor(child); - MON.setMonitor(this); - child.done(); - child = null; - } - - work += workFromParent; - message(msg); - } - - public void fork(int workFromParent, Runnable runnable) throws MonitorCanceledException - { - fork(workFromParent, runnable, null); - } - - public void fork(Runnable runnable, String msg) throws MonitorCanceledException - { - fork(1, runnable, msg); - } - - public void fork(Runnable runnable) throws MonitorCanceledException - { - fork(1, runnable, null); - } - - public OMSubMonitor fork(int workFromParent) throws MonitorCanceledException - { - MON.checkMonitor(this); - checkWork(workFromParent); - - child = subMonitor(workFromParent); - MON.setMonitor(child); - return child; - } - - public OMSubMonitor fork() throws MonitorCanceledException - { - return fork(1); - } - - public void join(String msg) throws MonitorCanceledException - { - MON.checkMonitor(this); - MON.setMonitor(parent); - parent.setChild(null); - parent.message(msg); - done(); - } - - public void join() throws MonitorCanceledException - { - join(null); - } - - protected Monitor getChild() - { - return child; - } - - protected void setChild(Monitor child) - { - this.child = child; - } - - protected void setCanceled(boolean canceled) - { - this.canceled = canceled; - if (child != null) - { - child.setCanceled(canceled); - } - } - - protected Monitor getParent() - { - return parent; - } - - protected int getWorkFromParent() - { - return workFromParent; - } - - protected String dump() - { - StringBuilder builder = new StringBuilder(); - dump(builder); - return builder.toString(); - } - - protected void begin(int totalWork, String task) throws MonitorCanceledException - { - checkCanceled(); - this.totalWork = totalWork; - if (task != null) - { - setTask(task); - } - } - - protected void done() - { - } - - protected void taskChanged(String task, int level) - { - if (parent != null) - { - parent.taskChanged(task, level + 1); - } - else - { - trace(task, level, true); - } - } - - protected void message(String msg, int level) - { - if (parent != null) - { - parent.message(msg, level + 1); - } - else - { - trace(msg, level, false); - } - } - - protected void trace(String msg, int level, boolean isTask) - { - if (TRACER.isEnabled()) - { - TRACER.trace(msg); - } - } - - protected void checkWork(int work) - { - if (!hasBegun()) - { - throw new MonitorNotBegunException("Monitor has not begun"); - } - - if (totalWork != UNKNOWN && this.work + work > totalWork) - { - throw new TotalWorkExceededException(("Work of " + work + " exceeded total work of " + totalWork)); - } - } - - protected void dump(StringBuilder builder) - { - builder.append(" "); - builder.append(task); - builder.append("\n"); - if (parent != null) - { - parent.dump(builder); - } - } - - protected abstract Monitor subMonitor(int workFromParent); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java deleted file mode 100644 index fe19bf1f9c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/monitor/NullMonitor.java +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.monitor; - -import org.eclipse.net4j.util.om.monitor.OMMonitor; -import org.eclipse.net4j.util.om.monitor.OMSubMonitor; - -/** - * @author Eike Stepper - */ -public class NullMonitor implements OMMonitor, OMSubMonitor -{ - public static final NullMonitor INSTANCE = new NullMonitor(); - - private NullMonitor() - { - } - - public void join() - { - } - - public void join(String msg) - { - } - - public OMSubMonitor fork() - { - return this; - } - - public void fork(int workFromParent, Runnable runnable, String msg) - { - } - - public void fork(int workFromParent, Runnable runnable) - { - } - - public OMSubMonitor fork(int workFromParent) - { - return this; - } - - public void fork(Runnable runnable, String msg) - { - } - - public void fork(Runnable runnable) - { - } - - public String getTask() - { - return null; - } - - public int getTotalWork() - { - return 0; - } - - public boolean hasBegun() - { - return true; - } - - public void message(String msg) - { - } - - public void setTask(String task) - { - } - - public void worked() - { - } - - public void worked(int work, String msg) - { - } - - public void worked(int work) - { - } - - public void worked(String msg) - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/ArrayPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/ArrayPreference.java deleted file mode 100644 index 0bbf155a94..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/ArrayPreference.java +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.om.pref.OMPreference; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; - -/** - * @author Eike Stepper - */ -public final class ArrayPreference extends Preference<String[]> implements OMPreference<String[]> -{ - private static final String SEPARATOR = ","; - - private static final String UTF_8 = "UTF-8"; - - public ArrayPreference(Preferences preferences, String name, String[] defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - String[] array = getValue(); - if (array.length == 0) - { - return null; - } - - StringBuilder builder = new StringBuilder(); - for (String element : array) - { - if (builder.length() != 0) - { - builder.append(SEPARATOR); - builder.append(" "); - } - - try - { - String encoded = URLEncoder.encode(element, UTF_8); - builder.append(encoded); - } - catch (UnsupportedEncodingException ex) - { - OM.LOG.error(ex); - return null; - } - } - - return builder.toString(); - } - - @Override - protected String[] convert(String value) - { - String[] array = value.split(SEPARATOR); - if (array.length == 0) - { - return Preferences.DEFAULT_ARRAY; - } - - for (int i = 0; i < array.length; i++) - { - try - { - array[i] = URLDecoder.decode(array[i].trim(), UTF_8); - } - catch (UnsupportedEncodingException ex) - { - OM.LOG.error(ex); - return null; - } - } - - return array; - } - - public Type getType() - { - return Type.ARRAY; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BooleanPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BooleanPreference.java deleted file mode 100644 index 4e6f605c40..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BooleanPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class BooleanPreference extends Preference<Boolean> implements OMPreference<Boolean> -{ - public BooleanPreference(Preferences preferences, String name, Boolean defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return Boolean.toString(getValue()); - } - - @Override - protected Boolean convert(String value) - { - return Boolean.parseBoolean(value); - } - - public Type getType() - { - return Type.BOOLEAN; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BytesPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BytesPreference.java deleted file mode 100644 index 6274af3797..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/BytesPreference.java +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.HexUtil; -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class BytesPreference extends Preference<byte[]> implements OMPreference<byte[]> -{ - public BytesPreference(Preferences preferences, String name, byte[] defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return HexUtil.bytesToHex(getValue()); - } - - @Override - protected byte[] convert(String value) - { - return HexUtil.hexToBytes(value); - } - - public Type getType() - { - return Type.BYTES; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/DoublePreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/DoublePreference.java deleted file mode 100644 index 4627a6d25c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/DoublePreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class DoublePreference extends Preference<Double> implements OMPreference<Double> -{ - public DoublePreference(Preferences preferences, String name, Double defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return Double.toString(getValue()); - } - - @Override - protected Double convert(String value) - { - return Double.parseDouble(value); - } - - public Type getType() - { - return Type.DOUBLE; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/FloatPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/FloatPreference.java deleted file mode 100644 index 87358297b1..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/FloatPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class FloatPreference extends Preference<Float> implements OMPreference<Float> -{ - public FloatPreference(Preferences preferences, String name, Float defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return Float.toString(getValue()); - } - - @Override - protected Float convert(String value) - { - return Float.parseFloat(value); - } - - public Type getType() - { - return Type.FLOAT; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/IntegerPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/IntegerPreference.java deleted file mode 100644 index b6df91c48c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/IntegerPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class IntegerPreference extends Preference<Integer> implements OMPreference<Integer> -{ - public IntegerPreference(Preferences preferences, String name, Integer defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return Integer.toString(getValue()); - } - - @Override - protected Integer convert(String value) - { - return Integer.parseInt(value); - } - - public Type getType() - { - return Type.INTEGER; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/LongPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/LongPreference.java deleted file mode 100644 index 6cbad27c33..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/LongPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class LongPreference extends Preference<Long> implements OMPreference<Long> -{ - public LongPreference(Preferences preferences, String name, Long defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return Long.toString(getValue()); - } - - @Override - protected Long convert(String value) - { - return Long.parseLong(value); - } - - public Type getType() - { - return Type.LONG; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preference.java deleted file mode 100644 index a1ea18c378..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preference.java +++ /dev/null @@ -1,121 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public abstract class Preference<T> implements OMPreference<T> -{ - private Preferences preferences; - - private String name; - - private T defaultValue; - - private T value; - - public Preference(Preferences preferences, String name, T defaultValue) - { - if (defaultValue == null) - { - throw new IllegalArgumentException("defaultValue == null"); - } - - this.preferences = preferences; - this.name = name; - this.defaultValue = defaultValue; - } - - public Preferences getPreferences() - { - return preferences; - } - - public String getName() - { - return name; - } - - public T getDefaultValue() - { - return defaultValue; - } - - public T getValue() - { - load(); - return value; - } - - public T setValue(T value) - { - if (value == null) - { - throw new IllegalArgumentException("value == null"); - } - - load(); - T oldValue = this.value; - if (!equals(oldValue, value)) - { - if (equals(defaultValue, value)) - { - value = defaultValue; - } - - this.value = value; - preferences.fireChangeEvent(this, oldValue, value); - return oldValue; - } - - return null; - } - - public boolean isSet() - { - return !equals(defaultValue, value); - } - - public T unSet() - { - return setValue(defaultValue); - } - - protected boolean equals(T v1, T v2) - { - return ObjectUtil.equals(v1, v2); - } - - protected void init(String value) - { - if (value == null) - { - this.value = defaultValue; - } - else - { - this.value = convert(value); - } - } - - protected abstract T convert(String value); - - protected abstract String getString(); - - private void load() - { - preferences.load(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java deleted file mode 100644 index ab8910c4e7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java +++ /dev/null @@ -1,292 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.internal.util.bundle.AbstractBundle; -import org.eclipse.net4j.internal.util.event.Notifier; -import org.eclipse.net4j.util.io.IORunnable; -import org.eclipse.net4j.util.io.IORuntimeException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.pref.OMPreference; -import org.eclipse.net4j.util.om.pref.OMPreferences; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -/** - * @author Eike Stepper - */ -public class Preferences extends Notifier implements OMPreferences -{ - private AbstractBundle bundle; - - private Map<String, Preference<?>> prefs = new HashMap<String, Preference<?>>(); - - private boolean loaded; - - private boolean dirty; - - public Preferences(AbstractBundle bundle) - { - this.bundle = bundle; - } - - public AbstractBundle getBundle() - { - return bundle; - } - - public synchronized void load() - { - if (!loaded) - { - loaded = true; - final Properties properties = new Properties(); - - File file = getFile(); - if (file.exists()) - { - IOUtil.safeInput(file, new IORunnable<FileInputStream>() - { - public void run(FileInputStream io) throws IOException - { - properties.load(io); - } - }); - } - - for (Preference<?> preference : prefs.values()) - { - String name = preference.getName(); - String value = properties.getProperty(name); - preference.init(value); - } - } - } - - public synchronized void save() - { - if (dirty) - { - final Properties properties = new Properties(); - for (Preference<?> preference : prefs.values()) - { - if (preference.isSet()) - { - String name = preference.getName(); - String value = preference.getString(); - if (value != null) - { - properties.put(name, value); - } - } - } - - File file = getFile(); - if (properties.isEmpty()) - { - if (file.exists()) - { - file.delete(); - } - } - else - { - IOUtil.safeOutput(file, new IORunnable<FileOutputStream>() - { - public void run(FileOutputStream io) throws IOException - { - properties.store(io, "Preferences of " + bundle.getBundleID()); - } - }); - } - - dirty = false; - } - } - - public boolean isDirty() - { - return dirty; - } - - public OMPreference<Boolean> init(String name, boolean defaultValue) - { - return init(new BooleanPreference(this, name, defaultValue)); - } - - public OMPreference<Integer> init(String name, int defaultValue) - { - return init(new IntegerPreference(this, name, defaultValue)); - } - - public OMPreference<Long> init(String name, long defaultValue) - { - return init(new LongPreference(this, name, defaultValue)); - } - - public OMPreference<Float> init(String name, float defaultValue) - { - return init(new FloatPreference(this, name, defaultValue)); - } - - public OMPreference<Double> init(String name, double defaultValue) - { - return init(new DoublePreference(this, name, defaultValue)); - } - - public OMPreference<String> init(String name, String defaultValue) - { - return init(new StringPreference(this, name, defaultValue)); - } - - public OMPreference<String[]> init(String name, String[] defaultValue) - { - return init(new ArrayPreference(this, name, defaultValue)); - } - - public OMPreference<byte[]> init(String name, byte[] defaultValue) - { - return init(new BytesPreference(this, name, defaultValue)); - } - - public OMPreference<Boolean> initBoolean(String name) - { - return init(name, DEFAULT_BOOLEAN); - } - - public OMPreference<Integer> initInteger(String name) - { - return init(name, DEFAULT_INTEGER); - } - - public OMPreference<Long> initLong(String name) - { - return init(name, DEFAULT_LONG); - } - - public OMPreference<Float> initFloat(String name) - { - return init(name, DEFAULT_FLOAT); - } - - public OMPreference<Double> initDouble(String name) - { - return init(name, DEFAULT_DOUBLE); - } - - public OMPreference<String> initString(String name) - { - return init(name, DEFAULT_STRING); - } - - public OMPreference<String[]> initArray(String name) - { - return init(name, DEFAULT_ARRAY); - } - - public OMPreference<byte[]> initBytes(String name) - { - return init(name, DEFAULT_BYTES); - } - - public boolean contains(String name) - { - return prefs.containsKey(name); - } - - public OMPreference<?> get(String name) - { - return prefs.get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<Boolean> getBoolean(String name) - { - return (OMPreference<Boolean>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<Integer> getInteger(String name) - { - return (OMPreference<Integer>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<Long> getLong(String name) - { - return (OMPreference<Long>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<Float> getFloat(String name) - { - return (OMPreference<Float>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<Double> getDouble(String name) - { - return (OMPreference<Double>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<String> getString(String name) - { - return (OMPreference<String>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<String[]> getArray(String name) - { - return (OMPreference<String[]>)get(name); - } - - @SuppressWarnings("unchecked") - public OMPreference<byte[]> getBytes(String name) - { - return (OMPreference<byte[]>)get(name); - } - - public <T> void fireChangeEvent(Preference<T> preference, T oldValue, T newValue) - { - dirty = true; - fireEvent(new PreferencesChangeEvent<T>(preference, oldValue, newValue)); - } - - private <T> OMPreference<T> init(Preference<T> preference) - { - String name = preference.getName(); - if (prefs.containsKey(name)) - { - throw new IllegalArgumentException("Duplicate name: " + name); - } - - prefs.put(name, preference); - return preference; - } - - private File getFile() - { - File file = new File(bundle.getStateLocation(), ".prefs"); - if (file.exists() && !file.isFile()) - { - throw new IORuntimeException("Not a file: " + file.getAbsolutePath()); - } - - return file; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/PreferencesChangeEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/PreferencesChangeEvent.java deleted file mode 100644 index d2ae7da465..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/PreferencesChangeEvent.java +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.internal.util.event.Event; -import org.eclipse.net4j.util.om.pref.OMPreferencesChangeEvent; - -/** - * @author Eike Stepper - */ -public final class PreferencesChangeEvent<T> extends Event implements OMPreferencesChangeEvent<T> -{ - private static final long serialVersionUID = 1L; - - private Preference<T> preference; - - private T oldValue; - - private T newValue; - - public PreferencesChangeEvent(Preference<T> preference, T oldValue, T newValue) - { - super(preference.getPreferences()); - this.preference = preference; - this.oldValue = oldValue; - this.newValue = newValue; - } - - @Override - public Preferences getSource() - { - return (Preferences)super.getSource(); - } - - public Preference<T> getPreference() - { - return preference; - } - - public T getOldValue() - { - return oldValue; - } - - public T getNewValue() - { - return newValue; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/StringPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/StringPreference.java deleted file mode 100644 index 7a9e9dc07e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/StringPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.pref; - -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class StringPreference extends Preference<String> implements OMPreference<String> -{ - public StringPreference(Preferences preferences, String name, String defaultValue) - { - super(preferences, name, defaultValue); - } - - @Override - protected String getString() - { - return getValue(); - } - - @Override - protected String convert(String value) - { - return value; - } - - public Type getType() - { - return Type.STRING; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/ContextTracer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/ContextTracer.java deleted file mode 100644 index 838ccb63a7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/ContextTracer.java +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.trace.OMTracer; - -/** - * @author Eike Stepper - */ -public class ContextTracer -{ - private OMTracer delegate; - - private Class<?> context; - - public ContextTracer(OMTracer delegate, Class<?> context) - { - this.delegate = delegate; - this.context = context; - } - - public OMBundle getBundle() - { - return delegate.getBundle(); - } - - public String getFullName() - { - return delegate.getFullName(); - } - - public String getName() - { - return delegate.getName(); - } - - public OMTracer getDelegate() - { - return delegate; - } - - public OMTracer getParent() - { - return delegate.getParent(); - } - - public boolean isEnabled() - { - return delegate.isEnabled(); - } - - public void setEnabled(boolean enabled) - { - delegate.setEnabled(enabled); - } - - public void format(String pattern, Object... args) - { - delegate.format(context, pattern, args); - } - - public void format(String pattern, Throwable t, Object... args) - { - delegate.format(context, pattern, t, args); - } - - public void trace(String msg, Throwable t) - { - delegate.trace(context, msg, t); - } - - public void trace(String msg) - { - delegate.trace(context, msg); - } - - public void trace(Throwable t) - { - delegate.trace(context, t); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PerfTracer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PerfTracer.java deleted file mode 100644 index 2fd536bb74..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PerfTracer.java +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class PerfTracer extends ContextTracer -{ - public static final long NOT_STARTED = 0L; - - private ConcurrentMap<Object, Long> timers = new ConcurrentHashMap<Object, Long>(); - - public PerfTracer(OMTracer delegate, Class<?> context) - { - super(delegate, context); - } - - public void start(Object object) - { - if (isEnabled()) - { - timers.put(object, System.currentTimeMillis()); - } - } - - public long stop(Object object) - { - long duration = NOT_STARTED; - if (isEnabled()) - { - Long timer = timers.remove(object); - if (timer != null) - { - duration = System.currentTimeMillis() - timer; - format("{0} = {1} millis", object, duration); - } - } - - return duration; - } - - public long getDuration(Object object) - { - long duration = NOT_STARTED; - if (isEnabled()) - { - Long timer = timers.get(object); - if (timer != null) - { - duration = System.currentTimeMillis() - timer; - } - } - - return duration; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PrintTraceHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PrintTraceHandler.java deleted file mode 100644 index 0696770351..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/PrintTraceHandler.java +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.trace.OMTraceHandler; -import org.eclipse.net4j.util.om.trace.OMTraceHandlerEvent; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.io.PrintStream; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class PrintTraceHandler implements OMTraceHandler -{ - public static final PrintTraceHandler CONSOLE = new PrintTraceHandler(); - - private PrintStream stream; - - private String pattern; - - private boolean shortContext; - - public PrintTraceHandler(PrintStream stream) - { - this.stream = stream; - } - - protected PrintTraceHandler() - { - this(IOUtil.OUT()); - } - - public String getPattern() - { - return pattern; - } - - /** - * Pattern arguments: - * <p> - * <ul> - * <li>{0} --> String <b>tracerName</b><br> - * <li>{1} --> String <b>tracerShort</b><br> - * <li>{2} --> String <b>contextName</b><br> - * <li>{3} --> String <b>contextShort</b><br> - * <li>{4} --> long <b>timeStamp</b><br> - * <li>{5} --> String <b>message</b><br> - * <li>{6} --> String <b>threadName</b><br> - * <li>{7} --> long <b>threadID</b><br> - * <li>{8} --> int <b>threadPriority</b><br> - * <li>{9} --> Thread.State <b>threadState</b><br> - * </ul> - */ - public void setPattern(String pattern) - { - this.pattern = pattern; - } - - public boolean isShortContext() - { - return shortContext; - } - - public void setShortContext(boolean shortContext) - { - this.shortContext = shortContext; - } - - public void traced(OMTraceHandlerEvent event) - { - String line = pattern == null ? format(shortContext, event) : format(pattern, event); - stream.println(line); - if (event.getThrowable() != null) - { - IOUtil.print(event.getThrowable(), stream); - } - } - - public static String format(boolean shortContext, OMTraceHandlerEvent event) - { - Class<?> context = event.getContext(); - String contextName = shortContext ? context.getSimpleName() : context.getName(); - return Thread.currentThread().getName() + " [" + contextName + "] " + event.getMessage(); - } - - /** - * Pattern arguments: - * <p> - * <ul> - * <li>{0} --> String <b>tracerName</b><br> - * <li>{1} --> String <b>tracerShort</b><br> - * <li>{2} --> String <b>contextName</b><br> - * <li>{3} --> String <b>contextShort</b><br> - * <li>{4} --> long <b>timeStamp</b><br> - * <li>{5} --> String <b>message</b><br> - * <li>{6} --> String <b>threadName</b><br> - * <li>{7} --> long <b>threadID</b><br> - * <li>{8} --> int <b>threadPriority</b><br> - * <li>{9} --> Thread.State <b>threadState</b><br> - * </ul> - */ - public static String format(String pattern, OMTraceHandlerEvent event) - { - final OMTracer tracer = event.getTracer(); - final String tracerName = tracer.getFullName(); - final String tracerShort = tracer.getName(); - - final Class<?> context = event.getContext(); - final String contextName = context.getName(); - final String contextShort = context.getName(); - - final long timeStamp = event.getTimeStamp(); - final String message = event.getMessage(); - - final Thread thread = Thread.currentThread(); - final String threadName = thread.getName(); - final long threadID = thread.getId(); - final int threadPriority = thread.getPriority(); - final Thread.State threadState = thread.getState(); - - return MessageFormat.format(pattern, tracerName, tracerShort, contextName, contextShort, timeStamp, message, - threadName, threadID, threadPriority, threadState); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceHandler.java deleted file mode 100644 index 50f0299e23..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceHandler.java +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.om.trace.OMTraceHandler; -import org.eclipse.net4j.util.om.trace.OMTraceHandlerEvent; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.Socket; -import java.util.UUID; - -/** - * @author Eike Stepper - */ -public class RemoteTraceHandler implements OMTraceHandler -{ - public static final String DEFAULT_HOST = "localhost"; //$NON-NLS-1$ - - public static final int DEFAULT_PORT = RemoteTraceServer.DEFAULT_PORT; - - private static int uniqueCounter; - - private String agentID; - - private String host; - - private int port; - - private Socket socket; - - public RemoteTraceHandler() throws IOException - { - this(uniqueAgentID()); - } - - public RemoteTraceHandler(String agentID) throws IOException - { - this(agentID, DEFAULT_HOST); - } - - public RemoteTraceHandler(String agentID, String host) throws IOException - { - this(agentID, host, DEFAULT_PORT); - } - - public RemoteTraceHandler(String agentID, String host, int port) throws IOException - { - this.agentID = agentID; - this.host = host; - this.port = port; - socket = connect(); - } - - public Exception close() - { - try - { - socket.close(); - return null; - } - catch (IOException ex) - { - OM.LOG.error(ex); - return ex; - } - } - - public void traced(OMTraceHandlerEvent event) - { - try - { - OutputStream outputStream = socket.getOutputStream(); - DataOutputStream out = new DataOutputStream(outputStream); - - out.writeLong(event.getTimeStamp()); - writeUTF(out, agentID); - writeUTF(out, event.getTracer().getBundle().getBundleID()); - writeUTF(out, event.getTracer().getFullName()); - writeUTF(out, event.getContext() == null ? "" : event.getContext().getName()); - writeUTF(out, event.getMessage()); - if (event.getThrowable() == null) - { - out.writeBoolean(false); - } - else - { - out.writeBoolean(true); - String message = event.getThrowable().getMessage(); - writeUTF(out, message); - - StackTraceElement[] stackTrace = event.getThrowable().getStackTrace(); - int size = stackTrace == null ? 0 : stackTrace.length; - out.writeInt(size); - - for (int i = 0; i < size; i++) - { - StackTraceElement element = stackTrace[i]; - writeUTF(out, element.getClassName()); - writeUTF(out, element.getMethodName()); - writeUTF(out, element.getFileName()); - out.writeInt(element.getLineNumber()); - } - } - - out.flush(); - } - catch (IOException ex) - { - IOUtil.print(ex); - } - } - - protected Socket connect() throws IOException - { - return new Socket(host, port); - } - - protected void writeUTF(DataOutputStream out, String str) throws IOException - { - out.writeUTF(str == null ? "" : str); - } - - public static String uniqueAgentID() - { - try - { - InetAddress localMachine = InetAddress.getLocalHost(); - return localMachine.getHostName() + "#" + ++uniqueCounter; - } - catch (Exception ex) - { - UUID uuid = UUID.randomUUID(); - return uuid.toString(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceServer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceServer.java deleted file mode 100644 index 953aba0854..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/RemoteTraceServer.java +++ /dev/null @@ -1,389 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.util.io.IOUtil; - -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Date; -import java.util.EventObject; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @author Eike Stepper - */ -public class RemoteTraceServer -{ - public static final String DEFAULT_ADDRESS = "0.0.0.0"; //$NON-NLS-1$ - - public static final int DEFAULT_PORT = 2035; - - public static final int ANY_PORT = 0; - - private static long lastEventID = 0; - - private int port; - - private String address; - - private ServerSocket serverSocket; - - private Queue<Listener> listeners = new ConcurrentLinkedQueue<Listener>(); - - public RemoteTraceServer() throws IOException - { - this(DEFAULT_PORT); - } - - public RemoteTraceServer(int port) throws IOException - { - this(port, DEFAULT_ADDRESS); - } - - public RemoteTraceServer(int port, String address) throws IOException - { - this.port = port; - this.address = address; - serverSocket = bind(); - new Thread("RemoteTraceServer") - { - @Override - public void run() - { - handleConnections(); - } - }.start(); - } - - public void addListener(Listener listener) - { - if (!listeners.contains(listener)) - { - listeners.add(listener); - } - } - - public void removeListener(Listener listener) - { - listeners.remove(listener); - } - - public Exception close() - { - try - { - serverSocket.close(); - return null; - } - catch (IOException ex) - { - OM.LOG.error(ex); - return ex; - } - } - - protected ServerSocket bind() throws IOException - { - InetAddress addr = InetAddress.getByName(this.address); - return new ServerSocket(port, 5, addr); - } - - protected void handleConnections() - { - for (;;) - { - try - { - final Socket socket = serverSocket.accept(); - new Thread() - { - @Override - public void run() - { - handleSession(socket); - } - }.start(); - } - catch (IOException ex) - { - if (!serverSocket.isClosed()) - { - IOUtil.print(ex); - } - - break; - } - } - } - - protected void handleSession(Socket socket) - { - try - { - InputStream inputStream = socket.getInputStream(); - DataInputStream in = new DataInputStream(inputStream); - - for (;;) - { - handleTrace(in); - } - } - catch (IOException ex) - { - IOUtil.print(ex); - } - } - - protected void handleTrace(DataInputStream in) throws IOException - { - Event event = new Event(); - event.timeStamp = in.readLong(); - event.agentID = in.readUTF(); - event.bundleID = in.readUTF(); - event.tracerName = in.readUTF(); - event.context = in.readUTF(); - event.message = in.readUTF(); - if (in.readBoolean()) - { - event.throwable = in.readUTF(); - int size = in.readInt(); - event.stackTrace = new StackTraceElement[size]; - for (int i = 0; i < size; i++) - { - String className = in.readUTF(); - String methodName = in.readUTF(); - String fileName = in.readUTF(); - int lineNumber = in.readInt(); - event.stackTrace[i] = new StackTraceElement(className, methodName, fileName, lineNumber); - } - } - - fireEvent(event); - } - - protected void fireEvent(Event event) - { - for (Listener listener : listeners) - { - try - { - listener.notifyRemoteTrace(event); - } - catch (RuntimeException ex) - { - IOUtil.print(ex); - } - } - } - - /** - * @author Eike Stepper - */ - public class Event extends EventObject - { - private static final long serialVersionUID = 1L; - - private long id; - - long timeStamp; - - String agentID; - - String bundleID; - - String tracerName; - - String context; - - String message; - - String throwable; - - StackTraceElement[] stackTrace; - - Event() - { - super(RemoteTraceServer.this); - id = ++lastEventID; - } - - public RemoteTraceServer getRemoteTraceServer() - { - return (RemoteTraceServer)source; - } - - public long getID() - { - return id; - } - - public long getTimeStamp() - { - return timeStamp; - } - - public String getAgentID() - { - return agentID; - } - - public String getBundleID() - { - return bundleID; - } - - public String getContext() - { - return context; - } - - public String getMessage() - { - return message; - } - - public StackTraceElement[] getStackTrace() - { - return stackTrace; - } - - public String getThrowable() - { - return throwable; - } - - public String getTracerName() - { - return tracerName; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("TraceEvent[agentID="); - builder.append(agentID); - - builder.append(", bundleID="); - builder.append(bundleID); - - builder.append(", tracerName="); - builder.append(tracerName); - - builder.append(", context="); - builder.append(context); - - builder.append(", message="); - builder.append(message); - - builder.append(", throwable="); - builder.append(throwable); - - builder.append(", stackTrace="); - builder.append(stackTrace); - - builder.append("]"); - return builder.toString(); - } - - public String getText(int index) - { - switch (index) - { - case 0: - return Long.toString(id); - case 1: - return new Date(timeStamp).toString(); - case 2: - return agentID; - case 3: - return bundleID; - case 4: - return tracerName; - case 5: - return context; - case 6: - return message; - case 7: - return throwable; - } - - throw new IllegalArgumentException("Invalid index: " + index); - } - - public boolean hasError() - { - return throwable != null && throwable.length() != 0 // - || stackTrace != null && stackTrace.length != 0; - } - - } - - /** - * @author Eike Stepper - */ - public interface Listener - { - public void notifyRemoteTrace(Event event); - } - - public static class PrintListener implements Listener - { - public static final PrintListener CONSOLE = new PrintListener(); - - private PrintStream stream; - - public PrintListener(PrintStream stream) - { - this.stream = stream; - } - - protected PrintListener() - { - this(IOUtil.OUT()); - } - - public void notifyRemoteTrace(Event event) - { - stream.println("[TRACE] " + event.getAgentID()); - stream.println(event.getBundleID()); - stream.println(event.getTracerName()); - stream.println(event.getContext()); - stream.println(event.getMessage()); - - String throwable = event.getThrowable(); - if (throwable != null && throwable.length() != 0) - { - stream.println(throwable); - } - - StackTraceElement[] stackTrace = event.getStackTrace(); - if (stackTrace != null) for (StackTraceElement element : stackTrace) - { - stream.print(element.getClassName()); - stream.print("." + element.getMethodName()); - stream.print("(" + element.getFileName()); - stream.print(":" + element.getLineNumber()); - stream.println(")"); - } - - stream.println(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/TraceHandlerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/TraceHandlerEvent.java deleted file mode 100644 index 30253d1f10..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/TraceHandlerEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.util.om.trace.OMTraceHandlerEvent; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.io.Serializable; - -/** - * @author Eike Stepper - */ -public class TraceHandlerEvent implements OMTraceHandlerEvent, Serializable -{ - private static final long serialVersionUID = 1L; - - protected long timeStamp; - - protected OMTracer tracer; - - protected Class<?> context; - - protected String message; - - protected Throwable throwable; - - public TraceHandlerEvent(OMTracer tracer, Class<?> context, String message, Throwable throwable) - { - if (tracer == null) - { - throw new IllegalArgumentException("tracer == null"); - } - - if (context == null) - { - throw new IllegalArgumentException("context == null"); - } - - timeStamp = System.currentTimeMillis(); - this.tracer = tracer; - this.context = context; - this.message = message; - this.throwable = throwable; - } - - public long getTimeStamp() - { - return timeStamp; - } - - public OMTracer getTracer() - { - return tracer; - } - - public Class<?> getContext() - { - return context; - } - - public String getMessage() - { - return message; - } - - public Throwable getThrowable() - { - return throwable; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/Tracer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/Tracer.java deleted file mode 100644 index a491d8caf0..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/trace/Tracer.java +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.om.trace; - -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMBundle.DebugSupport; -import org.eclipse.net4j.util.om.trace.OMTraceHandlerEvent; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class Tracer implements OMTracer -{ - private OMBundle bundle; - - private Tracer parent; - - private String name; - - private String fullName; - - public Tracer(OMBundle bundle, String name) - { - this.bundle = bundle; - this.name = name; - fullName = name; - } - - private Tracer(Tracer parent, String name) - { - bundle = parent.getBundle(); - this.parent = parent; - this.name = name; - fullName = parent.getFullName() + "." + name; //$NON-NLS-1$ - } - - public OMBundle getBundle() - { - return bundle; - } - - public OMTracer getParent() - { - return parent; - } - - public String getName() - { - return name; - } - - public String getFullName() - { - return fullName; - } - - public boolean isEnabled() - { - DebugSupport debugSupport = bundle.getDebugSupport(); - return debugSupport.isDebugging() && debugSupport.getDebugOption(fullName, false); - } - - public void setEnabled(boolean enabled) - { - DebugSupport debugSupport = bundle.getDebugSupport(); - debugSupport.setDebugOption(fullName, enabled); - } - - public void trace(OMTraceHandlerEvent event) - { - ((AbstractPlatform)bundle.getPlatform()).trace(event); - } - - public OMTraceHandlerEvent trace(Class<?> context, String msg, Throwable t) - { - OMTraceHandlerEvent event = new TraceHandlerEvent(this, context, msg, t); - trace(event); - return event; - } - - public OMTraceHandlerEvent format(Class<?> context, String pattern, Throwable t, Object... args) - { - String msg = MessageFormat.format(pattern, args); - return trace(context, msg, t); - } - - public OMTraceHandlerEvent format(Class<?> context, String pattern, Object... args) - { - return format(context, pattern, (Throwable)null, args); - } - - public OMTraceHandlerEvent trace(Class<?> context, String msg) - { - return trace(context, msg, (Throwable)null); - } - - public OMTraceHandlerEvent trace(Class<?> context, Throwable t) - { - return trace(context, (String)null, t); - } - - public OMTracer tracer(String name) - { - return new Tracer(this, name); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/DelegatingRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/DelegatingRegistry.java deleted file mode 100644 index 46b7f91f12..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/DelegatingRegistry.java +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.registry; - -import org.eclipse.net4j.util.registry.IRegistry; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Implementation note: AbstractDelegatingRegistry does not preserve the "modifyable view" contract of - * {@link Map#entrySet()} as well as of {@link Map#keySet()}, i.e. they are disconnected sets and modifications applied - * to them are not applied to their underlying AbstractDelegatingRegistry. - * <p> - * - * @author Eike Stepper - */ -public abstract class DelegatingRegistry<K, V> extends Registry<K, V> -{ - private IRegistry<K, V> delegate; - - public DelegatingRegistry(IRegistry<K, V> delegate) - { - this.delegate = delegate; - } - - public DelegatingRegistry(IRegistry<K, V> delegate, boolean autoCommit) - { - super(autoCommit); - this.delegate = delegate; - } - - @Override - public V get(Object key) - { - V result = getMap().get(key); - if (result == null && delegate != null) - { - result = delegate.get(key); - } - - return result; - } - - @Override - public Set<Entry<K, V>> entrySet() - { - return mergedEntrySet(); - } - - @Override - public Set<K> keySet() - { - return mergedKeySet(); - } - - @Override - public Collection<V> values() - { - return mergedValues(); - } - - @Override - protected V register(K key, V value) - { - V delegated = delegate != null ? delegate.get(key) : null; - V old = getMap().put(key, value); - if (old == null) - { - if (delegated != null) - { - // Unhidden delegated element now becomes hidden - getTransaction().rememberDeregistered(key, delegated); - } - - getTransaction().rememberRegistered(key, value); - return delegated; - } - - getTransaction().rememberDeregistered(key, old); - getTransaction().rememberRegistered(key, value); - return old; - } - - @SuppressWarnings("unchecked") - @Override - protected V deregister(Object key) - { - V delegated = delegate != null ? delegate.get(key) : null; - V old = getMap().remove(key); - if (old != null) - { - getTransaction().rememberDeregistered((K)key, old); - if (delegated != null) - { - // Hidden delegated element now becomes unhidden - getTransaction().rememberRegistered((K)key, delegated); - } - } - - return old; - } - - protected Set<Entry<K, V>> mergedEntrySet() - { - final Map<K, V> merged = new HashMap<K, V>(); - if (delegate != null) - { - merged.putAll(delegate); - } - - merged.putAll(getMap()); - return merged.entrySet(); - } - - protected Set<K> mergedKeySet() - { - final Set<K> merged = new HashSet<K>(); - if (delegate != null) - { - merged.addAll(delegate.keySet()); - } - - merged.addAll(getMap().keySet()); - return merged; - } - - protected Collection<V> mergedValues() - { - final List<V> result = new ArrayList<V>(); - for (K key : keySet()) - { - result.add(get(key)); - } - - return result; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapDelegatingRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapDelegatingRegistry.java deleted file mode 100644 index b7ccd2e3f6..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapDelegatingRegistry.java +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.registry; - -import org.eclipse.net4j.util.registry.IRegistry; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class HashMapDelegatingRegistry<K, V> extends DelegatingRegistry<K, V> -{ - private Map<K, V> map; - - public HashMapDelegatingRegistry(IRegistry<K, V> delegate) - { - super(delegate); - map = new HashMap<K, V>(); - } - - public HashMapDelegatingRegistry(IRegistry<K, V> delegate, int initialCapacity) - { - super(delegate); - map = new HashMap<K, V>(initialCapacity); - } - - public HashMapDelegatingRegistry(IRegistry<K, V> delegate, int initialCapacity, float loadFactor) - { - super(delegate); - map = new HashMap<K, V>(initialCapacity, loadFactor); - } - - public HashMapDelegatingRegistry(IRegistry<K, V> delegate, Map<? extends K, ? extends V> m) - { - super(delegate); - map = new HashMap<K, V>(m); - } - - @Override - protected Map<K, V> getMap() - { - return map; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapRegistry.java deleted file mode 100644 index 9515fe0f6b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/HashMapRegistry.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.registry; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class HashMapRegistry<K, V> extends Registry<K, V> -{ - private Map<K, V> map; - - public HashMapRegistry() - { - map = new HashMap<K, V>(); - } - - public HashMapRegistry(int initialCapacity) - { - map = new HashMap<K, V>(initialCapacity); - } - - public HashMapRegistry(int initialCapacity, float loadFactor) - { - map = new HashMap<K, V>(initialCapacity, loadFactor); - } - - public HashMapRegistry(Map<? extends K, ? extends V> m) - { - map = new HashMap<K, V>(m); - } - - @Override - protected Map<K, V> getMap() - { - return map; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java deleted file mode 100644 index 9b692dc1e3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/Registry.java +++ /dev/null @@ -1,328 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.registry; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.container.Container; -import org.eclipse.net4j.internal.util.container.ContainerEvent; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.registry.IRegistry; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class Registry<K, V> extends Container<Map.Entry<K, V>> implements IRegistry<K, V> -{ - private boolean autoCommit; - - private Transaction transaction; - - protected Registry(boolean autoCommit) - { - this.autoCommit = autoCommit; - } - - protected Registry() - { - this(true); - } - - @Override - public boolean isEmpty() - { - return keySet().isEmpty(); - } - - public int size() - { - return keySet().size(); - } - - public Set<Entry<K, V>> entrySet() - { - return getMap().entrySet(); - } - - public Set<K> keySet() - { - return getMap().keySet(); - } - - public Collection<V> values() - { - return getMap().values(); - } - - public boolean containsKey(Object key) - { - return keySet().contains(key); - } - - public boolean containsValue(Object value) - { - return values().contains(value); - } - - public V get(Object key) - { - return getMap().get(key); - } - - /** - * Requires {@link #commit()} to be called later if not {@link #isAutoCommit()}. - */ - public synchronized V put(K key, V value) - { - V result = register(key, value); - autoCommit(); - return result; - } - - /** - * Requires {@link #commit()} to be called later if not {@link #isAutoCommit()}. - */ - public synchronized void putAll(Map<? extends K, ? extends V> t) - { - if (!t.isEmpty()) - { - Iterator<? extends Entry<? extends K, ? extends V>> i = t.entrySet().iterator(); - while (i.hasNext()) - { - Entry<? extends K, ? extends V> e = i.next(); - register(e.getKey(), e.getValue()); - } - - autoCommit(); - } - } - - /** - * Requires {@link #commit()} to be called later if not {@link #isAutoCommit()}. - */ - public synchronized V remove(Object key) - { - V result = deregister(key); - autoCommit(); - return result; - } - - /** - * Requires {@link #commit()} to be called later if not {@link #isAutoCommit()}. - */ - public synchronized void clear() - { - if (!isEmpty()) - { - for (Object key : keySet().toArray()) - { - deregister(key); - } - - autoCommit(); - } - } - - @SuppressWarnings("unchecked") - public Entry<K, V>[] getElements() - { - return entrySet().toArray(new Entry[size()]); - } - - public boolean isAutoCommit() - { - return autoCommit; - } - - public void setAutoCommit(boolean autoCommit) - { - this.autoCommit = autoCommit; - } - - public synchronized void commit(boolean notifications) - { - if (transaction != null) - { - if (!transaction.isOwned()) - { - OM.LOG.warn("Committing thread is not owner of transaction: " + Thread.currentThread()); - } - - transaction.commit(notifications); - transaction = null; - notifyAll(); - } - } - - public void commit() - { - commit(true); - } - - @Override - public String toString() - { - return getMap().toString(); - } - - protected V register(K key, V value) - { - Transaction transaction = getTransaction(); - V oldValue = getMap().put(key, value); - if (oldValue != null) - { - transaction.rememberDeregistered(key, oldValue); - } - - transaction.rememberRegistered(key, value); - return oldValue; - } - - @SuppressWarnings("unchecked") - protected V deregister(Object key) - { - V value = getMap().remove(key); - if (value != null) - { - getTransaction().rememberDeregistered((K)key, value); - } - - return value; - } - - protected Transaction getTransaction() - { - for (;;) - { - if (transaction == null) - { - transaction = new Transaction(); - return transaction; - } - - if (transaction.isOwned()) - { - transaction.increaseNesting(); - return transaction; - } - - try - { - wait(); - } - catch (InterruptedException ex) - { - return null; - } - } - } - - protected void autoCommit() - { - if (autoCommit) - { - commit(); - } - } - - protected abstract Map<K, V> getMap(); - - /** - * @author Eike Stepper - */ - protected class Transaction - { - private int nesting = 1; - - private ContainerEvent<Map.Entry<K, V>> event; - - private Thread owner; - - public Transaction() - { - owner = Thread.currentThread(); - initEvent(); - } - - private void initEvent() - { - event = newContainerEvent(); - } - - public boolean isOwned() - { - return owner == Thread.currentThread(); - } - - public void increaseNesting() - { - ++nesting; - } - - public void commit(boolean notifications) - { - if (--nesting == 0) - { - if (notifications && !event.isEmpty()) - { - fireEvent(event); - } - - initEvent(); - } - } - - public void rememberRegistered(K key, V value) - { - event.addDelta(new Element<K, V>(key, value), IContainerDelta.Kind.ADDED); - } - - public void rememberDeregistered(K key, V value) - { - event.addDelta(new Element<K, V>(key, value), IContainerDelta.Kind.REMOVED); - } - } - - /** - * @author Eike Stepper - */ - private static final class Element<K, V> implements Map.Entry<K, V> - { - private final K key; - - private final V value; - - private Element(K key, V value) - { - this.key = key; - this.value = value; - } - - public K getKey() - { - return key; - } - - public V getValue() - { - return value; - } - - public V setValue(V value) - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/UnmodifiableRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/UnmodifiableRegistry.java deleted file mode 100644 index 84fb9a4576..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/registry/UnmodifiableRegistry.java +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.registry; - -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.registry.IRegistry; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -public class UnmodifiableRegistry<K, V> implements IRegistry<K, V> -{ - private IRegistry<K, V> delegate; - - public UnmodifiableRegistry(IRegistry<K, V> delegate) - { - this.delegate = delegate; - } - - public void addListener(IListener listener) - { - delegate.addListener(listener); - } - - public void removeListener(IListener listener) - { - delegate.removeListener(listener); - } - - public V put(K key, V value) - { - throw new UnsupportedOperationException(); - } - - public void putAll(Map<? extends K, ? extends V> t) - { - throw new UnsupportedOperationException(); - } - - public V remove(Object key) - { - throw new UnsupportedOperationException(); - } - - public void clear() - { - throw new UnsupportedOperationException(); - } - - public void commit() - { - throw new UnsupportedOperationException(); - } - - public void commit(boolean notifications) - { - throw new UnsupportedOperationException(); - } - - public void setAutoCommit(boolean on) - { - throw new UnsupportedOperationException(); - } - - public boolean isAutoCommit() - { - return delegate.isAutoCommit(); - } - - public boolean isEmpty() - { - return delegate.isEmpty(); - } - - public int size() - { - return delegate.size(); - } - - public Entry<K, V>[] getElements() - { - return delegate.getElements(); - } - - public V get(Object key) - { - return delegate.get(key); - } - - public boolean containsKey(Object key) - { - return delegate.containsKey(key); - } - - public boolean containsValue(Object value) - { - return delegate.containsValue(value); - } - - public Set<Entry<K, V>> entrySet() - { - return delegate.entrySet(); - } - - public Set<K> keySet() - { - return delegate.keySet(); - } - - public Collection<V> values() - { - return delegate.values(); - } - - public boolean equals(Object o) - { - return delegate.equals(o); - } - - public int hashCode() - { - return delegate.hashCode(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiator.java deleted file mode 100644 index adad8a793c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiator.java +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.security.INegotiationContext; -import org.eclipse.net4j.util.security.IRandomizer; -import org.eclipse.net4j.util.security.IUserManager; - -import java.nio.ByteBuffer; -import java.util.Arrays; - -/** - * @author Eike Stepper - */ -public class ChallengeNegotiator extends ChallengeResponseNegotiator -{ - public static final int DEFAULT_TOKEN_LENGTH = 1024; - - private int tokenLength = DEFAULT_TOKEN_LENGTH; - - private IRandomizer randomizer; - - private IUserManager userManager; - - public ChallengeNegotiator() - { - super(true); - } - - public int getTokenLength() - { - return tokenLength; - } - - public void setTokenLength(int tokenLength) - { - this.tokenLength = tokenLength; - } - - public IRandomizer getRandomizer() - { - return randomizer; - } - - public void setRandomizer(IRandomizer randomizer) - { - this.randomizer = randomizer; - } - - public IUserManager getUserManager() - { - return userManager; - } - - public void setUserManager(IUserManager userManager) - { - this.userManager = userManager; - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (tokenLength <= 0) - { - throw new IllegalStateException("tokenLength must be positive"); - } - - if (randomizer == null) - { - throw new IllegalStateException("randomizer == null"); - } - - if (userManager == null) - { - throw new IllegalStateException("userManager == null"); - } - } - - protected byte[] createRandomToken() - { - byte[] token = new byte[tokenLength]; - randomizer.nextBytes(token); - return token; - } - - protected byte[] encryptToken(String userID, byte[] token) throws SecurityException - { - return userManager.encrypt(userID, token, getAlgorithmName()); - } - - @Override - protected void createChallenge(INegotiationContext context, ByteBuffer challenge) - { - // Create and remember a random token - byte[] randomToken = createRandomToken(); - context.setInfo(randomToken); - - // Set the token into challenge - challenge.putInt(randomToken.length); - challenge.put(randomToken); - } - - @Override - protected void handleChallenge(INegotiationContext context, ByteBuffer challenge, ByteBuffer response) - { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean handleResponse(INegotiationContext context, ByteBuffer response) - { - // Get remembered random token - byte[] randomToken = (byte[])context.getInfo(); - - // Get userID from response - int size = response.getInt(); - byte[] userIDBytes = new byte[size]; - response.get(userIDBytes); - String userID = new String(userIDBytes); - - // Get crypted token from response - size = response.getInt(); - byte[] responseToken = new byte[size]; - response.get(responseToken); - - // Encrypt the remembered token and compare to crypted token from response - byte[] cryptedToken = encryptToken(userID, randomToken); - boolean success = Arrays.equals(responseToken, cryptedToken); - if (success) - { - context.setUserID(userID); - } - - return success; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java deleted file mode 100644 index 234091d592..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorConfigurer.java +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.security.IRandomizer; -import org.eclipse.net4j.util.security.IUserManager; - -/** - * @author Eike Stepper - */ -public class ChallengeNegotiatorConfigurer implements IElementProcessor -{ - public ChallengeNegotiatorConfigurer() - { - } - - public Object process(IManagedContainer container, String productGroup, String factoryType, String description, - Object element) - { - if (element instanceof ChallengeNegotiator) - { - ChallengeNegotiator negotiator = (ChallengeNegotiator)element; - if (negotiator.getRandomizer() == null) - { - IRandomizer randomizer = getRandomizer(container, description); - negotiator.setRandomizer(randomizer); - } - - if (negotiator.getUserManager() == null) - { - IUserManager userManager = getUserManager(container, description); - negotiator.setUserManager(userManager); - } - } - - return element; - } - - protected IRandomizer getRandomizer(IManagedContainer container, String description) - { - String productGroup = RandomizerFactory.PRODUCT_GROUP; - String type = getRandomizerType(description); - return (IRandomizer)container.getElement(productGroup, type, getRandomizerDescription(description)); - } - - protected String getRandomizerType(String description) - { - return RandomizerFactory.TYPE; - } - - protected String getRandomizerDescription(String description) - { - return null; - } - - protected IUserManager getUserManager(IManagedContainer container, String description) - { - String productGroup = FileUserManagerFactory.PRODUCT_GROUP; - String type = getUserManagerType(description); - return (IUserManager)container.getElement(productGroup, type, getUserManagerDescription(description)); - } - - protected String getUserManagerType(String description) - { - return FileUserManagerFactory.TYPE; - } - - protected String getUserManagerDescription(String description) - { - return description; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java deleted file mode 100644 index 7e48893eb2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeNegotiatorFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -/** - * @author Eike Stepper - */ -public class ChallengeNegotiatorFactory extends NegotiatorFactory -{ - public static final String TYPE = "challenge"; - - public ChallengeNegotiatorFactory() - { - super(TYPE); - } - - public ChallengeNegotiator create(String description) - { - return new ChallengeNegotiator(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeResponseNegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeResponseNegotiator.java deleted file mode 100644 index df841c5e4d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ChallengeResponseNegotiator.java +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.fsm.ITransition; -import org.eclipse.net4j.util.security.IChallengeResponse; -import org.eclipse.net4j.util.security.INegotiationContext; -import org.eclipse.net4j.util.security.SecurityUtil; - -import java.nio.ByteBuffer; - -/** - * @author Eike Stepper - */ -public abstract class ChallengeResponseNegotiator extends - Negotiator<IChallengeResponse.State, IChallengeResponse.Event> implements IChallengeResponse -{ - public static final String DEFAULT_ALGORITHM_NAME = SecurityUtil.PBE_WITH_MD5_AND_DES; - - private String algorithmName = DEFAULT_ALGORITHM_NAME; - - public ChallengeResponseNegotiator(boolean initiator) - { - super(State.class, Event.class, State.INITIAL, State.SUCCESS, State.FAILURE, Event.START, Event.BUFFER, initiator); - - init(State.INITIAL, Event.START, new Transition() - { - @Override - protected void execute(INegotiationContext context, ByteBuffer NULL) - { - // Create and transmit challenge - ByteBuffer challenge = context.getBuffer(); - createChallenge(context, challenge); - context.transmitBuffer(challenge); - - // Set context state - changeState(context, State.CHALLENGE); - } - }); - - init(State.INITIAL, Event.BUFFER, new Transition() - { - @Override - protected void execute(INegotiationContext context, ByteBuffer challenge) - { - // Handle challenge and transmit response - ByteBuffer response = context.getBuffer(); - handleChallenge(context, challenge, response); - context.transmitBuffer(response); - - // Set context state - changeState(context, State.RESPONSE); - } - }); - - init(State.CHALLENGE, Event.BUFFER, new Transition() - { - @Override - protected void execute(INegotiationContext context, ByteBuffer response) - { - // Handle response - boolean success = handleResponse(context, response); - - // Transmit acknowledgement - ByteBuffer acknowledgement = context.getBuffer(); - acknowledgement.put(success ? ACKNOWLEDGE_SUCCESS : ACKNOWLEDGE_FAILURE); - context.transmitBuffer(acknowledgement); - - // Set context state - changeState(context, success ? State.SUCCESS : State.FAILURE); - } - }); - - init(State.RESPONSE, Event.BUFFER, new Transition() - { - @Override - protected void execute(INegotiationContext context, ByteBuffer acknowledgement) - { - // Handle acknowledgement - boolean success = acknowledgement.get() == ACKNOWLEDGE_SUCCESS; - - // Set context state - changeState(context, success ? State.SUCCESS : State.FAILURE); - } - }); - } - - public String getAlgorithmName() - { - return algorithmName; - } - - public void setAlgorithmName(String algorithmName) - { - this.algorithmName = algorithmName; - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (algorithmName == null) - { - throw new IllegalStateException("algorithmName == null"); - } - } - - @Override - protected State getState(INegotiationContext subject) - { - return (State)subject.getState(); - } - - @Override - protected void setState(INegotiationContext subject, State state) - { - subject.setState(state); - } - - protected abstract void createChallenge(INegotiationContext context, ByteBuffer challenge); - - protected abstract void handleChallenge(INegotiationContext context, ByteBuffer challenge, ByteBuffer response); - - protected abstract boolean handleResponse(INegotiationContext context, ByteBuffer response); - - /** - * @author Eike Stepper - */ - protected abstract class Transition implements ITransition<State, Event, INegotiationContext, ByteBuffer> - { - public final void execute(INegotiationContext context, State state, Event event, ByteBuffer buffer) - { - execute(context, buffer); - } - - protected abstract void execute(INegotiationContext context, ByteBuffer buffer); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Credentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Credentials.java deleted file mode 100644 index 01ed0852ae..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Credentials.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.security.ICredentials; - -/** - * @author Eike Stepper - */ -public class Credentials implements ICredentials -{ - private String userID; - - public Credentials(String userID) - { - this.userID = userID; - } - - public String getUserID() - { - return userID; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManager.java deleted file mode 100644 index 9007fbb682..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManager.java +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.io.IORuntimeException; -import org.eclipse.net4j.util.io.IOUtil; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.text.MessageFormat; -import java.util.Map; -import java.util.Properties; -import java.util.Map.Entry; - -/** - * @author Eike Stepper - */ -public class FileUserManager extends UserManager -{ - protected String fileName; - - public FileUserManager() - { - } - - public String getFileName() - { - return fileName; - } - - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (fileName == null) - { - throw new IllegalStateException("fileName == null"); - } - - File file = new File(fileName); - if (file.exists() && !file.isFile()) - { - throw new IllegalStateException("Not a file: " + fileName); - } - } - - @Override - protected void load(Map<String, char[]> users) throws IORuntimeException - { - File file = new File(fileName); - if (!file.exists()) - { - return; - } - - FileInputStream stream = IOUtil.openInputStream(new File(fileName)); - try - { - load(users, stream); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - IOUtil.closeSilent(stream); - } - } - - protected void load(Map<String, char[]> users, InputStream stream) throws IOException - { - Properties properties = new Properties(); - properties.load(stream); - for (Entry<Object, Object> entry : properties.entrySet()) - { - String userID = (String)entry.getKey(); - char[] password = ((String)entry.getValue()).toCharArray(); - users.put(userID, password); - } - } - - @Override - protected void save(Map<String, char[]> users) throws IORuntimeException - { - File file = new File(fileName); - if (!file.exists()) - { - return; - } - - FileOutputStream stream = IOUtil.openOutputStream(new File(fileName)); - try - { - save(users, stream); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - IOUtil.closeSilent(stream); - } - } - - protected void save(Map<String, char[]> users, FileOutputStream stream) throws IOException - { - Properties properties = new Properties(); - for (Entry<String, char[]> entry : users.entrySet()) - { - properties.put(entry.getKey(), new String(entry.getValue())); - } - - String comment = MessageFormat.format("User database {0,date} {0,time}", System.currentTimeMillis()); - properties.store(stream, comment); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java deleted file mode 100644 index 99c244e5a5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/FileUserManagerFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -/** - * TODO Consider file attributes when creating initially empty file - * - * @author Eike Stepper - */ -public class FileUserManagerFactory extends UserManagerFactory -{ - public static final String TYPE = "file"; - - public FileUserManagerFactory() - { - super(TYPE); - } - - public FileUserManager create(String description) - { - FileUserManager userManager = new FileUserManager(); - userManager.setFileName(description); - return userManager; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiationContext.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiationContext.java deleted file mode 100644 index a5e8c6b621..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiationContext.java +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.security.INegotiationContext; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public abstract class NegotiationContext implements INegotiationContext -{ - private Receiver receiver; - - private Enum<?> state; - - private Object info; - - private CountDownLatch finishedLatch = new CountDownLatch(1); - - public NegotiationContext() - { - } - - public Receiver getReceiver() - { - return receiver; - } - - public void setReceiver(Receiver receiver) - { - this.receiver = receiver; - } - - public Enum<?> getState() - { - return state; - } - - public void setState(Enum<?> state) - { - this.state = state; - } - - public Object getInfo() - { - return info; - } - - public void setInfo(Object info) - { - this.info = info; - } - - public void setFinished(boolean success) - { - if (finishedLatch != null) - { - finishedLatch.countDown(); - } - } - - public Enum<?> waitUntilFinished(long timeout) - { - if (finishedLatch == null) - { - throw new IllegalStateException("finishedLatch == null"); - } - - try - { - if (timeout == -1) - { - finishedLatch.await(); - } - else - { - finishedLatch.await(timeout, TimeUnit.MILLISECONDS); - } - } - catch (InterruptedException ex) - { - throw WrappedException.wrap(ex); - } - finally - { - finishedLatch = null; - } - - return state; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Negotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Negotiator.java deleted file mode 100644 index 03974ad530..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Negotiator.java +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.fsm.FiniteStateMachine; -import org.eclipse.net4j.util.security.INegotiationContext; -import org.eclipse.net4j.util.security.INegotiator; - -import java.nio.ByteBuffer; - -/** - * @author Eike Stepper - */ -public abstract class Negotiator<STATE extends Enum<?>, EVENT extends Enum<?>> extends - FiniteStateMachine<STATE, EVENT, INegotiationContext> implements INegotiator, INegotiationContext.Receiver -{ - private transient STATE initialState; - - private transient STATE successState; - - private transient STATE failureState; - - private transient EVENT startEvent; - - private transient EVENT bufferEvent; - - private boolean initiator; - - public Negotiator(Class<STATE> stateEnum, Class<EVENT> eventEnum, STATE initialState, STATE successState, - STATE failureState, EVENT startEvent, EVENT bufferEvent, boolean initiator) - { - super(stateEnum, eventEnum); - - if (initialState == null) throw new IllegalStateException("initialState == null"); - if (successState == null) throw new IllegalStateException("successState == null"); - if (failureState == null) throw new IllegalStateException("failureState == null"); - if (startEvent == null) throw new IllegalStateException("startEvent == null"); - if (bufferEvent == null) throw new IllegalStateException("bufferEvent == null"); - - this.initialState = initialState; - this.successState = successState; - this.failureState = failureState; - this.startEvent = startEvent; - this.bufferEvent = bufferEvent; - this.initiator = initiator; - - } - - public STATE getInitialState() - { - return initialState; - } - - public STATE getSuccessState() - { - return successState; - } - - public STATE getFailureState() - { - return failureState; - } - - public EVENT getBufferEvent() - { - return bufferEvent; - } - - public EVENT getStartEvent() - { - return startEvent; - } - - public boolean isInitiator() - { - return initiator; - } - - public void negotiate(INegotiationContext context) - { - context.setReceiver(this); - context.setState(initialState); - if (initiator) - { - process(context, startEvent, null); - postProcess(context); - } - } - - public void receiveBuffer(INegotiationContext context, ByteBuffer buffer) - { - process(context, bufferEvent, buffer); - postProcess(context); - } - - protected void postProcess(INegotiationContext context) - { - Enum<?> state = context.getState(); - if (state == successState) - { - context.setFinished(true); - } - else if (state == failureState) - { - context.setFinished(false); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java deleted file mode 100644 index ee4090c1b5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/NegotiatorFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.internal.util.factory.Factory; - -/** - * @author Eike Stepper - */ -public abstract class NegotiatorFactory extends Factory -{ - public static final String PRODUCT_GROUP = "org.eclipse.net4j.Negotiators"; - - public NegotiatorFactory(String type) - { - super(PRODUCT_GROUP, type); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java deleted file mode 100644 index 94a83fd40e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentials.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.security.IPasswordCredentials; - -/** - * @author Eike Stepper - */ -public class PasswordCredentials extends Credentials implements IPasswordCredentials -{ - private char[] password; - - public PasswordCredentials(String userID, char[] password) - { - super(userID); - this.password = password; - } - - public char[] getPassword() - { - return password; - } - - public void setPassword(char[] password) - { - this.password = password; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentialsProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentialsProvider.java deleted file mode 100644 index 53d392d369..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/PasswordCredentialsProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.security.IPasswordCredentials; -import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; - -/** - * @author Eike Stepper - */ -public final class PasswordCredentialsProvider implements IPasswordCredentialsProvider -{ - private IPasswordCredentials credentials; - - public PasswordCredentialsProvider(IPasswordCredentials credentials) - { - this.credentials = credentials; - } - - public boolean isInteractive() - { - return false; - } - - public IPasswordCredentials getCredentials() - { - return credentials; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Randomizer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Randomizer.java deleted file mode 100644 index 0a58d395e7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/Randomizer.java +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.util.security.IRandomizer; - -import java.security.SecureRandom; - -/** - * @author Eike Stepper - */ -public class Randomizer extends Lifecycle implements IRandomizer -{ - public static final String ALGORITHM_SHA1PRNG = "SHA1PRNG"; - - public static final String DEFAULT_ALGORITHM_NAME = ALGORITHM_SHA1PRNG; - - private String algorithmName = DEFAULT_ALGORITHM_NAME; - - private String providerName; - - private transient SecureRandom secureRandom; - - public String getAlgorithmName() - { - return algorithmName; - } - - public void setAlgorithmName(String algorithmName) - { - this.algorithmName = algorithmName; - } - - public String getProviderName() - { - return providerName; - } - - public void setProviderName(String providerName) - { - this.providerName = providerName; - } - - public boolean nextBoolean() - { - return secureRandom.nextBoolean(); - } - - public double nextDouble() - { - return secureRandom.nextDouble(); - } - - public float nextFloat() - { - return secureRandom.nextFloat(); - } - - public synchronized double nextGaussian() - { - return secureRandom.nextGaussian(); - } - - public int nextInt() - { - return secureRandom.nextInt(); - } - - public int nextInt(int n) - { - return secureRandom.nextInt(n); - } - - public long nextLong() - { - return secureRandom.nextLong(); - } - - public byte[] generateSeed(int numBytes) - { - return secureRandom.generateSeed(numBytes); - } - - public String getAlgorithm() - { - return secureRandom.getAlgorithm(); - } - - public synchronized void nextBytes(byte[] bytes) - { - secureRandom.nextBytes(bytes); - } - - public synchronized void setSeed(byte[] seed) - { - secureRandom.setSeed(seed); - } - - public void setSeed(long seed) - { - secureRandom.setSeed(seed); - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (algorithmName == null) - { - throw new IllegalStateException("algorithmName == null"); - } - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - if (providerName == null) - { - secureRandom = SecureRandom.getInstance(algorithmName); - } - else - { - secureRandom = SecureRandom.getInstance(algorithmName, providerName); - } - - secureRandom.setSeed(System.currentTimeMillis()); - } - - @Override - protected void doDeactivate() throws Exception - { - secureRandom = null; - super.doDeactivate(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java deleted file mode 100644 index 537b8754af..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/RandomizerFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.internal.util.factory.Factory; -import org.eclipse.net4j.util.factory.ProductCreationException; - -/** - * @author Eike Stepper - */ -public class RandomizerFactory extends Factory -{ - public static final String PRODUCT_GROUP = "org.eclipse.net4j.randomizers"; - - public static final String TYPE = "default"; - - public RandomizerFactory() - { - super(PRODUCT_GROUP, TYPE); - } - - public Randomizer create(String description) throws ProductCreationException - { - Randomizer randomizer = new Randomizer(); - if (description != null) - { - randomizer.setAlgorithmName(description); - } - - return randomizer; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java deleted file mode 100644 index d734a7c25f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiator.java +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.util.security.INegotiationContext; -import org.eclipse.net4j.util.security.IPasswordCredentials; -import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; -import org.eclipse.net4j.util.security.SecurityUtil; - -import java.nio.ByteBuffer; - -/** - * @author Eike Stepper - */ -public class ResponseNegotiator extends ChallengeResponseNegotiator -{ - private IPasswordCredentialsProvider credentialsProvider; - - public ResponseNegotiator() - { - super(false); - } - - public IPasswordCredentialsProvider getCredentialsProvider() - { - return credentialsProvider; - } - - public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider) - { - this.credentialsProvider = credentialsProvider; - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (credentialsProvider == null) - { - throw new IllegalStateException("credentialsProvider == null"); - } - } - - @Override - protected void createChallenge(INegotiationContext context, ByteBuffer challenge) - { - throw new UnsupportedOperationException(); - } - - @Override - protected void handleChallenge(INegotiationContext context, ByteBuffer challenge, ByteBuffer response) - { - // Get random token from challenge - int size = challenge.getInt(); - byte[] randomToken = new byte[size]; - challenge.get(randomToken); - - // Get credentials and encrypt token - IPasswordCredentials credentials = credentialsProvider.getCredentials(); - String userID = credentials.getUserID(); - context.setUserID(userID); - - // Set userID into response - byte[] userIDBytes = userID.getBytes(); - response.putInt(userIDBytes.length); - response.put(userIDBytes); - - // Set crypted token into response - byte[] cryptedToken = encryptToken(credentials.getPassword(), randomToken); - response.putInt(cryptedToken.length); - response.put(cryptedToken); - } - - @Override - protected boolean handleResponse(INegotiationContext context, ByteBuffer response) - { - throw new UnsupportedOperationException(); - } - - protected byte[] encryptToken(char[] password, byte[] token) - { - try - { - return SecurityUtil.encrypt(token, password, getAlgorithmName()); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new SecurityException(ex); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java deleted file mode 100644 index 12030ce0df..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/ResponseNegotiatorFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -/** - * @author Eike Stepper - */ -public class ResponseNegotiatorFactory extends NegotiatorFactory -{ - public static final String TYPE = "response"; - - public ResponseNegotiatorFactory() - { - super(TYPE); - } - - public ResponseNegotiator create(String description) - { - return new ResponseNegotiator(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManager.java deleted file mode 100644 index bec24fa4d0..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManager.java +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.util.io.IORuntimeException; -import org.eclipse.net4j.util.security.IUserManager; -import org.eclipse.net4j.util.security.SecurityUtil; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class UserManager extends Lifecycle implements IUserManager -{ - // Transient to prevent from logging - protected transient Map<String, char[]> users = new HashMap<String, char[]>(); - - public UserManager() - { - } - - public synchronized void addUser(String userID, char[] password) - { - users.put(userID, password); - save(users); - } - - public synchronized void removeUser(String userID) - { - if (users.remove(userID) != null) - { - save(users); - } - } - - public byte[] encrypt(String userID, byte[] data, String algorithmName) throws SecurityException - { - char[] password; - synchronized (this) - { - password = users.get(userID); - } - - if (password == null) - { - throw new SecurityException("No such user: " + userID); - } - - try - { - return SecurityUtil.encrypt(data, password, algorithmName); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new SecurityException(ex); - } - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - load(users); - } - - @Override - protected void doDeactivate() throws Exception - { - users.clear(); - super.doDeactivate(); - } - - protected void load(Map<String, char[]> users) throws IORuntimeException - { - } - - protected void save(Map<String, char[]> users) throws IORuntimeException - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java deleted file mode 100644 index 448a721e63..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/security/UserManagerFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.security; - -import org.eclipse.net4j.internal.util.factory.Factory; - -/** - * @author Eike Stepper - */ -public abstract class UserManagerFactory extends Factory -{ - public static final String PRODUCT_GROUP = "org.eclipse.net4j.userManagers"; - - public UserManagerFactory(String type) - { - super(PRODUCT_GROUP, type); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java deleted file mode 100644 index d96fe298cb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.internal.util.transaction; - -import org.eclipse.net4j.util.transaction.ITransaction; -import org.eclipse.net4j.util.transaction.ITransactionalOperation; -import org.eclipse.net4j.util.transaction.TransactionException; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class Transaction<CONTEXT> implements ITransaction<CONTEXT> -{ - private List<ITransactionalOperation<CONTEXT>> operations = new ArrayList<ITransactionalOperation<CONTEXT>>(); - - private CONTEXT context; - - private boolean undoPhase1OnRollback; - - public Transaction(CONTEXT context, boolean undoPhase1OnRollback) - { - this.context = context; - this.undoPhase1OnRollback = undoPhase1OnRollback; - } - - public Transaction(CONTEXT context) - { - this(context, true); - } - - public boolean isUndoPhase1OnRollback() - { - return undoPhase1OnRollback; - } - - public boolean isActive() - { - return operations != null; - } - - public CONTEXT getContext() - { - return context; - } - - public void execute(ITransactionalOperation<CONTEXT> operation) throws TransactionException - { - if (!isActive()) - { - throw new TransactionException("Transaction inactive"); - } - - try - { - operation.phase1(context); - operations.add(operation); - } - catch (RuntimeException ex) - { - rollback(); - throw ex; - } - catch (Exception ex) - { - rollback(); - throw new TransactionException(ex); - } - } - - public void commit() - { - for (ITransactionalOperation<CONTEXT> operation : end()) - { - operation.phase2(context); - } - } - - public void rollback() - { - if (undoPhase1OnRollback) - { - for (ITransactionalOperation<CONTEXT> operation : end()) - { - operation.undoPhase1(context); - } - } - } - - private List<ITransactionalOperation<CONTEXT>> end() - { - List<ITransactionalOperation<CONTEXT>> tmp = operations; - operations = null; - return tmp; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/CheckUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/CheckUtil.java deleted file mode 100644 index c37a2d92d1..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/CheckUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -/** - * @author Eike Stepper - */ -public final class CheckUtil -{ - private CheckUtil() - { - } - - public static void checkNull(Object handle, String msg) throws NullPointerException - { - if (handle == null) - { - throw new NullPointerException(msg); - } - } - - public static void checkArg(boolean expr, String msg) throws IllegalArgumentException - { - if (!expr) - { - throw new IllegalArgumentException(msg); - } - } - - public static void checkArg(Object handle, String handleName) throws IllegalArgumentException - { - if (handle == null) - { - throw new IllegalArgumentException(handleName + " is null"); - } - } - - public static void checkState(boolean expr, String msg) throws IllegalStateException - { - if (!expr) - { - throw new IllegalStateException(msg); - } - } - - public static void checkState(Object handle, String handleName) throws IllegalStateException - { - if (handle == null) - { - throw new IllegalStateException(handleName + " is null"); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java deleted file mode 100644 index 09fb81fef9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -import org.eclipse.net4j.util.io.IORuntimeException; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public final class HexUtil -{ - public static final char DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; - - private HexUtil() - { - } - - /** - * Converts a byte array into a string of lower case hex chars. - * - * @param bs - * A byte array - * @param off - * The index of the first byte to read - * @param length - * The number of bytes to read. - * @return the string of hex chars. - */ - public static final String bytesToHex(byte[] bs, int off, int length) - { - if (bs.length <= off || bs.length < off + length) - { - throw new IllegalArgumentException(); - } - - StringBuilder sb = new StringBuilder(length * 2); - bytesToHexAppend(bs, off, length, sb); - return sb.toString(); - } - - public static final void bytesToHexAppend(byte[] bs, int off, int length, Appendable appendable) - { - if (bs.length <= off || bs.length < off + length) - { - throw new IllegalArgumentException(); - } - - if (appendable instanceof StringBuffer) - { - StringBuffer buffer = (StringBuffer)appendable; - buffer.ensureCapacity(buffer.length() + length * 2); - } - - try - { - for (int i = off; i < off + length; i++) - { - appendable.append(Character.forDigit(bs[i] >>> 4 & 0xf, 16)); - appendable.append(Character.forDigit(bs[i] & 0xf, 16)); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static final String bytesToHex(byte[] bs) - { - return bytesToHex(bs, 0, bs.length); - } - - public static final byte[] hexToBytes(String s) - { - return hexToBytes(s, 0); - } - - public static final byte[] hexToBytes(String s, int off) - { - byte[] bs = new byte[off + (1 + s.length()) / 2]; - hexToBytes(s, bs, off); - return bs; - } - - /** - * Converts a String of hex characters into an array of bytes. - * - * @param s - * A string of hex characters (upper case or lower) of even length. - * @param out - * A byte array of length at least s.length()/2 + off - * @param off - * The first byte to write of the array - */ - public static final void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, - IndexOutOfBoundsException - { - int slen = s.length(); - if (slen % 2 != 0) - { - s = '0' + s; - } - - if (out.length < off + slen / 2) - { - throw new IndexOutOfBoundsException("Output buffer too small for input (" + out.length + '<' + off + slen / 2 - + ')'); - } - - // Safe to assume the string is even length - byte b1, b2; - for (int i = 0; i < slen; i += 2) - { - b1 = (byte)Character.digit(s.charAt(i), 16); - b2 = (byte)Character.digit(s.charAt(i + 1), 16); - if (b1 < 0 || b2 < 0) - { - throw new NumberFormatException(); - } - - out[off + i / 2] = (byte)(b1 << 4 | b2); - } - } - - public static String longToHex(long v) - { - final String hex = Long.toHexString(v); - if (hex.length() < 8) - { - return "00000000".substring(hex.length()) + hex; - } - - return hex; - } - - @Deprecated - public static String formatByte(int b) - { - assertByte(b); - return "" + DIGITS[b >> 4] + DIGITS[b & 0xf]; //$NON-NLS-1$ - } - - @Deprecated - public static String formatBytes(byte[] bytes) - { - StringBuilder builder = new StringBuilder(); - for (byte b : bytes) - { - appendHex(builder, b - Byte.MIN_VALUE); - } - - return builder.toString(); - } - - @Deprecated - public static void appendHex(StringBuilder builder, int b) - { - assertByte(b); - builder.append(DIGITS[b >> 4]); - builder.append(DIGITS[b & 0xf]); - } - - @Deprecated - private static void assertByte(int b) - { - if (b < 0 || b > 255) - { - throw new IllegalArgumentException("b=" + b); //$NON-NLS-1$ - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java deleted file mode 100644 index 35258aba1d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -/** - * @author Eike Stepper - */ -public class ImplementationError extends Error -{ - private static final long serialVersionUID = 1L; - - public ImplementationError() - { - } - - public ImplementationError(String message) - { - super(message); - } - - public ImplementationError(String message, Throwable cause) - { - super(message, cause); - } - - public ImplementationError(Throwable cause) - { - super(cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java deleted file mode 100644 index 85fe87ca2e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -import java.lang.reflect.Array; - -/** - * @author Eike Stepper - */ -public final class ObjectUtil -{ - private ObjectUtil() - { - } - - public static boolean equals(Object o1, Object o2) - { - if (o1 == null) - { - return o2 == null; - } - - return o1.equals(o2); - } - - public static int hashCode(Object o) - { - if (o == null) - { - return 0; - } - - return o.hashCode(); - } - - public static int hashCode(long num) - { - return (int)(num >> 32) ^ (int)(num & 0xffffffff); - } - - @SuppressWarnings("unchecked") - public static <T> T[] appendtoArray(T[] array, T... elements) - { - T[] result = (T[])Array.newInstance(array.getClass().getComponentType(), array.length + elements.length); - System.arraycopy(array, 0, result, 0, array.length); - System.arraycopy(elements, 0, result, array.length, elements.length); - return result; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java deleted file mode 100644 index 2f97c40a4f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ReflectUtil.java +++ /dev/null @@ -1,594 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.util.collection.Pair; -import org.eclipse.net4j.util.io.IOUtil; - -import java.io.PrintStream; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; -import java.util.Map.Entry; - -/** - * @author Eike Stepper - */ -public final class ReflectUtil -{ - private static final String NAMESPACE_SEPARATOR = "."; - - public static final Class<Object> ROOT_CLASS = Object.class; - - public static final Class<?>[] NO_PARAMETERS = null; - - public static final Object[] NO_ARGUMENTS = null; - - private static final Method HASH_CODE_METHOD = lookupHashCodeMethod(); - - private static final Map<Object, Long> ids = new WeakHashMap<Object, Long>(); - - public static boolean DUMP_STATICS = false; - - private static long lastID; - - private ReflectUtil() - { - } - - public static Method getMethod(Class<?> c, String methodName, Class<?>... parameterTypes) - { - try - { - try - { - return c.getDeclaredMethod(methodName, parameterTypes); - } - catch (NoSuchMethodException ex) - { - Class<?> superclass = c.getSuperclass(); - if (superclass != null) - { - return getMethod(superclass, methodName, parameterTypes); - } - - return null; - } - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new ImplementationError(ex); - } - } - - public static Object invokeMethod(Method method, Object target, Object... arguments) throws InvocationTargetException - { - if (!method.isAccessible()) - { - method.setAccessible(true); - } - - try - { - return method.invoke(target, arguments); - } - catch (IllegalAccessException ex) - { - throw new ImplementationError(ex); - } - } - - public static Field getField(Class<?> c, String fieldName) - { - try - { - try - { - return c.getDeclaredField(fieldName); - } - catch (NoSuchFieldException ex) - { - Class<?> superclass = c.getSuperclass(); - if (superclass != null) - { - return getField(superclass, fieldName); - } - - return null; - } - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new ImplementationError(ex); - } - } - - public static void collectFields(Class<?> c, List<Field> fields) - { - if (c == ROOT_CLASS) - { - return; - } - - // Recurse - collectFields(c.getSuperclass(), fields); - - try - { - Field[] declaredFields = c.getDeclaredFields(); - for (Field field : declaredFields) - { - if (field.isSynthetic()) - { - continue; - } - - if ((field.getModifiers() & Modifier.STATIC) != 0 && !DUMP_STATICS) - { - continue; - } - - if (field.getAnnotation(ExcludeFromDump.class) != null) - { - continue; - } - - fields.add(field); - } - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new ImplementationError(ex); - } - } - - public static Object getValue(Field field, Object target) - { - if (!field.isAccessible()) - { - field.setAccessible(true); - } - - try - { - return field.get(target); - } - catch (IllegalAccessException ex) - { - throw new ImplementationError(ex); - } - } - - public static void setValue(Field field, Object target, Object value) - { - if (!field.isAccessible()) - { - field.setAccessible(true); - } - - try - { - field.set(target, value); - } - catch (IllegalAccessException ex) - { - throw new ImplementationError(ex); - } - } - - public static void printStackTrace(PrintStream out, StackTraceElement[] stackTrace) - { - for (int i = 2; i < stackTrace.length; i++) - { - StackTraceElement stackTraceElement = stackTrace[i]; - out.println("\tat " + stackTraceElement); - } - } - - public static void printStackTrace(StackTraceElement[] stackTrace) - { - printStackTrace(System.err, stackTrace); - } - - public static Integer getHashCode(Object object) - { - try - { - return (Integer)HASH_CODE_METHOD.invoke(object, NO_ARGUMENTS); - } - catch (Exception ex) - { - IOUtil.print(ex); - } - - return 0; - } - - public static Long getID(Object object) - { - Long id = ids.get(object); - if (id == null) - { - id = ++lastID; - ids.put(object, id); - } - - return id; - } - - public static String getPackageName(Class<? extends Object> c) - { - if (c == null) - { - return null; - } - - return getPackageName(c.getName()); - } - - public static String getPackageName(String className) - { - if (className == null) - { - return null; - } - - int lastDot = className.lastIndexOf('.'); - if (lastDot != -1) - { - className = className.substring(0, lastDot); - } - - return className; - } - - public static String getSimpleName(Class<? extends Object> c) - { - if (c == null) - { - return null; - } - - return c.getSimpleName(); - } - - public static String getSimpleClassName(String name) - { - if (name == null) - { - return null; - } - - int lastDot = name.lastIndexOf('.'); - if (lastDot != -1) - { - name = name.substring(lastDot + 1); - } - - return name.replace('$', '.'); - } - - public static String getSimpleClassName(Object object) - { - if (object == null) - { - return null; - } - - return getSimpleName(object.getClass()); - } - - public static String getLabel(Object object) - { - if (object == null) - { - return null; - } - - return object.getClass().getSimpleName() + "@" + getID(object); //$NON-NLS-1$ - } - - public static void dump(Object object) - { - dump(object, ""); //$NON-NLS-1$ - } - - public static void dump(Object object, String prefix) - { - dump(object, prefix, IOUtil.OUT()); - } - - public static void dump(Object object, String prefix, PrintStream out) - { - out.print(toString(object, prefix)); - } - - @SuppressWarnings("unchecked") - public static Pair<Field, Object>[] dumpToArray(Object object) - { - List<Field> fields = new ArrayList<Field>(); - collectFields(object.getClass(), fields); - Pair<Field, Object>[] result = new Pair[fields.size()]; - int i = 0; - for (Field field : fields) - { - Object value = getValue(field, object); - result[i++] = new Pair<Field, Object>(field, value); - } - - return result; - } - - public static Object instantiate(Map<Object, Object> properties, String namespace, String classKey, - ClassLoader classLoader) throws ClassNotFoundException, InstantiationException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException - { - if (namespace != null) - { - if (namespace.length() == 0) - { - namespace = null; - } - else if (!namespace.endsWith(NAMESPACE_SEPARATOR)) - { - namespace += NAMESPACE_SEPARATOR; - } - } - - String className = null; - Map<String, Object> values = new HashMap<String, Object>(); - for (Entry<Object, Object> entry : properties.entrySet()) - { - if (entry.getKey() instanceof String) - { - String key = (String)entry.getKey(); - if (namespace != null) - { - if (key.startsWith(namespace)) - { - key = key.substring(namespace.length()); - } - else - { - continue; - } - } - - if (classKey.equals(key)) - { - Object classValue = entry.getValue(); - if (classValue instanceof String) - { - className = (String)classValue; - } - else - { - OM.LOG.warn("Value of classKey " + classKey + " is not a String"); - } - } - else - { - values.put(key, entry.getValue()); - } - } - } - - if (className == null) - { - throw new IllegalArgumentException("Properties do not contain a valid class name for key " + classKey); - } - - Class<?> c = classLoader.loadClass(className); - Object instance = c.newInstance(); - Method[] methods = c.getMethods(); - for (Method method : methods) - { - if (isSetter(method)) - { - String name = StringUtil.uncap(method.getName().substring(3)); - Object value = values.get(name); - if (value != null) - { - Class<?> type = method.getParameterTypes()[0]; - if (!type.isAssignableFrom(value.getClass())) - { - if (value instanceof String) - { - String str = (String)value; - value = null; - if (type.isAssignableFrom(Boolean.class)) - { - value = Boolean.parseBoolean(str); - } - else if (type.isAssignableFrom(Byte.class)) - { - value = Byte.parseByte(str); - } - else if (type.isAssignableFrom(Short.class)) - { - value = Short.parseShort(str); - } - else if (type.isAssignableFrom(Integer.class)) - { - value = Integer.parseInt(str); - } - else if (type.isAssignableFrom(Long.class)) - { - value = Long.parseLong(str); - } - else if (type.isAssignableFrom(Float.class)) - { - value = Float.parseFloat(str); - } - else if (type.isAssignableFrom(Double.class)) - { - value = Double.parseDouble(str); - } - } - else - { - value = null; - } - } - - if (value == null) - { - throw new IllegalArgumentException("Value of property " + name + " can not be assigned to type " - + type.getName()); - } - - method.invoke(instance, value); - } - } - } - - return instance; - } - - public static boolean isSetter(Method method) - { - return method.getParameterTypes().length == 1 && isSetterName(method.getName()); - } - - public static boolean isSetterName(String name) - { - return name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)); - } - - public static String toString(Object object) - { - return toString(object, " "); //$NON-NLS-1$ - } - - public static String toString(Object object, String prefix) - { - StringBuilder builder = new StringBuilder(); - builder.append(prefix); - builder.append(getLabel(object)); - builder.append(StringUtil.NL); - toString(object.getClass(), object, prefix, builder); - return builder.toString(); - } - - private static void toString(Class<? extends Object> segment, Object object, String prefix, StringBuilder builder) - { - if (segment == ROOT_CLASS || segment == Lifecycle.class) - { - return; - } - - // Recurse - toString(segment.getSuperclass(), object, prefix, builder); - - String segmentPrefix = segment == object.getClass() ? "" : getSimpleName(segment) + NAMESPACE_SEPARATOR; //$NON-NLS-1$ - Field[] fields = segment.getDeclaredFields(); - for (Field field : fields) - { - if (field.isSynthetic()) - { - continue; - } - - if ((field.getModifiers() & Modifier.STATIC) != 0 && !DUMP_STATICS) - { - continue; - } - - if (field.getAnnotation(ExcludeFromDump.class) != null) - { - continue; - } - - builder.append(prefix); - builder.append(segmentPrefix); - builder.append(field.getName()); - builder.append(" = "); //$NON-NLS-1$ - - Object value = getValue(field, object); - if (value instanceof Map) - { - value = ((Map<?, ?>)value).entrySet(); - } - - if (value instanceof Collection) - { - builder.append(StringUtil.NL); - for (Object element : (Collection<?>)value) - { - builder.append(" "); - builder.append(element); - builder.append(StringUtil.NL); - } - } - else - { - builder.append(value); - builder.append(StringUtil.NL); - } - } - } - - private static Method lookupHashCodeMethod() - { - Method method; - - try - { - method = ROOT_CLASS.getMethod("hashCode", NO_PARAMETERS); //$NON-NLS-1$ - } - catch (Exception ex) - { - // This can really not happen - throw new AssertionError(); - } - - if (!method.isAccessible()) - { - method.setAccessible(true); - } - - return method; - } - - /** - * @author Eike Stepper - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface ExcludeFromDump - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java deleted file mode 100644 index 1faa1c8eed..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java +++ /dev/null @@ -1,144 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -/** - * @author Eike Stepper - */ -public final class StringUtil -{ - public static final String EMPTY = ""; - - public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$ - - private StringUtil() - { - } - - public static String replace(String text, String[] find, String[] replace) - { - for (int i = 0; i < find.length; i++) - { - int end = 0; - for (;;) - { - int start = text.indexOf(find[i], end); - if (start == -1) - { - break; - } - - end = start + find[i].length(); - text = text.substring(0, start) + replace[i] + text.substring(end); - } - } - - return text; - } - - public static String safe(String str) - { - if (str == null) - { - return EMPTY; - } - - return str; - } - - public static int compare(String s1, String s2) - { - if (s1 == null) - { - return s2 == null ? 0 : -1; - } - - if (s2 == null) - { - return 1; - } - - return s1.compareTo(s2); - } - - public static String cap(String str) - { - if (str == null || str.length() == 0) - { - return str; - } - - char first = str.charAt(0); - if (Character.isUpperCase(first)) - { - return str; - } - - if (str.length() == 1) - { - return str.toUpperCase(); - } - - StringBuilder builder = new StringBuilder(str); - builder.setCharAt(0, Character.toUpperCase(first)); - return builder.toString(); - } - - public static String uncap(String str) - { - if (str == null || str.length() == 0) - { - return str; - } - - char first = str.charAt(0); - if (Character.isLowerCase(first)) - { - return str; - } - - if (str.length() == 1) - { - return str.toLowerCase(); - } - - StringBuilder builder = new StringBuilder(str); - builder.setCharAt(0, Character.toLowerCase(first)); - return builder.toString(); - } - - public static int occurrences(String str, char c) - { - int count = 0; - for (int i = 0; (i = str.indexOf(c, i)) != -1; ++i) - { - ++count; - } - - return count; - } - - public static int occurrences(String str, String c) - { - int count = 0; - for (int i = 0; (i = str.indexOf(c, i)) != -1; i += c.length()) - { - ++count; - } - - return count; - } - - public static boolean isEmpty(String str) - { - return str == null || str.length() == 0; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java deleted file mode 100644 index e847ef302b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util; - -/** - * TODO Handle IORuntimeException - * - * @author Eike Stepper - */ -public class WrappedException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - private WrappedException(Exception exception) - { - super(exception); - } - - public Exception exception() - { - return (Exception)getCause(); - } - - public static RuntimeException wrap(Exception exception) - { - if (exception instanceof RuntimeException) - { - return (RuntimeException)exception; - } - - return new WrappedException(exception); - } - - public static Exception unwrap(Exception exception) - { - if (exception instanceof WrappedException) - { - return ((WrappedException)exception).exception(); - } - - return exception; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICache.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICache.java deleted file mode 100644 index 185ab61b94..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICache.java +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.cache; - -/** - * @author Eike Stepper - */ -public interface ICache -{ - public ICacheMonitor getCacheMonitor(); - - /** - * Instructs this cache to evict <b>elementCount</b> elements. - */ - public void evictElements(int elementCount); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitor.java deleted file mode 100644 index 5c1d77b167..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitor.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.cache; - -import org.eclipse.net4j.util.event.INotifier; - -/** - * @author Eike Stepper - */ -public interface ICacheMonitor extends INotifier -{ - public ConditionPolicy getConditionPolicy(); - - public Condition getCondition(); - - public ICacheProbe registerCache(ICache cache); - - public void deregisterCache(ICache cache); - - /** - * @author Eike Stepper - */ - public enum Condition - { - /** - * Condition <b>GREEN</b> indicates that the system is operating normally and enough free memory is available so - * that caches are free to cache additional elements. - */ - GREEN, - - /** - * Condition <b>YELLOW</b> indicates that the system is operating normally but free memory is about to go low so - * that caches should stop to cache additional elements. - */ - YELLOW, - - /** - * Condition <b>RED</b> indicates that the system state is critical and free memory is almost exhausted so that - * caches must immediately stop to cache additional elements. Depending of the eviction strategy element eviction is - * ordered. - */ - RED; - } - - /** - * @author Eike Stepper - */ - public interface ConditionPolicy - { - public Condition getNewCondition(Condition oldCondition); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitorEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitorEvent.java deleted file mode 100644 index e3227bc5a6..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheMonitorEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.cache; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface ICacheMonitorEvent extends IEvent -{ - public ICacheMonitor getCacheMonitor(); - - public ICacheMonitor.Condition getOldCondition(); - - public ICacheMonitor.Condition getNewCondition(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheProbe.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheProbe.java deleted file mode 100644 index db50f7b4a0..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheProbe.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.cache; - -/** - * @author Eike Stepper - */ -public interface ICacheProbe -{ - public boolean isDisposed(); - - public void elementCached(int elementSize); - - public void elementEvicted(int elementSize); - - public void elementReconstructed(long reconstructionTime); - - public int getElementCount(); - - public long getCacheSize(); - - public long getAverageElementSize(); - - public long getReconstructionCost(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheRegistration.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheRegistration.java deleted file mode 100644 index 980bf90b43..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/ICacheRegistration.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.cache; - -/** - * @author Eike Stepper - */ -public interface ICacheRegistration extends ICacheProbe -{ - public ICacheMonitor getCacheMonitor(); - - public ICache getCache(); - - public void dispose(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/package.html deleted file mode 100644 index 3c3ce0d71a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/cache/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A generic caching and memory monitoring framework. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HistoryUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HistoryUtil.java deleted file mode 100644 index 935cb12aca..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/HistoryUtil.java +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -import org.eclipse.net4j.internal.util.collection.History; -import org.eclipse.net4j.internal.util.collection.PreferenceHistory; -import org.eclipse.net4j.util.om.pref.OMPreference; - -/** - * @author Eike Stepper - */ -public final class HistoryUtil -{ - private HistoryUtil() - { - } - - public static IHistory<String> createHistory() - { - return new History<String>(); - } - - public static IHistory<String> createPreferenceHistory(OMPreference<String[]> preference) - { - return new PreferenceHistory(preference); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistory.java deleted file mode 100644 index d2776c66bb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistory.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -import org.eclipse.net4j.util.event.INotifier; - -/** - * @author Eike Stepper - */ -public interface IHistory<T> extends INotifier, Iterable<IHistoryElement<T>> -{ - public boolean isEmpty(); - - public int size(); - - public boolean clear(); - - public int indexOf(T data); - - public boolean add(T data); - - public IHistoryElement<T> remove(int index); - - public IHistoryElement<T> get(int index); - - public T getMostRecent(); - - public <D> D[] getData(D[] a); - - public IHistoryElement<T>[] toArray(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryChangeEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryChangeEvent.java deleted file mode 100644 index 8c462b03da..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryChangeEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface IHistoryChangeEvent extends IEvent -{ -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryElement.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryElement.java deleted file mode 100644 index 31823dc319..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/IHistoryElement.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -/** - * @author Eike Stepper - */ -public interface IHistoryElement<T> -{ - public IHistory<IHistoryElement<T>> getHistory(); - - public T getData(); - - public String getText(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MapEntry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MapEntry.java deleted file mode 100644 index cab706dedc..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MapEntry.java +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -import org.eclipse.net4j.util.ObjectUtil; - -import java.text.MessageFormat; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class MapEntry<K, V> implements Map.Entry<K, V> -{ - private K key; - - private V value; - - public MapEntry(K key, V value) - { - this.key = key; - this.value = value; - } - - public MapEntry(Map.Entry<K, V> entry) - { - key = entry.getKey(); - value = entry.getValue(); - } - - public K getKey() - { - return key; - } - - public V getValue() - { - return value; - } - - public V setValue(V value) - { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof Map.Entry<?, ?>) - { - Map.Entry<?, ?> entry = (Map.Entry<?, ?>)obj; - return ObjectUtil.equals(key, entry.getKey()) && ObjectUtil.equals(value, entry.getValue()); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(key) ^ ObjectUtil.hashCode(value); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}={1}", key, value); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableList.java deleted file mode 100644 index 35eed8012f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableList.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.eclipse.net4j.util.collection; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public interface MoveableList<E> extends List<E> -{ - public E move(int targetIndex, int sourceIndex); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MultiMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MultiMap.java deleted file mode 100644 index 09f6405bd8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MultiMap.java +++ /dev/null @@ -1,744 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -import org.eclipse.net4j.util.ObjectUtil; - -import java.util.AbstractCollection; -import java.util.AbstractSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class MultiMap<K, V> implements Map<K, V> -{ - private transient Entries entries; - - private transient Set<K> keys; - - private transient Collection<V> values; - - public MultiMap() - { - } - - public abstract int getDelegateCount(); - - public Map<K, V> getDelegate(int index) - { - if (0 <= index && index < getDelegateCount()) - { - return doGetDelegate(index); - } - - return null; - } - - /** - * @category WRITE - */ - public void clear() - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public V put(K key, V value) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public void putAll(Map<? extends K, ? extends V> t) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public V remove(Object key) - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean containsKey(Object key) - { - return containsKey(key, getDelegateCount()); - } - - /** - * @category READ - */ - public boolean containsValue(Object value) - { - for (int i = 0; i < getDelegateCount(); i++) - { - Map<K, V> delegate = getDelegate(i); - if (delegate != null) - { - if (delegate.containsValue(value)) - { - return true; - } - } - } - - return false; - } - - /** - * @category READ - */ - public V get(Object key) - { - for (int i = 0; i < getDelegateCount(); i++) - { - Map<K, V> delegate = getDelegate(i); - if (delegate != null) - { - if (delegate.containsKey(key)) - { - return delegate.get(key); - } - } - } - - return null; - } - - /** - * @category READ - */ - public int size() - { - int size = 0; - Map<K, V> delegate = getDelegate(0); - if (delegate != null) - { - size += delegate.size(); - for (int i = 1; i < getDelegateCount(); i++) - { - delegate = getDelegate(i); - if (delegate != null) - { - Set<K> keySet = delegate.keySet(); - for (K key : keySet) - { - if (!containsKey(key, i)) - { - ++size; - } - } - } - } - } - - return size; - } - - /** - * @category READ - */ - public boolean isEmpty() - { - for (int i = 0; i < getDelegateCount(); i++) - { - Map<K, V> delegate = getDelegate(i); - if (delegate != null) - { - if (!delegate.isEmpty()) - { - return false; - } - } - } - - return true; - } - - public synchronized Set<Map.Entry<K, V>> entrySet() - { - if (entries == null) - { - entries = new Entries(); - } - - return entries; - } - - public synchronized Set<K> keySet() - { - if (keys == null) - { - keys = new Keys(); - } - - return keys; - } - - public synchronized Collection<V> values() - { - if (values == null) - { - values = new Values(); - } - - return values; - } - - protected boolean containsKey(Object key, int delegateCount) - { - for (int i = 0; i < delegateCount; i++) - { - Map<K, V> delegate = getDelegate(i); - if (delegate != null) - { - if (delegate.containsKey(key)) - { - return true; - } - } - } - - return false; - } - - protected abstract Map<K, V> doGetDelegate(int index); - - /** - * @author Eike Stepper - */ - public static class ListBased<K, V> extends MultiMap<K, V> - { - private List<Map<K, V>> delegates; - - public ListBased() - { - } - - public ListBased(List<Map<K, V>> delegates) - { - this.delegates = delegates; - } - - public synchronized List<Map<K, V>> getDelegates() - { - if (delegates == null) - { - delegates = createDelegates(); - } - - return delegates; - } - - public void setDelegates(List<Map<K, V>> delegates) - { - this.delegates = delegates; - } - - @Override - public int getDelegateCount() - { - return getDelegates().size(); - } - - @Override - protected Map<K, V> doGetDelegate(int index) - { - return getDelegates().get(index); - } - - protected List<Map<K, V>> createDelegates() - { - return new ArrayList<Map<K, V>>(); - } - } - - /** - * @author Eike Stepper - */ - private final class Entries extends AbstractSet<Entry<K, V>> - { - public Entries() - { - } - - /** - * @category WRITE - */ - public boolean add(Entry<K, V> o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean addAll(Collection<? extends Entry<K, V>> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public void clear() - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean remove(Object o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean removeAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean retainAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - @SuppressWarnings("unchecked") - public boolean contains(Object o) - { - if (o instanceof Map.Entry) - { - for (int i = 0; i < getDelegateCount(); i++) - { - Map<K, V> delegate = getDelegate(i); - if (delegate != null) - { - K key = ((Map.Entry<K, V>)o).getKey(); - if (delegate.containsKey(key)) - { - V value = ((Map.Entry<K, V>)o).getValue(); - if (ObjectUtil.equals(delegate.get(key), value)) - { - return true; - } - } - } - } - } - - return false; - } - - /** - * @category READ - */ - public boolean isEmpty() - { - return MultiMap.this.isEmpty(); - } - - /** - * @category READ - */ - public int size() - { - return MultiMap.this.size(); - } - - public Iterator<Entry<K, V>> iterator() - { - return new Iterator<Entry<K, V>>() - { - private Entry<K, V> next; - - private int delegateIndex = -1; - - private Iterator<Entry<K, V>> delegateIt; - - /** - * @category WRITE - */ - public void remove() - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean hasNext() - { - next = null; - while (next == null) - { - if (delegateIt == null) - { - Map<K, V> delegate = getDelegate(++delegateIndex); - if (delegate == null) - { - // All delegates have been iterated - break; - } - - delegateIt = delegate.entrySet().iterator(); - } - - if (delegateIt.hasNext()) - { - next = delegateIt.next(); - - // Check if this key has been returned previously - if (containsKey(next.getKey(), delegateIndex)) - { - next = null; - } - } - else - { - // Determine next delegate iterator in next loop - delegateIt = null; - } - } - - return next != null; - } - - /** - * @category READ - */ - public Map.Entry<K, V> next() - { - if (next == null) - { - throw new NoSuchElementException(); - } - - try - { - return next; - } - finally - { - next = null; - } - } - }; - } - } - - /** - * @author Eike Stepper - */ - private final class Keys extends AbstractSet<K> - { - public Keys() - { - } - - /** - * @category WRITE - */ - public boolean add(K o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean addAll(Collection<? extends K> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public void clear() - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean remove(Object o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean removeAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean retainAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean contains(Object o) - { - return MultiMap.this.containsKey(o); - } - - /** - * @category READ - */ - public boolean isEmpty() - { - return MultiMap.this.isEmpty(); - } - - /** - * @category READ - */ - public int size() - { - return MultiMap.this.size(); - } - - /** - * @category READ - */ - public Iterator<K> iterator() - { - return new Iterator<K>() - { - private K next; - - private int delegateIndex = -1; - - private Iterator<K> delegateIt; - - /** - * @category WRITE - */ - public void remove() - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean hasNext() - { - next = null; - while (next == null) - { - if (delegateIt == null) - { - Map<K, V> delegate = getDelegate(++delegateIndex); - if (delegate == null) - { - // All delegates have been iterated - break; - } - - delegateIt = delegate.keySet().iterator(); - } - - if (delegateIt.hasNext()) - { - next = delegateIt.next(); - - // Check if this key has been returned previously - if (containsKey(next, delegateIndex)) - { - next = null; - } - } - else - { - // Determine next delegate iterator in next loop - delegateIt = null; - } - } - - return next != null; - } - - /** - * @category READ - */ - public K next() - { - if (next == null) - { - throw new NoSuchElementException(); - } - - try - { - return next; - } - finally - { - next = null; - } - } - }; - } - } - - /** - * @author Eike Stepper - */ - private final class Values extends AbstractCollection<V> - { - public Values() - { - } - - /** - * @category WRITE - */ - public boolean add(V o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean addAll(Collection<? extends V> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public void clear() - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean remove(Object o) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean removeAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category WRITE - */ - public boolean retainAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean contains(Object o) - { - return MultiMap.this.containsValue(o); - } - - /** - * @category READ - */ - public boolean isEmpty() - { - return MultiMap.this.isEmpty(); - } - - /** - * @category READ - */ - public int size() - { - return MultiMap.this.size(); - } - - /** - * @category READ - */ - public Iterator<V> iterator() - { - return new Iterator<V>() - { - private Iterator<Entry<K, V>> delegateIt = entrySet().iterator(); - - /** - * @category WRITE - */ - public void remove() - { - throw new UnsupportedOperationException(); - } - - /** - * @category READ - */ - public boolean hasNext() - { - return delegateIt.hasNext(); - } - - /** - * @category READ - */ - public V next() - { - return delegateIt.next().getValue(); - } - }; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/Pair.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/Pair.java deleted file mode 100644 index 6e98fd9ff2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/Pair.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.collection; - -/** - * @author Eike Stepper - */ -public class Pair<T1, T2> -{ - private T1 element1; - - private T2 element2; - - public Pair() - { - } - - public Pair(T1 element1, T2 element2) - { - this.element1 = element1; - this.element2 = element2; - } - - public final T1 getElement1() - { - return element1; - } - - public void setElement1(T1 element1) - { - this.element1 = element1; - } - - public final T2 getElement2() - { - return element2; - } - - public void setElement2(T2 element2) - { - this.element2 = element2; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/package.html deleted file mode 100644 index d17670b185..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Additional collection-like interfaces and classes. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java deleted file mode 100644 index 561f5353dc..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -import org.eclipse.net4j.util.WrappedException; - -/** - * @author Eike Stepper - */ -public final class ConcurrencyUtil -{ - private ConcurrencyUtil() - { - } - - public static void sleep(long millis) - { - try - { - Thread.sleep(millis); - } - catch (InterruptedException ex) - { - throw WrappedException.wrap(ex); - } - } - - public static void sleep(long millis, int nanos) - { - try - { - Thread.sleep(millis, nanos); - } - catch (InterruptedException ex) - { - throw WrappedException.wrap(ex); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ICorrelator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ICorrelator.java deleted file mode 100644 index 1842603388..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ICorrelator.java +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -/** - * @author Eike Stepper - */ -public interface ICorrelator<CORRELATION, VALUE> -{ - public boolean isCorrelated(CORRELATION correlation); - - public VALUE correlate(CORRELATION correlation); - - public VALUE correlateUnique(CORRELATION correlation); - - public VALUE uncorrelate(CORRELATION correlation); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ISynchronizer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ISynchronizer.java deleted file mode 100644 index 14da7b0a93..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ISynchronizer.java +++ /dev/null @@ -1,28 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -/** - * Synchronizes a producer and a consumer thread letting the producer pass a value to the consumer. Both producer and - * consumer must have access to this {@link ISynchronizer} and there must only ever exist one consumer for it. Once the - * result value is consumed by the consumer this {@link ISynchronizer} must not be reused. - * <p> - * - * @author Eike Stepper - */ -public interface ISynchronizer<RESULT> -{ - public RESULT get(long timeout); - - public void put(RESULT result); - - public boolean put(RESULT result, long timeout); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java deleted file mode 100644 index 7e09eb5253..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/IWorkSerializer.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -/** - * @author Eike Stepper - */ -public interface IWorkSerializer -{ - public boolean addWork(Runnable work); - - public void dispose(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingIntCounter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingIntCounter.java deleted file mode 100644 index 27237ddeb4..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingIntCounter.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * @author Eike Stepper - */ -public final class NonBlockingIntCounter -{ - private AtomicInteger value; - - public NonBlockingIntCounter() - { - this(0); - } - - public NonBlockingIntCounter(int initialValue) - { - value = new AtomicInteger(initialValue); - } - - public int getValue() - { - return value.get(); - } - - public int increment() - { - int v; - do - { - v = value.get(); - } while (!value.compareAndSet(v, v + 1)); - - return v + 1; - } - - @Override - public String toString() - { - return Long.toString(getValue()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingLongCounter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingLongCounter.java deleted file mode 100644 index 23a52ba2ec..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/NonBlockingLongCounter.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -import java.util.concurrent.atomic.AtomicLong; - -/** - * @author Eike Stepper - */ -public final class NonBlockingLongCounter -{ - private AtomicLong value; - - public NonBlockingLongCounter() - { - this(0L); - } - - public NonBlockingLongCounter(long initialValue) - { - value = new AtomicLong(initialValue); - } - - public long getValue() - { - return value.get(); - } - - public long increment() - { - long v; - do - { - v = value.get(); - } while (!value.compareAndSet(v, v + 1)); - - return v + 1; - } - - @Override - public String toString() - { - return Long.toString(getValue()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWLock.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWLock.java deleted file mode 100644 index 26c4c12077..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWLock.java +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -import org.eclipse.net4j.util.WrappedException; - -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * @author Eike Stepper - */ -public class RWLock extends ReentrantReadWriteLock -{ - private static final long serialVersionUID = 1L; - - private long timeoutMillis; - - public RWLock(long timeoutMillis) - { - this.timeoutMillis = timeoutMillis; - } - - public RWLock(long timeoutMillis, boolean fair) - { - super(fair); - this.timeoutMillis = timeoutMillis; - } - - public <V> V read(Callable<V> callable) - { - return call(callable, readLock(), timeoutMillis); - } - - public void read(Runnable runnable) - { - run(runnable, readLock(), timeoutMillis); - } - - public <V> V write(Callable<V> callable) - { - return call(callable, writeLock(), timeoutMillis); - } - - public void write(Runnable runnable) - { - run(runnable, writeLock(), timeoutMillis); - } - - public static <V> V call(Callable<V> callable, Lock lock, long timeoutMillis) - { - try - { - boolean locked = lock.tryLock(timeoutMillis, TimeUnit.MILLISECONDS); - if (locked) - { - try - { - return callable.call(); - } - finally - { - lock.unlock(); - } - } - - throw new TimeoutException("Acquisition of lock timed out after " + timeoutMillis + " millis"); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - public static void run(Runnable runnable, Lock lock, long timeoutMillis) - { - try - { - boolean locked = lock.tryLock(timeoutMillis, TimeUnit.MILLISECONDS); - if (locked) - { - try - { - runnable.run(); - } - finally - { - lock.unlock(); - } - } - else - { - throw new TimeoutException("Acquisition of lock timed out after " + timeoutMillis + " millis"); - } - } - catch (InterruptedException ignore) - { - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Sleeper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Sleeper.java deleted file mode 100644 index bc5da97c20..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/Sleeper.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -/** - * @author Eike Stepper - */ -public class Sleeper -{ - private static final int DEFAULT_INTERVAL = 10; - - private long start; - - private int interval; - - public Sleeper() - { - this(DEFAULT_INTERVAL); - } - - public Sleeper(int interval) - { - this.interval = interval; - restart(); - } - - public int getInterval() - { - return interval; - } - - public long getStart() - { - return start; - } - - public void restart() - { - start = System.currentTimeMillis(); - } - - public void sleep(long millis) - { - while (System.currentTimeMillis() < start + millis) - { - ConcurrencyUtil.sleep(interval); - } - } - - public void resleep(long millis) - { - restart(); - sleep(millis); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java deleted file mode 100644 index 35879444a4..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/TimeoutRuntimeException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.concurrent; - -/** - * @author Eike Stepper - */ -public class TimeoutRuntimeException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public TimeoutRuntimeException() - { - } - - public TimeoutRuntimeException(String message) - { - super(message); - } - - public TimeoutRuntimeException(Throwable cause) - { - super(cause); - } - - public TimeoutRuntimeException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/package.html deleted file mode 100644 index bd695ca252..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Utility interfaces and classes commonly useful in concurrent programming. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java deleted file mode 100644 index 4064df9f96..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ContainerUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -import org.eclipse.net4j.internal.util.container.ManagedContainer; -import org.eclipse.net4j.util.event.IListener; - -/** - * @author Eike Stepper - */ -public final class ContainerUtil -{ - private static final Object[] NO_ELEMENTS = {}; - - private static final IContainer<Object> EMPTY = new IContainer<Object>() - { - public Object[] getElements() - { - return NO_ELEMENTS; - } - - public boolean isEmpty() - { - return true; - } - - public void addListener(IListener listener) - { - } - - public void removeListener(IListener listener) - { - } - - @Override - public String toString() - { - return "EMPTY_CONTAINER"; - } - }; - - private ContainerUtil() - { - } - - public static IContainer<Object> emptyContainer() - { - return EMPTY; - } - - public static IManagedContainer createContainer() - { - return new ManagedContainer(); - } - - public static boolean isEmpty(Object container) - { - if (container instanceof IContainer) - { - return ((IContainer<?>)container).isEmpty(); - } - - return true; - } - - public static Object[] getElements(Object container) - { - if (container instanceof IContainer) - { - return ((IContainer<?>)container).getElements(); - } - - return NO_ELEMENTS; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/FactoryNotFoundException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/FactoryNotFoundException.java deleted file mode 100644 index 1b2300dcbf..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/FactoryNotFoundException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -/** - * @author Eike Stepper - */ -public class FactoryNotFoundException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public FactoryNotFoundException() - { - } - - public FactoryNotFoundException(String message) - { - super(message); - } - - public FactoryNotFoundException(Throwable cause) - { - super(cause); - } - - public FactoryNotFoundException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainer.java deleted file mode 100644 index ea05f57f72..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainer.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -import org.eclipse.net4j.util.event.INotifier; - -/** - * @author Eike Stepper - */ -public interface IContainer<E> extends INotifier -{ - public boolean isEmpty(); - - public E[] getElements(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerDelta.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerDelta.java deleted file mode 100644 index da2145647e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerDelta.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -/** - * @author Eike Stepper - */ -public interface IContainerDelta<E> -{ - public E getElement(); - - public Kind getKind(); - - /** - * @author Eike Stepper - */ - public enum Kind - { - ADDED, REMOVED - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java deleted file mode 100644 index 70971cae02..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -import org.eclipse.net4j.util.container.IContainerDelta.Kind; -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface IContainerEvent<E> extends IEvent -{ - public IContainer<E> getContainer(); - - public boolean isEmpty(); - - public IContainerDelta<E>[] getDeltas(); - - public IContainerDelta<E> getDelta() throws IllegalStateException; - - public E getDeltaElement() throws IllegalStateException; - - public Kind getDeltaKind() throws IllegalStateException; - - public void accept(IContainerEventVisitor<E> visitor); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEventVisitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEventVisitor.java deleted file mode 100644 index c87a0654ec..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IContainerEventVisitor.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -/** - * @author Eike Stepper - */ -public interface IContainerEventVisitor<E> -{ - public void added(E element); - - public void removed(E element); - - /** - * @author Eike Stepper - */ - public interface Filtered<E> extends IContainerEventVisitor<E> - { - public boolean filter(E element); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IElementProcessor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IElementProcessor.java deleted file mode 100644 index 52ecb03b78..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IElementProcessor.java +++ /dev/null @@ -1,20 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -/** - * @author Eike Stepper - */ -public interface IElementProcessor -{ - public Object process(IManagedContainer container, String productGroup, String factoryType, String description, - Object element); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java deleted file mode 100644 index 343d6d1b64..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -import org.eclipse.net4j.util.factory.IFactory; -import org.eclipse.net4j.util.factory.IFactoryKey; -import org.eclipse.net4j.util.registry.IRegistry; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public interface IManagedContainer extends IContainer<Object> -{ - public IRegistry<IFactoryKey, IFactory> getFactoryRegistry(); - - public IManagedContainer registerFactory(IFactory factory); - - public List<IElementProcessor> getPostProcessors(); - - public void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements); - - public void addPostProcessor(IElementProcessor postProcessor); - - public void removePostProcessor(IElementProcessor postProcessor); - - public Set<String> getProductGroups(); - - public Set<String> getFactoryTypes(String productGroup); - - public IFactory getFactory(String productGroup, String factoryType); - - public Object putElement(String productGroup, String factoryType, String description, Object element); - - public String[] getElementKey(Object element); - - public Object[] getElements(String productGroup); - - public Object[] getElements(String productGroup, String factoryType); - - public Object getElement(String productGroup, String factoryType, String description); - - public Object removeElement(String productGroup, String factoryType, String description); - - public void clearElements(); - - public void loadElements(InputStream stream) throws IOException; - - public void saveElements(OutputStream stream) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginContainer.java deleted file mode 100644 index 444ed5185e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IPluginContainer.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container; - -import org.eclipse.net4j.internal.util.container.PluginContainer; - -/** - * @author Eike Stepper - */ -public interface IPluginContainer extends IManagedContainer -{ - public static final IPluginContainer INSTANCE = PluginContainer.getInstance(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerBlockingQueue.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerBlockingQueue.java deleted file mode 100644 index cbb971adce..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerBlockingQueue.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import java.util.concurrent.BlockingQueue; - -/** - * @author Eike Stepper - */ -public interface IContainerBlockingQueue<E> extends IContainerQueue<E>, BlockingQueue<E> -{ - public BlockingQueue<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerCollection.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerCollection.java deleted file mode 100644 index 8edaac2503..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerCollection.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import org.eclipse.net4j.util.container.IContainer; - -import java.util.Collection; - -/** - * @author Eike Stepper - */ -public interface IContainerCollection<E> extends IContainer<E>, Collection<E> -{ - public Collection<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerList.java deleted file mode 100644 index 112ae7860d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerList.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public interface IContainerList<E> extends IContainerCollection<E>, List<E> -{ - public List<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerMap.java deleted file mode 100644 index 8c79d3f520..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerMap.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import org.eclipse.net4j.util.container.IContainer; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public interface IContainerMap<K, V> extends IContainer<Map.Entry<K, V>>, Map<K, V> -{ - public Map<K, V> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerQueue.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerQueue.java deleted file mode 100644 index df38858104..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerQueue.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import java.util.Queue; - -/** - * @author Eike Stepper - */ -public interface IContainerQueue<E> extends IContainerCollection<E>, Queue<E> -{ - public Queue<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSet.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSet.java deleted file mode 100644 index 1794fbeb23..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSet.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import java.util.Set; - -/** - * @author Eike Stepper - */ -public interface IContainerSet<E> extends IContainerCollection<E>, Set<E> -{ - public Set<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSortedSet.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSortedSet.java deleted file mode 100644 index ef1a696269..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/IContainerSortedSet.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.container.delegate; - -import java.util.SortedSet; - -/** - * @author Eike Stepper - */ -public interface IContainerSortedSet<E> extends IContainerSet<E>, SortedSet<E> -{ - public SortedSet<E> getDelegate(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/package.html deleted file mode 100644 index 2bcc5686a3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/delegate/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Hybrid interfaces of notifying containers and the Java Collection Framework. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/package.html deleted file mode 100644 index 4495924079..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework of notifying collections and wiring containers. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/EventUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/EventUtil.java deleted file mode 100644 index b90d99bbce..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/EventUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.event; - -/** - * @author Eike Stepper - */ -public final class EventUtil -{ - private static final IListener[] NO_LISTENERS = new IListener[0]; - - private EventUtil() - { - } - - public static boolean addListener(Object notifier, IListener listener) - { - if (notifier instanceof INotifier) - { - ((INotifier)notifier).addListener(listener); - return true; - } - - return false; - } - - public static boolean removeListener(Object notifier, IListener listener) - { - if (notifier instanceof INotifier) - { - ((INotifier)notifier).removeListener(listener); - return true; - } - - return false; - } - - public static IListener[] getListeners(Object notifier) - { - if (notifier instanceof INotifier.Introspection) - { - return ((INotifier.Introspection)notifier).getListeners(); - } - - return NO_LISTENERS; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IEvent.java deleted file mode 100644 index aa0921bffa..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.event; - -/** - * @author Eike Stepper - */ -public interface IEvent -{ - public INotifier getSource(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IListener.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IListener.java deleted file mode 100644 index dce34eaac3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/IListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.event; - -import java.util.EventListener; - -/** - * @author Eike Stepper - */ -public interface IListener extends EventListener -{ - public void notifyEvent(IEvent event); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/INotifier.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/INotifier.java deleted file mode 100644 index 39f3701934..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/INotifier.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.event; - -/** - * @author Eike Stepper - */ -public interface INotifier -{ - public void addListener(IListener listener); - - public void removeListener(IListener listener); - - /** - * @author Eike Stepper - */ - public interface Introspection extends INotifier - { - public boolean hasListeners(); - - public IListener[] getListeners(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/package.html deleted file mode 100644 index 2c5acc4d69..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/event/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for sending of and listening to events. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactory.java deleted file mode 100644 index 9f81f03bc2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.factory; - -/** - * @author Eike Stepper - */ -public interface IFactory -{ - public IFactoryKey getKey(); - - public Object create(String description) throws ProductCreationException; - - public String getDescriptionFor(Object product); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactoryKey.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactoryKey.java deleted file mode 100644 index e246b14eec..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/IFactoryKey.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.factory; - -/** - * @author Eike Stepper - */ -public interface IFactoryKey -{ - public String getProductGroup(); - - public String getType(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/ProductCreationException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/ProductCreationException.java deleted file mode 100644 index a18090c457..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/ProductCreationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.factory; - -/** - * @author Eike Stepper - */ -public class ProductCreationException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public ProductCreationException() - { - } - - public ProductCreationException(String message) - { - super(message); - } - - public ProductCreationException(Throwable cause) - { - super(cause); - } - - public ProductCreationException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/package.html deleted file mode 100644 index fcd135183d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/factory/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for factory based instance creation. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/FiniteStateMachine.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/FiniteStateMachine.java deleted file mode 100644 index fa543c02f0..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/FiniteStateMachine.java +++ /dev/null @@ -1,315 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.fsm; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public abstract class FiniteStateMachine<STATE extends Enum<?>, EVENT extends Enum<?>, SUBJECT> extends Lifecycle -{ - @SuppressWarnings("unchecked") - public static final ITransition IGNORE = new IgnoreTransition(); - - @SuppressWarnings("unchecked") - public static final ITransition FAIL = new FailTransition(); - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, FiniteStateMachine.class); - - private static final String MSG_PROCESS = "Processing event {0} in state {1} for {2} (data={3})"; - - private static final String MSG_IGNORE = "Ignoring event {0} in state {1} for {2} (data={3})"; - - private static final String MSG_FAIL = "Failing event {0} in state {1} for {2} (data={3})"; - - private STATE[] states; - - private EVENT[] events; - - private ITransition<STATE, EVENT, SUBJECT, ?>[][] transitions; - - @SuppressWarnings("unchecked") - public FiniteStateMachine(Class<STATE> stateEnum, Class<EVENT> eventEnum, - ITransition<STATE, EVENT, SUBJECT, ?> defaultTransition) - { - states = stateEnum.getEnumConstants(); - events = eventEnum.getEnumConstants(); - transitions = new ITransition[states.length][events.length]; - initAll(defaultTransition); - } - - @SuppressWarnings("unchecked") - public FiniteStateMachine(Class<STATE> stateEnum, Class<EVENT> eventEnum) - { - this(stateEnum, eventEnum, FAIL); - } - - public final STATE[] getStates() - { - return states; - } - - public final EVENT[] getEvents() - { - return events; - } - - public final ITransition<STATE, EVENT, SUBJECT, ?> getTransition(STATE state, EVENT event) - { - int s = state.ordinal(); - int e = event.ordinal(); - return transitions[s][e]; - } - - public final void init(STATE state, EVENT event, STATE targetState) - { - init(state, event, new ChangeStateTransition(targetState)); - } - - public final void init(STATE state, EVENT event, ITransition<STATE, EVENT, SUBJECT, ?> transition) - { - checkTransition(transition); - int s = state.ordinal(); - int e = event.ordinal(); - transitions[s][e] = transition; - } - - public final void initEvents(STATE state, STATE targetState) - { - initEvents(state, new ChangeStateTransition(targetState)); - } - - public final void initEvents(STATE state, ITransition<STATE, EVENT, SUBJECT, ?> transition) - { - checkTransition(transition); - int s = state.ordinal(); - for (int e = 0; e < events.length; e++) - { - transitions[s][e] = transition; - } - } - - public final void initStates(EVENT event, STATE targetState) - { - initStates(event, new ChangeStateTransition(targetState)); - } - - public final void initStates(EVENT event, ITransition<STATE, EVENT, SUBJECT, ?> transition) - { - checkTransition(transition); - int e = event.ordinal(); - for (int s = 0; s < states.length; s++) - { - transitions[s][e] = transition; - } - } - - public final void initAll(STATE targetState) - { - initAll(new ChangeStateTransition(targetState)); - } - - public final void initAll(ITransition<STATE, EVENT, SUBJECT, ?> transition) - { - checkTransition(transition); - for (int s = 0; s < states.length; s++) - { - for (int e = 0; e < events.length; e++) - { - transitions[s][e] = transition; - } - } - } - - @SuppressWarnings("unchecked") - public final <DATA> void process(SUBJECT subject, EVENT event, DATA data) - { - STATE state = getState(subject); - int s = state.ordinal(); - int e = event.ordinal(); - ITransition<STATE, EVENT, SUBJECT, DATA> transition = (ITransition<STATE, EVENT, SUBJECT, DATA>)transitions[s][e]; - if (transition == IGNORE) - { - // Do nothing - } - else if (transition == FAIL) - { - throw new IllegalStateException(formatFailMessage(subject, state, event, data)); - } - else - { - if (TRACER.isEnabled()) - { - TRACER.trace(formatProcessMessage(subject, state, event, data)); - } - - transition.execute(subject, state, event, data); - } - } - - @SuppressWarnings("unchecked") - protected ITransition<STATE, EVENT, SUBJECT, ?> createIgnoreTransition(STATE state, EVENT event) - { - return IGNORE; - } - - @SuppressWarnings("unchecked") - protected ITransition<STATE, EVENT, SUBJECT, ?> createFailTransition(STATE state, EVENT event) - { - return FAIL; - } - - protected String formatProcessMessage(SUBJECT subject, STATE state, EVENT event, Object data) - { - return MessageFormat.format(MSG_PROCESS, event, state, subject, data); - } - - protected String formatIgnoreMessage(SUBJECT subject, STATE state, EVENT event, Object data) - { - return MessageFormat.format(MSG_IGNORE, event, state, subject, data); - } - - protected String formatFailMessage(SUBJECT subject, STATE state, EVENT event, Object data) - { - return MessageFormat.format(MSG_FAIL, event, state, subject, data); - } - - protected abstract STATE getState(SUBJECT subject); - - protected abstract void setState(SUBJECT subject, STATE state); - - protected void changeState(SUBJECT subject, STATE state) - { - STATE oldState = getState(subject); - setState(subject, state); - if (oldState != state) - { - fireEvent(new StateChangedEvent(subject, oldState, state)); - } - } - - private void checkTransition(ITransition<STATE, EVENT, SUBJECT, ?> transition) - { - if (transition == null) - { - throw new IllegalArgumentException("transition == null"); - } - } - - /** - * @author Eike Stepper - */ - public static class IgnoreTransition implements ITransition<Enum<?>, Enum<?>, Object, Object> - { - public void execute(Object subject, Enum<?> state, Enum<?> event, Object data) - { - // Do nothing - } - - @Override - public String toString() - { - return "IGNORE"; - } - } - - /** - * @author Eike Stepper - */ - public static class FailTransition implements ITransition<Enum<?>, Enum<?>, Object, Object> - { - public void execute(Object subject, Enum<?> state, Enum<?> event, Object data) - { - // Do nothing - } - - @Override - public String toString() - { - return "FAIL"; - } - } - - /** - * @author Eike Stepper - */ - public class ChangeStateTransition implements ITransition<STATE, EVENT, SUBJECT, Object> - { - private STATE targetState; - - public ChangeStateTransition(STATE targetState) - { - this.targetState = targetState; - } - - public STATE getTargetState() - { - return targetState; - } - - public void execute(SUBJECT subject, STATE state, EVENT event, Object data) - { - changeState(subject, targetState); - } - - @Override - public String toString() - { - return MessageFormat.format("CHANGE_STATE[{0}]", targetState); - } - } - - /** - * @author Eike Stepper - */ - public class StateChangedEvent implements IEvent - { - private Object subject; - - private Enum<?> oldState; - - private Enum<?> newState; - - public StateChangedEvent(Object subject, Enum<?> oldState, Enum<?> newState) - { - this.subject = subject; - this.oldState = oldState; - this.newState = newState; - } - - public INotifier getSource() - { - return FiniteStateMachine.this; - } - - public Object getSubject() - { - return subject; - } - - public Enum<?> getOldState() - { - return oldState; - } - - public Enum<?> getNewState() - { - return newState; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/ITransition.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/ITransition.java deleted file mode 100644 index 73cffb5d61..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/ITransition.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.fsm; - -/** - * @author Eike Stepper - */ -public interface ITransition<STATE extends Enum<?>, EVENT extends Enum<?>, SUBJECT, DATA> -{ - public void execute(SUBJECT subject, STATE state, EVENT event, DATA data); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/package.html deleted file mode 100644 index e0810a4ece..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for finite state machines. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java deleted file mode 100644 index b366557ae3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class CachedFileMap<K extends Comparable<K>, V> extends SortedFileMap<K, V> -{ - private Map<K, V> cache = new HashMap<K, V>(); - - public CachedFileMap(File file, String mode) - { - super(file, mode); - } - - @Override - public V get(K key) - { - V value = cache.get(key); - if (value == null) - { - value = super.get(key); - cache.put(key, value); - } - - return value; - } - - @Override - public V put(K key, V value) - { - cache.put(key, value); - return super.put(key, value); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CloseableIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CloseableIterator.java deleted file mode 100644 index 24ed7f651b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CloseableIterator.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.Closeable; -import java.util.Iterator; - -/** - * @author Eike Stepper - */ -public interface CloseableIterator<E> extends Iterator<E>, Closeable -{ -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataInputExtender.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataInputExtender.java deleted file mode 100644 index 2145d11e6f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataInputExtender.java +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.util.io.ExtendedIOUtil.ClassResolver; - -import java.io.DataInput; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class DataInputExtender implements ExtendedDataInput -{ - private DataInput input; - - public DataInputExtender(DataInput input) - { - this.input = input; - } - - public boolean readBoolean() throws IOException - { - return input.readBoolean(); - } - - public byte readByte() throws IOException - { - return input.readByte(); - } - - public char readChar() throws IOException - { - return input.readChar(); - } - - public double readDouble() throws IOException - { - return input.readDouble(); - } - - public float readFloat() throws IOException - { - return input.readFloat(); - } - - public void readFully(byte[] b, int off, int len) throws IOException - { - input.readFully(b, off, len); - } - - public void readFully(byte[] b) throws IOException - { - input.readFully(b); - } - - public int readInt() throws IOException - { - return input.readInt(); - } - - public String readLine() throws IOException - { - return input.readLine(); - } - - public long readLong() throws IOException - { - return input.readLong(); - } - - public short readShort() throws IOException - { - return input.readShort(); - } - - public int readUnsignedByte() throws IOException - { - return input.readUnsignedByte(); - } - - public int readUnsignedShort() throws IOException - { - return input.readUnsignedShort(); - } - - public String readUTF() throws IOException - { - return input.readUTF(); - } - - public byte[] readByteArray() throws IOException - { - return ExtendedIOUtil.readByteArray(input); - } - - public Object readObject() throws IOException - { - return ExtendedIOUtil.readObject(input); - } - - public Object readObject(ClassLoader classLoader) throws IOException - { - return ExtendedIOUtil.readObject(input, classLoader); - } - - public Object readObject(ClassResolver classResolver) throws IOException - { - return ExtendedIOUtil.readObject(input, classResolver); - } - - public String readString() throws IOException - { - return ExtendedIOUtil.readString(input); - } - - public int skipBytes(int n) throws IOException - { - return input.skipBytes(n); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataOutputExtender.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataOutputExtender.java deleted file mode 100644 index c0696bc8e2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DataOutputExtender.java +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.DataOutput; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class DataOutputExtender implements ExtendedDataOutput -{ - private DataOutput output; - - public DataOutputExtender(DataOutput output) - { - this.output = output; - } - - public void write(byte[] b, int off, int len) throws IOException - { - output.write(b, off, len); - } - - public void write(byte[] b) throws IOException - { - output.write(b); - } - - public void write(int b) throws IOException - { - output.write(b); - } - - public void writeBoolean(boolean v) throws IOException - { - output.writeBoolean(v); - } - - public void writeByte(int v) throws IOException - { - output.writeByte(v); - } - - public void writeBytes(String s) throws IOException - { - output.writeBytes(s); - } - - public void writeChar(int v) throws IOException - { - output.writeChar(v); - } - - public void writeChars(String s) throws IOException - { - output.writeChars(s); - } - - public void writeDouble(double v) throws IOException - { - output.writeDouble(v); - } - - public void writeFloat(float v) throws IOException - { - output.writeFloat(v); - } - - public void writeInt(int v) throws IOException - { - output.writeInt(v); - } - - public void writeLong(long v) throws IOException - { - output.writeLong(v); - } - - public void writeShort(int v) throws IOException - { - output.writeShort(v); - } - - public void writeUTF(String str) throws IOException - { - output.writeUTF(str); - } - - public void writeByteArray(byte[] b) throws IOException - { - ExtendedIOUtil.writeByteArray(output, b); - } - - public void writeObject(Object object) throws IOException - { - ExtendedIOUtil.writeObject(output, object); - } - - public void writeString(String str) throws IOException - { - ExtendedIOUtil.writeString(output, str); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingInputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingInputStream.java deleted file mode 100644 index 06a837a27b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingInputStream.java +++ /dev/null @@ -1,179 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; - -/** - * A <code>DelegatingInputStream</code> contains some other input stream, which it uses as its basic source of data, - * possibly transforming the data along the way or providing additional functionality. The class - * <code>DelegatingInputStream</code> itself simply overrides all (see note below) methods of <code>InputStream</code> - * with versions that pass all requests to the contained input stream. Subclasses of <code>DelegatingInputStream</code> - * may further override some of these methods and may also provide additional methods and fields. - * <p> - * <b>Note:</b> The only difference to {@link java.io.FilterInputStream} is that <code>DelegatingInputStream</code> - * does <b>not</b> override {@link #read(byte[])} or {@link #read(byte[], int, int)} but rather exposes the original - * implementations of <code>InputStream</code> which call {@link #read()} instead of their delegate counterparts. - * - * @author Eike Stepper - */ -public class DelegatingInputStream extends InputStream -{ - /** - * The input stream to be filtered. - */ - protected volatile InputStream in; - - /** - * Creates a <code>DelegatingInputStream</code> by assigning the argument <code>in</code> to the field - * <code>this.in</code> so as to remember it for later use. - * - * @param in - * the underlying input stream, or <code>null</code> if this instance is to be created without an - * underlying stream. - */ - protected DelegatingInputStream(InputStream in) - { - this.in = in; - } - - public InputStream getDelegate() - { - return in; - } - - /** - * Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the - * range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been - * reached, the value <code>-1</code> is returned. This method blocks until input data is available, the end of the - * stream is detected, or an exception is thrown. - * <p> - * This method simply performs <code>in.read()</code> and returns the result. - * - * @return the next byte of data, or <code>-1</code> if the end of the stream is reached. - * @exception IOException - * if an I/O error occurs. - * @see DelegatingInputStream#in - */ - @Override - public int read() throws IOException - { - return in.read(); - } - - /** - * Skips over and discards <code>n</code> bytes of data from the input stream. The <code>skip</code> method may, - * for a variety of reasons, end up skipping over some smaller number of bytes, possibly <code>0</code>. The actual - * number of bytes skipped is returned. - * <p> - * This method simply performs <code>in.skip(n)</code>. - * - * @param n - * the number of bytes to be skipped. - * @return the actual number of bytes skipped. - * @exception IOException - * if an I/O error occurs. - */ - @Override - public long skip(long n) throws IOException - { - return in.skip(n); - } - - /** - * Returns the number of bytes that can be read from this input stream without blocking. - * <p> - * This method simply performs <code>in.available()</code> and returns the result. - * - * @return the number of bytes that can be read from the input stream without blocking. - * @exception IOException - * if an I/O error occurs. - * @see DelegatingInputStream#in - */ - @Override - public int available() throws IOException - { - return in.available(); - } - - /** - * Closes this input stream and releases any system resources associated with the stream. This method simply performs - * <code>in.close()</code>. - * - * @exception IOException - * if an I/O error occurs. - * @see DelegatingInputStream#in - */ - @Override - public void close() throws IOException - { - in.close(); - } - - /** - * Marks the current position in this input stream. A subsequent call to the <code>reset</code> method repositions - * this stream at the last marked position so that subsequent reads re-read the same bytes. - * <p> - * The <code>readlimit</code> argument tells this input stream to allow that many bytes to be read before the mark - * position gets invalidated. - * <p> - * This method simply performs <code>in.mark(readlimit)</code>. - * - * @param readlimit - * the maximum limit of bytes that can be read before the mark position becomes invalid. - * @see DelegatingInputStream#in - * @see DelegatingInputStream#reset() - */ - @Override - public synchronized void mark(int readlimit) - { - in.mark(readlimit); - } - - /** - * Repositions this stream to the position at the time the <code>mark</code> method was last called on this input - * stream. - * <p> - * This method simply performs <code>in.reset()</code>. - * <p> - * Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the - * stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the - * parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it - * fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser. - * - * @exception IOException - * if the stream has not been marked or if the mark has been invalidated. - * @see DelegatingInputStream#in - * @see DelegatingInputStream#mark(int) - */ - @Override - public synchronized void reset() throws IOException - { - in.reset(); - } - - /** - * Tests if this input stream supports the <code>mark</code> and <code>reset</code> methods. This method simply - * performs <code>in.markSupported()</code>. - * - * @return <code>true</code> if this stream type supports the <code>mark</code> and <code>reset</code> method; - * <code>false</code> otherwise. - * @see DelegatingInputStream#in - * @see java.io.InputStream#mark(int) - * @see java.io.InputStream#reset() - */ - @Override - public boolean markSupported() - { - return in.markSupported(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingOutputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingOutputStream.java deleted file mode 100644 index e49fe25605..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingOutputStream.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * This class is the superclass of all classes that filter output streams. These streams sit on top of an already - * existing output stream (the <i>underlying</i> output stream) which it uses as its basic sink of data, but possibly - * transforming the data along the way or providing additional functionality. - * <p> - * The class <code>DelegatingOutputStream</code> itself simply overrides all methods of <code>OutputStream</code> - * with versions that pass all requests to the underlying output stream. Subclasses of - * <code>DelegatingOutputStream</code> may further override some of these methods as well as provide additional - * methods and fields. - * <p> - * <b>Note:</b> The only difference to {@link java.io.FilterOutputStream} is that <code>DelegatingOutputStream</code> - * does <b>not</b> override {@link #write(byte[])} or {@link #write(byte[], int, int)} but rather exposes the original - * implementations of <code>InputStream</code> which call {@link #write(int)} instead of their delegate counterparts. - * - * @author Eike Stepper - */ -public class DelegatingOutputStream extends OutputStream -{ - /** - * The underlying output stream to be filtered. - */ - protected OutputStream out; - - /** - * Creates an output stream filter built on top of the specified underlying output stream. - * - * @param out - * the underlying output stream to be assigned to the field <tt>this.out</tt> for later use, or - * <code>null</code> if this instance is to be created without an underlying stream. - */ - public DelegatingOutputStream(OutputStream out) - { - this.out = out; - } - - public OutputStream getDelegate() - { - return out; - } - - /** - * Writes the specified <code>byte</code> to this output stream. - * <p> - * The <code>write</code> method of <code>DelegatingOutputStream</code> calls the <code>write</code> method of - * its underlying output stream, that is, it performs <tt>out.write(b)</tt>. - * <p> - * Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>. - * - * @param b - * the <code>byte</code>. - * @exception IOException - * if an I/O error occurs. - */ - @Override - public void write(int b) throws IOException - { - out.write(b); - } - - /** - * Flushes this output stream and forces any buffered output bytes to be written out to the stream. - * <p> - * The <code>flush</code> method of <code>DelegatingOutputStream</code> calls the <code>flush</code> method of - * its underlying output stream. - * - * @exception IOException - * if an I/O error occurs. - * @see DelegatingOutputStream#out - */ - @Override - public void flush() throws IOException - { - out.flush(); - } - - /** - * Closes this output stream and releases any system resources associated with the stream. - * <p> - * The <code>close</code> method of <code>DelegatingOutputStream</code> calls its <code>flush</code> method, and - * then calls the <code>close</code> method of its underlying output stream. - * - * @exception IOException - * if an I/O error occurs. - * @see DelegatingOutputStream#flush() - * @see DelegatingOutputStream#out - */ - @Override - public void close() throws IOException - { - try - { - flush(); - } - catch (IOException ignored) - { - } - out.close(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java deleted file mode 100644 index c3ded5a8a5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/DelegatingStreamWrapper.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public abstract class DelegatingStreamWrapper implements IStreamWrapper -{ - private IStreamWrapper delegate; - - public DelegatingStreamWrapper(IStreamWrapper delegate) - { - this.delegate = delegate; - } - - public IStreamWrapper getDelegate() - { - return delegate; - } - - public InputStream wrapInputStream(InputStream in) throws IOException - { - return doWrapInputStream(delegate.wrapInputStream(in)); - } - - public OutputStream wrapOutputStream(OutputStream out) throws IOException - { - return doWrapOutputStream(delegate.wrapOutputStream(out)); - } - - public void finishInputStream(InputStream in) throws IOException - { - delegate.finishInputStream(in); - doFinishInputStream(in); - } - - public void finishOutputStream(OutputStream out) throws IOException - { - delegate.finishOutputStream(out); - doFinishOutputStream(out); - } - - protected abstract InputStream doWrapInputStream(InputStream in) throws IOException; - - protected abstract OutputStream doWrapOutputStream(OutputStream out) throws IOException; - - protected abstract void doFinishInputStream(InputStream in) throws IOException; - - protected abstract void doFinishOutputStream(OutputStream out) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInput.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInput.java deleted file mode 100644 index d5a2dd5376..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInput.java +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.util.io.ExtendedIOUtil.ClassResolver; - -import java.io.DataInput; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public interface ExtendedDataInput extends DataInput -{ - public byte[] readByteArray() throws IOException; - - public Object readObject() throws IOException; - - public Object readObject(ClassLoader classLoader) throws IOException; - - public Object readObject(ClassResolver classResolver) throws IOException; - - public String readString() throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInputStream.java deleted file mode 100644 index e87a579f1a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataInputStream.java +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.util.io.ExtendedIOUtil.ClassResolver; - -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Eike Stepper - */ -public class ExtendedDataInputStream extends DataInputStream implements ExtendedDataInput -{ - public ExtendedDataInputStream(InputStream in) - { - super(in); - } - - public byte[] readByteArray() throws IOException - { - return ExtendedIOUtil.readByteArray(this); - } - - public String readString() throws IOException - { - return ExtendedIOUtil.readString(this); - } - - public Object readObject() throws IOException - { - return ExtendedIOUtil.readObject(this); - } - - public Object readObject(ClassLoader classLoader) throws IOException - { - return ExtendedIOUtil.readObject(this, classLoader); - } - - public Object readObject(ClassResolver classResolver) throws IOException - { - return ExtendedIOUtil.readObject(this, classResolver); - } - - public static ExtendedDataInputStream wrap(InputStream stream) - { - if (stream instanceof ExtendedDataInputStream) - { - return (ExtendedDataInputStream)stream; - } - - return new ExtendedDataInputStream(stream); - } - - public static InputStream unwrap(InputStream stream) - { - if (stream instanceof ExtendedDataInputStream) - { - return ((ExtendedDataInputStream)stream).in; - } - - return stream; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutput.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutput.java deleted file mode 100644 index a11b10b4fd..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutput.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.DataOutput; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public interface ExtendedDataOutput extends DataOutput -{ - public void writeByteArray(byte[] b) throws IOException; - - public void writeObject(Object object) throws IOException; - - public void writeString(String str) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutputStream.java deleted file mode 100644 index f304f10101..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedDataOutputStream.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public class ExtendedDataOutputStream extends DataOutputStream implements ExtendedDataOutput -{ - public ExtendedDataOutputStream(OutputStream out) - { - super(out); - } - - public void writeByteArray(byte[] b) throws IOException - { - ExtendedIOUtil.writeByteArray(this, b); - } - - public void writeString(String str) throws IOException - { - ExtendedIOUtil.writeString(this, str); - } - - public void writeObject(Object object) throws IOException - { - ExtendedIOUtil.writeObject(this, object); - } - - public static ExtendedDataOutputStream wrap(OutputStream stream) - { - if (stream instanceof ExtendedDataOutputStream) - { - return (ExtendedDataOutputStream)stream; - } - - return new ExtendedDataOutputStream(stream); - } - - public static OutputStream unwrap(OutputStream stream) - { - if (stream instanceof ExtendedDataOutputStream) - { - return ((ExtendedDataOutputStream)stream).out; - } - - return stream; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedIOUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedIOUtil.java deleted file mode 100644 index 3c0aa81a73..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ExtendedIOUtil.java +++ /dev/null @@ -1,239 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.WrappedException; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInput; -import java.io.ObjectInputStream; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamClass; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public final class ExtendedIOUtil -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, ExtendedIOUtil.class); - - private static final int UTF_HEADER_SIZE = 2; - - private static final int MAX_16_BIT = (1 << 16) - 1; - - private static final int MAX_UTF_LENGTH = MAX_16_BIT - UTF_HEADER_SIZE; - - private static final int MAX_UTF_CHARS = MAX_UTF_LENGTH / 3; - - private ExtendedIOUtil() - { - } - - public static void writeByteArray(DataOutput out, byte[] b) throws IOException - { - if (b != null) - { - out.writeInt(b.length); - out.write(b); - } - else - { - out.writeInt(-1); - } - } - - public static void writeObject(final DataOutput out, Object object) throws IOException - { - ObjectOutput wrapper = null; - if (out instanceof ObjectOutput) - { - wrapper = (ObjectOutput)out; - } - else - { - wrapper = new ObjectOutputStream(new OutputStream() - { - @Override - public void write(int b) throws IOException - { - out.writeByte((b & 0xff) + Byte.MIN_VALUE); - } - }); - } - - wrapper.writeObject(object); - } - - public static void writeString(DataOutput out, String str) throws IOException - { - if (str != null) - { - int size = str.length(); - int start = 0; - do - { - out.writeBoolean(true); - int chunk = Math.min(size, MAX_UTF_CHARS); - int end = start + chunk; - out.writeUTF(str.substring(start, end)); - start = end; - size -= chunk; - } while (size > 0); - } - - out.writeBoolean(false); - } - - public static byte[] readByteArray(DataInput in) throws IOException - { - int length = in.readInt(); - if (length < 0) - { - return null; - } - - byte[] b; - try - { - b = new byte[length]; - } - catch (Throwable t) - { - throw new IOException("Unable to allocate " + length + " bytes"); - } - - in.readFully(b); - return b; - } - - public static Object readObject(final DataInput in) throws IOException - { - return readObject(in, (ClassResolver)null); - } - - public static Object readObject(final DataInput in, ClassLoader classLoader) throws IOException - { - return readObject(in, new ClassLoaderClassResolver(classLoader)); - } - - public static Object readObject(final DataInput in, final ClassResolver classResolver) throws IOException - { - ObjectInput wrapper = null; - if (in instanceof ObjectInput) - { - wrapper = (ObjectInput)in; - } - else - { - wrapper = new ObjectInputStream(new InputStream() - { - @Override - public int read() throws IOException - { - return in.readByte() - Byte.MIN_VALUE; - } - }) - { - @Override - protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException - { - if (classResolver != null) - { - if (TRACER.isEnabled()) - { - TRACER.format("Deserializing class {0}", desc.getName()); - } - - Class<?> c = classResolver.resolveClass(desc); - if (c != null) - { - return c; - } - } - - return super.resolveClass(desc); - } - }; - } - - try - { - return wrapper.readObject(); - } - catch (ClassNotFoundException ex) - { - OM.LOG.error(ex); - throw WrappedException.wrap(ex); - } - } - - public static String readString(DataInput in) throws IOException - { - boolean more = in.readBoolean(); - if (!more) - { - return null; - } - - StringBuilder builder = new StringBuilder(); - do - { - String chunk = in.readUTF(); - builder.append(chunk); - more = in.readBoolean(); - } while (more); - - return builder.toString(); - } - - /** - * @author Eike Stepper - */ - public interface ClassResolver - { - public Class<?> resolveClass(ObjectStreamClass v) throws ClassNotFoundException; - } - - /** - * @author Eike Stepper - */ - public static class ClassLoaderClassResolver implements ClassResolver - { - private ClassLoader classLoader; - - public ClassLoaderClassResolver(ClassLoader classLoader) - { - this.classLoader = classLoader; - } - - public Class<?> resolveClass(ObjectStreamClass v) throws ClassNotFoundException - { - String className = v.getName(); - - try - { - return classLoader.loadClass(className); - } - catch (ClassNotFoundException ex) - { - OM.LOG.error(ex); - return null; - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java deleted file mode 100644 index db8e90f96d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * @author Eike Stepper - */ -public class GZIPStreamWrapper implements IStreamWrapper -{ - public GZIPStreamWrapper() - { - } - - public GZIPInputStream wrapInputStream(InputStream in) throws IOException - { - if (in instanceof GZIPInputStream) - { - return (GZIPInputStream)in; - } - - return new GZIPInputStream(in); - } - - public GZIPOutputStream wrapOutputStream(OutputStream out) throws IOException - { - if (out instanceof GZIPOutputStream) - { - return (GZIPOutputStream)out; - } - - return new GZIPOutputStream(out); - } - - public void finishInputStream(InputStream in) throws IOException - { - } - - public void finishOutputStream(OutputStream out) throws IOException - { - ((GZIPOutputStream)out).finish(); - } - - /** - * TODO Move or remove me - */ - public static void main(String[] args) throws Exception - { - final PipedOutputStream pos = new PipedOutputStream(); - final PipedInputStream pis = new PipedInputStream(pos); - - final GZIPOutputStream gos = new GZIPOutputStream(pos); - final byte[] out = "eike".getBytes(); - - Thread thread = new Thread() - { - @Override - public void run() - { - try - { - GZIPInputStream gis = new GZIPInputStream(pis); - - byte[] in = new byte[out.length]; - gis.read(in); - gis.close(); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - }; - - thread.start(); - ConcurrencyUtil.sleep(1000); - - gos.write(out); - gos.close(); - - ConcurrencyUtil.sleep(2000); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOFilter.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOFilter.java deleted file mode 100644 index c5d2cd4ed6..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -/** - * @author Eike Stepper - */ -public interface IOFilter<T> -{ - public T filter(T data); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORunnable.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORunnable.java deleted file mode 100644 index 21603c0e39..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORunnable.java +++ /dev/null @@ -1,22 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.Closeable; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public interface IORunnable<IO extends Closeable> -{ - public void run(IO io) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORuntimeException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORuntimeException.java deleted file mode 100644 index f764b6bed7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IORuntimeException.java +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class IORuntimeException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public IORuntimeException() - { - } - - public IORuntimeException(String message) - { - super(message); - } - - public IORuntimeException(Throwable cause) - { - super(cause); - } - - public IORuntimeException(String message, Throwable cause) - { - super(message, cause); - } - - public void unwrapIOException() throws IOException - { - if (getCause() instanceof IOException) - { - throw (IOException)getCause(); - } - - throw this; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java deleted file mode 100644 index 3050e6e7ff..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java +++ /dev/null @@ -1,564 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.internal.util.bundle.OM; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Eike Stepper - */ -public final class IOUtil -{ - public static final int DEFAULT_BUFFER_SIZE = 8192; - - private IOUtil() - { - } - - public static InputStream IN() - { - return System.in; - } - - public static PrintStream OUT() - { - return System.out; - } - - public static PrintStream ERR() - { - return System.err; - } - - public static void print(Throwable t, PrintStream stream) - { - t.printStackTrace(stream); - } - - public static void print(Throwable t) - { - print(t, System.err); - } - - public static FileInputStream openInputStream(String fileName) throws IORuntimeException - { - return openInputStream(new File(fileName)); - } - - public static FileInputStream openInputStream(File file) throws IORuntimeException - { - try - { - return new FileInputStream(file); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static FileOutputStream openOutputStream(String fileName) throws IORuntimeException - { - return openOutputStream(new File(fileName)); - } - - public static FileOutputStream openOutputStream(File file) throws IORuntimeException - { - try - { - return new FileOutputStream(file); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static FileReader openReader(String fileName) throws IORuntimeException - { - return openReader(new File(fileName)); - } - - public static FileReader openReader(File file) throws IORuntimeException - { - try - { - return new FileReader(file); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static FileWriter openWriter(String fileName) throws IORuntimeException - { - return openWriter(new File(fileName)); - } - - public static FileWriter openWriter(File file) throws IORuntimeException - { - try - { - return new FileWriter(file); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static Exception closeSilent(Closeable closeable) - { - try - { - if (closeable != null) - { - closeable.close(); - } - - return null; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return ex; - } - } - - public static void close(Closeable closeable) throws IORuntimeException - { - try - { - if (closeable != null) - { - closeable.close(); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static void mkdirs(File folder) - { - if (!folder.exists()) - { - if (!folder.mkdirs()) - { - throw new IORuntimeException("Unable to create directory " + folder.getAbsolutePath()); - } - } - } - - public static int delete(File file) - { - if (file == null) - { - return 0; - } - - int deleted = 0; - if (file.isDirectory()) - { - for (File child : file.listFiles()) - { - deleted += delete(child); - } - } - - if (file.delete()) - { - return deleted + 1; - } - - return deleted; - } - - public static void copyTree(File source, File target) throws IORuntimeException - { - if (source.isDirectory()) - { - mkdirs(target); - File[] files = source.listFiles(); - for (File file : files) - { - String name = file.getName(); - copyTree(new File(source, name), new File(target, name)); - } - } - else - { - copyFile(source, target); - } - } - - public static void copyTrees(Collection<File> sources, File target) throws IORuntimeException - { - for (File source : sources) - { - copyTree(source, target); - } - } - - public static void copyText(File source, File target, IOFilter<String>... lineFilters) throws IORuntimeException - { - BufferedReader reader = null; - BufferedWriter writer = null; - - try - { - reader = new BufferedReader(openReader(source)); - writer = new BufferedWriter(openWriter(target)); - copyText(reader, writer, lineFilters); - } - finally - { - closeSilent(reader); - closeSilent(writer); - } - } - - public static void copyText(BufferedReader reader, BufferedWriter writer, IOFilter<String>... lineFilters) - { - try - { - String line; - while ((line = reader.readLine()) != null) - { - for (IOFilter<String> lineFilter : lineFilters) - { - line = lineFilter.filter(line); - } - - writer.write(line); - writer.newLine(); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static int copy(InputStream input, OutputStream output, int size, byte buffer[]) throws IORuntimeException - { - try - { - int written = 0; - int bufferSize = buffer.length; - int n = Math.min(size, bufferSize); - while (n > 0 && (n = input.read(buffer, 0, n)) != -1) - { - output.write(buffer, 0, n); - written += n; - size -= n; - n = Math.min(size, bufferSize); - } - - return written; - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static void copy(InputStream input, OutputStream output, byte buffer[]) throws IORuntimeException - { - try - { - int n; - while ((n = input.read(buffer)) != -1) - { - output.write(buffer, 0, n); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static void copy(InputStream input, OutputStream output, int bufferSize) throws IORuntimeException - { - copy(input, output, new byte[bufferSize]); - } - - public static void copy(InputStream input, OutputStream output) throws IORuntimeException - { - copy(input, output, DEFAULT_BUFFER_SIZE); - } - - /** - * @see NIOUtil#copyFile(File, File) - */ - public static void copyFile(File source, File target) throws IORuntimeException - { - mkdirs(target.getParentFile()); - FileInputStream input = null; - FileOutputStream output = null; - - try - { - input = openInputStream(source); - output = openOutputStream(target); - copy(input, output); - } - finally - { - closeSilent(input); - closeSilent(output); - } - } - - public static byte[] readFile(File file) throws IORuntimeException - { - if (file.length() > Integer.MAX_VALUE) - { - throw new IllegalArgumentException("File too long: " + file.length()); - } - - int size = (int)file.length(); - FileInputStream input = openInputStream(file); - - try - { - ByteArrayOutputStream output = new ByteArrayOutputStream(size); - copy(input, output); - return output.toByteArray(); - } - finally - { - closeSilent(input); - } - } - - public static void writeFile(File file, byte[] bytes) throws IORuntimeException - { - FileOutputStream output = openOutputStream(file); - - try - { - ByteArrayInputStream input = new ByteArrayInputStream(bytes); - copy(input, output); - } - finally - { - closeSilent(output); - } - } - - public static List<File> listDepthFirst(File file) - { - FileCollector collector = new FileCollector(); - visitDepthFirst(file, collector); - return collector.getFiles(); - } - - public static List<File> listBreadthFirst(File file) - { - FileCollector collector = new FileCollector(); - visitBreadthFirst(file, collector); - return collector.getFiles(); - } - - public static void visitDepthFirst(File file, IOVisitor visitor) throws IORuntimeException - { - try - { - boolean recurse = visitor.visit(file); - if (recurse && file.isDirectory()) - { - visitDepthFirst(file.listFiles(), visitor); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static void visitDepthFirst(File[] files, IOVisitor visitor) - { - for (File file : files) - { - visitDepthFirst(file, visitor); - } - } - - public static void visitBreadthFirst(File file, IOVisitor visitor) throws IORuntimeException - { - File[] files = { file }; - visitBreadthFirst(files, visitor); - } - - public static void visitBreadthFirst(File[] files, IOVisitor visitor) throws IORuntimeException - { - try - { - boolean[] recurse = new boolean[files.length]; - for (int i = 0; i < files.length; i++) - { - File file = files[i]; - recurse[i] = visitor.visit(file); - } - - for (int i = 0; i < files.length; i++) - { - File file = files[i]; - if (file.isDirectory() && recurse[i]) - { - File[] children = file.listFiles(); - for (File child : children) - { - visitBreadthFirst(child, visitor); - } - } - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static <IO extends Closeable> void safeRun(IO io, IORunnable<IO> runnable) throws IORuntimeException - { - try - { - runnable.run(io); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - close(io); - } - } - - public static void safeInput(File file, IORunnable<FileInputStream> runnable) throws IORuntimeException - { - safeRun(openInputStream(file), runnable); - } - - public static void safeOutput(File file, IORunnable<FileOutputStream> runnable) throws IORuntimeException - { - safeRun(openOutputStream(file), runnable); - } - - public static void safeRead(File file, IORunnable<FileReader> runnable) throws IORuntimeException - { - safeRun(openReader(file), runnable); - } - - public static void safeWrite(File file, IORunnable<FileWriter> runnable) throws IORuntimeException - { - safeRun(openWriter(file), runnable); - } - - public static boolean equals(InputStream stream1, InputStream stream2) throws IORuntimeException - { - try - { - for (;;) - { - int byte1 = stream1.read(); - int byte2 = stream2.read(); - - if (byte1 != byte2) - { - return false; - } - - if (byte1 == -1)// Implies byte2 == -1 - { - return true; - } - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public static boolean equals(File file1, File file2) throws IORuntimeException - { - if (file1.length() != file2.length()) - { - return false; - } - - FileInputStream stream1 = null; - FileInputStream stream2 = null; - - try - { - stream1 = new FileInputStream(file1); - stream2 = new FileInputStream(file2); - return equals(stream1, stream2); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - closeSilent(stream1); - closeSilent(stream2); - } - } - - /** - * @author Eike Stepper - */ - public static class FileCollector implements IOVisitor - { - private List<File> files = new ArrayList<File>(); - - public FileCollector() - { - } - - public List<File> getFiles() - { - return files; - } - - public boolean visit(File file) throws IOException - { - files.add(file); - return true; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOVisitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOVisitor.java deleted file mode 100644 index db38e12306..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOVisitor.java +++ /dev/null @@ -1,22 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.File; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public interface IOVisitor -{ - public boolean visit(File file) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java deleted file mode 100644 index 1062666cd7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IStreamWrapper.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public interface IStreamWrapper -{ - public InputStream wrapInputStream(InputStream in) throws IOException; - - public OutputStream wrapOutputStream(OutputStream out) throws IOException; - - public void finishInputStream(InputStream in) throws IOException; - - public void finishOutputStream(OutputStream out) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java deleted file mode 100644 index 699bda1990..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/NIOUtil.java +++ /dev/null @@ -1,197 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import org.eclipse.net4j.util.ImplementationError; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; - -/** - * @author Eike Stepper - */ -public final class NIOUtil -{ - private NIOUtil() - { - } - - /** - * TODO Look at {@link #copy(File, File, boolean)} - */ - public static void copyFile(File source, File target) - { - // http://www.javalobby.org/java/forums/t17036.html - // http://java.sun.com/developer/JDCTechTips/2002/tt0507.html#tip1 - FileChannel sourceChannel = null; - FileChannel targetChannel = null; - - try - { - if (!target.getParentFile().exists()) - { - target.getParentFile().mkdirs(); - } - - if (!target.exists()) - { - target.createNewFile(); - } - - sourceChannel = new FileInputStream(source).getChannel(); - targetChannel = new FileOutputStream(target).getChannel(); - - long size = sourceChannel.size(); - long transfered = sourceChannel.transferTo(0, size, targetChannel); - if (transfered != size) - { - throw new ImplementationError("Seems as if a loop must be implemented here"); - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - IOUtil.closeSilent(sourceChannel); - IOUtil.closeSilent(targetChannel); - } - } - - /** - * Copy source file to destination. If destination is a path then source file name is appended. If destination file - * exists then: overwrite=true - destination file is replaced; overwite=false - exception is thrown. - * - * @param src - * source file - * @param dst - * destination file or path - * @param overwrite - * overwrite destination file - * @exception IOException - * I/O problem - */ - @SuppressWarnings("unused") - private static void copy(final File src, File dst, final boolean overwrite) throws IOException - { - long q = System.currentTimeMillis(); - if (!src.isFile() || !src.exists()) - { - throw new IllegalArgumentException("Source file '" + src.getAbsolutePath() + "' not found!"); - } - - if (dst.exists()) if (dst.isDirectory()) // Directory? -> use source file - // name - dst = new File(dst, src.getName()); - else if (dst.isFile()) - { - if (!overwrite) - throw new IllegalArgumentException("Destination file '" + dst.getAbsolutePath() + "' already exists!"); - } - else - throw new IllegalArgumentException("Invalid destination object '" + dst.getAbsolutePath() + "'!"); - File dstParent = dst.getParentFile(); - if (!dstParent.exists()) - if (!dstParent.mkdirs()) throw new IOException("Failed to create directory " + dstParent.getAbsolutePath()); - long fileSize = src.length(); - if (fileSize > 20971520l) - { // for larger files (20Mb) use streams - FileInputStream in = new FileInputStream(src); - FileOutputStream out = new FileOutputStream(dst); - try - { - int doneCnt = -1, bufSize = 32768; - byte buf[] = new byte[bufSize]; - while ((doneCnt = in.read(buf, 0, bufSize)) >= 0) - if (doneCnt == 0) - Thread.yield(); - else - out.write(buf, 0, doneCnt); - out.flush(); - } - finally - { - try - { - in.close(); - } - catch (IOException e) - { - } - - try - { - out.close(); - } - catch (IOException e) - { - } - } - } - else - { // smaller files, use channels - FileInputStream fis = new FileInputStream(src); - FileOutputStream fos = new FileOutputStream(dst); - FileChannel in = fis.getChannel(), out = fos.getChannel(); - - try - { - long offs = 0, doneCnt = 0, copyCnt = Math.min(65536, fileSize); - do - { - doneCnt = in.transferTo(offs, copyCnt, out); - offs += doneCnt; - fileSize -= doneCnt; - } - - while (fileSize > 0); - } - finally - { // cleanup - try - { - in.close(); - } - catch (IOException e) - { - } - - try - { - out.close(); - } - catch (IOException e) - { - } - - try - { - fis.close(); - } - catch (IOException e) - { - } - - try - { - fos.close(); - } - catch (IOException ex) - { - } - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java deleted file mode 100644 index 54cb295444..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java +++ /dev/null @@ -1,232 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; - -/** - * @author Eike Stepper - */ -public abstract class SortedFileMap<K extends Comparable<K>, V> implements Closeable -{ - private File file; - - private RandomAccessFile randomAccessFile; - - private ExtendedDataInput input; - - private ExtendedDataOutput output; - - private long entrySize; - - private long entryCount; - - /** - * @see RandomAccessFile#RandomAccessFile(File, String) - */ - public SortedFileMap(File file, String mode) - { - try - { - this.file = file; - randomAccessFile = new RandomAccessFile(file, mode); - input = new DataInputExtender(randomAccessFile); - output = new DataOutputExtender(randomAccessFile); - entrySize = getKeySize() + getValueSize(); - entryCount = randomAccessFile.length() / entrySize; - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public void close() throws IOException - { - IOUtil.close(randomAccessFile); - } - - public File getFile() - { - return file; - } - - public RandomAccessFile getRandomAccessFile() - { - return randomAccessFile; - } - - public long getEntryCount() - { - return entryCount; - } - - public int getEntrySize() - { - return (int)entrySize; - } - - public long getPosition(long index) - { - return index * entrySize; - } - - public long getValuePosition(long index) - { - return getPosition(index) + getKeySize(); - } - - public K getMaxKey() - { - if (entryCount == 0) - { - return null; - } - - return getKey(entryCount - 1); - } - - public K getKey(long index) - { - try - { - long pos = getPosition(index); - randomAccessFile.seek(pos); - return readKey(input); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public V getValue(long index) - { - try - { - long pos = getValuePosition(index); - randomAccessFile.seek(pos); - return readValue(input); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public V get(K key) - { - try - { - long index = search(key); - if (index < 0) - { - return null; - } - - return readValue(input); - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - public V put(K key, V value) - { - try - { - long index = search(key); - if (index >= 0) - { - long pos = getValuePosition(index); - randomAccessFile.seek(pos); - V oldValue = readValue(input); - randomAccessFile.seek(pos); - writeValue(output, value); - return oldValue; - } - - index = -index - 1; - for (long i = entryCount; i > index; --i) - { - randomAccessFile.seek(getPosition(i - 1)); - K k = readKey(input); - randomAccessFile.seek(getValuePosition(i - 1)); - V v = readValue(input); - - randomAccessFile.seek(getPosition(i)); - writeKey(output, k); - randomAccessFile.seek(getValuePosition(i)); - writeValue(output, v); - } - - ++entryCount; - randomAccessFile.seek(getPosition(index)); - writeKey(output, key); - randomAccessFile.seek(getValuePosition(index)); - writeValue(output, value); - return null; - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } - - /** - * @return The index of the entry with the given key if the key exists, <code>-(insertionIndex + 1)</code> - * otherwise. - */ - protected long search(K key) throws IOException - { - long low = 0; - long high = entryCount - 1; - - while (low <= high) - { - long mid = low + high >> 1; - randomAccessFile.seek(getPosition(mid)); - Comparable<K> midVal = readKey(input); - int cmp = midVal.compareTo(key); - - if (cmp < 0) - { - low = mid + 1; - } - else if (cmp > 0) - { - high = mid - 1; - } - else - { - return mid; // key found - } - } - - return -(low + 1); // key not found. - } - - public abstract int getKeySize(); - - protected abstract K readKey(ExtendedDataInput in) throws IOException; - - protected abstract void writeKey(ExtendedDataOutput out, K key) throws IOException; - - public abstract int getValueSize(); - - protected abstract V readValue(ExtendedDataInput in) throws IOException; - - protected abstract void writeValue(ExtendedDataOutput out, V value) throws IOException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java deleted file mode 100644 index bb25039f59..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/StreamWrapperChain.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public class StreamWrapperChain extends DelegatingStreamWrapper -{ - private IStreamWrapper head; - - public StreamWrapperChain(IStreamWrapper head, IStreamWrapper delegate) - { - super(delegate); - this.head = head; - } - - public IStreamWrapper getHead() - { - return head; - } - - @Override - protected InputStream doWrapInputStream(InputStream in) throws IOException - { - return head.wrapInputStream(in); - } - - @Override - protected OutputStream doWrapOutputStream(OutputStream out) throws IOException - { - return head.wrapOutputStream(out); - } - - @Override - protected void doFinishInputStream(InputStream in) throws IOException - { - head.finishInputStream(in); - } - - @Override - protected void doFinishOutputStream(OutputStream out) throws IOException - { - head.finishOutputStream(out); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/TMPUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/TMPUtil.java deleted file mode 100644 index 4a5356a551..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/TMPUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.File; -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public final class TMPUtil -{ - private TMPUtil() - { - } - - public static File createTempFolder() throws IORuntimeException - { - return createTempFolder("tmp"); - } - - public static File createTempFolder(String prefix) throws IORuntimeException - { - return createTempFolder(prefix, ""); - } - - public static File createTempFolder(String prefix, String suffix) throws IORuntimeException - { - return createTempFolder(prefix, suffix, null); - } - - public static File createTempFolder(String prefix, String suffix, File directory) throws IORuntimeException - { - // TODO Consider servlets - // ServletContext context = session.getServletContext(); - // File tempDir = (File)context.getAttribute("javax.servlet.context.tempdir"); - - try - { - File tmp = File.createTempFile(prefix, suffix, directory); - String tmpPath = tmp.getAbsolutePath(); - tmp.delete(); - tmp = new File(tmpPath); - tmp.mkdirs(); - return tmp; - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORInputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORInputStream.java deleted file mode 100644 index d1b7ae6bd6..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORInputStream.java +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Eike Stepper - */ -public class XORInputStream extends DelegatingInputStream -{ - private int[] key; - - private int index; - - public XORInputStream(InputStream in, int... key) - { - super(in); - this.key = key; - } - - public int[] getKey() - { - return key; - } - - @Override - public int read() throws IOException - { - int b = super.read(); - if (b != -1) - { - if (key != null && key.length != 0) - { - if (index == key.length) - { - index = 0; - } - - b = b & 0xFF ^ key[index++] & 0xFF; - } - } - - return b; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XOROutputStream.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XOROutputStream.java deleted file mode 100644 index 092d5969b5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XOROutputStream.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public class XOROutputStream extends DelegatingOutputStream -{ - private int[] key; - - private int index; - - public XOROutputStream(OutputStream out, int... key) - { - super(out); - this.key = key; - } - - public int[] getKey() - { - return key; - } - - @Override - public void write(int b) throws IOException - { - if (key != null && key.length != 0) - { - if (index == key.length) - { - index = 0; - } - - b = b & 0xFF ^ key[index++] & 0xFF; - } - - super.write(b); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORStreamWrapper.java deleted file mode 100644 index 8506fd2e61..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/XORStreamWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author Eike Stepper - */ -public class XORStreamWrapper implements IStreamWrapper -{ - private int[] key; - - public XORStreamWrapper(int[] key) - { - this.key = key; - } - - public int[] getKey() - { - return key; - } - - public XORInputStream wrapInputStream(InputStream in) throws IOException - { - if (in instanceof XORInputStream) - { - return (XORInputStream)in; - } - - return new XORInputStream(in, key); - } - - public XOROutputStream wrapOutputStream(OutputStream out) throws IOException - { - if (out instanceof XOROutputStream) - { - return (XOROutputStream)out; - } - - return new XOROutputStream(out, key); - } - - public void finishInputStream(InputStream in) throws IOException - { - } - - public void finishOutputStream(OutputStream out) throws IOException - { - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPUtil.java deleted file mode 100644 index d700869874..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/ZIPUtil.java +++ /dev/null @@ -1,401 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.io; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -/** - * @author Eike Stepper - */ -public final class ZIPUtil -{ - public static final int DEFALULT_BUFFER_SIZE = 4096; - - private static final int ORDER_KEEP = -1; - - private static final int ORDER_SWAP = 1; - - private ZIPUtil() - { - } - - public static void zip(ZipEntryHandler handler, File zipFile) throws IORuntimeException - { - final byte[] buffer = new byte[DEFALULT_BUFFER_SIZE]; - final EntryContext context = new EntryContext(); - - FileOutputStream fos = IOUtil.openOutputStream(zipFile); - ZipOutputStream zos = null; - InputStream input = null; - ZipEntry entry = null; - - try - { - zos = new ZipOutputStream(new BufferedOutputStream(fos, DEFALULT_BUFFER_SIZE)); - for (;;) - { - handler.handleEntry(context); - if (context.isEmpty()) - { - break; - } - - try - { - String name = context.getName().replace(File.separatorChar, '/'); - entry = new ZipEntry(name); - zos.putNextEntry(entry); - - if (!context.isDirectory()) - { - input = context.getInputStream(); - if (input == null) - { - throw new IllegalStateException("Input is null for zip entry " + name); - } - - IOUtil.copy(input, zos, buffer); - } - } - finally - { - IOUtil.closeSilent(input); - if (entry != null) - { - zos.closeEntry(); - } - - context.reset(); - } - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - IOUtil.closeSilent(zos); - IOUtil.closeSilent(fos); - } - } - - public static void zip(File sourceFolder, boolean excludeRoot, File zipFile) - { - zip(new FileSystemZipHandler(sourceFolder, excludeRoot), zipFile); - } - - public static void unzip(File zipFile, UnzipHandler handler) throws IORuntimeException - { - FileInputStream fis = IOUtil.openInputStream(zipFile); - ZipInputStream zis = null; - - try - { - zis = new ZipInputStream(new BufferedInputStream(fis, DEFALULT_BUFFER_SIZE)); - - ZipEntry entry; - while ((entry = zis.getNextEntry()) != null) - { - if (entry.isDirectory()) - { - handler.unzipDirectory(entry.getName()); - } - else - { - // TODO Provide delegating InputStream that ignores close() - handler.unzipFile(entry.getName(), zis); - } - } - } - catch (IOException ex) - { - throw new IORuntimeException(ex); - } - finally - { - IOUtil.closeSilent(zis); - IOUtil.closeSilent(fis); - } - } - - public static void unzip(File zipFile, File targetFolder) throws IORuntimeException - { - unzip(zipFile, new FileSystemUnzipHandler(targetFolder, DEFALULT_BUFFER_SIZE)); - } - - /** - * @author Eike Stepper - */ - public interface ZipEntryHandler - { - public void handleEntry(EntryContext context) throws IOException; - } - - /** - * @author Eike Stepper - */ - public interface UnzipHandler - { - public void unzipDirectory(String name) throws IOException; - - public void unzipFile(String name, InputStream zipStream) throws IOException; - } - - /** - * @author Eike Stepper - */ - public static final class EntryContext - { - private static final String EMPTY = new String(); - - private String name = EMPTY; - - private InputStream inputStream; - - private boolean directory; - - EntryContext() - { - } - - void reset() - { - name = null; - inputStream = null; - } - - boolean isEmpty() - { - return name == null; - } - - boolean isDirectory() - { - return directory; - } - - String getName() - { - return name; - } - - InputStream getInputStream() - { - return inputStream; - } - - public void setName(String name, boolean directory) - { - this.name = name + (directory ? "/" : ""); - this.directory = directory; - } - - public void setInputStream(InputStream inputStream) - { - this.inputStream = inputStream; - } - } - - /** - * @author Eike Stepper - */ - public static final class FileSystemZipHandler implements ZipEntryHandler - { - private int sourceFolderLength; - - private transient Iterator<File> files; - - public FileSystemZipHandler(File sourceFolder, boolean excludeRoot) - { - File root = excludeRoot ? sourceFolder : sourceFolder.getParentFile(); - sourceFolderLength = root.getAbsolutePath().length(); - if (excludeRoot) - { - ++sourceFolderLength; - } - - final int baseLength = sourceFolder.getAbsolutePath().length(); - List<File> list = IOUtil.listBreadthFirst(sourceFolder); - Collections.sort(list, new Comparator<File>() - { - public int compare(File f1, File f2) - { - String path1 = getPath(f1, baseLength); - String path2 = getPath(f2, baseLength); - if (path1.length() == 0) return ORDER_KEEP; - if (path2.length() == 0) return ORDER_SWAP; - - if (f1.isDirectory()) - { - if (f2.isDirectory()) - { - // f1=dir, f2=dir - if (path1.equalsIgnoreCase("/META-INF")) - { - return ORDER_KEEP; - } - - if (path2.equalsIgnoreCase("/META-INF")) - { - return ORDER_SWAP; - } - - return path1.compareTo(path2); - } - - // f1=dir, f2=file - if (path1.equalsIgnoreCase("/META-INF")) - { - return ORDER_KEEP; - } - - if (path2.equalsIgnoreCase("/META-INF/MANIFEST.MF")) - { - return ORDER_SWAP; - } - - return ORDER_KEEP; - } - - if (f2.isDirectory()) - { - // f1=file, f2=dir - if (path2.equalsIgnoreCase("/META-INF")) - { - return ORDER_SWAP; - } - - if (path1.equalsIgnoreCase("/META-INF/MANIFEST.MF")) - { - return ORDER_KEEP; - } - - return ORDER_SWAP; - } - - // f1=file, f2=file - if (path1.equalsIgnoreCase("/META-INF/MANIFEST.MF")) - { - return ORDER_KEEP; - } - - if (path2.equalsIgnoreCase("/META-INF/MANIFEST.MF")) - { - return ORDER_SWAP; - } - - return path1.compareTo(path2); - } - - private String getPath(File file, int baseLength) - { - String absolutePath = file.getAbsolutePath(); - String substring = absolutePath.substring(baseLength); - String replace = substring.replace(File.separatorChar, '/'); - return replace; - } - }); - - files = list.iterator(); - if (excludeRoot) - { - files.next(); - } - } - - public void handleEntry(EntryContext context) throws IOException - { - if (files.hasNext()) - { - File file = files.next(); - String name = getName(file); - if (name.length() != 0) - { - context.setName(name, file.isDirectory()); - - if (file.isFile()) - { - context.setInputStream(IOUtil.openInputStream(file)); - } - } - } - } - - protected String getName(File file) - { - return file.getAbsolutePath().substring(sourceFolderLength); - } - } - - /** - * @author Eike Stepper - */ - public static final class FileSystemUnzipHandler implements UnzipHandler - { - private File targetFolder; - - private transient byte[] buffer; - - public FileSystemUnzipHandler(File targetFolder, int bufferSize) - { - this.targetFolder = targetFolder; - buffer = new byte[bufferSize]; - } - - public File getTargetFolder() - { - return targetFolder; - } - - public void unzipDirectory(String name) - { - File directory = new File(targetFolder, name); - if (!directory.exists()) - { - directory.mkdirs(); - } - } - - public void unzipFile(String name, InputStream zipStream) - { - File targetFile = new File(targetFolder, name); - if (!targetFile.getParentFile().exists()) - { - targetFile.getParentFile().mkdirs(); - } - - FileOutputStream out = IOUtil.openOutputStream(targetFile); - - try - { - IOUtil.copy(zipStream, out, buffer); - } - finally - { - IOUtil.closeSilent(out); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/package.html deleted file mode 100644 index bb5f9cf555..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for I/O. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java deleted file mode 100644 index fd44921cca..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public interface ILifecycle -{ - public void activate() throws LifecycleException; - - public Exception deactivate(); - - /** - * @author Eike Stepper - */ - public interface Introspection extends ILifecycle - { - public ILifecycleState getLifecycleState(); - - public boolean isActive(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java deleted file mode 100644 index ab3694d2ef..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface ILifecycleEvent extends IEvent -{ - public ILifecycle getLifecycle(); - - public Kind getKind(); - - /** - * @author Eike Stepper - */ - public enum Kind - { - ABOUT_TO_ACTIVATE, ACTIVATED, ABOUT_TO_DEACTIVATE, DEACTIVATED - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java deleted file mode 100644 index a581c1907c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public enum ILifecycleState -{ - ACTIVATING, ACTIVE, DEACTIVATING, INACTIVE -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java deleted file mode 100644 index b00aec53f2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public class LifecycleException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public LifecycleException() - { - } - - public LifecycleException(String message) - { - super(message); - } - - public LifecycleException(Throwable cause) - { - super(cause); - } - - public LifecycleException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java deleted file mode 100644 index c50ae42fe5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java +++ /dev/null @@ -1,264 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.WrappedException; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public final class LifecycleUtil -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_LIFECYCLE, LifecycleUtil.class); - - private LifecycleUtil() - { - } - - public static ILifecycleState getLifecycleState(Object object) - { - if (object instanceof ILifecycle.Introspection) - { - return ((ILifecycle.Introspection)object).getLifecycleState(); - } - - return ILifecycleState.ACTIVE; - } - - public static boolean isActive(Object object) - { - if (object instanceof ILifecycle.Introspection) - { - return ((ILifecycle.Introspection)object).isActive(); - } - - return object != null; - } - - public static void activate(Object object) throws LifecycleException - { - activate(object, false); - } - - /** - * @see Activator - */ - public static void activate(Object object, boolean useAnnotation) throws LifecycleException - { - if (object instanceof ILifecycle) - { - ((ILifecycle)object).activate(); - } - else if (object != null && useAnnotation) - { - invokeAnnotation(object, Activator.class); - } - } - - public static Exception activateSilent(Object object) - { - return activateSilent(object, false); - } - - /** - * @see Activator - */ - public static Exception activateSilent(Object object, boolean useAnnotation) - { - try - { - activate(object, useAnnotation); - return null; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return ex; - } - } - - public static boolean waitForActive(Object object, long millis) - { - try - { - if (object instanceof ILifecycle) - { - Lifecycle lifecycle = (Lifecycle)object; - if (lifecycle.isActive()) - { - return true; - } - - final CountDownLatch latch = new CountDownLatch(1); - LifecycleEventAdapter adapter = new LifecycleEventAdapter() - { - @Override - protected void onActivated(ILifecycle lifecycle) - { - latch.countDown(); - } - }; - - try - { - lifecycle.addListener(adapter); - latch.await(millis, TimeUnit.MILLISECONDS); - } - finally - { - lifecycle.removeListener(adapter); - } - - return lifecycle.isActive(); - } - - return true; - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - public static Exception deactivate(Object object) - { - return deactivate(object, false); - } - - /** - * @see Deactivator - */ - public static Exception deactivate(Object object, boolean useAnnotation) - { - if (object instanceof ILifecycle) - { - return ((ILifecycle)object).deactivate(); - } - else if (object != null && useAnnotation) - { - // TODO Handle evtl. return value (exception) - invokeAnnotation(object, Deactivator.class); - } - - return null; - } - - public static void deactivateNoisy(Object object) throws LifecycleException - { - deactivateNoisy(object, false); - } - - public static void deactivateNoisy(Object object, boolean useAnnotation) throws LifecycleException - { - Exception ex = deactivate(object, useAnnotation); - if (ex instanceof RuntimeException) - { - throw (RuntimeException)ex; - } - else if (ex != null) - { - throw new LifecycleException(ex); - } - } - - private static <T extends Annotation> void invokeAnnotation(Object object, Class<T> annotationClass) - { - Class<?> c = object.getClass(); - while (c != Object.class) - { - final Method[] methods = c.getDeclaredMethods(); - for (Method method : methods) - { - if (method.getParameterTypes().length == 0) - { - Annotation annotation = method.getAnnotation(annotationClass); - if (annotation != null) - { - invokeMethod(object, method); - boolean propagate = annotationClass == Activator.class ? ((Activator)annotation).propagate() - : ((Deactivator)annotation).propagate(); - if (!propagate) - { - break; - } - } - } - } - - c = c.getSuperclass(); - } - } - - private static Object invokeMethod(Object object, Method method) - { - try - { - return method.invoke(object, (Object[])null); - } - catch (IllegalAccessException iae) - { - try - { - method.setAccessible(true); - return method.invoke(object, (Object[])null); - } - catch (Exception ex) - { - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - } - } - catch (Exception ex) - { - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - } - - return null; - } - - /** - * @author Eike Stepper - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface Activator - { - boolean propagate() default true; - } - - /** - * @author Eike Stepper - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface Deactivator - { - boolean propagate() default true; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html deleted file mode 100644 index e7e55a0ba2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for components with a simple lifecycle. -Interfaces that describe the behaviour of objects with respect to their lifecycle. -A utility class to interact with such objects and an abstract class that can be -used to implement such objects are provided as well. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java deleted file mode 100644 index e5c222d6a1..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/LegacyUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om; - -import org.eclipse.net4j.internal.util.om.LegacyBundle; - -/** - * @author Eike Stepper - */ -public final class LegacyUtil -{ - private LegacyUtil() - { - } - - public static void startBundles(OMBundle[] bundles) throws Exception - { - for (int i = 0; i < bundles.length; i++) - { - ((LegacyBundle)bundles[i]).start(); - } - } - - public static void stopBundles(OMBundle[] bundles) throws Exception - { - for (int i = bundles.length - 1; i >= 0; i--) - { - ((LegacyBundle)bundles[i]).stop(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java deleted file mode 100644 index 91ca5cfc30..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMBundle.java +++ /dev/null @@ -1,146 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om; - -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.pref.OMPreferences; -import org.eclipse.net4j.util.om.trace.OMTracer; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Properties; - -/** - * @author Eike Stepper - */ -public interface OMBundle -{ - public OMPlatform getPlatform(); - - public String getBundleID(); - - public URL getBaseURL(); - - public void setBundleContext(Object bundleContext); - - public OMTracer tracer(String name); - - public OMLogger logger(); - - public OMPreferences preferences(); - - public File getConfigFile(); - - public Properties getConfigProperties(); - - public String getStateLocation(); - - public InputStream getInputStream(String path) throws IOException; - - public DebugSupport getDebugSupport(); - - public TranslationSupport getTranslationSupport(); - - /** - * @author Eike Stepper - */ - public interface DebugSupport - { - public boolean isDebugging(); - - public void setDebugging(boolean debugging); - - public String getDebugOption(String option); - - public void setDebugOption(String option, String value); - - public String getDebugOption(String option, String defaultValue); - - public boolean getDebugOption(String option, boolean defaultValue); - - public void setDebugOption(String option, boolean value); - - public int getDebugOption(String option, int defaultValue); - - public void setDebugOption(String option, int value); - } - - /** - * @author Eike Stepper - */ - public interface TranslationSupport - { - /** - * Indicates whether strings should be translated by default. - * - * @return <code>true</code> if strings should be translated by default; <code>false</code> otherwise. - */ - public boolean shouldTranslate(); - - /** - * Sets whether strings should be translated by default. - * - * @param shouldTranslate - * whether strings should be translated by default. - */ - public void setShouldTranslate(boolean shouldTranslate); - - /** - * Returns the string resource associated with the key. - * - * @param key - * the key of the string resource. - * @return the string resource associated with the key. - */ - String getString(String key); - - /** - * Returns the string resource associated with the key. - * - * @param key - * the key of the string resource. - * @param translate - * whether the result is to be translated to the current locale. - * @return the string resource associated with the key. - */ - String getString(String key, boolean translate); - - /** - * Returns a string resource associated with the key, and performs substitutions. - * - * @param key - * the key of the string. - * @param args - * the message substitutions. - * @return a string resource associated with the key. - * @see #getString(String) - * @see java.text.MessageFormat#format(String, Object...) - */ - String getString(String key, Object... args); - - /** - * Returns a string resource associated with the key, and performs substitutions. - * - * @param key - * the key of the string. - * @param translate - * whether the result is to be translated to the current locale. - * @param args - * the message substitutions. - * @return a string resource associated with the key. - * @see #getString(String) - * @see java.text.MessageFormat#format(String, Object[]) - */ - String getString(String key, boolean translate, Object... args); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java deleted file mode 100644 index 0a54cf9caa..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OMPlatform.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om; - -import org.eclipse.net4j.internal.util.bundle.AbstractPlatform; -import org.eclipse.net4j.util.om.log.OMLogHandler; -import org.eclipse.net4j.util.om.trace.OMTraceHandler; - -import java.io.File; -import java.util.Properties; - -/** - * @author Eike Stepper - */ -public interface OMPlatform -{ - // @Singleton - public static final OMPlatform INSTANCE = AbstractPlatform.createPlatform(); - - public OMBundle bundle(String bundleID, Class<?> accessor); - - public boolean isOSGiRunning(); - - public boolean isDebugging(); - - public void setDebugging(boolean debugging); - - public void addLogHandler(OMLogHandler logHandler); - - public void removeLogHandler(OMLogHandler logHandler); - - public void addTraceHandler(OMTraceHandler traceHandler); - - public void removeTraceHandler(OMTraceHandler traceHandler); - - public File getStateFolder(); - - public File getConfigFolder(); - - public File getConfigFile(String name); - - public Properties getConfigProperties(String name); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java deleted file mode 100644 index 0a5b996c0e..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiActivator.java +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.OSGiBundle; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -/** - * @author Eike Stepper - */ -public abstract class OSGiActivator implements BundleActivator -{ - private OMBundle omBundle; - - public OSGiActivator(OMBundle omBundle) - { - this.omBundle = omBundle; - } - - public final OMBundle getOMBundle() - { - return omBundle; - } - - public void start(BundleContext context) throws Exception - { - startBundle(context, (OSGiBundle)getOMBundle()); - } - - public void stop(BundleContext context) throws Exception - { - stopBundle(context, (OSGiBundle)getOMBundle()); - } - - @Override - public final boolean equals(Object obj) - { - return super.equals(obj); - } - - @Override - public final int hashCode() - { - return super.hashCode(); - } - - @Override - public final String toString() - { - return super.toString(); - } - - @Override - protected final Object clone() throws CloneNotSupportedException - { - return super.clone(); - } - - @Override - protected final void finalize() throws Throwable - { - super.finalize(); - } - - public static void startBundle(BundleContext context, OSGiBundle bundle) throws Error, Exception - { - OM.Activator.traceStart(context); - if (bundle == null) - { - throw new IllegalStateException("bundle == null"); - } - - try - { - bundle.setBundleContext(context); - bundle.start(); - } - catch (Error error) - { - bundle.logger().error(error); - throw error; - } - catch (Exception ex) - { - bundle.logger().error(ex); - throw ex; - } - } - - public static void stopBundle(BundleContext context, OSGiBundle bundle) throws Error, Exception - { - OM.Activator.traceStop(context); - if (bundle == null) - { - throw new IllegalStateException("bundle == null"); - } - - try - { - bundle.stop(); - bundle.setBundleContext(null); - } - catch (Error error) - { - bundle.logger().error(error); - throw error; - } - catch (Exception ex) - { - bundle.logger().error(ex); - throw ex; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiApplication.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiApplication.java deleted file mode 100644 index 08f9037d94..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/OSGiApplication.java +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; - -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; - -import java.util.concurrent.CountDownLatch; - -/** - * @author Eike Stepper - */ -public class OSGiApplication implements IApplication -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OM, OSGiApplication.class); - - private String applicationID; - - private IApplicationContext context; - - private CountDownLatch stopLatch; - - public OSGiApplication(String applicationID) - { - this.applicationID = applicationID; - } - - public String getApplicationID() - { - return applicationID; - } - - public IApplicationContext getApplicationContext() - { - return context; - } - - public boolean isRunning() - { - return stopLatch != null; - } - - public final Object start(IApplicationContext context) throws Exception - { - this.context = context; - traceStart(applicationID); - - try - { - doStart(); - } - catch (Error error) - { - OM.LOG.error(error); - throw error; - } - catch (Exception ex) - { - OM.LOG.error(ex); - throw ex; - } - - context.applicationRunning(); - stopLatch = new CountDownLatch(1); - stopLatch.await(); - stopLatch = null; - return EXIT_OK; - } - - public final void stop() - { - traceStop(applicationID); - - try - { - doStop(); - } - catch (Error error) - { - OM.LOG.error(error); - throw error; - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - - context = null; - if (stopLatch != null) - { - stopLatch.countDown(); - } - } - - protected void doStart() throws Exception - { - } - - protected void doStop() throws Exception - { - } - - public static void traceStart(String applicationID) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Starting application {0}", applicationID); - } - } - catch (RuntimeException ignore) - { - } - } - - public static void traceStop(String applicationID) - { - try - { - if (TRACER.isEnabled()) - { - TRACER.format("Stopping application {0}", applicationID); - } - } - catch (RuntimeException ignore) - { - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogHandler.java deleted file mode 100644 index 3897eaa384..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.log; - -import org.eclipse.net4j.util.om.log.OMLogger.Level; - -/** - * @author Eike Stepper - */ -public interface OMLogHandler -{ - public void logged(OMLogger logger, Level level, String msg, Throwable t); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogger.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogger.java deleted file mode 100644 index da92e1c693..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/OMLogger.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.log; - -import org.eclipse.net4j.util.om.OMBundle; - -/** - * @author Eike Stepper - */ -public interface OMLogger -{ - public OMBundle getBundle(); - - public void log(Level level, String msg, Throwable t); - - public void error(String msg, Throwable t); - - public void warn(String msg, Throwable t); - - public void info(String msg, Throwable t); - - public void debug(String msg, Throwable t); - - public void log(Level level, String msg); - - public void error(String msg); - - public void warn(String msg); - - public void info(String msg); - - public void debug(String msg); - - public void log(Level level, Throwable t); - - public void error(Throwable t); - - public void warn(Throwable t); - - public void info(Throwable t); - - public void debug(Throwable t); - - /** - * @author Eike Stepper - */ - public enum Level - { - ERROR, WARN, INFO, DEBUG - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/package.html deleted file mode 100644 index 7465feddbb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/log/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for environment independent logging. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java deleted file mode 100644 index 92dbda2735..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/IllegalMonitorNestingException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class IllegalMonitorNestingException extends MonitorException -{ - private static final long serialVersionUID = 1L; - - public IllegalMonitorNestingException() - { - } - - public IllegalMonitorNestingException(String s) - { - super(s); - } - - public IllegalMonitorNestingException(Throwable cause) - { - super(cause); - } - - public IllegalMonitorNestingException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java deleted file mode 100644 index 19f44dea46..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorAlreadyBegunException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class MonitorAlreadyBegunException extends MonitorException -{ - private static final long serialVersionUID = 1L; - - public MonitorAlreadyBegunException() - { - } - - public MonitorAlreadyBegunException(String s) - { - super(s); - } - - public MonitorAlreadyBegunException(Throwable cause) - { - super(cause); - } - - public MonitorAlreadyBegunException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java deleted file mode 100644 index 92f3224f61..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorCanceledException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class MonitorCanceledException extends MonitorException -{ - private static final long serialVersionUID = 1L; - - public MonitorCanceledException() - { - } - - public MonitorCanceledException(String s) - { - super(s); - } - - public MonitorCanceledException(Throwable cause) - { - super(cause); - } - - public MonitorCanceledException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java deleted file mode 100644 index c39fb00426..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class MonitorException extends IllegalStateException -{ - private static final long serialVersionUID = 1L; - - public MonitorException() - { - } - - public MonitorException(String s) - { - super(s); - } - - public MonitorException(Throwable cause) - { - super(cause); - } - - public MonitorException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java deleted file mode 100644 index e4d31e6269..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorNotBegunException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class MonitorNotBegunException extends MonitorException -{ - private static final long serialVersionUID = 1L; - - public MonitorNotBegunException() - { - } - - public MonitorNotBegunException(String s) - { - super(s); - } - - public MonitorNotBegunException(Throwable cause) - { - super(cause); - } - - public MonitorNotBegunException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java deleted file mode 100644 index b139567a18..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitorUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.monitor.EclipseMonitor; -import org.eclipse.net4j.internal.util.om.monitor.LegacyMonitor; -import org.eclipse.net4j.internal.util.om.monitor.MON; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * @author Eike Stepper - */ -public final class MonitorUtil -{ - private MonitorUtil() - { - } - - public static boolean isCanceled() - { - return MON.isCanceled(); - } - - public static OMMonitor begin() - { - return MON.begin(OMMonitor.UNKNOWN, null); - } - - public static OMMonitor begin(int totalWork) - { - return MON.begin(totalWork, null); - } - - public static OMMonitor begin(String task) - { - return MON.begin(OMMonitor.UNKNOWN, task); - } - - public static OMMonitor begin(int totalWork, String task) - { - return MON.begin(totalWork, task); - } - - static void handleTrace(final OMMonitorHandler messageHandler, String msg, int level, boolean isTask) - { - if (messageHandler != null) - { - try - { - if (isTask) - { - messageHandler.handleTask(msg, level); - } - else - { - messageHandler.handleMessage(msg, level); - } - } - catch (RuntimeException ex) - { - OM.LOG.error(ex); - } - } - } - - /** - * @author Eike Stepper - */ - public static final class Eclipse - { - public static void startMonitoring(IProgressMonitor progressMonitor, final OMMonitorHandler messageHandler) - { - MON.startMonitoring(new EclipseMonitor(progressMonitor) - { - @Override - protected void trace(String msg, int level, boolean isTask) - { - super.trace(msg, level, isTask); - handleTrace(messageHandler, msg, level, isTask); - } - }); - } - - public static void startMonitoring(IProgressMonitor progressMonitor) - { - startMonitoring(progressMonitor, null); - } - - public static void stopMonitoring() - { - MON.stopMonitoring(); - } - } - - /** - * @author Eike Stepper - */ - public static final class Legacy - { - public static void startMonitoring(final OMMonitorHandler messageHandler) - { - MON.startMonitoring(new LegacyMonitor() - { - @Override - protected void trace(String msg, int level, boolean isTask) - { - super.trace(msg, level, isTask); - handleTrace(messageHandler, msg, level, isTask); - } - }); - } - - public static void startMonitoring() - { - startMonitoring(null); - } - - public static void stopMonitoring() - { - MON.stopMonitoring(); - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java deleted file mode 100644 index abf85017fc..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/MonitoredJob.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.om.monitor.MON; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; - -/** - * @author Eike Stepper - */ -public abstract class MonitoredJob extends Job -{ - private String bundleID; - - public MonitoredJob(String bundleID, String name) - { - super(name); - this.bundleID = bundleID; - } - - @Override - protected void canceling() - { - MON.setCanceled(true); - super.canceling(); - } - - @Override - protected final IStatus run(IProgressMonitor monitor) - { - MonitorUtil.Eclipse.startMonitoring(monitor); - - try - { - run(); - return Status.OK_STATUS; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return new Status(IStatus.ERROR, bundleID, ex.getMessage(), ex); - } - finally - { - MonitorUtil.Eclipse.stopMonitoring(); - } - } - - protected abstract void run() throws Exception; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java deleted file mode 100644 index 6da225e1b5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public interface OMMonitor -{ - public static final int UNKNOWN = -1; - - public String getTask(); - - public void setTask(String task); - - public int getTotalWork(); - - public boolean hasBegun(); - - public void message(String msg); - - public void worked(int work, String msg); - - public void worked(int work); - - public void worked(String msg); - - public void worked(); - - public void fork(int workFromParent, Runnable runnable, String msg); - - public void fork(int workFromParent, Runnable runnable); - - public void fork(Runnable runnable, String msg); - - public void fork(Runnable runnable); - - public OMSubMonitor fork(int workFromParent); - - public OMSubMonitor fork(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java deleted file mode 100644 index 6f7be296ea..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public interface OMMonitorHandler -{ - public void handleTask(String task, int level); - - public void handleMessage(String msg, int level); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java deleted file mode 100644 index 08c0e10d58..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMSubMonitor.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public interface OMSubMonitor -{ - public void join(String msg); - - public void join(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java deleted file mode 100644 index 6fbdeeb10d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/TotalWorkExceededException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.monitor; - -/** - * @author Eike Stepper - */ -public class TotalWorkExceededException extends MonitorException -{ - private static final long serialVersionUID = 1L; - - public TotalWorkExceededException() - { - } - - public TotalWorkExceededException(String s) - { - super(s); - } - - public TotalWorkExceededException(Throwable cause) - { - super(cause); - } - - public TotalWorkExceededException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/package.html deleted file mode 100644 index 841b0426d9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for environment independent progress monitoring. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/package.html deleted file mode 100644 index 77ce765784..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for environment independent operations and maintenance (O&M). -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreference.java deleted file mode 100644 index abc14cc6d7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreference.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.pref; - -/** - * @author Eike Stepper - */ -public interface OMPreference<T> -{ - public OMPreferences getPreferences(); - - public String getName(); - - public Type getType(); - - public T getDefaultValue(); - - public T getValue(); - - public T setValue(T value); - - public T unSet(); - - public boolean isSet(); - - /** - * @author Eike Stepper - */ - public enum Type - { - BOOLEAN, INTEGER, LONG, FLOAT, DOUBLE, STRING, ARRAY, BYTES - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java deleted file mode 100644 index 09aaf2d79b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.pref; - -import org.eclipse.net4j.util.event.INotifier; -import org.eclipse.net4j.util.om.OMBundle; - -/** - * @author Eike Stepper - */ -public interface OMPreferences extends INotifier -{ - public static final boolean DEFAULT_BOOLEAN = false; - - public static final int DEFAULT_INTEGER = 0; - - public static final long DEFAULT_LONG = 0L; - - public static final float DEFAULT_FLOAT = 0.0f; - - public static final double DEFAULT_DOUBLE = 0.0d; - - public static final String DEFAULT_STRING = ""; - - public static final String[] DEFAULT_ARRAY = {}; - - public static final byte[] DEFAULT_BYTES = {}; - - public OMBundle getBundle(); - - public boolean isDirty(); - - public void save(); - - public OMPreference<Boolean> init(String name, boolean defaultValue); - - public OMPreference<Integer> init(String name, int defaultValue); - - public OMPreference<Long> init(String name, long defaultValue); - - public OMPreference<Float> init(String name, float defaultValue); - - public OMPreference<Double> init(String name, double defaultValue); - - public OMPreference<String> init(String name, String defaultValue); - - public OMPreference<String[]> init(String name, String[] defaultValue); - - public OMPreference<byte[]> init(String name, byte[] defaultValue); - - public OMPreference<Boolean> initBoolean(String name); - - public OMPreference<Integer> initInteger(String name); - - public OMPreference<Long> initLong(String name); - - public OMPreference<Float> initFloat(String name); - - public OMPreference<Double> initDouble(String name); - - public OMPreference<String> initString(String name); - - public OMPreference<String[]> initArray(String name); - - public OMPreference<byte[]> initBytes(String name); - - public boolean contains(String name); - - public OMPreference<?> get(String name); - - public OMPreference<Boolean> getBoolean(String name); - - public OMPreference<Integer> getInteger(String name); - - public OMPreference<Long> getLong(String name); - - public OMPreference<Float> getFloat(String name); - - public OMPreference<Double> getDouble(String name); - - public OMPreference<String> getString(String name); - - public OMPreference<String[]> getArray(String name); - - public OMPreference<byte[]> getBytes(String name); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferencesChangeEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferencesChangeEvent.java deleted file mode 100644 index 3eafc6fad9..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferencesChangeEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.pref; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface OMPreferencesChangeEvent<T> extends IEvent -{ - public OMPreference<T> getPreference(); - - public T getOldValue(); - - public T getNewValue(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/package.html deleted file mode 100644 index 1cf8d695fd..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for environment independent preference management. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandler.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandler.java deleted file mode 100644 index e9368cb7f3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.trace; - -/** - * @author Eike Stepper - */ -public interface OMTraceHandler -{ - public void traced(OMTraceHandlerEvent event); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandlerEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandlerEvent.java deleted file mode 100644 index 348afc6a9a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTraceHandlerEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.trace; - -/** - * @author Eike Stepper - */ -public interface OMTraceHandlerEvent -{ - public long getTimeStamp(); - - public OMTracer getTracer(); - - public Class<?> getContext(); - - public String getMessage(); - - public Throwable getThrowable(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTracer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTracer.java deleted file mode 100644 index ea78f467e2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/OMTracer.java +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.om.trace; - -import org.eclipse.net4j.util.om.OMBundle; - -/** - * @author Eike Stepper - */ -public interface OMTracer -{ - public OMBundle getBundle(); - - public OMTracer getParent(); - - public String getName(); - - public String getFullName(); - - public boolean isEnabled(); - - public void setEnabled(boolean enabled); - - public void trace(OMTraceHandlerEvent traceRecord); - - public OMTraceHandlerEvent format(Class<?> context, String pattern, Object... args); - - public OMTraceHandlerEvent format(Class<?> context, String pattern, Throwable t, Object... args); - - public OMTraceHandlerEvent trace(Class<?> context, String msg, Throwable t); - - public OMTraceHandlerEvent trace(Class<?> context, String msg); - - public OMTraceHandlerEvent trace(Class<?> context, Throwable t); - - public OMTracer tracer(String name); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/package.html deleted file mode 100644 index 735df4ada7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/trace/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for environment independent tracing. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/package.html deleted file mode 100644 index 00377b0855..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Utility classes. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedPhantomReference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedPhantomReference.java deleted file mode 100644 index 65c5acc0d8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedPhantomReference.java +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import java.lang.ref.PhantomReference; -import java.lang.ref.ReferenceQueue; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class KeyedPhantomReference<K, T> extends PhantomReference<T> implements KeyedReference<K, T> -{ - private K key; - - public KeyedPhantomReference(K key, T ref, ReferenceQueue<T> queue) - { - super(ref, queue); - this.key = key; - } - - public ReferenceType getType() - { - return ReferenceType.PHANTOM; - } - - public K getKey() - { - return key; - } - - @Override - public String toString() - { - return MessageFormat.format("KeyedPhantomReference[{0} -> {1}]", key, isEnqueued() ? "ENQUEUED" : get()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedReference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedReference.java deleted file mode 100644 index d91a63d65a..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedReference.java +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import java.lang.ref.Reference; - -/** - * @see Reference - * @author Eike Stepper - */ -public interface KeyedReference<K, T> -{ - public ReferenceType getType(); - - public K getKey(); - - /** - * @see Reference#get() - */ - public T get(); - - /** - * @see Reference#clear() - */ - public void clear(); - - /** - * @see Reference#isEnqueued() - */ - public boolean isEnqueued(); - - /** - * @see Reference#enqueue() - */ - public boolean enqueue(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedSoftReference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedSoftReference.java deleted file mode 100644 index 721a83c9a8..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedSoftReference.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import java.lang.ref.ReferenceQueue; -import java.lang.ref.SoftReference; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class KeyedSoftReference<K, T> extends SoftReference<T> implements KeyedReference<K, T> -{ - private K key; - - public KeyedSoftReference(K key, T ref) - { - super(ref); - this.key = key; - } - - public KeyedSoftReference(K key, T ref, ReferenceQueue<T> queue) - { - super(ref, queue); - this.key = key; - } - - public ReferenceType getType() - { - return ReferenceType.SOFT; - } - - public K getKey() - { - return key; - } - - @Override - public String toString() - { - return MessageFormat.format("KeyedSoftReference[{0} -> {1}]", key, isEnqueued() ? "ENQUEUED" : get()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedStrongReference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedStrongReference.java deleted file mode 100644 index d8c5071e83..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedStrongReference.java +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class KeyedStrongReference<K, T> implements KeyedReference<K, T> -{ - private K key; - - private T ref; - - public KeyedStrongReference(K key, T ref) - { - this.key = key; - this.ref = ref; - } - - public ReferenceType getType() - { - return ReferenceType.STRONG; - } - - public K getKey() - { - return key; - } - - public T get() - { - return ref; - } - - public void clear() - { - ref = null; - } - - public boolean isEnqueued() - { - return false; - } - - public boolean enqueue() - { - return false; - } - - @Override - public String toString() - { - return MessageFormat.format("KeyedStrongReference[{0} -> {1}]", key, ref); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedWeakReference.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedWeakReference.java deleted file mode 100644 index b20029ded1..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/KeyedWeakReference.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class KeyedWeakReference<K, T> extends WeakReference<T> implements KeyedReference<K, T> -{ - private K key; - - public KeyedWeakReference(K key, T ref) - { - super(ref); - this.key = key; - } - - public KeyedWeakReference(K key, T ref, ReferenceQueue<T> queue) - { - super(ref, queue); - this.key = key; - } - - public ReferenceType getType() - { - return ReferenceType.WEAK; - } - - public K getKey() - { - return key; - } - - @Override - public String toString() - { - return MessageFormat.format("KeyedWeakReference[{0} -> {1}]", key, isEnqueued() ? "ENQUEUED" : get()); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceType.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceType.java deleted file mode 100644 index 2ee8adad51..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceType.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -/** - * @author Eike Stepper - */ -public enum ReferenceType -{ - STRONG, SOFT, WEAK, PHANTOM; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java deleted file mode 100644 index 0c65251985..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java +++ /dev/null @@ -1,497 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.ref; - -import org.eclipse.net4j.util.collection.MapEntry; - -import java.lang.ref.ReferenceQueue; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * A {@link ConcurrentMap} implementation that uses {@link KeyedReference} instances ({@link KeyedStrongReference}, - * {@link KeyedSoftReference}, {@link KeyedWeakReference} or {@link KeyedPhantomReference}) as its values. - * <p> - * A <code>ReferenceValueMap</code> can be used to cache mappings until the <em>value</em> of the mapping is no - * longer reachable from outside of the map - * <p> - * <b>Note:</b> This map is not synchronized. If it is to be used by multiple threads concurrently the user is - * responsible for applying proper external synchronization! - * - * @author Eike Stepper - */ -public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V> -{ - private ConcurrentMap<K, KeyedReference<K, V>> map; - - private ReferenceQueue<V> queue; - - private EntrySet entrySet; - - public ReferenceValueMap() - { - this(new ConcurrentHashMap<K, KeyedReference<K, V>>()); - } - - public ReferenceValueMap(ConcurrentMap<K, KeyedReference<K, V>> map) - { - if (!map.isEmpty()) - { - throw new IllegalArgumentException("!map.isEmpty()"); - } - - this.map = map; - queue = createQueue(); - } - - @Override - public int size() - { - purgeQueue(); - return map.size(); - } - - @Override - public boolean isEmpty() - { - purgeQueue(); - return map.isEmpty(); - } - - @Override - public boolean containsKey(Object key) - { - KeyedReference<K, V> ref = map.get(key); - if (ref != null) - { - if (ref.get() == null) - { - // ref.enqueue(); - return false; - } - - return true; - } - - return false; - } - - @Override - public boolean containsValue(Object value) - { - if (value == null) - { - throw new IllegalArgumentException("value == null"); - } - - for (KeyedReference<K, V> ref : map.values()) - { - V v = ref.get(); - if (v == null) - { - // ref.enqueue(); - return false; - } - - if (value.equals(v)) - { - return true; - } - } - - return false; - } - - @Override - public V get(Object key) - { - KeyedReference<K, V> ref = map.get(key); - return dereference(ref); - } - - @Override - public V put(K key, V value) - { - try - { - KeyedReference<K, V> ref = createReference(key, value, queue); - KeyedReference<K, V> oldRef = map.put(key, ref); - return dereference(oldRef); - } - finally - { - purgeQueue(); - } - } - - public V putIfAbsent(K key, V value) - { - try - { - KeyedReference<K, V> ref = createReference(key, value, queue); - KeyedReference<K, V> oldRef = map.putIfAbsent(key, ref); - return dereference(oldRef); - } - finally - { - purgeQueue(); - } - } - - public V replace(K key, V value) - { - try - { - KeyedReference<K, V> ref = createReference(key, value, queue); - KeyedReference<K, V> oldRef = map.replace(key, ref); - return dereference(oldRef); - } - finally - { - purgeQueue(); - } - } - - public boolean replace(K key, V oldValue, V newValue) - { - try - { - // TODO Consider a dummy KeyedReference class for oldRef - KeyedReference<K, V> oldRef = createReference(key, oldValue, queue); - KeyedReference<K, V> newRef = createReference(key, newValue, queue); - return map.replace(key, oldRef, newRef); - } - finally - { - purgeQueue(); - } - } - - @Override - public V remove(Object key) - { - KeyedReference<K, V> ref = map.remove(key); - return dereference(ref); - } - - public boolean remove(Object key, Object value) - { - // TODO Consider a dummy KeyedReference class for value - return map.remove(key, value); - } - - @Override - public void clear() - { - purgeQueue(); - map.clear(); - } - - @Override - public Set<Map.Entry<K, V>> entrySet() - { - if (entrySet == null) - { - purgeQueue(); - entrySet = new EntrySet(); - } - - return entrySet; - } - - protected ReferenceQueue<V> createQueue() - { - return new ReferenceQueue<V>(); - } - - @SuppressWarnings("unchecked") - protected void purgeQueue() - { - if (queue != null) - { - KeyedReference<K, V> ref; - while ((ref = (KeyedReference<K, V>)queue.poll()) != null) - { - // Slightly faster than map.get() + map.remove() - map.remove(ref.getKey(), ref); - } - } - } - - protected V dereference(KeyedReference<K, V> ref) - { - if (ref == null) - { - return null; - } - - return ref.get(); - } - - protected abstract KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue); - - /** - * @author Eike Stepper - */ - public static class Strong<K, V> extends ReferenceValueMap<K, V> - { - public Strong() - { - } - - public Strong(ConcurrentMap<K, KeyedReference<K, V>> map) - { - super(map); - } - - @Override - protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue) - { - return new KeyedStrongReference<K, V>(key, value); - } - - @Override - protected ReferenceQueue<V> createQueue() - { - return null; - } - } - - /** - * @author Eike Stepper - */ - public static class Soft<K, V> extends ReferenceValueMap<K, V> - { - public Soft() - { - } - - public Soft(ConcurrentMap<K, KeyedReference<K, V>> map) - { - super(map); - } - - @Override - protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue) - { - return new KeyedSoftReference<K, V>(key, value, queue); - } - } - - /** - * @author Eike Stepper - */ - public static class Weak<K, V> extends ReferenceValueMap<K, V> - { - public Weak() - { - } - - public Weak(ConcurrentMap<K, KeyedReference<K, V>> map) - { - super(map); - } - - @Override - protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue) - { - return new KeyedWeakReference<K, V>(key, value, queue); - } - } - - /** - * @author Eike Stepper - */ - private class EntrySet extends AbstractSet<Map.Entry<K, V>> - { - public EntrySet() - { - } - - @Override - public int size() - { - return map.size(); - } - - @Override - public boolean isEmpty() - { - return map.isEmpty(); - } - - @Override - public boolean contains(Object object) - { - if (object == null) - { - throw new IllegalArgumentException("object == null"); - } - - if (object instanceof Map.Entry<?, ?>) - { - Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object; - Object key = entry.getKey(); - Object value = entry.getValue(); - return key != null && value != null && value.equals(get(key)); - } - - return false; - } - - @Override - public Iterator<Map.Entry<K, V>> iterator() - { - return new EntrySetIterator(); - } - - @Override - public Object[] toArray() - { - Object[] a = new Object[size()]; - int i = 0; - for (Map.Entry<K, V> entry : this) - { - a[i++] = entry; - } - - return a; - } - - @SuppressWarnings("unchecked") - @Override - public <T> T[] toArray(T[] a) - { - if (a == null) - { - throw new IllegalArgumentException("array == null"); - } - - int size = size(); - if (a.length < size) - { - a = (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size); - } - - int i = 0; - for (Map.Entry<K, V> entry : this) - { - a[i++] = (T)entry; - } - - if (a.length > size) - { - a[size] = null; - } - - return a; - } - - @Override - public boolean remove(Object object) - { - if (object == null) - { - throw new IllegalArgumentException("object == null"); - } - - if (object instanceof Map.Entry<?, ?>) - { - Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object; - return map.remove(entry.getKey(), entry.getValue()); - } - - return false; - } - - @Override - public void clear() - { - map.clear(); - } - } - - /** - * @author Eike Stepper - */ - private class EntrySetIterator implements Iterator<Map.Entry<K, V>> - { - private Iterator<Entry<K, KeyedReference<K, V>>> it = map.entrySet().iterator(); - - private MapEntry<K, V> nextEntry; - - private K lastKey; - - public EntrySetIterator() - { - } - - public boolean hasNext() - { - if (nextEntry != null) - { - return true; - } - - while (it.hasNext()) - { - Entry<K, KeyedReference<K, V>> entry = it.next(); - lastKey = entry.getKey(); - V value = dereference(entry.getValue()); - if (value != null) - { - nextEntry = new MapEntry<K, V>(lastKey, value); - return true; - } - } - - return false; - } - - public Entry<K, V> next() - { - if (nextEntry == null) - { - if (!hasNext()) - { - throw new NoSuchElementException(); - } - } - - try - { - return nextEntry; - } - finally - { - nextEntry = null; - } - } - - public void remove() - { - if (lastKey == null) - { - throw new IllegalStateException("lastKey == null"); - } - - map.remove(lastKey); - lastKey = null; - nextEntry = null; - } - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistry.java deleted file mode 100644 index 7b23898231..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/IRegistry.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.registry; - -import org.eclipse.net4j.util.container.IContainer; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public interface IRegistry<K, V> extends Map<K, V>, IContainer<Map.Entry<K, V>> -{ - public boolean isAutoCommit(); - - public void setAutoCommit(boolean on); - - public void commit(boolean notifications); - - public void commit(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/RegistryUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/RegistryUtil.java deleted file mode 100644 index df8c7be09b..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/RegistryUtil.java +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.registry; - -import org.eclipse.net4j.internal.util.registry.UnmodifiableRegistry; - -/** - * @author Eike Stepper - */ -public final class RegistryUtil -{ - private RegistryUtil() - { - } - - public <K, V> IRegistry<K, V> unmodifiableRegistry(IRegistry<K, V> registry) - { - if (registry instanceof UnmodifiableRegistry) - { - return registry; - } - - return new UnmodifiableRegistry<K, V>(registry); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/package.html deleted file mode 100644 index a012d849fb..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/registry/package.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -Interfaces and classes for general purpose registries. -A registry is like a <code>Map</code> but has some additional features: -<ul> - <li>It provides a descriptor framework for registry elements that - are to be instantiated lazily - <li>It provides a notification framework that enables clients to - react on events (including the resolution of a lazy descriptor) -<ul> -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IChallengeResponse.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IChallengeResponse.java deleted file mode 100644 index 5097308af0..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IChallengeResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface IChallengeResponse -{ - public static final byte ACKNOWLEDGE_SUCCESS = 1; - - public static final byte ACKNOWLEDGE_FAILURE = 0; - - /** - * @author Eike Stepper - */ - public enum State - { - INITIAL, CHALLENGE, RESPONSE, SUCCESS, FAILURE - } - - /** - * @author Eike Stepper - */ - public enum Event - { - START, BUFFER - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentials.java deleted file mode 100644 index 84823b6534..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentials.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface ICredentials -{ - public String getUserID(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java deleted file mode 100644 index 45a14ed9c2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/ICredentialsProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface ICredentialsProvider -{ - public boolean isInteractive(); - - public ICredentials getCredentials(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java deleted file mode 100644 index ec6d722eb3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiationContext.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -import java.nio.ByteBuffer; - -/** - * @author Eike Stepper - */ -public interface INegotiationContext -{ - public ByteBuffer getBuffer(); - - public void transmitBuffer(ByteBuffer buffer); - - public Receiver getReceiver(); - - public void setReceiver(Receiver receiver); - - public Enum<?> getState(); - - public void setState(Enum<?> state); - - public void setUserID(String userID); - - public void setFinished(boolean success); - - public Object getInfo(); - - public void setInfo(Object info); - - /** - * @author Eike Stepper - */ - public interface Receiver - { - public void receiveBuffer(INegotiationContext context, ByteBuffer buffer); - } - -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiator.java deleted file mode 100644 index 61c2d5554f..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/INegotiator.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface INegotiator -{ - public void negotiate(INegotiationContext context); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java deleted file mode 100644 index e712cfee44..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentials.java +++ /dev/null @@ -1,21 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface IPasswordCredentials extends ICredentials -{ - public String getUserID(); - - public char[] getPassword(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java deleted file mode 100644 index bcb49521a3..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IPasswordCredentialsProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface IPasswordCredentialsProvider extends ICredentialsProvider -{ - public IPasswordCredentials getCredentials(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IRandomizer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IRandomizer.java deleted file mode 100644 index ca2f7b4129..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IRandomizer.java +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface IRandomizer -{ - public boolean nextBoolean(); - - public double nextDouble(); - - public float nextFloat(); - - public double nextGaussian(); - - public int nextInt(); - - public int nextInt(int n); - - public long nextLong(); - - public byte[] generateSeed(int numBytes); - - public void nextBytes(byte[] bytes); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IUserManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IUserManager.java deleted file mode 100644 index ea4a35b407..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/IUserManager.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -/** - * @author Eike Stepper - */ -public interface IUserManager -{ - public void addUser(String userID, char[] password); - - public void removeUser(String userID); - - public byte[] encrypt(String userID, byte[] data, String algorithmName) throws SecurityException; -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/SecurityUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/SecurityUtil.java deleted file mode 100644 index ddb773711d..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/security/SecurityUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.security; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.PBEParameterSpec; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; - -/** - * @author Eike Stepper - */ -public final class SecurityUtil -{ - public static final String PBE_WITH_MD5_AND_DES = "PBEWithMD5AndDES"; - - private SecurityUtil() - { - } - - public static byte[] encrypt(byte[] data, char[] password, String algorithmName) throws NoSuchAlgorithmException, - InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, - IllegalBlockSizeException, BadPaddingException - { - // Salt - final byte[] salt = { (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c, (byte)0x7e, (byte)0xc8, (byte)0xee, - (byte)0x99 }; // TODO Make configurable - - // Iteration count - final int count = 20; // TODO Make configurable - - // Create PBE parameter set - PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count); - PBEKeySpec pbeKeySpec = new PBEKeySpec(password); - SecretKeyFactory keyFac = SecretKeyFactory.getInstance(algorithmName); - SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec); - - // Create PBE Cipher - Cipher pbeCipher = Cipher.getInstance(algorithmName); - - // Initialize PBE Cipher with key and parameters - pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec); - - return pbeCipher.doFinal(data); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java deleted file mode 100644 index c4118dca89..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.transaction; - -/** - * @author Eike Stepper - */ -public interface ITransaction<CONTEXT> -{ - public boolean isActive(); - - public CONTEXT getContext(); - - public void execute(ITransactionalOperation<CONTEXT> operation) throws TransactionException; - - public void commit(); - - public void rollback(); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java deleted file mode 100644 index 7cdef365f7..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.transaction; - -/** - * @author Eike Stepper - */ -public interface ITransactionalOperation<CONTEXT> -{ - public void phase1(CONTEXT context) throws Exception; - - public void phase2(CONTEXT context); - - public void undoPhase1(CONTEXT context); -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java deleted file mode 100644 index 5fea066300..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.transaction; - -/** - * @author Eike Stepper - */ -public class TransactionException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public TransactionException() - { - } - - public TransactionException(String message) - { - super(message); - } - - public TransactionException(Throwable cause) - { - super(cause); - } - - public TransactionException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java deleted file mode 100644 index 356fb835dd..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.transaction; - -import org.eclipse.net4j.internal.util.transaction.Transaction; - -/** - * @author Eike Stepper - */ -public final class TransactionUtil -{ - private TransactionUtil() - { - } - - public static <CONTEXT> ITransaction<CONTEXT> createTransaction(CONTEXT context) - { - return new Transaction<CONTEXT>(context); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/package.html deleted file mode 100644 index d58f8b34e2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/package.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for transactional operations. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> |