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

Enable strict classpath scanning optionally #63

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ public interface ContainerConfiguration
ContainerConfiguration setJSR250Lifecycle( boolean on );

boolean getJSR250Lifecycle();

ContainerConfiguration setStrictClassPathScanning( boolean strictScanning );
Copy link
Contributor Author

@kwin kwin May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this interface was anyhow much modified with Sisu Plexus in comparison to the last known version at https://github.com/codehaus-plexus/plexus-containers/blob/3b0a8d5fd086e3f74ccdeecaac9cd63e44047e91/plexus-container-default/src/main/java/org/codehaus/plexus/ContainerConfiguration.java#L22. So adding two more methods doesn't do any harm here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, config was had to be changed (scanning, auto wire, etc)


boolean getStrictClassPathScanning();

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public final class DefaultContainerConfiguration

private boolean jsr250Lifecycle;

private boolean strictClassPathScanning;

// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -168,4 +170,17 @@ public boolean getJSR250Lifecycle()
{
return jsr250Lifecycle;
}

@Override
public ContainerConfiguration setStrictClassPathScanning( boolean strictScanning )
{
this.strictClassPathScanning = strictScanning;
return this;
}

@Override
public boolean getStrictClassPathScanning()
{
return strictClassPathScanning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ public DefaultPlexusContainer( final ContainerConfiguration configuration, final
final ClassSpace space = new URLClassSpace( containerRealm );
beanModules.add( new PlexusXmlBeanModule( space, variables, plexusXml ) );
final BeanScanning global = BeanScanning.INDEX == scanning ? BeanScanning.GLOBAL_INDEX : scanning;
beanModules.add( new PlexusAnnotatedBeanModule( space, variables, global ) );
beanModules.add( new PlexusAnnotatedBeanModule( space, variables, global,
configuration.getStrictClassPathScanning() ) );

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,27 @@ public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variab
* @param space The local class space
* @param variables The filter variables
* @param scanning The scanning options
* @deprecated Use {@link #PlexusAnnotatedBeanModule(ClassSpace, Map, BeanScanning, boolean)} instead.
*/
@Deprecated
public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variables, final BeanScanning scanning )
{
this( space, variables, scanning, false );
}

/**
* Creates a bean source that scans the given class space for Plexus annotations using the given scanner.
*
* @param space The local class space
* @param variables The filter variables
* @param scanning The scanning options
*/
public PlexusAnnotatedBeanModule( final ClassSpace space, final Map<?, ?> variables, final BeanScanning scanning,
boolean strictScanning )
{
if ( null != space && scanning != BeanScanning.OFF )
{
spaceModule = new SpaceModule( space, scanning ).with( PLEXUS_STRATEGY );
spaceModule = new SpaceModule( space, scanning, strictScanning ).with( PLEXUS_STRATEGY );
}
else
{
Expand Down