geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r462757 - in /geronimo/genesis/trunk/plugins/script-maven-plugin/src/main: java/org/apache/geronimo/genesis/plugins/script/ resources/ resources/META-INF/ resources/META-INF/plexus/
Date Wed, 11 Oct 2006 10:24:40 GMT
Author: jdillon
Date: Wed Oct 11 03:24:37 2006
New Revision: 462757

URL: http://svn.apache.org/viewvc?view=rev&rev=462757
Log:
Add DelayedConfiguration type and custom Plexus converter

Added:
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
  (with props)
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
  (with props)
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
  (with props)
Modified:
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java

Added: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java?view=auto&rev=462757
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
(added)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
Wed Oct 11 03:24:37 2006
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.genesis.plugins.script;
+
+import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.component.configurator.ConfigurationListener;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Container that captures a custom Plexus configuration for delayed processing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DelayedConfiguration
+{
+    private static final Log log = LogFactory.getLog(DelayedConfiguration.class);
+
+    private ConverterLookup converterLookup;
+
+    private PlexusConfiguration configuration;
+
+    private Class type;
+
+    private Class baseType;
+
+    private ClassLoader classLoader;
+
+    private ExpressionEvaluator expressionEvaluator;
+
+    private ConfigurationListener listener;
+
+    public DelayedConfiguration(final ConverterLookup converterLookup,
+                                final PlexusConfiguration configuration,
+                                final Class type,
+                                final Class baseType,
+                                final ClassLoader classLoader,
+                                final ExpressionEvaluator expressionEvaluator,
+                                final ConfigurationListener listener)
+    {
+        this.converterLookup = converterLookup;
+        this.configuration = configuration;
+        this.type = type;
+        this.baseType = baseType;
+        this.classLoader = classLoader;
+        this.expressionEvaluator = expressionEvaluator;
+        this.listener = listener;
+    }
+
+    public String toString() {
+        return String.valueOf(getConfiguration());
+    }
+
+    public ConverterLookup getConverterLookup() {
+        return converterLookup;
+    }
+
+    public PlexusConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public Class getType() {
+        return type;
+    }
+
+    public Class getBaseType() {
+        return baseType;
+    }
+
+    public ClassLoader getClassLoader() {
+        return classLoader;
+    }
+
+    public ExpressionEvaluator getExpressionEvaluator() {
+        return expressionEvaluator;
+    }
+
+    public ConfigurationListener getListener() {
+        return listener;
+    }
+}

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java?view=auto&rev=462757
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
(added)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
Wed Oct 11 03:24:37 2006
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.genesis.plugins.script;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ConfigurationListener;
+import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter;
+import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+
+/**
+ * Plexus converter for {@link DelayedConfiguration} objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DelayedConfigurationConverter
+    extends AbstractConfigurationConverter
+{
+    private static final Log log = LogFactory.getLog(DelayedConfigurationConverter.class);
+
+    public boolean canConvert(final Class type) {
+        return DelayedConfiguration.class.isAssignableFrom(type);
+    }
+
+    public Object fromConfiguration(final ConverterLookup converterLookup,
+                                    final PlexusConfiguration configuration,
+                                    final Class type,
+                                    final Class baseType,
+                                    final ClassLoader classLoader,
+                                    final ExpressionEvaluator expressionEvaluator,
+                                    final ConfigurationListener listener)
+            throws ComponentConfigurationException
+    {
+        if (log.isDebugEnabled()) {
+            log.debug("Capturing delayed config: " + configuration);
+        }
+
+        return new DelayedConfiguration(converterLookup,
+                                        configuration,
+                                        type,
+                                        baseType,
+                                        classLoader,
+                                        expressionEvaluator,
+                                        listener);
+    }
+}
\ No newline at end of file

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/DelayedConfigurationConverter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java?view=diff&rev=462757&r1=462756&r2=462757
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
(original)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
Wed Oct 11 03:24:37 2006
@@ -48,6 +48,7 @@
  * Executes a <a href="http://groovy.codehaus.org">Groovy</a> script.
  *
  * @goal groovy
+ * @configurator override
  * @requiresDependencyResolution
  *
  * @version $Rev$ $Date$
@@ -78,6 +79,15 @@
     private File[] scriptpath = null;
 
     //
+    // TODO: Find a better name for this...
+    //
+    
+    /**
+     * @parameter
+     */
+    private DelayedConfiguration custom = null;
+
+    //
     // Maven components
     //
     
@@ -116,12 +126,12 @@
 
         ClassLoader parent = getClass().getClassLoader();
         URL[] urls = getClasspath();
+        URLClassLoader cl = new URLClassLoader(urls, parent);
 
         //
         // TODO: Investigate using GroovyScript instead of this...
         //
 
-        URLClassLoader cl = new URLClassLoader(urls, parent);
         GroovyClassLoader loader = new GroovyClassLoader(cl);
         loader.setResourceLoader(new GroovyResourceLoader()
         {
@@ -173,6 +183,13 @@
         }
         
         GroovyObject groovyObject = (GroovyObject)groovyClass.newInstance();
+
+        if (custom != null) {
+            //
+            // TODO: Perform custom configuration processing
+            //
+            log.info("Applying delayed configuration: " + custom);
+        }
 
         // Put int a helper to the script object
         groovyObject.setProperty("script", groovyObject);

Added: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml?view=auto&rev=462757
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
(added)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
Wed Oct 11 03:24:37 2006
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<plexus>
+    <components>
+
+        <component>
+            <role>org.codehaus.plexus.component.configurator.ComponentConfigurator</role>
+            <role-hint>override</role-hint>
+            <implementation>org.codehaus.plexus.component.configurator.BasicComponentConfigurator</implementation>
+            <requirements>
+                <requirement>
+                    <role>org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup</role>
+                    <role-hint>override</role-hint>
+                </requirement>
+            </requirements>
+        </component>
+
+        <component>
+            <role>org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup</role>
+            <role-hint>override</role-hint>
+            <implementation>org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup</implementation>
+            <requirements>
+                <requirement>
+                    <role>org.codehaus.plexus.component.configurator.converters.ConfigurationConverter</role>
+                    <role-hint>DelayedConfiguration</role-hint>
+                    <field-name>customConverters</field-name>
+                </requirement>
+            </requirements>
+        </component>
+
+        <component>
+            <role>org.codehaus.plexus.component.configurator.converters.ConfigurationConverter</role>
+            <role-hint>DelayedConfiguration</role-hint>
+            <implementation>org.apache.geronimo.genesis.plugins.script.DelayedConfigurationConverter</implementation>
+        </component>
+        
+    </components>
+</plexus>
\ No newline at end of file

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message