|
From: Cameron B. <ca...@da...> - 2003-11-01 12:48:40
|
Actually .. after further investigation.. I can't seem to get the beanDefinitions anyway :( Any ideas ? Thanks. Cameron Braid wrote: > I just wanted to add that I for the second part of my question > (obtaining the bean ID for the current bean) I would implement > BeanFactoryAware and iterate through all of the bean names, calling > getBean(name) and checking for object identity. > > Does it make sense to add the ID and aliases into the > AbstractBeanDefinition and then to create a BeanDefinitionAware > interface that allows the bean to become aware ? > > Thanks again, > > Cameron > > Cameron Braid wrote: > >> Is there any way that I can allow a bean factory to find out its id >> attribute from the applicationContext.xml >> >> i.e. I am trying to get a grip on how spring works, and therefore I >> am trying to write a little integration layer to make spring an >> action factory for xwork, to allow me to use spring components and >> interceptors. I want to try and avoid repetition of configuration >> wherever possible. >> >> I have it at the stage where I have a bean declaration like this : >> >> <bean id="defaultActionTransactionAttributes" >> class="com.datacodex.spring.beans.PropertiesFactoryBean"> >> <property name="properties"> >> <props> >> <prop key="execute">PROPAGATION_REQUIRED</prop> >> </props> >> </property> >> </bean> >> >> <bean id="admin.SpringAdminAction" class="WebworkActionFactoryBean"> >> <property >> name="action"><value>/admin/SpringAdminAction</value></property> >> <property name="transactionManager"><ref >> local="transactionManager"/></property> >> <property name="transactionAttributes"><ref >> local="defaultActionTransactionAttributes"/></property> >> </bean> >> >> I would like to be able to access the id="admin.SpringAdminAction" >> value (or the bean name attribute) from within the >> WebworkActionFactoryBean therefore removing the need to have the >> extra 'action' property <property >> name="action"><value>/admin/SpringAdminAction</value></property>. >> >> Idealy I would like to use the /admin/SpringAdminAction as the bean >> id to make mapping from WebWork seamless, and without needing the >> conversion to '.' style. >> Therefore - is there any way that the bean id can be changed to allow >> any valid xml string ? Currently I am receiving an exception, from >> the xml validator. Can the id atttribuet be changed to be a >> >> [22:12:29]INFO [XmlBeanFactory] Loading XmlBeanFactory from >> InputStream [[ReadStream com.caucho.vfs.FileReadStream@190a0d6]] >> [22:12:29]ERROR[ContextLoader] Failed to initialize beans in >> application context: Line 44 in XML document is invalid; nested >> exception is: >> org.xml.sax.SAXParseException: Attribute value >> "/admin/SpringAdminAction" of type ID must be a name. >> org.xml.sax.SAXParseException: Attribute value >> "/admin/SpringAdminAction" of type ID must be a name. >> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) >> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) >> at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76) >> >> The dtd states that it myst be a valid XML ID, and to use the >> optional name attribute if you want an illegal name. Though this >> will require two identifyers for the bean, which I think is >> pointless. Does the ID have to be mandatory. Can't a validation be >> implemented in java to check that atleast the name or the id is >> supplied ? Then the same for the <!ATTLIST ref local IDREF >> #IMPLIED> this could be a CDATA with java based validation. >> >> Cheers, >> >> Cameron >> > > -- Any damn fool can write code that a computer can understand... The trick is to write code that humans can understand. [Martin Fowler http://www.martinfowler.com/distributedComputing/refactoring.pdf] |