-
1. Re: Multiple parsing implementation in RARDeployer
vickyk May 23, 2008 2:13 PM (in response to vickyk)There already exists the MetaData for the ra.xml and jboss-ra.xml , these classes are ConnectorMetaData AND JBossRAMetaData .
All I need is to create a RARDeploymentMetaData which will should be set with ConnectorMetaData AND JbossRAMetaData values .
The RARParsingDeployer needs to do
1) Take the ra.xml+jboss-ra.xml and map it to ConnectorMetaData and JbossRAMetaData.
2) The merge(..) or some other method should create the RARDeploymentMetaData and set the ConnectorMetaData+JbossRAMetaData in it .
I have referred to the mergeFiles(..) of the TestBeanMergeDeployer and found that it returns the KernelDeployment , I am not able to figure out how to get the ConnectorMetaData+JbossRAMetaData and set these values in RARDeploymentMetaData.
How can I do that ?
I am yet not sure if I need OMFD or SRD , any thoughts ? -
2. Re: Multiple parsing implementation in RARDeployer
alesj May 23, 2008 2:29 PM (in response to vickyk)"vickyk" wrote:
How can I do that ?
Currently there is no elegant solution. :-)
The problem that I see is that SRDeployer is expecting single output type (in test's case it's KernelDeloyment), where we actually need different types out of parse method, and combine them in merge function."vickyk" wrote:
I am yet not sure if I need OMFD or SRD , any thoughts ?
I'll prepare you a proper multi-input-type/single-output-type parser/deployer, along with the tests over the weekend. ;-) -
3. Re: Multiple parsing implementation in RARDeployer
vickyk May 23, 2008 3:22 PM (in response to vickyk)"vickyk" wrote:
I am yet not sure if I need OMFD or SRD , any thoughts ?
Ok looks like the SRD will not be used unless the SchemaResolverFactory is updated as shown in this diff
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/common/jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SingletonSchemaResolverFactory.java/?revision=2753&r1=2753&r2=2752
Let me investigate more options . -
4. Re: Multiple parsing implementation in RARDeployer
vickyk May 23, 2008 3:26 PM (in response to vickyk)"alesj" wrote:
The problem that I see is that SRDeployer is expecting single output type (in test's case it's KernelDeloyment), where we actually need different types out of parse method, and combine them in merge function.
Yes but I am not sure if this would work as I understand that the SRD will not work unless SchemaResoverFactory is also updated.
Let me have a look at you tests . -
5. Re: Multiple parsing implementation in RARDeployer
alesj May 23, 2008 4:06 PM (in response to vickyk)"vickyk" wrote:
Yes but I am not sure if this would work as I understand that the SRD will not work unless SchemaResoverFactory is also updated.
Let me have a look at you tests.
I'll make it work. ;) -
6. Re: Multiple parsing implementation in RARDeployer
alesj May 23, 2008 7:21 PM (in response to vickyk)"alesj" wrote:
"vickyk" wrote:
Yes but I am not sure if this would work as I understand that the SRD will not work unless SchemaResoverFactory is also updated.
Let me have a look at you tests.
I'll make it work. ;)
OK, I've commited a few untested deployers that might get you started:
- MultipleSchemaResolverDeployer
- JBossExtensionDeployer
Check both of them, JED is specially suited for your needs.
I'll hack the tests tomorrow. -
7. Re: Multiple parsing implementation in RARDeployer
vickyk May 24, 2008 2:34 PM (in response to vickyk)Yes I see the MockRarDeployer doing exactly what I have asked , looks great .
http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/deployer/merge/support/MockRarDeployer.javaI'll hack the tests tomorrow.
Let me have a look at these tests too . -
8. Re: Multiple parsing implementation in RARDeployer
vickyk May 26, 2008 3:55 AM (in response to vickyk)I tried to map the real rar.xml with has the declaration as
<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: ra.xml 71789 2008-04-08 13:46:40Z adrian@jboss.org $ --> <connector xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" version="1.5"> <description>JBoss LocalTransaction JDBC Wrapper Resource Adapter</description> </connector>
I mapped this to this dummy MetaData@JBossXmlSchema(namespace="j2ee", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="connector") public class RealRarMetaData implements Serializable { public static final long serialUIDVersion = 1l; private String description; public String getDescription() { return description; } @XmlElement(name = "description") public void setDescription(String description) { this.description = description; } }
However when I tried to map the data from the ra.xml to the MetaData Object the DeployerParser complained as this14940 ERROR [AbstractController] Error installing to Parse: name=vfsfile:/home/vicky/eclipseworkspaces/workspace/jboss-deployers-trunk/deployers-vfs/target/tests-classes/bean/multiple/real-rar.jar/ state=Not Installed mode=Manual requiredState=Parse org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfsfile:/home/vicky/eclipseworkspaces/workspace/jboss-deployers-trunk/deployers-vfs/target/tests-classes/bean/multiple/real-rar.jar/ at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:343) at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:288) at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:238) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:174) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:970) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:911) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1394) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:786) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:914) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:836) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:674) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:456) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:594) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541) at org.jboss.test.deployers.vfs.deployer.DeployerClientTest.assertDeploy(DeployerClientTest.java:57) at org.jboss.test.deployers.vfs.deployer.DeployerClientTest.assertDeploy(DeployerClientTest.java:46) at org.jboss.test.deployers.vfs.deployer.merge.test.MockRarUnitTestCase.testRarMerge(MockRarUnitTestCase.java:71) at org.jboss.test.deployers.vfs.deployer.merge.test.MockRarUnitTestCase.testSpecRar(MockRarUnitTestCase.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: Failed to parse schema for nsURI=http://java.sun.com/xml/ns/j2ee, baseURI=null, schemaLocation=http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:193) at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:153) at org.jboss.deployers.vfs.spi.deployer.JBossXBDeployer.parse(JBossXBDeployer.java:167) at org.jboss.deployers.vfs.spi.deployer.MultipleSchemaResolverDeployer.mergeFiles(MultipleSchemaResolverDeployer.java:168) at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parse(AbstractVFSParsingDeployer.java:156) at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:331) ... 41 more Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Failed to parse schema for nsURI=http://java.sun.com/xml/ns/j2ee, baseURI=null, schemaLocation=http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:340) at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:302) at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:407) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source) at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:189) ... 46 more Caused by: org.jboss.xb.binding.JBossXBRuntimeException: -1:-1 31:3 The declaration for the entity "HTML.Version" must end with '>'. at org.jboss.xb.binding.sunday.unmarshalling.XsdBinderTerminatingErrorHandler.handleError(XsdBinderTerminatingErrorHandler.java:40) at org.apache.xerces.impl.xs.XMLSchemaLoader.reportDOMFatalError(Unknown Source) at org.apache.xerces.impl.xs.XSLoaderImpl.load(Unknown Source) at org.jboss.xb.binding.Util.loadSchema(Util.java:395) at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:175) at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:146) at org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver.resolve(DefaultSchemaResolver.java:332) ... 61 more
What is that I am missing here ? -
9. Re: Multiple parsing implementation in RARDeployer
alesj May 26, 2008 5:33 AM (in response to vickyk)Your namespace is wrong, it should be a full name: xmlns="http://java.sun.com/xml/ns/j2ee" != namespace="j2ee".
I've changed the tests to use your xml.
But I needed to disable validation. -
10. Re: Multiple parsing implementation in RARDeployer
vickyk May 27, 2008 6:24 AM (in response to vickyk)"alesj" wrote:
Your namespace is wrong, it should be a full name: xmlns="http://java.sun.com/xml/ns/j2ee" != namespace="j2ee".
Yes i see it working , not sure why I did not get it when I had placed the same ns earlier ;(
Ales , using the SRD approach means a lot of annotation changes in the MetaData .
I am just wondering how much task it would be to get this working with OMFD approach , since we have ObjectModelFactory ready for the ra.xml/jboss-ra.xml .
How much change it would mean if we use OMFD which will be parsing the multiple xml's and using multiple ObjectModelFactory inside the merge(..) implementation ? -
11. Re: Multiple parsing implementation in RARDeployer
alesj May 27, 2008 8:23 AM (in response to vickyk)"vickyk" wrote:
Ales , using the SRD approach means a lot of annotation changes in the MetaData .
I am just wondering how much task it would be to get this working with OMFD approach , since we have ObjectModelFactory ready for the ra.xml/jboss-ra.xml .
How much change it would mean if we use OMFD which will be parsing the multiple xml's and using multiple ObjectModelFactory inside the merge(..) implementation ?
I have refactored the code, so you can now easily add your MultipleOMFD.
- http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleObjectModelFactoryDeployer.java -
12. Re: Multiple parsing implementation in RARDeployer
vickyk May 28, 2008 2:03 AM (in response to vickyk)"alesj" wrote:
I have refactored the code, so you can now easily add your MultipleOMFD.
- http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleObjectModelFactoryDeployer.java
Ales , you are on fire ;)
I am still trying to see how this can be used .
We have 2 ObjectModel factories which are
1) ResourceAdapterObjectModelFactory , this creates the ObjectModel for the ra.xml file .
2) JBossRAObjectModelFactory , this creates the ObjectModel for the jboss-ra.xml file.
I am not able to find out where in I can pass the ObjectModelFactories and do the merging of MetaData to the required MetaData Object .
I was able to write it with SRD aspublic class RARParserDeployer extends JBossExtensionDeployer<ConnectorMetaData, JBossRAMetaData, RARDeploymentMetaData> { /** The metadata repsoitory */ private JCAMetaDataRepository metaDataRepository; /** * Create a new RARParserDeployer. */ public RARParserDeployer() { //super(ConnectorMetaData.class); //setName("ra.xml"); super(RARDeploymentMetaData.class, "ra.xml", ConnectorMetaData.class, "jboss-ra.xml", JBossRAMetaData.class); } public JCAMetaDataRepository getMetaDataRepository() { return metaDataRepository; } public void setMetaDataRepository(JCAMetaDataRepository metaDataRepository) { this.metaDataRepository = metaDataRepository; } /* protected ObjectModelFactory getObjectModelFactory(ConnectorMetaData root) { return new ResourceAdapterObjectModelFactory(); } */ //@Override // Check this STUFF protected void init(VFSDeploymentUnit unit, ConnectorMetaData cmd, VirtualFile file) throws Exception { cmd.setURL(file.toURL()); VFSDeploymentUnit parent = unit.getParent(); String name = unit.getSimpleName(); if( parent != null ) name = parent.getSimpleName() + "#" + name; metaDataRepository.addConnectorMetaData(name, cmd); } private ConnectorMetaData specMetaData; private JBossRAMetaData jbossSpecificMetaData; protected RARDeploymentMetaData mergeMetaData(VFSDeploymentUnit unit, ConnectorMetaData specMetaData, JBossRAMetaData jbossSpecificMetaData) throws Exception { this.specMetaData = specMetaData; this.jbossSpecificMetaData = jbossSpecificMetaData; RARDeploymentMetaData deployment = new RARDeploymentMetaData(); if (specMetaData != null) { deployment.setConnectorMetaData(specMetaData); } if (jbossSpecificMetaData != null) { deployment.setRaXmlMetaData(jbossSpecificMetaData); } return deployment; } public ConnectorMetaData getSpecMetaData() { return specMetaData; } public JBossRAMetaData getJbossSpecificMetaData() { return jbossSpecificMetaData; } }
Ales , can you give me some outline for OMFD scenario ?
I will take it from there .
PS: The SRD is just a raw outline as I felt OMFD will make life simpler . -
13. Re: Multiple parsing implementation in RARDeployer
alesj May 28, 2008 4:14 AM (in response to vickyk)"vickyk" wrote:
Ales , can you give me some outline for OMFD scenario ?
I will take it from there .
I've fixed the MultipleObjectModelFactoryDeployer to have better/right method to handle ObjectModelFactory creation for specific file/class.
My outline - play with this class. ;-)
If after two days you still don't succeed, let me know. -
14. Re: Multiple parsing implementation in RARDeployer
vickyk May 29, 2008 4:52 AM (in response to vickyk)"alesj" wrote:
"vickyk" wrote:
My outline - play with this class. ;-)
If after two days you still don't succeed, let me know.
I have managed to get RARParserDeployer working after making the changes in the MultipleVFSParsingDeployer , I commented the mappings sectionpublic MultipleVFSParsingDeployer(Class<T> output, Map<String, Class<?>> mappings, String suffix, Class<?> suffixClass) { super(output); //if (mappings == null || mappings.isEmpty()) // throw new IllegalArgumentException("Illegal mappings"); this.mappings = mappings; setNames(mappings.keySet()); setSuffix(suffix); if (suffix != null && suffixClass == null) throw new IllegalArgumentException("Null suffix class"); this.suffixClass = suffixClass; }
However when I ran the testcases I started getting these errors*** DEPLOYMENTS IN ERROR: Name -> Error vfsfile:/home/vicky/eclipseworkspaces/workspace/jboss5-trunk/testsuite/output/lib/jcatest.jar -> org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/home/vicky/eclipseworkspaces/workspace/jboss5-trunk/testsuite/output/lib/jcatest.jar *** CONTEXTS IN ERROR: Name -> Error vfsfile:/home/vicky/eclipseworkspaces/workspace/jboss5-trunk/testsuite/output/lib/jcatest.jar -> java.lang.NoSuchMethodError: org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(Lorg/jboss/virtual/VirtualFile;)Ljava/lang/Object;
I am not able to see the required parse(.. ) implementation in the SchemaResolverDeployer , looks like the recent changes had remove this method .