diff options
137 files changed, 14777 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.classpath b/plugins/org.eclipse.emf.cdo.examples.server/.classpath new file mode 100644 index 0000000000..751c8f2e50 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.cvsignore b/plugins/org.eclipse.emf.cdo.examples.server/.cvsignore new file mode 100644 index 0000000000..eb65b4b8f2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.cvsignore @@ -0,0 +1,5 @@ +tmp +bin +dist +build +runtime diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.project b/plugins/org.eclipse.emf.cdo.examples.server/.project new file mode 100644 index 0000000000..7a7489ac5e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.example.server</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.emf.cdo.examples.server/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b6a3213fa8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,256 @@ +#Fri Mar 24 07:37:47 CET 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.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=2 +org.eclipse.jdt.core.formatter.blank_lines_after_package=2 +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=2 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=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=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=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=false +org.eclipse.jdt.core.formatter.comment.format_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_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=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +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 diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..a5280f6651 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,19 @@ +#Mon Mar 13 08:16:17 CET 2006 +comment_clear_blank_lines=false +comment_format_comments=false +comment_format_header=false +comment_format_html=true +comment_format_source_code=true +comment_indent_parameter_description=true +comment_indent_root_tags=true +comment_line_length=100 +comment_new_line_for_parameter=true +comment_separate_root_tags=true +eclipse.preferences.version=1 +formatter_settings_version=10 +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.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..a31119f00d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.pde.prefs @@ -0,0 +1,12 @@ +#Mon Mar 14 22:44:04 CET 2005 +compilers.p.deprecated=1 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=0 +compilers.p.unknown-class=1 +compilers.p.unknown-element=0 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.use-project=true +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..321b9877ac --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.emf.cdo.example.server;singleton:=true +Bundle-Version: 1.0.0 +Bundle-ClassPath: net4j.cdo.test.serverapp.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Eclipse-LazyStart: true +Require-Bundle: org.eclipse.emf.cdo.server, + org.eclipse.net4j.socket +Export-Package: org.eclipse.emf.cdo.example.server +Bundle-Activator: org.eclipse.emf.cdo.example.server.CdoTestServerPlugin diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/auth.users b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/auth.users new file mode 100644 index 0000000000..38fac2f997 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/auth.users @@ -0,0 +1 @@ +test=test diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.properties b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.properties new file mode 100644 index 0000000000..6c47d2d99c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.properties @@ -0,0 +1,7 @@ +randomizer.algorithm=SHA1PRNG + +bufferPool.bufferSize=4096 + +channel.responseTimeoutMillis=250000 + +connectionManager.maxConnections=50 diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.xml b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.xml new file mode 100644 index 0000000000..3a3f6bf2a6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/common.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>plugin:/META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- + Net4j Common Part + --> + + <!-- ######################################################## --> + <bean id="randomizer" class="org.eclipse.net4j.core.impl.RandomizerImpl"> + <property name="algorithmName"> + <value>${randomizer.algorithm}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="basicServerProtocol" class="org.eclipse.net4j.core.protocol.BasicServerProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="basicClientProtocol" class="org.eclipse.net4j.core.protocol.BasicClientProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="selectorManager" class="org.eclipse.net4j.socket.impl.SelectorManagerImpl"/> + + <!-- + CDO Common Part + --> + + <!-- ######################################################## --> + <bean id="oidEncoder" class="org.eclipse.emf.cdo.core.impl.OidEncoderImpl"> + <property name="fragmentBits"> + <value>48</value> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties new file mode 100644 index 0000000000..8815dc1883 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties @@ -0,0 +1,53 @@ +acceptor.listenAddr=0.0.0.0 +acceptor.listenPort=2036 + +passiveNegotiator.algorithmName=PBEWithMD5AndDES +passiveNegotiator.tokenLength=128 + +auth.users.file=plugin:/META-INF/auth.users + +################### +# JDBC PROPERTIES # +################### + + +########## +# HSQLDB # +########## + +#jdbc.dialect=hsqldb +#jdbc.driver=org.hsqldb.jdbcDriver +#jdbc.url=jdbc:hsqldb:. +#jdbc.username=sa +#jdbc.password= + +######### +# MYSQL # +######### + +jdbc.dialect=MYSQL +jdbc.driver=org.gjt.mm.mysql.Driver +jdbc.url=jdbc:mysql://localhost/cdoTest +jdbc.username=test +jdbc.password=test + +########## +# ORACLE # +########## + +#jdbc.dialect=oracle +#jdbc.driver= +#jdbc.url= +#jdbc.username= +#jdbc.password= + +######### +# MIMER # +######### + +#jdbc.dialect=mimer +#jdbc.driver= +#jdbc.url= +#jdbc.username= +#jdbc.password= + diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml new file mode 100644 index 0000000000..98ff13f218 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml @@ -0,0 +1,147 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value> plugin:/META-INF/server.properties </value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="acceptor" class="org.eclipse.net4j.socket.impl.SocketAcceptorImpl"> + <property name="listenAddr"> + <value>${acceptor.listenAddr}</value> + </property> + <property name="listenPort"> + <value>${acceptor.listenPort}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="slave" singleton="false" + class="org.eclipse.net4j.socket.impl.PassiveSocketConnectorImpl"> + <property name="bufferPool"> + <ref bean="bufferPool"/> + </property> + <property name="connectionManager"> + <ref bean="connectionManager"/> + </property> + <property name="protocolManager"> + <ref bean="protocolManager"/> + </property> + <property name="selectorManager"> + <ref bean="selectorManager"/> + </property> + </bean> + + <!-- + CDO Server Part + --> + + <!-- ######################################################## --> + <bean id="packageManager" class="org.eclipse.emf.cdo.server.impl.PackageManagerImpl"/> + + <!-- ######################################################## --> + <bean id="resourceManager" class="org.eclipse.emf.cdo.server.impl.ResourceManagerImpl"/> + + <!-- ######################################################## --> + <bean id="columnConverter" class="org.eclipse.emf.cdo.server.impl.ColumnConverterImpl"/> + + <!-- ######################################################## --> + <bean id="cdoServerProtocol" class="org.eclipse.emf.cdo.server.protocol.CdoServerProtocolImpl"> + <property name="protocolManager"> + <ref bean="protocolManager"/> + </property> + <property name="transactionTemplate"> + <ref local="transactionTemplate"/> + </property> + <property name="mapper"> + <ref local="mapper"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="cdoResServerProtocol" + class="org.eclipse.emf.cdo.server.protocol.CdoResServerProtocolImpl"> + <property name="protocolManager"> + <ref bean="protocolManager"/> + </property> + <property name="transactionTemplate"> + <ref local="transactionTemplate"/> + </property> + <property name="mapper"> + <ref local="mapper"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="dataSource" class="org.eclipse.net4j.spring.db.ContextClassLoaderDataSource"> + <property name="driverClassName"> + <value>${jdbc.driver}</value> + </property> + <property name="url"> + <value>${jdbc.url}</value> + </property> + <property name="username"> + <value>${jdbc.username}</value> + </property> + <property name="password"> + <value>${jdbc.password}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="transactionManager" + class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource"> + <ref local="dataSource"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="transactionTemplate" + class="org.springframework.transaction.support.TransactionTemplate"> + <property name="transactionManager"> + <ref local="transactionManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> + <property name="dataSource"> + <ref local="dataSource"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="mapper" class="org.eclipse.emf.cdo.server.impl.MapperImpl"> + <property name="columnConverter"> + <ref local="columnConverter"/> + </property> + <property name="packageManager"> + <ref local="packageManager"/> + </property> + <property name="resourceManager"> + <ref local="resourceManager"/> + </property> + <property name="dataSource"> + <ref local="dataSource"/> + </property> + <property name="jdbcTemplate"> + <ref local="jdbcTemplate"/> + </property> + <property name="oidEncoder"> + <ref bean="oidEncoder"/> + </property> + <property name="sqlDialectName"> + <value>${jdbc.dialect}</value> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/build.properties b/plugins/org.eclipse.emf.cdo.examples.server/build.properties new file mode 100644 index 0000000000..4c82f0a041 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/build.properties @@ -0,0 +1,9 @@ +src.includes = src/ +bin.includes = plugin.xml,\ + META-INF/,\ + plugin.properties,\ + epl-v10.html,\ + net4j.cdo.test.serverapp.jar +jars.compile.order = net4j.cdo.test.serverapp.jar +source.net4j.cdo.test.serverapp.jar = src/ +output.net4j.cdo.test.serverapp.jar = bin/ diff --git a/plugins/org.eclipse.emf.cdo.examples.server/epl-v10.html b/plugins/org.eclipse.emf.cdo.examples.server/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/epl-v10.html @@ -0,0 +1,319 @@ +<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.emf.cdo.examples.server/initMysql.bat b/plugins/org.eclipse.emf.cdo.examples.server/initMysql.bat new file mode 100644 index 0000000000..d39169f617 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/initMysql.bat @@ -0,0 +1,3 @@ +@echo off + +mysql -u test -ptest -e "drop database if exists cdoTest; create database cdoTest" mysql diff --git a/plugins/org.eclipse.emf.cdo.examples.server/launches/CDO Server.launch b/plugins/org.eclipse.emf.cdo.examples.server/launches/CDO Server.launch new file mode 100644 index 0000000000..89af3f721c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/launches/CDO Server.launch @@ -0,0 +1,328 @@ +<?xml version="1.0" encoding="UTF-8"?> +<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> +<stringAttribute key="product" value="org.eclipse.platform.ide"/> +<booleanAttribute key="usefeatures" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<booleanAttribute key="useProduct" value="false"/> +<booleanAttribute key="tracing" value="false"/> +<stringAttribute key="location2" value="_embedded"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +</listAttribute> +<stringAttribute key="selected_target_plugins" value="com.sympedia.tools.ant,com.sympedia.util,com.sympedia.util.eclipse,com.sympedia.util.eclipse.resources,org.apache.ant,org.apache.log4j,org.eclipse.ant.core,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.filesystem,org.eclipse.core.filesystem.win32.x86,org.eclipse.core.jobs,org.eclipse.core.resources,org.eclipse.core.resources.compatibility,org.eclipse.core.resources.win32,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility,org.eclipse.core.runtime.compatibility.registry,org.eclipse.core.variables,org.eclipse.emf.common,org.eclipse.emf.ecore,org.eclipse.emf.edit,org.eclipse.equinox.common,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.osgi,org.eclipse.update.configurator"/> +<booleanAttribute key="automaticValidate" value="true"/> +<mapAttribute key="tracingOptions"> +<mapEntry key="org.eclipse.team.cvs.core/syncchangeevents" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/tldcmdocument/manager" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/jspindexmanager" value="false"/> +<mapEntry key="org.eclipse.core.resources/perf/listeners" value="500"/> +<mapEntry key="org.eclipse.wst.server.core/resources" value="false"/> +<mapEntry key="org.eclipse.wst.css.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> +<mapEntry key="org.eclipse.update.configurator/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/activation" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug" value="true"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/jspsearch" value="false"/> +<mapEntry key="org.eclipse.ui/debug/showSystemJobs" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/structuredmodel/state" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/remote/debug/vmtraceout" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/classes" value="false"/> +<mapEntry key="org.eclipse.wst.xml.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.update.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug/context" value="true"/> +<mapEntry key="org.eclipse.ui/debug/swtdebug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javamodel" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/builder/detection" value="false"/> +<mapEntry key="com.ibm.wtp.common.util/debug/logtrace" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/debug/reconcilerjob" value="false"/> +<mapEntry key="org.eclipse.ui.intro/trace/printHTML" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta/verbose" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.expressions/tracePropertyResolving" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/debug/outline" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/filename" value="runtime.traces"/> +<mapEntry key="org.eclipse.wst.sse.ui/propertyChangeUpdateActionContributionItem" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/transferbuilder/time" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/web" value="false"/> +<mapEntry key="com.ibm.wtp.common.util/debug/loglevel" value="WARNING"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="true"/> +<mapEntry key="org.eclipse.osgi/debug" value="false"/> +<mapEntry key="com.omondo.uml.core/trace/level" value="error"/> +<mapEntry key="org.eclipse.osgi/trace/activation" value="false"/> +<mapEntry key="com.omondo.database/debug/debug" value="true"/> +<mapEntry key="org.eclipse.jface.text/debug/AnnotationPainter" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugmenu" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> +<mapEntry key="org.eclipse.osgi/resolver/imports" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/filters" value="trace.properties"/> +<mapEntry key="org.eclipse.wst.sse.ui/debug" value="true"/> +<mapEntry key="org.eclipse.wst.html.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/extension" value="true"/> +<mapEntry key="org.eclipse.jem.ui/debug/logtracefile" value="default"/> +<mapEntry key="org.eclipse.wst.javascript.core/debug" value="true"/> +<mapEntry key="org.eclipse.team.cvs.core/debug" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> +<mapEntry key="org.eclipse.osgi/resolver/debug" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/install" value="false"/> +<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/errorondeadlock" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser/inprocess" value="false"/> +<mapEntry key="org.eclipse.core.resources/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/profile/impl" value="org.eclipse.osgi.profile.DefaultProfileLogger"/> +<mapEntry key="org.eclipse.osgi/profile/benchmark" value="false"/> +<mapEntry key="org.eclipse.wst.internet.webbrowser/url" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/cvsprotocol" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/postaction" value="false"/> +<mapEntry key="org.eclipse.ui/trace/perspective.listeners" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/manifest" value="false"/> +<mapEntry key="org.eclipse.help/debug/context" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/builder" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/actioncontributor/debugstatusfields" value="false"/> +<mapEntry key="org.eclipse.osgi/resolver/requires" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendedconfigurationbuilder" value="true"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/activateplugin" value="true"/> +<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> +<mapEntry key="org.eclipse.wst.javascript.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/startlevel" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> +<mapEntry key="com.omondo.database/debug/explorer" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.core.resources/preferences" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> +<mapEntry key="org.eclipse.help/debug/protocols" value="false"/> +<mapEntry key="org.eclipse.help.base/debug/search" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/filemodelprovider/modelstatelistener" value="false"/> +<mapEntry key="org.eclipse.core.resources/natures" value="false"/> +<mapEntry key="org.eclipse.jem/debug/loglevel" value="default"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> +<mapEntry key="org.eclipse.osgi/defaultprofile/buffersize" value="256"/> +<mapEntry key="org.eclipse.osgi/resolver/cycles" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="true"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings.verbose" value="false"/> +<mapEntry key="org.eclipse.core.runtime/preferences/get" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/filebuffers/modelmanagement" value="false"/> +<mapEntry key="org.eclipse.core.runtime/perf/success" value="false"/> +<mapEntry key="org.eclipse.core.runtime/compatibility/debug" value="true"/> +<mapEntry key="org.eclipse.ui/debug/declaredImages" value="false"/> +<mapEntry key="org.eclipse.pde.build/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/location" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts.verbose" value="false"/> +<mapEntry key="org.eclipse.help.base/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/jobs" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/debug/logtrace" value="default"/> +<mapEntry key="org.eclipse.core.runtime/contenttypes/debug" value="true"/> +<mapEntry key="com.omondo.database/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/strings" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/checkCoreBindingGetJavaElement" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/metainfo" value="false"/> +<mapEntry key="org.eclipse.wst.server.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/timing/startup" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/builder" value="false"/> +<mapEntry key="org.eclipse.core.runtime/perf" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/tldcmdocument/factory" value="false"/> +<mapEntry key="org.eclipse.ui/trace/page.listeners" value="false"/> +<mapEntry key="org.eclipse.ui/debug/job.stale" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/allTypesCache" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/debug/logtracefile" value="default"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/jsptranslation" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/builder/modelprovider" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> +<mapEntry key="org.eclipse.wst.internet.monitor.core/debug" value="true"/> +<mapEntry key="org.eclipse.wst.sse.ui/storagemodelprovider/operations" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/loader" value="false"/> +<mapEntry key="org.eclipse.wtp.common/debug/logtrace" value="false"/> +<mapEntry key="org.eclipse.wst.html.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.jst.jsp.core/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/defaultprofile/logsynchronously" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/classLoading" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder/readtime" value="false"/> +<mapEntry key="com.omondo.database/debug/error" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose.commandId" value=""/> +<mapEntry key="org.eclipse.osgi/debug/filter" value="false"/> +<mapEntry key="com.omondo.database/debug/warning" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/structuredmodel/lifecycle" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/ASTProvider" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/taglib/resolve" value="false"/> +<mapEntry key="com.omondo.uml.core/trace/module/viewEvent" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> +<mapEntry key="org.eclipse.core.runtime/jobs/timing" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/filemodelprovider/operations" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="true"/> +<mapEntry key="org.eclipse.wtp.common/debug/loglevel" value="WARNING"/> +<mapEntry key="org.eclipse.help.webapp/debug/workingsets" value="false"/> +<mapEntry key="org.eclipse.osgi/defaultprofile/logfilename" value=""/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> +<mapEntry key="org.eclipse.jem/debug/logtrace" value="default"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> +<mapEntry key="org.eclipse.jface.text/debug/ContentAssistSubjectAdapters" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/builder/participant/tasktag" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> +<mapEntry key="com.omondo.uml.std/trace/module/modelMapper" value="false"/> +<mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/resolution" value="false"/> +<mapEntry key="com.omondo.database/debug/trace" value="true"/> +<mapEntry key="org.eclipse.jst.jsp.core/taglib/indexcreation" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> +<mapEntry key="org.eclipse.core.resources/perf/snapshot" value="500"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug" value="true"/> +<mapEntry key="com.omondo.uml.core/trace/module/UMLPlugin" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packages" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/participantregistry" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/dom/adapter/notification/time" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/converter/debug" value="false"/> +<mapEntry key="org.eclipse.wst.internet.webbrowser/debug" value="true"/> +<mapEntry key="org.eclipse.wtp.common/debug/logtracefile" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser" value="false"/> +<mapEntry key="org.eclipse.core.runtime/preferences/set" value="false"/> +<mapEntry key="org.eclipse.team.core/streams" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/locks" value="false"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/TypeConstraints" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> +<mapEntry key="org.eclipse.jst.jsp.core/taglib/indextime" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/checkCoreBindingIsEqualTo" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/compiler" value="false"/> +<mapEntry key="org.eclipse.jst.server.tomcat.core/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/plugin" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/dom/adapter/notification/time/criteria" value="10"/> +<mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> +<mapEntry key="org.eclipse.jem.beaninfo/debug/logtrace" value="default"/> +<mapEntry key="org.eclipse.jem.beaninfo/debug/logtracefile" value="default"/> +<mapEntry key="org.eclipse.jem.ui/debug/logtrace" value="default"/> +<mapEntry key="org.eclipse.help.webapp/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/filebuffers/lifecycle" value="false"/> +<mapEntry key="org.eclipse.core.resources/refresh" value="false"/> +<mapEntry key="org.eclipse.team.core/backgroundevents" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/debug/loglevel" value="default"/> +<mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> +<mapEntry key="org.eclipse.jem.beaninfo/debug/loglevel" value="default"/> +<mapEntry key="org.eclipse.core.resources/save" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/filemodelprovider/lifecyclelistener" value="false"/> +<mapEntry key="org.eclipse.jem/debug/logtracefile" value="default"/> +<mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> +<mapEntry key="com.omondo.database/debug/info" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/preferences/general" value="false"/> +<mapEntry key="org.eclipse.team.core/threading" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachelookup" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin/timing" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/reconciler" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/security" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/remote/debug/debugvm" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.core.resources/save/syncinfo" value="false"/> +<mapEntry key="org.eclipse.osgi/profile/startup" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/resource" value="*"/> +<mapEntry key="org.eclipse.osgi/debug/services" value="false"/> +<mapEntry key="com.omondo.database/debug/fatal" value="true"/> +<mapEntry key="com.omondo.uml.std/trace/module/modelJavaEvent" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/resources" value="false"/> +<mapEntry key="org.eclipse.jem.proxy/remote/debug/ioconsole" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugpopup" value="false"/> +<mapEntry key="org.eclipse.jem.ui/debug/loglevel" value="default"/> +<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder" value="true"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="true"/> +<mapEntry key="org.eclipse.wst.css.core/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/include.timings" value="true"/> +<mapEntry key="org.eclipse.osgi/debug/bundleTime" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/beginend" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugtoolbar" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/metafiles" value="false"/> +<mapEntry key="org.eclipse.team.core/debug" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/storagemodelprovider/elementstatelistener" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendededitoractionbuilder/contributetime" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/events" value="false"/> +<mapEntry key="org.eclipse.wst.xml.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="true"/> +<mapEntry key="org.eclipse.osgi/debug/monitorbundles" value="false"/> +<mapEntry key="org.eclipse.core.runtime/debug/pluginstopper" value="true"/> +<mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> +<mapEntry key="org.eclipse.jst.jsp.core/partitioner/prefixlistener" value="false"/> +<mapEntry key="org.eclipse.wst.server.ui/editor" value="false"/> +<mapEntry key="org.eclipse.osgi/resolver/wiring" value="false"/> +<mapEntry key="org.eclipse.osgi/profile/debug" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="true"/> +<mapEntry key="org.eclipse.ui/debug/uijob.longwarning" value="false"/> +<mapEntry key="org.eclipse.core.resources/perf/builders" value="10000"/> +<mapEntry key="org.eclipse.update.core/debug/type" value="false"/> +<mapEntry key="org.eclipse.core.resources/history" value="false"/> +<mapEntry key="org.eclipse.team.core/refreshjob" value="false"/> +<mapEntry key="org.eclipse.ui.intro/debug" value="true"/> +<mapEntry key="org.eclipse.wst.sse.core/resourcechangehandling" value="false"/> +<mapEntry key="org.eclipse.debug.core/debug" value="false"/> +<mapEntry key="org.eclipse.help/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> +<mapEntry key="org.eclipse.ui/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/debug/tracefilter" value=""/> +<mapEntry key="org.eclipse.core.runtime/config/debug" value="true"/> +<mapEntry key="org.eclipse.help.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> +<mapEntry key="org.eclipse.wst.sse.core/builder/time" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> +<mapEntry key="com.ibm.wtp.common.util/debug/logtracefile" value="false"/> +<mapEntry key="org.eclipse.core.runtime/perf/failure" value="false"/> +<mapEntry key="org.eclipse.wst.sse.ui/extendedconfigurationbuilder/time" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/buffermanager" value="false"/> +<mapEntry key="org.eclipse.wst.internet.monitor.core/parsing" value="false"/> +<mapEntry key="org.eclipse.wst.server.core/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/resolver/grouping" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="true"/> +<mapEntry key="org.eclipse.ui.intro/trace/logInfo" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> +</mapAttribute> +<stringAttribute key="location3" value="runtime-embedded"/> +<booleanAttribute key="automaticAdd" value="false"/> +<stringAttribute key="checked" value="org.eclipse.core.runtime"/> +<booleanAttribute key="includeFragments" value="true"/> +<stringAttribute key="location" value="/ws.rt/cdo.server"/> +<stringAttribute key="selected_workspace_plugins" value="org.eclipse.net4j.spring,org.eclipse.net4j.socket,org.eclipse.net4j.core,org.eclipse.net4j.spring.db,org.eclipse.emf.cdo.core,org.eclipse.emf.dbgen,org.eclipse.net4j.util,org.eclipse.emf.cdo.example.server,org.eclipse.emf.cdo.server,org.eclipse.emf.jdbc,org.eclipse.emf.dbgen.oracle,org.eclipse.emf.jdbc.mysql,org.eclipse.emf.dbgen.mysql,org.eclipse.emf.dbgen.hsqldb,org.eclipse.emf.dbgen.ansi92"/> +<stringAttribute key="location4" value="C:\workspaces\runtime-workspace"/> +<stringAttribute key="application" value="org.eclipse.emf.cdo.example.server.application"/> +<stringAttribute key="configLocation" value=""/> +<booleanAttribute key="clearws" value="false"/> +<stringAttribute key="location1" value="../cdo.embedded"/> +<stringAttribute key="pde.version" value="3.2a"/> +<stringAttribute key="templateConfig" value=""/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="clearConfig" value="false"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<booleanAttribute key="askclear" value="false"/> +<booleanAttribute key="includeOptional" value="true"/> +</launchConfiguration> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties b/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties new file mode 100644 index 0000000000..ad0d011a53 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties @@ -0,0 +1,2 @@ +pluginName = Net4j CDO Test +providerName = Eclipse.org diff --git a/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml b/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml new file mode 100644 index 0000000000..cc2b5f5c63 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<plugin> + <extension + id="application" + name="CDO Test Server Application" + point="org.eclipse.core.runtime.applications"> + <application> + <run class="org.eclipse.emf.cdo.example.server.CdoTestServerApplication"/> + </application> + </extension> + + + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerApplication.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerApplication.java new file mode 100644 index 0000000000..f033b7e3ea --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerApplication.java @@ -0,0 +1,20 @@ +package org.eclipse.emf.cdo.example.server; + + +import org.eclipse.core.runtime.IPlatformRunnable; + + +public class CdoTestServerApplication implements IPlatformRunnable +{ + public CdoTestServerApplication() + { + } + + public Object run(Object args) throws Exception + { + for (;;) + { + // Graceful shutdown? + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerPlugin.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerPlugin.java new file mode 100644 index 0000000000..e0ed3a8dd2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/CdoTestServerPlugin.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.example.server; + + +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.ContainerCreationException; +import org.eclipse.net4j.spring.impl.ContainerImpl; +import org.eclipse.net4j.util.eclipse.AbstractPlugin; + +import java.io.IOException; + + +/** + * The main plugin class to be used in the desktop. + */ +public class CdoTestServerPlugin extends AbstractPlugin +{ + public static final String CONTEXT_PATH = "META-INF/"; + + //The shared instance. + private static CdoTestServerPlugin plugin; + + private static Container container; + + private static Container serverContainer; + + /** + * The constructor. + */ + public CdoTestServerPlugin() + { + if (plugin == null) plugin = this; + } + + /** + * Returns the shared instance. + */ + public static CdoTestServerPlugin getDefault() + { + return plugin; + } + + protected void doStart() throws Exception + { + getServerContainer(); + } + + protected void doStop() throws Exception + { + if (serverContainer != null) + { + serverContainer.stop(); + serverContainer = null; + } + + if (container != null) + { + container.stop(); + container = null; + } + + plugin = null; + } + + public static Container getContainer() + { + if (container == null) + { + String baseResourcePath; + + try + { + baseResourcePath = getBundleLocation(getDefault().getBundle()); + } + catch (IOException ex) + { + throw new ContainerCreationException("Error while computing location of bundle " + + getDefault().getBundle(), ex); + } + + String location = CONTEXT_PATH + "common.xml"; + String name = "common"; + Container parent = null; + ClassLoader classLoader = getDefault().getClassLoader(); + container = new ContainerImpl(baseResourcePath, location, name, parent, classLoader); + } + + return container; + } + + public static Container getServerContainer() + { + if (serverContainer == null) + { + String baseResourcePath; + + try + { + baseResourcePath = getBundleLocation(getDefault().getBundle()); + } + catch (IOException ex) + { + throw new ContainerCreationException("Error while computing location of bundle " + + getDefault().getBundle(), ex); + } + + String location = CONTEXT_PATH + "server.xml"; + String name = "server"; + Container parent = getContainer(); + ClassLoader classLoader = getDefault().getClassLoader(); + serverContainer = new ContainerImpl(baseResourcePath, location, name, parent, classLoader); + } + + return serverContainer; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/.classpath b/plugins/org.eclipse.emf.cdo.server/.classpath new file mode 100644 index 0000000000..751c8f2e50 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.emf.cdo.server/.cvsignore b/plugins/org.eclipse.emf.cdo.server/.cvsignore new file mode 100644 index 0000000000..eb65b4b8f2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.cvsignore @@ -0,0 +1,5 @@ +tmp +bin +dist +build +runtime diff --git a/plugins/org.eclipse.emf.cdo.server/.project b/plugins/org.eclipse.emf.cdo.server/.project new file mode 100644 index 0000000000..9ea6a8ca9c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.server</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.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..a26cfdb179 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,256 @@ +#Tue Mar 21 17:41:42 CET 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.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=2 +org.eclipse.jdt.core.formatter.blank_lines_after_package=2 +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=2 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=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=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=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=false +org.eclipse.jdt.core.formatter.comment.format_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_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=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +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 diff --git a/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..166555c1ac --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,20 @@ +#Mon Mar 13 08:16:17 CET 2006 +comment_clear_blank_lines=false +comment_format_comments=false +comment_format_header=false +comment_format_html=true +comment_format_source_code=true +comment_indent_parameter_description=true +comment_indent_root_tags=true +comment_line_length=100 +comment_new_line_for_parameter=true +comment_separate_root_tags=true +eclipse.preferences.version=1 +formatter_settings_version=10 +internal.default.compliance=default +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.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 diff --git a/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..7aff9bcec7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/.settings/org.eclipse.pde.prefs @@ -0,0 +1,12 @@ +#Mon Mar 14 22:44:16 CET 2005 +compilers.p.deprecated=1 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=0 +compilers.p.unknown-class=1 +compilers.p.unknown-element=0 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.use-project=true +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7f39047697 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.emf.cdo.server +Bundle-Version: 1.0.0 +Bundle-ClassPath: net4j.cdo.server.jar +Bundle-Activator: org.eclipse.emf.cdo.server.CdoServerPlugin +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Require-Bundle: org.eclipse.emf.cdo.core;visibility:=reexport, + org.eclipse.emf.dbgen;visibility:=reexport, + org.eclipse.emf.jdbc;visibility:=reexport +Eclipse-LazyStart: true +Export-Package: org.eclipse.emf.cdo.server, + org.eclipse.emf.cdo.server.impl, + org.eclipse.emf.cdo.server.protocol diff --git a/plugins/org.eclipse.emf.cdo.server/build.properties b/plugins/org.eclipse.emf.cdo.server/build.properties new file mode 100644 index 0000000000..9557100be9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/build.properties @@ -0,0 +1,9 @@ +src.includes = src/ +bin.includes = plugin.xml,\ + META-INF/,\ + net4j.cdo.server.jar,\ + plugin.properties,\ + epl-v10.html +jars.compile.order = net4j.cdo.server.jar +source.net4j.cdo.server.jar = src/ +output.net4j.cdo.server.jar = bin/ diff --git a/plugins/org.eclipse.emf.cdo.server/epl-v10.html b/plugins/org.eclipse.emf.cdo.server/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/epl-v10.html @@ -0,0 +1,319 @@ +<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.emf.cdo.server/plugin.properties b/plugins/org.eclipse.emf.cdo.server/plugin.properties new file mode 100644 index 0000000000..e6fd2cbf38 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/plugin.properties @@ -0,0 +1,2 @@ +pluginName = Net4j CDO Server +providerName = Eclipse.org diff --git a/plugins/org.eclipse.emf.cdo.server/plugin.xml b/plugins/org.eclipse.emf.cdo.server/plugin.xml new file mode 100644 index 0000000000..8e49b52120 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/plugin.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/AttributeInfo.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/AttributeInfo.java new file mode 100644 index 0000000000..195587a374 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/AttributeInfo.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public interface AttributeInfo +{ + public String getName(); + + public int getFeatureID(); + + public int getDataType(); + + public String getColumnName(); + + public int getColumnType(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java new file mode 100644 index 0000000000..cf1a9a6116 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.spring.Service; + +import org.springframework.transaction.support.TransactionTemplate; + + +public interface CdoResServerProtocol extends Service +{ + public Mapper getMapper(); + + public TransactionTemplate getTransactionTemplate(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerException.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerException.java new file mode 100644 index 0000000000..978061afdb --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerException.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.emf.cdo.core.CdoException; + + +public class CdoServerException extends CdoException +{ + /** + * + */ + private static final long serialVersionUID = 4120854356464777268L; + + /** + * + */ + public CdoServerException() + { + super(); + } + + /** + * @param message + */ + public CdoServerException(String message) + { + super(message); + } + + /** + * @param cause + */ + public CdoServerException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public CdoServerException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerPlugin.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerPlugin.java new file mode 100644 index 0000000000..542bb6d4b3 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerPlugin.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.util.eclipse.AbstractPlugin; +import org.eclipse.net4j.util.eclipse.Element; +import org.eclipse.net4j.util.eclipse.ListExtensionParser; + +import java.util.List; + + +/** + * The main plugin class to be used in the desktop. + */ +public class CdoServerPlugin extends AbstractPlugin +{ + //The shared instance. + private static CdoServerPlugin plugin; + + /** + * The constructor. + */ + public CdoServerPlugin() + { + if (plugin == null) plugin = this; + } + + protected void doStart() throws Exception + { + } + + protected void doStop() throws Exception + { + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static CdoServerPlugin getDefault() + { + return plugin; + } + + + public class MappingElement extends Element + { + protected String uri; + + protected String map; + + public String getMap() + { + return map; + } + + public void setMap(String map) + { + this.map = map; + } + + public String getUri() + { + return uri; + } + + public void setUri(String url) + { + this.uri = url; + } + + public String toString() + { + return "Mapping(" + uri + ", " + map + ")"; + } + } + + + public class MappingExtensionParser extends ListExtensionParser + { + public MappingExtensionParser(List list) + { + super(list); + + addFactory("mapping", new Element.Factory() + { + public Element createElementData() + { + return new MappingElement(); + } + }); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java new file mode 100644 index 0000000000..1441b7d8d7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.spring.Service; + +import org.springframework.transaction.support.TransactionTemplate; + + +public interface CdoServerProtocol extends Service +{ + public Mapper getMapper(); + + public TransactionTemplate getTransactionTemplate(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ClassInfo.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ClassInfo.java new file mode 100644 index 0000000000..b94d6ccb7d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ClassInfo.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public interface ClassInfo +{ + public int getCid(); + + public String getName(); + + public String getParentName(); + + public String getTableName(); + + public PackageInfo getPackageInfo(); + + public AttributeInfo addAttribute(String name, int featureID, int dataType, String columnName, + int columnType); + + public AttributeInfo getAttributeInfo(int feature); + + public AttributeInfo[] getAttributeInfos(); + + public ClassInfo getParent(); + + public String getColumnNames(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ColumnConverter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ColumnConverter.java new file mode 100644 index 0000000000..e01b155016 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ColumnConverter.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.spring.Service; + + +public interface ColumnConverter extends Service +{ + /** + * @param channel + * @return + */ + public Object fromChannel(Channel channel, int dataType); + + /** + * + * @param channel + * @param value + */ + public void toChannel(Channel channel, int dataType, Object value); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/DatabaseInconsistencyException.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/DatabaseInconsistencyException.java new file mode 100644 index 0000000000..1df76e76e9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/DatabaseInconsistencyException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public class DatabaseInconsistencyException extends CdoServerException +{ + /** + * + */ + private static final long serialVersionUID = 3618700786088031544L; + + /** + * + */ + public DatabaseInconsistencyException() + { + super(); + } + + /** + * @param message + */ + public DatabaseInconsistencyException(String message) + { + super(message); + } + + /** + * @param cause + */ + public DatabaseInconsistencyException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public DatabaseInconsistencyException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java new file mode 100644 index 0000000000..60dae9cfbf --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.spring.Service; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.core.OidEncoder; + + +public interface Mapper extends Service, CdoProtocol +{ + public int getNextPid(); + + public int getNextCid(); + + public int getNextRid(); + + public long getNextOid(int rid); + + public void sql(String sql); + + public void sql(String sql, Object[] args); + + public int getCollectionCount(long oid, int feature); + + public boolean lock(long oid, int oca); + + public void insertPackage(final PackageInfo packageInfo); + + public void insertClass(final ClassInfo classInfo); + + public void insertAttribute(final AttributeInfo attributeInfo, final int cid); + + public ResourceInfo createResource(String resourcePath); + + public ResourceInfo selectResourceInfo(String path); + + public ResourceInfo selectResourceInfo(int rid); + + public void insertReference(long oid, int feature, int ordinal, long target, boolean content); + + public void removeReference(long oid, int feature, int ordinal); + + public void moveReferenceAbsolute(long oid, int feature, int toIndex, int fromIndex); + + public void moveReferencesRelative(long oid, int feature, int startIndex, int endIndex, int offset); + + public void insertObject(long oid, int cid); + + public void insertContent(long oid); + + public void removeObject(long oid); + + public void removeContent(long oid); + + public void transmitContent(Channel channel, ResourceInfo resourceInfo); + + public void transmitObject(Channel channel, long oid); + + public void transmitAttributes(Channel channel, long oid, ClassInfo classInfo); + + public void transmitReferences(Channel channel, long oid); + + public void transmitAllResources(Channel channel); + + public void createAttributeTables(PackageInfo packageInfo); + + public void insertResource(int rid, String path); + + public OidEncoder getOidEncoder(); + + public PackageManager getPackageManager(); + + public ResourceManager getResourceManager(); + + public ColumnConverter getColumnConverter(); + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageInfo.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageInfo.java new file mode 100644 index 0000000000..fbbf69b3e8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageInfo.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public interface PackageInfo +{ + public int getPid(); + + public String getName(); + + public PackageManager getPackageManager(); + + public ClassInfo addClass(int cid, String name, String parentName, String tableName); + + public ClassInfo[] getClasses(); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageListener.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageListener.java new file mode 100644 index 0000000000..ce106fdff4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageListener.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public interface PackageListener +{ + public void notifyAddedPackage(); +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageManager.java new file mode 100644 index 0000000000..d0278e4960 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/PackageManager.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.spring.Service; + + +public interface PackageManager extends Service +{ + public void addPackageListener(PackageListener listener); + + public void removePackageListener(PackageListener listener); + + public PackageInfo addPackage(int pid, String name); + + public PackageInfo getPackageInfo(String name); + + public void registerClassInfo(ClassInfo classInfo); + + public ClassInfo getClassInfo(int cid); + + public ClassInfo getClassInfo(String name); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceInfo.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceInfo.java new file mode 100644 index 0000000000..7714efd5a8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceInfo.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public interface ResourceInfo +{ + public long getNextOIDFragment(); + + public String getPath(); + + public int getRid(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java new file mode 100644 index 0000000000..073587db70 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceManager.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +import org.eclipse.net4j.spring.Service; + + +public interface ResourceManager extends Service +{ + public void registerResourceInfo(ResourceInfo resourceInfo); + + public ResourceInfo registerResourceInfo(String resourcePath, int rid, long nextOidFragment); + + public ResourceInfo getResourceInfo(int rid, Mapper mapper); + + public ResourceInfo getResourceInfo(String path, Mapper mapper); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceNotFoundException.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceNotFoundException.java new file mode 100644 index 0000000000..4b9e8c22b2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ResourceNotFoundException.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server; + + +public class ResourceNotFoundException extends CdoServerException +{ + /** + * + */ + private static final long serialVersionUID = 3545239124224062515L; + + public ResourceNotFoundException() + { + super(); + } + + public ResourceNotFoundException(String message) + { + super(message); + } + + public ResourceNotFoundException(Throwable cause) + { + super(cause); + } + + public ResourceNotFoundException(String message, Throwable cause) + { + super(message, cause); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/AttributeInfoImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/AttributeInfoImpl.java new file mode 100644 index 0000000000..4a942cf5ae --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/AttributeInfoImpl.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.emf.cdo.server.AttributeInfo; + + +public class AttributeInfoImpl implements AttributeInfo +{ + protected String name; + + protected int featureID; + + protected int dataType; + + protected String columnName; + + protected int columnType; + + public AttributeInfoImpl(String name, int featureID, int dataType, String columnName, + int columnType) + { + this.name = name; + this.featureID = featureID; + this.dataType = dataType; + this.columnName = columnName; + this.columnType = columnType; + } + + public String getName() + { + return name; + } + + public int getFeatureID() + { + return featureID; + } + + public int getDataType() + { + return dataType; + } + + public String getColumnName() + { + return columnName; + } + + public int getColumnType() + { + return columnType; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ClassInfoImpl.java new file mode 100644 index 0000000000..2a382d44a0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ClassInfoImpl.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.emf.cdo.server.AttributeInfo; +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.PackageInfo; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public class ClassInfoImpl implements ClassInfo +{ + protected int cid; + + protected String name; + + protected String parentName; + + protected String tableName; + + protected PackageInfo packageInfo; + + protected List attributeInfos = new ArrayList(); + + private ClassInfo cachedParent; + + private String cachedColumnNames; + + public ClassInfoImpl(int cid, String name, String parentName, String tableName, + PackageInfo packageInfo) + { + this.cid = cid; + this.cid = cid; + this.name = name; + this.parentName = parentName; + this.tableName = tableName; + this.packageInfo = packageInfo; + } + + public int getCid() + { + return cid; + } + + public String getName() + { + return name; + } + + public String getParentName() + { + return parentName; + } + + public String getTableName() + { + return tableName; + } + + public PackageInfo getPackageInfo() + { + return packageInfo; + } + + public AttributeInfo addAttribute(String name, int featureID, int dataType, String columnName, + int columnType) + { + AttributeInfo attributeInfo = new AttributeInfoImpl(name, featureID, dataType, columnName, + columnType); + attributeInfos.add(attributeInfo); + return attributeInfo; + } + + public AttributeInfo getAttributeInfo(int feature) + { + for (Iterator iter = attributeInfos.iterator(); iter.hasNext();) + { + AttributeInfo attributeInfo = (AttributeInfo) iter.next(); + + if (attributeInfo.getFeatureID() == feature) + { + return attributeInfo; + } + } + + ClassInfo parentInfo = getParent(); + if (parentInfo != null) + { + return parentInfo.getAttributeInfo(feature); + } + + return null; + } + + public AttributeInfo[] getAttributeInfos() + { + return (AttributeInfo[]) attributeInfos.toArray(new AttributeInfo[attributeInfos.size()]); + } + + public ClassInfo getParent() + { + if (cachedParent == null && parentName != null) + { + cachedParent = packageInfo.getPackageManager().getClassInfo(parentName); + } + + return cachedParent; + } + + public String getColumnNames() + { + if (cachedColumnNames == null) + { + StringBuffer buffer = new StringBuffer(); + boolean first = true; + + for (Iterator iter = attributeInfos.iterator(); iter.hasNext();) + { + AttributeInfo attributeInfo = (AttributeInfo) iter.next(); + + if (first) + { + first = false; + } + else + { + buffer.append(", "); + } + + buffer.append(attributeInfo.getColumnName()); + } + + cachedColumnNames = buffer.toString(); + } + + return cachedColumnNames; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ColumnConverterImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ColumnConverterImpl.java new file mode 100644 index 0000000000..1083244e71 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ColumnConverterImpl.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.net4j.core.Channel; + +import org.eclipse.emf.cdo.core.impl.AbstractConverter; +import org.eclipse.emf.cdo.server.ColumnConverter; + + +public class ColumnConverterImpl extends AbstractConverter implements ColumnConverter +{ + public Object fromChannel(Channel channel, int dataType) + { + if (dataType > MIN_PRIMITIVE) + { + boolean isNull = channel.receiveBoolean(); + + if (isNull) + { + return null; + } + + if (dataType < MAX_PRIMITIVE) + { + dataType = -dataType; + } + } + + return dispatchFromChannel(channel, dataType); + } + + public void toChannel(Channel channel, int dataType, Object value) + { + if (dataType > MIN_PRIMITIVE) + { + boolean isNull = value == null; + channel.transmitBoolean(isNull); + + if (isNull) + { + return; + } + + if (dataType < MAX_PRIMITIVE) + { + dataType = -dataType; + } + } + + dispatchToChannel(channel, dataType, value); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java new file mode 100644 index 0000000000..64bf45a82e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java @@ -0,0 +1,876 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.spring.ValidationException; +import org.eclipse.net4j.spring.impl.ServiceImpl; +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.net4j.util.StringHelper; + +import org.eclipse.emf.cdo.core.CdoResProtocol; +import org.eclipse.emf.cdo.core.OidEncoder; +import org.eclipse.emf.cdo.server.AttributeInfo; +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.ColumnConverter; +import org.eclipse.emf.cdo.server.DatabaseInconsistencyException; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.PackageInfo; +import org.eclipse.emf.cdo.server.PackageManager; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.ResourceManager; +import org.eclipse.emf.cdo.server.ResourceNotFoundException; +import org.eclipse.emf.dbgen.ColumnType; +import org.eclipse.emf.dbgen.Database; +import org.eclipse.emf.dbgen.DbgenFactory; +import org.eclipse.emf.dbgen.IndexType; +import org.eclipse.emf.dbgen.SqlDialect; +import org.eclipse.emf.dbgen.Table; +import org.eclipse.emf.dbgen.internal.DbgenActivator; + +import org.springframework.dao.IncorrectResultSizeDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import javax.sql.DataSource; + + +public class MapperImpl extends ServiceImpl implements Mapper, SqlConstants +{ + protected static final int OBJECT_NOT_FOUND_IN_DB = 0; + + protected static final long OBJECT_NOT_REFERENCED_IN_DB = 0; + + protected ColumnConverter columnConverter; + + protected PackageManager packageManager; + + protected ResourceManager resourceManager; + + protected DataSource dataSource; + + protected JdbcTemplate jdbcTemplate; + + protected String sqlDialectName; + + protected OidEncoder oidEncoder; + + private int nextPid; + + private int nextRid; + + private int nextCid; + + private transient SqlDialect cachedSqlDialect; + + /** + * @return Returns the packageManager. + */ + public PackageManager getPackageManager() + { + return packageManager; + } + + /** + * @param packageManager The packageManager to set. + */ + public void setPackageManager(PackageManager packageManager) + { + doSet("packageManager", packageManager); + } + + /** + * @return Returns the columnConverter. + */ + public ColumnConverter getColumnConverter() + { + return columnConverter; + } + + /** + * @param columnConverter The columnConverter to set. + */ + public void setColumnConverter(ColumnConverter columnConverter) + { + doSet("columnConverter", columnConverter); + } + + public ResourceManager getResourceManager() + { + return resourceManager; + } + + public void setResourceManager(ResourceManager resourceManager) + { + doSet("resourceManager", resourceManager); + } + + /** + * @return Returns the dataSource. + */ + public DataSource getDataSource() + { + return dataSource; + } + + /** + * @param dataSource The dataSource to set. + */ + public void setDataSource(DataSource dataSource) + { + doSet("dataSource", dataSource); + } + + /** + * @return Returns the sqlDialect. + */ + public SqlDialect getSqlDialect() + { + if (cachedSqlDialect == null) + { + cachedSqlDialect = DbgenActivator.INSTANCE.createDialect(sqlDialectName); + } + return cachedSqlDialect; + } + + public String getSqlDialectName() + { + return sqlDialectName; + } + + /** + * @param sqlDialectName The sqlDialectName to set. + */ + public void setSqlDialectName(String sqlDialectName) + { + doSet("sqlDialectName", sqlDialectName); + } + + /** + * @return Returns the oidEncoder. + */ + public OidEncoder getOidEncoder() + { + return oidEncoder; + } + + /** + * @param oidEncoder The oidEncoder to set. + */ + public void setOidEncoder(OidEncoder oidEncoder) + { + doSet("oidEncoder", oidEncoder); + } + + /** + * @return Returns the jdbcTemplate. + */ + public JdbcTemplate getJdbcTemplate() + { + return jdbcTemplate; + } + + /** + * @param jdbcTemplate The jdbcTemplate to set. + */ + public void setJdbcTemplate(JdbcTemplate jdbcTemplate) + { + doSet("jdbcTemplate", jdbcTemplate); + } + + public int getNextPid() + { + return nextPid++; + } + + public int getNextCid() + { + return nextCid++; + } + + public int getNextRid() + { + return nextRid++; + } + + public long getNextOid(int rid) + { + ResourceInfo resourceInfo = resourceManager.getResourceInfo(rid, this); + if (resourceInfo == null) throw new ResourceNotFoundException("Unknown RID: " + rid); + + long nextOidFragment = resourceInfo.getNextOIDFragment(); + return oidEncoder.getOID(rid, nextOidFragment); + } + + protected void validate() throws ValidationException + { + super.validate(); + assertNotNull("columnConverter"); + assertNotNull("packageManager"); + assertNotNull("resourceManager"); + assertNotNull("dataSource"); + assertNotNull("oidEncoder"); + assertNotNull("jdbcTemplate"); + + initTables(); + initPackages(); + + nextPid = selectMaxPid() + 1; + nextCid = selectMaxCid() + 1; + nextRid = selectMaxRid() + 1; + } + + protected void initTables() + { + Database database = DbgenFactory.eINSTANCE.createDatabase(); + + // Table systemTable = database.addTable(SYSTEM_TABLE); + // systemTable.addColumn(SYSTEM_SID_COLUMN, ColumnType.VARCHAR_LITERAL, 63); + // systemTable.addColumn(SYSTEM_STARTED_COLUMN, ColumnType.BOOLEAN_LITERAL); + // systemTable.addSimpleIndex(SYSTEM_SID_COLUMN, IndexType.PRIMARY_LITERAL); + + Table packageTable = database.addTable(PACKAGE_TABLE); + packageTable.addColumn(PACKAGE_PID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + packageTable.addColumn(PACKAGE_NAME_COLUMN, ColumnType.VARCHAR_LITERAL, 255, "NOT NULL"); + packageTable.addSimpleIndex(PACKAGE_PID_COLUMN, IndexType.PRIMARY_LITERAL); + packageTable.addSimpleIndex(PACKAGE_NAME_COLUMN, IndexType.UNIQUE_LITERAL); + + Table classTable = database.addTable(CLASS_TABLE); + classTable.addColumn(CLASS_CID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + classTable.addColumn(CLASS_NAME_COLUMN, ColumnType.VARCHAR_LITERAL, 255, "NOT NULL"); + classTable.addColumn(CLASS_PARENTNAME_COLUMN, ColumnType.VARCHAR_LITERAL, 255); + classTable.addColumn(CLASS_TABLENAME_COLUMN, ColumnType.VARCHAR_LITERAL, 127, "NOT NULL"); + classTable.addColumn(CLASS_PID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + classTable.addSimpleIndex(CLASS_CID_COLUMN, IndexType.PRIMARY_LITERAL); + classTable.addSimpleIndex(CLASS_NAME_COLUMN, IndexType.UNIQUE_LITERAL); + classTable.addSimpleIndex(CLASS_PID_COLUMN, IndexType.NON_UNIQUE_LITERAL); + + Table columnTable = database.addTable(ATTRIBUTE_TABLE); + columnTable.addColumn(ATTRIBUTE_NAME_COLUMN, ColumnType.VARCHAR_LITERAL, 127, "NOT NULL"); + columnTable.addColumn(ATTRIBUTE_FEATUREID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + columnTable.addColumn(ATTRIBUTE_DATATYPE_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + columnTable.addColumn(ATTRIBUTE_COLUMNNAME_COLUMN, ColumnType.VARCHAR_LITERAL, 127, "NOT NULL"); + columnTable.addColumn(ATTRIBUTE_COLUMNTYPE_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + columnTable.addColumn(ATTRIBUTE_CID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + columnTable.addSimpleIndex(ATTRIBUTE_CID_COLUMN, IndexType.NON_UNIQUE_LITERAL); + + Table objectTable = database.addTable(OBJECT_TABLE); + objectTable.addColumn(OBJECT_OID_COLUMN, ColumnType.BIGINT_LITERAL, "NOT NULL"); + objectTable.addColumn(OBJECT_OCA_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + objectTable.addColumn(OBJECT_CID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + objectTable.addSimpleIndex(OBJECT_OID_COLUMN, IndexType.PRIMARY_LITERAL); + objectTable.addSimpleIndex(OBJECT_CID_COLUMN, IndexType.NON_UNIQUE_LITERAL); + + Table resourceTable = database.addTable(RESOURCE_TABLE); + resourceTable.addColumn(RESOURCE_RID_COLUMN, ColumnType.INTEGER_LITERAL, "NOT NULL"); + resourceTable.addColumn(RESOURCE_PATH_COLUMN, ColumnType.VARCHAR_LITERAL, 255, "NOT NULL"); + resourceTable.addSimpleIndex(RESOURCE_RID_COLUMN, IndexType.PRIMARY_LITERAL); + resourceTable.addSimpleIndex(RESOURCE_PATH_COLUMN, IndexType.UNIQUE_LITERAL); + + Table contentTable = database.addTable(CONTENT_TABLE); + contentTable.addColumn(CONTENT_OID_COLUMN, ColumnType.BIGINT_LITERAL, "NOT NULL"); + contentTable.addSimpleIndex(CONTENT_OID_COLUMN, IndexType.PRIMARY_LITERAL); + + Table referenceTable = database.addTable(REFERENCE_TABLE); + referenceTable.addColumn(REFERENCE_OID_COLUMN, ColumnType.BIGINT_LITERAL); + referenceTable.addColumn(REFERENCE_FEATUREID_COLUMN, ColumnType.INTEGER_LITERAL); + referenceTable.addColumn(REFERENCE_ORDINAL_COLUMN, ColumnType.BIGINT_LITERAL); + referenceTable.addColumn(REFERENCE_TARGET_COLUMN, ColumnType.BIGINT_LITERAL, 0, "NOT NULL"); + referenceTable.addColumn(REFERENCE_CONTENT_COLUMN, ColumnType.BOOLEAN_LITERAL); + referenceTable.addSimpleIndex(REFERENCE_TARGET_COLUMN, IndexType.NON_UNIQUE_LITERAL); + + // TODO Check if this compound index generally makes preceding simple index superfluous + referenceTable.addCompoundIndex(new String[] { REFERENCE_TARGET_COLUMN, + REFERENCE_CONTENT_COLUMN,}, IndexType.NON_UNIQUE_LITERAL); + + // This index can not be a real PK (UNIQUE), since during movement of allReferences + // it temporarily holds duplicate entries!!! + referenceTable.addCompoundIndex(new String[] { REFERENCE_OID_COLUMN, + REFERENCE_FEATUREID_COLUMN, REFERENCE_ORDINAL_COLUMN}, IndexType.NON_UNIQUE_LITERAL); + + getSqlDialect().save(dataSource, database, false); + } + + protected void initPackages() + { + if (isDebugEnabled()) debug(SELECT_PACKAGES); + jdbcTemplate.query(SELECT_PACKAGES, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + int pid = resultSet.getInt(1); + String name = resultSet.getString(2); + + if (isDebugEnabled()) debug("Initializing package: pid=" + pid + ", name=" + name); + PackageInfo packageInfo = packageManager.addPackage(pid, name); + initClasses(packageInfo); + } + }); + } + + protected void initClasses(final PackageInfo packageInfo) + { + // TODO This is NOT necessary! + // Important to create a new template instance to handle nested select + JdbcTemplate nestedTemplate = new JdbcTemplate(dataSource); + + Object[] args = { new Integer(packageInfo.getPid())}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_CLASSES, "?", args)); + + nestedTemplate.query(SELECT_CLASSES, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + int cid = resultSet.getInt(1); + String name = resultSet.getString(2); + String parentName = resultSet.getString(3); + String tableName = resultSet.getString(4); + + if (isDebugEnabled()) + debug("Initializing class: cid=" + cid + ", name=" + name + ", parentName=" + parentName + + ", tableName=" + tableName); + ClassInfo classInfo = packageInfo.addClass(cid, name, parentName, tableName); + initAttributes(classInfo); + + if (cid > nextCid) + { + nextCid = cid; + } + } + }); + + ++nextCid; + } + + protected void initAttributes(final ClassInfo classInfo) + { + // Important to create a new template instance to handle nested select + JdbcTemplate nestedTemplate = new JdbcTemplate(dataSource); + + Object[] args = { new Integer(classInfo.getCid())}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_ATTRIBUTES, "?", args)); + + nestedTemplate.query(SELECT_ATTRIBUTES, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + String name = resultSet.getString(1); + int featureId = resultSet.getInt(2); + int dataType = resultSet.getInt(3); + String columnName = resultSet.getString(4); + int columnType = resultSet.getInt(5); + + if (isDebugEnabled()) + debug("Initializing attribute: name=" + name + ", featureId=" + featureId + ", dataType=" + + dataType + ", columnName=" + columnName + ", columnType=" + columnType); + classInfo.addAttribute(name, featureId, dataType, columnName, columnType); + } + }); + } + + public void insertPackage(final PackageInfo packageInfo) + { + sql(INSERT_PACKAGE, new Object[] { new Integer(packageInfo.getPid()), packageInfo.getName()}); + } + + public void insertClass(final ClassInfo classInfo) + { + sql(INSERT_CLASS, new Object[] { new Integer(classInfo.getCid()), classInfo.getName(), + classInfo.getParentName(), classInfo.getTableName(), + new Integer(classInfo.getPackageInfo().getPid())}); + } + + public void insertAttribute(final AttributeInfo attributeInfo, final int cid) + { + sql(INSERT_ATTRIBUTE, + new Object[] { attributeInfo.getName(), new Integer(attributeInfo.getFeatureID()), + new Integer(attributeInfo.getDataType()), attributeInfo.getColumnName(), + new Integer(attributeInfo.getColumnType()), new Integer(cid)}); + } + + public ResourceInfo selectResourceInfo(String path) + { + Object[] args = { path}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_RID_OF_RESOURCE, "?", args)); + + final int[] rows = new int[1]; + final ResourceInfoImpl result = new ResourceInfoImpl(); + result.setPath(path); + + jdbcTemplate.query(SELECT_RID_OF_RESOURCE, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + result.setRid(resultSet.getInt(1)); + ++rows[0]; + } + }); + + if (rows[0] != 1) + { + return null; + } + + long nextOidFragment = selectMaxOidFragment(result.getRid()) + 1; + result.setNextOIDFragment(nextOidFragment); + + if (isDebugEnabled()) debug("Selected " + result); + return result; + } + + public ResourceInfo selectResourceInfo(int rid) + { + Object[] args = { new Integer(rid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_PATH_OF_RESOURCE, "?", args)); + + final int[] rows = new int[1]; + final ResourceInfoImpl result = new ResourceInfoImpl(); + result.setRid(rid); + + jdbcTemplate.query(SELECT_PATH_OF_RESOURCE, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + result.setPath(resultSet.getString(1)); + ++rows[0]; + } + }); + + if (rows[0] != 1) + { + return null; + } + + long nextOidFragment = selectMaxOidFragment(result.getRid()) + 1; + result.setNextOIDFragment(nextOidFragment); + + if (isDebugEnabled()) debug("Selected " + result); + return result; + } + + protected int selectMaxOidFragment(int rid) + { + Object[] args = ridBounds(rid); + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_MAX_OID_FRAGMENT, "?", args)); + long oid = jdbcTemplate.queryForLong(SELECT_MAX_OID_FRAGMENT, args); + return (int) (oid & 0xFFFFFFFFL); // TODO Without OidEncoder??? + } + + private Object[] ridBounds(int rid) + { + long lowerBound = oidEncoder.getOID(rid, 1); + long upperBound = oidEncoder.getOID(rid + 1, 1) - 1; + return new Object[] { new Long(lowerBound), new Long(upperBound)}; + } + + private int selectMaxPid() + { + if (isDebugEnabled()) debug(SELECT_MAX_PID); + return jdbcTemplate.queryForInt(SELECT_MAX_PID); + } + + private int selectMaxCid() + { + if (isDebugEnabled()) debug(SELECT_MAX_CID); + return jdbcTemplate.queryForInt(SELECT_MAX_CID); + } + + private int selectMaxRid() + { + if (isDebugEnabled()) debug(SELECT_MAX_RID); + return jdbcTemplate.queryForInt(SELECT_MAX_RID); + } + + public ResourceInfo createResource(String resourcePath) + { + int rid = getNextRid(); + sql(INSERT_RESOURCE, new Object[] { new Integer(rid), resourcePath}); + return resourceManager.registerResourceInfo(resourcePath, rid, 1); + } + + public int getCollectionCount(long oid, int feature) + { + Object[] args = { new Long(oid), new Integer(feature)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_COLLECTION_COUNT, "?", args)); + + return jdbcTemplate.queryForInt(SELECT_COLLECTION_COUNT, args); + } + + public boolean lock(long oid, int oca) + { + Object[] args = { new Long(oid), new Integer(oca)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(DO_OPTIMISTIC_CONTROL, "?", args)); + + int changed = jdbcTemplate.update(DO_OPTIMISTIC_CONTROL, args); + return changed == 1; + } + + public void insertResource(int rid, String path) + { + sql(INSERT_RESOURCE, new Object[] { new Integer(rid), path}); + } + + public void insertReference(long oid, int feature, int ordinal, long target, boolean content) + { + sql(INSERT_REFERENCE, new Object[] { new Long(oid), new Integer(feature), new Integer(ordinal), + new Long(target), new Boolean(content)}); + } + + public void removeReference(long oid, int feature, int ordinal) + { + sql(REMOVE_REFERENCE, new Object[] { new Long(oid), new Integer(feature), new Integer(ordinal)}); + } + + public void moveReferenceAbsolute(long oid, int feature, int toIndex, int fromIndex) + { + sql(MOVE_REFERENCE_ABSOLUTE, new Object[] { new Integer(toIndex), new Long(oid), + new Integer(feature), new Integer(fromIndex)}); + } + + public void moveReferencesRelative(long oid, int feature, int startIndex, int endIndex, int offset) + { + Object[] args = { new Integer(offset), new Long(oid), new Integer(feature), + new Integer(startIndex), new Integer(endIndex)}; + if (isDebugEnabled()) + debug(StringHelper.replaceWildcards(MOVE_REFERENCES_RELATIVE, "?", args)); + + // ignore number of affected rows + jdbcTemplate.update(MOVE_REFERENCES_RELATIVE, args); + } + + public void insertObject(long oid, int cid) + { + sql(INSERT_OBJECT, new Object[] { new Long(oid), new Integer(cid)}); + } + + protected void removeReferences(long oid) + { + Object[] args = { new Long(oid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(REMOVE_REFERENCES, "?", args)); + + jdbcTemplate.update(REMOVE_REFERENCES, args); + } + + public void removeObject(long oid) + { + removeReferences(oid); // TODO optimize for objects with no refs + + int cid = selectCidOfObject(oid); + ClassInfo classInfo = packageManager.getClassInfo(cid); + + while (classInfo != null) + { + removeSegment(oid, classInfo.getTableName()); + classInfo = classInfo.getParent(); + } + + removeSegment(oid, OBJECT_TABLE); + } + + protected int selectCidOfObject(long oid) + { + Object[] args = { new Long(oid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(SELECT_CID_OF_OBJECT, "?", args)); + + try + { + return jdbcTemplate.queryForInt(SELECT_CID_OF_OBJECT, args); + } + catch (IncorrectResultSizeDataAccessException ex) + { + return OBJECT_NOT_FOUND_IN_DB; + } + } + + protected void removeSegment(long oid, String tableName) + { + StringBuffer query = new StringBuffer("DELETE FROM "); + query.append(tableName); + query.append(" WHERE "); + query.append(OBJECT_OID_COLUMN); + query.append("="); + query.append(oid); + + sql(query.toString()); + } + + public void insertContent(long oid) + { + sql(INSERT_CONTENT, new Object[] { new Long(oid)}); + } + + public void removeContent(long oid) + { + sql(REMOVE_CONTENT, new Object[] { new Long(oid)}); + } + + public void sql(String sql) + { + if (isDebugEnabled()) debug(sql); + + int rows = jdbcTemplate.update(sql); + + if (rows != 1) + { + throw new DatabaseInconsistencyException(sql); + } + } + + public void sql(String sql, Object[] args) + { + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(sql, "?", args)); + + int rows = jdbcTemplate.update(sql, args); + + if (rows != 1) + { + throw new DatabaseInconsistencyException(sql); + } + } + + public void transmitContent(final Channel channel, ResourceInfo resourceInfo) + { + if (resourceInfo != null) + { + Object[] args = ridBounds(resourceInfo.getRid()); + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(TRANSMIT_CONTENT, "?", args)); + + jdbcTemplate.query(TRANSMIT_CONTENT, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + long oid = resultSet.getLong(1); + int oca = resultSet.getInt(2); + int cid = resultSet.getInt(3); + + if (isDebugEnabled()) + debug("Object: oid=" + oidEncoder.toString(oid) + ", oca=" + oca + ", cid=" + cid); + + channel.transmitLong(oid); + channel.transmitInt(oca); + channel.transmitInt(cid); + + ClassInfo classInfo = packageManager.getClassInfo(cid); + if (classInfo == null) throw new ImplementationError("Unknown cid " + cid); + + transmitAttributes(channel, oid, classInfo); + transmitReferences(channel, oid); + } + }); + } + + channel.transmitLong(0); + } + + public void transmitObject(final Channel channel, final long oid) + { + Object[] args = { new Long(oid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(TRANSMIT_OBJECT, "?", args)); + + jdbcTemplate.query(TRANSMIT_OBJECT, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + int oca = resultSet.getInt(1); + int cid = resultSet.getInt(2); + + if (isDebugEnabled()) + debug("Object: oid=" + oidEncoder.toString(oid) + ", oca=" + oca + ", cid=" + cid); + + channel.transmitLong(oid); + channel.transmitInt(oca); + channel.transmitInt(cid); + + ClassInfo classInfo = packageManager.getClassInfo(cid); + if (classInfo == null) throw new ImplementationError("Unknown cid " + cid); + + transmitContainers(channel, oid); + transmitAttributes(channel, oid, classInfo); + transmitReferences(channel, oid); + } + }); + + channel.transmitLong(0); + } + + public void transmitContainers(final Channel channel, long oid) + { + class Container + { + public long oid; + + public int cid; + + public Container(long oid, int cid) + { + this.oid = oid; + this.cid = cid; + } + } + ; + + final List containers = new LinkedList(); + final long[] child = { oid}; + + while (child[0] != 0) + { + Object[] args = { new Long(child[0]), Boolean.TRUE}; + if (isDebugEnabled()) + debug(StringHelper.replaceWildcards(SELECT_CONTAINER_OF_OBJECT, "?", args)); + + child[0] = 0; + jdbcTemplate.query(SELECT_CONTAINER_OF_OBJECT, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + long oid = resultSet.getLong(1); + int cid = resultSet.getInt(2); + + containers.add(0, new Container(oid, cid)); + child[0] = oid; + } + }); + } + + channel.transmitInt(containers.size()); + for (Iterator it = containers.iterator(); it.hasNext();) + { + Container container = (Container) it.next(); + if (isDebugEnabled()) + debug("Container: oid=" + oidEncoder.toString(container.oid) + ", cid=" + container.cid); + + channel.transmitLong(container.oid); + channel.transmitInt(container.cid); + } + } + + public void transmitReferences(final Channel channel, long oid) + { + Object[] args = { new Long(oid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(TRANSMIT_REFERENCES, "?", args)); + jdbcTemplate.query(TRANSMIT_REFERENCES, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + int feature = resultSet.getInt(1); + long target = resultSet.getLong(2); + int cid = resultSet.getInt(3); + + if (isDebugEnabled()) + debug("Reference: feature=" + feature + ", target=" + oidEncoder.toString(target) + + ", cid=" + cid); + + channel.transmitInt(feature); + channel.transmitLong(target); + channel.transmitInt(cid); + } + }); + + channel.transmitInt(-1); + } + + public void transmitAttributes(final Channel channel, long oid, ClassInfo classInfo) + { + while (classInfo != null) + { + String columnNames = classInfo.getColumnNames(); + + if (columnNames != null && columnNames.length() > 0) + { + final ClassInfo finalClassInfo = classInfo; + String sql = "SELECT " + columnNames + " FROM " + classInfo.getTableName() + " WHERE " + + OBJECT_OID_COLUMN + "=?"; + + Object[] args = { new Long(oid)}; + if (isDebugEnabled()) debug(StringHelper.replaceWildcards(sql, "?", args)); + + jdbcTemplate.query(sql, args, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + AttributeInfo[] attributeInfos = finalClassInfo.getAttributeInfos(); + for (int i = 0; i < attributeInfos.length; i++) + { + AttributeInfo attributeInfo = attributeInfos[i]; + + Object value = resultSet.getObject(i + 1); + columnConverter.toChannel(channel, attributeInfo.getDataType(), value); + } + } + }); + } + + classInfo = classInfo.getParent(); + } + } + + public void transmitAllResources(final Channel channel) + { + if (isDebugEnabled()) debug("Querying all resources"); + if (isDebugEnabled()) debug(SELECT_ALL_RESOURCES); + + jdbcTemplate.query(SELECT_ALL_RESOURCES, new RowCallbackHandler() + { + public void processRow(ResultSet resultSet) throws SQLException + { + int rid = resultSet.getInt(1); + String path = resultSet.getString(2); + + channel.transmitInt(rid); + channel.transmitString(path); + } + }); + + channel.transmitInt(CdoResProtocol.NO_MORE_RESOURCES); + } + + public void createAttributeTables(PackageInfo packageInfo) + { + if (isDebugEnabled()) debug("Creating attribute tables"); + + Database database = DbgenFactory.eINSTANCE.createDatabase(); + ClassInfo[] classes = packageInfo.getClasses(); + + for (int i = 0; i < classes.length; i++) + { + ClassInfo classInfo = classes[i]; + createAttributeTable(classInfo, database); + } + + getSqlDialect().save(dataSource, database, false); + } + + private void createAttributeTable(ClassInfo classInfo, Database database) + { + Table segmentTable = database.addTable(classInfo.getTableName()); + segmentTable.addColumn(OBJECT_OID_COLUMN, ColumnType.BIGINT_LITERAL, "NOT NULL"); + + AttributeInfo[] attributeInfos = classInfo.getAttributeInfos(); + for (int i = 0; i < attributeInfos.length; i++) + { + AttributeInfo attributeInfo = attributeInfos[i]; + + String columnName = attributeInfo.getColumnName(); + ColumnType columnType = ColumnType.get(attributeInfo.getColumnType()); + segmentTable.addColumn(columnName, columnType); + } + + segmentTable.addSimpleIndex(OBJECT_OID_COLUMN, IndexType.PRIMARY_LITERAL); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageInfoImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageInfoImpl.java new file mode 100644 index 0000000000..c41019eeb4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageInfoImpl.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.PackageInfo; +import org.eclipse.emf.cdo.server.PackageManager; + +import java.util.ArrayList; +import java.util.List; + + +public class PackageInfoImpl implements PackageInfo +{ + protected int pid; + + protected String name; + + protected PackageManager packageManager; + + protected List classes = new ArrayList(); + + public PackageInfoImpl(int pid, String name, PackageManager packageManager) + { + this.pid = pid; + this.name = name; + this.packageManager = packageManager; + } + + public PackageManager getPackageManager() + { + return packageManager; + } + + public int getPid() + { + return pid; + } + + public String getName() + { + return name; + } + + public ClassInfo addClass(int cid, String name, String parentName, String tableName) + { + ClassInfo classInfo = new ClassInfoImpl(cid, name, parentName, tableName, this); + classes.add(classInfo); + packageManager.registerClassInfo(classInfo); + return classInfo; + } + + public ClassInfo[] getClasses() + { + return (ClassInfo[]) classes.toArray(new ClassInfo[classes.size()]); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageManagerImpl.java new file mode 100644 index 0000000000..04d142254f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/PackageManagerImpl.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.net4j.spring.impl.ServiceImpl; + +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.PackageInfo; +import org.eclipse.emf.cdo.server.PackageListener; +import org.eclipse.emf.cdo.server.PackageManager; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + + +public class PackageManagerImpl extends ServiceImpl implements PackageManager +{ + protected Map cidToClassInfoMap = new HashMap(2111); + + protected Map nameToClassInfoMap = new HashMap(2111); + + protected Map packages = new HashMap(); + + protected List listeners = new ArrayList(); + + public PackageInfo getPackageInfo(String name) + { + return (PackageInfo) packages.get(name); + } + + public PackageInfo addPackage(int pid, String name) + { + PackageInfo packageInfo = new PackageInfoImpl(pid, name, this); + packages.put(name, packageInfo); + notifyPackageListeners(); + return packageInfo; + } + + public void addPackageListener(PackageListener listener) + { + listeners.add(listener); + } + + public void removePackageListener(PackageListener listener) + { + listeners.remove(listener); + } + + public void registerClassInfo(ClassInfo classInfo) + { + cidToClassInfoMap.put(new Integer(classInfo.getCid()), classInfo); + nameToClassInfoMap.put(classInfo.getName(), classInfo); + } + + public ClassInfo getClassInfo(int cid) + { + return (ClassInfo) cidToClassInfoMap.get(new Integer(cid)); + } + + public ClassInfo getClassInfo(String name) + { + return (ClassInfo) nameToClassInfoMap.get(name); + } + + protected void notifyPackageListeners() + { + for (Iterator iter = listeners.iterator(); iter.hasNext();) + { + PackageListener listener = (PackageListener) iter.next(); + listener.notifyAddedPackage(); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceInfoImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceInfoImpl.java new file mode 100644 index 0000000000..f0ad428269 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceInfoImpl.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.emf.cdo.server.ResourceInfo; + + +public class ResourceInfoImpl implements ResourceInfo +{ + private String path; + + private int rid; + + private long nextOIDFragment; + + public ResourceInfoImpl() + { + } + + public ResourceInfoImpl(String path, int rid, long nextOIDFragment) + { + this.path = path; + this.rid = rid; + this.nextOIDFragment = nextOIDFragment; + } + + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public int getRid() + { + return rid; + } + + public void setRid(int rid) + { + this.rid = rid; + } + + public long getNextOIDFragment() + { + return nextOIDFragment++; + } + + public void setNextOIDFragment(long nextOIDFragment) + { + this.nextOIDFragment = nextOIDFragment; + } + + @Override + public String toString() + { + return "ResourceInfo(rid=" + rid + ", path=" + path + ", nextOidFragment=" + nextOIDFragment + + ")"; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceManagerImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceManagerImpl.java new file mode 100644 index 0000000000..6783d56db9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/ResourceManagerImpl.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +import org.eclipse.net4j.spring.impl.ServiceImpl; + +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.ResourceManager; + +import java.util.HashMap; +import java.util.Map; + + +public class ResourceManagerImpl extends ServiceImpl implements ResourceManager +{ + private Map<Integer, ResourceInfo> ridToResourceMap = new HashMap<Integer, ResourceInfo>(); + + private Map<String, ResourceInfo> pathToResourceMap = new HashMap<String, ResourceInfo>(); + + public void registerResourceInfo(ResourceInfo resourceInfo) + { + if (isDebugEnabled()) debug("Registering " + resourceInfo); + ridToResourceMap.put(resourceInfo.getRid(), resourceInfo); + pathToResourceMap.put(resourceInfo.getPath(), resourceInfo); + } + + public ResourceInfo registerResourceInfo(String resourcePath, int rid, long nextOidFragment) + { + ResourceInfo resourceInfo = new ResourceInfoImpl(resourcePath, rid, nextOidFragment); + registerResourceInfo(resourceInfo); + return resourceInfo; + } + + public ResourceInfo getResourceInfo(String path, Mapper mapper) + { + ResourceInfo resourceInfo = pathToResourceMap.get(path); + + if (resourceInfo == null) + { + resourceInfo = mapper.selectResourceInfo(path); + + if (resourceInfo == null) + { + return null; + } + + registerResourceInfo(resourceInfo); + } + + return resourceInfo; + } + + public ResourceInfo getResourceInfo(int rid, Mapper mapper) + { + ResourceInfo resourceInfo = ridToResourceMap.get(new Integer(rid)); + + if (resourceInfo == null) + { + resourceInfo = mapper.selectResourceInfo(rid); + + if (resourceInfo == null) + { + return null; + } + + registerResourceInfo(resourceInfo); + } + + return resourceInfo; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/SqlConstants.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/SqlConstants.java new file mode 100644 index 0000000000..63365efbdc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/SqlConstants.java @@ -0,0 +1,199 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.impl; + + +public interface SqlConstants +{ + //-------------------------------------------------------------------- + public static final String SYSTEM_TABLE = "CDO_SYSTEM"; + + public static final String SYSTEM_SID_COLUMN = "SID"; + + public static final String SYSTEM_STARTED_COLUMN = "STARTED"; + + //-------------------------------------------------------------------- + public static final String PACKAGE_TABLE = "CDO_PACKAGE"; + + public static final String PACKAGE_PID_COLUMN = "PID"; + + public static final String PACKAGE_NAME_COLUMN = "NAME"; + + //-------------------------------------------------------------------- + public static final String CLASS_TABLE = "CDO_CLASS"; + + public static final String CLASS_CID_COLUMN = "CID"; + + public static final String CLASS_NAME_COLUMN = "NAME"; + + public static final String CLASS_PARENTNAME_COLUMN = "PARENT" + CLASS_NAME_COLUMN; + + public static final String CLASS_TABLENAME_COLUMN = "TABLENAME"; + + public static final String CLASS_PID_COLUMN = PACKAGE_PID_COLUMN; + + //-------------------------------------------------------------------- + public static final String ATTRIBUTE_TABLE = "CDO_ATTRIBUTE"; + + public static final String ATTRIBUTE_NAME_COLUMN = "NAME"; + + public static final String ATTRIBUTE_FEATUREID_COLUMN = "FEATUREID"; + + public static final String ATTRIBUTE_DATATYPE_COLUMN = "DATATYPE"; + + public static final String ATTRIBUTE_COLUMNNAME_COLUMN = "COLUMNNAME"; + + public static final String ATTRIBUTE_COLUMNTYPE_COLUMN = "COLUMNTYPE"; + + public static final String ATTRIBUTE_CID_COLUMN = CLASS_CID_COLUMN; + + //-------------------------------------------------------------------- + public static final String OBJECT_TABLE = "CDO_OBJECT"; + + public static final String OBJECT_OID_COLUMN = "OID"; + + public static final String OBJECT_OCA_COLUMN = "OCA"; + + public static final String OBJECT_CID_COLUMN = CLASS_CID_COLUMN; + + //-------------------------------------------------------------------- + public static final String RESOURCE_TABLE = "CDO_RESOURCE"; + + public static final String RESOURCE_RID_COLUMN = "RID"; + + public static final String RESOURCE_PATH_COLUMN = "PATH"; + + //-------------------------------------------------------------------- + public static final String CONTENT_TABLE = "CDO_CONTENT"; + + public static final String CONTENT_OID_COLUMN = OBJECT_OID_COLUMN; + + //-------------------------------------------------------------------- + public static final String REFERENCE_TABLE = "CDO_REFERENCE"; + + public static final String REFERENCE_OID_COLUMN = "SOURCE" + OBJECT_OID_COLUMN; + + public static final String REFERENCE_FEATUREID_COLUMN = "FEATUREID"; + + public static final String REFERENCE_CONTENT_COLUMN = "CONTENT"; + + public static final String REFERENCE_ORDINAL_COLUMN = "ORDINAL"; + + public static final String REFERENCE_TARGET_COLUMN = "TARGET" + OBJECT_OID_COLUMN; + + //-------------------------------------------------------------------- + public static final String SELECT_PACKAGES = "SELECT " + PACKAGE_PID_COLUMN + ", " + + PACKAGE_NAME_COLUMN + " FROM " + PACKAGE_TABLE; + + public static final String SELECT_CLASSES = "SELECT " + CLASS_CID_COLUMN + ", " + + CLASS_NAME_COLUMN + ", " + CLASS_PARENTNAME_COLUMN + ", " + CLASS_TABLENAME_COLUMN + + " FROM " + CLASS_TABLE + " WHERE " + CLASS_PID_COLUMN + "=?"; + + public static final String SELECT_ATTRIBUTES = "SELECT " + ATTRIBUTE_NAME_COLUMN + ", " + + ATTRIBUTE_FEATUREID_COLUMN + ", " + ATTRIBUTE_DATATYPE_COLUMN + ", " + + ATTRIBUTE_COLUMNNAME_COLUMN + ", " + ATTRIBUTE_COLUMNTYPE_COLUMN + " FROM " + + ATTRIBUTE_TABLE + " WHERE " + ATTRIBUTE_CID_COLUMN + "=?"; + + public static final String INSERT_PACKAGE = "INSERT INTO " + PACKAGE_TABLE + " VALUES (?, ?)"; + + public static final String INSERT_CLASS = "INSERT INTO " + CLASS_TABLE + + " VALUES (?, ?, ?, ?, ?)"; + + public static final String INSERT_ATTRIBUTE = "INSERT INTO " + ATTRIBUTE_TABLE + + " VALUES (?, ?, ?, ?, ?, ?)"; + + public static final String SELECT_MAX_PID = "SELECT MAX(" + PACKAGE_PID_COLUMN + ") FROM " + + PACKAGE_TABLE; + + public static final String SELECT_MAX_CID = "SELECT MAX(" + CLASS_CID_COLUMN + ") FROM " + + CLASS_TABLE; + + public static final String SELECT_MAX_RID = "SELECT MAX(" + RESOURCE_RID_COLUMN + ") FROM " + + RESOURCE_TABLE; + + public static final String SELECT_MAX_OID_FRAGMENT = "SELECT MAX(" + OBJECT_OID_COLUMN + + ") FROM " + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + " BETWEEN ? AND ?"; + + public static final String SELECT_CID_OF_OBJECT = "SELECT " + OBJECT_CID_COLUMN + " FROM " + + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + "=?"; + + public static final String SELECT_CONTAINER_OF_OBJECT = "SELECT " + REFERENCE_TABLE + "." + + REFERENCE_OID_COLUMN + ", " + OBJECT_TABLE + "." + OBJECT_CID_COLUMN + " FROM " + + REFERENCE_TABLE + ", " + OBJECT_TABLE + " WHERE " + REFERENCE_TABLE + "." + + REFERENCE_TARGET_COLUMN + "=? AND " + REFERENCE_TABLE + "." + REFERENCE_CONTENT_COLUMN + + "=? AND " + REFERENCE_TABLE + "." + REFERENCE_OID_COLUMN + "=" + OBJECT_TABLE + "." + + OBJECT_OID_COLUMN; + + public static final String SELECT_ALL_RESOURCES = "SELECT " + RESOURCE_RID_COLUMN + ", " + + RESOURCE_PATH_COLUMN + " FROM " + RESOURCE_TABLE; + + public static final String SELECT_RID_OF_RESOURCE = "SELECT " + RESOURCE_RID_COLUMN + " FROM " + + RESOURCE_TABLE + " WHERE " + RESOURCE_PATH_COLUMN + "=?"; + + public static final String SELECT_PATH_OF_RESOURCE = "SELECT " + RESOURCE_PATH_COLUMN + " FROM " + + RESOURCE_TABLE + " WHERE " + RESOURCE_RID_COLUMN + "=?"; + + public static final String SELECT_COLLECTION_COUNT = "SELECT COUNT(" + REFERENCE_OID_COLUMN + + ") FROM " + REFERENCE_TABLE + " WHERE " + REFERENCE_OID_COLUMN + "=? AND " + + REFERENCE_FEATUREID_COLUMN + "=?"; + + public static final String INSERT_RESOURCE = "INSERT INTO " + RESOURCE_TABLE + " VALUES (?, ?)"; + + public static final String INSERT_REFERENCE = "INSERT INTO " + REFERENCE_TABLE + + " VALUES (?, ?, ?, ?, ?)"; + + public static final String REMOVE_REFERENCES = "DELETE FROM " + REFERENCE_TABLE + " WHERE " + + REFERENCE_OID_COLUMN + "=?"; + + public static final String REMOVE_REFERENCE = "DELETE FROM " + REFERENCE_TABLE + " WHERE " + + REFERENCE_OID_COLUMN + "=? AND " + REFERENCE_FEATUREID_COLUMN + "=? AND " + + REFERENCE_ORDINAL_COLUMN + "=?"; + + public static final String MOVE_REFERENCE_ABSOLUTE = "UPDATE " + REFERENCE_TABLE + " SET " + + REFERENCE_ORDINAL_COLUMN + "=? WHERE " + REFERENCE_OID_COLUMN + "=? AND " + + REFERENCE_FEATUREID_COLUMN + "=? AND " + REFERENCE_ORDINAL_COLUMN + "=?"; + + public static final String MOVE_REFERENCES_RELATIVE = "UPDATE " + REFERENCE_TABLE + " SET " + + REFERENCE_ORDINAL_COLUMN + "=" + REFERENCE_ORDINAL_COLUMN + "+? WHERE " + + REFERENCE_OID_COLUMN + "=? AND " + REFERENCE_FEATUREID_COLUMN + "=? AND " + + REFERENCE_ORDINAL_COLUMN + " BETWEEN ? AND ?"; + + public static final String TRANSMIT_REFERENCES = "SELECT " + + (REFERENCE_TABLE + "." + REFERENCE_FEATUREID_COLUMN) + ", " + + (REFERENCE_TABLE + "." + REFERENCE_TARGET_COLUMN) + ", " + + (OBJECT_TABLE + "." + OBJECT_CID_COLUMN) + " FROM " + REFERENCE_TABLE + ", " + OBJECT_TABLE + + " WHERE " + (REFERENCE_TABLE + "." + REFERENCE_OID_COLUMN) + "=? AND " + + (REFERENCE_TABLE + "." + REFERENCE_TARGET_COLUMN) + "=" + + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + " ORDER BY " + + (REFERENCE_TABLE + "." + REFERENCE_FEATUREID_COLUMN) + ", " + + (REFERENCE_TABLE + "." + REFERENCE_ORDINAL_COLUMN); + + public static final String INSERT_OBJECT = "INSERT INTO " + OBJECT_TABLE + " VALUES (?, 1, ?)"; + + public static final String INSERT_CONTENT = "INSERT INTO " + CONTENT_TABLE + " VALUES (?)"; + + public static final String REMOVE_CONTENT = "DELETE FROM " + CONTENT_TABLE + " WHERE " + + CONTENT_OID_COLUMN + "=?"; + + public static final String TRANSMIT_CONTENT = "SELECT " + + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + ", " + (OBJECT_TABLE + "." + OBJECT_OCA_COLUMN) + + ", " + (OBJECT_TABLE + "." + OBJECT_CID_COLUMN) + " FROM " + CONTENT_TABLE + ", " + + OBJECT_TABLE + " WHERE " + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + "=" + + (CONTENT_TABLE + "." + CONTENT_OID_COLUMN) + " AND " + + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + " BETWEEN ? AND ?"; + + public static final String TRANSMIT_OBJECT = "SELECT " + OBJECT_OCA_COLUMN + ", " + + OBJECT_CID_COLUMN + " FROM " + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + "=?"; + + public static final String DO_OPTIMISTIC_CONTROL = "UPDATE " + OBJECT_TABLE + " SET " + + OBJECT_OCA_COLUMN + "=" + OBJECT_OCA_COLUMN + "+1 WHERE " + OBJECT_OID_COLUMN + "=?" + + " AND " + OBJECT_OCA_COLUMN + "=?"; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/AnnouncePackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/AnnouncePackageIndication.java new file mode 100644 index 0000000000..bdd4225fe7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/AnnouncePackageIndication.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.PackageInfo; + + +public class AnnouncePackageIndication extends AbstractIndicationWithResponse +{ + private String packageName; + + public short getSignalId() + { + return CdoProtocol.ANNOUNCE_PACKAGE; + } + + public void indicate() + { + packageName = receiveString(); + if (isDebugEnabled()) debug("Announced package " + packageName); + } + + public void respond() + { + Mapper mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + PackageInfo packageInfo = mapper.getPackageManager().getPackageInfo(packageName); + + if (packageInfo == null) + { + if (isDebugEnabled()) debug("Unknown package " + packageName); + transmitInt(-1); + } + else + { + ClassInfo[] classInfos = packageInfo.getClasses(); + transmitInt(classInfos.length); + + for (int i = 0; i < classInfos.length; i++) + { + ClassInfo classInfo = classInfos[i]; + if (isDebugEnabled()) + debug("Responding class " + classInfo.getName() + " = " + classInfo.getCid()); + + transmitInt(classInfo.getCid()); + transmitString(classInfo.getName()); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoResServerProtocolImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoResServerProtocolImpl.java new file mode 100644 index 0000000000..25431f8696 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoResServerProtocolImpl.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.Indication; +import org.eclipse.net4j.spring.ValidationException; +import org.eclipse.net4j.util.ImplementationError; + +import org.eclipse.emf.cdo.core.protocol.AbstractCdoResProtocol; +import org.eclipse.emf.cdo.server.CdoResServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; + +import org.springframework.transaction.support.TransactionTemplate; + + +public class CdoResServerProtocolImpl extends AbstractCdoResProtocol implements + CdoResServerProtocol +{ + protected Mapper mapper; + + protected TransactionTemplate transactionTemplate; + + public CdoResServerProtocolImpl() + { + } + + public int getType() + { + return SERVER; + } + + public Indication createIndication(short signalId) + { + switch (signalId) + { + case QUERY_ALL_RESOURCES: + return new QueryAllResourcesIndication(); + + default: + throw new ImplementationError("Invalid " + PROTOCOL_NAME + " signalId: " + signalId); + } + } + + public Mapper getMapper() + { + return mapper; + } + + public void setMapper(Mapper mapper) + { + doSet("mapper", mapper); + } + + public TransactionTemplate getTransactionTemplate() + { + return transactionTemplate; + } + + public void setTransactionTemplate(TransactionTemplate transactionTemplate) + { + doSet("transactionTemplate", transactionTemplate); + } + + protected void validate() throws ValidationException + { + super.validate(); + assertNotNull("mapper"); + assertNotNull("transactionTemplate"); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java new file mode 100644 index 0000000000..e5260954d9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.Indication; +import org.eclipse.net4j.spring.ValidationException; +import org.eclipse.net4j.util.ImplementationError; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.core.protocol.AbstractCdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; + +import org.springframework.transaction.support.TransactionTemplate; + + +public class CdoServerProtocolImpl extends AbstractCdoProtocol implements CdoServerProtocol +{ + protected Mapper mapper; + + protected TransactionTemplate transactionTemplate; + + public CdoServerProtocolImpl() + { + } + + public int getType() + { + return SERVER; + } + + public Indication createIndication(short signalId) + { + switch (signalId) + { + case ANNOUNCE_PACKAGE: + return new AnnouncePackageIndication(); + + case DESCRIBE_PACKAGE: + return new DescribePackageIndication(); + + case RESOURCE_RID: + return new ResourceRidIndication(); + + case RESOURCE_PATH: + return new ResourcePathIndication(); + + case LOAD_RESOURCE: + return new LoadResourceIndication(); + + case LOAD_OBJECT: + return new LoadObjectIndication(); + + case COMMIT_TRANSACTION: + return new CommitTransactionIndication(); + + default: + throw new ImplementationError("Invalid " + CdoProtocol.PROTOCOL_NAME + " signalId: " + + signalId); + } + } + + public Mapper getMapper() + { + return mapper; + } + + public void setMapper(Mapper mapper) + { + doSet("mapper", mapper); + } + + public TransactionTemplate getTransactionTemplate() + { + return transactionTemplate; + } + + public void setTransactionTemplate(TransactionTemplate transactionTemplate) + { + doSet("transactionTemplate", transactionTemplate); + } + + protected void validate() throws ValidationException + { + super.validate(); + assertNotNull("mapper"); + assertNotNull("transactionTemplate"); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java new file mode 100644 index 0000000000..3531ff99a2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java @@ -0,0 +1,620 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; +import org.eclipse.net4j.util.ImplementationError; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.core.OidEncoder; +import org.eclipse.emf.cdo.server.AttributeInfo; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.ColumnConverter; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.impl.SqlConstants; + +import org.springframework.transaction.TransactionException; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + + +public class CommitTransactionIndication extends AbstractIndicationWithResponse +{ + public static final int CAPACITY_tempIdtoPersistentIdMap = 499; + + private Map tempOIDs = new HashMap(CAPACITY_tempIdtoPersistentIdMap); + + private List changedObjectIds = new ArrayList(); + + private Map changedObjectOidOca = new HashMap(); + + private List oidList = new ArrayList(); + + private boolean optimisticControlException = false; + + private Mapper mapper; + + public short getSignalId() + { + return CdoProtocol.COMMIT_TRANSACTION; + } + + public void indicate() + { + try + { + TransactionTemplate transactionTemplate = ((CdoServerProtocol) getProtocol()) + .getTransactionTemplate(); + transactionTemplate.execute(new TransactionCallbackWithoutResult() + { + public void doInTransactionWithoutResult(TransactionStatus status) + { + receiveObjectsToDetach(); + receiveObjectsToAttach(); + receiveObjectChanges(); + + announcedNewResources(); + } + }); + } + catch (TransactionException ex) + { + error("Error while committing transaction to database", ex); + } + + transmitInvalidations(); + } + + public void respond() + { + if (optimisticControlException) + { + transmitBoolean(false); + return; + } + else + { + transmitBoolean(true); + } + + transmitInt(oidList.size()); + + for (Iterator iter = oidList.iterator(); iter.hasNext();) + { + Long id = (Long) iter.next(); + transmitLong(id.longValue()); + } + + transmitInt(changedObjectIds.size()); + + for (Iterator iter = changedObjectIds.iterator(); iter.hasNext();) + { + Long id = (Long) iter.next(); + transmitLong(id.longValue()); + + Integer oca = (Integer) changedObjectOidOca.get(id); + transmitInt(oca.intValue()); + } + } + + private void announcedNewResources() + { + int rid; + while ((rid = receiveInt()) != 0) + { + String path = receiveString(); + getMapper().insertResource(rid, path); + } + } + + private void receiveObjectsToDetach() + { + if (isDebugEnabled()) debug("receiveObjectsToDetach()"); + + for (;;) + { + long oid = receiveLong(); + + if (oid == 0) + { + break; + } + + getMapper().removeObject(oid); + } + } + + private void receiveObjectsToAttach() + { + if (isDebugEnabled()) debug("receiveObjectsToAttach()"); + int count = receiveInt(); + + for (int i = 0; i < count; i++) + { + long oid = receiveLong(); + + if (oid < 0) + { + oid = registerTempOID(oid); + } + + ClassInfo info = receiveClassInfo(); + getMapper().insertObject(oid, info.getCid()); + + boolean isContent = receiveBoolean(); + if (isContent) + { + getMapper().insertContent(oid); + } + + receiveObjectsToAttachAttributes(info, oid); + } + + receiveObjectsToAttachReferences(); + } + + private void receiveObjectsToAttachReferences() + { + if (isDebugEnabled()) debug("receiveObjectsToAttachReferences()"); + int count = receiveInt(); + + for (int i = 0; i < count; i++) + { + long oid = receiveLong(); + int feature = receiveInt(); + int ordinal = receiveInt(); + long target = receiveLong(); + boolean content = receiveBoolean(); + + if (oid < 0) + { + oid = resolveTempOID(oid); + } + + if (target < 0) + { + target = resolveTempOID(target); + } + + getMapper().insertReference(oid, feature, ordinal, target, content); + } + } + + /** + * @return + */ + private ClassInfo receiveClassInfo() + { + int cid = receiveInt(); + ClassInfo classInfo = getMapper().getPackageManager().getClassInfo(cid); + if (classInfo == null) throw new ImplementationError("Unknown cid " + cid); + + return classInfo; + } + + /** + * @param tempOID + * @return + */ + private long registerTempOID(long tempOID) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + int rid = oidEncoder.getRID(-tempOID); + ResourceInfo resourceInfo = getMapper().getResourceManager().getResourceInfo(rid, getMapper()); + long oidFragment = resourceInfo.getNextOIDFragment(); + + Long key = new Long(tempOID); + long oid = oidEncoder.getOID(rid, oidFragment); + Long val = new Long(oid); + + tempOIDs.put(key, val); + oidList.add(val); + + if (isDebugEnabled()) + debug("Mapping oid " + oidEncoder.toString(key) + " --> " + oidEncoder.toString(val)); + return oid; + } + + /** + * @param tempOID + * @return + */ + private long resolveTempOID(long tempOID) + { + Long sourceVal = (Long) tempOIDs.get(new Long(tempOID)); + + if (sourceVal == null) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + throw new ImplementationError("no mapping for temporary oid " + oidEncoder.toString(tempOID)); + } + + return sourceVal.longValue(); + } + + private void receiveObjectChanges() + { + if (isDebugEnabled()) debug("receiveObjectChanges()"); + + for (;;) + { + long oid = receiveLong(); + if (oid == CdoProtocol.NO_MORE_OBJECT_CHANGES) + { + break; + } + + int oca = receiveInt(); + int newOCA = lock(oid, oca); + + receiveReferenceChanges(); + receiveAttributeChanges(oid); + rememberChangedObject(oid, newOCA); + } + } + + private void receiveReferenceChanges() + { + for (;;) + { + byte changeKind = receiveByte(); + if (changeKind == CdoProtocol.NO_MORE_REFERENCE_CHANGES) + { + break; + } + + switch (changeKind) + { + case CdoProtocol.FEATURE_SET: + receiveReferenceSet(); + break; + + case CdoProtocol.FEATURE_UNSET: + receiveReferenceUnset(); + break; + + case CdoProtocol.LIST_ADD: + receiveReferenceAdd(); + break; + + case CdoProtocol.LIST_REMOVE: + receiveReferenceRemove(); + break; + + case CdoProtocol.LIST_MOVE: + receiveReferenceMove(); + break; + + default: + throw new ImplementationError("invalid changeKind: " + changeKind); + } + } + } + + /** + * @param oid + * @param feature + */ + private void receiveReferenceSet() + { + // oid is not mapped for changes! + long oid = receiveLong(); + int feature = receiveInt(); + long target = receiveLong(); + boolean content = receiveBoolean(); + + if (target < 0) + { + target = resolveTempOID(target); + } + + if (isDebugEnabled()) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + debug("received reference set: oid=" + oidEncoder.toString(oid) + ", feature=" + feature + + ", target=" + oidEncoder.toString(target) + ", content=" + content); + } + + getMapper().insertReference(oid, feature, 0, target, content); + } + + /** + * + */ + private void receiveReferenceUnset() + { + // oid is not mapped for changes! + long oid = receiveLong(); + int feature = receiveInt(); + + if (isDebugEnabled()) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + debug("received reference unset: oid=" + oidEncoder.toString(oid) + ", feature=" + feature); + } + + getMapper().removeReference(oid, feature, 0); + } + + /** + * + */ + private void receiveReferenceAdd() + { + // oid is not mapped for changes! + long oid = receiveLong(); + int feature = receiveInt(); + int ordinal = receiveInt() + 1; + long target = receiveLong(); + boolean content = receiveBoolean(); + + if (target < 0) + { + target = resolveTempOID(target); + } + + if (isDebugEnabled()) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + debug("received reference add: oid=" + oidEncoder.toString(oid) + ", feature=" + feature + + ", ordinal=" + ordinal + ", target=" + oidEncoder.toString(target) + ", content=" + + content); + } + + if (ordinal == 0) + { + ordinal = getMapper().getCollectionCount(oid, feature); + } + + getMapper().moveReferencesRelative(oid, feature, ordinal, Integer.MAX_VALUE, 1); + getMapper().insertReference(oid, feature, ordinal, target, content); + } + + /** + * + */ + private void receiveReferenceRemove() + { + // oid is not mapped for changes! + long oid = receiveLong(); + int feature = receiveInt(); + int ordinal = receiveInt() + 1; + + if (isDebugEnabled()) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + debug("receiveObjectChangesReferences(REMOVE, sourceId=" + oidEncoder.toString(oid) + + ", featureId=" + feature + ", sourceOrdinal=" + ordinal + ")"); + } + + getMapper().removeReference(oid, feature, ordinal); + getMapper().moveReferencesRelative(oid, feature, ordinal, Integer.MAX_VALUE, -1); + } + + /** + * + */ + private void receiveReferenceMove() + { + // oid is not mapped for changes! + long oid = receiveLong(); + int feature = receiveInt(); + int ordinal = receiveInt(); + int moveToIndex = receiveInt(); + + if (isDebugEnabled()) + { + OidEncoder oidEncoder = getMapper().getOidEncoder(); + debug("received reference move: oid=" + oidEncoder.toString(oid) + ", feature=" + feature + + ", ordinal=" + ordinal + ", moveToIndex=" + moveToIndex); + } + + ordinal++; + moveToIndex++; + + getMapper().moveReferenceAbsolute(oid, feature, -1, ordinal); + + if (moveToIndex > ordinal) + { + getMapper().moveReferencesRelative(oid, feature, ordinal + 1, moveToIndex, -1); + } + else if (moveToIndex < ordinal) + { + getMapper().moveReferencesRelative(oid, feature, moveToIndex, ordinal - 1, 1); + } + + getMapper().moveReferenceAbsolute(oid, feature, moveToIndex, -1); + } + + /** + * + * @param oid + * @param oca + */ + private int lock(long oid, int oca) + { + boolean ok = getMapper().lock(oid, oca); + + if (!ok) + { + optimisticControlException = true; + + if (isDebugEnabled()) + { + debug(""); + debug("============================"); + debug("OPTIMISTIC CONTROL EXCEPTION"); + debug("============================"); + debug(""); + } + + return oca; + } + + return oca + 1; + } + + /** + * @param oid + */ + private void rememberChangedObject(long oid, int oca) + { + Long key = new Long(oid); + changedObjectIds.add(key); + changedObjectOidOca.put(key, new Integer(oca)); + } + + /** + * @param info + * @param oid + * @throws InterruptedException + */ + private void receiveAttributeChanges(long oid) + { + ClassInfo classInfo = null; + + for (;;) + { + int cid = receiveInt(); + if (cid == CdoProtocol.NO_MORE_SEGMENTS) + { + break; + } + + classInfo = getMapper().getPackageManager().getClassInfo(cid); + receiveAttributeChangeSegment(oid, classInfo); + } + } + + /** + * + */ + private void receiveAttributeChangeSegment(long oid, ClassInfo classInfo) + { + int count = receiveInt(); + Object[] args = new Object[count + 1]; // last element is the oid + args[count] = new Long(oid); + + StringBuffer sql = new StringBuffer("UPDATE "); + sql.append(classInfo.getTableName()); + sql.append(" SET "); + + for (int i = 0; i < count; i++) + { + int feature = receiveInt(); + AttributeInfo attributeInfo = classInfo.getAttributeInfo(feature); + ColumnConverter converter = getMapper().getColumnConverter(); + args[i] = converter.fromChannel(getChannel(), attributeInfo.getDataType()); + + if (i > 0) sql.append(", "); + sql.append(attributeInfo.getColumnName()); + sql.append("=?"); + } + + sql.append(" WHERE "); + sql.append(SqlConstants.OBJECT_OID_COLUMN); + sql.append("=?"); + + getMapper().sql(sql.toString(), args); + + } + + private void receiveObjectsToAttachAttributes(ClassInfo classInfo, long oid) + { + if (isDebugEnabled()) debug("receiveObjectsToAttachAttributes()"); + + while (classInfo != null) + { + AttributeInfo[] attributeInfos = classInfo.getAttributeInfos(); + + Object[] args = new Object[attributeInfos.length + 1]; // the first element is the oid + args[0] = new Long(oid); + + StringBuffer sql = new StringBuffer("INSERT INTO "); + sql.append(classInfo.getTableName()); + sql.append(" VALUES(?"); + + for (int i = 0; i < attributeInfos.length; i++) + { + AttributeInfo attributeInfo = attributeInfos[i]; + if (isDebugEnabled()) debug("Receiving attribute " + attributeInfo.getName()); + + ColumnConverter converter = getMapper().getColumnConverter(); + args[i + 1] = converter.fromChannel(getChannel(), attributeInfo.getDataType()); + + sql.append(", ?"); + } + + sql.append(")"); + getMapper().sql(sql.toString(), args); + + classInfo = classInfo.getParent(); + } + } + + /** + * + */ + private void transmitInvalidations() + { + if (!changedObjectIds.isEmpty()) + { + Channel me = getChannel(); + int myType = me.getConnector().getType(); + Protocol cdo = me.getProtocol(); + + Channel[] channels = cdo.getChannels(); + for (int i = 0; i < channels.length; i++) + { + Channel channel = channels[i]; + if (channel != me) + { + int type = channel.getConnector().getType(); + if (type == myType) // Important to exclude embedded peers (clients) + { + InvalidateObjectRequest signal = new InvalidateObjectRequest(changedObjectIds); + + try + { + channel.transmit(signal); + } + catch (Exception ex) + { + error("Error while requesting signal " + signal, ex); + } + } + } + } + } + } + + private Mapper getMapper() + { + if (mapper == null) + { + mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + } + + return mapper; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java new file mode 100644 index 0000000000..7764255db4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/DescribePackageIndication.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.AttributeInfo; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.ClassInfo; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.PackageInfo; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public class DescribePackageIndication extends AbstractIndicationWithResponse +{ + private List infos; + + public short getSignalId() + { + return CdoProtocol.DESCRIBE_PACKAGE; + } + + public void indicate() + { + int pid = getMapper().getNextPid(); + String packageName = receiveString(); + if (isDebugEnabled()) debug("Described package " + packageName); + + PackageInfo packageInfo = getMapper().getPackageManager().addPackage(pid, packageName); + getMapper().insertPackage(packageInfo); + + infos = receiveClasses(packageInfo); + getMapper().createAttributeTables(packageInfo); + } + + public void respond() + { + transmitInt(infos.size()); + + for (Iterator iter = infos.iterator(); iter.hasNext();) + { + ClassInfo classInfo = (ClassInfo) iter.next(); + if (isDebugEnabled()) + debug("Responding class " + classInfo.getName() + " = " + classInfo.getCid()); + + transmitInt(classInfo.getCid()); + transmitString(classInfo.getName()); + } + } + + private List receiveClasses(PackageInfo packageInfo) + { + List result = new ArrayList(); + int count = receiveInt(); + + for (int i = 0; i < count; i++) + { + int cid = getMapper().getNextCid(); + String name = receiveString(); + String parentName = receiveString(); + String tableName = receiveString(); + if (isDebugEnabled()) debug("Described class " + name); + + ClassInfo classInfo = packageInfo.addClass(cid, name, parentName, tableName); + getMapper().insertClass(classInfo); + receiveAttributes(classInfo); + + result.add(classInfo); + } + + return result; + } + + private void receiveAttributes(ClassInfo classInfo) + { + int count = receiveInt(); + for (int i = 0; i < count; i++) + { + String name = receiveString(); + int featureId = receiveInt(); + int dataType = receiveInt(); + String columnName = receiveString(); + int columnType = receiveInt(); + if (isDebugEnabled()) debug("Described attribute " + name); + + AttributeInfo attributeInfo = classInfo.addAttribute(name, featureId, dataType, columnName, + columnType); + getMapper().insertAttribute(attributeInfo, classInfo.getCid()); + } + } + + private Mapper getMapper() + { + return ((CdoServerProtocol) getProtocol()).getMapper(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/InvalidateObjectRequest.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/InvalidateObjectRequest.java new file mode 100644 index 0000000000..77da72598c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/InvalidateObjectRequest.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractRequest; + +import org.eclipse.emf.cdo.core.CdoProtocol; + +import java.util.Iterator; +import java.util.List; + + +public class InvalidateObjectRequest extends AbstractRequest +{ + private List changedObjectIds; + + public InvalidateObjectRequest(List changedObjectIds) + { + this.changedObjectIds = changedObjectIds; + } + + public short getSignalId() + { + return CdoProtocol.INVALIDATE_OBJECT; + } + + public void request() + { + transmitInt(changedObjectIds.size()); + + for (Iterator iter = changedObjectIds.iterator(); iter.hasNext();) + { + Long id = (Long) iter.next(); + transmitLong(id.longValue()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadObjectIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadObjectIndication.java new file mode 100644 index 0000000000..e9e8a21d0f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadObjectIndication.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; + + +public class LoadObjectIndication extends AbstractIndicationWithResponse +{ + private long oid; + + public short getSignalId() + { + return CdoProtocol.LOAD_OBJECT; + } + + public void indicate() + { + oid = receiveLong(); + } + + public void respond() + { + Mapper mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + mapper.transmitObject(getChannel(), oid); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadResourceIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadResourceIndication.java new file mode 100644 index 0000000000..9bb7e54d1e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/LoadResourceIndication.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.ResourceManager; + + +public class LoadResourceIndication extends AbstractIndicationWithResponse +{ + private int rid; + + public short getSignalId() + { + return CdoProtocol.LOAD_RESOURCE; + } + + public void indicate() + { + rid = receiveInt(); + } + + public void respond() + { + Mapper mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + ResourceManager resourceManager = mapper.getResourceManager(); + ResourceInfo resourceInfo = resourceManager.getResourceInfo(rid, mapper); + + Channel channel = getChannel(); + // CdoServerProtocolImpl.setResourceInfo(channel, resourceInfo); + mapper.transmitContent(channel, resourceInfo); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/QueryAllResourcesIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/QueryAllResourcesIndication.java new file mode 100644 index 0000000000..28f7cacfde --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/QueryAllResourcesIndication.java @@ -0,0 +1,34 @@ +package org.eclipse.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoResSignals; +import org.eclipse.emf.cdo.server.CdoResServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; + + +public class QueryAllResourcesIndication extends AbstractIndicationWithResponse implements + CdoResSignals +{ + public QueryAllResourcesIndication() + { + } + + public short getSignalId() + { + return QUERY_ALL_RESOURCES; + } + + public void indicate() + { + } + + public void respond() + { + Protocol protocol = getProtocol(); + Mapper mapper = ((CdoResServerProtocol) protocol).getMapper(); + mapper.transmitAllResources(channel); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcePathIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcePathIndication.java new file mode 100644 index 0000000000..3c99c98d12 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcePathIndication.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.ResourceManager; + + +public class ResourcePathIndication extends AbstractIndicationWithResponse +{ + private String path; + + public short getSignalId() + { + return CdoProtocol.RESOURCE_PATH; + } + + public void indicate() + { + path = receiveString(); + if (isDebugEnabled()) debug("Requested path " + path); + } + + public void respond() + { + Mapper mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + ResourceManager resourceManager = mapper.getResourceManager(); + ResourceInfo info = resourceManager.getResourceInfo(path, mapper); + + if (info == null) + { + int rid = mapper.getNextRid(); + resourceManager.registerResourceInfo(path, rid, 1); + + if (isDebugEnabled()) debug("No resource with path " + path); + if (isDebugEnabled()) debug("Reserving rid " + rid); + transmitInt(-rid); + } + else + { + if (isDebugEnabled()) debug("Responding rid " + info.getRid()); + transmitInt(info.getRid()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourceRidIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourceRidIndication.java new file mode 100644 index 0000000000..70de2f99d9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourceRidIndication.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.emf.cdo.server.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + +import org.eclipse.emf.cdo.core.CdoProtocol; +import org.eclipse.emf.cdo.server.CdoServerProtocol; +import org.eclipse.emf.cdo.server.Mapper; +import org.eclipse.emf.cdo.server.ResourceInfo; +import org.eclipse.emf.cdo.server.ResourceManager; + + +public class ResourceRidIndication extends AbstractIndicationWithResponse +{ + private int rid; + + public short getSignalId() + { + return CdoProtocol.RESOURCE_RID; + } + + public void indicate() + { + rid = receiveInt(); + if (isDebugEnabled()) debug("Requested rid " + rid); + } + + public void respond() + { + Mapper mapper = ((CdoServerProtocol) getProtocol()).getMapper(); + ResourceManager resourceManager = mapper.getResourceManager(); + ResourceInfo info = resourceManager.getResourceInfo(rid, mapper); + + if (info == null) + { + if (isDebugEnabled()) debug("No resource with rid " + rid); + transmitString(null); + } + else + { + if (isDebugEnabled()) debug("Responding path " + info.getPath()); + transmitString(info.getPath()); + } + } +} diff --git a/plugins/org.eclipse.net4j.tests/.classpath b/plugins/org.eclipse.net4j.tests/.classpath new file mode 100644 index 0000000000..544119ad6b --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.classpath @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry excluding="org/eclipse/net4j/test/ChannelImplTest.java|org/eclipse/net4j/test/PoolTest.java|org/eclipse/net4j/test/SelectorTest.java|org/eclipse/net4j/test/SocketConnectorTest.java|org/eclipse/net4j/test/old/ChannelImplTest.java|org/eclipse/net4j/test/old/PoolTest.java|org/eclipse/net4j/test/old/SelectorTest.java|org/eclipse/net4j/test/old/SocketConnectorTest.java" kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="src" path="/org.eclipse.net4j.core"/> + <classpathentry kind="src" path="/org.eclipse.net4j.embedded"/> + <classpathentry kind="src" path="/org.eclipse.net4j.socket"/> + <classpathentry kind="src" path="/org.eclipse.net4j.spring"/> + <classpathentry kind="src" path="/org.eclipse.net4j.util"/> + <classpathentry sourcepath="/ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.2.0.v20060215-1200-0cq-cuim1y/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> + <classpathentry kind="lib" path="lib/easymock.jar"/> + <classpathentry kind="lib" path="lib/easymockclassextension.jar"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.net4j.tests/.cvsignore b/plugins/org.eclipse.net4j.tests/.cvsignore new file mode 100644 index 0000000000..28c3030d91 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.cvsignore @@ -0,0 +1,6 @@ +tmp +bin +dist +build +runtime +*.log diff --git a/plugins/org.eclipse.net4j.tests/.project b/plugins/org.eclipse.net4j.tests/.project new file mode 100644 index 0000000000..980ccde5a3 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.net4j.test</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.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..fb74a5035d --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,261 @@ +#Mon Mar 13 08:16:19 CET 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.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=2 +org.eclipse.jdt.core.formatter.blank_lines_after_package=2 +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=2 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=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=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=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=false +org.eclipse.jdt.core.formatter.comment.format_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_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=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +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 diff --git a/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..6b2f797e54 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,19 @@ +#Mon Mar 13 08:16:19 CET 2006 +comment_clear_blank_lines=false +comment_format_comments=false +comment_format_header=false +comment_format_html=true +comment_format_source_code=true +comment_indent_parameter_description=true +comment_indent_root_tags=true +comment_line_length=100 +comment_new_line_for_parameter=true +comment_separate_root_tags=true +eclipse.preferences.version=1 +formatter_settings_version=10 +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.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 diff --git a/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..901cd80165 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.net4j.test;singleton:=true +Bundle-Version: 1.0.0 +Bundle-ClassPath: library.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime +Eclipse-LazyStart: false +Export-Package: org.eclipse.net4j.test, + org.eclipse.net4j.test.protocol, + org.eclipse.net4j.test.util diff --git a/plugins/org.eclipse.net4j.tests/META-INF/common.properties b/plugins/org.eclipse.net4j.tests/META-INF/common.properties new file mode 100644 index 0000000000..23de5e4dbf --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/common.properties @@ -0,0 +1,8 @@ +bufferPool.bufferSize=4096 + +connectionManager.maxConnections=50 + +channel.responseTimeoutMillis=6000000 + +socket.host=localhost +socket.port=12345 diff --git a/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml b/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml new file mode 100644 index 0000000000..a619b3926c --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/embedded.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicServerProtocol" class="org.eclipse.net4j.core.protocol.BasicServerProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="basicClientProtocol" class="org.eclipse.net4j.core.protocol.BasicClientProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connector" class="org.eclipse.net4j.embedded.impl.ActiveEmbeddedConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="slave" singleton="false" + class="org.eclipse.net4j.embedded.impl.PassiveEmbeddedConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="connectionManager"> + <ref local="connectionManager"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml b/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml new file mode 100644 index 0000000000..ba94843956 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/socketClient.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicClientProtocol" class="org.eclipse.net4j.core.protocol.BasicClientProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="selectorManager" class="org.eclipse.net4j.socket.impl.SelectorManagerImpl"/> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connector" class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + <property name="selectorManager"> + <ref local="selectorManager"/> + </property> + <property name="host"> + <value>${socket.host}</value> + </property> + <property name="port"> + <value>${socket.port}</value> + </property> + <property name="autoStart"> + <value>false</value> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml b/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml new file mode 100644 index 0000000000..c570efe600 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/META-INF/socketServer.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" + "http://www.springframework.org/dtd/spring-beans.dtd"> +<beans> + + <!-- ######################################################## --> + <bean id="propertyConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>file:META-INF/common.properties</value> + </list> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="bufferPool" class="org.eclipse.net4j.core.impl.BufferPoolImpl"> + <property name="bufferSize"> + <value>${bufferPool.bufferSize}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="connectionManager" class="org.eclipse.net4j.core.impl.ConnectionManagerImpl"> + <property name="maxConnections"> + <value>${connectionManager.maxConnections}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="protocolManager" class="org.eclipse.net4j.core.impl.ProtocolManagerImpl"/> + + <!-- ######################################################## --> + <bean id="multiplexer" class="org.eclipse.net4j.core.impl.MultiplexerImpl"/> + + <!-- ######################################################## --> + <bean id="basicServerProtocol" class="org.eclipse.net4j.core.protocol.BasicServerProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="channel" singleton="false" class="org.eclipse.net4j.core.impl.ChannelImpl"> + <property name="multiplexer"> + <ref local="multiplexer"/> + </property> + <property name="responseTimeoutMillis"> + <value>${channel.responseTimeoutMillis}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="selectorManager" class="org.eclipse.net4j.socket.impl.SelectorManagerImpl"/> + + <!-- ######################################################## --> + <bean id="protocol" class="org.eclipse.net4j.test.protocol.Net4jTestProtocol"> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="acceptor" class="org.eclipse.net4j.socket.impl.SocketAcceptorImpl"> + <property name="listenAddr"> + <value>0.0.0.0</value> + </property> + <property name="listenPort"> + <value>${socket.port}</value> + </property> + </bean> + + <!-- ######################################################## --> + <bean id="slave" singleton="false" + class="org.eclipse.net4j.socket.impl.PassiveSocketConnectorImpl"> + <property name="bufferPool"> + <ref local="bufferPool"/> + </property> + <property name="connectionManager"> + <ref local="connectionManager"/> + </property> + <property name="protocolManager"> + <ref local="protocolManager"/> + </property> + <property name="selectorManager"> + <ref local="selectorManager"/> + </property> + </bean> + +</beans> diff --git a/plugins/org.eclipse.net4j.tests/build.properties b/plugins/org.eclipse.net4j.tests/build.properties new file mode 100644 index 0000000000..1a993197c7 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/build.properties @@ -0,0 +1,9 @@ +src.includes = src/ +bin.includes = plugin.xml,\ + META-INF/,\ + epl-v10.html,\ + lib/,\ + library.jar +jars.compile.order = library.jar +source.library.jar = src/ +output.library.jar = bin/ diff --git a/plugins/org.eclipse.net4j.tests/epl-v10.html b/plugins/org.eclipse.net4j.tests/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/epl-v10.html @@ -0,0 +1,319 @@ +<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.tests/plugin.xml b/plugins/org.eclipse.net4j.tests/plugin.xml new file mode 100644 index 0000000000..8e49b52120 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/plugin.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin> + +</plugin> diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java new file mode 100644 index 0000000000..0f7dea62a9 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SocketTest.java @@ -0,0 +1,286 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.Request; +import org.eclipse.net4j.test.protocol.Net4jTestProtocol; +import org.eclipse.net4j.test.protocol.TestRequest; +import org.eclipse.net4j.util.thread.DeadlockDetector; + +import junit.framework.TestCase; + + +public class SocketTest extends TestCase +{ + private static final boolean PERFORMANCE = true; + + // ValueHelper.sizeOf(VALUES) --> 363 Bytes + private static final Object[] VALUES = { 1, 2, 3, 4, 5, 6, 7, 8, 9, "A rose is a rose is a...", + 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, "Eclipse 3", 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, "Net4j: An extensible signalling framework", true, false}; + + private TestContainer serverContainer; + + private TestContainer[] clientContainers; + + private int workers; + + private Exception exception; + + private Thread deadlockDetector; + + // static + // { + // System.out.println(ValueHelper.sizeOf(VALUES)); + // } + + public SocketTest(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + workers = 0; + exception = null; + + if (DeadlockDetector.DETECTION) + { + deadlockDetector = new Thread("DeadlockDetector") + { + @Override + public void run() + { + for (;;) + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException ex) + { + return; + } + DeadlockDetector.dump(); + } + } + }; + deadlockDetector.setDaemon(true); + deadlockDetector.start(); + } + } + + protected void tearDown() throws Exception + { + if (clientContainers != null) + { + for (int i = 0; i < clientContainers.length; i++) + { + if (clientContainers[i] != null) + { + clientContainers[i].stop(); + clientContainers[i] = null; + } + } + } + + if (serverContainer != null) + { + serverContainer.stop(); + serverContainer = null; + } + + // if (DeadlockDetector.DETECTION) + // { + // DeadlockDetector.dump(); + // } + + if (deadlockDetector != null) + { + deadlockDetector.interrupt(); + deadlockDetector = null; + } + + workers = 0; + exception = null; + super.tearDown(); + } + + protected void startContainers(int numberOfClients) + { + serverContainer = new TestContainer.SocketServer(); + clientContainers = new TestContainer.SocketClient[numberOfClients]; + for (int i = 0; i < numberOfClients; i++) + { + clientContainers[i] = new TestContainer.SocketClient("client" + + (numberOfClients == 1 ? "" : "" + (i + 1))); + } + } + + protected void joinWorkers() throws InterruptedException, Exception + { + for (;;) + { + Thread.sleep(2000); + synchronized (this) + { + if (workers == 0) break; + if (exception != null) + { + exception.printStackTrace(); + throw exception; + } + } + } + } + + public static void echo(Channel channel, Object[] values) + { + Request request = new TestRequest(values); + Object[] echo = (Object[]) channel.transmit(request); + assertEquals(values, echo); + } + + public static void assertEquals(Object[] values, Object[] echo) + { + assertEquals(values.length, echo.length); + for (int i = 0; i < values.length; i++) + { + assertEquals(values[i], echo[i]); + } + } + + + public class ChannelWorker extends Thread + { + private Channel channel; + + private Object[] values; + + private int numberOfRequests; + + public ChannelWorker(Connector connector, Object[] values, int numberOfRequests) + { + channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + this.values = values; + this.numberOfRequests = numberOfRequests; + + synchronized (SocketTest.this) + { + workers++; + } + + start(); + } + + @Override + public void run() + { + for (int i = 0; i < numberOfRequests; i++) + { + try + { + if (exception != null) return; + echo(channel, values); + } + catch (Exception ex) + { + exception = ex; + } + } + + synchronized (SocketTest.this) + { + workers--; + } + } + } + + public void stressTest() throws Exception + { + final int NUMBER_OF_CLIENTS = 4; + final int CHANNELS_PER_CLIENT = 4; + final int REQUESTS_PER_CHANNEL = 10000; + + startContainers(NUMBER_OF_CLIENTS); + long t0 = System.currentTimeMillis(); + for (int i = 0; i < NUMBER_OF_CLIENTS; i++) + { + for (int j = 0; j < CHANNELS_PER_CLIENT; j++) + { + new ChannelWorker(clientContainers[i].getConnector(), VALUES, REQUESTS_PER_CHANNEL); + Thread.sleep(200); + } + } + + joinWorkers(); + long t1 = System.currentTimeMillis(); + System.out.println("Duration: " + (t1 - t0) + " millisec"); + } + + public void performanceTest() throws Exception + { + startContainers(1); + Connector connector = clientContainers[0].getConnector(); + Channel channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + + double total = 0.0; + for (int i = 1; i <= 1000; i++) + { + long t0 = System.nanoTime(); + echo(channel, VALUES); + long t1 = System.nanoTime(); + + double duration = t1 - t0; + total += duration; + System.out.println("Run " + i + ": " + (duration / 1000000d)); + } + + System.out.println("Average: " + (total / 1000000000d) + " millisec"); + } + + public final void testSocket() throws Exception + { + if (!PERFORMANCE) + { + stressTest(); + } + else + { + performanceTest(); + } + } + + public final void testEmbedded() throws Exception + { + serverContainer = new TestContainer.Embedded(); + Connector connector = serverContainer.getConnector(); + Channel channel = connector.addChannel(Net4jTestProtocol.PROTOCOL_NAME); + + double total = 0.0; + for (int i = 1; i <= 1000; i++) + { + long t0 = System.nanoTime(); + echo(channel, VALUES); + long t1 = System.nanoTime(); + + double duration = t1 - t0; + total += duration; + System.out.println("Run " + i + ": " + (duration / 1000000d)); + } + + System.out.println("Average: " + (total / 1000000000d) + " millisec"); + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java new file mode 100644 index 0000000000..ff864c0033 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TestContainer.java @@ -0,0 +1,73 @@ +package org.eclipse.net4j.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; + +import org.springframework.beans.BeansException; + + +public class TestContainer extends ContainerImpl +{ + private Connector connector; + + protected TestContainer(String baseResourcePath, String configLocation, String name, + Container parent, ClassLoader classLoader) throws BeansException + { + super(baseResourcePath, configLocation, name, parent, classLoader); + } + + protected TestContainer(String baseResourcePath, String[] configLocations, String name, + Container parent, ClassLoader classLoader) throws BeansException + { + super(baseResourcePath, configLocations, name, parent, classLoader); + } + + public Connector getConnector() + { + if (connector == null) + { + connector = (Connector) getBean("connector"); + + try + { + connector.start(); + } + catch (Exception ex) + { + ex.printStackTrace(); + return null; + } + } + + return connector; + } + + + public static class SocketClient extends TestContainer + { + public SocketClient(String name) throws BeansException + { + super(".", "META-INF/socketClient.xml", name, null, null); + } + } + + + public static class SocketServer extends TestContainer + { + public SocketServer() throws BeansException + { + super(".", "META-INF/socketServer.xml", "server", null, null); + } + } + + + public static class Embedded extends TestContainer + { + public Embedded() throws BeansException + { + super(".", "META-INF/embedded.xml", "embedded", null, null); + } + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java new file mode 100644 index 0000000000..ec86e2f6bb --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/ChannelImplTest.java @@ -0,0 +1,763 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.Executor; +import org.eclipse.net4j.core.Multiplexer; +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.BufferImpl; +import org.eclipse.net4j.core.impl.ChannelImpl; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.Service; +import org.eclipse.net4j.spring.ValidationException; +import org.eclipse.net4j.spring.impl.ContainerImpl; +import org.eclipse.net4j.test.util.BlockingDetector; +import org.eclipse.net4j.test.util.ServiceInvoker; +import org.eclipse.net4j.test.util.TestUtils; +import org.eclipse.net4j.util.ImplementationError; + +import org.easymock.MockControl; + +import java.util.Arrays; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +import junit.framework.TestCase; + + +public class ChannelImplTest extends TestCase +{ + protected static Container net4j = new ContainerImpl(null, (String[]) null, "net4j", null, null); + + protected ChannelImpl channel; + + protected Connector connectorMock; + + protected MockControl connectorMockControl; + + protected Executor dispatcherMock; + + protected MockControl dispatcherMockControl; + + protected Multiplexer multiplexerMock; + + protected MockControl multiplexerMockControl; + + protected Protocol protocolMock; + + protected MockControl protocolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + channel = new ChannelImpl(); + channel.setApplicationContext(net4j); + channel.setBeanName("channel"); + + connectorMockControl = MockControl.createControl(Connector.class); + connectorMock = (Connector) connectorMockControl.getMock(); + + dispatcherMockControl = MockControl.createControl(Executor.class); + dispatcherMock = (Executor) dispatcherMockControl.getMock(); + + multiplexerMockControl = MockControl.createControl(Multiplexer.class); + multiplexerMock = (Multiplexer) multiplexerMockControl.getMock(); + + protocolMockControl = MockControl.createControl(Protocol.class); + protocolMock = (Protocol) protocolMockControl.getMock(); + } + + protected void start() + { + connectorMockControl.replay(); + dispatcherMockControl.replay(); + multiplexerMockControl.replay(); + protocolMockControl.replay(); + } + + protected void verify() + { + protocolMockControl.verify(); + multiplexerMockControl.verify(); + dispatcherMockControl.verify(); + connectorMockControl.verify(); + } + + protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + { + BufferImpl buffer = new BufferImpl(capacity); + + if (level > 0) + { + buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + + for (int i = 1; i < level; i++) + { + buffer.put((byte) (i % 256)); + } + } + + if (flipped) + { + buffer.flip(); + } + + return buffer; + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int[] capacities, int[] levels, + boolean flipped) + { + BlockingQueue<BufferImpl> queue = new LinkedBlockingQueue(); + + for (int i = 0; i < levels.length; i++) + { + queue.add(createBuffer(capacities[i], levels[i], flipped)); + } + + return queue; + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int capacity, int[] levels, boolean flipped) + { + int[] capacities = new int[levels.length]; + Arrays.fill(capacities, capacity); + return createBufferQueue(capacities, levels, flipped); + } + + protected BlockingQueue<BufferImpl> createBufferQueue(int capacity, int level, boolean flipped) + { + return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + } + + public final void testSetGetChannelIndex() + { + channel.setChannelIndex((short) 4711); + short result = channel.getChannelIndex(); + assertEquals("getChannelIndex returns the value of setChannelIndex", 4711, result); + + channel.setChannelIndex((short) 0); + result = channel.getChannelIndex(); + assertEquals("getChannelIndex returns 0", 0, result); + } + + public final void testSetGetConnector() + { + channel.setConnector(connectorMock); + Connector result = channel.getConnector(); + assertEquals("getConnector returns the value of setConnector", connectorMock, result); + + channel.setConnector(null); + result = channel.getConnector(); + assertNull("getConnector returns null", result); + } + + public final void testSetGetDispatcher() + { + channel.setDispatcher(dispatcherMock); + Executor result = channel.getDispatcher(); + assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + + channel.setDispatcher(null); + result = channel.getDispatcher(); + assertNull("getDispatcher returns null", result); + } + + public final void testSetGetMultiplexer() + { + channel.setMultiplexer(multiplexerMock); + Multiplexer result = channel.getMultiplexer(); + assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + + channel.setMultiplexer(null); + result = channel.getMultiplexer(); + assertNull("getMultiplexer returns null", result); + } + + public final void testSetGetProtocol() + { + channel.setProtocol(protocolMock); + Protocol result = channel.getProtocol(); + assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + + channel.setProtocol(null); + result = channel.getProtocol(); + assertNull("getProtocol returns null", result); + } + + public final void testSetGetInternalReturnValue() + { + Object returnValue = new Object(); + + channel.internalSetReturnValue(returnValue); + Object result = channel.testGetReturnValue(); + assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + result); + + channel.internalSetReturnValue(null); + result = channel.testGetReturnValue(); + assertNull("testGetReturnValue returns null", result); + } + + public final void testSetGetProtocolData() + { + Object protocolData = new Object(); + + channel.setProtocolData(protocolData); + Object result = channel.getProtocolData(); + assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + + channel.setProtocolData(null); + result = channel.getProtocolData(); + assertNull("getProtocolData returns null", result); + } + + public final void testServiceGuards() + { + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).handleTransmission(); + } + }; + + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).transmit(null); + } + }; + + new ServiceInvoker(channel) + { + protected void invokeService(Service bean) throws Exception + { + ((ChannelImpl) bean).transmit(null); + } + }; + } + + public final void testValidate() + { + channel.setDispatcher(dispatcherMock); + channel.setMultiplexer(multiplexerMock); + channel.testValidate(); + + try + { + channel.setDispatcher(null); + channel.setMultiplexer(multiplexerMock); + channel.testValidate(); + fail("expected ValidationException"); + } + catch (ValidationException expected) + { + TestUtils.assertContains(expected, "dispatcher"); + } + + try + { + channel.setDispatcher(dispatcherMock); + channel.setMultiplexer(null); + channel.testValidate(); + fail("expected ValidationException"); + } + catch (ValidationException expected) + { + TestUtils.assertContains(expected, "multiplexer"); + } + } + + /** + * PRECONDITION: dataSize == 0 + * + * EXPECTATION: doesn't block; + * throws IllegalArgumentException + */ + public final void testEnsureReceiverBuffer1() throws Throwable + { + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(0); + } + }; + fail("IllegalArgumentException expected"); + } + catch (IllegalArgumentException expected) + { + TestUtils.assertContains(expected, "dataSize"); + } + verify(); + } + + /** + * PRECONDITION: dataSize < 0 + * + * EXPECTATION: doesn't block; + * throws IllegalArgumentException + */ + public final void testEnsureReceiverBuffer2() throws Throwable + { + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(-1); + } + }; + fail("IllegalArgumentException expected"); + } + catch (IllegalArgumentException expected) + { + TestUtils.assertContains(expected, "dataSize"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < level < dataSize + * + * EXPECTATION: doesn't block; + * throws ImplementationError + */ + public final void testEnsureReceiverBuffer3() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 3, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "receiverBuffer level too low"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < dataSize < level + * + * EXPECTATION: doesn't block; + * receiverBuffer not returned to bufferPool + */ + public final void testEnsureReceiverBuffer4() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 12, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 < dataSize == level + * + * EXPECTATION: doesn't block; + * receiverBuffer not returned to bufferPool + */ + public final void testEnsureReceiverBuffer5() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 12, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(12); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue empty + * + * EXPECTATION: receiverBuffer returned to bufferPool; + * blocks + */ + public final void testEnsureReceiverBuffer6() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = new LinkedBlockingQueue(); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, true) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has too small buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + * throws ImplementationError + */ + public final void testEnsureReceiverBuffer7() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 5, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + try + { + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "receiverBuffer level too low"); + } + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has exact buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + */ + public final void testEnsureReceiverBuffer8() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 7, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: receiverBuffer exists; + * 0 == level < dataSize; + * receiverQueue has too big buffer + * + * EXPECTATION: doesn't block; + * receiverBuffer returned to bufferPool + */ + public final void testEnsureReceiverBuffer9() throws Throwable + { + BufferImpl receiverBuffer = createBuffer(20, 0, true); + channel.testSetReceiverBuffer(receiverBuffer); + + BlockingQueue<BufferImpl> receiverQueue = createBufferQueue(20, 12, true); + channel.testSetReceiverQueue(receiverQueue); + + connectorMock.releaseBuffer(receiverBuffer); + channel.setConnector(connectorMock); + + start(); + new BlockingDetector(channel, receiverQueue, false) + { + protected void blockableOperation(Object target) throws Exception + { + ((ChannelImpl) target).testEnsureReceiverBufferData(7); + } + }; + verify(); + } + + /** + * PRECONDITION: transmitterBuffer doesn't exists + * + * EXPECTATION: throws ImplementationError + */ + public final void testFlush1() + { + start(); + try + { + channel.flush(); + fail("ImplementationError expected"); + } + catch (ImplementationError expected) + { + TestUtils.assertContains(expected, "transmitterBuffer must exist"); + } + verify(); + } + + /** + * PRECONDITION: transmitterBuffer exists; + * level == 0 + * + * EXPECTATION: immediately returns + */ + public final void testFlush2() + { + BufferImpl transmitterBuffer = createBuffer(20, 0, false); + channel.testSetTransmitterBuffer(transmitterBuffer); + + start(); + channel.flush(); + verify(); + } + + /** + * PRECONDITION: transmitterBuffer exists; + * level > 0 + * + * EXPECTATION: transmitterBuffer is flipped; + * appended to transmitterQueue; + * channel is scheduled for transmission; + * a new transmitterBuffer is fetched from the bufferPool; + * the new transmitterBuffer is empty + */ + public final void testFlush3() + { + BufferImpl transmitterBuffer = createBuffer(20, 7, false); + channel.testSetTransmitterBuffer(transmitterBuffer); + + BlockingQueue<BufferImpl> transmitterQueue = new LinkedBlockingQueue(); + channel.testSetTransmitterQueue(transmitterQueue); + + multiplexerMock.schedule(channel); + channel.setMultiplexer(multiplexerMock); + + connectorMockControl.expectAndReturn(connectorMock.provideBuffer(), createBuffer(10, 10, true)); + channel.setConnector(connectorMock); + + start(); + channel.flush(); + verify(); + + assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + assertTrue("transmitterBuffer is in transmitterQueue", + transmitterQueue.peek() == transmitterBuffer); + assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, channel + .testGetTransmitterBuffer()); + assertTrue("the new transmitterBuffer must be empty", channel.testGetTransmitterBuffer() + .position() < channel.testGetTransmitterBuffer().limit()); // TODO test emptyness + } + + // public final void testReceiveBoolean() + // { + // throw new ImplementationError("Implement receiveBoolean()"); + // } + // + // public final void testReceiveByte() + // { + // throw new ImplementationError("Implement receiveByte()"); + // } + // + // public final void testReceiveChar() + // { + // throw new ImplementationError("Implement receiveChar()"); + // } + // + // public final void testReceiveDouble() + // { + // throw new ImplementationError("Implement receiveDouble()"); + // } + // + // public final void testReceiveFloat() + // { + // throw new ImplementationError("Implement receiveFloat()"); + // } + // + // public final void testReceiveInt() + // { + // throw new ImplementationError("Implement receiveInt()"); + // } + // + // public final void testReceiveLong() + // { + // throw new ImplementationError("Implement receiveLong()"); + // } + // + // public final void testReceiveObject() + // { + // throw new ImplementationError("Implement receiveObject()"); + // } + // + // public final void testReceiveShort() + // { + // throw new ImplementationError("Implement receiveShort()"); + // } + // + // public final void testReceiveString() + // { + // throw new ImplementationError("Implement receiveString()"); + // } + // + // public final void testTransmitBoolean() + // { + // throw new ImplementationError("Implement transmitBoolean()"); + // } + // + // public final void testTransmitByte() + // { + // throw new ImplementationError("Implement transmitByte()"); + // } + // + // public final void testTransmitChar() + // { + // throw new ImplementationError("Implement transmitChar()"); + // } + // + // public final void testTransmitDouble() + // { + // throw new ImplementationError("Implement transmitDouble()"); + // } + // + // public final void testTransmitFloat() + // { + // throw new ImplementationError("Implement transmitFloat()"); + // } + // + // public final void testTransmitInt() + // { + // throw new ImplementationError("Implement transmitInt()"); + // } + // + // public final void testTransmitLong() + // { + // throw new ImplementationError("Implement transmitLong()"); + // } + // + // public final void testTransmitObject() + // { + // throw new ImplementationError("Implement transmitObject()"); + // } + // + // public final void testTransmitShort() + // { + // throw new ImplementationError("Implement transmitShort()"); + // } + // + // public final void testTransmitString() + // { + // throw new ImplementationError("Implement transmitString()"); + // } + // + // public final void testNotifyFinished() + // { + // throw new ImplementationError("Implement notifyFinished()"); + // } + // + // public final void testNotifyData() + // { + // throw new ImplementationError("Implement notifyData()"); + // } + // + // public final void testNotification() + // { + // throw new ImplementationError("Implement notification()"); + // } + // + // public final void testRequest() + // { + // throw new ImplementationError("Implement request()"); + // } + // + // public final void testHandleTransmission() + // { + // throw new ImplementationError("Implement handleTransmission()"); + // } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java new file mode 100644 index 0000000000..caf9f07114 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/PoolTest.java @@ -0,0 +1,724 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test; + + +import org.eclipse.net4j.core.impl.AbstractPool; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; + +import junit.framework.TestCase; + + +public class PoolTest extends TestCase +{ + protected class TestPooled + { + protected Object key; + + public TestPooled(Object key) + { + this.key = key; + } + + public Object getKey() + { + return key; + } + } + + + protected class TestPool extends AbstractPool + { + protected Class doGetPooledClass(Object key) + { + return TestPooled.class; + } + + protected Object newPooled(Object key) throws Exception + { + return new TestPooled(key); + } + } + + protected static Container net4j = new ContainerImpl(null, (String[]) null, "net4j", null, null); + + protected TestPool pool; + + // protected Pool bufferPoolMock; + // + // protected MockControl bufferPoolMockControl; + // + // protected Connector connectorMock; + // + // protected MockControl connectorMockControl; + // + // protected Executor dispatcherMock; + // + // protected MockControl dispatcherMockControl; + // + // protected Multiplexer multiplexerMock; + // + // protected MockControl multiplexerMockControl; + // + // protected Protocol protocolMock; + // + // protected MockControl protocolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + pool = new TestPool(); + pool.setApplicationContext(net4j); + pool.setBeanName("testPool"); + + // bufferPoolMockControl = MockControl.createControl(Pool.class); + // bufferPoolMock = (Pool) bufferPoolMockControl.getMock(); + // + // connectorMockControl = MockControl.createControl(Connector.class); + // connectorMock = (Connector) connectorMockControl.getMock(); + // + // dispatcherMockControl = MockControl.createControl(Executor.class); + // dispatcherMock = (Executor) dispatcherMockControl.getMock(); + // + // multiplexerMockControl = MockControl.createControl(Multiplexer.class); + // multiplexerMock = (Multiplexer) multiplexerMockControl.getMock(); + // + // protocolMockControl = MockControl.createControl(Protocol.class); + // protocolMock = (Protocol) protocolMockControl.getMock(); + } + + protected void start() + { + // bufferPoolMockControl.replay(); + // connectorMockControl.replay(); + // dispatcherMockControl.replay(); + // multiplexerMockControl.replay(); + // protocolMockControl.replay(); + } + + protected void verify() + { + // protocolMockControl.verify(); + // multiplexerMockControl.verify(); + // dispatcherMockControl.verify(); + // connectorMockControl.verify(); + // bufferPoolMockControl.verify(); + } + + // protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + // { + // BufferImpl buffer = new BufferImpl(capacity); + // + // if (level > 0) + // { + // buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + // + // for (int i = 1; i < level; i++) + // { + // buffer.put((byte) (i % 256)); + // } + // } + // + // if (flipped) + // { + // buffer.flip(); + // } + // + // return buffer; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int[] capacities, int[] levels, boolean flipped) + // { + // NodeCachingLinkedList queue = new NodeCachingLinkedList(); + // + // for (int i = 0; i < levels.length; i++) + // { + // queue.add(createBuffer(capacities[i], levels[i], flipped)); + // } + // + // return queue; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int[] levels, boolean flipped) + // { + // int[] capacities = new int[levels.length]; + // Arrays.fill(capacities, capacity); + // return createBufferQueue(capacities, levels, flipped); + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int level, boolean flipped) + // { + // return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + // } + + public final void testGet() + { + pool.setMinimumCapacity(0); + pool.setMaximumCapacity(10); + + final int COUNT = 20; + Object[] pooled = new Object[COUNT]; + + for (int i = COUNT - 1; i >= 0; --i) + { + pooled[i] = pool.get(); + assertNotNull(pooled[i]); + assertEquals(0, pool.getLevel()); + } + + for (int i = 0; i < COUNT; i++) + { + assertEquals(i, pool.getLevel()); + pool.put(pooled[i]); + assertEquals(i + 1, pool.getLevel()); + } + + for (int i = COUNT - 1; i >= 0; --i) + { + assertEquals(i + 1, pool.getLevel()); + pooled[i] = pool.get(); + assertNotNull(pooled[i]); + assertEquals(i, pool.getLevel()); + } + + } + + // public final void testSetGetChannelIndex() + // { + // pool.setChannelId((short) 4711); + // short result = pool.getChannelId(); + // assertEquals("getChannelId returns the value of setChannelId", 4711, result); + // + // pool.setChannelId((short) 0); + // result = pool.getChannelId(); + // assertEquals("getChannelId returns 0", 0, result); + // } + // + // public final void testSetGetBufferPool() + // { + // pool.setBufferPool(bufferPoolMock); + // Pool result = pool.getBufferPool(); + // assertEquals("getBufferPool returns the value of setBufferPool", bufferPoolMock, result); + // + // pool.setBufferPool(null); + // result = pool.getBufferPool(); + // assertNull("getBufferPool returns null", result); + // } + // + // public final void testSetGetConnector() + // { + // pool.setConnector(connectorMock); + // Connector result = pool.getConnector(); + // assertEquals("getConnector returns the value of setConnector", connectorMock, result); + // + // pool.setConnector(null); + // result = pool.getConnector(); + // assertNull("getConnector returns null", result); + // } + // + // public final void testSetGetDispatcher() + // { + // pool.setDispatcher(dispatcherMock); + // Executor result = pool.getDispatcher(); + // assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + // + // pool.setDispatcher(null); + // result = pool.getDispatcher(); + // assertNull("getDispatcher returns null", result); + // } + // + // public final void testSetGetMultiplexer() + // { + // pool.setMultiplexer(multiplexerMock); + // Multiplexer result = pool.getMultiplexer(); + // assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + // + // pool.setMultiplexer(null); + // result = pool.getMultiplexer(); + // assertNull("getMultiplexer returns null", result); + // } + // + // public final void testSetGetProtocol() + // { + // pool.setProtocol(protocolMock); + // Protocol result = pool.getProtocol(); + // assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + // + // pool.setProtocol(null); + // result = pool.getProtocol(); + // assertNull("getProtocol returns null", result); + // } + // + // public final void testSetGetInternalReturnValue() + // { + // Object returnValue = new Object(); + // + // pool.internalSetReturnValue(returnValue); + // Object result = pool.testGetReturnValue(); + // assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + // result); + // + // pool.internalSetReturnValue(null); + // result = pool.testGetReturnValue(); + // assertNull("testGetReturnValue returns null", result); + // } + // + // public final void testSetGetProtocolData() + // { + // Object protocolData = new Object(); + // + // pool.setProtocolData(protocolData); + // Object result = pool.getProtocolData(); + // assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + // + // pool.setProtocolData(null); + // result = pool.getProtocolData(); + // assertNull("getProtocolData returns null", result); + // } + // + // public final void testServiceGuards() + // { + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).handleTransmission(); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).notification(null); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).request(null); + // } + // }; + // } + // + // public final void testValidate() + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // + // try + // { + // pool.setBufferPool(null); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "bufferPool"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(null); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "dispatcher"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(null); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "multiplexer"); + // } + // } + // + // /** + // * PRECONDITION: dataSize == 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer1() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(0); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: dataSize < 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer2() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(-1); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < level < dataSize + // * + // * EXPECTATION: doesn't block; + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer3() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 3, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize < level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer4() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize == level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer5() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(12); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue empty + // * + // * EXPECTATION: receiverBuffer returned to bufferPool; + // * blocks + // */ + // public final void testEnsureReceiverBuffer6() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, true) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too small buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer7() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 5, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has exact buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer8() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 7, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too big buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer9() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 12, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer doesn't exists + // * + // * EXPECTATION: throws ImplementationError + // */ + // public final void testFlush1() + // { + // start(); + // try + // { + // pool.flush(); + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "transmitterBuffer must exist"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level == 0 + // * + // * EXPECTATION: immediately returns + // */ + // public final void testFlush2() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 0, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // start(); + // pool.flush(); + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level > 0 + // * + // * EXPECTATION: transmitterBuffer is flipped; + // * appended to transmitterQueue; + // * channel is scheduled for transmission; + // * a new transmitterBuffer is fetched from the bufferPool; + // * the new transmitterBuffer is empty + // */ + // public final void testFlush3() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 7, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // NodeCachingLinkedList transmitterQueue = new NodeCachingLinkedList(); + // pool.testSetTransmitterQueue(transmitterQueue); + // + // multiplexerMock.schedule(pool); + // pool.setMultiplexer(multiplexerMock); + // + // bufferPoolMockControl.expectAndReturn(bufferPoolMock.get(), createBuffer(10, 10, false)); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // pool.flush(); + // verify(); + // + // assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + // assertTrue("transmitterBuffer is in transmitterQueue", + // transmitterQueue.get(0) == transmitterBuffer); + // assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, pool + // .testGetTransmitterBuffer()); + // assertTrue("the new transmitterBuffer must be empty", pool.testGetTransmitterBuffer() + // .position() == 0); + // + // } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java new file mode 100644 index 0000000000..bdea7d8a69 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SelectorTest.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test; + + +import java.io.IOException; + +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; + +import java.net.InetAddress; +import java.net.InetSocketAddress; + +import junit.framework.TestCase; + + +public class SelectorTest extends TestCase +{ + protected class Server extends Thread + { + protected ServerSocketChannel serverChannel; + + public Server(String listen, int port) throws IOException + { + serverChannel = ServerSocketChannel.open(); + + InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(listen), port); + serverChannel.socket().bind(addr); + start(); + } + + public void run() + { + try + { + SocketChannel socketChannel = serverChannel.accept(); + socketChannel.configureBlocking(false); + readSocketChannel(socketChannel); + } + catch (Exception ex) + { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + } + + public void readSocketChannel(SocketChannel socketChannel) + { + } + } + + public void testFlooding() + { + + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java new file mode 100644 index 0000000000..5f77479267 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/old/SocketConnectorTest.java @@ -0,0 +1,678 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test; + + +import org.eclipse.net4j.core.Connector; +import org.eclipse.net4j.core.DataListener; +import org.eclipse.net4j.core.impl.BufferImpl; +import org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl; +import org.eclipse.net4j.socket.impl.PassiveSocketConnectorImpl; +import org.eclipse.net4j.socket.impl.SocketAcceptorImpl; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; +import org.eclipse.net4j.test.SocketConnectorTest.TestAcceptor.PassiveTestConnector; + +import java.nio.channels.SocketChannel; + +import junit.framework.TestCase; + + +public class SocketConnectorTest extends TestCase +{ + protected static Container container = new ContainerImpl(null, (String[]) null, "container", + null, null); + + protected PassiveTestConnector slave; + + protected TestConnector client; + + protected DataListener slaveListener = new DataListener() + { + public void notifyData(BufferImpl data) + { + } + }; + + // protected Pool bufferPoolMock; + // + // protected MockControl bufferPoolMockControl; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + init(); + } + + protected void init() + { + client = new TestConnector(); + client.setApplicationContext(container); + client.setBeanName("client"); + + // bufferPoolMockControl = MockControl.createControl(Pool.class); + // bufferPoolMock = (Pool) bufferPoolMockControl.getMock(); + } + + protected void start() + { + // bufferPoolMockControl.replay(); + } + + protected void verify() + { + // bufferPoolMockControl.verify(); + } + + // protected BufferImpl createBuffer(int capacity, int level, boolean flipped) + // { + // BufferImpl buffer = new BufferImpl(capacity); + // + // if (level > 0) + // { + // buffer.put(Byte.MIN_VALUE); // for sequence-error-detection + // + // for (int i = 1; i < level; i++) + // { + // buffer.put((byte) (i % 256)); + // } + // } + // + // if (flipped) + // { + // buffer.flip(); + // } + // + // return buffer; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int[] capacities, int[] levels, boolean flipped) + // { + // NodeCachingLinkedList queue = new NodeCachingLinkedList(); + // + // for (int i = 0; i < levels.length; i++) + // { + // queue.add(createBuffer(capacities[i], levels[i], flipped)); + // } + // + // return queue; + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int[] levels, boolean flipped) + // { + // int[] capacities = new int[levels.length]; + // Arrays.fill(capacities, capacity); + // return createBufferQueue(capacities, levels, flipped); + // } + // + // protected NodeCachingLinkedList createBufferQueue(int capacity, int level, boolean flipped) + // { + // return createBufferQueue(new int[] { capacity}, new int[] { level}, flipped); + // } + + public final void testGet() + { + } + + + // public final void testSetGetChannelId() + // { + // pool.setChannelId((short) 4711); + // short result = pool.getChannelId(); + // assertEquals("getChannelId returns the value of setChannelId", 4711, result); + // + // pool.setChannelId((short) 0); + // result = pool.getChannelId(); + // assertEquals("getChannelId returns 0", 0, result); + // } + // + // public final void testSetGetBufferPool() + // { + // pool.setBufferPool(bufferPoolMock); + // Pool result = pool.getBufferPool(); + // assertEquals("getBufferPool returns the value of setBufferPool", bufferPoolMock, result); + // + // pool.setBufferPool(null); + // result = pool.getBufferPool(); + // assertNull("getBufferPool returns null", result); + // } + // + // public final void testSetGetConnector() + // { + // pool.setConnector(connectorMock); + // Connector result = pool.getConnector(); + // assertEquals("getConnector returns the value of setConnector", connectorMock, result); + // + // pool.setConnector(null); + // result = pool.getConnector(); + // assertNull("getConnector returns null", result); + // } + // + // public final void testSetGetDispatcher() + // { + // pool.setDispatcher(dispatcherMock); + // Executor result = pool.getDispatcher(); + // assertEquals("getDispatcher returns the value of setDispatcher", dispatcherMock, result); + // + // pool.setDispatcher(null); + // result = pool.getDispatcher(); + // assertNull("getDispatcher returns null", result); + // } + // + // public final void testSetGetMultiplexer() + // { + // pool.setMultiplexer(multiplexerMock); + // Multiplexer result = pool.getMultiplexer(); + // assertEquals("getBufferPool returns the value of setMultiplexer", multiplexerMock, result); + // + // pool.setMultiplexer(null); + // result = pool.getMultiplexer(); + // assertNull("getMultiplexer returns null", result); + // } + // + // public final void testSetGetProtocol() + // { + // pool.setProtocol(protocolMock); + // Protocol result = pool.getProtocol(); + // assertEquals("getProtocol returns the value of setProtocol", protocolMock, result); + // + // pool.setProtocol(null); + // result = pool.getProtocol(); + // assertNull("getProtocol returns null", result); + // } + // + // public final void testSetGetInternalReturnValue() + // { + // Object returnValue = new Object(); + // + // pool.internalSetReturnValue(returnValue); + // Object result = pool.testGetReturnValue(); + // assertEquals("testGetReturnValue returns the value of internalSetReturnValue", returnValue, + // result); + // + // pool.internalSetReturnValue(null); + // result = pool.testGetReturnValue(); + // assertNull("testGetReturnValue returns null", result); + // } + // + // public final void testSetGetProtocolData() + // { + // Object protocolData = new Object(); + // + // pool.setProtocolData(protocolData); + // Object result = pool.getProtocolData(); + // assertEquals("getProtocolData returns the value of setProtocolData", protocolData, result); + // + // pool.setProtocolData(null); + // result = pool.getProtocolData(); + // assertNull("getProtocolData returns null", result); + // } + // + // public final void testServiceGuards() + // { + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).handleTransmission(); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).notification(null); + // } + // }; + // + // new ServiceInvoker(pool) + // { + // protected void invokeService(DefaultBean bean) throws Exception + // { + // ((DefaultChannel) bean).request(null); + // } + // }; + // } + // + // public final void testValidate() + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // + // try + // { + // pool.setBufferPool(null); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "bufferPool"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(null); + // pool.setMultiplexer(multiplexerMock); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "dispatcher"); + // } + // + // try + // { + // pool.setBufferPool(bufferPoolMock); + // pool.setDispatcher(dispatcherMock); + // pool.setMultiplexer(null); + // pool.testValidate(); + // fail("expected ValidationException"); + // } + // catch (ValidationException expected) + // { + // TestUtils.assertContains(expected, "multiplexer"); + // } + // } + // + // /** + // * PRECONDITION: dataSize == 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer1() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(0); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: dataSize < 0 + // * + // * EXPECTATION: doesn't block; + // * throws IllegalArgumentException + // */ + // public final void testEnsureReceiverBuffer2() throws Throwable + // { + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(-1); + // } + // }; + // fail("IllegalArgumentException expected"); + // } + // catch (IllegalArgumentException expected) + // { + // TestUtils.assertContains(expected, "dataSize"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < level < dataSize + // * + // * EXPECTATION: doesn't block; + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer3() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 3, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize < level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer4() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 < dataSize == level + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer not returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer5() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 12, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(12); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue empty + // * + // * EXPECTATION: receiverBuffer returned to bufferPool; + // * blocks + // */ + // public final void testEnsureReceiverBuffer6() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = new NodeCachingLinkedList(); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, true) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too small buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // * throws ImplementationError + // */ + // public final void testEnsureReceiverBuffer7() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 5, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // try + // { + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "receiverBuffer level too low"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has exact buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer8() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 7, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: receiverBuffer exists; + // * 0 == level < dataSize; + // * receiverQueue has too big buffer + // * + // * EXPECTATION: doesn't block; + // * receiverBuffer returned to bufferPool + // */ + // public final void testEnsureReceiverBuffer9() throws Throwable + // { + // BufferImpl receiverBuffer = createBuffer(20, 0, true); + // pool.testSetReceiverBuffer(receiverBuffer); + // + // NodeCachingLinkedList receiverQueue = createBufferQueue(20, 12, true); + // pool.testSetReceiverQueue(receiverQueue); + // + // bufferPoolMock.put(new Integer(20), receiverBuffer); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // new BlockingDetector(pool, receiverQueue, false) + // { + // protected void blockableOperation(Object target) throws Exception + // { + // ((DefaultChannel) target).testEnsureReceiverBuffer(7); + // } + // }; + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer doesn't exists + // * + // * EXPECTATION: throws ImplementationError + // */ + // public final void testFlush1() + // { + // start(); + // try + // { + // pool.flush(); + // fail("ImplementationError expected"); + // } + // catch (ImplementationError expected) + // { + // TestUtils.assertContains(expected, "transmitterBuffer must exist"); + // } + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level == 0 + // * + // * EXPECTATION: immediately returns + // */ + // public final void testFlush2() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 0, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // start(); + // pool.flush(); + // verify(); + // } + // + // /** + // * PRECONDITION: transmitterBuffer exists; + // * level > 0 + // * + // * EXPECTATION: transmitterBuffer is flipped; + // * appended to transmitterQueue; + // * channel is scheduled for transmission; + // * a new transmitterBuffer is fetched from the bufferPool; + // * the new transmitterBuffer is empty + // */ + // public final void testFlush3() + // { + // BufferImpl transmitterBuffer = createBuffer(20, 7, false); + // pool.testSetTransmitterBuffer(transmitterBuffer); + // + // NodeCachingLinkedList transmitterQueue = new NodeCachingLinkedList(); + // pool.testSetTransmitterQueue(transmitterQueue); + // + // multiplexerMock.schedule(pool); + // pool.setMultiplexer(multiplexerMock); + // + // bufferPoolMockControl.expectAndReturn(bufferPoolMock.get(), createBuffer(10, 10, false)); + // pool.setBufferPool(bufferPoolMock); + // + // start(); + // pool.flush(); + // verify(); + // + // assertTrue("transmitterBuffer is flipped", transmitterBuffer.position() == 0); + // assertTrue("transmitterBuffer is in transmitterQueue", + // transmitterQueue.get(0) == transmitterBuffer); + // assertNotSame("a new transmitterBuffer is expected", transmitterBuffer, pool + // .testGetTransmitterBuffer()); + // assertTrue("the new transmitterBuffer must be empty", pool.testGetTransmitterBuffer() + // .position() == 0); + // + // } + protected class TestAcceptor extends SocketAcceptorImpl + { + protected Connector createSlave(SocketChannel socketChannel) + { + slave = new PassiveTestConnector(); + slave.setApplicationContext(SocketConnectorTest.container); + slave.setBeanName("slave"); + slave.setSocketChannel(socketChannel); + return slave; + } + + + protected class PassiveTestConnector extends PassiveSocketConnectorImpl + { + protected void prepareBasicChannel() + { + } + } + } + + + protected class TestConnector extends ActiveSocketConnectorImpl + { + protected void prepareBasicChannel() + { + } + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java new file mode 100644 index 0000000000..81d5447abf --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/Net4jTestProtocol.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.protocol; + + +import org.eclipse.net4j.core.Indication; +import org.eclipse.net4j.core.Protocol; +import org.eclipse.net4j.core.impl.AbstractProtocol; +import org.eclipse.net4j.util.ImplementationError; + + +public class Net4jTestProtocol extends AbstractProtocol implements Protocol +{ + public static final String PROTOCOL_NAME = "test"; + + public static final short TEST_SIGNAL = 4711; + + public Indication createIndication(short signalId) + { + switch (signalId) + { + case TEST_SIGNAL: + return new TestIndication(); + + default: + throw new ImplementationError("Invalid signalId: " + signalId); + } + } + + public String getName() + { + return PROTOCOL_NAME; + } + + public int getType() + { + return SYMMETRIC; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java new file mode 100644 index 0000000000..43c83cacd3 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestIndication.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.protocol; + + +import org.eclipse.net4j.core.impl.AbstractIndicationWithResponse; + + +public class TestIndication extends AbstractIndicationWithResponse +{ + protected Object[] values; + + public TestIndication() + { + } + + public short getSignalId() + { + return Net4jTestProtocol.TEST_SIGNAL; + } + + public void indicate() + { + values = ValueHelper.receiveValues(getChannel()); + } + + public void respond() + { + ValueHelper.transmitValues(getChannel(), values); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java new file mode 100644 index 0000000000..5a7d1ed137 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/TestRequest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.protocol; + + +import org.eclipse.net4j.core.impl.AbstractRequestWithConfirmation; + + +public class TestRequest extends AbstractRequestWithConfirmation +{ + protected Object[] values; + + public TestRequest(Object[] values) + { + this.values = values; + } + + public short getSignalId() + { + return Net4jTestProtocol.TEST_SIGNAL; + } + + public void request() + { + ValueHelper.transmitValues(getChannel(), values); + } + + public Object confirm() + { + return ValueHelper.receiveValues(getChannel()); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java new file mode 100644 index 0000000000..5f84e4412c --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/protocol/ValueHelper.java @@ -0,0 +1,196 @@ +package org.eclipse.net4j.test.protocol; + + +import org.eclipse.net4j.core.Channel; +import org.eclipse.net4j.util.ImplementationError; + +import java.util.ArrayList; +import java.util.List; + + +public class ValueHelper +{ + public static final byte END_OF_TRANSMISSION = -1; + + public static final byte BOOLEAN = 1; + + public static final byte CHARACTER = 2; + + public static final byte BYTE = 3; + + public static final byte SHORT = 4; + + public static final byte INTEGER = 5; + + public static final byte LONG = 6; + + public static final byte FLOAT = 7; + + public static final byte DOUBLE = 8; + + public static final byte STRING = 9; + + public static void transmitValues(Channel channel, Object[] values) + { + for (int i = 0; i < values.length; i++) + { + Object value = values[i]; + + if (value instanceof Boolean) + { + channel.transmitByte(BOOLEAN); + channel.transmitBoolean(((Boolean) value).booleanValue()); + } + else if (value instanceof Character) + { + channel.transmitByte(CHARACTER); + channel.transmitChar(((Character) value).charValue()); + } + else if (value instanceof Byte) + { + channel.transmitByte(BYTE); + channel.transmitByte(((Byte) value).byteValue()); + } + else if (value instanceof Short) + { + channel.transmitByte(SHORT); + channel.transmitShort(((Short) value).shortValue()); + } + else if (value instanceof Integer) + { + channel.transmitByte(INTEGER); + channel.transmitInt(((Integer) value).intValue()); + } + else if (value instanceof Long) + { + channel.transmitByte(LONG); + channel.transmitLong(((Long) value).longValue()); + } + else if (value instanceof Float) + { + channel.transmitByte(FLOAT); + channel.transmitFloat(((Float) value).floatValue()); + } + else if (value instanceof Double) + { + channel.transmitByte(DOUBLE); + channel.transmitDouble(((Double) value).doubleValue()); + } + else if (value instanceof String) + { + channel.transmitByte(STRING); + channel.transmitString((String) value); + } + else + { + throw new ImplementationError("invalid class: " + value.getClass().getName()); + } + } + + channel.transmitByte(END_OF_TRANSMISSION); + } + + public static Object[] receiveValues(Channel channel) + { + List list = new ArrayList(); + + for (;;) + { + byte type = channel.receiveByte(); + + switch (type) + { + case END_OF_TRANSMISSION: + return list.toArray(); + + case BOOLEAN: + list.add(new Boolean(channel.receiveBoolean())); + break; + + case CHARACTER: + list.add(new Character(channel.receiveChar())); + break; + + case BYTE: + list.add(new Byte(channel.receiveByte())); + break; + + case SHORT: + list.add(new Short(channel.receiveShort())); + break; + + case INTEGER: + list.add(new Integer(channel.receiveInt())); + break; + + case LONG: + list.add(new Long(channel.receiveLong())); + break; + + case FLOAT: + list.add(new Float(channel.receiveFloat())); + break; + + case DOUBLE: + list.add(new Double(channel.receiveDouble())); + break; + + case STRING: + list.add(channel.receiveString()); + break; + } + } + } + + public static int sizeOf(Object[] values) + { + int sum = 4; // END_OF_TRANSMISSION + for (int i = 0; i < values.length; i++) + { + Object value = values[i]; + + if (value instanceof Boolean) + { + sum += 1 + 1; + } + else if (value instanceof Character) + { + sum += 1 + 2; + } + else if (value instanceof Byte) + { + sum += 1 + 1; + } + else if (value instanceof Short) + { + sum += 1 + 2; + } + else if (value instanceof Integer) + { + sum += 1 + 4; + } + else if (value instanceof Long) + { + sum += 1 + 8; + } + else if (value instanceof Float) + { + sum += 1 + 4; + } + else if (value instanceof Double) + { + sum += 1 + 8; + } + else if (value instanceof String) + { + sum += 1 + 4 + 2 * ((String) value).length(); + } + else + { + throw new ImplementationError("invalid class: " + value.getClass().getName()); + } + } + + return sum; + } +} diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java new file mode 100644 index 0000000000..6aa8cef915 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/BlockingDetector.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.util; + + +import junit.framework.Assert; + + +public abstract class BlockingDetector +{ + public static final long DEFAULT_WAIT_MILLIS = 100; + + protected Thread thread; + + protected BlockableOperationException exception; + + public BlockingDetector(Object target, Object monitor, boolean blockingExpected) throws Throwable + { + this(target, monitor, blockingExpected, DEFAULT_WAIT_MILLIS); + } + + public BlockingDetector(Object target, Object monitor, boolean blockingExpected, long waitMillis) + throws Throwable + { + startOperation(target); + + try + { + Thread.sleep(waitMillis); + } + catch (InterruptedException ex) + { + throw new BlockableOperationException(ex); + } + + if (exception != null) + { + throw exception.getCause(); + } + + boolean alive = thread.isAlive(); + + if (alive) synchronized (monitor) + { + monitor.notifyAll(); + } + + if (blockingExpected) + { + Assert.assertTrue("blocking expected", alive); + } + else + { + Assert.assertTrue("no blocking expected", !alive); + } + } + + public void startOperation(final Object target) + { + thread = new Thread() + { + + public void run() + { + try + { + blockableOperation(target); + } + catch (Exception ex) + { + exception = new BlockableOperationException(ex); + throw exception; + } + } + }; + + thread.start(); + } + + protected abstract void blockableOperation(Object target) throws Exception; + + + private static class BlockableOperationException extends RuntimeException + { + private static final long serialVersionUID = 1L; + + public BlockableOperationException(Exception ex) + { + super(ex); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java new file mode 100644 index 0000000000..caa722cce2 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/ServiceInvoker.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.util; + + +import org.eclipse.net4j.spring.InactiveException; +import org.eclipse.net4j.spring.Service; +import org.eclipse.net4j.spring.impl.ServiceImpl; + +import junit.framework.Assert; + + +public abstract class ServiceInvoker +{ + private static final byte[] STATES = { ServiceImpl.ServiceStateMachine.STATE_STOPPING, + ServiceImpl.ServiceStateMachine.STATE_STOPPING, + ServiceImpl.ServiceStateMachine.STATE_INCONSISTENT, + ServiceImpl.ServiceStateMachine.STATE_ACTIVE, ServiceImpl.ServiceStateMachine.STATE_DISPOSED}; + + private static final int OK_INDEX = 2; + + public ServiceInvoker(Service bean) + { + for (int i = 0; i < STATES.length; i++) + { + byte state = STATES[i]; + bean.testSetState(state); + Throwable throwable = null; + + try + { + invokeService(bean); + } + catch (Throwable t) + { + throwable = t; + } + + if (i == OK_INDEX) + { + Assert.assertFalse("No InactiveException is thrown", throwable != null + && throwable instanceof InactiveException); + } + else + { + Assert.assertNotNull("An exception is thrown", throwable); + Assert.assertTrue("An InactiveException is thrown", throwable instanceof InactiveException); + } + } + } + + protected abstract void invokeService(Service bean) throws Exception; +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java new file mode 100644 index 0000000000..b6b0ab7998 --- /dev/null +++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/util/TestUtils.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.test.util; + + +import junit.framework.Assert; + + +public class TestUtils +{ + public static void assertContains(String message, String text, String word) + { + if (text == null) + { + Assert.assertNull(message, word); + } + + Assert.assertTrue(message, text.matches(".*" + word + ".*")); + } + + public static void assertContains(String text, String word) + { + String message = "'" + text + "' should contain '" + word + "'"; + assertContains(message, text, word); + } + + public static void assertContains(String message, Throwable t, String word) + { + String text = t.getMessage(); + assertContains(message, text, word); + } + + public static void assertContains(Throwable t, String word) + { + String text = t.getMessage(); + assertContains(text, word); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/.classpath b/plugins/org.eclipse.net4j.util/.classpath new file mode 100644 index 0000000000..bdcf047b18 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/.classpath @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src/"/> + <classpathentry kind="src" path="config"/> + <classpathentry exported="true" kind="lib" path="lib/commons-logging.jar"/> + <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.9.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.net4j.util/.cvsignore b/plugins/org.eclipse.net4j.util/.cvsignore new file mode 100644 index 0000000000..eb65b4b8f2 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/.cvsignore @@ -0,0 +1,5 @@ +tmp +bin +dist +build +runtime diff --git a/plugins/org.eclipse.net4j.util/.project b/plugins/org.eclipse.net4j.util/.project new file mode 100644 index 0000000000..b52e9e4cf3 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/.project @@ -0,0 +1,28 @@ +<?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 new file mode 100644 index 0000000000..bebcb41b95 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,256 @@ +#Mon Mar 13 12:05:55 CET 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.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=2 +org.eclipse.jdt.core.formatter.blank_lines_after_package=2 +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=2 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=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=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=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=false +org.eclipse.jdt.core.formatter.comment.format_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_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=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +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 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 new file mode 100644 index 0000000000..6b2f797e54 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,19 @@ +#Mon Mar 13 08:16:19 CET 2006 +comment_clear_blank_lines=false +comment_format_comments=false +comment_format_header=false +comment_format_html=true +comment_format_source_code=true +comment_indent_parameter_description=true +comment_indent_root_tags=true +comment_line_length=100 +comment_new_line_for_parameter=true +comment_separate_root_tags=true +eclipse.preferences.version=1 +formatter_settings_version=10 +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.net4j;org.eclipse.emf;org.eclipse;org.apache;org;com;java.lang;java.util;java.io;java.nio;java.net;java;javax; +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2fa6dc2816 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF @@ -0,0 +1,41 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.net4j.util +Bundle-Version: 1.0.0 +Bundle-ClassPath: net4j.util.jar, + lib/commons-logging.jar, + lib/log4j-1.2.9.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Export-Package: META-INF, + org.apache.commons.logging, + org.apache.commons.logging.impl, + org.apache.log4j, + org.apache.log4j.chainsaw, + org.apache.log4j.config, + org.apache.log4j.helpers, + org.apache.log4j.jdbc, + org.apache.log4j.jmx, + org.apache.log4j.lf5, + org.apache.log4j.lf5.config, + org.apache.log4j.lf5.util, + org.apache.log4j.lf5.viewer, + org.apache.log4j.lf5.viewer.categoryexplorer, + org.apache.log4j.lf5.viewer.configure, + org.apache.log4j.lf5.viewer.images, + org.apache.log4j.net, + org.apache.log4j.nt, + org.apache.log4j.or, + org.apache.log4j.or.sax, + org.apache.log4j.spi, + org.apache.log4j.varia, + org.apache.log4j.xml, + org.eclipse.net4j.util, + org.eclipse.net4j.util.eclipse, + org.eclipse.net4j.util.fsm, + org.eclipse.net4j.util.thread +Require-Bundle: org.eclipse.core.runtime;visibility:=reexport, + org.eclipse.core.resources;visibility:=reexport +Eclipse-LazyStart: true +Bundle-Activator: org.eclipse.net4j.util.Net4jUtilPlugin diff --git a/plugins/org.eclipse.net4j.util/build.properties b/plugins/org.eclipse.net4j.util/build.properties new file mode 100644 index 0000000000..d2f1a67244 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/build.properties @@ -0,0 +1,12 @@ +src.includes = src/ +bin.includes = plugin.xml,\ + META-INF/,\ + config/,\ + plugin.properties,\ + net4j.util.jar,\ + lib/,\ + epl-v10.html +jars.compile.order = net4j.util.jar +source.net4j.util.jar = src/,\ + config/ +output.net4j.util.jar = bin/ diff --git a/plugins/org.eclipse.net4j.util/config/log4j.dtd b/plugins/org.eclipse.net4j.util/config/log4j.dtd new file mode 100644 index 0000000000..d92a6e7bc6 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/config/log4j.dtd @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- Authors: Chris Taylor, Ceki Gulcu. --> + +<!-- Version: 1.2 --> + +<!-- A configuration element consists of optional renderer +elements,appender elements, categories and an optional root +element. --> + +<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?, + categoryFactory?)> + +<!-- The "threshold" attribute takes a level value such that all --> +<!-- logging statements with a level equal or below this value are --> +<!-- disabled. --> + +<!-- Setting the "debug" enable the printing of internal log4j logging --> +<!-- statements. --> + +<!-- By default, debug attribute is "null", meaning that we not do touch --> +<!-- internal log4j logging settings. The "null" value for the threshold --> +<!-- attribute can be misleading. The threshold field of a repository --> +<!-- cannot be set to null. The "null" value for the threshold attribute --> +<!-- simply means don't touch the threshold field, the threshold field --> +<!-- keeps its old value. --> + +<!ATTLIST log4j:configuration + xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/" + threshold (all|debug|info|warn|error|fatal|off|null) "null" + debug (true|false|null) "null" +> + +<!-- renderer elements allow the user to customize the conversion of --> +<!-- message objects to String. --> + +<!ELEMENT renderer EMPTY> +<!ATTLIST renderer + renderedClass CDATA #REQUIRED + renderingClass CDATA #REQUIRED +> + +<!-- Appenders must have a name and a class. --> +<!-- Appenders may contain an error handler, a layout, optional parameters --> +<!-- and filters. They may also reference (or include) other appenders. --> +<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)> +<!ATTLIST appender + name ID #REQUIRED + class CDATA #REQUIRED +> + +<!ELEMENT layout (param*)> +<!ATTLIST layout + class CDATA #REQUIRED +> + +<!ELEMENT filter (param*)> +<!ATTLIST filter + class CDATA #REQUIRED +> + +<!-- ErrorHandlers can be of any class. They can admit any number of --> +<!-- parameters. --> + +<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)> +<!ATTLIST errorHandler + class CDATA #REQUIRED +> + +<!ELEMENT root-ref EMPTY> + +<!ELEMENT logger-ref EMPTY> +<!ATTLIST logger-ref + ref IDREF #REQUIRED +> + +<!ELEMENT param EMPTY> +<!ATTLIST param + name CDATA #REQUIRED + value CDATA #REQUIRED +> + + +<!-- The priority class is org.apache.log4j.Level by default --> +<!ELEMENT priority (param*)> +<!ATTLIST priority + class CDATA #IMPLIED + value CDATA #REQUIRED +> + +<!-- The level class is org.apache.log4j.Level by default --> +<!ELEMENT level (param*)> +<!ATTLIST level + class CDATA #IMPLIED + value CDATA #REQUIRED +> + + +<!-- If no level element is specified, then the configurator MUST not --> +<!-- touch the level of the named category. --> +<!ELEMENT category (param*,(priority|level)?,appender-ref*)> +<!ATTLIST category + class CDATA #IMPLIED + name CDATA #REQUIRED + additivity (true|false) "true" +> + +<!-- If no level element is specified, then the configurator MUST not --> +<!-- touch the level of the named logger. --> +<!ELEMENT logger (level?,appender-ref*)> +<!ATTLIST logger + name ID #REQUIRED + additivity (true|false) "true" +> + + +<!ELEMENT categoryFactory (param*)> +<!ATTLIST categoryFactory + class CDATA #REQUIRED> + +<!ELEMENT appender-ref EMPTY> +<!ATTLIST appender-ref + ref IDREF #REQUIRED +> + +<!-- If no priority element is specified, then the configurator MUST not --> +<!-- touch the priority of root. --> +<!-- The root category always exists and cannot be subclassed. --> +<!ELEMENT root (param*, (priority|level)?, appender-ref*)> + + +<!-- ==================================================================== --> +<!-- A logging event --> +<!-- ==================================================================== --> +<!ELEMENT log4j:eventSet (log4j:event*)> +<!ATTLIST log4j:eventSet + xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/" + version (1.1|1.2) "1.2" + includesLocationInfo (true|false) "true" +> + + + +<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?, + log4j:locationInfo?) > + +<!-- The timestamp format is application dependent. --> +<!ATTLIST log4j:event + logger CDATA #REQUIRED + level CDATA #REQUIRED + thread CDATA #REQUIRED + timestamp CDATA #REQUIRED +> + +<!ELEMENT log4j:message (#PCDATA)> +<!ELEMENT log4j:NDC (#PCDATA)> + +<!ELEMENT log4j:throwable (#PCDATA)> + +<!ELEMENT log4j:locationInfo EMPTY> +<!ATTLIST log4j:locationInfo + class CDATA #REQUIRED + method CDATA #REQUIRED + file CDATA #REQUIRED + line CDATA #REQUIRED +> diff --git a/plugins/org.eclipse.net4j.util/config/log4j.xml b/plugins/org.eclipse.net4j.util/config/log4j.xml new file mode 100644 index 0000000000..8298e6844b --- /dev/null +++ b/plugins/org.eclipse.net4j.util/config/log4j.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "../../org.eclipse.net4j.util/config/log4j.dtd"> +<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <appender name="LOGFACTOR" class="org.apache.log4j.lf5.LF5Appender"> + <param name="MaxNumberOfRecords" value="1000"/> + </appender> + + <appender name="GANYMEDE" class="org.apache.log4j.net.SocketAppender"> + <param name="RemoteHost" value="localhost"/> + <param name="Port" value="4445"/> + <param name="LocationInfo" value="true"/> + </appender> + + <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="[%p] %c: %m%n"/> + </layout> + </appender> + + <appender name="FILE" class="org.apache.log4j.FileAppender"> + <param name="File" value="densityd.log"/> + <param name="Append" value="false"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="[%p] %c: %m%n"/> + </layout> + </appender> + + <category name="org.eclipse.net4j.spring.impl.ContainerImpl"> + <priority value="warn"/> + </category> + + <category name="org.eclipse.net4j.util.fsm.StateMachine"> + <priority value="warn"/> + </category> + + <category name="org.eclipse.net4j.core.impl.ChannelImpl$ClientStateMachine"> + <priority value="warn"/> + </category> + + <category name="org.eclipse.net4j.core.impl.ChannelImpl$ServerStateMachine"> + <priority value="warn"/> + </category> + + <category name="org.springframework"> + <priority value="warn"/> + </category> + + <category name="org.springframework.jdbc"> + <priority value="error"/> + </category> + + <category name="density.bufferPool"> + <priority value="warn"/> + </category> + + <category name="density.connectionManager"> + <priority value="debug"/> + </category> + + <category name="density.executorPool"> + <priority value="warn"/> + </category> + + <category name="density.multiplexer"> + <priority value="warn"/> + </category> + + <root> + <priority value="debug"/> + <!-- + <appender-ref ref="LOGFACTOR" /> + <appender-ref ref="FILE"/> + --> + <appender-ref ref="CONSOLE"/> + </root> + +</log4j:configuration> diff --git a/plugins/org.eclipse.net4j.util/epl-v10.html b/plugins/org.eclipse.net4j.util/epl-v10.html new file mode 100644 index 0000000000..d7b88e9416 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/epl-v10.html @@ -0,0 +1,319 @@ +<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 new file mode 100644 index 0000000000..8fb336abda --- /dev/null +++ b/plugins/org.eclipse.net4j.util/plugin.properties @@ -0,0 +1,2 @@ +pluginName = Net4j Utilities +providerName = Eclipse.org diff --git a/plugins/org.eclipse.net4j.util/plugin.xml b/plugins/org.eclipse.net4j.util/plugin.xml new file mode 100644 index 0000000000..635a28e0c6 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/plugin.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<plugin> + + +</plugin> diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java new file mode 100644 index 0000000000..d251e296e6 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Argument.java @@ -0,0 +1,75 @@ +package org.eclipse.net4j.util; + + +/** + * <code>Assert</code> is useful for for embedding runtime sanity checks + * in code. + * The predicate methods all test a condition and throw some + * type of unchecked exception if the condition does not hold. + * <p> + * Assertion failure exceptions, like most runtime exceptions, are + * thrown when something is misbehaving. Assertion failures are invariably + * unspecified behavior; consequently, clients should never rely on + * these being thrown (and certainly should not being catching them + * specifically). + * </p> + */ +public final class Argument +{ + /* This class is not intended to be instantiated. */ + private Argument() + { + // not allowed + } + + /** Asserts that the given object is not <code>null</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * + * @param object the value to test + * @exception IllegalArgumentException if the object is <code>null</code> + */ + public static void isNotNull(Object object) + { + isNotNull(object, ""); //$NON-NLS-1$ + } + + /** Asserts that the given object is not <code>null</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + * + * @param object the value to test + * @param message the message to include in the exception + * @exception IllegalArgumentException if the object is <code>null</code> + */ + public static void isNotNull(Object object, String message) + { + if (object == null) throw new IllegalArgumentException("null argument:" + message); //$NON-NLS-1$ + } + + /** Asserts that the given boolean is <code>true</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * + * @param expression the outcode of the check + * @return <code>true</code> if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression) + { + return isTrue(expression, ""); //$NON-NLS-1$ + } + + /** Asserts that the given boolean is <code>true</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + * + * @param expression the outcode of the check + * @param message the message to include in the exception + * @return <code>true</code> if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression, String message) + { + if (!expression) throw new IllegalArgumentException("assertion failed: " + message); //$NON-NLS-1$ + return expression; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java new file mode 100644 index 0000000000..b389e83463 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Assert.java @@ -0,0 +1,96 @@ +package org.eclipse.net4j.util; + + +/** + * <code>Assert</code> is useful for for embedding runtime sanity checks + * in code. + * The predicate methods all test a condition and throw some + * type of unchecked exception if the condition does not hold. + * <p> + * Assertion failure exceptions, like most runtime exceptions, are + * thrown when something is misbehaving. Assertion failures are invariably + * unspecified behavior; consequently, clients should never rely on + * these being thrown (and certainly should not being catching them + * specifically). + * </p> + */ +public final class Assert +{ + /* This class is not intended to be instantiated. */ + private Assert() + { + // not allowed + } + + /** Asserts that the given object is not <code>null</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * + * @param object the value to test + * @exception IllegalArgumentException if the object is <code>null</code> + */ + public static void isNotNull(Object object) + { + isNotNull(object, ""); //$NON-NLS-1$ + } + + /** Asserts that the given object is not <code>null</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + * + * @param object the value to test + * @param message the message to include in the exception + * @exception IllegalArgumentException if the object is <code>null</code> + */ + public static void isNotNull(Object object, String message) + { + if (object == null) + { + String txt = "null argument:" + message; //$NON-NLS-1$ + System.out.println(txt); + throw new AssertionFailedError(txt); + } + } + + /** Asserts that the given boolean is <code>true</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * + * @param expression the outcode of the check + * @return <code>true</code> if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression) + { + return isTrue(expression, ""); //$NON-NLS-1$ + } + + /** Asserts that the given boolean is <code>true</code>. If this + * is not the case, some kind of unchecked exception is thrown. + * The given message is included in that exception, to aid debugging. + * + * @param expression the outcode of the check + * @param message the message to include in the exception + * @return <code>true</code> if the check passes (does not return + * if the check fails) + */ + public static boolean isTrue(boolean expression, String message) + { + if (!expression) + { + String txt = "assertion failed: " + message; //$NON-NLS-1$ + System.out.println(txt); + throw new AssertionFailedError(txt); + } + + return expression; + } + + public static boolean fail() + { + return fail(""); //$NON-NLS-1$ + } + + public static boolean fail(String message) + { + return isTrue(false, message); + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java new file mode 100644 index 0000000000..e6ddc5af66 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/AssertionFailedError.java @@ -0,0 +1,23 @@ +package org.eclipse.net4j.util; + + +/** + * <code>AssertionFailedException</code> is a runtime exception thrown + * by some of the methods in <code>Assert</code>. + * <p> + * This class is not declared public to prevent some misuses; programs that catch + * or otherwise depend on assertion failures are susceptible to unexpected + * breakage when assertions in the code are added or removed. + * </p> + */ +class AssertionFailedError extends ImplementationError +{ + private static final long serialVersionUID = -1363257600902142582L; + + /** Constructs a new exception with the given message. + */ + public AssertionFailedError(String detail) + { + super(detail); + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java new file mode 100644 index 0000000000..7d05fb183f --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class BeanException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = 3979274633562501681L; + + /** + * + */ + public BeanException() + { + super(); + } + + /** + * @param arg0 + */ + public BeanException(String arg0) + { + super(arg0); + } + + /** + * @param arg0 + */ + public BeanException(Throwable arg0) + { + super(arg0); + } + + /** + * @param arg0 + * @param arg1 + */ + public BeanException(String arg0, Throwable arg1) + { + super(arg0, arg1); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java new file mode 100644 index 0000000000..8a75e38e94 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BeanHelper.java @@ -0,0 +1,286 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.Method; + + +public class BeanHelper +{ + public static Class mostSpecificClass(Class[] classes) + { + int size = classes.length; + + for (int i = 0; i < size; i++) + { + Class iClass = classes[i]; + + for (int k = i + 1; k < size; k++) + { + Class kClass = classes[k]; + + if (iClass.isAssignableFrom(kClass)) + { + // iClass is super class of kClass + // iClass is less specific + classes[i] = classes[--size]; + break; + } + else if (kClass.isAssignableFrom(iClass)) + { + // kClass is super class of iClass + // kClass is less specific + classes[k] = classes[--size]; + break; + } + } + } + + if (size > 1) + { + throw new RuntimeException("Ambiguous ViewFacories"); + } + + if (size < 1) + { + throw new RuntimeException("No ViewFacories"); + } + + return classes[0]; + } + + public static void dispatchChild(Object object, String name, Object value) + { + Method adder = findAdder(object.getClass(), name); + if (adder == null) throw new BeanException("Child " + name + " not reognized"); + + try + { + adder.invoke(object, new Object[] { value}); + } + catch (Throwable t) + { + throw new BeanException("Child " + name + " not accessible", t); + } + } + + public static Object[] children(Object object, String name) + { + Method getter = findChildGetter(object.getClass(), name); + if (getter == null) throw new BeanException("Child " + name + " not reognized"); + + try + { + return (Object[]) getter.invoke(object, (Object[])null); + } + catch (Throwable t) + { + throw new BeanException("Child " + name + " not accessible", t); + } + } + + public static void dispatchAttributeValue(Object object, String name, String value) + { + Method setter = findSetter(object.getClass(), name); + if (setter == null) throw new BeanException("Attribute " + name + " not reognized"); + + try + { + Class type = setter.getParameterTypes()[0]; + + if (type == Boolean.class) + { + Boolean bool = value == null ? null : Boolean.valueOf(value); + setter.invoke(object, new Object[] { bool}); + } + else + { + // if (type == String) + setter.invoke(object, new Object[] { value}); + } + } + catch (Throwable t) + { + throw new BeanException("Attribute " + name + " not accessible", t); + } + } + + public static void dispatchAttributeValueBoolean(Object object, String name, Boolean value) + { + Method setter = findSetter(object.getClass(), name); + if (setter == null) throw new BeanException("Attribute " + name + " not reognized"); + if (setter.getParameterTypes()[0] != Boolean.class) + throw new BeanException("Attribute " + name + " is not Boolean"); + + try + { + setter.invoke(object, new Object[] { value}); + } + catch (Throwable t) + { + throw new BeanException("Attribute " + name + " not accessible", t); + } + } + + public static String attributeValue(Object object, String name) + { + Method getter = findGetter(object.getClass(), name); + if (getter == null) throw new BeanException("Attribute " + name + " not reognized"); + + try + { + Object returnValue = getter.invoke(object, (Object[])null); + if (returnValue == null) return null; + if (returnValue instanceof String) return (String) returnValue; + + //if (returnValue instanceof Boolean) + return ((Boolean) returnValue).toString(); + + } + catch (Throwable t) + { + throw new BeanException("Attribute " + name + " not accessible", t); + } + } + + public static Boolean attributeValueBoolean(Object object, String name) + { + Method getter = findGetter(object.getClass(), name); + if (getter == null) throw new BeanException("Attribute " + name + " not reognized"); + if (getter.getReturnType() != Boolean.class) + throw new BeanException("Attribute " + name + " is not Boolean"); + + try + { + return (Boolean) getter.invoke(object, (Object[])null); + } + catch (Throwable t) + { + throw new BeanException("Attribute " + name + " accessible", t); + } + } + + public static Method findGetter(Class clazz, String name) + { + String accessor = "is" + capitalize(name); + Method method = findMethod(clazz, accessor); + if (validGetter(method)) return method; + + accessor = "get" + capitalize(name); + method = findMethod(clazz, accessor); + if (validGetter(method)) return method; + + return null; + } + + public static Method findChildGetter(Class clazz, String name) + { + String accessor = "get" + capitalize(name) + "s"; + Method method = findMethod(clazz, accessor); + if (validChildGetter(method)) return method; + + return null; + } + + public static Method findSetter(Class clazz, String name) + { + String accessor = "set" + capitalize(name); + Method method = findMethod(clazz, accessor); + return validSetter(method) ? method : null; + } + + public static Method findAdder(Class clazz, String name) + { + String accessor = "add" + capitalize(name); + Method method = findMethod(clazz, accessor); + return validAdder(method) ? method : null; + } + + public static Method findMethod(Class clazz, String name) + { + Method[] methods = clazz.getMethods(); + for (int i = 0; i < methods.length; i++) + { + Method method = methods[i]; + if (name.equals(method.getName())) return method; + } + return null; + } + + private static boolean validGetter(Method method) + { + if (method == null) return false; + + Class[] paramTypes = method.getParameterTypes(); + if (paramTypes != null || paramTypes.length != 0) return false; + + Class returnType = method.getReturnType(); + if (returnType == null || !validAttributeType(returnType)) return false; + + return true; + } + + private static boolean validSetter(Method method) + { + if (method == null) return false; + + Class[] paramTypes = method.getParameterTypes(); + if (paramTypes == null || paramTypes.length != 1 || !validAttributeType(paramTypes[0])) + return false; + + Class returnType = method.getReturnType(); + if (returnType != null && returnType != void.class) return false; + + return true; + } + + private static boolean validAdder(Method method) + { + if (method == null) return false; + + Class[] paramTypes = method.getParameterTypes(); + if (paramTypes == null || paramTypes.length != 1) return false; + + Class returnType = method.getReturnType(); + if (returnType != null && returnType != void.class) return false; + + return true; + } + + private static boolean validChildGetter(Method method) + { + if (method == null) return false; + + Class[] paramTypes = method.getParameterTypes(); + if (paramTypes != null || paramTypes.length != 0) return false; + + Class returnType = method.getReturnType(); + if (returnType == null || !validChildType(returnType)) return false; + + return true; + } + + private static boolean validAttributeType(Class type) + { + return type == String.class || type == Boolean.class; + } + + private static boolean validChildType(Class type) + { + return type.isArray(); + } + + private static String capitalize(String name) + { + return StringHelper.firstToUpper(name); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java new file mode 100644 index 0000000000..df8975b676 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/BitHelper.java @@ -0,0 +1,26 @@ +package org.eclipse.net4j.util; + + +public class BitHelper +{ + public static final int LOWEST_BIT = 0x0000001; + + public static int getMask(int bits, int rightPad) + { + int mask = LOWEST_BIT; + + // Create bit mask + for (int i = 0; i < bits - 1; i++) + { + mask <<= 1; + mask |= LOWEST_BIT; + } + + return mask << rightPad; + } + + public static int getMask(int bits) + { + return getMask(bits, 0); + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java new file mode 100644 index 0000000000..3780898c81 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DateHelper.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + + +/** + * This is a timezone conversion utility class. + */ +public class DateHelper +{ + + private static final String[] MONTHS = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec"}; + + // as SimpleDateFormat is not thread-safe - we have to use ThreadLocal + private final static ThreadLocal AFTER_SIX = new ThreadLocal() + { + + protected Object initialValue() + { + return new SimpleDateFormat(" yyyy"); + } + }; + + private final static ThreadLocal BEFORE_SIX = new ThreadLocal() + { + + protected Object initialValue() + { + return new SimpleDateFormat("HH:mm"); + } + }; + + /** + * Get unix style date string. + */ + public static String getUnixDate(Date date) + { + long dateTime = date.getTime(); + if (dateTime < 0) + { + return "------------"; + } + + Calendar cal = new GregorianCalendar(); + cal.setTime(date); + String firstPart = MONTHS[cal.get(Calendar.MONTH)] + ' '; + + String dateStr = String.valueOf(cal.get(Calendar.DATE)); + if (dateStr.length() == 1) + { + dateStr = ' ' + dateStr; + } + firstPart += dateStr + ' '; + + long nowTime = System.currentTimeMillis(); + if (Math.abs(nowTime - dateTime) > 183L * 24L * 60L * 60L * 1000L) + { + DateFormat fmt = (DateFormat) AFTER_SIX.get(); + return firstPart + fmt.format(date); + } + else + { + DateFormat fmt = (DateFormat) BEFORE_SIX.get(); + return firstPart + fmt.format(date); + } + } + + /** + * Get the timezone specific string. + */ + public static String getString(Date dt, DateFormat df, TimeZone to) + { + df.setTimeZone(to); + return df.format(dt); + } + + /** + * Get the timezone specific calendar. + */ + public static Calendar getCalendar(Date dt, TimeZone to) + { + Calendar cal = Calendar.getInstance(to); + cal.setTime(dt); + return cal; + } + + /** + * Get date object. + */ + public static Date getDate(String str, DateFormat df, TimeZone from) + throws java.text.ParseException + { + df.setTimeZone(from); + return df.parse(str); + } + + /** + * Get date difference => d1 - d2. + */ + public static String getDifference(Date d1, Date d2) + { + Calendar calendar = new GregorianCalendar(); + calendar.setTime(d2); + int year2 = calendar.get(Calendar.YEAR); + int day2 = calendar.get(Calendar.DAY_OF_YEAR); + int hour2 = calendar.get(Calendar.HOUR_OF_DAY); + int min2 = calendar.get(Calendar.MINUTE); + + calendar.setTime(d1); + int year1 = calendar.get(Calendar.YEAR); + int day1 = calendar.get(Calendar.DAY_OF_YEAR); + int hour1 = calendar.get(Calendar.HOUR_OF_DAY); + int min1 = calendar.get(Calendar.MINUTE); + + int leftDays = (day1 - day2) + (year1 - year2) * 365; + int leftHours = hour1 - hour2; + int leftMins = min1 - min2; + + if (leftMins < 0) + { + leftMins += 60; + --leftHours; + } + if (leftHours < 0) + { + leftHours += 24; + --leftDays; + } + + String interval = ""; + if (leftDays > 0) + { + interval = leftDays + " Days"; + } + else if ((leftHours > 0) && (leftDays == 0)) + { + interval = leftHours + " Hours"; + } + else if ((leftMins > 0) && (leftHours == 0) && (leftDays == 0)) + { + interval = leftMins + " Minutes"; + } + else + { + interval = ""; + } + return interval; + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java new file mode 100644 index 0000000000..f3ac9429be --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/DigestHelper.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + + +public class DigestHelper +{ + + /** + * Encrypt byte array. + */ + public static byte[] encrypt(byte[] source, String algorithm) throws NoSuchAlgorithmException + { + MessageDigest md = MessageDigest.getInstance(algorithm); + md.reset(); + md.update(source); + return md.digest(); + } + + /** + * Encrypt string + */ + public static String encrypt(String source, String algorithm) throws NoSuchAlgorithmException + { + byte[] resByteArray = encrypt(source.getBytes(), algorithm); + return StringHelper.toHexString(resByteArray); + } + + /** + * Encrypt string using MD5 algorithm + */ + public static String encryptMD5(String source) + { + if (source == null) + { + source = ""; + } + + String result = ""; + + try + { + result = encrypt(source, "MD5"); + } + catch (NoSuchAlgorithmException ex) + { + ex.printStackTrace(); + } + + return result; + } + + /** + * Encrypt string using SHA algorithm + */ + public static String encryptSHA(String source) + { + if (source == null) + { + source = ""; + } + + String result = ""; + + try + { + result = encrypt(source, "SHA"); + } + catch (NoSuchAlgorithmException ex) + { + ex.printStackTrace(); + } + + return result; + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java new file mode 100644 index 0000000000..87e292ed17 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/IOHelper.java @@ -0,0 +1,683 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.util.Date; +import java.util.Random; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; + +import java.text.SimpleDateFormat; + + +public class IOHelper +{ + public static String currentDirectory() + { + String path = new File(".").getAbsolutePath(); + return path.substring(0, path.length() - 2); + } + + /** + * Random number generator to make unique file name + */ + private static final Random RANDOM_GEN = new Random(System.currentTimeMillis()); + + /** + * Get a <code>BufferedInputStream</code>. + */ + public static BufferedInputStream getBufferedInputStream(InputStream in) + { + BufferedInputStream bin = null; + if (in instanceof java.io.BufferedInputStream) + { + bin = (BufferedInputStream) in; + } + else + { + bin = new BufferedInputStream(in); + } + return bin; + } + + /** + * Get a <code>BufferedOutputStream</code>. + */ + public static BufferedOutputStream getBufferedOutputStream(OutputStream out) + { + BufferedOutputStream bout = null; + if (out instanceof java.io.BufferedOutputStream) + { + bout = (BufferedOutputStream) out; + } + else + { + bout = new BufferedOutputStream(out); + } + return bout; + } + + /** + * Get <code>BufferedReader</code>. + */ + public static BufferedReader getBufferedReader(Reader rd) + { + if (rd instanceof java.io.BufferedReader) + { + return (BufferedReader) rd; + } + else + { + return new BufferedReader(rd); + } + } + + /** + * Get <code>BufferedWriter</code>. + */ + public static BufferedWriter getBufferedWriter(Writer wr) + { + BufferedWriter bw = null; + if (wr instanceof java.io.BufferedWriter) + { + bw = (BufferedWriter) wr; + } + else + { + bw = new BufferedWriter(wr); + } + return bw; + } + + /** + * Get unique file object. + */ + public static File getUniqueFile(File oldFile) + { + File newFile = oldFile; + + while (true) + { + if (!newFile.exists()) + { + break; + } + + newFile = new File(oldFile.getAbsolutePath() + '.' + Math.abs(RANDOM_GEN.nextLong())); + } + return newFile; + } + + /** + * No exception <code>InputStream</code> close method. + */ + public static void close(InputStream is) + { + if (is != null) + { + try + { + is.close(); + } + catch (Exception ignore) + { + ignore.printStackTrace(); + } + } + } + + /** + * No exception <code>OutputStream</code> close method. + */ + public static void close(OutputStream os) + { + if (os != null) + { + try + { + os.close(); + } + catch (Exception ignore) + { + ignore.printStackTrace(); + } + } + } + + /** + * No exception <code>java.io.Reader</code> close method. + */ + public static void close(Reader rd) + { + if (rd != null) + { + try + { + rd.close(); + } + catch (Exception ignore) + { + ignore.printStackTrace(); + } + } + } + + /** + * No exception <code>java.io.Writer</code> close method. + */ + public static void close(Writer wr) + { + if (wr != null) + { + try + { + wr.close(); + } + catch (Exception ignore) + { + ignore.printStackTrace(); + } + } + } + + /** + * Get exception stack trace. + */ + public static String getStackTrace(Throwable ex) + { + String result = ""; + try + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + ex.printStackTrace(pw); + pw.close(); + sw.close(); + result = sw.toString(); + } + catch (Exception e) + { + e.printStackTrace(); + } + return result; + } + + /** + * Copy chars from a <code>Reader</code> to a <code>Writer</code>. + * + * @param bufferSize + * Size of internal buffer to use. + */ + public static void copy(Reader input, Writer output, int bufferSize) throws IOException + { + char buffer[] = new char[bufferSize]; + int n = 0; + + while ((n = input.read(buffer)) != -1) + { + output.write(buffer, 0, n); + } + } + + public static void copy(InputStream input, OutputStream output, byte buffer[]) throws IOException + { + int n = 0; + + while ((n = input.read(buffer)) != -1) + { + output.write(buffer, 0, n); + } + } + + public static void copy(InputStream input, OutputStream output, int bufferSize) + throws IOException + { + copy(input, output, new byte[bufferSize]); + } + + public static void copy(InputStream input, OutputStream output) throws IOException + { + copy(input, output, 4096); + } + + public static void copy(File input, File output) throws IOException + { + FileInputStream fis = null; + FileOutputStream fos = null; + + try + { + fis = new FileInputStream(input); + fos = new FileOutputStream(output); + + copy(fis, fos); + } + finally + { + close(fis); + close(fos); + } + } + + /** + * Read fully from reader + */ + public static String readFully(Reader reader) throws IOException + { + StringWriter writer = new StringWriter(); + copy(reader, writer, 1024); + return writer.toString(); + } + + /** + * Read fully from stream + */ + public static String readFully(InputStream input) throws IOException + { + InputStreamReader reader = new InputStreamReader(input); + return readFully(reader); + } + + /** + * Read fully from file + */ + public static String readFully(File file) throws IOException + { + FileInputStream stream = null; + + try + { + stream = new FileInputStream(file); + return readFully(stream); + } + finally + { + close(stream); + } + } + + public static void log(String message) + { + log(message, null); + } + + public static void log(String message, Throwable t) + { + PrintWriter writer = null; + + try + { + writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream("log.txt", true))); + writer.println(new SimpleDateFormat().format(new Date()) + " " + message); + + if (t != null) + { + t.printStackTrace(writer); + } + } + catch (Exception ignore) + { + } + finally + { + if (writer != null) + { + try + { + writer.close(); + } + catch (Exception ignore) + { + } + } + } + } + + public static File createTempFolder() throws IOException + { + return createTempFolder("tmp"); + } + + public static File createTempFolder(String prefix) throws IOException + { + return createTempFolder(prefix, ""); + } + + public static File createTempFolder(String prefix, String suffix) throws IOException + { + return createTempFolder(prefix, suffix, null); + } + + public static File createTempFolder(String prefix, String suffix, File directory) + throws IOException + { + File tmp = File.createTempFile(prefix, suffix, directory); + String tmpPath = tmp.getAbsolutePath(); + tmp.delete(); + tmp = new File(tmpPath); + tmp.mkdirs(); + return tmp; + } + + public static void zip(File source, File target) + { + zip(source, target, false); + } + + public static void zip(File source, File target, boolean excludeRoot) + { + ZipOutputStream zos = null; + + try + { + File root = excludeRoot ? source : source.getParentFile(); + int prefixLength = root.getAbsolutePath().length() + (excludeRoot ? 1 : 0); + + zos = new ZipOutputStream(new FileOutputStream(target)); + zipRecurse(source, prefixLength, zos); + zos.flush(); + } + catch (IOException ex) + { + throw new UnderlyingIOException("Error while jaring " + source + " to " + target, ex); + } + finally + { + close(zos); + } + } + + public static void unzip(String zipFilePath, String targetPath) + { + final int BUFFER = 4096; + byte data[] = new byte[BUFFER]; + int count; + + BufferedOutputStream dest = null; + ZipInputStream zis = null; + + try + { + new File(targetPath).mkdirs(); + + FileInputStream fis = new FileInputStream(zipFilePath); + zis = new ZipInputStream(new BufferedInputStream(fis)); + ZipEntry entry; + + while ((entry = zis.getNextEntry()) != null) + { + File path = new File(targetPath, entry.getName()); + if (entry.isDirectory()) + { + path.mkdirs(); + } + else + { + path.getParentFile().mkdirs(); + FileOutputStream fos = new FileOutputStream(path); + dest = new BufferedOutputStream(fos, BUFFER); + + while ((count = zis.read(data, 0, BUFFER)) != -1) + { + dest.write(data, 0, count); + } + + dest.flush(); + dest.close(); + dest = null; + } + } + } + catch (IOException ex) + { + throw new UnderlyingIOException("Error while unzipping " + zipFilePath + " to " + targetPath, + ex); + } + finally + { + IOHelper.close(dest); + IOHelper.close(zis); + } + } + + public static void jar(File source, File target) + { + jar(source, target, false); + } + + public static void jar(File source, File target, boolean excludeRoot) + { + FileOutputStream fos = null; + JarOutputStream jos = null; + + try + { + Manifest manifest = null; + File metainfFolder = new File(source, "META-INF"); + File manifestFile = metainfFolder.exists() ? new File(metainfFolder, "MANIFEST.MF") : null; + + if (manifestFile == null) + { + manifest = new Manifest(); + } + else + { + FileInputStream fis = null; + + try + { + fis = new FileInputStream(manifestFile); + manifest = new Manifest(fis); + } + catch (IOException ex) + { + throw ex; + } + finally + { + close(fis); + } + } + + File root = excludeRoot ? source : source.getParentFile(); + int prefixLength = root.getAbsolutePath().length() + 1; + + fos = new FileOutputStream(target); + jos = new JarOutputStream(fos, manifest); + jarRecurse(source, prefixLength, jos); + jos.flush(); + } + catch (IOException ex) + { + throw new UnderlyingIOException("Error while jaring " + source + " to " + target, ex); + } + finally + { + close(jos); + close(fos); + } + } + + /** + * + * @param file + * @param impliedPrefix + * @param jos + * @throws IOException + */ + + public static long diskUsage(File file) + { + if (file.isFile()) + { + return file.length(); + } + else if (file.isDirectory()) + { + long usage = 0; + File[] children = file.listFiles(); + + for (int i = 0; i < children.length; i++) + { + File child = children[i]; + usage += diskUsage(child); + } + + return usage; + } + + return 0; + } + + public static int deleteFile(File file) + { + if (file == null) + { + return 0; + } + + int deleted = 0; + + if (file.isDirectory()) + { + File[] children = file.listFiles(); + for (int i = 0; i < children.length; i++) + { + File child = children[i]; + deleted += deleteFile(child); + } + } + + return deleted + (file.delete() ? 1 : 0); + } + + private static void zipRecurse(File file, int prefixLength, ZipOutputStream zos) + throws IOException + { + ZipEntry entry = null; + + try + { + String name = file.getAbsolutePath() + (file.isDirectory() ? "/" : ""); + name = name.substring(prefixLength); + + if (name.length() > 0) + { + entry = new ZipEntry(name); + zos.putNextEntry(entry); + + if (file.isFile()) + { + FileInputStream fis = null; + + try + { + fis = new FileInputStream(file); + copy(fis, zos, 4096); + } + finally + { + close(fis); + } + } + } + } + finally + { + if (entry != null) + { + zos.closeEntry(); + } + } + + if (file.isDirectory()) + { + File[] children = file.listFiles(); + for (int i = 0; i < children.length; i++) + { + File child = children[i]; + zipRecurse(child, prefixLength, zos); + } + } + } + + private static void jarRecurse(File file, int prefixLength, JarOutputStream jos) + throws IOException + { + JarEntry entry = null; + + try + { + String name = file.getAbsolutePath() + (file.isDirectory() ? "/" : ""); + name = name.substring(prefixLength); + + if (name.length() > 0) + { + if (file.isFile() && !name.replace('\\', '/').equals("META-INF/MANIFEST.MF")) + { + entry = new JarEntry(name); + jos.putNextEntry(entry); + + FileInputStream fis = null; + + try + { + fis = new FileInputStream(file); + copy(fis, jos, 4096); + } + finally + { + close(fis); + } + } + } + } + finally + { + if (entry != null) + { + jos.closeEntry(); + } + } + + if (file.isDirectory()) + { + File[] children = file.listFiles(); + for (int i = 0; i < children.length; i++) + { + File child = children[i]; + jarRecurse(child, prefixLength, jos); + } + } + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..65a3fed675 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ImplementationError.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class ImplementationError extends Net4jException +{ + + /** + * + */ + private static final long serialVersionUID = 3256718498427318836L; + + public ImplementationError() + { + super(); + } + + public ImplementationError(String arg0) + { + super(arg0); + } + + public ImplementationError(Throwable arg0) + { + super(arg0); + } + + public ImplementationError(String arg0, Throwable arg1) + { + super(arg0, arg1); + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java new file mode 100644 index 0000000000..2ac28c550a --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/MathHelper.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class MathHelper +{ + + public static boolean isPrime(int number) + { + if (number % 2 == 0) + { + return false; + } + else + { + int max = (int) Math.floor(Math.sqrt(number)); + for (int i = 3; i <= max; i += 2) + { + if (number % i == 0) + { + return false; + } + } + } + + return true; + } + + public static int getPrime(int min) + { + while (!isPrime(min)) + { + ++min; + } + + return min; + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java new file mode 100644 index 0000000000..2df853cd6f --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class Net4jException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = 3978703987010976050L; + + /** + * + */ + public Net4jException() + { + super(); + } + + /** + * @param message + */ + public Net4jException(String message) + { + super(message); + } + + /** + * @param cause + */ + public Net4jException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public Net4jException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java new file mode 100644 index 0000000000..8c542faa96 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Net4jUtilPlugin.java @@ -0,0 +1,63 @@ +package org.eclipse.net4j.util; + + +import org.eclipse.net4j.util.eclipse.AbstractPlugin; + +import org.eclipse.core.runtime.FileLocator; + +import org.apache.log4j.xml.DOMConfigurator; + +import org.osgi.framework.BundleContext; + +import java.net.URL; + + +public class Net4jUtilPlugin extends AbstractPlugin +{ + //The shared instance. + private static Net4jUtilPlugin plugin; + + /** + * The constructor. + */ + public Net4jUtilPlugin() + { + if (plugin == null) plugin = this; + } + + public void start(BundleContext context) throws Exception + { + super.start(context); + initializeLogger(); + } + + protected void doStop() throws Exception + { + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static Net4jUtilPlugin getDefault() + { + return plugin; + } + + private void initializeLogger() + { + // IOHelper.log("Initializing Log4j..."); + + try + { + URL pluginURL = getBundle().getEntry("/config/log4j.xml"); + URL absoluteURL = FileLocator.toFileURL(pluginURL); + + DOMConfigurator.configure(absoluteURL); + } + catch (Exception ex) + { + IOHelper.log("Warning: Initialization of Log4j failed", ex); + } + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java new file mode 100644 index 0000000000..a65d6db4bf --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/Pair.java @@ -0,0 +1,55 @@ +package org.eclipse.net4j.util; + + +public final class Pair<T1, T2> +{ + private final T1 first; + + private final T2 second; + + public Pair(T1 first, T2 second) + { + this.first = first; + this.second = second; + } + + public T1 getFirst() + { + return first; + } + + public T2 getSecond() + { + return second; + } + + @Override + public boolean equals(Object o) + { + if (!(o instanceof Pair)) return false; + Pair that = (Pair) o; + + Object f1 = getFirst(); + Object f2 = that.getFirst(); + if (f1 == f2 || (f1 != null && f1.equals(f2))) + { + Object s1 = getSecond(); + Object s2 = that.getSecond(); + if (s1 == s2 || (s1 != null && s1.equals(s2))) return true; + } + + return false; + } + + @Override + public int hashCode() + { + return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode()); + } + + @Override + public String toString() + { + return "Pair[" + first + ", " + second + "]"; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java new file mode 100644 index 0000000000..b0dde7ef67 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringHelper.java @@ -0,0 +1,578 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import java.nio.ByteBuffer; + + +public class StringHelper +{ + + public static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', + 'b', 'c', 'd', 'e', 'f',}; + + public static final String UTF8_CHARS = " " + + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + + "`abcdefghijklmnopqrstuvwxyz{|}~"; + + public static final char SEPARATOR = '\n'; + + /** + * This method is used to insert HTML block dynamically + * + * @param source + * the HTML code to be processes + * @param bReplaceNl + * if true '\n' will be replaced by <br> + * @param bReplaceTag + * if true ' <' will be replaced by < and '>' will be replaced by > + * @param bReplaceQuote + * if true '\"' will be replaced by " + */ + public static String formatHtml(String source, boolean bReplaceNl, boolean bReplaceTag, + boolean bReplaceQuote) + { + + StringBuffer sb = new StringBuffer(); + int len = source.length(); + for (int i = 0; i < len; i++) + { + char c = source.charAt(i); + switch (c) + { + case '\"': + if (bReplaceQuote) + sb.append("""); + else + sb.append(c); + break; + + case '<': + if (bReplaceTag) + sb.append("<"); + else + sb.append(c); + break; + + case '>': + if (bReplaceTag) + sb.append(">"); + else + sb.append(c); + break; + + case '\n': + if (bReplaceNl) + { + if (bReplaceTag) + sb.append("<br>"); + else + sb.append("<br>"); + } + else + { + sb.append(c); + } + break; + + case '\r': + break; + + case '&': + sb.append("&"); + break; + + default: + sb.append(c); + break; + } + } + return sb.toString(); + } + + public static String getLastToken(String str, char separator) + { + int pos = str.lastIndexOf(separator); + if (pos != -1) + { + str = str.substring(pos + 1); + } + return str; + } + + public static String getSimpleClassName(Class aClass) + { + return getSimpleClassName(aClass.getName()); + } + + public static String getSimpleClassName(String qualifiedClassName) + { + return getLastToken(qualifiedClassName, '.'); + } + + /** + * Pad string object + */ + public static String pad(String src, char padChar, boolean rightPad, int totalLength) + { + + int srcLength = src.length(); + if (srcLength >= totalLength) + { + return src; + } + + int padLength = totalLength - srcLength; + StringBuffer sb = new StringBuffer(padLength); + for (int i = 0; i < padLength; ++i) + { + sb.append(padChar); + } + + if (rightPad) + { + return src + sb.toString(); + } + else + { + return sb.toString() + src; + } + } + + public static String removePrefix(String str, String prefix) + { + if (str.startsWith(prefix)) + { + return str.substring(prefix.length()); + } + return str; + } + + public static String removeSuffix(String str, String suffix) + { + if (str.endsWith(suffix)) + { + return str.substring(0, str.length() - suffix.length()); + } + return str; + } + + /** + * Replace string + */ + public static String replaceString(String source, Map args) + { + int startIndex = 0; + int openIndex = source.indexOf('{', startIndex); + if (openIndex == -1) + { + return source; + } + + int closeIndex = source.indexOf('}', startIndex); + if ((closeIndex == -1) || (openIndex > closeIndex)) + { + return source; + } + + StringBuffer sb = new StringBuffer(); + sb.append(source.substring(startIndex, openIndex)); + while (true) + { + String key = source.substring(openIndex + 1, closeIndex); + Object val = args.get(key); + if (val != null) + { + sb.append(val); + } + + startIndex = closeIndex + 1; + openIndex = source.indexOf('{', startIndex); + if (openIndex == -1) + { + sb.append(source.substring(startIndex)); + break; + } + + closeIndex = source.indexOf('}', startIndex); + if ((closeIndex == -1) || (openIndex > closeIndex)) + { + sb.append(source.substring(startIndex)); + break; + } + sb.append(source.substring(startIndex, openIndex)); + } + return sb.toString(); + } + + /** + * Replace string + */ + public static String replaceString(String source, Object[] args) + { + int startIndex = 0; + int openIndex = source.indexOf('{', startIndex); + if (openIndex == -1) + { + return source; + } + + int closeIndex = source.indexOf('}', startIndex); + if ((closeIndex == -1) || (openIndex > closeIndex)) + { + return source; + } + + StringBuffer sb = new StringBuffer(); + sb.append(source.substring(startIndex, openIndex)); + while (true) + { + String intStr = source.substring(openIndex + 1, closeIndex); + int index = Integer.parseInt(intStr); + sb.append(args[index]); + + startIndex = closeIndex + 1; + openIndex = source.indexOf('{', startIndex); + if (openIndex == -1) + { + sb.append(source.substring(startIndex)); + break; + } + + closeIndex = source.indexOf('}', startIndex); + if ((closeIndex == -1) || (openIndex > closeIndex)) + { + sb.append(source.substring(startIndex)); + break; + } + sb.append(source.substring(startIndex, openIndex)); + } + return sb.toString(); + } + + /** + * This is a string replacement method. + */ + public static String replaceString(String source, String oldStr, String newStr) + { + StringBuffer sb = new StringBuffer(source.length()); + int sind = 0; + int cind = 0; + while ((cind = source.indexOf(oldStr, sind)) != -1) + { + sb.append(source.substring(sind, cind)); + sb.append(newStr); + sind = cind + oldStr.length(); + } + sb.append(source.substring(sind)); + return sb.toString(); + } + + public static String replaceWildcards(String source, String param, Object[] args) + { + String tmp = source; + for (int i = 0; i < args.length; i++) + { + int pos = tmp.indexOf(param); + if (pos == -1) + throw new IllegalArgumentException("source '" + source + "' must contain at least " + + args.length + " params '" + param + "'"); + + String arg = args[i] == null ? "null" : args[i].toString(); + tmp = tmp.substring(0, pos) + arg + tmp.substring(pos + 1); + } + return tmp; + } + + /** + * Get byte array from hex string + */ + public static byte[] toByteArray(String hexString) + { + int arrLength = hexString.length() >> 1; + byte buff[] = new byte[arrLength]; + for (int i = 0; i < arrLength; i++) + { + int index = i << 1; + String digit = hexString.substring(index, index + 2); + buff[i] = (byte) Integer.parseInt(digit, 16); + } + return buff; + } + + /** + * Append hex string from byte to StringBuffer + */ + public static void appendHexString(StringBuffer buffer, byte data) + { + int positive = data < 0 ? ~data : data; + buffer.append(HEX_DIGITS[positive >> 4]); + buffer.append(HEX_DIGITS[positive & 0xf]); + } + + /** + * Get hex string from byte + */ + public static String toHexString(byte data) + { + StringBuffer buffer = new StringBuffer(); + appendHexString(buffer, data); + return buffer.toString(); + } + + /** + * Get hex string from byte array + */ + public static String toHexString(byte[] data) + { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < data.length; i++) + { + appendHexString(buffer, data[i]); + buffer.append(' '); + } + + return buffer.toString(); + } + + public static String toHexString(ByteBuffer buffer) + { + StringBuffer line = new StringBuffer(); + + while (buffer.hasRemaining()) + { + byte dec = buffer.get(); + StringHelper.appendHexString(line, dec); + line.append(' '); + } + + return line.toString(); + } + + /** + * Append hex string from byte to StringBuffer + */ + public static void appendUTF8String(StringBuffer buffer, byte data, boolean flat) + { + if (32 <= data && data < 127) + { + char c = UTF8_CHARS.charAt(data); + buffer.append(c); + } + else + { + if (!flat) + { + buffer.append("."); + } + } + } + + /** + * Get hex string from byte + */ + public static String toUTF8String(byte data, boolean flat) + { + StringBuffer buffer = new StringBuffer(); + appendUTF8String(buffer, data, flat); + return buffer.toString(); + } + + /** + * Get hex string from byte array + */ + public static String toUTF8String(byte[] data, boolean flat) + { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < data.length; i++) + { + appendUTF8String(buffer, data[i], flat); + } + + return buffer.toString(); + } + + public static String toUTF8String(ByteBuffer buffer, boolean flat) + { + StringBuffer line = new StringBuffer(); + + while (buffer.hasRemaining()) + { + byte dec = buffer.get(); + StringHelper.appendUTF8String(line, dec, flat); + } + + return line.toString(); + } + + public static boolean parseBoolean(String str) throws NumberFormatException + { + if (str.equals("true")) return true; + if (str.equals("false")) return false; + throw new NumberFormatException("'" + str + "' is neither 'true' nor 'false'"); + } + + public static String implode(Collection collection, String separator) + { + if (collection == null) return null; + if (collection.size() == 0) return ""; + + Iterator iter = collection.iterator(); + StringBuffer result = new StringBuffer(iter.next().toString()); + + while (iter.hasNext()) + { + if (separator != null) result.append(separator); + result.append(iter.next().toString()); + } + + return result.toString(); + } + + public static String implode(Object[] array, String separator) + { + if (array == null) return null; + if (array.length == 0) return ""; + + StringBuffer result = new StringBuffer(array[0].toString()); + + for (int i = 1; i < array.length; i++) + { + if (separator != null) result.append(separator); + result.append(array[i].toString()); + } + + return result.toString(); + } + + public static int getChoice(String str, String[] choices) + { + if (choices == null) throw new IllegalArgumentException("choices should be non-null"); + + for (int i = 0; i < choices.length; i++) + { + if ((str == null && choices[i] == null) || str.equals(choices[i])) + { + return i; + } + } + + return -1; + } + + public static List parseName(String name, char separator) + { + List result = new ArrayList(); + StringBuffer currentWord = new StringBuffer(); + + int length = name.length(); + boolean lastIsLower = false; + + for (int index = 0; index < length; index++) + { + char curChar = name.charAt(index); + if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) + || curChar == separator) + { + if (lastIsLower || curChar == separator) + { + result.add(currentWord.toString()); + currentWord = new StringBuffer(); + } + lastIsLower = false; + } + else + { + if (!lastIsLower) + { + int currentWordLength = currentWord.length(); + if (currentWordLength > 1) + { + char lastChar = currentWord.charAt(--currentWordLength); + currentWord.setLength(currentWordLength); + result.add(currentWord.toString()); + currentWord = new StringBuffer(); + currentWord.append(lastChar); + } + } + lastIsLower = true; + } + if (curChar != separator) + { + currentWord.append(curChar); + } + } + + result.add(currentWord.toString()); + return result; + } + + /** + * @param text + */ + public static String firstToLower(String text) + { + if (text == null || text.length() == 0) return text; + if (Character.isUpperCase(text.charAt(0))) + { + return text.substring(0, 1).toLowerCase() + text.substring(1); + } + return text; + } + + /** + * @param text + */ + public static String firstToUpper(String text) + { + if (text == null || text.length() == 0) return text; + if (Character.isLowerCase(text.charAt(0))) + { + return text.substring(0, 1).toUpperCase() + text.substring(1); + } + return text; + } + + public static int toInt(String intValue, int defaultValue) + { + try + { + return Integer.valueOf(intValue).intValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + public static boolean equals(Object obj1, Object obj2) + { + if (obj1 == null) return obj2 == null; + return obj1.equals(obj2); + } + + public static String formatNull(String str, String nullReplacement) + { + return str == null ? nullReplacement : str; + } + + public static String toNonNull(String str) + { + return formatNull(str, ""); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java new file mode 100644 index 0000000000..61339cc1ce --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ThreadInterruptedException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class ThreadInterruptedException extends Net4jException +{ + /** + * + */ + private static final long serialVersionUID = 3256443603340244792L; + + /** + * + */ + public ThreadInterruptedException() + { + super(); + } + + /** + * @param message + */ + public ThreadInterruptedException(String message) + { + super(message); + } + + /** + * @param cause + */ + public ThreadInterruptedException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public ThreadInterruptedException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java new file mode 100644 index 0000000000..a41c7afa00 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/TimeOutException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class TimeOutException extends Net4jException +{ + /** + * + */ + private static final long serialVersionUID = 3977295508371158066L; + + /** + * + */ + public TimeOutException() + { + super(); + } + + /** + * @param message + */ + public TimeOutException(String message) + { + super(message); + } + + /** + * @param cause + */ + public TimeOutException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public TimeOutException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java new file mode 100644 index 0000000000..a7ea89597c --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UnderlyingIOException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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; + + +public class UnderlyingIOException extends Net4jException +{ + /** + * + */ + private static final long serialVersionUID = 3833179220800386871L; + + /** + * + */ + public UnderlyingIOException() + { + super(); + } + + /** + * @param message + */ + public UnderlyingIOException(String message) + { + super(message); + } + + /** + * @param cause + */ + public UnderlyingIOException(Throwable cause) + { + super(cause); + } + + /** + * @param message + * @param cause + */ + public UnderlyingIOException(String message, Throwable cause) + { + super(message, cause); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java new file mode 100644 index 0000000000..91dbbdc51b --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/AbstractPlugin.java @@ -0,0 +1,253 @@ +package org.eclipse.net4j.util.eclipse; + + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; + +import org.apache.log4j.Logger; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import java.io.IOException; + +import java.net.URL; + + +/** + * The main plugin class to be used in the desktop. + */ +public abstract class AbstractPlugin extends Plugin implements ClassLoaderFactory +{ + /** + * Logger for this class + */ + private final Logger logger = Logger.getLogger(getClass()); + + private String pluginId; + + private ResourceBundle resourceBundle; + + private BundleContext bundleContext; + + /** + * The constructor. + */ + protected AbstractPlugin() + { + } + + public String getPluginId() + { + return pluginId; + } + + public ClassLoader getClassLoader() + { + return getClass().getClassLoader(); + } + + public Logger getLogger() + { + return logger; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception + { + super.start(context); + bundleContext = context; + pluginId = context.getBundle().getSymbolicName(); + + try + { + if (resourceBundle == null) + { + try + { + resourceBundle = ResourceBundle.getBundle(pluginId); + } + catch (MissingResourceException x) + { + resourceBundle = null; + } + } + + if (logger.isDebugEnabled()) logger.debug("ENTER STARTUP"); + doStart(); + } + catch (Throwable t) + { + logger.error("Startup error", t); + } + finally + { + if (logger.isDebugEnabled()) logger.debug("EXIT STARTUP"); + } + } + + /** + * This method is called upon plug-in deactivation + */ + public void stop(BundleContext context) throws Exception + { + try + { + if (logger.isDebugEnabled()) logger.debug("ENTER SHUTDOWN"); + doStop(); + } + catch (Throwable t) + { + logger.error("Shutdown error", t); + } + finally + { + if (logger.isDebugEnabled()) logger.debug("EXIT SHUTDOWN"); + } + + super.stop(context); + resourceBundle = null; + } + + /** + * + */ + protected void doStart() throws Exception + { + } + + /** + * + */ + protected void doStop() throws Exception + { + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public String getResourceString(String key) + { + ResourceBundle bundle = getResourceBundle(); + + try + { + return (bundle != null) ? bundle.getString(key) : key; + } + catch (MissingResourceException e) + { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() + { + return resourceBundle; + } + + /** + * @return Returns the bundleContext. + */ + public BundleContext getBundleContext() + { + return bundleContext; + } + + public String getBundleLocation() throws IOException + { + Bundle bundle = bundleContext.getBundle(); + return getBundleLocation(bundle); + } + + /** + * Progress monitor helpers + */ + public static void checkCanceled(IProgressMonitor monitor) + { + if (monitor.isCanceled()) cancelOperation(); + } + + public static void cancelOperation() + { + throw new OperationCanceledException(); + } + + public static IProgressMonitor monitorFor(IProgressMonitor monitor) + { + if (monitor == null) return new NullProgressMonitor(); + return monitor; + } + + public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) + { + if (monitor == null) return new NullProgressMonitor(); + if (monitor instanceof NullProgressMonitor) return monitor; + return new SubProgressMonitor(monitor, ticks); + } + + public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) + { + if (monitor == null) return new NullProgressMonitor(); + if (monitor instanceof NullProgressMonitor) return monitor; + return new SubProgressMonitor(monitor, ticks, style); + } + + public static String getBundleLocation(Bundle bundle) throws IOException + { + URL url = bundle.getEntry("/"); + return FileLocator.toFileURL(url).getFile(); + } + + public void debug(String message) + { + logger.debug(message); + getLog().log(new Status(IStatus.INFO, pluginId, IStatus.OK, message, null)); + } + + public void warn(String message) + { + warn(message, null); + } + + public void error(String message) + { + error(message, null); + } + + public void warn(Throwable t) + { + warn(t.getMessage(), t); + } + + public void error(Throwable t) + { + error(t.getMessage(), t); + } + + public void warn(String message, Throwable t) + { + logger.warn(message, t); + getLog().log(new Status(IStatus.WARNING, pluginId, IStatus.OK, message, t)); + } + + public void error(String message, Throwable t) + { + logger.error(message, t); + getLog().log(new Status(IStatus.ERROR, pluginId, IStatus.OK, message, t)); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java new file mode 100644 index 0000000000..35978c3fb8 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ClassLoaderFactory.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +public interface ClassLoaderFactory +{ + public ClassLoader getClassLoader(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java new file mode 100644 index 0000000000..51d2e0d28b --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/Element.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +import org.eclipse.net4j.util.BeanHelper; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; + + +public class Element extends BeanHelper +{ + protected IConfigurationElement configurationElement; + + public Element() + { + } + + public void internalSetConfigurationElement(IConfigurationElement configurationElement) + { + this.configurationElement = configurationElement; + } + + public void validate(ExtensionParser parser) + { + } + + public IConfigurationElement configurationElement() + { + return configurationElement; + } + + public IExtension declaringExtension() + { + return configurationElement.getDeclaringExtension(); + } + + public String name() + { + return configurationElement.getName(); + } + + public void dispatchChild(String name, Object value) + { + dispatchChild(this, name, value); + } + + public void dispatchAttributeValue(String name, String value) + { + dispatchAttributeValue(this, name, value); + } + + protected String executableExtensionPropertyName() + { + return "className"; + } + + + public interface Factory + { + public Element createElementData(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java new file mode 100644 index 0000000000..33255a609c --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ElementRegistry.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +import java.util.HashMap; +import java.util.Map; + + +public class ElementRegistry extends HashMap +{ + /** + * + */ + private static final long serialVersionUID = 3762810506670847288L; + + public ElementRegistry() + { + super(); + } + + public ElementRegistry(int initialCapacity) + { + super(initialCapacity); + } + + public ElementRegistry(int initialCapacity, float loadFactor) + { + super(initialCapacity, loadFactor); + } + + public ElementRegistry(Map m) + { + super(m); + } + + public Object put(Item value) + { + Object key = value.registryKey(); + return super.put(key, value); + } + + + public interface Item + { + public Object registryKey(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java new file mode 100644 index 0000000000..be57ddbeb4 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExamplePlugin.java @@ -0,0 +1,36 @@ +package org.eclipse.net4j.util.eclipse; + + +/** + * The main plugin class to be used in the desktop. + */ +public class ExamplePlugin extends AbstractPlugin +{ + //The shared instance. + private static ExamplePlugin plugin; + + /** + * The constructor. + */ + public ExamplePlugin() + { + if (plugin == null) plugin = this; + } + + protected void doStart() throws Exception + { + } + + public void doStop() throws Exception + { + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static ExamplePlugin getDefault() + { + return plugin; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java new file mode 100644 index 0000000000..04e4c64684 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExecutableElement.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +import org.eclipse.core.runtime.CoreException; + + +public class ExecutableElement extends Element +{ + protected String className; + + public String getClassName() + { + return className; + } + + public void setClassName(String className) + { + this.className = className; + } + + public Object createExecutableExtension() throws CoreException + { + String propertyName = executableExtensionPropertyName(); + return configurationElement.createExecutableExtension(propertyName); + } + + public Object createExecutableExtension(String propertyName) throws CoreException + { + return configurationElement.createExecutableExtension(propertyName); + } + + public String toString() + { + return "Executable(" + className + ")"; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java new file mode 100644 index 0000000000..84aafea998 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionConfigException.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +public class ExtensionConfigException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = 3979274633562501681L; + + /** + * + */ + public ExtensionConfigException() + { + super(); + } + + /** + * @param arg0 + */ + public ExtensionConfigException(String arg0) + { + super(arg0); + } + + /** + * @param arg0 + */ + public ExtensionConfigException(Throwable arg0) + { + super(arg0); + } + + /** + * @param arg0 + * @param arg1 + */ + public ExtensionConfigException(String arg0, Throwable arg1) + { + super(arg0, arg1); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java new file mode 100644 index 0000000000..d849193178 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ExtensionParser.java @@ -0,0 +1,182 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.net4j.util.StringHelper; +import org.eclipse.net4j.util.eclipse.Element.Factory; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + +import org.apache.log4j.Logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class ExtensionParser +{ + protected Map elementDataFactoryRegistry = new HashMap(); + + protected List contextStack = new ArrayList(); + + private static final Logger logger = Logger.getLogger(ExtensionParser.class.getName()); + + public void parse(String extPointId) + { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint point = registry.getExtensionPoint(extPointId); + + if (point == null) + { + String msg = "Extension point '" + extPointId + "' does not exist."; + logger.error(msg); + return; + } + + parse(point); + } + + public void parse(IExtensionPoint point) + { + IExtension[] extensions = point.getExtensions(); + for (int i = 0; extensions != null && i < extensions.length; i++) + { + try + { + parse(extensions[i]); + } + catch (Throwable t) + { + String msg = "Error in plugin " + extensions[i].getNamespaceIdentifier() + + " while reading extension to " + point.getUniqueIdentifier(); + logger.error(msg, t); + } + } + } + + public Element[] parse(IExtension extension) + { + if (logger.isDebugEnabled()) + logger.debug("Parsing plugin " + extension.getNamespaceIdentifier() + " (extension-point = " + + extension.getExtensionPointUniqueIdentifier() + ")"); + + IConfigurationElement[] elems = extension.getConfigurationElements(); + return parse(elems); + } + + public Element[] parse(IConfigurationElement[] elems) + { + Element[] result = new Element[elems.length]; + + for (int i = 0; i < elems.length; i++) + { + IConfigurationElement elem = elems[i]; + result[i] = parse(elem); + } + + if (logger.isDebugEnabled()) + logger.debug("All extension data: " + StringHelper.implode(result, ", ")); + + return result; + } + + public Element parse(IConfigurationElement elem) + { + pushContext(elem.getName()); + String context = getContextString(); + + Element.Factory factory = findFactory(context); + if (factory == null) + throw new ExtensionConfigException("No element factory for context " + context); + + Element elementData = factory.createElementData(); + if (elementData == null) + throw new ExtensionConfigException("No element created for context " + context); + elementData.internalSetConfigurationElement(elem); + + String[] attributeNames = elem.getAttributeNames(); + for (int i = 0; i < attributeNames.length; i++) + { + String attributeName = attributeNames[i]; + String attributeValue = elem.getAttribute(attributeName); + + if (logger.isDebugEnabled()) + logger.debug("Dispatching " + context + "." + attributeName + " = " + attributeValue); + + elementData.dispatchAttributeValue(attributeName, attributeValue); + } + + // Recurse + for (int i = 0; i < elem.getChildren().length; i++) + { + IConfigurationElement child = elem.getChildren()[i]; + Element childData = parse(child); + elementData.dispatchChild(child.getName(), childData); + } + + popContext(); + validate(elementData); + return elementData; + } + + public void addFactory(String contextPattern, Factory factory) + { + Pattern pattern = Pattern.compile(contextPattern); + elementDataFactoryRegistry.put(pattern, factory); + } + + public Factory findFactory(String context) + { + for (Iterator it = elementDataFactoryRegistry.entrySet().iterator(); it.hasNext();) + { + Map.Entry entry = (Map.Entry) it.next(); + Pattern pattern = (Pattern) entry.getKey(); + Matcher matcher = pattern.matcher(context); + if (matcher.matches()) + { + return (Factory) entry.getValue(); + } + } + return null; + } + + protected void pushContext(String elementName) + { + contextStack.add(elementName); + } + + protected String popContext() + { + if (contextStack.isEmpty()) throw new ImplementationError("contextStack is empty"); + return (String) contextStack.remove(contextStack.size() - 1); + } + + protected String getContextString() + { + return StringHelper.implode(contextStack, "/"); + } + + protected void validate(Element elementData) + { + elementData.validate(this); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java new file mode 100644 index 0000000000..9ac17cda7a --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ListExtensionParser.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +import java.util.ArrayList; +import java.util.List; + + +public class ListExtensionParser extends ExtensionParser +{ + protected List list; + + public ListExtensionParser() + { + } + + public ListExtensionParser(List list) + { + this.list = list; + } + + public List getList() + { + if (list == null) + { + list = new ArrayList(); + } + + return list; + } + + public void setList(List list) + { + this.list = list; + } + + protected void validate(Element elementData) + { + super.validate(elementData); + if (contextStack.isEmpty()) + { + getList().add(elementData); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java new file mode 100644 index 0000000000..710f96b51c --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/RegistryExtensionParser.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.eclipse; + + +public class RegistryExtensionParser extends ExtensionParser +{ + protected ElementRegistry registry; + + public RegistryExtensionParser() + { + } + + public RegistryExtensionParser(ElementRegistry registry) + { + this.registry = registry; + } + + public ElementRegistry getRegistry() + { + if (registry == null) + { + registry = new ElementRegistry(); + } + + return registry; + } + + public void setRegistry(ElementRegistry registry) + { + this.registry = registry; + } + + protected void validate(Element elementData) + { + super.validate(elementData); + + if (elementData instanceof ElementRegistry.Item) + { + getRegistry().put((ElementRegistry.Item) elementData); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java new file mode 100644 index 0000000000..33eeb165bc --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/eclipse/ResourcesHelper.java @@ -0,0 +1,157 @@ +package org.eclipse.net4j.util.eclipse; + + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; + +import java.util.ArrayList; +import java.util.List; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + + +public class ResourcesHelper +{ + public static void writeFile(IFile file, String[] content, IProgressMonitor monitor) + throws CoreException + { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < content.length; i++) + { + String line = content[i]; + buffer.append(line); + buffer.append("\n"); + } + + writeFile(file, buffer.toString(), monitor); + } + + public static void writeFile(IFile file, String content, IProgressMonitor monitor) + throws CoreException + { + InputStream stream = new ByteArrayInputStream(content.getBytes()); + writeFile(file, stream, monitor); + } + + public static void writeFile(IFile file, InputStream content, IProgressMonitor monitor) + throws CoreException + { + if (file.exists()) + { + file.setContents(content, false, true, monitor); + } + else + { + if (file.getParent() instanceof IFolder) + { + mkdirs((IFolder) file.getParent(), monitor); + } + + file.create(content, true, monitor); + } + } + + public static void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException + { + if (folder != null && !folder.exists()) + { + IContainer parent = folder.getParent(); + if (parent != null && parent instanceof IFolder) + { + mkdirs((IFolder) parent, monitor); + } + + folder.create(true, true, monitor); + } + } + + public static String readFileIntoString(IFile file) throws CoreException, IOException + { + return readFileIntoString(file, null); + } + + public static String readFileIntoString(IFile file, String linePrefix) throws CoreException, + IOException + { + BufferedReader br = new BufferedReader(new InputStreamReader(file.getContents())); + StringBuffer buffer = new StringBuffer(); + String line; + + while ((line = br.readLine()) != null) + { + if (linePrefix != null) + { + buffer.append(linePrefix); + } + + buffer.append(line); + buffer.append("\n"); + } + + return buffer.toString(); + } + + public static String[] readFileIntoStringArray(IFile file) throws IOException, CoreException + { + return readFileIntoStringArray(file.getContents()); + } + + public static String[] readFileIntoStringArray(InputStream stream) throws IOException + { + BufferedReader br = new BufferedReader(new InputStreamReader(stream)); + List result = new ArrayList(); + String line; + + while ((line = br.readLine()) != null) + { + result.add(line); + } + + return (String[]) result.toArray(new String[result.size()]); + } + + public static IProject ensureProject(String name) throws CoreException + { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); + + if (!project.exists()) + { + project.create(new NullProgressMonitor()); + } + + if (!project.isOpen()) + { + project.open(new NullProgressMonitor()); + } + + return project; + } + + public static IFolder ensureFolder(IContainer container, String path) throws CoreException + { + if (container == null) + { + container = ResourcesPlugin.getWorkspace().getRoot(); + } + + IFolder folder = container.getFolder(new Path(path)); + + if (!folder.exists()) + { + folder.create(true, true, new NullProgressMonitor()); + } + + return folder; + } +} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java new file mode 100644 index 0000000000..9c5f2ff1e4 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/IStateMachine.java @@ -0,0 +1,31 @@ +package org.eclipse.net4j.util.fsm; + + +public interface IStateMachine<SUBJECT> +{ + public int getStateCount(); + + public int getEventCount(); + + public String getStateName(int state); + + public String getEventName(int event); + + public ITransition<SUBJECT> getIdentityTransition(); + + public void process(SUBJECT subject, int event, Object data) throws Exception; + + public void handle(int state, int event, ITransition<SUBJECT> transition); + + public void handle(int state, int event, int newState); + + public void ignore(int state, int event); + + public void cancel(int state, int event); + + + public interface ITransition<SUBJECT> + { + public void process(SUBJECT subject, int event, Object data) throws Exception; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java new file mode 100644 index 0000000000..2f5e991122 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/fsm/StateMachine.java @@ -0,0 +1,149 @@ +package org.eclipse.net4j.util.fsm; + + +import org.apache.log4j.Logger; + + +public abstract class StateMachine<SUBJECT> implements IStateMachine<SUBJECT> +{ + private static final Logger logger = Logger.getLogger(StateMachine.class.getName()); + + private String[] stateNames; + + private String[] eventNames; + + private ITransition<SUBJECT>[][] matrix; + + public StateMachine(String[] stateNames, String[] eventNames, + ITransition<SUBJECT> defaultTransition) + { + this.stateNames = stateNames; + this.eventNames = eventNames; + + matrix = new ITransition[stateNames.length][eventNames.length]; + + if (defaultTransition != null) + { + for (int state = 0; state < stateNames.length; state++) + { + for (int event = 0; event < eventNames.length; event++) + { + handle(state, event, defaultTransition); + } + } + } + } + + public StateMachine(String[] stateNames, String[] eventNames) + { + this(stateNames, eventNames, null); + } + + public int getStateCount() + { + return stateNames.length; + } + + public int getEventCount() + { + return eventNames.length; + } + + public String getStateName(int state) + { + return stateNames[state]; + } + + public String getEventName(int event) + { + return eventNames[event]; + } + + public ITransition<SUBJECT> getIdentityTransition() + { + return new ITransition<SUBJECT>() + { + public void process(SUBJECT subject, int event, Object data) throws Exception + { + if (getLogger().isDebugEnabled()) + { + int state = getState(subject); + getLogger().debug("Ignoring " + makeLabel(subject, state, event)); + } + } + }; + } + + public void handle(int state, int event, ITransition<SUBJECT> transition) + { + matrix[state][event] = transition; + } + + public void handle(int state, int event, final int newState) + { + handle(state, event, new ITransition<SUBJECT>() + { + public void process(SUBJECT subject, int event, Object data) throws Exception + { + setState(subject, newState); + } + }); + } + + public void ignore(int state, int event) + { + handle(state, event, getIdentityTransition()); + } + + public void cancel(int state, int event) + { + handle(state, event, null); + } + + public void process(SUBJECT subject, int event, Object data) throws Exception + { + int state = getState(subject); + ITransition<SUBJECT> transition = matrix[state][event]; + + if (transition == null) + { + if (getLogger().isDebugEnabled()) + { + getLogger().warn("Ignoring " + makeLabel(subject, state, event)); + } + + return; + } + + if (getLogger().isDebugEnabled()) + { + getLogger().debug("Processing " + makeLabel(subject, state, event)); + } + + transition.process(subject, event, data); + + if (getLogger().isDebugEnabled()) + { + int newState = getState(subject); + getLogger() + .debug( + "Finished " + makeLabel(subject, state, event) + ", newState=" + + getStateName(newState)); + } + } + + protected Logger getLogger() + { + return logger; + } + + protected String makeLabel(SUBJECT subject, int state, int event) + { + return "event " + eventNames[event] + " in state " + stateNames[state] + " for subject " + + subject; + } + + protected abstract int getState(SUBJECT subject); + + protected abstract void setState(SUBJECT subject, int state); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java new file mode 100644 index 0000000000..4de5b55b89 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/DeadlockDetector.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.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.thread; + + +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.net4j.util.ThreadInterruptedException; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + + +public final class DeadlockDetector +{ + public static boolean DETECTION = false; + + public static final boolean COMPLETE_TRACE = true; + + protected static final HashMap locks = new HashMap(); + + public static void preLock() + { + if (DETECTION) + { + Object old = locks.put(Thread.currentThread(), identifySource()); + if (old != null) throw new ImplementationError("Don't nest deadlock detection!"); + } + } + + public static void postLock() + { + if (DETECTION) locks.remove(Thread.currentThread()); + } + + public static void sleep(long millis) throws ThreadInterruptedException + { + preLock(); + + try + { + Thread.sleep(millis); + } + catch (InterruptedException ex) + { + throw new ThreadInterruptedException(ex); + } + finally + { + postLock(); + } + } + + public static void wait(Object object) throws ThreadInterruptedException + { + preLock(); + + try + { + object.wait(); + } + catch (InterruptedException ex) + { + throw new ThreadInterruptedException(ex); + } + finally + { + postLock(); + } + } + + public static void dump() + { + System.out.println(); + System.out.println("Deadlock Detection Dump"); + System.out.println("====================================================================="); + + Map.Entry[] array = (Map.Entry[]) locks.entrySet().toArray(new Map.Entry[locks.size()]); + for (int i = 0; i < array.length; i++) + { + Entry entry = array[i]; + Thread key = (Thread) entry.getKey(); + String val = (String) entry.getValue(); + System.out.println("Lock in " + key + "\n" + val); + } + + System.out.println("====================================================================="); + System.out.println(); + // locks.clear(); + } + + public static String identifySource() + { + class SourceIdentificationException extends Exception + { + private static final long serialVersionUID = 1L; + } + + try + { + throw new SourceIdentificationException(); + } + catch (SourceIdentificationException ex) + { + String ignore = DeadlockDetector.class.getName(); + StackTraceElement[] frames = ex.getStackTrace(); + + for (int i = 0; i < frames.length; i++) + { + if (!frames[i].getClassName().equals(ignore)) + { + if (!COMPLETE_TRACE) return frames[i].toString(); + + StringBuffer result = new StringBuffer(); + for (int j = i; j < frames.length; j++) + { + result.append("\tat " + frames[j].toString() + "\n"); + } + return result.toString(); + } + } + + throw new ImplementationError("identifySource() must not be called from inside the class " + + ignore); + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java new file mode 100644 index 0000000000..3bfce93de1 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/thread/Worker.java @@ -0,0 +1,336 @@ +package org.eclipse.net4j.util.thread; + + +import org.eclipse.net4j.util.ImplementationError; + +import org.apache.log4j.Logger; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public abstract class Worker extends Thread +{ + public static final long TERMINATE = -1; + + public static final long NO_PAUSE = 0; + + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(Worker.class); + + private List progressListeners; + + private List shutdownListeners; + + private int progress; + + private boolean running; + + private Object waitMonitor; + + /** + * + */ + public Worker() + { + super(); + } + + /** + * @param target + */ + public Worker(Runnable target) + { + super(target); + } + + /** + * @param name + */ + public Worker(String name) + { + super(name); + } + + /** + * @param group + * @param target + */ + public Worker(ThreadGroup group, Runnable target) + { + super(group, target); + } + + /** + * @param target + * @param name + */ + public Worker(Runnable target, String name) + { + super(target, name); + } + + /** + * @param group + * @param name + */ + public Worker(ThreadGroup group, String name) + { + super(group, name); + } + + /** + * @param group + * @param target + * @param name + */ + public Worker(ThreadGroup group, Runnable target, String name) + { + super(group, target, name); + } + + /** + * @param group + * @param target + * @param name + * @param stackSize + */ + public Worker(ThreadGroup group, Runnable target, String name, long stackSize) + { + super(group, target, name, stackSize); + } + + public String getLabel() + { + String name = getName(); + return name == null ? toString() : name; + } + + /** + * @return Returns the running. + */ + public boolean isRunning() + { + return running; + } + + /* (non-Javadoc) + * @see java.lang.Runnable#run() + */ + public final void run() + { + notifyProgress(); + + try + { + while (running && !isInterrupted()) + { + if (progress == Integer.MAX_VALUE) + { + progress = 0; + } + else + { + ++progress; + } + + long pause = doWorkStep(progress); + notifyProgress(); + + if (pause == TERMINATE) + { + break; + } + + if (pause > 0) + { + try + { + Thread.sleep(pause); + } + catch (InterruptedException ex) + { + if (logger.isDebugEnabled()) + logger.debug("Interrupted while pausing worker " + getLabel()); + break; + } + } + } + } + catch (Throwable t) + { + try + { + logger.error("Error in worker " + getLabel(), t); + } + catch (Exception ignore) + { + // Can happen due to already unloaded plugins (logging)! + } + } + + notifyShutdown(); + } + + protected void doWait(Object object) throws InterruptedException + { + synchronized (this) + { + waitMonitor = object; + } + + DeadlockDetector.wait(waitMonitor); + + synchronized (this) + { + waitMonitor = null; + } + + if (!running) + { + throw new InterruptedException(); + } + } + + /** + * + * @param progress + * @return The duration to sleep after this step in milliseconds. + */ + protected abstract long doWorkStep(int progress); + + /* (non-Javadoc) + * @see java.lang.Thread#start() + */ + public final void start() + { + throw new ImplementationError("use startup()"); + } + + public void startup() + { + running = true; + super.start(); + } + + public void shutdown() + { + shutdown(0); + } + + public void shutdown(long timeoutMillis) + { + if (logger.isDebugEnabled()) logger.debug("Shutting down worker " + getLabel()); + running = false; + + synchronized (this) + { + if (waitMonitor != null) + { + synchronized (waitMonitor) + { + waitMonitor.notifyAll(); + } + } + } + + try + { + join(timeoutMillis); + } + catch (InterruptedException ex) + { + if (logger.isDebugEnabled()) logger.debug(ex); + } + + if (running) + { + if (logger.isDebugEnabled()) + logger.debug("Shutdown timeout expired. Interrupting worker " + getLabel()); + + interrupt(); + + try + { + join(); + } + catch (InterruptedException ex) + { + if (logger.isDebugEnabled()) logger.debug(ex); + } + } + } + + public void addProgressListener(ProgressListener listener) + { + if (progressListeners == null) + { + progressListeners = new ArrayList(); + } + progressListeners.add(listener); + } + + public void removeProgressListener(ProgressListener listener) + { + if (progressListeners != null) + { + progressListeners.remove(listener); + } + } + + public void addShutdownListener(ShutdownListener listener) + { + if (shutdownListeners == null) + { + shutdownListeners = new ArrayList(); + } + shutdownListeners.add(listener); + } + + public void removeShutdownListener(ShutdownListener listener) + { + if (shutdownListeners != null) + { + shutdownListeners.remove(listener); + } + } + + protected void notifyProgress() + { + if (progressListeners != null) + { + for (Iterator it = progressListeners.iterator(); it.hasNext();) + { + ProgressListener listener = (ProgressListener) it.next(); + listener.notifyProgress(this, progress); + } + } + } + + protected void notifyShutdown() + { + if (shutdownListeners != null) + { + for (Iterator it = shutdownListeners.iterator(); it.hasNext();) + { + ShutdownListener listener = (ShutdownListener) it.next(); + listener.notifyShutdown(this); + } + } + } + + + public interface ProgressListener + { + public void notifyProgress(Worker worker, int progress); + } + + + public interface ShutdownListener + { + public void notifyShutdown(Worker worker); + } +}
\ No newline at end of file |