private static ProfileActivator[] getProfileActivators(File basedir) throws RemoteException { SystemPropertyProfileActivator sysPropertyActivator = new SystemPropertyProfileActivator(); DefaultContext context = new DefaultContext(); context.put("SystemProperties", MavenServerUtil.collectSystemProperties()); try { sysPropertyActivator.contextualize(context); } catch (ContextException e) { Maven3ServerGlobals.getLogger().error(e); return new ProfileActivator[0]; } return new ProfileActivator[] { new MyFileProfileActivator(basedir), sysPropertyActivator, new JdkPrefixProfileActivator(), new OperatingSystemProfileActivator() }; }
protected void setupContainer() { // ---------------------------------------------------------------------------- // Context Setup // ---------------------------------------------------------------------------- final DefaultContext context = new DefaultContext(); context.put("repository.path", "/usr/share/maven-repo/"); context.put("index.path", "target/indexOutput"); // ---------------------------------------------------------------------------- // Configuration // ---------------------------------------------------------------------------- final ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration().setName("debian").setContext(context.getContextData()); try { container = new DefaultPlexusContainer(containerConfiguration); } catch (final PlexusContainerException ex) { Logger.getLogger(MavenRepoApp.class.getName()).log(Level.SEVERE, null, ex); } }
protected void initializeConfiguration() throws ConfigurationProcessingException, ConfigurationResourceNotFoundException, PlexusConfigurationException, ContextException, IOException { // System userConfiguration InputStream is = containerRealm.getResourceAsStream(PlexusConstants.BOOTSTRAP_CONFIGURATION); if (is == null) { ClassRealm cr = containerRealm; String realmStack = ""; while (cr != null) { realmStack += "\n " + cr.getId() + " parent=" + cr.getParent() + " (" + cr.getResource(PlexusConstants.BOOTSTRAP_CONFIGURATION) + ")"; cr = cr.getParentRealm(); } throw new IllegalStateException( "The internal default plexus-bootstrap.xml is missing. " + "This is highly irregular, your plexus JAR is most likely corrupt. Realms:" + realmStack); } PlexusConfiguration bootstrapConfiguration = PlexusTools.buildConfiguration( PlexusConstants.BOOTSTRAP_CONFIGURATION, ReaderFactory.newXmlReader(is)); // Some of this could probably be collapsed as having a plexus.xml in your // META-INF/plexus directory is probably a better solution then specifying // a configuration with an URL but I'm leaving the configuration by URL // as folks might be using it ... I made this change to accomodate Maven // but I think it's better to discover a configuration in a standard // place. configuration = bootstrapConfiguration; if (!containerContext.contains(PlexusConstants.IGNORE_CONTAINER_CONFIGURATION) || containerContext.get(PlexusConstants.IGNORE_CONTAINER_CONFIGURATION) != Boolean.TRUE) { PlexusXmlComponentDiscoverer discoverer = new PlexusXmlComponentDiscoverer(); PlexusConfiguration plexusConfiguration = discoverer.discoverConfiguration(getContext(), containerRealm); if (plexusConfiguration != null) { configuration = PlexusConfigurationMerger.merge(plexusConfiguration, configuration); processConfigurationsDirectory(); } } if (configurationReader != null) { // User userConfiguration PlexusConfiguration userConfiguration = PlexusTools.buildConfiguration( "<User Specified Configuration Reader>", getInterpolationConfigurationReader(configurationReader)); // Merger of bootstrapConfiguration and user userConfiguration configuration = PlexusConfigurationMerger.merge(userConfiguration, configuration); processConfigurationsDirectory(); } // --------------------------------------------------------------------------- // Now that we have the configuration we will use the ConfigurationProcessor // to inline any external configuration instructions. // // At his point the variables in the configuration have already been // interpolated so we can send in an empty Map because the containerContext // values are already there. // --------------------------------------------------------------------------- ConfigurationProcessor p = new ConfigurationProcessor(); p.addConfigurationResourceHandler(new FileConfigurationResourceHandler()); p.addConfigurationResourceHandler(new DirectoryConfigurationResourceHandler()); configuration = p.process(configuration, Collections.EMPTY_MAP); }
public void addContextValue(Object key, Object value) { containerContext.put(key, value); }