Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit 244caa4

Browse files
committed
Enable strict classpath scanning optionally
This closes #51
1 parent 73a2d52 commit 244caa4

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

org.eclipse.sisu.plexus/src/main/java/org/codehaus/plexus/ContainerConfiguration.java

+5
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public interface ContainerConfiguration
6262
ContainerConfiguration setJSR250Lifecycle( boolean on );
6363

6464
boolean getJSR250Lifecycle();
65+
66+
ContainerConfiguration setStrictClassPathScanning( boolean strictScanning );
67+
68+
boolean getStrictClassPathScanning();
69+
6570
}

org.eclipse.sisu.plexus/src/main/java/org/codehaus/plexus/DefaultContainerConfiguration.java

+15
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public final class DefaultContainerConfiguration
4646

4747
private boolean jsr250Lifecycle;
4848

49+
private boolean strictClassPathScanning;
50+
4951
// ----------------------------------------------------------------------
5052
// Public methods
5153
// ----------------------------------------------------------------------
@@ -168,4 +170,17 @@ public boolean getJSR250Lifecycle()
168170
{
169171
return jsr250Lifecycle;
170172
}
173+
174+
@Override
175+
public ContainerConfiguration setStrictClassPathScanning( boolean strictScanning )
176+
{
177+
this.strictClassPathScanning = strictScanning;
178+
return this;
179+
}
180+
181+
@Override
182+
public boolean getStrictClassPathScanning()
183+
{
184+
return strictClassPathScanning;
185+
}
171186
}

org.eclipse.sisu.plexus/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ public DefaultPlexusContainer( final ContainerConfiguration configuration, final
200200
final ClassSpace space = new URLClassSpace( containerRealm );
201201
beanModules.add( new PlexusXmlBeanModule( space, variables, plexusXml ) );
202202
final BeanScanning global = BeanScanning.INDEX == scanning ? BeanScanning.GLOBAL_INDEX : scanning;
203-
beanModules.add( new PlexusAnnotatedBeanModule( space, variables, global ) );
203+
beanModules.add( new PlexusAnnotatedBeanModule( space, variables, global,
204+
configuration.getStrictClassPathScanning() ) );
204205

205206
try
206207
{

org.eclipse.sisu.plexus/src/main/java/org/eclipse/sisu/plexus/PlexusAnnotatedBeanModule.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,27 @@ public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variab
6868
* @param space The local class space
6969
* @param variables The filter variables
7070
* @param scanning The scanning options
71+
* @deprecated Use {@link #PlexusAnnotatedBeanModule(ClassSpace, Map, BeanScanning, boolean)} instead.
7172
*/
73+
@Deprecated
7274
public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variables, final BeanScanning scanning )
75+
{
76+
this( space, variables, scanning, false );
77+
}
78+
79+
/**
80+
* Creates a bean source that scans the given class space for Plexus annotations using the given scanner.
81+
*
82+
* @param space The local class space
83+
* @param variables The filter variables
84+
* @param scanning The scanning options
85+
*/
86+
public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variables, final BeanScanning scanning,
87+
boolean strictScanning )
7388
{
7489
if ( null != space && scanning != BeanScanning.OFF )
7590
{
76-
spaceModule = new SpaceModule( space, scanning ).with( PLEXUS_STRATEGY );
91+
spaceModule = new SpaceModule( space, scanning, strictScanning ).with( PLEXUS_STRATEGY );
7792
}
7893
else
7994
{

0 commit comments

Comments
 (0)