Announcement Announcement Module
Collapse
No announcement yet.
Extending Spring with new Schema Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending Spring with new Schema

    Hi,

    I'm trying to extend Spring, and in the process supply a new schema.

    Here's the background (reason) for my extension. I want to extend the SimpleRemoteStatelessSessionProxyFactoryBean to allow a list of MethodInterceptors to be set. These interceptors should be called before the proxy is called (and subsequently the EJB). I'm using these interceptors to move context from a local thread into a request context.

    So I've made an extension of RemoteStatelessSessionBeanDefinitionParser (which actually can't be extended, as it for some reason is package private. so I had to extend AbstractSingleBeanDefinitionParser and duplicate the business logic from the subimplementations) and a separate NamespaceHandler.

    So, here's the issue. I have to implement the postProcess to process the custom element I have called "method-interceptors". It's defined like this in my xsd:
    Code:
    <xsd:element name="method-interceptors"  minOccurs="0" maxOccurs="1">   
      <xsd:complexType> 
        <xsd:sequence>                                          
          <xsd:element ref="beans:list"/> 
        </xsd:sequence>                                         
      </xsd:complexType> 
    </xsd:element>
    My context.xml:
    Code:
    ....(part of remote-slsb-extension)...
    <myscema:method-interceptor>
       <list><bean ref="myInterceptorBean"/></list>
    </myscema:method-interceptor>
    ..
    This is my postProcess-code:
    Code:
           
    protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) { 
                    NodeList childNodes = element.getChildNodes(); 
                    for (int i = 0; i < childNodes.getLength(); i++) { 
                            Node node = childNodes.item(i); 
    if(METHOD_INTERCEPTORS.equals(node.getLocalName())){ 
                                    //Get the listNode 
                                    Node listNode = node.getFirstChild(); 
                                    NodeList interceptors = listNode.getChildNodes(); 
                                    //TODO: Implement
                            } 
                    } 
            }
    At the todo, I want to get the List of bean-refs that is in my context.xml and set it on my bean. But I can't figure out how. The parameters provided through the method doesn't really help me. Obviously, I'm just being stupid...but instead of waisting more time trying to find out this myself I thought I'd give the forum a go. Basically what I want is a way to convert this nodeList into a javalist and set it on my bean instance...

  • #2
    I think what you need is probably a BeanDefinitionParserDelegate - you can use it to embed beans namespace elements inside a custim namespace.

    Comment


    • #3
      Originally posted by Dave Syer View Post
      I think what you need is probably a BeanDefinitionParserDelegate - you can use it to embed beans namespace elements inside a custim namespace.
      Well that class isn't documented very well, and the usage is even worse documented.

      Can you provide me some example code, and tell me which method I should hook into from the AbstractSimpleBeanDefinitionParser to where the necessary variables are available?

      Comment

      Working...
      X