Comments (3)
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.
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.
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)
- Fix @AllowPureAccess not working correctly with Objects
- Exceptions being thrown while storing a value for old() in a pre-condition should be thrown in the post-condition
- Work together with EclEmma
- Fix old-Expressions being evaluated in post-condition
- Fix bug when using old and unchanged together in a post-condition
- Fix bug when using old and unchanged in a post-condition as well as in a class-invariant
- Fix pure trying to access package-private fields when subclass is in another package
- Fix XML-Configuration not working for top-level package-names
- Improve performance by removing Thread.currentThread.getStackTrace() calls
- Allow class initializers write access on own static fields in pure validation
- Configure contracts to be run only for a fraction of method calls, ensuring a limited overhead during runtime
- Use SLF4J instead of Log4J
- Review and decide on LSP Implementation HOT 1
- No instrumentation when method is undeclared and already instrumented in super-class
- Bug: unchanged() and old() not usable within extracted methods in Contract class
- Change constructor contract functionality
- Synthetic static method in contract class throws UsageError
- instrumenting too much?
- c4j once configured in Base Eclipse Plugin used in dependant plugins
- Checking whether a precondition is strengthening a super-defined precondition seems to be to strict in case of using external contract classes.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c4j.