File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes filtering component scans (doesn't work) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "filtering component scans (doesn Watch "filtering component scans (doesn New topic

filtering component scans (doesn't work)

Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
I have this configuration in my bean.xml

I have a few services in com.example.engine.manager package:

but I wanted to disable some service like DealManager and the rest of services will be still running.
Therefore I put this "exclude-filter" into bean.xml, but it doesn't work.

any wrong with my syntax (i ran it without error though) or any that I don't know?

I tried search with google but the results are not helpful.

Any master here can give me a clue ?

Thanks in advance.

From NickyEng
Diploma in Computer Studies
SCJP 1.4
Formula 1 app by Maxis (Playbook)
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well, I can't help with regex, I don't know regex, nor want to know it. ;)

You can do a couple of approaches. I see that you turned off the default filters which are includes for @Service, @Repository etc.

I do know your order might not make it work, where the first include included your DealManager and therefore the exclude after is overwritten, or maybe the other way around.

One approach I like in this scenario is to create my own set of Annotations and use those in your class and filters where type="Annotations" (Always make sure you include package for your Annotation in the value)

I had three web apps all sharing the same Core project that had Services that in some apps needed and in others didn't. And I couldn't come up with a good filter at that time. Since then and after I left that company, I realized that creating my own Annotation, one for each app, I could put those on those classes and write a clean filter and get exactly the classes I want.

So say I have an app called Moo and another called Bark, I would create an @Moo and a @Bark annotation, I could annotate those annotations with @Service or @Component, then put one or both on Managers that I need in that particular app. Then just

for the Bark application.

That is one possible solution.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: filtering component scans (doesn't work)
It's not a secret anymore!