[
https://jira.jboss.org/jira/browse/DNA-264?page=com.atlassian.jira.plugin...
]
Randall Hauch resolved DNA-264.
-------------------------------
Resolution: Done
This change adds the ability in ExecutionContext to get a MimeTypeDetector, which can be
used to get the MIME type for some content. This allows a connector (such as the File
System Connector) to detect the MIME type given the name/content.
Several options were considered, but this proved to be the "best" approach. One
option considered was adding a "getMimeTypeDetector()" to RepositoryContext,
which are handed to RepositorySource instances when they're managed. Since very few
RepositorySource implementations need to use this, it seemed like it raised the bar (in
terms of work) for connector implementors. And, that only let the RepositorySource have
access to a MimeTypeDetector, and the connector still had to pass it around to the
different components that needed it (e.g., the RepositoryConnection implementation, and
then the RequestProcessor implementation).
Another option considered was moving the MimeTypes, MimeTypeDetectorConfig, and
MimeTypeDetectors (the component library) classes from 'org.jboss.dna.repository'
into 'org.jboss.dna.graph'. This would have made the Graph project more heavy
weight, and wouldn't have really solved the problem. Using MimeTypes would have,
however, since it contains static methods that delegate to a singleton MimeTypeDetectors
library - but singletons have a lot of disadvantages when it comes to flexible
configuration and dependencies. Therefore this option was not chosen.
The final option considered (and chosen) was putting the "getMimeTypeDetector()"
in ExecutionContext. Since there are a lot of components in DNA that already have access
to ExecutionContext, this approach made MIME type detection available to them all.
This approach required providing a default implementation of a MimeTypeDetector in
BasicExecutionContext (the default implementation of ExecutionContext), so there is now a
new lightweight and reusable MimeTypeDetector implementation called
ExtensionBasedMimeTypeDetector that reads a well-known properties file
("/org/jboss/dna/graph/MimeTypes.properties") as a resource from the
classloader, and this file defines the extensions for each MIME type. A file containing
many common extensions is provided as part of 'org.jboss.dna.graph', although a
user can either supply their own (at the same resource location) or use a different
constructor that takes the mappings as a constructor parameter. This implementation,
which only looks at the name, may not be as powerful or robust as the Aperture
extension's implementation, but it is very lightweight and easy to manage.
Connectors may need to determine the MIME type for content
----------------------------------------------------------
Key: DNA-264
URL:
https://jira.jboss.org/jira/browse/DNA-264
Project: DNA
Issue Type: Task
Reporter: Randall Hauch
Assignee: Randall Hauch
Some connectors may need to be able to determine the MIME type for content, and
there's currently no way in the connector API to do that. The 'dna-graph'
project does have MimeTypeDetector interface, but that's meant as a lower-level
interface for an implementation. MimeType was designed to be the main entry point for
general components, but that's currently in 'dna-repository' (and connectors
don't currently require that).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira