Announcement Announcement Module
Collapse
No announcement yet.
spring 2.0: how to use own spring-beans schema? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 2.0: how to use own spring-beans schema?

    hi,

    want to use a modified spring-beans.xsd file for my bean definitions.

    with following definition i get below Exception:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns=" http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    ../spring-beans.xsd">

    <bean ...

    </beans>


    exception:

    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Unknown Source)

  • #2
    Hi Vai

    The Spring 2.0 support for customising one's Spring XML configuration is not as of today detailed in the Spring reference documentation. It IS coming, it's just that other stuff has to date had a higher priority... transactions and AOP for example .

    However, the support has been in and stable for some time now, and early adopting members of the Spring community have already written a number of blogs about how to start writing one's own custom tags. Find below some links that might help you out.

    http://plainvanilla.typepad.com/spri...ol_cohere.html
    http://www.memestorm.com/blog/spring...n-on-steroids/
    http://blog.decaresystems.ie/index.p...chema-part-ii/
    http://mblog.lib.umich.edu/~jaynes/a..._20_-_xml.html

    If you posted back and gave everyone an idea of what it is you are actually trying to accomplish with the extensible tag someone might have a bright idea and help you out with more than just links

    Cheers
    Rick

    Comment


    • #3
      Recently I created simple bean parser decorator that extends default metadata parser and allows to define maps and lists of strings as metadata values. For example:

      <beans
      xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:meta="http://www.springframework.org/schema/meta"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schem...ring-beans.xsd
      http://www.springframework.org/schema/meta
      http://www.springframework.org/schema/meta/spring-meta.xsd">

      <bean id="foo">
      <meta:list name="testList">
      <meta:value>value1</meta:value>
      <meta:value>value2</meta:value>
      <meta:value>
      value31
      value32
      </meta:value>
      </meta:list>

      <meta:map name="testMap">
      <meta:entry key="key1">value1</meta:entry>
      <meta:entry key="key2">value2</meta:entry>
      </meta:map>

      </bean>

      </beans>

      I attached code to JIRA issue SPR-1711 about bean metadata. See http://opensource.atlassian.com/proj...rowse/SPR-1711

      Comment


      • #4
        Hello, im developing an XML extension. Without extension my Spring configuration is:

        Code:
        <bean id="dg.architecture.validator.Service" class="com.dg.architecture.service.validator.impl.ValidatorService">
        		<property name="configuration">
        			<bean class="com.dg.architecture.service.validator.impl.ValidatorConfiguration"/>
        		</property>
        	</bean>
        Now i want something like:
        Code:
         <dg:service name="dg.architecture.validator.Service" implementation="com.dg.architecture.service.validator.impl.ValidatorService" configuration="com.dg.architecture.service.validator.impl.ValidatorConfiguration" description=""/>
        I have developed but when i try to create the configuration bean property, i just don't know how to do because if i use the addPropertyReference() method with BeanDefinitionBuilder, passing the result of executing rootBeanDefinition method, an exception is thrown telling me that bean has no id.

        When i look the API i see a childBeanDefinition rather than rootBeanDefinition, but no class attribute is present. So how can i create using a NamespaceHandler for creating this embbedded bean (configuration) ?

        Thank you very much

        Comment

        Working...
        X