Giter VIP home page Giter VIP logo

Comments (3)

BenRomberg avatar BenRomberg commented on August 21, 2024

This is how Spring is doing it: https://github.com/SpringSource/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

from c4j.

BenRomberg avatar BenRomberg commented on August 21, 2024

After some brainstorming with Timm we've found a nice solution:
There will be 2 configuration-files, located at the root classpath:

  • c4j-local.xml will include all project-specific configuration details, like root-package names, pure configuration, contract-scan-packages, etc. This allows us to have multiple c4j-local.xml files on the classpath, e.g. one for each library using C4J.
  • c4j-global.xml will include global configuration details making sense to be overridden by the actual project using a library, e.g. if contract violations should be logged or if assertions should be thrown. There can only be one c4j-global.xml file on the classpath.

from c4j.

BenRomberg avatar BenRomberg commented on August 21, 2024

This is how the XML-Files in c4j-systemtest look right now:

c4j-local.xml

<?xml version="1.0" encoding="UTF-8"?>
<c4j-local xmlns="http://c4j.vksi.de/c4j-local/">
    <configuration>
        <root-package>de.vksi.c4j.systemtest</root-package>
        <pure-validate>true</pure-validate>
        <pure-registry-import>systemtest-pure-registry.xml</pure-registry-import>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.defaultpreconditiontrue</root-package>
        <default-precondition>true</default-precondition>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.strengtheningpreconditionallowed</root-package>
        <strengthening-preconditions-allowed>true</strengthening-preconditions-allowed>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.externalcontract</root-package>
        <contract-scan-package>de.vksi.c4j.systemtest.config.externalcontract</contract-scan-package>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.purebehaviorskiponly</root-package>
        <pure-validate>false</pure-validate>
        <pure-skip-invariants>true</pure-skip-invariants>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.purebehaviorempty</root-package>
        <pure-validate>false</pure-validate>
        <pure-skip-invariants>false</pure-skip-invariants>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.contractsdirectory</root-package>
        <contract-scan-package>de.vksi.c4j.systemtest.config.contractsdirectory</contract-scan-package>
    </configuration>
    <configuration>
        <root-package>de.vksi.c4j.systemtest.config.contractsdirectoryasjarfile</root-package>
        <contract-scan-package>de.vksi.c4j.systemtest.config.contractsdirectoryasjarfile</contract-scan-package>
    </configuration>
</c4j-local>

systemtest-pure-registry.xml (referenced within c4j-local.xml)

<?xml version="1.0" encoding="UTF-8"?>
<c4j-pure-registry xmlns="http://c4j.vksi.de/c4j-pure-registry/">
    <type name="com.external.ExternalClass">
        <pure-method signature="pureMethodWhitelistedInConfig()"/>
        <pure-method signature="pureStaticMethodWhitelistedInConfig()"/>
        <unpure-method signature="unpureMethodWhitelistedInConfig()"/>
        <unpure-method signature="unpureStaticMethodWhitelistedInConfig()"/>
    </type>
    <type name="java.lang.Boolean">
        <pure-method signature="booleanValue()"/>
    </type>
    <type name="java.lang.Class">
        <pure-method signature="desiredAssertionStatus()"/>
        <pure-method signature="getName()"/>
    </type>
    <type name="java.lang.Integer">
        <pure-method signature="intValue()"/>
        <pure-method signature="valueOf(int)"/>
    </type>
    <type name="java.lang.Object">
        <pure-method signature="getClass()"/>
        <pure-method signature="equals(java.lang.Object)"/>
        <pure-method signature="hashCode()"/>
        <pure-method signature="toString()"/>
    </type>
    <type name="java.lang.StackTraceElement">
        <pure-method signature="getClassName()"/>
    </type>
    <type name="java.lang.String">
        <pure-method signature="valueOf(java.lang.Object)"/>
    </type>
    <type name="java.lang.Throwable">
        <pure-method signature="getStackTrace()"/>
    </type>
    <type name="java.util.Collection">
        <pure-method signature="size()"/>
        <pure-method signature="isEmpty()"/>
    </type>
    <type name="java.util.List">
        <pure-method signature="get(int)"/>
    </type>
</c4j-pure-registry>

c4j-global.xml

<?xml version="1.0" encoding="UTF-8"?>
<c4j-global xmlns="http://c4j.vksi.de/c4j-global/">
    <write-transformed-classes directory="c4j-classes">true</write-transformed-classes>
    <contract-violation-action>
        <default>
            <log>true</log>
            <throw-error>true</throw-error>
        </default>
        <package name="de.vksi.c4j.systemtest.config.logonly">
            <log>true</log>
            <throw-error>false</throw-error>
        </package>
        <class name="de.vksi.c4j.systemtest.config.assertionerroronly.AssertionErrorOnlyConfigurationSystemTest">
            <log>false</log>
            <throw-error>true</throw-error>
        </class>
    </contract-violation-action>
</c4j-global>

from c4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.