Dependency Rules and Spring IOC

I am trying to set up some dependency rules to help enforce the use of Spring IOC.

I created a scope for my implementations which includes the classes that implement the
interfaces.

I added a rule to "allow usages of" the implementations scope "only in" the implementations
scope.

The Dependency Viewer displays my Spring XML configuration file as being an invalid usage of
the implementations scope. Cool, I didn't expect to have xml dependencies inspected. That
may come in handy some day.

Here is my problem though: How do I add the xml files to the allowed scope? They are not
in a package and the "default package" doesn't seem to include them either.

Tim

5 comments

Hello Tim,

Well, that's indeed a problem for now since scopes operate in terms
of packages, while .xml files definetely do not belong to any package. Any
ideas?

-


Maxim Shafirov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I am trying to set up some dependency rules to help enforce the use of
Spring IOC.

I created a scope for my implementations which includes the classes
that implement the interfaces.

I added a rule to "allow usages of" the implementations scope "only
in" the implementations scope.

The Dependency Viewer displays my Spring XML configuration file as
being an invalid usage of the implementations scope. Cool, I didn't
expect to have xml dependencies inspected. That may come in handy
some day.

Here is my problem though: How do I add the xml files to the allowed
scope? They are not in a package and the "default package" doesn't
seem to include them either.

Tim



0

Hello Maxim,

MS> Hello Tim,
MS>
MS> Well, that's indeed a problem for now since scopes operate
MS> in terms of packages, while .xml files definetely do not belong to
MS> any package. Any ideas?

Load the xml for the module (module based in this case, plus dependecy if
need be) and its references, find all the beans which are created, and process
to mark an import statement as a break of the IoC rules.

Maybe I'm over simplifying.

R


0

Yeah, allow module-based dependency rules. Even ignoring references in non-Java files, this would be a good idea. In pure Java apps, it would rule to be able to say things like "only classes in module 'UI' can use classes in javax.swing.*"

(Also, simplify the dependency rule UI, and make the completion and auto-import systems understand dependency rules, but you know that already.)


--Dave Griffith

0

Maxim Shafirov wrote:

Hello Tim,

Well, that's indeed a problem for now since scopes operate in
terms of packages, while .xml files definetely do not belong to any
package. Any ideas?


Maxim,

What about allowing scopes to be either packages OR directories & file masks?
You allow specification of modules and source vs library for the packages, how about
allowing the specification of file as well.

For instance;

I would like to be able to include files relative to the $PROJECT_DIR$ in scopes like this:

file[moduleName]:WebRoot\WEB-INF\struts-config*.xml
file[moduleName]:WebRoot\WEB-INF\applicationContext*.xml
file[moduleName]:WebRoot\WEB-INF\sql-map-config*.xml
file[moduleName]:WebRoot\..\*.jsp
file[moduleName]:src\..\dao\ibatis\maps\*.xml

Absolute paths could be included like this:

file:D:\somewhereElse\src\..\dao\ibatis\maps\*.xml
file:E:\somewhereElse\src\..\dao\ibatis\maps\*.xml

It would also be extremely handy if you could right-click on a file/package/scope dependency
from the Dependency Viewer and add it to either the list of allowed or disallowed
dependencies without having to open up the Dependency Validation rule editor.

Tim

0

Dave Griffith wrote:

Yeah, allow module-based dependency rules.
Even ignoring references in non-Java files, this would be a good idea.
In pure Java apps, it would rule to be able to say things like

> "only classes in module 'UI' can use classes in javax.swing.*"


Dave,

You can already do that:

src[ModuleName]:..
is a scope for all classes the "ModuleName" module sources (not test or libs)

and

lib:javax.swing..*
is a scope for all classes in the javax.swing package (from libraries only)


Tim

0

Please sign in to leave a comment.