upgrading custom interceptors from 3 to 4

106 views
Skip to first unread message

Fabian Kessler

unread,
Mar 12, 2014, 5:55:13 PM3/12/14
to membrane...@googlegroups.com
i could not find anything about upgrading in the documentation, so i've started this page:
https://github.com/membrane/service-proxy/wiki/Upgrading-from-service-proxy-3.x-to-4.x

currently i'm stuck with the following 2 questions, i think that something has changed completely related to configuration.

  • Custom interceptors (that implement membrane's Interceptor or extend AbstractInterceptor that previously had an annotation @com.predic8.membrane.core.config.ElementName now need ???
  • AbstractInterceptor.parseAttributes() => ???

Fabian Kessler

unread,
Nov 19, 2014, 12:46:56 PM11/19/14
to membrane...@googlegroups.com
In version 3.5 it is possible to write interceptors that have their own xml tag, with attributes.
Can someone point me at a piece of documentation how to achieve this in version 4?
On http://www.membrane-soa.org/service-proxy-doc/4.0/interceptors/ I can't find anything.

In 3.5 it works with an annotation on the class
@com.predic8.membrane.core.config.ElementName("myInterceptor")
and overriding the parseAttributes() method.

In 4 it's with a @MCElement(name="myInterceptor") annotation on the class, and then injecting the properties
with @MCAttribute annotated setters. Nice. The LogInterceptor.class is one of them.

But using that won't work:

org.xml.sax.SAXParseException; lineNumber: 102; columnNumber: 64; cvc-complex-type.2.4.a: Invalid content was found starting with element 'myInterceptor'. One of '{"http://membrane-soa.org/proxies/1/":path, "http://membrane-soa.org/proxies/1/":ssl, "http://membrane-soa.org/proxies/1/":balancer, "http://membrane-soa.org/proxies/1/":statisticsJDBC, "http://membrane-soa.org/proxies/1/":statisticsProvider, "http://membrane-soa.org/proxies/1/":stompClient, "http://membrane-soa.org/proxies/1/":headerFilter, "http://membrane-soa.org/proxies/1/":throttle, "http://membrane-soa.org/proxies/1/":authHead2Body, "http://membrane-soa.org/proxies/1/":wadlRewriter, "http://membrane-soa.org/proxies/1/":dispatching, "http://membrane-soa.org/proxies/1/":webServer, "http://membrane-soa.org/proxies/1/":soap2Rest, "http://membrane-soa.org/proxies/1/":formValidation, "http://membrane-soa.org/proxies/1/":wsdlRewriter, "http://membrane-soa.org/proxies/1/":reverseProxying, "http://membrane-soa.org/proxies/1/":if, "http://membrane-soa.org/proxies/1/":switch, "http://membrane-soa.org/proxies/1/":adminConsole, "http://membrane-soa.org/proxies/1/":transform, "http://membrane-soa.org/proxies/1/":rest2Soap, "http://membrane-soa.org/proxies/1/":index, "http://membrane-soa.org/proxies/1/":login, "http://membrane-soa.org/proxies/1/":wsdlPublisher, "http://membrane-soa.org/proxies/1/":soapOperationExtractor, "http://membrane-soa.org/proxies/1/":soapStackTraceFilter, "http://membrane-soa.org/proxies/1/":rewriter, "http://membrane-soa.org/proxies/1/":exchangeStore, "http://membrane-soa.org/proxies/1/":limit, "http://membrane-soa.org/proxies/1/":basicAuthentication, "http://membrane-soa.org/proxies/1/":groovy, "http://membrane-soa.org/proxies/1/":accessControl, "http://membrane-soa.org/proxies/1/":log, "http://membrane-soa.org/proxies/1/":regExReplacer, "http://membrane-soa.org/proxies/1/":ruleMatching, "http://membrane-soa.org/proxies/1/":response, "http://membrane-soa.org/proxies/1/":testService, "http://membrane-soa.org/proxies/1/":httpClient, "http://membrane-soa.org/proxies/1/":xmlProtection, "http://membrane-soa.org/proxies/1/":clusterNotification, "http://membrane-soa.org/proxies/1/":userFeature, "http://membrane-soa.org/proxies/1/":statisticsCSV, "http://membrane-soa.org/proxies/1/":http2xml, "http://membrane-soa.org/proxies/1/":request, "http://membrane-soa.org/proxies/1/":interceptor, "http://membrane-soa.org/proxies/1/":counter, "http://membrane-soa.org/proxies/1/":analyser, "http://membrane-soa.org/proxies/1/":validator, "http://membrane-soa.org/proxies/1/":xmlContentFilter, "http://membrane-soa.org/proxies/1/":urlNormalizer, "http://membrane-soa.org/proxies/1/":oauth2Resource, "http://membrane-soa.org/proxies/1/":webServiceExplorer, WC[##other:"http://membrane-soa.org/proxies/1/"], "http://membrane-soa.org/proxies/1/":target}' is expected.

Because my tag is not in http://membrane-soa.org/schemas/proxies-1.xsd

What to do?

The example in membrane-service-proxy-4.0.17\examples\custom-interceptor uses a simple <interceptor refid="myInterceptor" /> tag.

Fabian Kessler

unread,
Nov 20, 2014, 4:35:48 AM11/20/14
to membrane...@googlegroups.com
By annotating my Interceptor class with

@MCMain(
        outputPackage="foo.myinterceptor.config.spring",
        outputName="router-foo.xsd",
        targetNamespace="http://membrane-soa.org/proxies/1/")

the Parser for my syntax was generated.

What's left (I believe) is to call
namespaceHandler.registerGlobalBeanDefinitionParser("myInterceptor", new MyInterceptorParser());
but I can't figure out yet how to achieve this.
It would be nice if I could just pack my contributed tag registration into a spring service that gets picked up.

The Changelog.txt writes:
  To extend Membrane's configuration language using the @MC... annotations,
  you now have to implement a Spring NamespaceHandler extending
  com.predic8.membrane.annot.AbstractNamespaceHandler . Use
  com.predic8.membrane.core.config.spring.NamespaceHandler as an example.

I did that but it's not picked up.

A separate Java project on GitHub with a demo interceptor would be nice.
Reply all
Reply to author
Forward
0 new messages