Author: brett
Date: Sun Jul 9 21:39:44 2006
New Revision: 420421
URL: http://svn.apache.org/viewvc?rev=420421&view=rev
Log:
[MRM-46] set application up so that configuration can be loaded from a webapp
context param (using expressions)
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
(with props)
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
(with props)
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
(with props)
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
(with props)
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml
(contents, props changed)
- copied, changed from r420385,
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
Removed:
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
Modified:
maven/repository-manager/trunk/maven-repository-configuration/pom.xml
maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
maven/repository-manager/trunk/maven-repository-webapp/pom.xml
Modified: maven/repository-manager/trunk/maven-repository-configuration/pom.xml
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/pom.xml?rev=420421&r1=420420&r2=420421&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-configuration/pom.xml
(original)
+++ maven/repository-manager/trunk/maven-repository-configuration/pom.xml Sun
Jul 9 21:39:44 2006
@@ -12,6 +12,10 @@
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
</dependencies>
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java?rev=420421&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
(added)
+++
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
Sun Jul 9 21:39:44 2006
@@ -0,0 +1,33 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Component capable of noticing configuration changes and adjusting
accordingly.
+ * This is not a Plexus role.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ */
+public interface ConfigurationChangeListener
+{
+ /**
+ * Notify the object that there has been a configuration change.
+ *
+ * @param configuration the new configuration
+ */
+ void notifyOfConfigurationChange( Configuration configuration );
+}
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationChangeListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java?rev=420421&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
(added)
+++
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
Sun Jul 9 21:39:44 2006
@@ -0,0 +1,47 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A component for loading the configuration into the model.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ * @todo this is something that could possibly be generalised into Modello.
+ */
+public interface ConfigurationStore
+{
+ /**
+ * The Plexus role for the component.
+ */
+ String ROLE = ConfigurationStore.class.getName();
+
+ /**
+ * Get the configuration from the store. A cached version may be used.
+ *
+ * @return the configuration
+ */
+ Configuration getConfigurationFromStore()
+ throws ConfigurationStoreException;
+
+ /**
+ * Save the configuration to the store.
+ *
+ * @param configuration the configuration to store
+ */
+ void storeConfiguration( Configuration configuration )
+ throws ConfigurationStoreException;
+}
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStore.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java?rev=420421&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
(added)
+++
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
Sun Jul 9 21:39:44 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exception occurring using the configuration store.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ */
+public class ConfigurationStoreException
+ extends Exception
+{
+ public ConfigurationStoreException( String message )
+ {
+ super( message );
+ }
+
+ public ConfigurationStoreException( String message, Throwable e )
+ {
+ super( message, e );
+ }
+}
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/ConfigurationStoreException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java?rev=420421&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
(added)
+++
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
Sun Jul 9 21:39:44 2006
@@ -0,0 +1,119 @@
+package org.apache.maven.repository.configuration;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import
org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Reader;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Load and store the configuration. No synchronization is used, but it is
unnecessary as the old configuration object
+ * can continue to be used.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ * @todo would be great for plexus to do this for us - so the configuration
would be a component itself rather than this store
+ * @todo would be good to monitor the store file for changes
+ * @todo support other implementations than XML file
+ * @plexus.component
role="org.apache.maven.repository.configuration.ConfigurationStore"
role-hint="default"
+ */
+public class DefaultConfigurationStore
+ extends AbstractLogEnabled
+ implements ConfigurationStore
+{
+ /**
+ * @plexus.configuration default-value="${configuration.store.file}"
+ */
+ private File file;
+
+ /**
+ * The cached configuration.
+ */
+ private Configuration configuration;
+
+ /**
+ * List of listeners to configuration changes.
+ */
+ private List/*<ConfigurationChangeListener>*/ listeners = new LinkedList();
+
+ public Configuration getConfigurationFromStore()
+ throws ConfigurationStoreException
+ {
+ if ( configuration == null )
+ {
+ ConfigurationXpp3Reader reader = new ConfigurationXpp3Reader();
+
+ if ( file == null )
+ {
+ file = new File( System.getProperty( "user.home" ),
"/.m2/repository-manager.xml" );
+ }
+
+ FileReader fileReader;
+ try
+ {
+ fileReader = new FileReader( file );
+ }
+ catch ( FileNotFoundException e )
+ {
+ getLogger().warn( "Configuration file: " + file + " not found.
Using defaults." );
+ configuration = new Configuration();
+ return configuration;
+ }
+
+ try
+ {
+ configuration = reader.read( fileReader );
+ }
+ catch ( IOException e )
+ {
+ throw new ConfigurationStoreException( e.getMessage(), e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new ConfigurationStoreException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( fileReader );
+ }
+ }
+ return configuration;
+ }
+
+ public void storeConfiguration( Configuration configuration )
+ throws ConfigurationStoreException
+ {
+ // TODO: finish!
+
+ for ( Iterator i = listeners.iterator(); i.hasNext(); )
+ {
+ ConfigurationChangeListener listener =
(ConfigurationChangeListener) i.next();
+
+ listener.notifyOfConfigurationChange( configuration );
+ }
+
+ throw new UnsupportedOperationException( "Not yet implemented:
storeConfiguration" );
+ }
+}
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo?rev=420421&r1=420420&r2=420421&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
(original)
+++
maven/repository-manager/trunk/maven-repository-configuration/src/main/mdo/configuration.mdo
Sun Jul 9 21:39:44 2006
@@ -10,7 +10,7 @@
<value>org.apache.maven.repository.configuration</value>
</default>
</defaults>
- <!-- TODO! break out subtypes such as <discovery> and create a list of
blacklist -->
+ <!-- TODO! break out subtypes such as <discovery> and create a list of
blacklist, have multiple repositories -->
<classes>
<class rootElement="true" xml.tagName="configuration">
<name>Configuration</name>
Modified: maven/repository-manager/trunk/maven-repository-webapp/pom.xml
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/pom.xml?rev=420421&r1=420420&r2=420421&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-webapp/pom.xml (original)
+++ maven/repository-manager/trunk/maven-repository-webapp/pom.xml Sun Jul 9
21:39:44 2006
@@ -44,6 +44,11 @@
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-log4j-logging</artifactId>
+ <version>1.1-alpha-2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>1.0-alpha-10-SNAPSHOT</version>
</dependency>
Copied:
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml
(from r420385,
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml)
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml?p2=maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml&p1=maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml&r1=420385&r2=420421&rev=420421&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
(original)
+++
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml
Sun Jul 9 21:39:44 2006
@@ -15,103 +15,80 @@
-->
<plexus>
- <!--
- <load-on-start>
- <component>
- <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
- <role-hint>build-project</role-hint>
- </component>
- <component>
- <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
- <role-hint>check-out-project</role-hint>
- </component>
- </load-on-start>
- -->
-
-
<components>
-
-
- <!--
- | Object factory for WebWork
- -->
-
- <component>
- <role>com.opensymphony.xwork.ObjectFactory</role>
-
<implementation>org.codehaus.plexus.xwork.PlexusObjectFactory</implementation>
- </component>
-
<!--
| Logger manager
-->
- <!--
- <component>
- <role>org.codehaus.plexus.logging.LoggerManager</role>
-
<implementation>org.codehaus.plexus.logging.log4j.Log4JLoggerManager</implementation>
- <lifecycle-handler>basic</lifecycle-handler>
-
- <configuration>
+ <component>
+ <role>org.codehaus.plexus.logging.LoggerManager</role>
+
<implementation>org.codehaus.plexus.logging.log4j.Log4JLoggerManager</implementation>
+ <lifecycle-handler>basic</lifecycle-handler>
+
+ <configuration>
+ <threshold>DEBUG</threshold>
+ <default-appender>console</default-appender>
+ <appenders>
+ <appender>
+ <id>console</id>
<threshold>DEBUG</threshold>
- <default-appender>console,rolling</default-appender>
- <appenders>
- <appender>
- <id>console</id>
- <threshold>DEBUG</threshold>
- <type>org.apache.log4j.ConsoleAppender</type>
- <conversion-pattern>%d [%t] %-5p %-30c{1} -
%m%n</conversion-pattern>
- </appender>
-
- <appender>
- <id>rolling</id>
- <threshold>DEBUG</threshold>
- <type>org.apache.log4j.RollingFileAppender</type>
- <conversion-pattern>%-4r [%t] %-5p %c %x -
%m%n</conversion-pattern>
-
- <properties>
- <property>
- <name>file</name>
- <value>${plexus.home}/logs/continuum.log</value>
- </property>
- <property>
- <name>append</name>
- <value>true</value>
- </property>
- <property>
- <name>maxBackupIndex</name>
- <value>10</value>
- </property>
- <property>
- <name>maxFileSize</name>
- <value>10MB</value>
- </property>
- </properties>
- </appender>
- </appenders>
- <levels>
- <level>
- <hierarchy>org.codehaus.plexus.velocity</hierarchy>
- <level>WARN</level>
- </level>
- <level>
-
<hierarchy>org.codehaus.plexus.mailsender.MailSender</hierarchy>
- <level>INFO</level>
- </level>
- <level>
- <hierarchy>org.apache.jasper</hierarchy>
- <level>INFO</level>
- </level>
- <level>
- <hierarchy>com.opensymphony.xwork</hierarchy>
- <level>INFO</level>
- </level>
- <level>
- <hierarchy>com.opensymphony.webwork</hierarchy>
- <level>INFO</level>
- </level>
- </levels>
- </configuration>
- </component>
- -->
+ <type>org.apache.log4j.ConsoleAppender</type>
+ <conversion-pattern>%d [%t] %-5p %-30c{1} -
%m%n</conversion-pattern>
+ </appender>
+ </appenders>
+ <levels>
+ <level>
+ <hierarchy>org.codehaus.plexus.velocity</hierarchy>
+ <level>WARN</level>
+ </level>
+ <level>
+ <hierarchy>org.codehaus.plexus.mailsender.MailSender</hierarchy>
+ <level>INFO</level>
+ </level>
+ <level>
+ <hierarchy>org.apache.jasper</hierarchy>
+ <level>INFO</level>
+ </level>
+ <level>
+ <hierarchy>com.opensymphony.xwork</hierarchy>
+ <level>INFO</level>
+ </level>
+ <level>
+ <hierarchy>com.opensymphony.webwork</hierarchy>
+ <level>INFO</level>
+ </level>
+ </levels>
+ </configuration>
+ </component>
</components>
+ <!-- Override default configuration of components -->
+ <lifecycle-handler-manager
implementation="org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager">
+ <default-lifecycle-handler-id>webapp</default-lifecycle-handler-id>
+ <lifecycle-handlers>
+ <lifecycle-handler
implementation="org.codehaus.plexus.personality.plexus.PlexusLifecycleHandler">
+ <id>webapp</id>
+ <name>Web Application Component Lifecycle Handler</name>
+ <begin-segment>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.LogEnablePhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.ContextualizePhase"/>
+ <phase
implementation="org.codehaus.plexus.xwork.ConfigurationPhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceablePhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializePhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.StartPhase"/>
+ </begin-segment>
+ <suspend-segment>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.SuspendPhase"/>
+ </suspend-segment>
+ <resume-segment>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.ResumePhase"/>
+ </resume-segment>
+ <end-segment>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.StopPhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.DisposePhase"/>
+ <phase
implementation="org.codehaus.plexus.personality.plexus.lifecycle.phase.LogDisablePhase"/>
+ </end-segment>
+ </lifecycle-handler>
+ </lifecycle-handlers>
+ </lifecycle-handler-manager>
</plexus>
Propchange:
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/plexus-application.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision