How to combine FileContentPattern with XmlPatterns ?


I'm currently trying to implement a facet for an internal framework.

I have some problem to implement the "createSuitableFilePattern". The framework dectection is based on the presence of a Spring bean with a specficic value for the attribute 'class'

Here's how I try tho do that :

return FileContentPattern.fileContent()
        .xmlWithRootTag("beans").and(XmlPatterns.xmlTag().withName("bean").withAttributeValue("class", "com.bsb.fluid.core.model.scanner.ScanningConfiguration"));

But this does not seem to work. The first part (before ".and") works, it detects correctly all spring configuration file, but the complete pattern does not work.

Is there a way to implement what I'm trying to do ?

I also noticed that facet configuration seems to have some kind of cache. Restarting does not always take changes of the method "createSuitableFilePattern" into account, I need to add/remove some plugins before it works correctly.

Is there a way to bypass that cache ?



1 comment

I was finally able to implement what I wanted to do like this :

  public ElementPattern<FileContent> createSuitableFilePattern() {
    return FileContentPattern.fileContent()
      .with(new PatternCondition<FileContent>("fluidCondition") {
        public boolean accepts(@NotNull FileContent fileContent, ProcessingContext context) {
          StdXMLBuilder builder = new StdXMLBuilder();
          NanoXmlUtil.parse(CharArrayUtil.readerFromCharSequence(fileContent.getContentAsText()), builder);
          IXMLElement result = (IXMLElement)builder.getResult();
          for (Object beanObject : result.getChildrenNamed("bean")) {
            IXMLElement bean = (IXMLElement)beanObject;
            String aClass = bean.getAttribute("class", "");
            if ("com.bsb.fluid.core.model.scanner.ScanningConfiguration".equals(aClass)) {
              return true;
          return false;

But I still have a lot of questions and misunderstandings. Is there any documentation on how to implement Facets somewhere ?




Please sign in to leave a comment.