[
https://issues.apache.org/jira/browse/FELIX-1211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717951#action_12717951
]
Felix Meschberger commented on FELIX-1211:
------------------------------------------
The Web Console bundle itself registers a path with the OSGi HttpService as
resources. This makes it easy to supply resources, since the Web Console just
has to provide an URL to the resource, while the HttpService itself spools the
resource with the correct response headers to the client.
For plugins various options exist:
(1) Plugins register resources with HttpService
I am not sure, whether it is a good idea to create dependencies on the
HttpService for web console plugins
(2) The plugins spool the resource themselves
This option is implemented by the Apache Sling Commons MIME console plugin in
the MimeTypeWebConsolePlugin [1] class. This plugin overwrites the doGet method
and checks whether the request is for a "/res/*" resource below the plugins own
page.
(2a) Approach (2) could be enhanced by abstracting the spoolResource method
into the AbstractWebConsolePlugin and define a new abstract getResource method,
which returns an URL to a resource, should the request address an URL. This
method would be implemented in the AbstractWebConsolePlugin extension
(2b) The drawback of approach (2a) is, that it requires a plugin to extend the
AbstractWebConsolePlugin to provide resources. Going in the direction of the
Declarative Services specification, the web console looks for a "URL
getResource(String)" method in the plugin class (and its ancestor classes) to
call to resolve resources. This would allow for automatic support for
resources. The method must be public or protected, but may be private if it is
declared in the plugin class itself.
(3) Plugin lists resource paths in Manifest
The bundle manifest of the plugin could provide a manifest header listing
resource-paths. The Web Console would then use the providing bundle to access
resources. The drawback of this approach is, that it detaches the plugin from
the resource it needs.
In light of FELIX-1043 (not requiring to extend AbstractWebConsolePlugin to
extend the web console) I prefer approach 2b.
[1]
https://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/commons/mime/src/main/java/org/apache/sling/commons/mime/internal/MimeTypeWebConsolePlugin.java
> How to provide resources like CSS or JavaScript files for plugins
> -----------------------------------------------------------------
>
> Key: FELIX-1211
> URL: https://issues.apache.org/jira/browse/FELIX-1211
> Project: Felix
> Issue Type: Sub-task
> Reporter: Felix Meschberger
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.