Re: [macker-user] always accessing a package via its interface
Brought to you by:
barredijkstra,
melquiades
From: Paul C. <can...@po...> - 2007-02-19 22:02:45
|
First you need to come up with a pattern that separates the interfaces from the implementation classes. If all of your "interface classes" are, in fact, interfaces, you could write a rule like this: <pattern name="foo" class="my.app.foo.**"/> <pattern name="foo-api" pattern="foo"> <include filter="interface"/> </pattern> Or if you want to include both interfaces and abstract classes: <pattern name="foo-api" pattern="foo"> <include filter="interface"/> <include filter="abstract-class"/> </pattern> Or if you separate the implementation classes by naming convention: <pattern name="foo-api" pattern="foo"> <exclude class="**Impl"/> </pattern> Once you have a "foo-api" pattern that separates out the API from the implementation, you just need this rule: <access-rule> <deny> <to pattern="foo"/> <!-- Deny all access to foo... --> </deny> <allow> <to pattern="foo-api"/> <!-- ...except to its API --> </allow> <allow> <from pattern="foo"/> <!-- ...or from within the package --> </allow> <access-rule> (Warning: these examples are untested.) Hope that helps! More details here: http://innig.net/macker/guide/ Cheers, Paul On Feb 19, 2007, at 11:35 AM, Sebastian Dietrich wrote: > Hi! > > I wonder how I could define that a given package has always to be > accessed via its defined interface classes/interfaces. > Right now I don't see a way other than defining it for each access > rule. > > Thanks, > Sebastian _________________________________________________________________ Piano music podcast: http://inthehands.com Other interesting stuff: http://innig.net |