[jboss-user] [Microcontainer] - Retrieve all metadata from a deployment unit.
beve
do-not-reply at jboss.com
Thu Apr 23 22:34:36 EDT 2009
Hi,
I'm wondering what the correct way of retrieving all metadata from a VFSDeploymentUnit is.
The following test decribes what we are doing.
| package org.jboss.deployers.vfs.plugins.structure;
|
| import static org.junit.Assert.assertEquals;
| import static org.junit.Assert.assertNotNull;
|
| import java.io.IOException;
| import java.net.URL;
| import java.util.Arrays;
| import java.util.List;
|
| import org.jboss.virtual.MemoryFileFactory;
| import org.jboss.virtual.VFS;
| import org.jboss.virtual.VirtualFile;
| import org.junit.Before;
| import org.junit.BeforeClass;
| import org.junit.Test;
|
| public class AbstractVFSDeploymentContextTest
| {
| private AbstractVFSDeploymentContext context;
| private String fileName = "/WEB-INF/wsdl/test.wsdl";
|
| @BeforeClass
| public static void initVFS()
| {
| VFS.init();
| }
|
| @Before
| public void populateVirtualFileSystem() throws IOException
| {
| context = new AbstractVFSDeploymentContext();
| URL dynamicClassRoot = new URL("vfsmemory", getClass().getSimpleName(), "");
| VirtualFile dynamicClasspathDir = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
| URL wsdlUrl = new URL(dynamicClassRoot + fileName);
| MemoryFileFactory.putFile(wsdlUrl, "wsdlcontent".getBytes());
|
| context.setMetaDataLocations(Arrays.asList(new VirtualFile[] {dynamicClasspathDir}));
| }
|
| @Test
| public void getMetaDataFile() throws IOException
| {
| VirtualFile metaDataFile = context.getMetaDataFile(fileName);
| assertNotNull(metaDataFile);
| }
|
| @Test
| public void getMetaDataFiles() throws IOException
| {
| List<VirtualFile> metaDataFiles = context.getMetaDataFiles(null, "");
| assertEquals(1, metaDataFiles.size());
| }
|
| @Test
| public void getAllMetaDataFiles() throws IOException
| {
| List<VirtualFile> metaDataFiles = context.getAllMetaDataFiles();
| assertEquals(1, metaDataFiles.size());
| }
|
| }
|
Now, the second test method, getMetaDataFiles, fails. This is what we are currently using to retrieve all metadata. Is there another way of retrieving all metadata?
For the third test method I add the following method to AbstractVFSDeploymentContext and it returns all metadata from the deployment context:
public List<VirtualFile> getAllMetaDataFiles()
| {
| List<VirtualFile> results = new ArrayList<VirtualFile>();
| try
| {
| for (VirtualFile location : metaDataLocations)
| {
| List<VirtualFile> result = location.getChildren();
| if (result != null && result.isEmpty() == false)
| {
| results.addAll(result);
| deployed();
| }
| }
| }
| catch(final IOException e)
| {
| log.debug("Error retrieving all meta data");
| }
| return results;
|
}
This is related to this jira: https://jira.jboss.org/jira/browse/JBWS-2619
Thanks,
/Daniel
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226401#4226401
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4226401
More information about the jboss-user
mailing list