use of org.codehaus.plexus.context.Context in project maven-scm by apache.
the class MavenScmCli method createPlexusContainer.
private PlexusContainer createPlexusContainer() {
final Context context = new DefaultContext();
String path = System.getProperty("basedir");
if (path == null) {
path = new File("").getAbsolutePath();
}
context.put("basedir", path);
ContainerConfiguration plexusConfiguration = new DefaultContainerConfiguration();
plexusConfiguration.setName("maven-scm-cli").setContext(context.getContextData()).setClassPathScanning(PlexusConstants.SCANNING_CACHE).setAutoWiring(true);
try {
return new DefaultPlexusContainer(plexusConfiguration);
} catch (PlexusContainerException e) {
throw new IllegalStateException("Could not create Plexus container", e);
}
}
use of org.codehaus.plexus.context.Context in project plexus-containers by codehaus-plexus.
the class ContextualizePhase method execute.
public void execute(Object object, ComponentManager manager, ClassRealm lookupRealm) throws PhaseExecutionException {
if (object instanceof Contextualizable) {
Context context = manager.getContainer().getContext();
ClassRealm origRealm = manager.getContainer().setLookupRealm(lookupRealm);
try {
((Contextualizable) object).contextualize(context);
} catch (ContextException e) {
throw new PhaseExecutionException("Unable to contextualize component", e);
} finally {
manager.getContainer().setLookupRealm(origRealm);
}
}
}
Aggregations