-
1. Re: Parsing more than one file
adrian.brock Mar 28, 2008 8:20 AM (in response to alesj)The parsing multiple files has two parts:
1) Being able to parse n files into one piece of metatdata from one parsing deployer
This is so you can deploy something programmatically properly.
e.g. You pass EjbJarMetaData. The current parsing deployers will say,
ok I'm not going to reparse ejb-jar.xml but I will reparse jboss.xml
which is wrong
2) Being able to parse multiple files with the same suffix from META-INF.
e.g.
META-INF/a-beans.xml
META-INF/b-beans.xml
should create two KernelDeployment attachments (with the attachment names
as the metadata url).
But this requires the deployers further down the chain to understand it.
i.e. not use getAttachments(KernelDeployment.class) but use
getAllAttachments(KernelDeployment.class) and handle the multiple pieces
of configuration correctly. -
2. Re: Parsing more than one file
adrian.brock Mar 28, 2008 8:21 AM (in response to alesj)Again these are implementation details i.e. not requirements for CR1
-
3. Re: Parsing more than one file
alesj Mar 28, 2008 6:50 PM (in response to alesj)"adrian@jboss.org" wrote:
Again these are implementation details i.e. not requirements for CR1
But I can keep my 'parseMultipleFiles' hook? -
4. Re: Parsing more than one file
adrian.brock Mar 29, 2008 5:42 AM (in response to alesj)"alesj" wrote:
"adrian@jboss.org" wrote:
Again these are implementation details i.e. not requirements for CR1
But I can keep my 'parseMultipleFiles' hook?
If you like, but provide a way to do what I said above
i.e. create multiple attachments for each file which should be the usual implementation
when not throwing an error because it is not supported. e.g. you can't have
two web.xmls -
5. Re: Parsing more than one file
alesj Mar 31, 2008 9:36 AM (in response to alesj)"adrian@jboss.org" wrote:
2) Being able to parse multiple files with the same suffix from META-INF.
e.g.
META-INF/a-beans.xml
META-INF/b-beans.xml
should create two KernelDeployment attachments (with the attachment names
as the metadata url).
But this requires the deployers further down the chain to understand it.
i.e. not use getAttachments(KernelDeployment.class) but use
getAllAttachments(KernelDeployment.class) and handle the multiple pieces
of configuration correctly.
This is done.
KernelDeploymentDeployer already handles KernelDeployments in such way - getAllMetaData(KernelDeployment.class)."adrian@jboss.org" wrote:
1) Being able to parse n files into one piece of metatdata from one parsing deployer
This is so you can deploy something programmatically properly.
e.g. You pass EjbJarMetaData. The current parsing deployers will say,
ok I'm not going to reparse ejb-jar.xml but I will reparse jboss.xml
which is wrong
This probably requires change into AbstractParsingDeployerWithOutput, to take more than one name? -
6. Re: Parsing more than one file
alesj Mar 31, 2008 11:30 AM (in response to alesj)"alesj" wrote:
This probably requires change into AbstractParsingDeployerWithOutput, to take more than one name?
Is there a default impl we want/can do with these two new methods - handling multiple names in AbstractParsingDeployerWithOutput:if (suffix == null) { if (hasSingleName()) result = parse(unit, getName(), result); else result = parse(unit, names, result); } else { if (hasSingleName()) result = parse(unit, getName(), suffix, result); else result = parse(unit, names, suffix, result); } protected T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception { return null; } protected T parse(DeploymentUnit unit, Set<String> names, String suffix, T root) throws Exception { return null; }
-
7. Re: Parsing more than one file
alesj Mar 31, 2008 11:42 AM (in response to alesj)"alesj" wrote:
Is there a default impl we want/can do with these two new methods - handling multiple names in AbstractParsingDeployerWithOutput:protected T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception { return null; }
This one is no brainer. :-)protected T parse(DeploymentUnit unit, Set<String> names, T root) throws Exception { if (names == null || names.isEmpty()) throw new IllegalArgumentException("Null or empty names."); VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit; Set<VirtualFile> files = new HashSet<VirtualFile>(); Set<String> missingFiles = new HashSet<String>(); for (String name : names) { VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name); if (file != null) files.add(file); else missingFiles.add(name); } if (missingFiles.size() == names.size()) return null; return mergeFiles(files, missingFiles); } /** * Merge files into one piece of metatdata * * @param files matching meta files * @param missingFiles file names that are missing matching file * @return merged metadata */ protected T mergeFiles(Set<VirtualFile> files, Set<String> missingFiles) { return null; }
-
8. Re: Parsing more than one file
alesj Mar 31, 2008 11:52 AM (in response to alesj)"alesj" wrote:
This one is no brainer. :-)
So it the second one. :-)
It just matches more files, due to additional suffix match.protected T parse(DeploymentUnit unit, Set<String> names, String suffix, T root) throws Exception { if (names == null || names.isEmpty()) throw new IllegalArgumentException("Null or empty names."); VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit; Set<VirtualFile> files = new HashSet<VirtualFile>(); Set<String> missingFiles = new HashSet<String>(); for (String name : names) { List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix); if (matched != null && matched.isEmpty() == false) files.addAll(matched); else missingFiles.add(name); } if (missingFiles.size() == names.size()) return null; return mergeFiles(files, missingFiles); }
-
9. Re: Parsing more than one file
alesj Mar 31, 2008 12:17 PM (in response to alesj)Merge method has been changed a bit:
/** * Merge files into one piece of metatdata * * @param unit the unit * @param root possibly null pre-existing root * @param files matching meta files * @param missingFiles file names that are missing matching file * @return merged metadata * @throws Exception for any error */ protected T mergeFiles(VFSDeploymentUnit unit, T root, Set<VirtualFile> files, Set<String> missingFiles) throws Exception { return null; }