Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2006-09-28 16:14:09 +0000
committerSimon Kaegi2006-09-28 16:14:09 +0000
commit788e5fc2580c43595fd3fb2f89553ce9b95c2f0a (patch)
tree383129345d2f600d1b2d996c3bd2568e80d94d23 /bundles/org.eclipse.equinox.http.servlet
parent776557b9e400799f6003d387259959aa7f363d59 (diff)
downloadrt.equinox.bundles-788e5fc2580c43595fd3fb2f89553ce9b95c2f0a.tar.gz
rt.equinox.bundles-788e5fc2580c43595fd3fb2f89553ce9b95c2f0a.tar.xz
rt.equinox.bundles-788e5fc2580c43595fd3fb2f89553ce9b95c2f0a.zip
Adding the serverside eclipse projects to the main depot
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet')
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/.cvsignore1
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/.project28
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs253
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.ui.prefs8
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF15
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/build.properties4
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java73
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java85
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultHttpContext.java41
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java34
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java83
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServletRequestAdaptor.java127
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java92
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java36
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java169
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Registration.java57
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/RequestDispatcherAdaptor.java28
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceRegistration.java142
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java53
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java187
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletRegistration.java87
22 files changed, 1610 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/.classpath b/bundles/org.eclipse.equinox.http.servlet/.classpath
new file mode 100644
index 000000000..ce0c7a5d4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.0%Foundation-1.0"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.equinox.http.servlet/.cvsignore b/bundles/org.eclipse.equinox.http.servlet/.cvsignore
new file mode 100644
index 000000000..ba077a403
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/bundles/org.eclipse.equinox.http.servlet/.project b/bundles/org.eclipse.equinox.http.servlet/.project
new file mode 100644
index 000000000..b32d05a6c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.equinox.http.servlet</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..f72f4bca6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,253 @@
+#Thu Sep 28 11:26:23 EDT 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
+org.eclipse.jdt.core.compiler.compliance=1.3
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
+org.eclipse.jdt.core.formatter.comment.format_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=true
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=800
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
diff --git a/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..87292426d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,8 @@
+#Thu Sep 28 11:26:55 EDT 2006
+eclipse.preferences.version=1
+formatter_profile=_core
+formatter_settings_version=10
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=;
+org.eclipse.jdt.ui.ondemandthreshold=3
+org.eclipse.jdt.ui.staticondemandthreshold=3
diff --git a/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..67063dcbb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Http Services Servlet
+Bundle-SymbolicName: org.eclipse.equinox.http.servlet
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.equinox.http.servlet.internal.Activator
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,
+ J2SE-1.3
+Export-Package: org.eclipse.equinox.http.servlet;version="1.0.0"
+Import-Package: javax.servlet;version="[2.3.0,2.5.0)",
+ javax.servlet.http;version="[2.3.0,2.5.0)",
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.http;version="1.2.0"
+Eclipse-LazyStart: true
diff --git a/bundles/org.eclipse.equinox.http.servlet/build.properties b/bundles/org.eclipse.equinox.http.servlet/build.properties
new file mode 100644
index 000000000..34d2e4d2d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java
new file mode 100644
index 000000000..48afc3e01
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/HttpServiceServlet.java
@@ -0,0 +1,73 @@
+package org.eclipse.equinox.http.servlet;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import javax.servlet.*;
+import javax.servlet.http.HttpServlet;
+import org.eclipse.equinox.http.servlet.internal.ProxyServlet;
+
+/**
+ * The HttpServiceServlet is the "public" side of a Servlet that when registered (and init() called) in a servlet container
+ * will in-turn register and provide an OSGi Http Service implementation.
+ * This class is not meant for extending or even using directly and is purely meant for registering
+ * in a servlet container.
+ */
+public class HttpServiceServlet extends HttpServlet {
+
+ private static final long serialVersionUID = -8247735945454143446L;
+
+ private ProxyServlet delegate;
+
+ public HttpServiceServlet() {
+ delegate = new ProxyServlet();
+ }
+
+ public void destroy() {
+ delegate.destroy();
+ }
+
+ public String getInitParameter(String name) {
+ return delegate.getInitParameter(name);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return delegate.getInitParameterNames();
+ }
+
+ public ServletConfig getServletConfig() {
+ return delegate.getServletConfig();
+ }
+
+ public ServletContext getServletContext() {
+ return delegate.getServletContext();
+ }
+
+ public String getServletInfo() {
+ return delegate.getServletInfo();
+ }
+
+ public String getServletName() {
+ return delegate.getServletName();
+ }
+
+ public void init() throws ServletException {
+ delegate.init();
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ delegate.init(config);
+ }
+
+ public void log(String message, Throwable t) {
+ delegate.log(message, t);
+ }
+
+ public void log(String msg) {
+ delegate.log(msg);
+ }
+
+ public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
+ delegate.service(req, res);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java
new file mode 100644
index 000000000..6556dd6ee
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Activator.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.util.*;
+import javax.servlet.ServletConfig;
+import org.osgi.framework.*;
+import org.osgi.service.http.HttpService;
+
+public class Activator implements BundleActivator {
+
+ private static final String DEFAULT_SERVICE_DESCRIPTION = "Equinox Servlet Bridge"; //$NON-NLS-1$
+ private static final String DEFAULT_SERVICE_VENDOR = "Eclipse.org"; //$NON-NLS-1$
+
+ private static BundleContext context;
+ private static Map serviceRegistrations = new HashMap();
+
+ public void start(BundleContext context) throws Exception {
+ startHttpServiceProxy(context);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ stopHttpServiceProxy(context);
+ }
+
+ private static synchronized void startHttpServiceProxy(BundleContext bundleContext) {
+ context = bundleContext;
+ Object[] proxyServlets = serviceRegistrations.keySet().toArray();
+ for (int i = 0; i < proxyServlets.length; ++i) {
+ ServiceRegistration registration = registerHttpService((ProxyServlet) proxyServlets[i]);
+ serviceRegistrations.put(proxyServlets[i], registration);
+ }
+ }
+
+ private static synchronized void stopHttpServiceProxy(BundleContext bundleContext) {
+ Object[] proxyServlets = serviceRegistrations.keySet().toArray();
+ for (int i = 0; i < proxyServlets.length; ++i) {
+ ServiceRegistration registration = (ServiceRegistration) serviceRegistrations.put(proxyServlets[i], null);
+ registration.unregister();
+ }
+ context = null;
+ }
+
+ static synchronized void addProxyServlet(ProxyServlet proxyServlet) {
+ ServiceRegistration registration = null;
+ if (context != null)
+ registration = registerHttpService(proxyServlet);
+
+ serviceRegistrations.put(proxyServlet, registration);
+ }
+
+ private static ServiceRegistration registerHttpService(ProxyServlet proxyServlet) {
+ HttpServiceFactory factory = new HttpServiceFactory(proxyServlet);
+ Dictionary serviceProperties = new Hashtable(2);
+ ServletConfig config = proxyServlet.getServletConfig();
+ Enumeration initparameterNames = config.getInitParameterNames();
+ while (initparameterNames.hasMoreElements()) {
+ String name = (String) initparameterNames.nextElement();
+ serviceProperties.put(name, config.getInitParameter(name));
+ }
+
+ if (serviceProperties.get(Constants.SERVICE_VENDOR) == null)
+ serviceProperties.put(Constants.SERVICE_VENDOR, DEFAULT_SERVICE_VENDOR);
+
+ if (serviceProperties.get(Constants.SERVICE_DESCRIPTION) == null)
+ serviceProperties.put(Constants.SERVICE_DESCRIPTION, DEFAULT_SERVICE_DESCRIPTION);
+
+ return context.registerService(HttpService.class.getName(), factory, serviceProperties);
+ }
+
+ static synchronized void removeProxyServlet(ProxyServlet proxyServlet) {
+ ServiceRegistration registration = (ServiceRegistration) serviceRegistrations.remove(proxyServlet);
+ if (registration != null)
+ registration.unregister();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultHttpContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultHttpContext.java
new file mode 100644
index 000000000..528f8299f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/DefaultHttpContext.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.HttpContext;
+
+public class DefaultHttpContext implements HttpContext {
+
+ private Bundle bundle;
+
+ public DefaultHttpContext(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // default behaviour assumes the container has already performed authentication
+ return true;
+ }
+
+ public URL getResource(String name) {
+ return bundle.getResource(name);
+ }
+
+ public String getMimeType(String name) {
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java
new file mode 100644
index 000000000..0af26c647
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceFactory.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import org.osgi.framework.*;
+
+// Factory to create http services. This is because the service needs to be customized for each bundle in order to implement the default resource lookups.
+public class HttpServiceFactory implements ServiceFactory {
+
+ private ProxyServlet proxy;
+
+ public HttpServiceFactory(ProxyServlet proxy) {
+ this.proxy = proxy;
+ }
+
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ return new HttpServiceImpl(bundle, proxy);
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ ((HttpServiceImpl) service).unregisterAliases();
+
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java
new file mode 100644
index 000000000..cb7a6bea8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceImpl.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ * IBM Corporation - comments, and costmetic changes
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.util.*;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.*;
+
+public class HttpServiceImpl implements HttpService {
+
+ private Bundle bundle; //The bundle associated with this instance of http service
+
+ private ProxyServlet proxy; //The proxy that does the dispatching of the incoming requests
+
+ Set aliases = new HashSet(); //Aliases registered against this particular instance of the service
+
+ public HttpServiceImpl(Bundle bundle, ProxyServlet proxy) {
+ this.bundle = bundle;
+ this.proxy = proxy;
+ }
+
+ //Clean up method
+ public synchronized void unregisterAliases() {
+ for (Iterator it = aliases.iterator(); it.hasNext();) {
+ String alias = (String) it.next();
+ proxy.unregister(alias, false);
+ }
+ aliases.clear();
+ }
+
+ /**
+ * @see HttpService#registerServlet(String, Servlet, Dictionary, HttpContext)
+ */
+ public synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException {
+ if (context == null) {
+ context = createDefaultHttpContext();
+ }
+ proxy.registerServlet(alias, servlet, initparams, context, bundle);
+ aliases.add(alias);
+ }
+
+ /**
+ * @see HttpService#registerResources(String, String, HttpContext)
+ */
+ public synchronized void registerResources(String alias, String name, HttpContext context) throws NamespaceException {
+ if (context == null) {
+ context = createDefaultHttpContext();
+ }
+ proxy.registerResources(alias, name, context);
+ aliases.add(alias);
+ }
+
+ /**
+ * @see HttpService#unregister(String)
+ */
+ public synchronized void unregister(String alias) {
+ if (aliases.remove(alias)) {
+ proxy.unregister(alias, true);
+ } else {
+ // TODO perhaps this is too strong a reacttion ?
+ throw new IllegalArgumentException("Alias not found."); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see HttpService#createDefaultHttpContext()
+ */
+ public HttpContext createDefaultHttpContext() {
+ return new DefaultHttpContext(bundle);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServletRequestAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServletRequestAdaptor.java
new file mode 100644
index 000000000..ab8d5e72a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServletRequestAdaptor.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.http.*;
+
+public class HttpServletRequestAdaptor extends HttpServletRequestWrapper {
+
+ private String alias;
+ private Servlet servlet;
+ private boolean isRequestDispatcherInclude;
+
+ static final String INCLUDE_REQUEST_URI_ATTRIBUTE = "javax.servlet.include.request_uri"; //$NON-NLS-1$
+ static final String INCLUDE_CONTEXT_PATH_ATTRIBUTE = "javax.servlet.include.context_path"; //$NON-NLS-1$
+ static final String INCLUDE_SERVLET_PATH_ATTRIBUTE = "javax.servlet.include.servlet_path"; //$NON-NLS-1$
+ static final String INCLUDE_PATH_INFO_ATTRIBUTE = "javax.servlet.include.path_info"; //$NON-NLS-1$
+
+ public HttpServletRequestAdaptor(HttpServletRequest req, String alias, Servlet servlet) {
+ super(req);
+ this.alias = alias;
+ this.servlet = servlet;
+ isRequestDispatcherInclude = req.getAttribute(HttpServletRequestAdaptor.INCLUDE_REQUEST_URI_ATTRIBUTE) != null;
+ }
+
+ public String getPathInfo() {
+ if (isRequestDispatcherInclude)
+ return super.getPathInfo();
+
+ if (alias.equals("/")) { //$NON-NLS-1$
+ return super.getPathInfo();
+ }
+ return super.getPathInfo().substring(alias.length());
+ }
+
+ public String getServletPath() {
+ if (isRequestDispatcherInclude)
+ return super.getServletPath();
+
+ if (alias.equals("/")) { //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ return alias;
+ }
+
+ public String getContextPath() {
+ if (isRequestDispatcherInclude)
+ return super.getContextPath();
+
+ return super.getContextPath() + super.getServletPath();
+ }
+
+ public Object getAttribute(String attributeName) {
+ if (isRequestDispatcherInclude) {
+ if (attributeName.equals(HttpServletRequestAdaptor.INCLUDE_CONTEXT_PATH_ATTRIBUTE)) {
+ String contextPath = (String) super.getAttribute(HttpServletRequestAdaptor.INCLUDE_CONTEXT_PATH_ATTRIBUTE);
+ if (contextPath == null || contextPath.equals("/")) //$NON-NLS-1$
+ contextPath = ""; //$NON-NLS-1$
+
+ String servletPath = (String) super.getAttribute(HttpServletRequestAdaptor.INCLUDE_SERVLET_PATH_ATTRIBUTE);
+ if (servletPath == null || servletPath.equals("/")) //$NON-NLS-1$
+ servletPath = ""; //$NON-NLS-1$
+
+ return contextPath + servletPath;
+ } else if (attributeName.equals(HttpServletRequestAdaptor.INCLUDE_SERVLET_PATH_ATTRIBUTE)) {
+ if (alias.equals("/")) { //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ return alias;
+ } else if (attributeName.equals(HttpServletRequestAdaptor.INCLUDE_PATH_INFO_ATTRIBUTE)) {
+ String pathInfo = (String) super.getAttribute(HttpServletRequestAdaptor.INCLUDE_PATH_INFO_ATTRIBUTE);
+ if (alias.equals("/")) { //$NON-NLS-1$
+ return pathInfo;
+ }
+ return pathInfo.substring(alias.length());
+ }
+ }
+
+ return super.getAttribute(attributeName);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ return new RequestDispatcherAdaptor(super.getRequestDispatcher(super.getServletPath() + arg0));
+ }
+
+ public static String getDispatchPathInfo(HttpServletRequest req) {
+ if (req.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null)
+ return (String) req.getAttribute(INCLUDE_PATH_INFO_ATTRIBUTE);
+
+ return req.getPathInfo();
+ }
+
+ public static String getDispatchServletPath(HttpServletRequest req) {
+ if (req.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null) {
+ String servletPath = (String) req.getAttribute(INCLUDE_SERVLET_PATH_ATTRIBUTE);
+ return (servletPath == null) ? "" : servletPath; //$NON-NLS-1$
+ }
+ return req.getServletPath();
+ }
+
+ public HttpSession getSession() {
+ HttpSession session = super.getSession();
+ if (session != null)
+ return new HttpSessionAdaptor(session, servlet);
+
+ return null;
+ }
+
+ public HttpSession getSession(boolean create) {
+ HttpSession session = super.getSession(create);
+ if (session != null)
+ return new HttpSessionAdaptor(session, servlet);
+
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java
new file mode 100644
index 000000000..78b7643a7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpSessionAdaptor.java
@@ -0,0 +1,92 @@
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.util.Enumeration;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+
+// This class adapts HttpSessions in order to return the right ServletContext
+public class HttpSessionAdaptor implements HttpSession {
+
+ private HttpSession session;
+ private Servlet servlet;
+
+ public HttpSessionAdaptor(HttpSession session, Servlet servlet) {
+ this.session = session;
+ this.servlet = servlet;
+ }
+
+ public ServletContext getServletContext() {
+ return servlet.getServletConfig().getServletContext();
+ }
+
+ public Object getAttribute(String arg0) {
+ return session.getAttribute(arg0);
+ }
+
+ public Enumeration getAttributeNames() {
+ return session.getAttributeNames();
+ }
+
+ public long getCreationTime() {
+ return session.getCreationTime();
+ }
+
+ public String getId() {
+ return session.getId();
+ }
+
+ public long getLastAccessedTime() {
+ return session.getLastAccessedTime();
+ }
+
+ public int getMaxInactiveInterval() {
+ return session.getMaxInactiveInterval();
+ }
+
+ /**@deprecated*/
+ public javax.servlet.http.HttpSessionContext getSessionContext() {
+ return session.getSessionContext();
+ }
+
+ /**@deprecated*/
+ public Object getValue(String arg0) {
+ return session.getValue(arg0);
+ }
+
+ /**@deprecated*/
+ public String[] getValueNames() {
+ return session.getValueNames();
+ }
+
+ public void invalidate() {
+ session.invalidate();
+ }
+
+ public boolean isNew() {
+ return session.isNew();
+ }
+
+ /**@deprecated*/
+ public void putValue(String arg0, Object arg1) {
+ session.putValue(arg0, arg1);
+ }
+
+ public void removeAttribute(String arg0) {
+ session.removeAttribute(arg0);
+ }
+
+ /**@deprecated*/
+ public void removeValue(String arg0) {
+ session.removeValue(arg0);
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ session.setAttribute(arg0, arg1);
+ }
+
+ public void setMaxInactiveInterval(int arg0) {
+ session.setMaxInactiveInterval(arg0);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java
new file mode 100644
index 000000000..fd3a6717a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyContext.java
@@ -0,0 +1,36 @@
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.util.*;
+import javax.servlet.http.HttpServletRequest;
+import org.osgi.service.http.HttpContext;
+
+/**
+ * The ProxyContext provides something similar to a ServletContext for all servlets and resources under a particular ProxyServlet.
+ * In particular it holds and represent the concept of "context path" through the Proxy Servlets servlet path.
+ * The Http Service also requires a ServletContext namespaced by eachindividual HttpContext. The ProxyContext provides support for the
+ * attribute map of a ServletContext again namespaced by HttpContext as specified in the Http Service specification. A WeakHashMap is
+ * used to hold the various attributes so that when the HttpContext is no longer referenced the associated context attributes can be
+ * garbage collected.
+ */
+public class ProxyContext {
+ private String servletPath;
+ private WeakHashMap contextAttributes = new WeakHashMap();
+
+ synchronized void initializeServletPath(HttpServletRequest req) {
+ if (servletPath == null)
+ servletPath = HttpServletRequestAdaptor.getDispatchServletPath(req);
+ }
+
+ synchronized String getServletPath() {
+ return servletPath;
+ }
+
+ synchronized void createContextAttributes(HttpContext httpContext) {
+ if (!contextAttributes.containsKey(httpContext))
+ contextAttributes.put(httpContext, new Hashtable());
+ }
+
+ synchronized Dictionary getContextAttributes(HttpContext httpContext) {
+ return (Dictionary) contextAttributes.get(httpContext);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java
new file mode 100644
index 000000000..dc7dac279
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ProxyServlet.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ * IBM Corporation - comments and javadoc
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.NamespaceException;
+
+/**
+ * The ProxyServlet is the private side of a Servlet that when registered (and init() called) in a servlet container
+ * will in-turn register and provide an OSGi Http Service implementation.
+ * This class is not meant for extending or even using directly and is purely meant for registering
+ * in a servlet container.
+ */
+public class ProxyServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 4117456123807468871L;
+ private Map registrations = new HashMap(); //alias --> registration
+ private Set servlets = new HashSet(); //All the servlets objects that have been registered
+ private ProxyContext proxyContext;
+
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ proxyContext = new ProxyContext();
+ Activator.addProxyServlet(this);
+ }
+
+ public void destroy() {
+ Activator.removeProxyServlet(this);
+ proxyContext = null;
+ super.destroy();
+ }
+
+ /**
+ * @see HttpServlet#service(ServletRequest, ServletResponse)
+ */
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ proxyContext.initializeServletPath(req);
+ String alias = HttpServletRequestAdaptor.getDispatchPathInfo(req);
+ if (alias == null)
+ alias = "/"; //$NON-NLS-1$
+
+ // perfect match
+ if (processAlias(req, resp, alias, null))
+ return;
+
+ String extensionAlias = findExtensionAlias(alias);
+ alias = alias.substring(0, alias.lastIndexOf('/'));
+
+ // longest path match
+ while (alias.length() != 0) {
+ if (processAlias(req, resp, alias, extensionAlias))
+ return;
+ alias = alias.substring(0, alias.lastIndexOf('/'));
+ }
+
+ // default handler match
+ if (extensionAlias != null)
+ extensionAlias = extensionAlias.substring(1); // remove the leading '/'
+ if (processAlias(req, resp, "/", extensionAlias)) //Handle '/' aliases //$NON-NLS-1$
+ return;
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND, "ProxyServlet: " + req.getRequestURI()); //$NON-NLS-1$
+ }
+
+ private String findExtensionAlias(String alias) {
+ String lastSegment = alias.substring(alias.lastIndexOf('/') + 1);
+ int dot = lastSegment.indexOf('.');
+ if (dot == -1)
+ return null;
+ String extension = lastSegment.substring(dot + 1);
+ if (extension.length() == 0)
+ return null;
+ return "/*." + extension; //$NON-NLS-1$
+ }
+
+ private boolean processAlias(HttpServletRequest req, HttpServletResponse resp, String alias, String extensionAlias) throws ServletException, IOException {
+ Registration registration = null;
+ synchronized (this) {
+ if (extensionAlias == null)
+ registration = (Registration) registrations.get(alias);
+ else {
+ registration = (Registration) registrations.get(alias + extensionAlias);
+ if (registration != null) // extensions should be handled on the full alias
+ alias = HttpServletRequestAdaptor.getDispatchPathInfo(req);
+ else
+ registration = (Registration) registrations.get(alias);
+ }
+
+ if (registration != null)
+ registration.addReference();
+ }
+ if (registration != null) {
+ try {
+ if (registration.handleRequest(req, resp, alias))
+ return true;
+ } finally {
+ registration.removeReference();
+ }
+ }
+ return false;
+ }
+
+ //Effective unregistration of servlet and resources as defined in HttpService#unregister()
+ synchronized void unregister(String alias, boolean destroy) {
+ Registration removedRegistration = (Registration) registrations.remove(alias);
+ if (removedRegistration != null) {
+ if (destroy)
+ removedRegistration.destroy();
+ removedRegistration.close();
+ }
+ }
+
+ //Effective registration of the servlet as defined HttpService#registerServlet()
+ synchronized void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context, Bundle bundle) throws ServletException, NamespaceException {
+ checkAlias(alias);
+ if (servlet == null)
+ throw new IllegalArgumentException("Servlet cannot be null"); //$NON-NLS-1$
+
+ ServletRegistration registration = new ServletRegistration(servlet, context, bundle, servlets);
+ registration.checkServletRegistration();
+
+ ServletContext wrappedServletContext = new ServletContextAdaptor(proxyContext, getServletContext(), context, AccessController.getContext());
+ ServletConfig servletConfig = new ServletConfigImpl(servlet, initparams, wrappedServletContext);
+
+ registration.init(servletConfig);
+ registrations.put(alias, registration);
+ }
+
+ //Effective registration of the resources as defined HttpService#registerResources()
+ synchronized void registerResources(String alias, String name, HttpContext context) throws NamespaceException {
+ checkAlias(alias);
+ checkName(name);
+ registrations.put(alias, new ResourceRegistration(name, context, getServletContext(), AccessController.getContext()));
+ }
+
+ private void checkName(String name) {
+ if (name == null)
+ throw new IllegalArgumentException("Name cannot be null"); //$NON-NLS-1$
+
+ if (name.endsWith("/") && !name.equals("/")) //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException("Invalid Name '" + name + "'"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ private void checkAlias(String alias) throws NamespaceException {
+ if (alias == null)
+ throw new IllegalArgumentException("Alias cannot be null"); //$NON-NLS-1$
+
+ if (!alias.startsWith("/") || (alias.endsWith("/") && !alias.equals("/"))) //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ throw new IllegalArgumentException("Invalid alias '" + alias + "'"); //$NON-NLS-1$//$NON-NLS-2$
+
+ if (registrations.containsKey(alias))
+ throw new NamespaceException("The alias '" + alias + "' is already in use."); //$NON-NLS-1$//$NON-NLS-2$
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Registration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Registration.java
new file mode 100644
index 000000000..e70869bfb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/Registration.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public abstract class Registration {
+
+ protected int referenceCount;
+
+ public synchronized void addReference() {
+ ++referenceCount;
+ }
+
+ public synchronized void removeReference() {
+ --referenceCount;
+ if (referenceCount == 0) {
+ notifyAll();
+ }
+ }
+
+ public synchronized void destroy() {
+ boolean interrupted = false;
+ try {
+ while (referenceCount != 0) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // wait until the servlet is inactive but save the interrupted status
+ interrupted = true;
+ }
+ }
+ } finally {
+ if (interrupted)
+ Thread.currentThread().interrupt(); //restore the interrupted state
+ }
+ }
+
+ public abstract boolean handleRequest(HttpServletRequest req, HttpServletResponse resp, String alias) throws IOException, ServletException;
+
+ public void close() {
+ // do nothing
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/RequestDispatcherAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/RequestDispatcherAdaptor.java
new file mode 100644
index 000000000..2e43fc1ba
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/RequestDispatcherAdaptor.java
@@ -0,0 +1,28 @@
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.IOException;
+import javax.servlet.*;
+
+//This class unwraps the request so it can be processed by the underlying servlet container.
+public class RequestDispatcherAdaptor implements RequestDispatcher {
+
+ private RequestDispatcher requestDispatcher;
+
+ public RequestDispatcherAdaptor(RequestDispatcher requestDispatcher) {
+ this.requestDispatcher = requestDispatcher;
+ }
+
+ public void forward(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+ if (req instanceof HttpServletRequestAdaptor)
+ req = ((HttpServletRequestAdaptor) req).getRequest();
+
+ requestDispatcher.forward(req, resp);
+ }
+
+ public void include(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+ if (req instanceof HttpServletRequestAdaptor)
+ req = ((HttpServletRequestAdaptor) req).getRequest();
+
+ requestDispatcher.include(req, resp);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceRegistration.java
new file mode 100644
index 000000000..95c696808
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ResourceRegistration.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.*;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.osgi.service.http.HttpContext;
+
+public class ResourceRegistration extends Registration {
+ private static final String LAST_MODIFIED = "Last-Modified"; //$NON-NLS-1$
+ private static final String IF_MODIFIED_SINCE = "If-Modified-Since"; //$NON-NLS-1$
+ private static final String IF_NONE_MATCH = "If-None-Match"; //$NON-NLS-1$
+ private static final String ETAG = "ETag"; //$NON-NLS-1$
+
+ private String internalName;
+ HttpContext httpContext;
+ private ServletContext servletContext;
+ private AccessControlContext acc;
+
+ public ResourceRegistration(String internalName, HttpContext context, ServletContext servletContext, AccessControlContext acc) {
+ this.internalName = internalName;
+ if (internalName.equals("/")) { //$NON-NLS-1$
+ this.internalName = ""; //$NON-NLS-1$
+ }
+ this.httpContext = context;
+ this.servletContext = servletContext;
+ this.acc = acc;
+ }
+
+ public boolean handleRequest(HttpServletRequest req, final HttpServletResponse resp, String alias) throws IOException {
+ if (httpContext.handleSecurity(req, resp)) {
+
+ String method = req.getMethod();
+ if (method.equals("GET") || method.equals("POST") || method.equals("HEAD")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+
+ String pathInfo = HttpServletRequestAdaptor.getDispatchPathInfo(req);
+ int aliasLength = alias.equals("/") ? 0 : alias.length(); //$NON-NLS-1$
+ String resourcePath = internalName + pathInfo.substring(aliasLength);
+ URL testURL = httpContext.getResource(resourcePath);
+ if (testURL == null) {
+ return false;
+ }
+ return writeResource(req, resp, resourcePath);
+ }
+ resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ }
+ return true;
+ }
+
+ private boolean writeResource(final HttpServletRequest req, final HttpServletResponse resp, final String resourcePath) throws IOException {
+ Boolean result = Boolean.TRUE;
+ try {
+ result = (Boolean) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+
+ public Object run() throws Exception {
+ URL url = httpContext.getResource(resourcePath);
+ if (url == null)
+ return Boolean.FALSE;
+
+ URLConnection connection = url.openConnection();
+ long lastModified = connection.getLastModified();
+ int contentLength = connection.getContentLength();
+
+ String etag = null;
+ if (lastModified != -1 && contentLength != -1)
+ etag = "W/\"" + contentLength + "-" + lastModified + "\""; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+
+ // Check for cache revalidation.
+ // We should prefer ETag validation as the guarantees are stronger and all HTTP 1.1 clients should be using it
+ String ifNoneMatch = req.getHeader(IF_NONE_MATCH);
+ if (ifNoneMatch != null && etag != null && ifNoneMatch.indexOf(etag) != -1) {
+ resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return Boolean.TRUE;
+ } else {
+ long ifModifiedSince = req.getDateHeader(IF_MODIFIED_SINCE);
+ // for purposes of comparison we add 999 to ifModifiedSince since the fidelity
+ // of the IMS header generally doesn't include milli-seconds
+ if (ifModifiedSince > -1 && lastModified > 0 && lastModified <= (ifModifiedSince + 999)) {
+ resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return Boolean.TRUE;
+ }
+ }
+
+ // return the full contents regularly
+ if (contentLength != -1)
+ resp.setContentLength(contentLength);
+
+ String contentType = httpContext.getMimeType(resourcePath);
+ if (contentType == null)
+ contentType = servletContext.getMimeType(resourcePath);
+
+ if (contentType != null)
+ resp.setContentType(contentType);
+
+ if (lastModified > 0)
+ resp.setDateHeader(LAST_MODIFIED, lastModified);
+
+ if (etag != null)
+ resp.setHeader(ETAG, etag);
+
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+ OutputStream os = resp.getOutputStream();
+ byte[] buffer = new byte[8192];
+ int bytesRead = is.read(buffer);
+ int writtenContentLength = 0;
+ while (bytesRead != -1) {
+ os.write(buffer, 0, bytesRead);
+ writtenContentLength += bytesRead;
+ bytesRead = is.read(buffer);
+ }
+ if (contentLength == -1 || contentLength != writtenContentLength)
+ resp.setContentLength(writtenContentLength);
+ } finally {
+ if (is != null)
+ is.close();
+ }
+ return Boolean.TRUE;
+ }
+ }, acc);
+ } catch (PrivilegedActionException e) {
+ throw (IOException) e.getException();
+ }
+ return result.booleanValue();
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java
new file mode 100644
index 000000000..44ed9f113
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.util.*;
+import javax.servlet.*;
+
+public class ServletConfigImpl implements ServletConfig {
+
+ private static final Dictionary EMPTY_PARAMS = new Hashtable(0);
+ private static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$
+ private Servlet servlet;
+ private Dictionary initparams;
+ private ServletContext servletContext;
+
+ public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext) {
+ this.servlet = servlet;
+ this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS;
+ this.servletContext = servletContext;
+ }
+
+ /*
+ * @see javax.servlet.ServletConfig#getServletName()
+ *
+ * The OSGi Http Service does not specify a way to set a servlet name at the API level. This
+ * implementation will try to use the value of the "servlet-name" initial parameter if available.
+ */
+ public String getServletName() {
+ String servletName = (String) initparams.get(SERVLET_NAME);
+ return (servletName != null) ? servletName : servlet.getClass().getName();
+ }
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public String getInitParameter(String name) {
+ return (String) initparams.get(name);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return initparams.keys();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java
new file mode 100644
index 000000000..8afc9a2f1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletContextAdaptor.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.*;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.*;
+import java.util.*;
+import javax.servlet.*;
+import org.osgi.service.http.HttpContext;
+
+public class ServletContextAdaptor implements ServletContext {
+
+ private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir"; //$NON-NLS-1$
+ private ServletContext servletContext;
+ HttpContext httpContext;
+ private AccessControlContext acc;
+ private ProxyContext proxyContext;
+
+ public ServletContextAdaptor(ProxyContext proxyContext, ServletContext servletContext, HttpContext httpContext, AccessControlContext acc) {
+ this.servletContext = servletContext;
+ this.httpContext = httpContext;
+ this.acc = acc;
+ this.proxyContext = proxyContext;
+ proxyContext.createContextAttributes(httpContext);
+
+ if (proxyContext.getContextAttributes(httpContext).get(JAVAX_SERVLET_CONTEXT_TEMPDIR) == null) {
+ File tempDir = (File) servletContext.getAttribute(JAVAX_SERVLET_CONTEXT_TEMPDIR);
+ if (tempDir != null) {
+ File contextTempDir = new File(tempDir, "HttpContext" + httpContext.hashCode()); //$NON-NLS-1$
+ contextTempDir.mkdirs();
+ contextTempDir.deleteOnExit();
+ proxyContext.getContextAttributes(httpContext).put(JAVAX_SERVLET_CONTEXT_TEMPDIR, contextTempDir);
+ }
+ }
+ }
+
+ /**
+ * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
+ *
+ * This method was added in the Servlet 2.3 API however the OSGi HttpService currently does not provide
+ * support for this method in the HttpContext interface. To support "getResourcePaths(...) this
+ * implementation uses reflection to check for and then call the associated HttpContext.getResourcePaths(...)
+ * method opportunistically. Null is returned if the method is not present or fails.
+ */
+ public Set getResourcePaths(String name) {
+ if (name == null || !name.startsWith("/")) //$NON-NLS-1$
+ return null;
+ try {
+ Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] {String.class}); //$NON-NLS-1$
+ if (!getResourcePathsMethod.isAccessible())
+ getResourcePathsMethod.setAccessible(true);
+ return (Set) getResourcePathsMethod.invoke(httpContext, new Object[] {name});
+ } catch (Exception e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public Object getAttribute(String attributeName) {
+ Dictionary attributes = proxyContext.getContextAttributes(httpContext);
+ return attributes.get(attributeName);
+ }
+
+ public Enumeration getAttributeNames() {
+ Dictionary attributes = proxyContext.getContextAttributes(httpContext);
+ return attributes.keys();
+ }
+
+ public void setAttribute(String attributeName, Object attributeValue) {
+ Dictionary attributes = proxyContext.getContextAttributes(httpContext);
+ attributes.put(attributeName, attributeValue);
+ }
+
+ public void removeAttribute(String attributeName) {
+ Dictionary attributes = proxyContext.getContextAttributes(httpContext);
+ attributes.remove(attributeName);
+ }
+
+ public String getMimeType(String name) {
+ String mimeType = httpContext.getMimeType(name);
+ return (mimeType != null) ? mimeType : servletContext.getMimeType(name);
+ }
+
+ public URL getResource(final String name) {
+ try {
+ return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ return httpContext.getResource(name);
+ }
+ }, acc);
+ } catch (PrivilegedActionException e) {
+ log(e.getException().getMessage(), e.getException());
+ }
+ return null;
+ }
+
+ public InputStream getResourceAsStream(String name) {
+ URL url = getResource(name);
+ if (url != null) {
+ try {
+ return url.openStream();
+ } catch (IOException e) {
+ log("Error opening stream for resource '" + name + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return null;
+ }
+
+ public ServletContext getContext(String arg0) {
+ return servletContext.getContext(arg0);
+ }
+
+ public String getInitParameter(String arg0) {
+ return servletContext.getInitParameter(arg0);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return servletContext.getInitParameterNames();
+ }
+
+ public int getMajorVersion() {
+ return servletContext.getMajorVersion();
+ }
+
+ public int getMinorVersion() {
+ return servletContext.getMinorVersion();
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0) {
+ return new RequestDispatcherAdaptor(servletContext.getNamedDispatcher(arg0));
+ }
+
+ public String getRealPath(String arg0) {
+ return servletContext.getRealPath(arg0);
+ }
+
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ return new RequestDispatcherAdaptor(servletContext.getRequestDispatcher(proxyContext.getServletPath() + arg0));
+ }
+
+ public String getServerInfo() {
+ return servletContext.getServerInfo();
+ }
+
+ /**@deprecated*/
+ public Servlet getServlet(String arg0) throws ServletException {
+ return servletContext.getServlet(arg0);
+ }
+
+ public String getServletContextName() {
+ return servletContext.getServletContextName();
+ }
+
+ /**@deprecated*/
+ public Enumeration getServletNames() {
+ return servletContext.getServletNames();
+ }
+
+ /**@deprecated*/
+ public Enumeration getServlets() {
+ return servletContext.getServlets();
+ }
+
+ /**@deprecated*/
+ public void log(Exception arg0, String arg1) {
+ servletContext.log(arg0, arg1);
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ servletContext.log(arg0, arg1);
+ }
+
+ public void log(String arg0) {
+ servletContext.log(arg0);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletRegistration.java
new file mode 100644
index 000000000..4c08a9fb6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletRegistration.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Cognos Incorporated.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cognos Incorporated - initial API and implementation
+ * IBM Corporation - comments
+ *******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal;
+
+import java.io.IOException;
+import java.util.Set;
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.HttpContext;
+
+//This class wraps the servlet object registered in the HttpService.registerServlet call, to manage the context classloader when handleRequests are being asked.
+//It is also responsible to ensure that a given servlet has only been registered once.
+public class ServletRegistration extends Registration {
+
+ private Servlet servlet; //The actual servlet object registered against the http service. All requests will eventually be delegated to it.
+ private HttpContext httpContext; //The context used during the registration of the servlet
+ private Set servlets; //All the servlets registered against the instance of the proxy servlet that "ownes" self.
+ private ClassLoader registeredContextClassLoader;
+
+ public ServletRegistration(Servlet servlet, HttpContext context, Bundle bundle, Set servlets) {
+ this.servlet = servlet;
+ this.servlets = servlets;
+ this.httpContext = context;
+ registeredContextClassLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ public void destroy() {
+ ClassLoader original = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(registeredContextClassLoader);
+ super.destroy();
+ } finally {
+ Thread.currentThread().setContextClassLoader(original);
+ }
+ servlet.destroy();
+ }
+
+ public void close() {
+ servlets.remove(servlet);
+ }
+
+ //Delegate the init call to the actual servlet
+ public void init(ServletConfig servletConfig) throws ServletException {
+ ClassLoader original = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(registeredContextClassLoader);
+ servlet.init(servletConfig);
+ } finally {
+ Thread.currentThread().setContextClassLoader(original);
+ }
+ servlets.add(servlet);
+ }
+
+ public void checkServletRegistration() throws ServletException {
+ if (servlets.contains(servlet)) {
+ throw new ServletException("This servlet has already been registered at a different alias."); //$NON-NLS-1$
+ }
+ }
+
+ //Delegate the handling of the request to the actual servlet
+ public boolean handleRequest(HttpServletRequest req, HttpServletResponse resp, String alias) throws IOException, ServletException {
+ HttpServletRequest wrappedRequest = new HttpServletRequestAdaptor(req, alias, servlet);
+
+ if (httpContext.handleSecurity(wrappedRequest, resp)) {
+ ClassLoader original = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(registeredContextClassLoader);
+ servlet.service(wrappedRequest, resp);
+ } finally {
+ Thread.currentThread().setContextClassLoader(original);
+ }
+ }
+ return true;
+ }
+}

Back to the top