diff options
author | Eike Stepper | 2012-01-14 10:27:01 +0000 |
---|---|---|
committer | Eike Stepper | 2012-01-14 10:27:01 +0000 |
commit | 0266166cb9ff9535c150250073ea1e57b42d2693 (patch) | |
tree | c006a3bc0ba1f6e1d8a2bc032eedc346f71eab0d /plugins/org.eclipse.net4j.jms | |
parent | 7416443692cdda72d1f704ea4fc5ececcc669df7 (diff) | |
download | cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.gz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.xz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.zip |
Adjusted copyrights to 2012
Diffstat (limited to 'plugins/org.eclipse.net4j.jms')
53 files changed, 4701 insertions, 4701 deletions
diff --git a/plugins/org.eclipse.net4j.jms/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.jms/.settings/org.eclipse.jdt.ui.prefs index aaef0ccba1..6726e7034a 100644 --- a/plugins/org.eclipse.net4j.jms/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.net4j.jms/.settings/org.eclipse.jdt.ui.prefs @@ -1,120 +1,120 @@ -#Thu Feb 04 09:44:24 CET 2010 -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=true -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=true -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=false -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=true -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=_EMFT -cleanup_settings_version=2 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_EMFT -formatter_settings_version=11 -org.eclipse.jdt.ui.exception.name=ex -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java; -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=false -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=true -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=true -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=true -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=true -sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=true -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +#Thu Feb 04 09:44:24 CET 2010
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=false
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=false
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_EMFT
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_EMFT
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=true
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/plugins/org.eclipse.net4j.jms/build.properties b/plugins/org.eclipse.net4j.jms/build.properties index 78b4d0fca5..8d8e51838a 100644 --- a/plugins/org.eclipse.net4j.jms/build.properties +++ b/plugins/org.eclipse.net4j.jms/build.properties @@ -1,21 +1,21 @@ -# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Eike Stepper - initial API and implementation - -# NLS_MESSAGEFORMAT_VAR - -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - .options,\ - about.html,\ - copyright.txt,\ - plugin.properties -src.includes = about.html,\ - copyright.txt +# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+# NLS_MESSAGEFORMAT_VAR
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ .options,\
+ about.html,\
+ copyright.txt,\
+ plugin.properties
+src.includes = about.html,\
+ copyright.txt
diff --git a/plugins/org.eclipse.net4j.jms/copyright.txt b/plugins/org.eclipse.net4j.jms/copyright.txt index e921242cf0..8f6328980e 100644 --- a/plugins/org.eclipse.net4j.jms/copyright.txt +++ b/plugins/org.eclipse.net4j.jms/copyright.txt @@ -1,8 +1,8 @@ -Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html - -Contributors: +Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
Eike Stepper - initial API and implementation
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.jms/plugin.properties b/plugins/org.eclipse.net4j.jms/plugin.properties index 83ceca4a6c..58ab001dcc 100644 --- a/plugins/org.eclipse.net4j.jms/plugin.properties +++ b/plugins/org.eclipse.net4j.jms/plugin.properties @@ -1,11 +1,11 @@ -# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Eike Stepper - initial API and implementation - -pluginName = Net4j JMS Provider -providerName = Eclipse Modeling Project +# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+pluginName = Net4j JMS Provider
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/BytesMessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/BytesMessageImpl.java index 77161fd4d4..abc4c23b8e 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/BytesMessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/BytesMessageImpl.java @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.BytesMessage; -import javax.jms.JMSException; -import javax.jms.Message; - -import java.io.IOException; - -public class BytesMessageImpl extends MessageImpl implements BytesMessage -{ - public long getBodyLength() - { - throw new NotYetImplementedException(); - } - - public boolean readBoolean() - { - throw new NotYetImplementedException(); - } - - public byte readByte() - { - throw new NotYetImplementedException(); - } - - public int readBytes(byte[] value) - { - throw new NotYetImplementedException(); - } - - public int readBytes(byte[] value, int length) - { - throw new NotYetImplementedException(); - } - - public char readChar() - { - throw new NotYetImplementedException(); - } - - public double readDouble() - { - throw new NotYetImplementedException(); - } - - public float readFloat() - { - throw new NotYetImplementedException(); - } - - public int readInt() - { - throw new NotYetImplementedException(); - } - - public long readLong() - { - throw new NotYetImplementedException(); - } - - public short readShort() - { - throw new NotYetImplementedException(); - } - - public String readUTF() - { - throw new NotYetImplementedException(); - } - - public int readUnsignedByte() - { - throw new NotYetImplementedException(); - } - - public int readUnsignedShort() - { - throw new NotYetImplementedException(); - } - - public void reset() - { - throw new NotYetImplementedException(); - } - - public void writeBoolean(boolean value) - { - throw new NotYetImplementedException(); - } - - public void writeByte(byte value) - { - throw new NotYetImplementedException(); - } - - public void writeBytes(byte[] value) - { - throw new NotYetImplementedException(); - } - - public void writeBytes(byte[] value, int offset, int length) - { - throw new NotYetImplementedException(); - } - - public void writeChar(char value) - { - throw new NotYetImplementedException(); - } - - public void writeDouble(double value) - { - throw new NotYetImplementedException(); - } - - public void writeFloat(float value) - { - throw new NotYetImplementedException(); - } - - public void writeInt(int value) - { - throw new NotYetImplementedException(); - } - - public void writeLong(long value) - { - throw new NotYetImplementedException(); - } - - public void writeObject(Object value) - { - throw new NotYetImplementedException(); - } - - public void writeShort(short value) - { - throw new NotYetImplementedException(); - } - - public void writeUTF(String value) - { - throw new NotYetImplementedException(); - } - - @Override - public void populate(Message source) throws JMSException - { - super.populate(source); - byte[] buffer = new byte[512]; - BytesMessage bytes = (BytesMessage)source; - - bytes.reset(); - int count; - while ((count = bytes.readBytes(buffer)) != -1) - { - writeBytes(buffer, 0, count); - } - } - - @Override - public void write(ExtendedDataOutputStream out) throws IOException - { - super.write(out); - } - - @Override - public void read(ExtendedDataInputStream in) throws IOException - { - super.read(in); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import java.io.IOException;
+
+public class BytesMessageImpl extends MessageImpl implements BytesMessage
+{
+ public long getBodyLength()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public boolean readBoolean()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public byte readByte()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readBytes(byte[] value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readBytes(byte[] value, int length)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public char readChar()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public double readDouble()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public float readFloat()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readInt()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public long readLong()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public short readShort()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String readUTF()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readUnsignedByte()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readUnsignedShort()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void reset()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBoolean(boolean value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeByte(byte value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBytes(byte[] value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBytes(byte[] value, int offset, int length)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeChar(char value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeDouble(double value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeFloat(float value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeInt(int value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeLong(long value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeObject(Object value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeShort(short value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeUTF(String value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void populate(Message source) throws JMSException
+ {
+ super.populate(source);
+ byte[] buffer = new byte[512];
+ BytesMessage bytes = (BytesMessage)source;
+
+ bytes.reset();
+ int count;
+ while ((count = bytes.readBytes(buffer)) != -1)
+ {
+ writeBytes(buffer, 0, count);
+ }
+ }
+
+ @Override
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ super.write(out);
+ }
+
+ @Override
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ super.read(in);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java index 8b4516944b..756fa9c1ae 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionFactoryImpl.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.util.container.IManagedContainer; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; - -import java.io.Serializable; -import java.rmi.Remote; - -public class ConnectionFactoryImpl implements ConnectionFactory, Remote, Serializable -{ - private static final long serialVersionUID = 1L; - - private String connectorType; - - private String connectorDescription; - - private Object transportContainer; - - public ConnectionFactoryImpl(String connectorType, String connectorDescription) - { - this.connectorType = connectorType; - this.connectorDescription = connectorDescription; - } - - public String getConnectorType() - { - return connectorType; - } - - public String getConnectorDescription() - { - return connectorDescription; - } - - public Object getTransportContainer() - { - return transportContainer; - } - - public void setTransportContainer(Object transportContainer) - { - this.transportContainer = transportContainer; - } - - public Connection createConnection() throws JMSException - { - return createConnection(null, null); - } - - public Connection createConnection(String userName, String password) throws JMSException - { - return new ConnectionImpl((IManagedContainer)transportContainer, connectorType, connectorDescription, userName, - password); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+
+public class ConnectionFactoryImpl implements ConnectionFactory, Remote, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private String connectorType;
+
+ private String connectorDescription;
+
+ private Object transportContainer;
+
+ public ConnectionFactoryImpl(String connectorType, String connectorDescription)
+ {
+ this.connectorType = connectorType;
+ this.connectorDescription = connectorDescription;
+ }
+
+ public String getConnectorType()
+ {
+ return connectorType;
+ }
+
+ public String getConnectorDescription()
+ {
+ return connectorDescription;
+ }
+
+ public Object getTransportContainer()
+ {
+ return transportContainer;
+ }
+
+ public void setTransportContainer(Object transportContainer)
+ {
+ this.transportContainer = transportContainer;
+ }
+
+ public Connection createConnection() throws JMSException
+ {
+ return createConnection(null, null);
+ }
+
+ public Connection createConnection(String userName, String password) throws JMSException
+ {
+ return new ConnectionImpl((IManagedContainer)transportContainer, connectorType, connectorDescription, userName,
+ password);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java index 4ba959bedf..59c567b2c6 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionImpl.java @@ -1,407 +1,407 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.Net4jUtil; -import org.eclipse.net4j.channel.IChannel; -import org.eclipse.net4j.connector.IConnector; -import org.eclipse.net4j.internal.jms.bundle.OM; -import org.eclipse.net4j.internal.jms.messages.Messages; -import org.eclipse.net4j.internal.jms.protocol.JMSClientProtocol; -import org.eclipse.net4j.internal.jms.protocol.JMSLogonRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSOpenSessionRequest; -import org.eclipse.net4j.jms.JMSUtil; -import org.eclipse.net4j.util.container.Container; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.IContainerDelta.Kind; -import org.eclipse.net4j.util.container.IContainerEvent; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.container.LifecycleEventConverter; -import org.eclipse.net4j.util.container.SingleDeltaContainerEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter; - -import javax.jms.Connection; -import javax.jms.ConnectionConsumer; -import javax.jms.ConnectionMetaData; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.ServerSessionPool; -import javax.jms.Session; -import javax.jms.Topic; - -import java.util.ArrayList; -import java.util.List; - -public class ConnectionImpl extends Container<Session> implements Connection -{ - private String connectorType; - - private String connectorDescription; - - private String userName; - - private String password; - - private ExceptionListener exceptionListener; - - private String clientID; - - private ConnectionMetaData metaData = new ConnectionMetaDataImpl(this); - - private long sendTimeout = 2500; - - private IManagedContainer transportContainer; - - private JMSClientProtocol protocol; - - private List<SessionImpl> sessions = new ArrayList<SessionImpl>(0); - - private transient IListener sessionListener = new LifecycleEventConverter<Session>(this) - { - @Override - protected IContainerEvent<Session> createContainerEvent(IContainer<Session> container, Session element, Kind kind) - { - if (kind == IContainerDelta.Kind.REMOVED) - { - removeSession((SessionImpl)element); - } - - return new SingleDeltaContainerEvent<Session>(container, element, kind); - } - }; - - private transient IListener channelListener = new LifecycleEventAdapter() - { - @Override - protected void onDeactivated(ILifecycle lifecycle) - { - close(); - } - }; - - private boolean modified; - - private boolean stopped = true; - - public ConnectionImpl(IManagedContainer transportContainer, String connectorType, String connectorDescription, - String userName, String password) throws JMSException - { - this.transportContainer = transportContainer == null ? JMSUtil.getTransportContainer() : transportContainer; - if (transportContainer == null) - { - throw new JMSException(Messages.getString("ConnectionImpl_0")); //$NON-NLS-1$ - } - - this.connectorType = connectorType; - this.connectorDescription = connectorDescription; - this.userName = userName; - this.password = password; - - IConnector connector = Net4jUtil.getConnector(transportContainer, connectorType, connectorDescription); - JMSClientProtocol protocol = new JMSClientProtocol(this); - IChannel channel = protocol.open(connector); - channel.addListener(channelListener); - - try - { - if (!new JMSLogonRequest(protocol, userName, password).send()) - { - throw new JMSException(Messages.getString("ConnectionImpl_1")); //$NON-NLS-1$ - } - } - catch (JMSException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - - public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, - ServerSessionPool sessionPool, int maxMessages) - { - throw new UnsupportedOperationException(); - } - - public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, - String messageSelector, ServerSessionPool sessionPool, int maxMessages) - { - throw new UnsupportedOperationException(); - } - - public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException - { - ensureOpen(); - setModified(); - int sessionID = findFreeSessionID(); - SessionImpl session = new SessionImpl(this, sessionID, transacted, acknowledgeMode); - addSession(session); - - try - { - if (!new JMSOpenSessionRequest(protocol, sessionID).send()) - { - throw new JMSException(Messages.getString("ConnectionImpl_2")); //$NON-NLS-1$ - } - } - catch (JMSException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - - return session; - } - - public IManagedContainer getTransportContainer() - { - return transportContainer; - } - - public String getConnectorType() - { - return connectorType; - } - - public String getConnectorDescription() - { - return connectorDescription; - } - - public String getUserName() - { - return userName; - } - - public String getPassword() - { - return password; - } - - public ConnectionMetaData getMetaData() - { - ensureOpen(); - setModified(); - return metaData; - } - - public String getClientID() - { - ensureOpen(); - setModified(); - return clientID; - } - - public void setClientID(String clientID) - { - ensureOpen(); - if (clientID != null) - { - throw new IllegalStateException("clientID != null"); //$NON-NLS-1$ - } - - if (modified) - { - throw new IllegalStateException("modified == true"); //$NON-NLS-1$ - } - - this.clientID = clientID; - } - - public ExceptionListener getExceptionListener() - { - ensureOpen(); - setModified(); - return exceptionListener; - } - - public void setExceptionListener(ExceptionListener listener) - { - ensureOpen(); - setModified(); - exceptionListener = listener; - } - - public long getSendTimeout() - { - return sendTimeout; - } - - public void setSendTimeout(long sendTimeout) - { - this.sendTimeout = sendTimeout; - } - - public synchronized void start() throws JMSException - { - ensureOpen(); - setModified(); - if (stopped) - { - for (SessionImpl session : getSessions()) - { - try - { - session.activate(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - throw new JMSException(ex.getMessage()); - } - } - - stopped = false; - } - } - - public synchronized void stop() - { - ensureOpen(); - setModified(); - if (!stopped) - { - for (SessionImpl session : getSessions()) - { - session.deactivate(); - } - - stopped = true; - } - } - - public synchronized void close() - { - if (protocol != null) - { - stop(); - for (SessionImpl session : getSessions()) - { - session.close(); - } - - protocol.getChannel().removeListener(channelListener); - protocol.close(); - protocol = null; - } - } - - /** - * @since 2.0 - */ - public JMSClientProtocol getProtocol() - { - return protocol; - } - - public void handleMessageFromSignal(int sessionID, long consumerID, MessageImpl message) - { - SessionImpl session = sessions.get(sessionID); - session.handleServerMessage(consumerID, message); - } - - public SessionImpl[] getSessions() - { - List<SessionImpl> result = new ArrayList<SessionImpl>(sessions.size()); - synchronized (sessions) - { - for (SessionImpl session : sessions) - { - if (session != null) - { - result.add(session); - } - } - } - - return result.toArray(new SessionImpl[result.size()]); - } - - public Session[] getElements() - { - return getSessions(); - } - - @Override - public boolean isEmpty() - { - return getSessions().length == 0; - } - - private int findFreeSessionID() - { - synchronized (sessions) - { - int size = sessions.size(); - for (int i = 0; i < size; i++) - { - if (sessions.get(i) == null) - { - return i; - } - } - - return size; - } - } - - private void addSession(SessionImpl session) - { - synchronized (sessions) - { - int sessionID = session.getID(); - while (sessionID >= sessions.size()) - { - sessions.add(null); - } - - sessions.set(sessionID, session); - } - } - - private boolean removeSession(SessionImpl session) - { - synchronized (sessions) - { - int sessionID = session.getID(); - if (sessions.get(sessionID) == session) - { - session.removeListener(sessionListener); - sessions.set(sessionID, null); - return true; - } - - return false; - } - } - - private void setModified() - { - modified = true; - } - - private void ensureOpen() throws IllegalStateException - { - if (protocol == null) - { - throw new IllegalStateException("protocol == null"); //$NON-NLS-1$ - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.internal.jms.bundle.OM;
+import org.eclipse.net4j.internal.jms.messages.Messages;
+import org.eclipse.net4j.internal.jms.protocol.JMSClientProtocol;
+import org.eclipse.net4j.internal.jms.protocol.JMSLogonRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSOpenSessionRequest;
+import org.eclipse.net4j.jms.JMSUtil;
+import org.eclipse.net4j.util.container.Container;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.IContainerDelta.Kind;
+import org.eclipse.net4j.util.container.IContainerEvent;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.LifecycleEventConverter;
+import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConnectionImpl extends Container<Session> implements Connection
+{
+ private String connectorType;
+
+ private String connectorDescription;
+
+ private String userName;
+
+ private String password;
+
+ private ExceptionListener exceptionListener;
+
+ private String clientID;
+
+ private ConnectionMetaData metaData = new ConnectionMetaDataImpl(this);
+
+ private long sendTimeout = 2500;
+
+ private IManagedContainer transportContainer;
+
+ private JMSClientProtocol protocol;
+
+ private List<SessionImpl> sessions = new ArrayList<SessionImpl>(0);
+
+ private transient IListener sessionListener = new LifecycleEventConverter<Session>(this)
+ {
+ @Override
+ protected IContainerEvent<Session> createContainerEvent(IContainer<Session> container, Session element, Kind kind)
+ {
+ if (kind == IContainerDelta.Kind.REMOVED)
+ {
+ removeSession((SessionImpl)element);
+ }
+
+ return new SingleDeltaContainerEvent<Session>(container, element, kind);
+ }
+ };
+
+ private transient IListener channelListener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ close();
+ }
+ };
+
+ private boolean modified;
+
+ private boolean stopped = true;
+
+ public ConnectionImpl(IManagedContainer transportContainer, String connectorType, String connectorDescription,
+ String userName, String password) throws JMSException
+ {
+ this.transportContainer = transportContainer == null ? JMSUtil.getTransportContainer() : transportContainer;
+ if (transportContainer == null)
+ {
+ throw new JMSException(Messages.getString("ConnectionImpl_0")); //$NON-NLS-1$
+ }
+
+ this.connectorType = connectorType;
+ this.connectorDescription = connectorDescription;
+ this.userName = userName;
+ this.password = password;
+
+ IConnector connector = Net4jUtil.getConnector(transportContainer, connectorType, connectorDescription);
+ JMSClientProtocol protocol = new JMSClientProtocol(this);
+ IChannel channel = protocol.open(connector);
+ channel.addListener(channelListener);
+
+ try
+ {
+ if (!new JMSLogonRequest(protocol, userName, password).send())
+ {
+ throw new JMSException(Messages.getString("ConnectionImpl_1")); //$NON-NLS-1$
+ }
+ }
+ catch (JMSException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+
+ public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector,
+ ServerSessionPool sessionPool, int maxMessages)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName,
+ String messageSelector, ServerSessionPool sessionPool, int maxMessages)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
+ {
+ ensureOpen();
+ setModified();
+ int sessionID = findFreeSessionID();
+ SessionImpl session = new SessionImpl(this, sessionID, transacted, acknowledgeMode);
+ addSession(session);
+
+ try
+ {
+ if (!new JMSOpenSessionRequest(protocol, sessionID).send())
+ {
+ throw new JMSException(Messages.getString("ConnectionImpl_2")); //$NON-NLS-1$
+ }
+ }
+ catch (JMSException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+
+ return session;
+ }
+
+ public IManagedContainer getTransportContainer()
+ {
+ return transportContainer;
+ }
+
+ public String getConnectorType()
+ {
+ return connectorType;
+ }
+
+ public String getConnectorDescription()
+ {
+ return connectorDescription;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public ConnectionMetaData getMetaData()
+ {
+ ensureOpen();
+ setModified();
+ return metaData;
+ }
+
+ public String getClientID()
+ {
+ ensureOpen();
+ setModified();
+ return clientID;
+ }
+
+ public void setClientID(String clientID)
+ {
+ ensureOpen();
+ if (clientID != null)
+ {
+ throw new IllegalStateException("clientID != null"); //$NON-NLS-1$
+ }
+
+ if (modified)
+ {
+ throw new IllegalStateException("modified == true"); //$NON-NLS-1$
+ }
+
+ this.clientID = clientID;
+ }
+
+ public ExceptionListener getExceptionListener()
+ {
+ ensureOpen();
+ setModified();
+ return exceptionListener;
+ }
+
+ public void setExceptionListener(ExceptionListener listener)
+ {
+ ensureOpen();
+ setModified();
+ exceptionListener = listener;
+ }
+
+ public long getSendTimeout()
+ {
+ return sendTimeout;
+ }
+
+ public void setSendTimeout(long sendTimeout)
+ {
+ this.sendTimeout = sendTimeout;
+ }
+
+ public synchronized void start() throws JMSException
+ {
+ ensureOpen();
+ setModified();
+ if (stopped)
+ {
+ for (SessionImpl session : getSessions())
+ {
+ try
+ {
+ session.activate();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ throw new JMSException(ex.getMessage());
+ }
+ }
+
+ stopped = false;
+ }
+ }
+
+ public synchronized void stop()
+ {
+ ensureOpen();
+ setModified();
+ if (!stopped)
+ {
+ for (SessionImpl session : getSessions())
+ {
+ session.deactivate();
+ }
+
+ stopped = true;
+ }
+ }
+
+ public synchronized void close()
+ {
+ if (protocol != null)
+ {
+ stop();
+ for (SessionImpl session : getSessions())
+ {
+ session.close();
+ }
+
+ protocol.getChannel().removeListener(channelListener);
+ protocol.close();
+ protocol = null;
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public JMSClientProtocol getProtocol()
+ {
+ return protocol;
+ }
+
+ public void handleMessageFromSignal(int sessionID, long consumerID, MessageImpl message)
+ {
+ SessionImpl session = sessions.get(sessionID);
+ session.handleServerMessage(consumerID, message);
+ }
+
+ public SessionImpl[] getSessions()
+ {
+ List<SessionImpl> result = new ArrayList<SessionImpl>(sessions.size());
+ synchronized (sessions)
+ {
+ for (SessionImpl session : sessions)
+ {
+ if (session != null)
+ {
+ result.add(session);
+ }
+ }
+ }
+
+ return result.toArray(new SessionImpl[result.size()]);
+ }
+
+ public Session[] getElements()
+ {
+ return getSessions();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return getSessions().length == 0;
+ }
+
+ private int findFreeSessionID()
+ {
+ synchronized (sessions)
+ {
+ int size = sessions.size();
+ for (int i = 0; i < size; i++)
+ {
+ if (sessions.get(i) == null)
+ {
+ return i;
+ }
+ }
+
+ return size;
+ }
+ }
+
+ private void addSession(SessionImpl session)
+ {
+ synchronized (sessions)
+ {
+ int sessionID = session.getID();
+ while (sessionID >= sessions.size())
+ {
+ sessions.add(null);
+ }
+
+ sessions.set(sessionID, session);
+ }
+ }
+
+ private boolean removeSession(SessionImpl session)
+ {
+ synchronized (sessions)
+ {
+ int sessionID = session.getID();
+ if (sessions.get(sessionID) == session)
+ {
+ session.removeListener(sessionListener);
+ sessions.set(sessionID, null);
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private void setModified()
+ {
+ modified = true;
+ }
+
+ private void ensureOpen() throws IllegalStateException
+ {
+ if (protocol == null)
+ {
+ throw new IllegalStateException("protocol == null"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionMetaDataImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionMetaDataImpl.java index 712cae362d..12b9aa75f8 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionMetaDataImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ConnectionMetaDataImpl.java @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.ConnectionMetaData; - -import java.util.Enumeration; -import java.util.StringTokenizer; - -public class ConnectionMetaDataImpl implements ConnectionMetaData -{ - private ConnectionImpl connection; - - public ConnectionMetaDataImpl(ConnectionImpl connection) - { - this.connection = connection; - } - - public ConnectionImpl getConnection() - { - return connection; - } - - public int getJMSMajorVersion() - { - return 1; - } - - public int getJMSMinorVersion() - { - return 1; - } - - public String getJMSVersion() - { - return "1.1"; //$NON-NLS-1$ - } - - public String getJMSProviderName() - { - return "Net4j JMS"; //$NON-NLS-1$ - } - - public int getProviderMajorVersion() - { - return 0; - } - - public int getProviderMinorVersion() - { - return 8; - } - - public String getProviderVersion() - { - return "0.8.0"; //$NON-NLS-1$ - } - - public Enumeration<?> getJMSXPropertyNames() - { - return new StringTokenizer(""); //$NON-NLS-1$ - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.ConnectionMetaData;
+
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+
+public class ConnectionMetaDataImpl implements ConnectionMetaData
+{
+ private ConnectionImpl connection;
+
+ public ConnectionMetaDataImpl(ConnectionImpl connection)
+ {
+ this.connection = connection;
+ }
+
+ public ConnectionImpl getConnection()
+ {
+ return connection;
+ }
+
+ public int getJMSMajorVersion()
+ {
+ return 1;
+ }
+
+ public int getJMSMinorVersion()
+ {
+ return 1;
+ }
+
+ public String getJMSVersion()
+ {
+ return "1.1"; //$NON-NLS-1$
+ }
+
+ public String getJMSProviderName()
+ {
+ return "Net4j JMS"; //$NON-NLS-1$
+ }
+
+ public int getProviderMajorVersion()
+ {
+ return 0;
+ }
+
+ public int getProviderMinorVersion()
+ {
+ return 8;
+ }
+
+ public String getProviderVersion()
+ {
+ return "0.8.0"; //$NON-NLS-1$
+ }
+
+ public Enumeration<?> getJMSXPropertyNames()
+ {
+ return new StringTokenizer(""); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/DestinationImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/DestinationImpl.java index 838aac456e..fb8db5df69 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/DestinationImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/DestinationImpl.java @@ -1,19 +1,19 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import java.io.Serializable; -import java.rmi.Remote; - -public abstract class DestinationImpl implements JMSDestination, Remote, Serializable -{ - private static final long serialVersionUID = 1L; -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+
+public abstract class DestinationImpl implements JMSDestination, Remote, Serializable
+{
+ private static final long serialVersionUID = 1L;
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSDestination.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSDestination.java index 5cd8325ad4..5e24076915 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSDestination.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSDestination.java @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.Destination; - -public interface JMSDestination extends Destination -{ - public String getName(); -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.Destination;
+
+public interface JMSDestination extends Destination
+{
+ public String getName();
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSTemporaryDestination.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSTemporaryDestination.java index 6fd7f15ff4..409acf33ce 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSTemporaryDestination.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/JMSTemporaryDestination.java @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -public interface JMSTemporaryDestination extends JMSDestination -{ - public ConnectionImpl getOwningConnection(); - - public long getConnectionId(); - - public boolean validForConnection(ConnectionImpl connection); -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+public interface JMSTemporaryDestination extends JMSDestination
+{
+ public ConnectionImpl getOwningConnection();
+
+ public long getConnectionId();
+
+ public boolean validForConnection(ConnectionImpl connection);
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MapMessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MapMessageImpl.java index 4989620976..39751c8ac6 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MapMessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MapMessageImpl.java @@ -1,175 +1,175 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; - -import java.io.IOException; -import java.util.Enumeration; - -public class MapMessageImpl extends MessageImpl implements MapMessage -{ - public boolean getBoolean(String name) - { - throw new NotYetImplementedException(); - } - - public byte getByte(String name) - { - throw new NotYetImplementedException(); - } - - public byte[] getBytes(String name) - { - throw new NotYetImplementedException(); - } - - public char getChar(String name) - { - throw new NotYetImplementedException(); - } - - public double getDouble(String name) - { - throw new NotYetImplementedException(); - } - - public float getFloat(String name) - { - throw new NotYetImplementedException(); - } - - public int getInt(String name) - { - throw new NotYetImplementedException(); - } - - public long getLong(String name) - { - throw new NotYetImplementedException(); - } - - public Enumeration<?> getMapNames() - { - throw new NotYetImplementedException(); - } - - public Object getObject(String name) - { - throw new NotYetImplementedException(); - } - - public short getShort(String name) - { - throw new NotYetImplementedException(); - } - - public String getString(String name) - { - throw new NotYetImplementedException(); - } - - public boolean itemExists(String name) - { - throw new NotYetImplementedException(); - } - - public void setBoolean(String name, boolean value) - { - throw new NotYetImplementedException(); - } - - public void setByte(String name, byte value) - { - throw new NotYetImplementedException(); - } - - public void setBytes(String name, byte[] value) - { - throw new NotYetImplementedException(); - } - - public void setBytes(String name, byte[] value, int offset, int length) - { - throw new NotYetImplementedException(); - } - - public void setChar(String name, char value) - { - throw new NotYetImplementedException(); - } - - public void setDouble(String name, double value) - { - throw new NotYetImplementedException(); - } - - public void setFloat(String name, float value) - { - throw new NotYetImplementedException(); - } - - public void setInt(String name, int value) - { - throw new NotYetImplementedException(); - } - - public void setLong(String name, long value) - { - throw new NotYetImplementedException(); - } - - public void setObject(String name, Object value) - { - throw new NotYetImplementedException(); - } - - public void setShort(String name, short value) - { - throw new NotYetImplementedException(); - } - - public void setString(String name, String value) - { - throw new NotYetImplementedException(); - } - - @Override - public void populate(Message source) throws JMSException - { - super.populate(source); - MapMessage map = (MapMessage)source; - Enumeration<?> e = map.getMapNames(); - while (e.hasMoreElements()) - { - String name = (String)e.nextElement(); - Object value = map.getObject(name); - setObject(name, value); - } - } - - @Override - public void write(ExtendedDataOutputStream out) throws IOException - { - super.write(out); - } - - @Override - public void read(ExtendedDataInputStream in) throws IOException - { - super.read(in); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+public class MapMessageImpl extends MessageImpl implements MapMessage
+{
+ public boolean getBoolean(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public byte getByte(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public byte[] getBytes(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public char getChar(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public double getDouble(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public float getFloat(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int getInt(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public long getLong(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Enumeration<?> getMapNames()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object getObject(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public short getShort(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String getString(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public boolean itemExists(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setBoolean(String name, boolean value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setByte(String name, byte value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setBytes(String name, byte[] value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setBytes(String name, byte[] value, int offset, int length)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setChar(String name, char value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setDouble(String name, double value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setFloat(String name, float value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setInt(String name, int value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setLong(String name, long value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setObject(String name, Object value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setShort(String name, short value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void setString(String name, String value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void populate(Message source) throws JMSException
+ {
+ super.populate(source);
+ MapMessage map = (MapMessage)source;
+ Enumeration<?> e = map.getMapNames();
+ while (e.hasMoreElements())
+ {
+ String name = (String)e.nextElement();
+ Object value = map.getObject(name);
+ setObject(name, value);
+ }
+ }
+
+ @Override
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ super.write(out);
+ }
+
+ @Override
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ super.read(in);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageConsumerImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageConsumerImpl.java index 53ce592ef7..d1192be2ef 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageConsumerImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageConsumerImpl.java @@ -1,160 +1,160 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.internal.jms.bundle.OM; -import org.eclipse.net4j.internal.jms.messages.Messages; -import org.eclipse.net4j.util.lifecycle.Lifecycle; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -public class MessageConsumerImpl extends Lifecycle implements MessageConsumer -{ - private static final long DO_NOT_WAIT = -1L; - - private SessionImpl session; - - private long consumerID; - - private DestinationImpl destination; - - private String messageSelector; - - private MessageListener messageListener; - - /** - * Incoming messages - */ - private BlockingQueue<MessageImpl> messages = new LinkedBlockingQueue<MessageImpl>(); - - public MessageConsumerImpl(SessionImpl session, long consumerID, DestinationImpl destination, String messageSelector) - { - this.session = session; - this.consumerID = consumerID; - this.destination = destination; - this.messageSelector = messageSelector; - } - - public SessionImpl getSession() - { - return session; - } - - public long getConsumerID() - { - return consumerID; - } - - public DestinationImpl getDestination() - { - return destination; - } - - public String getMessageSelector() - { - return messageSelector; - } - - public MessageListener getMessageListener() - { - return messageListener; - } - - public void setMessageListener(MessageListener listener) - { - messageListener = listener; - if (messageListener != null) - { - session.addWork(this); - } - } - - public Message receive() throws JMSException - { - return receive(Long.MAX_VALUE); - } - - public Message receive(long timeout) throws JMSException - { - if (messageListener != null) - { - throw new JMSException(Messages.getString("MessageConsumerImpl.0")); //$NON-NLS-1$ - } - - if (timeout == DO_NOT_WAIT) - { - return messages.poll(); - } - - try - { - return messages.poll(timeout, TimeUnit.MILLISECONDS); - } - catch (InterruptedException ex) - { - throw new JMSException(ex.getMessage()); - } - } - - public Message receiveNoWait() throws JMSException - { - return receive(DO_NOT_WAIT); - } - - public void close() - { - throw new NotYetImplementedException(); - } - - public void handleServerMessage(MessageImpl message) - { - messages.add(message); - if (messageListener != null) - { - session.addWork(this); - } - } - - public void dispatchMessage() - { - MessageListener listener = messageListener; - if (listener != null) - { - MessageImpl message = messages.poll(); - if (message == null) - { - OM.LOG.warn(Messages.getString("MessageConsumerImpl.1")); //$NON-NLS-1$ - return; - } - - try - { - listener.onMessage(message); - if (!session.getTransacted() && session.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE) - { - session.acknowledgeMessages(this); - } - } - catch (RuntimeException ex) - { - OM.LOG.warn(ex); - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.internal.jms.bundle.OM;
+import org.eclipse.net4j.internal.jms.messages.Messages;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class MessageConsumerImpl extends Lifecycle implements MessageConsumer
+{
+ private static final long DO_NOT_WAIT = -1L;
+
+ private SessionImpl session;
+
+ private long consumerID;
+
+ private DestinationImpl destination;
+
+ private String messageSelector;
+
+ private MessageListener messageListener;
+
+ /**
+ * Incoming messages
+ */
+ private BlockingQueue<MessageImpl> messages = new LinkedBlockingQueue<MessageImpl>();
+
+ public MessageConsumerImpl(SessionImpl session, long consumerID, DestinationImpl destination, String messageSelector)
+ {
+ this.session = session;
+ this.consumerID = consumerID;
+ this.destination = destination;
+ this.messageSelector = messageSelector;
+ }
+
+ public SessionImpl getSession()
+ {
+ return session;
+ }
+
+ public long getConsumerID()
+ {
+ return consumerID;
+ }
+
+ public DestinationImpl getDestination()
+ {
+ return destination;
+ }
+
+ public String getMessageSelector()
+ {
+ return messageSelector;
+ }
+
+ public MessageListener getMessageListener()
+ {
+ return messageListener;
+ }
+
+ public void setMessageListener(MessageListener listener)
+ {
+ messageListener = listener;
+ if (messageListener != null)
+ {
+ session.addWork(this);
+ }
+ }
+
+ public Message receive() throws JMSException
+ {
+ return receive(Long.MAX_VALUE);
+ }
+
+ public Message receive(long timeout) throws JMSException
+ {
+ if (messageListener != null)
+ {
+ throw new JMSException(Messages.getString("MessageConsumerImpl.0")); //$NON-NLS-1$
+ }
+
+ if (timeout == DO_NOT_WAIT)
+ {
+ return messages.poll();
+ }
+
+ try
+ {
+ return messages.poll(timeout, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+
+ public Message receiveNoWait() throws JMSException
+ {
+ return receive(DO_NOT_WAIT);
+ }
+
+ public void close()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void handleServerMessage(MessageImpl message)
+ {
+ messages.add(message);
+ if (messageListener != null)
+ {
+ session.addWork(this);
+ }
+ }
+
+ public void dispatchMessage()
+ {
+ MessageListener listener = messageListener;
+ if (listener != null)
+ {
+ MessageImpl message = messages.poll();
+ if (message == null)
+ {
+ OM.LOG.warn(Messages.getString("MessageConsumerImpl.1")); //$NON-NLS-1$
+ return;
+ }
+
+ try
+ {
+ listener.onMessage(message);
+ if (!session.getTransacted() && session.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE)
+ {
+ session.acknowledgeMessages(this);
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.warn(ex);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageImpl.java index 10c47ecc1f..8ab7963923 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageImpl.java @@ -1,464 +1,464 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.internal.jms.messages.Messages; -import org.eclipse.net4j.internal.jms.util.DestinationUtil; -import org.eclipse.net4j.internal.jms.util.TypeUtil; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageFormatException; -import javax.jms.Session; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -public class MessageImpl implements Message, Comparable<MessageImpl> -{ - private static final String[] KEYWORDS = { "and", "between", "escape", "in", "is", "like", "false", "null", "or", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ - "not", "true" }; //$NON-NLS-1$ //$NON-NLS-2$ - - private Map<String, Object> properties = new HashMap<String, Object>(); - - private byte[] correlationID; - - private int deliveryMode; - - private DestinationImpl destination; - - private long expiration; - - private String messageID; - - private int priority; - - private boolean redelivered; - - private DestinationImpl replyTo; - - private long timestamp; - - private String type; - - private SessionImpl receivingSession; - - private MessageConsumerImpl receivingConsumer; - - public MessageImpl() - { - } - - public SessionImpl getReceivingSession() - { - return receivingSession; - } - - public void setReceivingSession(SessionImpl receivingSession) - { - this.receivingSession = receivingSession; - } - - public MessageConsumerImpl getReceivingConsumer() - { - return receivingConsumer; - } - - public void setReceivingConsumer(MessageConsumerImpl receivingConsumer) - { - this.receivingConsumer = receivingConsumer; - } - - public String getJMSCorrelationID() - { - if (correlationID == null) - { - return null; - } - - return new String(correlationID); - } - - public void setJMSCorrelationID(String correlationID) - { - this.correlationID = correlationID == null ? null : correlationID.getBytes(); - } - - public byte[] getJMSCorrelationIDAsBytes() - { - return correlationID; - } - - public void setJMSCorrelationIDAsBytes(byte[] correlationID) - { - this.correlationID = correlationID; - } - - public int getJMSDeliveryMode() - { - return deliveryMode; - } - - public void setJMSDeliveryMode(int deliveryMode) - { - this.deliveryMode = deliveryMode; - } - - public Destination getJMSDestination() - { - return destination; - } - - public void setJMSDestination(Destination destination) throws JMSException - { - this.destination = DestinationUtil.convert(destination); - } - - public long getJMSExpiration() - { - return expiration; - } - - public void setJMSExpiration(long expiration) - { - this.expiration = expiration; - } - - public String getJMSMessageID() - { - return messageID; - } - - public void setJMSMessageID(String messageID) - { - this.messageID = messageID; - } - - public int getJMSPriority() - { - return priority; - } - - public void setJMSPriority(int priority) - { - this.priority = priority; - } - - public boolean getJMSRedelivered() - { - return redelivered; - } - - public void setJMSRedelivered(boolean redelivered) - { - this.redelivered = redelivered; - } - - public Destination getJMSReplyTo() - { - return replyTo; - } - - public void setJMSReplyTo(Destination replyTo) throws JMSException - { - this.replyTo = DestinationUtil.convert(replyTo); - } - - public long getJMSTimestamp() - { - return timestamp; - } - - public void setJMSTimestamp(long timestamp) - { - this.timestamp = timestamp; - } - - public String getJMSType() - { - return type; - } - - public void setJMSType(String type) - { - this.type = type; - } - - public void clearProperties() - { - properties.clear(); - } - - public boolean propertyExists(String name) - { - return properties.containsKey(name); - } - - public boolean getBooleanProperty(String name) throws MessageFormatException - { - return TypeUtil.getBoolean(properties.get(name)); - } - - public byte getByteProperty(String name) throws MessageFormatException - { - return TypeUtil.getByte(properties.get(name)); - } - - public short getShortProperty(String name) throws MessageFormatException - { - return TypeUtil.getShort(properties.get(name)); - } - - public int getIntProperty(String name) throws MessageFormatException - { - return TypeUtil.getInt(properties.get(name)); - } - - public long getLongProperty(String name) throws MessageFormatException - { - return TypeUtil.getLong(properties.get(name)); - } - - public float getFloatProperty(String name) throws MessageFormatException - { - return TypeUtil.getFloat(properties.get(name)); - } - - public double getDoubleProperty(String name) throws MessageFormatException - { - return TypeUtil.getDouble(properties.get(name)); - } - - public String getStringProperty(String name) throws MessageFormatException - { - return TypeUtil.getString(properties.get(name)); - } - - public Object getObjectProperty(String name) - { - return properties.get(name); - } - - public Enumeration<String> getPropertyNames() - { - return Collections.enumeration(properties.keySet()); - } - - public void setBooleanProperty(String name, boolean value) throws JMSException - { - setProperty(name, value); - } - - public void setByteProperty(String name, byte value) throws JMSException - { - setProperty(name, value); - } - - public void setShortProperty(String name, short value) throws JMSException - { - setProperty(name, value); - } - - public void setIntProperty(String name, int value) throws JMSException - { - setProperty(name, value); - } - - public void setLongProperty(String name, long value) throws JMSException - { - setProperty(name, value); - } - - public void setFloatProperty(String name, float value) throws JMSException - { - setProperty(name, value); - } - - public void setDoubleProperty(String name, double value) throws JMSException - { - setProperty(name, value); - } - - public void setStringProperty(String name, String value) throws JMSException - { - setProperty(name, value); - } - - public void setObjectProperty(String name, Object value) throws JMSException - { - if (value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer - || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String - || value == null) - { - setProperty(name, value); - } - else - { - throw new MessageFormatException(MessageFormat.format( - Messages.getString("MessageImpl_11"), value.getClass().getName())); //$NON-NLS-1$ - } - } - - protected void setProperty(String name, Object value) throws JMSException - { - if (name == null) - { - throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$ - } - - char[] chars = name.toCharArray(); - if (chars.length == 0) - { - throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$ - } - - if (!Character.isJavaIdentifierStart(chars[0])) - { - throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$ - } - - for (int i = 1; i < chars.length; ++i) - { - if (!Character.isJavaIdentifierPart(chars[i])) - { - throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$ - } - } - - for (int i = 0; i < KEYWORDS.length; ++i) - { - if (name.equalsIgnoreCase(KEYWORDS[i])) - { - throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$ - } - } - - properties.put(name, value); - } - - public void acknowledge() - { - if (receivingSession == null) - { - return; - } - - if (!receivingSession.isActive()) - { - return; - } - - if (receivingSession.getTransacted()) - { - return; - } - - if (receivingSession.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE) - { - return; - } - - receivingSession.acknowledgeMessages(receivingConsumer); - } - - public void clearBody() - { - throw new NotYetImplementedException(); - } - - public int compareTo(MessageImpl obj) - { - if (priority < obj.priority) - { - return -1; - } - - if (priority > obj.priority) - { - return 1; - } - - return 0; - } - - @SuppressWarnings("unchecked") - public void populate(Message source) throws JMSException - { - setJMSMessageID(source.getJMSMessageID()); - setJMSDestination(source.getJMSDestination()); - setJMSTimestamp(source.getJMSTimestamp()); - setJMSPriority(source.getJMSPriority()); - setJMSExpiration(source.getJMSExpiration()); - setJMSDeliveryMode(source.getJMSDeliveryMode()); - setJMSCorrelationID(source.getJMSCorrelationID()); - setJMSType(source.getJMSType()); - setJMSReplyTo(source.getJMSReplyTo()); - - Enumeration<String> e = source.getPropertyNames(); - while (e.hasMoreElements()) - { - String name = e.nextElement(); - Object value = source.getObjectProperty(name); - setObjectProperty(name, value); - } - } - - public void write(ExtendedDataOutputStream out) throws IOException - { - out.writeByteArray(correlationID); - out.writeByte(deliveryMode); - DestinationUtil.write(out, destination); - out.writeLong(expiration); - out.writeString(messageID); - out.writeByte(priority); - out.writeBoolean(redelivered); - DestinationUtil.write(out, replyTo); - out.writeLong(timestamp); - out.writeString(type); - - out.writeInt(properties.size()); - for (Entry<String, Object> entry : properties.entrySet()) - { - out.writeString(entry.getKey()); - TypeUtil.write(out, entry.getValue()); - } - } - - public void read(ExtendedDataInputStream in) throws IOException - { - correlationID = in.readByteArray(); - deliveryMode = in.readByte(); - destination = DestinationUtil.read(in); - expiration = in.readLong(); - messageID = in.readString(); - priority = in.readByte(); - redelivered = in.readBoolean(); - replyTo = DestinationUtil.read(in); - timestamp = in.readLong(); - type = in.readString(); - - int size = in.readInt(); - for (int i = 0; i < size; i++) - { - String key = in.readString(); - Object value = TypeUtil.read(in); - properties.put(key, value); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.internal.jms.messages.Messages;
+import org.eclipse.net4j.internal.jms.util.DestinationUtil;
+import org.eclipse.net4j.internal.jms.util.TypeUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageFormatException;
+import javax.jms.Session;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class MessageImpl implements Message, Comparable<MessageImpl>
+{
+ private static final String[] KEYWORDS = { "and", "between", "escape", "in", "is", "like", "false", "null", "or", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ "not", "true" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ private Map<String, Object> properties = new HashMap<String, Object>();
+
+ private byte[] correlationID;
+
+ private int deliveryMode;
+
+ private DestinationImpl destination;
+
+ private long expiration;
+
+ private String messageID;
+
+ private int priority;
+
+ private boolean redelivered;
+
+ private DestinationImpl replyTo;
+
+ private long timestamp;
+
+ private String type;
+
+ private SessionImpl receivingSession;
+
+ private MessageConsumerImpl receivingConsumer;
+
+ public MessageImpl()
+ {
+ }
+
+ public SessionImpl getReceivingSession()
+ {
+ return receivingSession;
+ }
+
+ public void setReceivingSession(SessionImpl receivingSession)
+ {
+ this.receivingSession = receivingSession;
+ }
+
+ public MessageConsumerImpl getReceivingConsumer()
+ {
+ return receivingConsumer;
+ }
+
+ public void setReceivingConsumer(MessageConsumerImpl receivingConsumer)
+ {
+ this.receivingConsumer = receivingConsumer;
+ }
+
+ public String getJMSCorrelationID()
+ {
+ if (correlationID == null)
+ {
+ return null;
+ }
+
+ return new String(correlationID);
+ }
+
+ public void setJMSCorrelationID(String correlationID)
+ {
+ this.correlationID = correlationID == null ? null : correlationID.getBytes();
+ }
+
+ public byte[] getJMSCorrelationIDAsBytes()
+ {
+ return correlationID;
+ }
+
+ public void setJMSCorrelationIDAsBytes(byte[] correlationID)
+ {
+ this.correlationID = correlationID;
+ }
+
+ public int getJMSDeliveryMode()
+ {
+ return deliveryMode;
+ }
+
+ public void setJMSDeliveryMode(int deliveryMode)
+ {
+ this.deliveryMode = deliveryMode;
+ }
+
+ public Destination getJMSDestination()
+ {
+ return destination;
+ }
+
+ public void setJMSDestination(Destination destination) throws JMSException
+ {
+ this.destination = DestinationUtil.convert(destination);
+ }
+
+ public long getJMSExpiration()
+ {
+ return expiration;
+ }
+
+ public void setJMSExpiration(long expiration)
+ {
+ this.expiration = expiration;
+ }
+
+ public String getJMSMessageID()
+ {
+ return messageID;
+ }
+
+ public void setJMSMessageID(String messageID)
+ {
+ this.messageID = messageID;
+ }
+
+ public int getJMSPriority()
+ {
+ return priority;
+ }
+
+ public void setJMSPriority(int priority)
+ {
+ this.priority = priority;
+ }
+
+ public boolean getJMSRedelivered()
+ {
+ return redelivered;
+ }
+
+ public void setJMSRedelivered(boolean redelivered)
+ {
+ this.redelivered = redelivered;
+ }
+
+ public Destination getJMSReplyTo()
+ {
+ return replyTo;
+ }
+
+ public void setJMSReplyTo(Destination replyTo) throws JMSException
+ {
+ this.replyTo = DestinationUtil.convert(replyTo);
+ }
+
+ public long getJMSTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setJMSTimestamp(long timestamp)
+ {
+ this.timestamp = timestamp;
+ }
+
+ public String getJMSType()
+ {
+ return type;
+ }
+
+ public void setJMSType(String type)
+ {
+ this.type = type;
+ }
+
+ public void clearProperties()
+ {
+ properties.clear();
+ }
+
+ public boolean propertyExists(String name)
+ {
+ return properties.containsKey(name);
+ }
+
+ public boolean getBooleanProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getBoolean(properties.get(name));
+ }
+
+ public byte getByteProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getByte(properties.get(name));
+ }
+
+ public short getShortProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getShort(properties.get(name));
+ }
+
+ public int getIntProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getInt(properties.get(name));
+ }
+
+ public long getLongProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getLong(properties.get(name));
+ }
+
+ public float getFloatProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getFloat(properties.get(name));
+ }
+
+ public double getDoubleProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getDouble(properties.get(name));
+ }
+
+ public String getStringProperty(String name) throws MessageFormatException
+ {
+ return TypeUtil.getString(properties.get(name));
+ }
+
+ public Object getObjectProperty(String name)
+ {
+ return properties.get(name);
+ }
+
+ public Enumeration<String> getPropertyNames()
+ {
+ return Collections.enumeration(properties.keySet());
+ }
+
+ public void setBooleanProperty(String name, boolean value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setByteProperty(String name, byte value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setShortProperty(String name, short value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setIntProperty(String name, int value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setLongProperty(String name, long value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setFloatProperty(String name, float value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setDoubleProperty(String name, double value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setStringProperty(String name, String value) throws JMSException
+ {
+ setProperty(name, value);
+ }
+
+ public void setObjectProperty(String name, Object value) throws JMSException
+ {
+ if (value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer
+ || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String
+ || value == null)
+ {
+ setProperty(name, value);
+ }
+ else
+ {
+ throw new MessageFormatException(MessageFormat.format(
+ Messages.getString("MessageImpl_11"), value.getClass().getName())); //$NON-NLS-1$
+ }
+ }
+
+ protected void setProperty(String name, Object value) throws JMSException
+ {
+ if (name == null)
+ {
+ throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$
+ }
+
+ char[] chars = name.toCharArray();
+ if (chars.length == 0)
+ {
+ throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$
+ }
+
+ if (!Character.isJavaIdentifierStart(chars[0]))
+ {
+ throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$
+ }
+
+ for (int i = 1; i < chars.length; ++i)
+ {
+ if (!Character.isJavaIdentifierPart(chars[i]))
+ {
+ throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$
+ }
+ }
+
+ for (int i = 0; i < KEYWORDS.length; ++i)
+ {
+ if (name.equalsIgnoreCase(KEYWORDS[i]))
+ {
+ throw new JMSException(MessageFormat.format(Messages.getString("MessageImpl_13"), name)); //$NON-NLS-1$
+ }
+ }
+
+ properties.put(name, value);
+ }
+
+ public void acknowledge()
+ {
+ if (receivingSession == null)
+ {
+ return;
+ }
+
+ if (!receivingSession.isActive())
+ {
+ return;
+ }
+
+ if (receivingSession.getTransacted())
+ {
+ return;
+ }
+
+ if (receivingSession.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE)
+ {
+ return;
+ }
+
+ receivingSession.acknowledgeMessages(receivingConsumer);
+ }
+
+ public void clearBody()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int compareTo(MessageImpl obj)
+ {
+ if (priority < obj.priority)
+ {
+ return -1;
+ }
+
+ if (priority > obj.priority)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void populate(Message source) throws JMSException
+ {
+ setJMSMessageID(source.getJMSMessageID());
+ setJMSDestination(source.getJMSDestination());
+ setJMSTimestamp(source.getJMSTimestamp());
+ setJMSPriority(source.getJMSPriority());
+ setJMSExpiration(source.getJMSExpiration());
+ setJMSDeliveryMode(source.getJMSDeliveryMode());
+ setJMSCorrelationID(source.getJMSCorrelationID());
+ setJMSType(source.getJMSType());
+ setJMSReplyTo(source.getJMSReplyTo());
+
+ Enumeration<String> e = source.getPropertyNames();
+ while (e.hasMoreElements())
+ {
+ String name = e.nextElement();
+ Object value = source.getObjectProperty(name);
+ setObjectProperty(name, value);
+ }
+ }
+
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ out.writeByteArray(correlationID);
+ out.writeByte(deliveryMode);
+ DestinationUtil.write(out, destination);
+ out.writeLong(expiration);
+ out.writeString(messageID);
+ out.writeByte(priority);
+ out.writeBoolean(redelivered);
+ DestinationUtil.write(out, replyTo);
+ out.writeLong(timestamp);
+ out.writeString(type);
+
+ out.writeInt(properties.size());
+ for (Entry<String, Object> entry : properties.entrySet())
+ {
+ out.writeString(entry.getKey());
+ TypeUtil.write(out, entry.getValue());
+ }
+ }
+
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ correlationID = in.readByteArray();
+ deliveryMode = in.readByte();
+ destination = DestinationUtil.read(in);
+ expiration = in.readLong();
+ messageID = in.readString();
+ priority = in.readByte();
+ redelivered = in.readBoolean();
+ replyTo = DestinationUtil.read(in);
+ timestamp = in.readLong();
+ type = in.readString();
+
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ String key = in.readString();
+ Object value = TypeUtil.read(in);
+ properties.put(key, value);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageProducerImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageProducerImpl.java index 04bbd6ec17..466e8b9ca5 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageProducerImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/MessageProducerImpl.java @@ -1,160 +1,160 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.internal.jms.messages.Messages; -import org.eclipse.net4j.util.lifecycle.Lifecycle; - -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageFormatException; -import javax.jms.MessageProducer; - -import java.util.Date; - -public class MessageProducerImpl extends Lifecycle implements MessageProducer -{ - private SessionImpl session; - - private DestinationImpl destination; - - private int deliveryMode = DeliveryMode.PERSISTENT; - - private int priority = Message.DEFAULT_PRIORITY; - - private long timeToLive; - - private boolean disableMessageTimestamp; - - private boolean disableMessageID; - - public MessageProducerImpl(SessionImpl session, DestinationImpl destination) - { - this.session = session; - this.destination = destination; - } - - public SessionImpl getSession() - { - return session; - } - - public int getDeliveryMode() - { - return deliveryMode; - } - - public void setDeliveryMode(int deliveryMode) - { - this.deliveryMode = deliveryMode; - } - - public int getPriority() - { - return priority; - } - - public void setPriority(int priority) - { - this.priority = priority; - } - - public long getTimeToLive() - { - return timeToLive; - } - - public void setTimeToLive(long timeToLive) - { - this.timeToLive = timeToLive; - } - - public DestinationImpl getDestination() - { - return destination; - } - - public boolean getDisableMessageID() - { - return disableMessageID; - } - - public void setDisableMessageID(boolean disableMessageID) - { - this.disableMessageID = disableMessageID; - } - - public boolean getDisableMessageTimestamp() - { - return disableMessageTimestamp; - } - - public void setDisableMessageTimestamp(boolean disableMessageTimestamp) - { - this.disableMessageTimestamp = disableMessageTimestamp; - } - - public void send(Message message) throws JMSException - { - send(getDestination(), message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException - { - send(getDestination(), message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void send(Destination destination, Message message) throws JMSException - { - send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) - throws JMSException - { - if (message == null) - { - throw new MessageFormatException(Messages.getString("MessageProducerImpl_0")); //$NON-NLS-1$ - } - - // message.setJMSMessageID(MessageId.create()); - message.setJMSDestination(destination); - message.setJMSTimestamp(new Date().getTime()); - message.setJMSPriority(priority); - - if (timeToLive > 0) - { - message.setJMSExpiration(System.currentTimeMillis() + timeToLive); - } - else - { - message.setJMSExpiration(0); - } - - if (destination instanceof JMSTemporaryDestination) - { - message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - else - { - message.setJMSDeliveryMode(deliveryMode); - } - - session.sendMessage(message); - } - - public void close() - { - throw new NotYetImplementedException(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.internal.jms.messages.Messages;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageProducer;
+
+import java.util.Date;
+
+public class MessageProducerImpl extends Lifecycle implements MessageProducer
+{
+ private SessionImpl session;
+
+ private DestinationImpl destination;
+
+ private int deliveryMode = DeliveryMode.PERSISTENT;
+
+ private int priority = Message.DEFAULT_PRIORITY;
+
+ private long timeToLive;
+
+ private boolean disableMessageTimestamp;
+
+ private boolean disableMessageID;
+
+ public MessageProducerImpl(SessionImpl session, DestinationImpl destination)
+ {
+ this.session = session;
+ this.destination = destination;
+ }
+
+ public SessionImpl getSession()
+ {
+ return session;
+ }
+
+ public int getDeliveryMode()
+ {
+ return deliveryMode;
+ }
+
+ public void setDeliveryMode(int deliveryMode)
+ {
+ this.deliveryMode = deliveryMode;
+ }
+
+ public int getPriority()
+ {
+ return priority;
+ }
+
+ public void setPriority(int priority)
+ {
+ this.priority = priority;
+ }
+
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive)
+ {
+ this.timeToLive = timeToLive;
+ }
+
+ public DestinationImpl getDestination()
+ {
+ return destination;
+ }
+
+ public boolean getDisableMessageID()
+ {
+ return disableMessageID;
+ }
+
+ public void setDisableMessageID(boolean disableMessageID)
+ {
+ this.disableMessageID = disableMessageID;
+ }
+
+ public boolean getDisableMessageTimestamp()
+ {
+ return disableMessageTimestamp;
+ }
+
+ public void setDisableMessageTimestamp(boolean disableMessageTimestamp)
+ {
+ this.disableMessageTimestamp = disableMessageTimestamp;
+ }
+
+ public void send(Message message) throws JMSException
+ {
+ send(getDestination(), message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ {
+ send(getDestination(), message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void send(Destination destination, Message message) throws JMSException
+ {
+ send(destination, message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive)
+ throws JMSException
+ {
+ if (message == null)
+ {
+ throw new MessageFormatException(Messages.getString("MessageProducerImpl_0")); //$NON-NLS-1$
+ }
+
+ // message.setJMSMessageID(MessageId.create());
+ message.setJMSDestination(destination);
+ message.setJMSTimestamp(new Date().getTime());
+ message.setJMSPriority(priority);
+
+ if (timeToLive > 0)
+ {
+ message.setJMSExpiration(System.currentTimeMillis() + timeToLive);
+ }
+ else
+ {
+ message.setJMSExpiration(0);
+ }
+
+ if (destination instanceof JMSTemporaryDestination)
+ {
+ message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ }
+ else
+ {
+ message.setJMSDeliveryMode(deliveryMode);
+ }
+
+ session.sendMessage(message);
+ }
+
+ public void close()
+ {
+ throw new NotYetImplementedException();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/NotYetImplementedException.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/NotYetImplementedException.java index fe75132182..f0901699d6 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/NotYetImplementedException.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/NotYetImplementedException.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -public class NotYetImplementedException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public NotYetImplementedException() - { - } - - public NotYetImplementedException(String message) - { - super(message); - } - - public NotYetImplementedException(Throwable cause) - { - super(cause); - } - - public NotYetImplementedException(String message, Throwable cause) - { - super(message, cause); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+public class NotYetImplementedException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public NotYetImplementedException()
+ {
+ }
+
+ public NotYetImplementedException(String message)
+ {
+ super(message);
+ }
+
+ public NotYetImplementedException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public NotYetImplementedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ObjectMessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ObjectMessageImpl.java index 476c1cbbd4..061fc7f578 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ObjectMessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/ObjectMessageImpl.java @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.internal.jms.bundle.OM; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.ObjectMessage; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -public class ObjectMessageImpl extends MessageImpl implements ObjectMessage -{ - private Serializable object; - - public ObjectMessageImpl() - { - } - - public ObjectMessageImpl(Serializable object) - { - this.object = object; - } - - public Serializable getObject() - { - return object; - } - - public void setObject(Serializable object) - { - this.object = object; - } - - @Override - public void populate(Message source) throws JMSException - { - super.populate(source); - ObjectMessage object = (ObjectMessage)source; - setObject(object.getObject()); - } - - @Override - public void write(ExtendedDataOutputStream out) throws IOException - { - super.write(out); - if (object != null) - { - out.writeBoolean(true); - ObjectOutputStream stream = new ObjectOutputStream(out); - stream.writeObject(object); - } - else - { - out.writeBoolean(false); - } - } - - @Override - public void read(ExtendedDataInputStream in) throws IOException - { - super.read(in); - boolean notNull = in.readBoolean(); - if (notNull) - { - try - { - ObjectInputStream stream = new ObjectInputStream(in); - object = (Serializable)stream.readObject(); - } - catch (ClassNotFoundException ex) - { - OM.LOG.error(ex); - throw new IOException(ex.getMessage()); - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.internal.jms.bundle.OM;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+public class ObjectMessageImpl extends MessageImpl implements ObjectMessage
+{
+ private Serializable object;
+
+ public ObjectMessageImpl()
+ {
+ }
+
+ public ObjectMessageImpl(Serializable object)
+ {
+ this.object = object;
+ }
+
+ public Serializable getObject()
+ {
+ return object;
+ }
+
+ public void setObject(Serializable object)
+ {
+ this.object = object;
+ }
+
+ @Override
+ public void populate(Message source) throws JMSException
+ {
+ super.populate(source);
+ ObjectMessage object = (ObjectMessage)source;
+ setObject(object.getObject());
+ }
+
+ @Override
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ super.write(out);
+ if (object != null)
+ {
+ out.writeBoolean(true);
+ ObjectOutputStream stream = new ObjectOutputStream(out);
+ stream.writeObject(object);
+ }
+ else
+ {
+ out.writeBoolean(false);
+ }
+ }
+
+ @Override
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ super.read(in);
+ boolean notNull = in.readBoolean();
+ if (notNull)
+ {
+ try
+ {
+ ObjectInputStream stream = new ObjectInputStream(in);
+ object = (Serializable)stream.readObject();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ OM.LOG.error(ex);
+ throw new IOException(ex.getMessage());
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueBrowserImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueBrowserImpl.java index 0997d6c871..3322e3cf7c 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueBrowserImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueBrowserImpl.java @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.Queue; -import javax.jms.QueueBrowser; - -import java.util.Enumeration; - -public class QueueBrowserImpl implements QueueBrowser -{ - private Queue queue; - - private String messageSelector; - - public QueueBrowserImpl(Queue queue, String messageSelector) - { - this.queue = queue; - this.messageSelector = messageSelector; - } - - public QueueBrowserImpl(Queue queue) - { - this(queue, null); - } - - public Queue getQueue() - { - return queue; - } - - public String getMessageSelector() - { - return messageSelector; - } - - public void close() - { - throw new NotYetImplementedException(); - } - - public Enumeration<?> getEnumeration() - { - throw new NotYetImplementedException(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+
+import java.util.Enumeration;
+
+public class QueueBrowserImpl implements QueueBrowser
+{
+ private Queue queue;
+
+ private String messageSelector;
+
+ public QueueBrowserImpl(Queue queue, String messageSelector)
+ {
+ this.queue = queue;
+ this.messageSelector = messageSelector;
+ }
+
+ public QueueBrowserImpl(Queue queue)
+ {
+ this(queue, null);
+ }
+
+ public Queue getQueue()
+ {
+ return queue;
+ }
+
+ public String getMessageSelector()
+ {
+ return messageSelector;
+ }
+
+ public void close()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Enumeration<?> getEnumeration()
+ {
+ throw new NotYetImplementedException();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueImpl.java index 4911e15972..17dedfd27e 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueImpl.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.Queue; - -public class QueueImpl extends DestinationImpl implements Queue -{ - private static final long serialVersionUID = 1L; - - private String queueName; - - public QueueImpl(String queueName) - { - this.queueName = queueName; - } - - public String getQueueName() - { - return queueName; - } - - public String getName() - { - return queueName; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.Queue;
+
+public class QueueImpl extends DestinationImpl implements Queue
+{
+ private static final long serialVersionUID = 1L;
+
+ private String queueName;
+
+ public QueueImpl(String queueName)
+ {
+ this.queueName = queueName;
+ }
+
+ public String getQueueName()
+ {
+ return queueName;
+ }
+
+ public String getName()
+ {
+ return queueName;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueReceiverImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueReceiverImpl.java index b25f28cbaa..624f858a29 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueReceiverImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueReceiverImpl.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.QueueReceiver; - -public class QueueReceiverImpl extends MessageConsumerImpl implements QueueReceiver -{ - public QueueReceiverImpl(SessionImpl session, int id, QueueImpl queue, String messageSelector) - { - super(session, id, queue, messageSelector); - } - - public QueueImpl getQueue() - { - return (QueueImpl)getDestination(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.QueueReceiver;
+
+public class QueueReceiverImpl extends MessageConsumerImpl implements QueueReceiver
+{
+ public QueueReceiverImpl(SessionImpl session, int id, QueueImpl queue, String messageSelector)
+ {
+ super(session, id, queue, messageSelector);
+ }
+
+ public QueueImpl getQueue()
+ {
+ return (QueueImpl)getDestination();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueSenderImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueSenderImpl.java index 97b9cebeb7..2d5472c580 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueSenderImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/QueueSenderImpl.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueSender; - -public class QueueSenderImpl extends MessageProducerImpl implements QueueSender -{ - public QueueSenderImpl(SessionImpl session, QueueImpl queue) - { - super(session, queue); - } - - public QueueImpl getQueue() - { - return (QueueImpl)getDestination(); - } - - public void send(Queue queue, Message message) throws JMSException - { - send(queue, message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException - { - super.send(queue, message, deliveryMode, priority, timeToLive); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueSender;
+
+public class QueueSenderImpl extends MessageProducerImpl implements QueueSender
+{
+ public QueueSenderImpl(SessionImpl session, QueueImpl queue)
+ {
+ super(session, queue);
+ }
+
+ public QueueImpl getQueue()
+ {
+ return (QueueImpl)getDestination();
+ }
+
+ public void send(Queue queue, Message message) throws JMSException
+ {
+ send(queue, message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ {
+ super.send(queue, message, deliveryMode, priority, timeToLive);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java index b6053b60e6..5b119fb86c 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/SessionImpl.java @@ -1,455 +1,455 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.internal.jms.bundle.OM; -import org.eclipse.net4j.internal.jms.messages.Messages; -import org.eclipse.net4j.internal.jms.protocol.JMSAcknowledgeRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSClientMessageRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSCommitRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSRecoverRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSRegisterConsumerRequest; -import org.eclipse.net4j.internal.jms.protocol.JMSRollbackRequest; -import org.eclipse.net4j.internal.jms.util.DestinationUtil; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.util.concurrent.QueueWorker; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; -import org.eclipse.net4j.util.om.log.OMLogger; - -import javax.jms.BytesMessage; -import javax.jms.Destination; -import javax.jms.IllegalStateException; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.Session; -import javax.jms.StreamMessage; -import javax.jms.TemporaryQueue; -import javax.jms.TemporaryTopic; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; -import javax.transaction.TransactionRolledbackException; - -import java.io.Serializable; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class SessionImpl extends QueueWorker<MessageConsumerImpl> implements Session -{ - private ConnectionImpl connection; - - private int id; - - private boolean transacted; - - private int acknowledgeMode; - - private Map<Long, MessageConsumerImpl> consumers = new HashMap<Long, MessageConsumerImpl>(); - - /** - * Outgoing transacted messages - */ - private List<MessageImpl> messages = new ArrayList<MessageImpl>(); - - private Set<MessageProducerImpl> producers = new HashSet<MessageProducerImpl>(); - - public SessionImpl(ConnectionImpl connection, int id, boolean transacted, int acknowledgeMode) throws JMSException - { - this.connection = connection; - this.id = id; - this.transacted = transacted; - this.acknowledgeMode = acknowledgeMode; - - try - { - activate(); - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - - public ConnectionImpl getConnection() - { - return connection; - } - - public int getID() - { - return id; - } - - public boolean getTransacted() - { - return transacted; - } - - public int getAcknowledgeMode() - { - return acknowledgeMode; - } - - public MessageListener getMessageListener() - { - return null; - } - - public void setMessageListener(MessageListener listener) - { - throw new UnsupportedOperationException(); - } - - public MessageProducer createProducer(Destination destination) throws JMSException - { - DestinationImpl dest = DestinationUtil.convert(destination); - MessageProducerImpl producer = new MessageProducerImpl(this, dest); - producers.add(producer); - return producer; - } - - public MessageConsumer createConsumer(Destination destination) throws JMSException - { - return createConsumer(destination, null); - } - - public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException - { - return createConsumer(destination, null, false); - } - - public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) - throws JMSException - { - DestinationImpl dest = DestinationUtil.convert(destination); - long consumerID = registerConsumer(dest, messageSelector, noLocal, false); - MessageConsumerImpl consumer = new MessageConsumerImpl(this, consumerID, dest, messageSelector); - consumers.put(consumerID, consumer); - return consumer; - } - - public Queue createQueue(String queueName) - { - return new QueueImpl(queueName); - } - - public TemporaryQueue createTemporaryQueue() - { - return new TemporaryQueueImpl(); - } - - public QueueBrowser createBrowser(Queue queue) - { - return new QueueBrowserImpl(queue); - } - - public QueueBrowser createBrowser(Queue queue, String messageSelector) - { - return new QueueBrowserImpl(queue, messageSelector); - } - - public Topic createTopic(String topicName) - { - return new TopicImpl(topicName); - } - - public TemporaryTopic createTemporaryTopic() - { - return new TemporaryTopicImpl(); - } - - public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException - { - return createDurableSubscriber(topic, name, null, false); - } - - public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) - throws JMSException - { - TopicImpl dest = (TopicImpl)DestinationUtil.convert(topic); - long consumerID = registerConsumer(dest, messageSelector, noLocal, true); - TopicSubscriberImpl subscriber = new TopicSubscriberImpl(this, consumerID, dest, name, messageSelector, noLocal); - consumers.put(consumerID, subscriber); - return subscriber; - } - - public void unsubscribe(String name) - { - throw new NotYetImplementedException(); - } - - public Message createMessage() - { - return new MessageImpl(); - } - - public StreamMessage createStreamMessage() - { - return new StreamMessageImpl(); - } - - public BytesMessage createBytesMessage() - { - return new BytesMessageImpl(); - } - - public MapMessage createMapMessage() - { - return new MapMessageImpl(); - } - - public ObjectMessage createObjectMessage() - { - return createObjectMessage(null); - } - - public ObjectMessage createObjectMessage(Serializable object) - { - return new ObjectMessageImpl(object); - } - - public TextMessage createTextMessage() - { - return createTextMessage(null); - } - - public TextMessage createTextMessage(String text) - { - return new TextMessageImpl(text); - } - - public void recover() throws JMSException - { - ensureNotTransacted(); - try - { - stop(); - new JMSRecoverRequest(connection.getProtocol(), id).send(); - start(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - close(); - } - } - - public void commit() throws JMSException - { - ensureTransacted(); - synchronized (messages) - { - try - { - String[] messageIDs = new JMSCommitRequest(connection.getProtocol(), id, messages).send(); - if (messageIDs == null) - { - throw new TransactionRolledbackException(Messages.getString("SessionImpl_0")); //$NON-NLS-1$ - } - - for (int i = 0; i < messageIDs.length; i++) - { - messages.get(i).setJMSMessageID(messageIDs[i]); - } - - messages.clear(); - } - catch (JMSException ex) - { - throw ex; - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - } - - public void rollback() throws JMSException - { - ensureTransacted(); - synchronized (messages) - { - try - { - if (!new JMSRollbackRequest(connection.getProtocol(), id).send()) - { - throw new JMSException(Messages.getString("SessionImpl_1")); //$NON-NLS-1$ - } - - messages.clear(); - } - catch (JMSException ex) - { - throw ex; - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - } - - public void close() - { - LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG); - } - - public void run() - { - throw new UnsupportedOperationException(); - } - - public long registerConsumer(DestinationImpl destination, String messageSelector, boolean noLocal, boolean durable) - throws JMSException - { - try - { - return new JMSRegisterConsumerRequest(connection.getProtocol(), id, destination, messageSelector, noLocal, - durable).send(); - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - - public void sendMessage(Message message) throws JMSException - { - if (getTransacted()) - { - synchronized (messages) - { - if (message instanceof MessageImpl) - { - messages.add(MessageUtil.copy(message)); - } - else - { - messages.add(MessageUtil.convert(message)); - } - } - } - else - { - try - { - MessageImpl impl = MessageUtil.convert(message); - JMSClientMessageRequest request = new JMSClientMessageRequest(connection.getProtocol(), impl); - String messageID = request.send(connection.getSendTimeout()); - if (messageID == null) - { - throw new JMSException(Messages.getString("SessionImpl_2")); //$NON-NLS-1$ - } - - message.setJMSMessageID(messageID); - } - catch (JMSException ex) - { - throw ex; - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new JMSException(ex.getMessage()); - } - } - } - - public boolean acknowledgeMessages(MessageConsumerImpl consumer) - { - try - { - new JMSAcknowledgeRequest(connection.getProtocol(), id).sendAsync(); - return true; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return true; - } - } - - public void handleServerMessage(long consumerID, MessageImpl message) - { - message.setReceivingSession(this); - MessageConsumerImpl consumer = consumers.get(consumerID); - if (consumer == null) - { - OM.LOG.warn(MessageFormat.format(Messages.getString("SessionImpl_3"), consumerID)); //$NON-NLS-1$ - return; - } - - consumer.handleServerMessage(message); - } - - @Override - protected String getThreadName() - { - return "jms-session"; //$NON-NLS-1$ - } - - /** - * @since 2.0 - */ - @Override - protected void work(WorkContext context, MessageConsumerImpl consumer) - { - consumer.dispatchMessage(); - } - - private void ensureTransacted() throws IllegalStateException - { - if (!transacted) - { - throw new IllegalStateException("Session " + id + " not transacted"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - private void ensureNotTransacted() throws IllegalStateException - { - if (transacted) - { - throw new IllegalStateException("Session " + id + " transacted"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - private void start() - { - } - - private void stop() - { - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.internal.jms.bundle.OM;
+import org.eclipse.net4j.internal.jms.messages.Messages;
+import org.eclipse.net4j.internal.jms.protocol.JMSAcknowledgeRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSClientMessageRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSCommitRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSRecoverRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSRegisterConsumerRequest;
+import org.eclipse.net4j.internal.jms.protocol.JMSRollbackRequest;
+import org.eclipse.net4j.internal.jms.util.DestinationUtil;
+import org.eclipse.net4j.internal.jms.util.MessageUtil;
+import org.eclipse.net4j.util.concurrent.QueueWorker;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.log.OMLogger;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.transaction.TransactionRolledbackException;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class SessionImpl extends QueueWorker<MessageConsumerImpl> implements Session
+{
+ private ConnectionImpl connection;
+
+ private int id;
+
+ private boolean transacted;
+
+ private int acknowledgeMode;
+
+ private Map<Long, MessageConsumerImpl> consumers = new HashMap<Long, MessageConsumerImpl>();
+
+ /**
+ * Outgoing transacted messages
+ */
+ private List<MessageImpl> messages = new ArrayList<MessageImpl>();
+
+ private Set<MessageProducerImpl> producers = new HashSet<MessageProducerImpl>();
+
+ public SessionImpl(ConnectionImpl connection, int id, boolean transacted, int acknowledgeMode) throws JMSException
+ {
+ this.connection = connection;
+ this.id = id;
+ this.transacted = transacted;
+ this.acknowledgeMode = acknowledgeMode;
+
+ try
+ {
+ activate();
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+
+ public ConnectionImpl getConnection()
+ {
+ return connection;
+ }
+
+ public int getID()
+ {
+ return id;
+ }
+
+ public boolean getTransacted()
+ {
+ return transacted;
+ }
+
+ public int getAcknowledgeMode()
+ {
+ return acknowledgeMode;
+ }
+
+ public MessageListener getMessageListener()
+ {
+ return null;
+ }
+
+ public void setMessageListener(MessageListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public MessageProducer createProducer(Destination destination) throws JMSException
+ {
+ DestinationImpl dest = DestinationUtil.convert(destination);
+ MessageProducerImpl producer = new MessageProducerImpl(this, dest);
+ producers.add(producer);
+ return producer;
+ }
+
+ public MessageConsumer createConsumer(Destination destination) throws JMSException
+ {
+ return createConsumer(destination, null);
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException
+ {
+ return createConsumer(destination, null, false);
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal)
+ throws JMSException
+ {
+ DestinationImpl dest = DestinationUtil.convert(destination);
+ long consumerID = registerConsumer(dest, messageSelector, noLocal, false);
+ MessageConsumerImpl consumer = new MessageConsumerImpl(this, consumerID, dest, messageSelector);
+ consumers.put(consumerID, consumer);
+ return consumer;
+ }
+
+ public Queue createQueue(String queueName)
+ {
+ return new QueueImpl(queueName);
+ }
+
+ public TemporaryQueue createTemporaryQueue()
+ {
+ return new TemporaryQueueImpl();
+ }
+
+ public QueueBrowser createBrowser(Queue queue)
+ {
+ return new QueueBrowserImpl(queue);
+ }
+
+ public QueueBrowser createBrowser(Queue queue, String messageSelector)
+ {
+ return new QueueBrowserImpl(queue, messageSelector);
+ }
+
+ public Topic createTopic(String topicName)
+ {
+ return new TopicImpl(topicName);
+ }
+
+ public TemporaryTopic createTemporaryTopic()
+ {
+ return new TemporaryTopicImpl();
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
+ {
+ return createDurableSubscriber(topic, name, null, false);
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal)
+ throws JMSException
+ {
+ TopicImpl dest = (TopicImpl)DestinationUtil.convert(topic);
+ long consumerID = registerConsumer(dest, messageSelector, noLocal, true);
+ TopicSubscriberImpl subscriber = new TopicSubscriberImpl(this, consumerID, dest, name, messageSelector, noLocal);
+ consumers.put(consumerID, subscriber);
+ return subscriber;
+ }
+
+ public void unsubscribe(String name)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Message createMessage()
+ {
+ return new MessageImpl();
+ }
+
+ public StreamMessage createStreamMessage()
+ {
+ return new StreamMessageImpl();
+ }
+
+ public BytesMessage createBytesMessage()
+ {
+ return new BytesMessageImpl();
+ }
+
+ public MapMessage createMapMessage()
+ {
+ return new MapMessageImpl();
+ }
+
+ public ObjectMessage createObjectMessage()
+ {
+ return createObjectMessage(null);
+ }
+
+ public ObjectMessage createObjectMessage(Serializable object)
+ {
+ return new ObjectMessageImpl(object);
+ }
+
+ public TextMessage createTextMessage()
+ {
+ return createTextMessage(null);
+ }
+
+ public TextMessage createTextMessage(String text)
+ {
+ return new TextMessageImpl(text);
+ }
+
+ public void recover() throws JMSException
+ {
+ ensureNotTransacted();
+ try
+ {
+ stop();
+ new JMSRecoverRequest(connection.getProtocol(), id).send();
+ start();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ close();
+ }
+ }
+
+ public void commit() throws JMSException
+ {
+ ensureTransacted();
+ synchronized (messages)
+ {
+ try
+ {
+ String[] messageIDs = new JMSCommitRequest(connection.getProtocol(), id, messages).send();
+ if (messageIDs == null)
+ {
+ throw new TransactionRolledbackException(Messages.getString("SessionImpl_0")); //$NON-NLS-1$
+ }
+
+ for (int i = 0; i < messageIDs.length; i++)
+ {
+ messages.get(i).setJMSMessageID(messageIDs[i]);
+ }
+
+ messages.clear();
+ }
+ catch (JMSException ex)
+ {
+ throw ex;
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+ }
+
+ public void rollback() throws JMSException
+ {
+ ensureTransacted();
+ synchronized (messages)
+ {
+ try
+ {
+ if (!new JMSRollbackRequest(connection.getProtocol(), id).send())
+ {
+ throw new JMSException(Messages.getString("SessionImpl_1")); //$NON-NLS-1$
+ }
+
+ messages.clear();
+ }
+ catch (JMSException ex)
+ {
+ throw ex;
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+ }
+
+ public void close()
+ {
+ LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG);
+ }
+
+ public void run()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long registerConsumer(DestinationImpl destination, String messageSelector, boolean noLocal, boolean durable)
+ throws JMSException
+ {
+ try
+ {
+ return new JMSRegisterConsumerRequest(connection.getProtocol(), id, destination, messageSelector, noLocal,
+ durable).send();
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+
+ public void sendMessage(Message message) throws JMSException
+ {
+ if (getTransacted())
+ {
+ synchronized (messages)
+ {
+ if (message instanceof MessageImpl)
+ {
+ messages.add(MessageUtil.copy(message));
+ }
+ else
+ {
+ messages.add(MessageUtil.convert(message));
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ MessageImpl impl = MessageUtil.convert(message);
+ JMSClientMessageRequest request = new JMSClientMessageRequest(connection.getProtocol(), impl);
+ String messageID = request.send(connection.getSendTimeout());
+ if (messageID == null)
+ {
+ throw new JMSException(Messages.getString("SessionImpl_2")); //$NON-NLS-1$
+ }
+
+ message.setJMSMessageID(messageID);
+ }
+ catch (JMSException ex)
+ {
+ throw ex;
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new JMSException(ex.getMessage());
+ }
+ }
+ }
+
+ public boolean acknowledgeMessages(MessageConsumerImpl consumer)
+ {
+ try
+ {
+ new JMSAcknowledgeRequest(connection.getProtocol(), id).sendAsync();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ return true;
+ }
+ }
+
+ public void handleServerMessage(long consumerID, MessageImpl message)
+ {
+ message.setReceivingSession(this);
+ MessageConsumerImpl consumer = consumers.get(consumerID);
+ if (consumer == null)
+ {
+ OM.LOG.warn(MessageFormat.format(Messages.getString("SessionImpl_3"), consumerID)); //$NON-NLS-1$
+ return;
+ }
+
+ consumer.handleServerMessage(message);
+ }
+
+ @Override
+ protected String getThreadName()
+ {
+ return "jms-session"; //$NON-NLS-1$
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ protected void work(WorkContext context, MessageConsumerImpl consumer)
+ {
+ consumer.dispatchMessage();
+ }
+
+ private void ensureTransacted() throws IllegalStateException
+ {
+ if (!transacted)
+ {
+ throw new IllegalStateException("Session " + id + " not transacted"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ private void ensureNotTransacted() throws IllegalStateException
+ {
+ if (transacted)
+ {
+ throw new IllegalStateException("Session " + id + " transacted"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ private void start()
+ {
+ }
+
+ private void stop()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/StreamMessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/StreamMessageImpl.java index 500932787f..1e11159b93 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/StreamMessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/StreamMessageImpl.java @@ -1,175 +1,175 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageEOFException; -import javax.jms.StreamMessage; - -import java.io.IOException; - -public class StreamMessageImpl extends MessageImpl implements StreamMessage -{ - public boolean readBoolean() - { - throw new NotYetImplementedException(); - } - - public byte readByte() - { - throw new NotYetImplementedException(); - } - - public int readBytes(byte[] value) - { - throw new NotYetImplementedException(); - } - - public char readChar() - { - throw new NotYetImplementedException(); - } - - public double readDouble() - { - throw new NotYetImplementedException(); - } - - public float readFloat() - { - throw new NotYetImplementedException(); - } - - public int readInt() - { - throw new NotYetImplementedException(); - } - - public long readLong() - { - throw new NotYetImplementedException(); - } - - public Object readObject() - { - throw new NotYetImplementedException(); - } - - public short readShort() - { - throw new NotYetImplementedException(); - } - - public String readString() - { - throw new NotYetImplementedException(); - } - - public void reset() - { - throw new NotYetImplementedException(); - } - - public void writeBoolean(boolean value) - { - throw new NotYetImplementedException(); - } - - public void writeByte(byte value) - { - throw new NotYetImplementedException(); - } - - public void writeBytes(byte[] value) - { - throw new NotYetImplementedException(); - } - - public void writeBytes(byte[] value, int offset, int length) - { - throw new NotYetImplementedException(); - } - - public void writeChar(char value) - { - throw new NotYetImplementedException(); - } - - public void writeDouble(double value) - { - throw new NotYetImplementedException(); - } - - public void writeFloat(float value) - { - throw new NotYetImplementedException(); - } - - public void writeInt(int value) - { - throw new NotYetImplementedException(); - } - - public void writeLong(long value) - { - throw new NotYetImplementedException(); - } - - public void writeObject(Object value) - { - throw new NotYetImplementedException(); - } - - public void writeShort(short value) - { - throw new NotYetImplementedException(); - } - - public void writeString(String value) - { - throw new NotYetImplementedException(); - } - - @Override - public void populate(Message source) throws JMSException - { - super.populate(source); - StreamMessage from = (StreamMessage)source; - from.reset(); - try - { - while (true) - { - Object object = from.readObject(); - writeObject(object); - } - } - catch (MessageEOFException ignore) - { - } - } - - @Override - public void write(ExtendedDataOutputStream out) throws IOException - { - super.write(out); - } - - @Override - public void read(ExtendedDataInputStream in) throws IOException - { - super.read(in); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageEOFException;
+import javax.jms.StreamMessage;
+
+import java.io.IOException;
+
+public class StreamMessageImpl extends MessageImpl implements StreamMessage
+{
+ public boolean readBoolean()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public byte readByte()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readBytes(byte[] value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public char readChar()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public double readDouble()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public float readFloat()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public int readInt()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public long readLong()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object readObject()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public short readShort()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String readString()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void reset()
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBoolean(boolean value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeByte(byte value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBytes(byte[] value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeBytes(byte[] value, int offset, int length)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeChar(char value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeDouble(double value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeFloat(float value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeInt(int value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeLong(long value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeObject(Object value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeShort(short value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void writeString(String value)
+ {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void populate(Message source) throws JMSException
+ {
+ super.populate(source);
+ StreamMessage from = (StreamMessage)source;
+ from.reset();
+ try
+ {
+ while (true)
+ {
+ Object object = from.readObject();
+ writeObject(object);
+ }
+ }
+ catch (MessageEOFException ignore)
+ {
+ }
+ }
+
+ @Override
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ super.write(out);
+ }
+
+ @Override
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ super.read(in);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryQueueImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryQueueImpl.java index 64552d868c..ee897db306 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryQueueImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryQueueImpl.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.TemporaryQueue; - -public class TemporaryQueueImpl extends QueueImpl implements TemporaryQueue -{ - private static final long serialVersionUID = 1L; - - private static int counter; - - public TemporaryQueueImpl() - { - super("TempQueue" + ++counter); //$NON-NLS-1$ - } - - public void delete() - { - throw new NotYetImplementedException(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.TemporaryQueue;
+
+public class TemporaryQueueImpl extends QueueImpl implements TemporaryQueue
+{
+ private static final long serialVersionUID = 1L;
+
+ private static int counter;
+
+ public TemporaryQueueImpl()
+ {
+ super("TempQueue" + ++counter); //$NON-NLS-1$
+ }
+
+ public void delete()
+ {
+ throw new NotYetImplementedException();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryTopicImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryTopicImpl.java index 81c8c4284b..e955ed5a2d 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryTopicImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TemporaryTopicImpl.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.TemporaryTopic; - -public class TemporaryTopicImpl extends TopicImpl implements TemporaryTopic -{ - private static final long serialVersionUID = 1L; - - private static int counter; - - public TemporaryTopicImpl() - { - super("TempTopic" + ++counter); //$NON-NLS-1$ - } - - public void delete() - { - throw new NotYetImplementedException(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.TemporaryTopic;
+
+public class TemporaryTopicImpl extends TopicImpl implements TemporaryTopic
+{
+ private static final long serialVersionUID = 1L;
+
+ private static int counter;
+
+ public TemporaryTopicImpl()
+ {
+ super("TempTopic" + ++counter); //$NON-NLS-1$
+ }
+
+ public void delete()
+ {
+ throw new NotYetImplementedException();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TextMessageImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TextMessageImpl.java index a446109970..3fed516422 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TextMessageImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TextMessageImpl.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.TextMessage; - -import java.io.IOException; - -public class TextMessageImpl extends MessageImpl implements TextMessage -{ - private String text; - - public TextMessageImpl() - { - } - - public TextMessageImpl(String text) - { - this.text = text; - } - - public String getText() - { - return text; - } - - public void setText(String text) - { - this.text = text; - } - - @Override - public void populate(Message source) throws JMSException - { - super.populate(source); - TextMessage text = (TextMessage)source; - setText(text.getText()); - } - - @Override - public void write(ExtendedDataOutputStream out) throws IOException - { - super.write(out); - out.writeString(text); - } - - @Override - public void read(ExtendedDataInputStream in) throws IOException - { - super.read(in); - text = in.readString(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+
+public class TextMessageImpl extends MessageImpl implements TextMessage
+{
+ private String text;
+
+ public TextMessageImpl()
+ {
+ }
+
+ public TextMessageImpl(String text)
+ {
+ this.text = text;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+ @Override
+ public void populate(Message source) throws JMSException
+ {
+ super.populate(source);
+ TextMessage text = (TextMessage)source;
+ setText(text.getText());
+ }
+
+ @Override
+ public void write(ExtendedDataOutputStream out) throws IOException
+ {
+ super.write(out);
+ out.writeString(text);
+ }
+
+ @Override
+ public void read(ExtendedDataInputStream in) throws IOException
+ {
+ super.read(in);
+ text = in.readString();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicImpl.java index 5aa7353062..f9b45c8825 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicImpl.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.Topic; - -public class TopicImpl extends DestinationImpl implements Topic -{ - private static final long serialVersionUID = 1L; - - private String topicName; - - public TopicImpl(String topicName) - { - this.topicName = topicName; - } - - public String getTopicName() - { - return topicName; - } - - public String getName() - { - return topicName; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.Topic;
+
+public class TopicImpl extends DestinationImpl implements Topic
+{
+ private static final long serialVersionUID = 1L;
+
+ private String topicName;
+
+ public TopicImpl(String topicName)
+ {
+ this.topicName = topicName;
+ }
+
+ public String getTopicName()
+ {
+ return topicName;
+ }
+
+ public String getName()
+ {
+ return topicName;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicPublisherImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicPublisherImpl.java index 10c0e7bc6a..f140b04081 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicPublisherImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicPublisherImpl.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Topic; -import javax.jms.TopicPublisher; - -public class TopicPublisherImpl extends MessageProducerImpl implements TopicPublisher -{ - public TopicPublisherImpl(SessionImpl session, TopicImpl topic) - { - super(session, topic); - } - - public TopicImpl getTopic() - { - return (TopicImpl)getDestination(); - } - - public void publish(Message message) throws JMSException - { - publish(getTopic(), message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void publish(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException - { - publish(getTopic(), message, deliveryMode, priority, timeToLive); - } - - public void publish(Topic topic, Message message) throws JMSException - { - publish(topic, message, getDeliveryMode(), getPriority(), getTimeToLive()); - } - - public void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive) - throws JMSException - { - send(topic, message, deliveryMode, priority, timeToLive); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Topic;
+import javax.jms.TopicPublisher;
+
+public class TopicPublisherImpl extends MessageProducerImpl implements TopicPublisher
+{
+ public TopicPublisherImpl(SessionImpl session, TopicImpl topic)
+ {
+ super(session, topic);
+ }
+
+ public TopicImpl getTopic()
+ {
+ return (TopicImpl)getDestination();
+ }
+
+ public void publish(Message message) throws JMSException
+ {
+ publish(getTopic(), message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void publish(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ {
+ publish(getTopic(), message, deliveryMode, priority, timeToLive);
+ }
+
+ public void publish(Topic topic, Message message) throws JMSException
+ {
+ publish(topic, message, getDeliveryMode(), getPriority(), getTimeToLive());
+ }
+
+ public void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive)
+ throws JMSException
+ {
+ send(topic, message, deliveryMode, priority, timeToLive);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicSubscriberImpl.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicSubscriberImpl.java index 118d3d68a1..fdad08fa6b 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicSubscriberImpl.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/TopicSubscriberImpl.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms; - -import javax.jms.TopicSubscriber; - -public class TopicSubscriberImpl extends MessageConsumerImpl implements TopicSubscriber -{ - private String name; - - private boolean noLocal; - - public TopicSubscriberImpl(SessionImpl session, long id, TopicImpl topic, String name, String messageSelector, - boolean noLocal) - { - super(session, id, topic, messageSelector); - this.name = name; - this.noLocal = noLocal; - } - - public boolean getNoLocal() - { - return noLocal; - } - - public TopicImpl getTopic() - { - return (TopicImpl)getDestination(); - } - - public String getName() - { - return name; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms;
+
+import javax.jms.TopicSubscriber;
+
+public class TopicSubscriberImpl extends MessageConsumerImpl implements TopicSubscriber
+{
+ private String name;
+
+ private boolean noLocal;
+
+ public TopicSubscriberImpl(SessionImpl session, long id, TopicImpl topic, String name, String messageSelector,
+ boolean noLocal)
+ {
+ super(session, id, topic, messageSelector);
+ this.name = name;
+ this.noLocal = noLocal;
+ }
+
+ public boolean getNoLocal()
+ {
+ return noLocal;
+ }
+
+ public TopicImpl getTopic()
+ {
+ return (TopicImpl)getDestination();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java index 027c5c94d6..7972fce01d 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/bundle/OM.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.bundle; - -import org.eclipse.net4j.jms.JMSUtil; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.OSGiActivator; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -/** - * The <em>Operations & Maintenance</em> class of this bundle. - * - * @author Eike Stepper - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.net4j.jms"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - static void start() throws Exception - { - JMSUtil.setTransportContainer(IPluginContainer.INSTANCE); - } - - /** - * @author Eike Stepper - */ - public static final class Activator extends OSGiActivator - { - public Activator() - { - super(BUNDLE); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.bundle;
+
+import org.eclipse.net4j.jms.JMSUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.net4j.jms"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ static void start() throws Exception
+ {
+ JMSUtil.setTransportContainer(IPluginContainer.INSTANCE);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/Messages.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/Messages.java index eb233881ef..023d27691c 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/Messages.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/Messages.java @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Victor Roldan Betancort - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.net4j.internal.jms.messages; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * @author Victor Roldan Betancort - */ -public class Messages -{ - private static final String BUNDLE_NAME = "org.eclipse.net4j.internal.jms.messages.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() - { - } - - public static String getString(String key) - { - try - { - return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) - { - return '!' + key + '!'; - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.internal.jms.messages;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.eclipse.net4j.internal.jms.messages.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/messages.properties b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/messages.properties index 1077c50a49..1ce563b4f2 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/messages.properties +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/messages/messages.properties @@ -1,22 +1,22 @@ -# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Victor Roldan Betancort - initial API and implementation -# Eike Stepper - maintenance - -ConnectionImpl_0=No transport container available -ConnectionImpl_1=Server rejected logon request -ConnectionImpl_2=Server rejected open session request -MessageConsumerImpl.0=Consumer is configured for asynchronous delivery -MessageConsumerImpl.1=No message to dispatch -MessageImpl_11=Values of type {0} are not supported -MessageImpl_13=Invalid property name {0} -MessageProducerImpl_0=Null message -SessionImpl_0=Transaction rolled back by JMS server -SessionImpl_1=JMS server failed to rolled back transaction -SessionImpl_2=Message not accepted by JMS server -SessionImpl_3=Consumer {0} not found. Discarding message. +# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Victor Roldan Betancort - initial API and implementation
+# Eike Stepper - maintenance
+
+ConnectionImpl_0=No transport container available
+ConnectionImpl_1=Server rejected logon request
+ConnectionImpl_2=Server rejected open session request
+MessageConsumerImpl.0=Consumer is configured for asynchronous delivery
+MessageConsumerImpl.1=No message to dispatch
+MessageImpl_11=Values of type {0} are not supported
+MessageImpl_13=Invalid property name {0}
+MessageProducerImpl_0=Null message
+SessionImpl_0=Transaction rolled back by JMS server
+SessionImpl_1=JMS server failed to rolled back transaction
+SessionImpl_2=Message not accepted by JMS server
+SessionImpl_3=Consumer {0} not found. Discarding message.
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java index 19e09dbf4d..5e3637a033 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSAcknowledgeRequest.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSAcknowledgeRequest extends Request -{ - private int sessionID; - - /** - * @since 2.0 - */ - public JMSAcknowledgeRequest(JMSClientProtocol protocol, int sessionID) - { - super(protocol, JMSProtocolConstants.SIGNAL_ACKNOWLEDGE); - this.sessionID = sessionID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSAcknowledgeRequest extends Request
+{
+ private int sessionID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSAcknowledgeRequest(JMSClientProtocol protocol, int sessionID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_ACKNOWLEDGE);
+ this.sessionID = sessionID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java index 538a4b7c25..7bf00843a9 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientMessageRequest.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSClientMessageRequest extends RequestWithConfirmation<String> -{ - private MessageImpl message; - - /** - * @since 2.0 - */ - public JMSClientMessageRequest(JMSClientProtocol protocol, MessageImpl message) - { - super(protocol, JMSProtocolConstants.SIGNAL_CLIENT_MESSAGE); - this.message = message; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - MessageUtil.write(out, message); - } - - @Override - protected String confirming(ExtendedDataInputStream in) throws Exception - { - return in.readString(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.internal.jms.MessageImpl;
+import org.eclipse.net4j.internal.jms.util.MessageUtil;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSClientMessageRequest extends RequestWithConfirmation<String>
+{
+ private MessageImpl message;
+
+ /**
+ * @since 2.0
+ */
+ public JMSClientMessageRequest(JMSClientProtocol protocol, MessageImpl message)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_CLIENT_MESSAGE);
+ this.message = message;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ MessageUtil.write(out, message);
+ }
+
+ @Override
+ protected String confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readString();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java index a9d9faf77f..8f4db31d6e 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSClientProtocol.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.internal.jms.ConnectionImpl; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.signal.SignalReactor; - -/** - * @author Eike Stepper - */ -public class JMSClientProtocol extends SignalProtocol<ConnectionImpl> -{ - /** - * @since 2.0 - */ - public JMSClientProtocol(ConnectionImpl connection) - { - super(JMSProtocolConstants.PROTOCOL_NAME); - setInfraStructure(connection); - } - - @Override - protected SignalReactor createSignalReactor(short signalID) - { - switch (signalID) - { - case JMSProtocolConstants.SIGNAL_SERVER_MESSAGE: - return new JMSServerMessageIndication(this); - - default: - return super.createSignalReactor(signalID); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.internal.jms.ConnectionImpl;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSClientProtocol extends SignalProtocol<ConnectionImpl>
+{
+ /**
+ * @since 2.0
+ */
+ public JMSClientProtocol(ConnectionImpl connection)
+ {
+ super(JMSProtocolConstants.PROTOCOL_NAME);
+ setInfraStructure(connection);
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case JMSProtocolConstants.SIGNAL_SERVER_MESSAGE:
+ return new JMSServerMessageIndication(this);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java index 39e15ca3cb..3bc2c81e19 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCloseSessionRequest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSCloseSessionRequest extends RequestWithConfirmation<Boolean> -{ - private int sessionID; - - /** - * @since 2.0 - */ - public JMSCloseSessionRequest(JMSClientProtocol protocol, int sessionID) - { - super(protocol, JMSProtocolConstants.SIGNAL_CLOSE_SESSION); - this.sessionID = sessionID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - } - - @Override - protected Boolean confirming(ExtendedDataInputStream in) throws Exception - { - return in.readBoolean(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSCloseSessionRequest extends RequestWithConfirmation<Boolean>
+{
+ private int sessionID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSCloseSessionRequest(JMSClientProtocol protocol, int sessionID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_CLOSE_SESSION);
+ this.sessionID = sessionID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCommitRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCommitRequest.java index 12f95fc665..c34c7fa754 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCommitRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSCommitRequest.java @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.util.List; - -/** - * @author Eike Stepper - */ -public class JMSCommitRequest extends RequestWithConfirmation<String[]> -{ - private int sessionID; - - private List<MessageImpl> messages; - - /** - * @since 2.0 - */ - public JMSCommitRequest(JMSClientProtocol protocol, int sessionID, List<MessageImpl> messages) - { - super(protocol, JMSProtocolConstants.SIGNAL_COMMIT); - this.sessionID = sessionID; - this.messages = messages; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - out.writeInt(messages.size()); - for (MessageImpl message : messages) - { - MessageUtil.write(out, message); - } - } - - @Override - protected String[] confirming(ExtendedDataInputStream in) throws Exception - { - int size = in.readInt(); - if (size == -1) - { - return null; - } - - String[] messageIDs = new String[size]; - for (int i = 0; i < size; i++) - { - messageIDs[i] = in.readString(); - } - - return messageIDs; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.internal.jms.MessageImpl;
+import org.eclipse.net4j.internal.jms.util.MessageUtil;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSCommitRequest extends RequestWithConfirmation<String[]>
+{
+ private int sessionID;
+
+ private List<MessageImpl> messages;
+
+ /**
+ * @since 2.0
+ */
+ public JMSCommitRequest(JMSClientProtocol protocol, int sessionID, List<MessageImpl> messages)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_COMMIT);
+ this.sessionID = sessionID;
+ this.messages = messages;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ out.writeInt(messages.size());
+ for (MessageImpl message : messages)
+ {
+ MessageUtil.write(out, message);
+ }
+ }
+
+ @Override
+ protected String[] confirming(ExtendedDataInputStream in) throws Exception
+ {
+ int size = in.readInt();
+ if (size == -1)
+ {
+ return null;
+ }
+
+ String[] messageIDs = new String[size];
+ for (int i = 0; i < size; i++)
+ {
+ messageIDs[i] = in.readString();
+ }
+
+ return messageIDs;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java index 2ea706c80d..0782d06af1 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSDeregisterConsumerRequest.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSDeregisterConsumerRequest extends RequestWithConfirmation<Boolean> -{ - private int sessionID; - - private long consumerID; - - /** - * @since 2.0 - */ - public JMSDeregisterConsumerRequest(JMSClientProtocol protocol, int sessionID, long consumerID) - { - super(protocol, JMSProtocolConstants.SIGNAL_DEREGISTER_CONSUMER); - this.sessionID = sessionID; - this.consumerID = consumerID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - out.writeLong(consumerID); - } - - @Override - protected Boolean confirming(ExtendedDataInputStream in) throws Exception - { - return in.readBoolean(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSDeregisterConsumerRequest extends RequestWithConfirmation<Boolean>
+{
+ private int sessionID;
+
+ private long consumerID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSDeregisterConsumerRequest(JMSClientProtocol protocol, int sessionID, long consumerID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_DEREGISTER_CONSUMER);
+ this.sessionID = sessionID;
+ this.consumerID = consumerID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ out.writeLong(consumerID);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java index 5d2c0a604f..e69f4cd82b 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogoffRequest.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSLogoffRequest extends Request -{ - /** - * @since 2.0 - */ - public JMSLogoffRequest(JMSClientProtocol protocol) - { - super(protocol, JMSProtocolConstants.SIGNAL_LOGOFF); - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSLogoffRequest extends Request
+{
+ /**
+ * @since 2.0
+ */
+ public JMSLogoffRequest(JMSClientProtocol protocol)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_LOGOFF);
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java index 5a235cd029..26572848ba 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSLogonRequest.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSLogonRequest extends RequestWithConfirmation<Boolean> -{ - private String userName; - - private String password; - - /** - * @since 2.0 - */ - public JMSLogonRequest(JMSClientProtocol protocol, String userName, String password) - { - super(protocol, JMSProtocolConstants.SIGNAL_LOGON); - this.userName = userName; - this.password = password; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeString(userName); - out.writeString(password); - } - - @Override - protected Boolean confirming(ExtendedDataInputStream in) throws Exception - { - return in.readBoolean(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSLogonRequest extends RequestWithConfirmation<Boolean>
+{
+ private String userName;
+
+ private String password;
+
+ /**
+ * @since 2.0
+ */
+ public JMSLogonRequest(JMSClientProtocol protocol, String userName, String password)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_LOGON);
+ this.userName = userName;
+ this.password = password;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(userName);
+ out.writeString(password);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java index dc5a6e40a3..8dfe08e6a6 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSOpenSessionRequest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSOpenSessionRequest extends RequestWithConfirmation<Boolean> -{ - private int sessionID; - - /** - * @since 2.0 - */ - public JMSOpenSessionRequest(JMSClientProtocol protocol, int sessionID) - { - super(protocol, JMSProtocolConstants.SIGNAL_OPEN_SESSION); - this.sessionID = sessionID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - } - - @Override - protected Boolean confirming(ExtendedDataInputStream in) throws Exception - { - return in.readBoolean(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSOpenSessionRequest extends RequestWithConfirmation<Boolean>
+{
+ private int sessionID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSOpenSessionRequest(JMSClientProtocol protocol, int sessionID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_OPEN_SESSION);
+ this.sessionID = sessionID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java index e4ac2f8bfe..d1ae83d47c 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRecoverRequest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSRecoverRequest extends RequestWithConfirmation<Object> -{ - private int sessionID; - - /** - * @since 2.0 - */ - public JMSRecoverRequest(JMSClientProtocol protocol, int sessionID) - { - super(protocol, JMSProtocolConstants.SIGNAL_RECOVER); - this.sessionID = sessionID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - } - - @Override - protected Object confirming(ExtendedDataInputStream in) throws Exception - { - return null; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSRecoverRequest extends RequestWithConfirmation<Object>
+{
+ private int sessionID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSRecoverRequest(JMSClientProtocol protocol, int sessionID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_RECOVER);
+ this.sessionID = sessionID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ }
+
+ @Override
+ protected Object confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java index 9347b65a5a..7cebad9ad7 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRegisterConsumerRequest.java @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.internal.jms.DestinationImpl; -import org.eclipse.net4j.internal.jms.util.DestinationUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSRegisterConsumerRequest extends RequestWithConfirmation<Long> -{ - private int sessionID; - - private DestinationImpl destination; - - private String messageSelector; - - private boolean noLocal; - - private boolean durable; - - /** - * @since 2.0 - */ - public JMSRegisterConsumerRequest(JMSClientProtocol protocol, int sessionID, DestinationImpl destination, - String messageSelector, boolean noLocal, boolean durable) - { - super(protocol, JMSProtocolConstants.SIGNAL_REGISTER_CONSUMER); - this.sessionID = sessionID; - this.destination = destination; - this.messageSelector = messageSelector; - this.noLocal = noLocal; - this.durable = durable; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - DestinationUtil.write(out, destination); - out.writeString(messageSelector); - out.writeBoolean(noLocal); - out.writeBoolean(durable); - } - - @Override - protected Long confirming(ExtendedDataInputStream in) throws Exception - { - return in.readLong(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.internal.jms.DestinationImpl;
+import org.eclipse.net4j.internal.jms.util.DestinationUtil;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSRegisterConsumerRequest extends RequestWithConfirmation<Long>
+{
+ private int sessionID;
+
+ private DestinationImpl destination;
+
+ private String messageSelector;
+
+ private boolean noLocal;
+
+ private boolean durable;
+
+ /**
+ * @since 2.0
+ */
+ public JMSRegisterConsumerRequest(JMSClientProtocol protocol, int sessionID, DestinationImpl destination,
+ String messageSelector, boolean noLocal, boolean durable)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_REGISTER_CONSUMER);
+ this.sessionID = sessionID;
+ this.destination = destination;
+ this.messageSelector = messageSelector;
+ this.noLocal = noLocal;
+ this.durable = durable;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ DestinationUtil.write(out, destination);
+ out.writeString(messageSelector);
+ out.writeBoolean(noLocal);
+ out.writeBoolean(durable);
+ }
+
+ @Override
+ protected Long confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readLong();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java index 1c7adb2362..ab6a039054 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSRollbackRequest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSRollbackRequest extends RequestWithConfirmation<Boolean> -{ - private int sessionID; - - /** - * @since 2.0 - */ - public JMSRollbackRequest(JMSClientProtocol protocol, int sessionID) - { - super(protocol, JMSProtocolConstants.SIGNAL_ROLLBACK); - this.sessionID = sessionID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeInt(sessionID); - } - - @Override - protected Boolean confirming(ExtendedDataInputStream in) throws Exception - { - return in.readBoolean(); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSRollbackRequest extends RequestWithConfirmation<Boolean>
+{
+ private int sessionID;
+
+ /**
+ * @since 2.0
+ */
+ public JMSRollbackRequest(JMSClientProtocol protocol, int sessionID)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_ROLLBACK);
+ this.sessionID = sessionID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(sessionID);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java index 0d554883ed..a4469a3b92 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSServerMessageIndication.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.internal.jms.ConnectionImpl; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.Indication; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; - -/** - * @author Eike Stepper - */ -public class JMSServerMessageIndication extends Indication -{ - /** - * @since 2.0 - */ - public JMSServerMessageIndication(JMSClientProtocol protocol) - { - super(protocol, JMSProtocolConstants.SIGNAL_SERVER_MESSAGE); - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws Exception - { - int sessionID = in.readInt(); - long consumerID = in.readLong(); - MessageImpl message = MessageUtil.read(in); - JMSClientProtocol protocol = (JMSClientProtocol)getProtocol(); - ConnectionImpl connection = protocol.getInfraStructure(); - connection.handleMessageFromSignal(sessionID, consumerID, message); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.internal.jms.ConnectionImpl;
+import org.eclipse.net4j.internal.jms.MessageImpl;
+import org.eclipse.net4j.internal.jms.util.MessageUtil;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSServerMessageIndication extends Indication
+{
+ /**
+ * @since 2.0
+ */
+ public JMSServerMessageIndication(JMSClientProtocol protocol)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_SERVER_MESSAGE);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ int sessionID = in.readInt();
+ long consumerID = in.readLong();
+ MessageImpl message = MessageUtil.read(in);
+ JMSClientProtocol protocol = (JMSClientProtocol)getProtocol();
+ ConnectionImpl connection = protocol.getInfraStructure();
+ connection.handleMessageFromSignal(sessionID, consumerID, message);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java index 040283383d..f0d8e8d2bb 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/protocol/JMSSyncRequest.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class JMSSyncRequest extends RequestWithConfirmation<Long> -{ - private long clientTime0; - - /** - * @since 2.0 - */ - public JMSSyncRequest(JMSClientProtocol protocol) - { - super(protocol, JMSProtocolConstants.SIGNAL_SYNC); - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - clientTime0 = System.currentTimeMillis(); - } - - @Override - protected Long confirming(ExtendedDataInputStream in) throws Exception - { - long serverTime = in.readLong(); - long clientTime1 = System.currentTimeMillis(); - long roundTripDuration = clientTime1 - clientTime0; - return serverTime + roundTripDuration / 2; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.protocol;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSSyncRequest extends RequestWithConfirmation<Long>
+{
+ private long clientTime0;
+
+ /**
+ * @since 2.0
+ */
+ public JMSSyncRequest(JMSClientProtocol protocol)
+ {
+ super(protocol, JMSProtocolConstants.SIGNAL_SYNC);
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ clientTime0 = System.currentTimeMillis();
+ }
+
+ @Override
+ protected Long confirming(ExtendedDataInputStream in) throws Exception
+ {
+ long serverTime = in.readLong();
+ long clientTime1 = System.currentTimeMillis();
+ long roundTripDuration = clientTime1 - clientTime0;
+ return serverTime + roundTripDuration / 2;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/DestinationUtil.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/DestinationUtil.java index 518bca50f3..20a456d06b 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/DestinationUtil.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/DestinationUtil.java @@ -1,145 +1,145 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.util; - -import org.eclipse.net4j.internal.jms.DestinationImpl; -import org.eclipse.net4j.internal.jms.QueueImpl; -import org.eclipse.net4j.internal.jms.TopicImpl; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.Topic; - -import java.io.IOException; - -public final class DestinationUtil -{ - private DestinationUtil() - { - } - - public static byte getType(Destination destination) - { - if (destination instanceof Queue) - { - return JMSProtocolConstants.DESTINATION_TYPE_QUEUE; - } - - if (destination instanceof Topic) - { - return JMSProtocolConstants.DESTINATION_TYPE_TOPIC; - } - - if (destination == null) - { - return JMSProtocolConstants.DESTINATION_TYPE_NULL; - } - - throw new IllegalArgumentException("destination: " + destination); //$NON-NLS-1$ - } - - public static String getTypeName(byte type) - { - switch (type) - { - case JMSProtocolConstants.DESTINATION_TYPE_NULL: - return "NULL_DESTINATION"; //$NON-NLS-1$ - - case JMSProtocolConstants.DESTINATION_TYPE_QUEUE: - return "QUEUE_DESTINATION"; //$NON-NLS-1$ - - case JMSProtocolConstants.DESTINATION_TYPE_TOPIC: - return "TOPIC_DESTINATION"; //$NON-NLS-1$ - } - - throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$ - } - - public static String getName(Destination destination) throws JMSException - { - byte type = getType(destination); - switch (type) - { - case JMSProtocolConstants.DESTINATION_TYPE_QUEUE: - return ((Queue)destination).getQueueName(); - - case JMSProtocolConstants.DESTINATION_TYPE_TOPIC: - return ((Topic)destination).getTopicName(); - } - - return null; - } - - public static DestinationImpl create(byte type, String name) - { - switch (type) - { - case JMSProtocolConstants.DESTINATION_TYPE_QUEUE: - return new QueueImpl(name); - - case JMSProtocolConstants.DESTINATION_TYPE_TOPIC: - return new TopicImpl(name); - } - - return null; - } - - public static DestinationImpl copy(Destination source) throws JMSException - { - byte type = getType(source); - switch (type) - { - case JMSProtocolConstants.DESTINATION_TYPE_QUEUE: - return new QueueImpl(((Queue)source).getQueueName()); - - case JMSProtocolConstants.DESTINATION_TYPE_TOPIC: - return new TopicImpl(((Topic)source).getTopicName()); - } - - return null; - } - - public static DestinationImpl convert(Destination source) throws JMSException - { - if (source instanceof DestinationImpl) - { - return (DestinationImpl)source; - } - - return copy(source); - } - - public static void write(ExtendedDataOutputStream out, DestinationImpl destination) throws IOException - { - byte type = getType(destination); - out.writeByte(type); - if (type != JMSProtocolConstants.DESTINATION_TYPE_NULL) - { - out.writeString(destination.getName()); - } - } - - public static DestinationImpl read(ExtendedDataInputStream in) throws IOException - { - byte type = in.readByte(); - String name = null; - if (type != JMSProtocolConstants.DESTINATION_TYPE_NULL) - { - name = in.readString(); - } - - return create(type, name); - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.util;
+
+import org.eclipse.net4j.internal.jms.DestinationImpl;
+import org.eclipse.net4j.internal.jms.QueueImpl;
+import org.eclipse.net4j.internal.jms.TopicImpl;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import java.io.IOException;
+
+public final class DestinationUtil
+{
+ private DestinationUtil()
+ {
+ }
+
+ public static byte getType(Destination destination)
+ {
+ if (destination instanceof Queue)
+ {
+ return JMSProtocolConstants.DESTINATION_TYPE_QUEUE;
+ }
+
+ if (destination instanceof Topic)
+ {
+ return JMSProtocolConstants.DESTINATION_TYPE_TOPIC;
+ }
+
+ if (destination == null)
+ {
+ return JMSProtocolConstants.DESTINATION_TYPE_NULL;
+ }
+
+ throw new IllegalArgumentException("destination: " + destination); //$NON-NLS-1$
+ }
+
+ public static String getTypeName(byte type)
+ {
+ switch (type)
+ {
+ case JMSProtocolConstants.DESTINATION_TYPE_NULL:
+ return "NULL_DESTINATION"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.DESTINATION_TYPE_QUEUE:
+ return "QUEUE_DESTINATION"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.DESTINATION_TYPE_TOPIC:
+ return "TOPIC_DESTINATION"; //$NON-NLS-1$
+ }
+
+ throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$
+ }
+
+ public static String getName(Destination destination) throws JMSException
+ {
+ byte type = getType(destination);
+ switch (type)
+ {
+ case JMSProtocolConstants.DESTINATION_TYPE_QUEUE:
+ return ((Queue)destination).getQueueName();
+
+ case JMSProtocolConstants.DESTINATION_TYPE_TOPIC:
+ return ((Topic)destination).getTopicName();
+ }
+
+ return null;
+ }
+
+ public static DestinationImpl create(byte type, String name)
+ {
+ switch (type)
+ {
+ case JMSProtocolConstants.DESTINATION_TYPE_QUEUE:
+ return new QueueImpl(name);
+
+ case JMSProtocolConstants.DESTINATION_TYPE_TOPIC:
+ return new TopicImpl(name);
+ }
+
+ return null;
+ }
+
+ public static DestinationImpl copy(Destination source) throws JMSException
+ {
+ byte type = getType(source);
+ switch (type)
+ {
+ case JMSProtocolConstants.DESTINATION_TYPE_QUEUE:
+ return new QueueImpl(((Queue)source).getQueueName());
+
+ case JMSProtocolConstants.DESTINATION_TYPE_TOPIC:
+ return new TopicImpl(((Topic)source).getTopicName());
+ }
+
+ return null;
+ }
+
+ public static DestinationImpl convert(Destination source) throws JMSException
+ {
+ if (source instanceof DestinationImpl)
+ {
+ return (DestinationImpl)source;
+ }
+
+ return copy(source);
+ }
+
+ public static void write(ExtendedDataOutputStream out, DestinationImpl destination) throws IOException
+ {
+ byte type = getType(destination);
+ out.writeByte(type);
+ if (type != JMSProtocolConstants.DESTINATION_TYPE_NULL)
+ {
+ out.writeString(destination.getName());
+ }
+ }
+
+ public static DestinationImpl read(ExtendedDataInputStream in) throws IOException
+ {
+ byte type = in.readByte();
+ String name = null;
+ if (type != JMSProtocolConstants.DESTINATION_TYPE_NULL)
+ {
+ name = in.readString();
+ }
+
+ return create(type, name);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/MessageUtil.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/MessageUtil.java index 671c73dfc2..20f80bf86e 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/MessageUtil.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/MessageUtil.java @@ -1,161 +1,161 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.util; - -import org.eclipse.net4j.internal.jms.BytesMessageImpl; -import org.eclipse.net4j.internal.jms.MapMessageImpl; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.ObjectMessageImpl; -import org.eclipse.net4j.internal.jms.StreamMessageImpl; -import org.eclipse.net4j.internal.jms.TextMessageImpl; -import org.eclipse.net4j.internal.jms.bundle.OM; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import javax.jms.BytesMessage; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; -import javax.jms.ObjectMessage; -import javax.jms.StreamMessage; -import javax.jms.TextMessage; - -import java.io.IOException; - -public final class MessageUtil -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, MessageUtil.class); - - private MessageUtil() - { - } - - public static byte getType(Message message) - { - if (message instanceof BytesMessage) - { - return JMSProtocolConstants.MESSAGE_TYPE_BYTES; - } - - if (message instanceof MapMessage) - { - return JMSProtocolConstants.MESSAGE_TYPE_MAP; - } - - if (message instanceof ObjectMessage) - { - return JMSProtocolConstants.MESSAGE_TYPE_OBJECT; - } - - if (message instanceof StreamMessage) - { - return JMSProtocolConstants.MESSAGE_TYPE_STREAM; - } - - if (message instanceof TextMessage) - { - return JMSProtocolConstants.MESSAGE_TYPE_TEXT; - } - - throw new IllegalArgumentException("message: " + message); //$NON-NLS-1$ - } - - public static String getTypeName(byte type) - { - switch (type) - { - case JMSProtocolConstants.MESSAGE_TYPE_BYTES: - return "BYTES_MESSAGE"; //$NON-NLS-1$ - - case JMSProtocolConstants.MESSAGE_TYPE_MAP: - return "MAP_MESSAGE"; //$NON-NLS-1$ - - case JMSProtocolConstants.MESSAGE_TYPE_OBJECT: - return "OBJECT_MESSAGE"; //$NON-NLS-1$ - - case JMSProtocolConstants.MESSAGE_TYPE_STREAM: - return "STREAM_MESSAGE"; //$NON-NLS-1$ - - case JMSProtocolConstants.MESSAGE_TYPE_TEXT: - return "TEXT_MESSAGE"; //$NON-NLS-1$ - } - - throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$ - } - - public static MessageImpl create(byte type) - { - switch (type) - { - case JMSProtocolConstants.MESSAGE_TYPE_BYTES: - return new BytesMessageImpl(); - - case JMSProtocolConstants.MESSAGE_TYPE_MAP: - return new MapMessageImpl(); - - case JMSProtocolConstants.MESSAGE_TYPE_OBJECT: - return new ObjectMessageImpl(); - - case JMSProtocolConstants.MESSAGE_TYPE_STREAM: - return new StreamMessageImpl(); - - case JMSProtocolConstants.MESSAGE_TYPE_TEXT: - return new TextMessageImpl(); - } - - throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$ - } - - public static MessageImpl copy(Message source) throws JMSException - { - byte type = getType(source); - MessageImpl result = create(type); - result.populate(source); - return result; - } - - public static MessageImpl convert(Message source) throws JMSException - { - if (source instanceof MessageImpl) - { - return (MessageImpl)source; - } - - return copy(source); - } - - public static void write(ExtendedDataOutputStream out, MessageImpl message) throws IOException - { - byte type = getType(message); - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0}", getTypeName(type)); //$NON-NLS-1$ - } - - out.writeByte(type); - message.write(out); - } - - public static MessageImpl read(ExtendedDataInputStream in) throws IOException - { - byte type = in.readByte(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0}", getTypeName(type)); //$NON-NLS-1$ - } - - MessageImpl message = create(type); - message.read(in); - return message; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.util;
+
+import org.eclipse.net4j.internal.jms.BytesMessageImpl;
+import org.eclipse.net4j.internal.jms.MapMessageImpl;
+import org.eclipse.net4j.internal.jms.MessageImpl;
+import org.eclipse.net4j.internal.jms.ObjectMessageImpl;
+import org.eclipse.net4j.internal.jms.StreamMessageImpl;
+import org.eclipse.net4j.internal.jms.TextMessageImpl;
+import org.eclipse.net4j.internal.jms.bundle.OM;
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+
+public final class MessageUtil
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, MessageUtil.class);
+
+ private MessageUtil()
+ {
+ }
+
+ public static byte getType(Message message)
+ {
+ if (message instanceof BytesMessage)
+ {
+ return JMSProtocolConstants.MESSAGE_TYPE_BYTES;
+ }
+
+ if (message instanceof MapMessage)
+ {
+ return JMSProtocolConstants.MESSAGE_TYPE_MAP;
+ }
+
+ if (message instanceof ObjectMessage)
+ {
+ return JMSProtocolConstants.MESSAGE_TYPE_OBJECT;
+ }
+
+ if (message instanceof StreamMessage)
+ {
+ return JMSProtocolConstants.MESSAGE_TYPE_STREAM;
+ }
+
+ if (message instanceof TextMessage)
+ {
+ return JMSProtocolConstants.MESSAGE_TYPE_TEXT;
+ }
+
+ throw new IllegalArgumentException("message: " + message); //$NON-NLS-1$
+ }
+
+ public static String getTypeName(byte type)
+ {
+ switch (type)
+ {
+ case JMSProtocolConstants.MESSAGE_TYPE_BYTES:
+ return "BYTES_MESSAGE"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.MESSAGE_TYPE_MAP:
+ return "MAP_MESSAGE"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.MESSAGE_TYPE_OBJECT:
+ return "OBJECT_MESSAGE"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.MESSAGE_TYPE_STREAM:
+ return "STREAM_MESSAGE"; //$NON-NLS-1$
+
+ case JMSProtocolConstants.MESSAGE_TYPE_TEXT:
+ return "TEXT_MESSAGE"; //$NON-NLS-1$
+ }
+
+ throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$
+ }
+
+ public static MessageImpl create(byte type)
+ {
+ switch (type)
+ {
+ case JMSProtocolConstants.MESSAGE_TYPE_BYTES:
+ return new BytesMessageImpl();
+
+ case JMSProtocolConstants.MESSAGE_TYPE_MAP:
+ return new MapMessageImpl();
+
+ case JMSProtocolConstants.MESSAGE_TYPE_OBJECT:
+ return new ObjectMessageImpl();
+
+ case JMSProtocolConstants.MESSAGE_TYPE_STREAM:
+ return new StreamMessageImpl();
+
+ case JMSProtocolConstants.MESSAGE_TYPE_TEXT:
+ return new TextMessageImpl();
+ }
+
+ throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$
+ }
+
+ public static MessageImpl copy(Message source) throws JMSException
+ {
+ byte type = getType(source);
+ MessageImpl result = create(type);
+ result.populate(source);
+ return result;
+ }
+
+ public static MessageImpl convert(Message source) throws JMSException
+ {
+ if (source instanceof MessageImpl)
+ {
+ return (MessageImpl)source;
+ }
+
+ return copy(source);
+ }
+
+ public static void write(ExtendedDataOutputStream out, MessageImpl message) throws IOException
+ {
+ byte type = getType(message);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Writing {0}", getTypeName(type)); //$NON-NLS-1$
+ }
+
+ out.writeByte(type);
+ message.write(out);
+ }
+
+ public static MessageImpl read(ExtendedDataInputStream in) throws IOException
+ {
+ byte type = in.readByte();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Reading {0}", getTypeName(type)); //$NON-NLS-1$
+ }
+
+ MessageImpl message = create(type);
+ message.read(in);
+ return message;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/TypeUtil.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/TypeUtil.java index 8ba980016d..224c11fe22 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/TypeUtil.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/internal/jms/util/TypeUtil.java @@ -1,301 +1,301 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.internal.jms.util; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import javax.jms.MessageFormatException; - -import java.io.IOException; - -public final class TypeUtil -{ - private TypeUtil() - { - } - - public static boolean getBoolean(Object value) throws MessageFormatException - { - if (value instanceof Boolean) - { - return (Boolean)value; - } - else if (value instanceof String) - { - return Boolean.valueOf((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(boolean.class, value)); - } - - public static byte getByte(Object value) throws MessageFormatException - { - if (value instanceof Byte) - { - return (Byte)value; - } - else if (value instanceof String) - { - return Byte.parseByte((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(byte.class, value)); - } - - public static short getShort(Object value) throws MessageFormatException - { - if (value instanceof Short) - { - return (Short)value; - } - else if (value instanceof Byte) - { - return (Byte)value; - } - else if (value instanceof String) - { - return Short.parseShort((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(short.class, value)); - } - - public static char getChar(Object value) throws MessageFormatException - { - if (value instanceof Character) - { - return (Character)value; - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(char.class, value)); - } - - public static int getInt(Object value) throws MessageFormatException - { - if (value instanceof Integer) - { - return (Integer)value; - } - else if (value instanceof Short) - { - return (Short)value; - } - else if (value instanceof Byte) - { - return (Byte)value; - } - else if (value instanceof String) - { - return Integer.parseInt((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(int.class, value)); - } - - public static long getLong(Object value) throws MessageFormatException - { - if (value instanceof Long) - { - return (Long)value; - } - else if (value instanceof Integer) - { - return (Integer)value; - } - else if (value instanceof Short) - { - return (Short)value; - } - else if (value instanceof Byte) - { - return (Byte)value; - } - else if (value instanceof String) - { - return Long.parseLong((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(long.class, value)); - } - - public static float getFloat(Object value) throws MessageFormatException - { - if (value instanceof Float) - { - return (Float)value; - } - else if (value instanceof String) - { - return Float.parseFloat((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(float.class, value)); - } - - public static double getDouble(Object value) throws MessageFormatException - { - if (value instanceof Double) - { - return (Double)value; - } - else if (value instanceof Float) - { - return (Float)value; - } - else if (value instanceof String) - { - return Double.parseDouble((String)value); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(double.class, value)); - } - - public static String getString(Object value) throws MessageFormatException - { - if (value instanceof byte[]) - { - throw new MessageFormatException(conversionProblem(String.class, value)); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - return String.valueOf(value); - } - - public static byte[] getBytes(Object value) throws MessageFormatException - { - if (value instanceof byte[]) - { - byte[] bytes = (byte[])value; - byte[] result = new byte[bytes.length]; - System.arraycopy(bytes, 0, result, 0, bytes.length); - } - else if (value == null) - { - throw new IllegalArgumentException("value == null"); //$NON-NLS-1$ - } - - throw new MessageFormatException(conversionProblem(byte[].class, value)); - } - - public static void write(ExtendedDataOutputStream out, Object value) throws IOException - { - if (value instanceof Boolean) - { - out.writeByte(JMSProtocolConstants.TYPE_BOOLEAN); - out.writeBoolean((Boolean)value); - } - else if (value instanceof Byte) - { - out.writeByte(JMSProtocolConstants.TYPE_BYTE); - out.writeByte((Byte)value); - } - else if (value instanceof Character) - { - out.writeByte(JMSProtocolConstants.TYPE_CHAR); - out.writeChar((Character)value); - } - else if (value instanceof Double) - { - out.writeByte(JMSProtocolConstants.TYPE_DOUBLE); - out.writeDouble((Double)value); - } - else if (value instanceof Float) - { - out.writeByte(JMSProtocolConstants.TYPE_FLOAT); - out.writeFloat((Float)value); - } - else if (value instanceof Long) - { - out.writeByte(JMSProtocolConstants.TYPE_LONG); - out.writeLong((Long)value); - } - else if (value instanceof Short) - { - out.writeByte(JMSProtocolConstants.TYPE_SHORT); - out.writeShort((Short)value); - } - else if (value instanceof String) - { - out.writeByte(JMSProtocolConstants.TYPE_STRING); - out.writeString((String)value); - } - - throw new IllegalArgumentException("value: " + value); //$NON-NLS-1$ - } - - public static Object read(ExtendedDataInputStream in) throws IOException - { - byte type = in.readByte(); - switch (type) - { - case JMSProtocolConstants.TYPE_BOOLEAN: - return in.readBoolean(); - case JMSProtocolConstants.TYPE_BYTE: - return in.readByte(); - case JMSProtocolConstants.TYPE_CHAR: - return in.readChar(); - case JMSProtocolConstants.TYPE_DOUBLE: - return in.readDouble(); - case JMSProtocolConstants.TYPE_FLOAT: - return in.readFloat(); - case JMSProtocolConstants.TYPE_LONG: - return in.readLong(); - case JMSProtocolConstants.TYPE_SHORT: - return in.readShort(); - case JMSProtocolConstants.TYPE_STRING: - return in.readString(); - } - - throw new IOException("Invalid type: " + type); //$NON-NLS-1$ - } - - private static String conversionProblem(Class<?> type, Object value) - { - return "Cannot convert values of type " + value.getClass().getName() + " to " + type.getName(); //$NON-NLS-1$ //$NON-NLS-2$ - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.jms.util;
+
+import org.eclipse.net4j.jms.JMSProtocolConstants;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import javax.jms.MessageFormatException;
+
+import java.io.IOException;
+
+public final class TypeUtil
+{
+ private TypeUtil()
+ {
+ }
+
+ public static boolean getBoolean(Object value) throws MessageFormatException
+ {
+ if (value instanceof Boolean)
+ {
+ return (Boolean)value;
+ }
+ else if (value instanceof String)
+ {
+ return Boolean.valueOf((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(boolean.class, value));
+ }
+
+ public static byte getByte(Object value) throws MessageFormatException
+ {
+ if (value instanceof Byte)
+ {
+ return (Byte)value;
+ }
+ else if (value instanceof String)
+ {
+ return Byte.parseByte((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(byte.class, value));
+ }
+
+ public static short getShort(Object value) throws MessageFormatException
+ {
+ if (value instanceof Short)
+ {
+ return (Short)value;
+ }
+ else if (value instanceof Byte)
+ {
+ return (Byte)value;
+ }
+ else if (value instanceof String)
+ {
+ return Short.parseShort((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(short.class, value));
+ }
+
+ public static char getChar(Object value) throws MessageFormatException
+ {
+ if (value instanceof Character)
+ {
+ return (Character)value;
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(char.class, value));
+ }
+
+ public static int getInt(Object value) throws MessageFormatException
+ {
+ if (value instanceof Integer)
+ {
+ return (Integer)value;
+ }
+ else if (value instanceof Short)
+ {
+ return (Short)value;
+ }
+ else if (value instanceof Byte)
+ {
+ return (Byte)value;
+ }
+ else if (value instanceof String)
+ {
+ return Integer.parseInt((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(int.class, value));
+ }
+
+ public static long getLong(Object value) throws MessageFormatException
+ {
+ if (value instanceof Long)
+ {
+ return (Long)value;
+ }
+ else if (value instanceof Integer)
+ {
+ return (Integer)value;
+ }
+ else if (value instanceof Short)
+ {
+ return (Short)value;
+ }
+ else if (value instanceof Byte)
+ {
+ return (Byte)value;
+ }
+ else if (value instanceof String)
+ {
+ return Long.parseLong((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(long.class, value));
+ }
+
+ public static float getFloat(Object value) throws MessageFormatException
+ {
+ if (value instanceof Float)
+ {
+ return (Float)value;
+ }
+ else if (value instanceof String)
+ {
+ return Float.parseFloat((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(float.class, value));
+ }
+
+ public static double getDouble(Object value) throws MessageFormatException
+ {
+ if (value instanceof Double)
+ {
+ return (Double)value;
+ }
+ else if (value instanceof Float)
+ {
+ return (Float)value;
+ }
+ else if (value instanceof String)
+ {
+ return Double.parseDouble((String)value);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(double.class, value));
+ }
+
+ public static String getString(Object value) throws MessageFormatException
+ {
+ if (value instanceof byte[])
+ {
+ throw new MessageFormatException(conversionProblem(String.class, value));
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ return String.valueOf(value);
+ }
+
+ public static byte[] getBytes(Object value) throws MessageFormatException
+ {
+ if (value instanceof byte[])
+ {
+ byte[] bytes = (byte[])value;
+ byte[] result = new byte[bytes.length];
+ System.arraycopy(bytes, 0, result, 0, bytes.length);
+ }
+ else if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ throw new MessageFormatException(conversionProblem(byte[].class, value));
+ }
+
+ public static void write(ExtendedDataOutputStream out, Object value) throws IOException
+ {
+ if (value instanceof Boolean)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_BOOLEAN);
+ out.writeBoolean((Boolean)value);
+ }
+ else if (value instanceof Byte)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_BYTE);
+ out.writeByte((Byte)value);
+ }
+ else if (value instanceof Character)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_CHAR);
+ out.writeChar((Character)value);
+ }
+ else if (value instanceof Double)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_DOUBLE);
+ out.writeDouble((Double)value);
+ }
+ else if (value instanceof Float)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_FLOAT);
+ out.writeFloat((Float)value);
+ }
+ else if (value instanceof Long)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_LONG);
+ out.writeLong((Long)value);
+ }
+ else if (value instanceof Short)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_SHORT);
+ out.writeShort((Short)value);
+ }
+ else if (value instanceof String)
+ {
+ out.writeByte(JMSProtocolConstants.TYPE_STRING);
+ out.writeString((String)value);
+ }
+
+ throw new IllegalArgumentException("value: " + value); //$NON-NLS-1$
+ }
+
+ public static Object read(ExtendedDataInputStream in) throws IOException
+ {
+ byte type = in.readByte();
+ switch (type)
+ {
+ case JMSProtocolConstants.TYPE_BOOLEAN:
+ return in.readBoolean();
+ case JMSProtocolConstants.TYPE_BYTE:
+ return in.readByte();
+ case JMSProtocolConstants.TYPE_CHAR:
+ return in.readChar();
+ case JMSProtocolConstants.TYPE_DOUBLE:
+ return in.readDouble();
+ case JMSProtocolConstants.TYPE_FLOAT:
+ return in.readFloat();
+ case JMSProtocolConstants.TYPE_LONG:
+ return in.readLong();
+ case JMSProtocolConstants.TYPE_SHORT:
+ return in.readShort();
+ case JMSProtocolConstants.TYPE_STRING:
+ return in.readString();
+ }
+
+ throw new IOException("Invalid type: " + type); //$NON-NLS-1$
+ }
+
+ private static String conversionProblem(Class<?> type, Object value)
+ {
+ return "Cannot convert values of type " + value.getClass().getName() + " to " + type.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSAdminProtocolConstants.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSAdminProtocolConstants.java index 488058a78c..ca6f2ea58f 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSAdminProtocolConstants.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSAdminProtocolConstants.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.jms; - -/** - * @author Eike Stepper - */ -public interface JMSAdminProtocolConstants -{ - public static final String PROTOCOL_NAME = "jmsadmin"; //$NON-NLS-1$ - - public static final short SIGNAL_CREATE_DESTINATION = 1; - - public static final byte DESTINATION_TYPE_QUEUE = JMSProtocolConstants.DESTINATION_TYPE_QUEUE; - - public static final byte DESTINATION_TYPE_TOPIC = JMSProtocolConstants.DESTINATION_TYPE_TOPIC; -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms;
+
+/**
+ * @author Eike Stepper
+ */
+public interface JMSAdminProtocolConstants
+{
+ public static final String PROTOCOL_NAME = "jmsadmin"; //$NON-NLS-1$
+
+ public static final short SIGNAL_CREATE_DESTINATION = 1;
+
+ public static final byte DESTINATION_TYPE_QUEUE = JMSProtocolConstants.DESTINATION_TYPE_QUEUE;
+
+ public static final byte DESTINATION_TYPE_TOPIC = JMSProtocolConstants.DESTINATION_TYPE_TOPIC;
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java index 8bb5323155..78565c6982 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSInitialContext.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.jms; - -import org.eclipse.net4j.internal.jms.ConnectionFactoryImpl; -import org.eclipse.net4j.util.container.IManagedContainer; - -import javax.naming.InitialContext; -import javax.naming.Name; -import javax.naming.NamingException; - -import java.util.Hashtable; - -/** - * @author Eike Stepper - */ -public class JMSInitialContext extends InitialContext -{ - private IManagedContainer transportContainer; - - public JMSInitialContext(IManagedContainer transportContainer) throws NamingException - { - this.transportContainer = transportContainer; - } - - public JMSInitialContext(boolean lazy, IManagedContainer transportContainer) throws NamingException - { - super(lazy); - this.transportContainer = transportContainer; - } - - public JMSInitialContext(Hashtable<?, ?> environment, IManagedContainer transportContainer) throws NamingException - { - super(environment); - this.transportContainer = transportContainer; - } - - public IManagedContainer getTransportContainer() - { - return transportContainer; - } - - @Override - public Object lookup(Name name) throws NamingException - { - return postProcess(super.lookup(name)); - } - - @Override - public Object lookup(String name) throws NamingException - { - return postProcess(super.lookup(name)); - } - - @Override - public Object lookupLink(Name name) throws NamingException - { - return postProcess(super.lookupLink(name)); - } - - @Override - public Object lookupLink(String name) throws NamingException - { - return postProcess(super.lookupLink(name)); - } - - protected Object postProcess(Object object) - { - if (object instanceof ConnectionFactoryImpl) - { - ConnectionFactoryImpl factory = (ConnectionFactoryImpl)object; - factory.setTransportContainer(transportContainer); - } - - return object; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms;
+
+import org.eclipse.net4j.internal.jms.ConnectionFactoryImpl;
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import java.util.Hashtable;
+
+/**
+ * @author Eike Stepper
+ */
+public class JMSInitialContext extends InitialContext
+{
+ private IManagedContainer transportContainer;
+
+ public JMSInitialContext(IManagedContainer transportContainer) throws NamingException
+ {
+ this.transportContainer = transportContainer;
+ }
+
+ public JMSInitialContext(boolean lazy, IManagedContainer transportContainer) throws NamingException
+ {
+ super(lazy);
+ this.transportContainer = transportContainer;
+ }
+
+ public JMSInitialContext(Hashtable<?, ?> environment, IManagedContainer transportContainer) throws NamingException
+ {
+ super(environment);
+ this.transportContainer = transportContainer;
+ }
+
+ public IManagedContainer getTransportContainer()
+ {
+ return transportContainer;
+ }
+
+ @Override
+ public Object lookup(Name name) throws NamingException
+ {
+ return postProcess(super.lookup(name));
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException
+ {
+ return postProcess(super.lookup(name));
+ }
+
+ @Override
+ public Object lookupLink(Name name) throws NamingException
+ {
+ return postProcess(super.lookupLink(name));
+ }
+
+ @Override
+ public Object lookupLink(String name) throws NamingException
+ {
+ return postProcess(super.lookupLink(name));
+ }
+
+ protected Object postProcess(Object object)
+ {
+ if (object instanceof ConnectionFactoryImpl)
+ {
+ ConnectionFactoryImpl factory = (ConnectionFactoryImpl)object;
+ factory.setTransportContainer(transportContainer);
+ }
+
+ return object;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSProtocolConstants.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSProtocolConstants.java index bc77eb6a4b..84e9645805 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSProtocolConstants.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSProtocolConstants.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.jms; - -/** - * @author Eike Stepper - */ -public interface JMSProtocolConstants -{ - public static final String PROTOCOL_NAME = "jms"; //$NON-NLS-1$ - - // Signals - - public static final short SIGNAL_SYNC = 1; - - public static final short SIGNAL_LOGON = 2; - - public static final short SIGNAL_LOGOFF = 3; - - public static final short SIGNAL_OPEN_SESSION = 4; - - public static final short SIGNAL_CLOSE_SESSION = 5; - - public static final short SIGNAL_REGISTER_CONSUMER = 6; - - public static final short SIGNAL_DEREGISTER_CONSUMER = 7; - - public static final short SIGNAL_CLIENT_MESSAGE = 8; - - public static final short SIGNAL_SERVER_MESSAGE = 9; - - public static final short SIGNAL_ACKNOWLEDGE = 10; - - public static final short SIGNAL_RECOVER = 11; - - public static final short SIGNAL_COMMIT = 12; - - public static final short SIGNAL_ROLLBACK = 13; - - // Message Types - - public static final byte MESSAGE_TYPE_BYTES = 1; - - public static final byte MESSAGE_TYPE_MAP = 2; - - public static final byte MESSAGE_TYPE_OBJECT = 3; - - public static final byte MESSAGE_TYPE_STREAM = 4; - - public static final byte MESSAGE_TYPE_TEXT = 5; - - // Destination Types - - public static final byte DESTINATION_TYPE_NULL = 0; - - public static final byte DESTINATION_TYPE_QUEUE = 1; - - public static final byte DESTINATION_TYPE_TOPIC = 2; - - // Data Types - - public static final byte TYPE_BOOLEAN = 1; - - public static final byte TYPE_BYTE = 2; - - public static final byte TYPE_CHAR = 3; - - public static final byte TYPE_DOUBLE = 4; - - public static final byte TYPE_FLOAT = 5; - - public static final byte TYPE_LONG = 6; - - public static final byte TYPE_SHORT = 7; - - public static final byte TYPE_STRING = 8; -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms;
+
+/**
+ * @author Eike Stepper
+ */
+public interface JMSProtocolConstants
+{
+ public static final String PROTOCOL_NAME = "jms"; //$NON-NLS-1$
+
+ // Signals
+
+ public static final short SIGNAL_SYNC = 1;
+
+ public static final short SIGNAL_LOGON = 2;
+
+ public static final short SIGNAL_LOGOFF = 3;
+
+ public static final short SIGNAL_OPEN_SESSION = 4;
+
+ public static final short SIGNAL_CLOSE_SESSION = 5;
+
+ public static final short SIGNAL_REGISTER_CONSUMER = 6;
+
+ public static final short SIGNAL_DEREGISTER_CONSUMER = 7;
+
+ public static final short SIGNAL_CLIENT_MESSAGE = 8;
+
+ public static final short SIGNAL_SERVER_MESSAGE = 9;
+
+ public static final short SIGNAL_ACKNOWLEDGE = 10;
+
+ public static final short SIGNAL_RECOVER = 11;
+
+ public static final short SIGNAL_COMMIT = 12;
+
+ public static final short SIGNAL_ROLLBACK = 13;
+
+ // Message Types
+
+ public static final byte MESSAGE_TYPE_BYTES = 1;
+
+ public static final byte MESSAGE_TYPE_MAP = 2;
+
+ public static final byte MESSAGE_TYPE_OBJECT = 3;
+
+ public static final byte MESSAGE_TYPE_STREAM = 4;
+
+ public static final byte MESSAGE_TYPE_TEXT = 5;
+
+ // Destination Types
+
+ public static final byte DESTINATION_TYPE_NULL = 0;
+
+ public static final byte DESTINATION_TYPE_QUEUE = 1;
+
+ public static final byte DESTINATION_TYPE_TOPIC = 2;
+
+ // Data Types
+
+ public static final byte TYPE_BOOLEAN = 1;
+
+ public static final byte TYPE_BYTE = 2;
+
+ public static final byte TYPE_CHAR = 3;
+
+ public static final byte TYPE_DOUBLE = 4;
+
+ public static final byte TYPE_FLOAT = 5;
+
+ public static final byte TYPE_LONG = 6;
+
+ public static final byte TYPE_SHORT = 7;
+
+ public static final byte TYPE_STRING = 8;
+}
diff --git a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java index e249c7a76c..5e7aa7be0d 100644 --- a/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java +++ b/plugins/org.eclipse.net4j.jms/src/org/eclipse/net4j/jms/JMSUtil.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.net4j.jms; - -import org.eclipse.net4j.util.container.IManagedContainer; - -import javax.naming.Context; -import javax.naming.NamingException; - -/** - * @author Eike Stepper - */ -public final class JMSUtil -{ - private static IManagedContainer transportContainer; - - private JMSUtil() - { - } - - public static Context createInitialContext() throws NamingException - { - if (transportContainer == null) - { - throw new IllegalStateException("transportContainer == null"); //$NON-NLS-1$ - } - - return new JMSInitialContext(transportContainer); - } - - public static IManagedContainer getTransportContainer() - { - return transportContainer; - } - - public static void setTransportContainer(IManagedContainer transportContainer) - { - JMSUtil.transportContainer = transportContainer; - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms;
+
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+/**
+ * @author Eike Stepper
+ */
+public final class JMSUtil
+{
+ private static IManagedContainer transportContainer;
+
+ private JMSUtil()
+ {
+ }
+
+ public static Context createInitialContext() throws NamingException
+ {
+ if (transportContainer == null)
+ {
+ throw new IllegalStateException("transportContainer == null"); //$NON-NLS-1$
+ }
+
+ return new JMSInitialContext(transportContainer);
+ }
+
+ public static IManagedContainer getTransportContainer()
+ {
+ return transportContainer;
+ }
+
+ public static void setTransportContainer(IManagedContainer transportContainer)
+ {
+ JMSUtil.transportContainer = transportContainer;
+ }
+}
|