You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Stephane Landelle (JIRA)" <ji...@apache.org> on 2008/11/17 10:08:44 UTC
[jira] Created: (JCR-1861) Support classpath config
Support classpath config
------------------------
Key: JCR-1861
URL: https://issues.apache.org/jira/browse/JCR-1861
Project: Jackrabbit
Issue Type: Improvement
Components: config
Reporter: Stephane Landelle
Fix For: 1.5.0
It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
protected Element getIndexingConfigurationDOM() {
if (indexingConfiguration != null) {
return indexingConfiguration;
}
if (indexingConfigPath == null) {
return null;
}
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new IndexingConfigurationEntityResolver());
if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = this.getClass().getClassLoader();
}
InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
if (config == null) {
log.warn("Classpath resource does not exist: {}", indexingConfigPath);
return null;
}
indexingConfiguration = builder.parse(config).getDocumentElement();
log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
} else {
File config = new File(indexingConfigPath);
if (!config.exists()) {
log.warn("File does not exist: {}", indexingConfigPath);
return null;
} else if (!config.canRead()) {
log.warn("Cannot read file: {}", indexingConfigPath);
return null;
}
indexingConfiguration = builder.parse(config).getDocumentElement();
}
} catch (ParserConfigurationException e) {
log.warn("Unable to create XML parser", e);
} catch (IOException e) {
log.warn("Exception parsing " + indexingConfigPath, e);
} catch (SAXException e) {
log.warn("Exception parsing " + indexingConfigPath, e);
}
return indexingConfiguration;
}
Would it be possible to commit this in the trunk?
Best regards,
Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-1861) Support classpath config
Posted by "Stephane Landelle (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12650588#action_12650588 ]
Stephane Landelle commented on JCR-1861:
----------------------------------------
Yes, I totally agree, it would be nice to have a resource resolver that
would look up for resources on the filesystem or in the classpath and that
would be used for all the config files (repository.xml, indexing-config,
security-config, etc...).
Maybe we can have something similar to Spring Resource?
Sorry, for the patch format, I guess the linebreaks pb comes from the fact I
work on mac in UTF-8...
2008/11/25 Jukka Zitting (JIRA) <ji...@apache.org>
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit
> Issue Type: Improvement
> Components: config
> Reporter: Stephane Landelle
> Fix For: 1.6.0
>
> Attachments: classpathresolvingsearchindex.patch
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (JCR-1861) Support classpath config
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jukka Zitting updated JCR-1861:
-------------------------------
Fix Version/s: (was: 1.5.0)
1.6.0
Would you care to attach the change as a patch against Jackrabbit trunk? That would make it easier to review and apply.
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit
> Issue Type: Improvement
> Components: config
> Reporter: Stephane Landelle
> Fix For: 1.6.0
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-1861) Support classpath config
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12650583#action_12650583 ]
Jukka Zitting commented on JCR-1861:
------------------------------------
Thanks!
I wonder if we should make this into a generic feature that you could use also for the repository configuration file even outside jackrabbit-jca.
PS. Minor nits: your patch contains weird linebreaks (U+2028 LINE SEPARATOR) and uses tabs instead of spaces for indentation.
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit
> Issue Type: Improvement
> Components: config
> Reporter: Stephane Landelle
> Fix For: 1.6.0
>
> Attachments: classpathresolvingsearchindex.patch
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (JCR-1861) Support classpath config
Posted by "Stephane Landelle (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stephane Landelle updated JCR-1861:
-----------------------------------
Attachment: jackrabbit.patch
Hello,
Here is a new patch.
I've refactored out the code into a ResourceResolver. It's currenlty being used by JCARepositoryManager and SearchIndex but might be used for other needs too (just that I don't know Jackrabbit deep enough so I can identify where...).
Could this be committed?
Best Regards,
Stéphane Landelle
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit
> Issue Type: Improvement
> Components: config
> Reporter: Stephane Landelle
> Fix For: 1.6.0
>
> Attachments: classpathresolvingsearchindex.patch, jackrabbit.patch
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (JCR-1861) Support classpath config
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jukka Zitting updated JCR-1861:
-------------------------------
Component/s: jackrabbit-core
Fix Version/s: (was: 1.6.0)
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit Content Repository
> Issue Type: Improvement
> Components: config, jackrabbit-core
> Reporter: Stephane Landelle
> Attachments: classpathresolvingsearchindex.patch, jackrabbit.patch
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (JCR-1861) Support classpath config
Posted by "Stephane Landelle (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stephane Landelle updated JCR-1861:
-----------------------------------
Attachment: classpathresolvingsearchindex.patch
Here is an eclipse patch. Patch root is jackrabbit-core.
Best Regards,
Stephane Landelle
> Support classpath config
> ------------------------
>
> Key: JCR-1861
> URL: https://issues.apache.org/jira/browse/JCR-1861
> Project: Jackrabbit
> Issue Type: Improvement
> Components: config
> Reporter: Stephane Landelle
> Fix For: 1.6.0
>
> Attachments: classpathresolvingsearchindex.patch
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> It's possible (and even handy) not to have config resources as Files but as classpath resources, so they can be bundled into the binaries.
> For example, org.apache.jackrabbit.jca.JCARepositoryManager is able to resolve the repository config file as a classpath resource if it's prefixed with "classpath:".
> However, other config files such as the indexing configuration can't currently be resolved this way. IMHO, this is particularly a problem when using a connector, which should operate as a standalone bundle without requiring deploying additional resources on the filesystem.
> Concerning the indexing configuration, I've modified org.apache.jackrabbit.core.query.lucene.SearchIndex.getIndexingConfigurationDOM() so it resolves indexingConfiguration as a classpath resource if it's prefixed with "classpath:":
> protected Element getIndexingConfigurationDOM() {
> if (indexingConfiguration != null) {
> return indexingConfiguration;
> }
> if (indexingConfigPath == null) {
> return null;
> }
> try {
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> builder.setEntityResolver(new IndexingConfigurationEntityResolver());
> if (indexingConfigPath.startsWith(CLASSPATH_CONFIG_PREFIX)) {
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl == null) {
> cl = this.getClass().getClassLoader();
> }
> InputStream config = cl.getResourceAsStream(indexingConfigPath.substring(CLASSPATH_CONFIG_PREFIX.length()));
> if (config == null) {
> log.warn("Classpath resource does not exist: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> log.info("indexingConfigPath '{}' resolved as classpath resource", indexingConfigPath);
> } else {
> File config = new File(indexingConfigPath);
> if (!config.exists()) {
> log.warn("File does not exist: {}", indexingConfigPath);
> return null;
> } else if (!config.canRead()) {
> log.warn("Cannot read file: {}", indexingConfigPath);
> return null;
> }
> indexingConfiguration = builder.parse(config).getDocumentElement();
> }
>
>
> } catch (ParserConfigurationException e) {
> log.warn("Unable to create XML parser", e);
> } catch (IOException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> } catch (SAXException e) {
> log.warn("Exception parsing " + indexingConfigPath, e);
> }
> return indexingConfiguration;
> }
> Would it be possible to commit this in the trunk?
> Best regards,
> Stéphane Landelle
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.