geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r712325 [2/2] - in /geronimo/server/trunk: buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ framework/configs/j2ee-system/ framework/configs/j2ee-system/src/main/history/ framework/configs/j2ee-system/src/ma...
Date Sat, 08 Nov 2008 00:37:36 GMT
Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=712325&r1=712324&r2=712325&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Fri Nov  7 16:37:34 2008
@@ -26,26 +26,31 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.SortedSet;
 import java.util.Set;
+import java.util.SortedSet;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
+
 import javax.management.ObjectName;
 
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.ObjectNameUtil;
 import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
 import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationDataTransformer;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.IOUtil;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoOConfigurationDataTransformer;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
-import org.apache.geronimo.kernel.config.IOUtil;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
 import org.slf4j.Logger;
@@ -57,6 +62,7 @@
  *
  * @version $Rev$ $Date$
  */
+@GBean(j2eeType= "ConfigurationStore")
 public class RepositoryConfigurationStore implements ConfigurationStore {
     private static final Logger log = LoggerFactory.getLogger(RepositoryConfigurationStore.class);
     private final Kernel kernel;
@@ -64,16 +70,33 @@
     private final AbstractName abstractName;
     protected final WritableListableRepository repository;
     private final InPlaceConfigurationUtil inPlaceConfUtil;
+    private final ConfigurationDataTransformer transformer;
 
     public RepositoryConfigurationStore(WritableListableRepository repository) {
-        this(null, null, null, repository);
+        this(null, null, null, repository, NoOConfigurationDataTransformer.SINGLETON);
     }
 
-    public RepositoryConfigurationStore(Kernel kernel, String objectName, AbstractName abstractName,
WritableListableRepository repository) {
+    public RepositoryConfigurationStore(Kernel kernel,
+            String objectName,
+            AbstractName abstractName,
+            WritableListableRepository repository) {
+        this(kernel, objectName, abstractName, repository, NoOConfigurationDataTransformer.SINGLETON);
+    }
+    
+    public RepositoryConfigurationStore(@ParamSpecial(type=SpecialAttributeType.kernel) Kernel
kernel,
+            @ParamSpecial(type=SpecialAttributeType.objectName) String objectName,
+            @ParamSpecial(type=SpecialAttributeType.abstractName) AbstractName abstractName,
+            @ParamReference(name=GBEAN_REF_REPOSITORY, namingType=GBEAN_REF_REPOSITORY) WritableListableRepository
repository,
+            @ParamReference(name=GBEAN_REF_CONFIG_DATA_TRANSFORMER) ConfigurationDataTransformer
transformer) {
         this.kernel = kernel;
         this.objectName = objectName == null ? null : ObjectNameUtil.getObjectName(objectName);
         this.abstractName = abstractName;
         this.repository = repository;
+        if (null == transformer) {
+            this.transformer = NoOConfigurationDataTransformer.SINGLETON;
+        } else {
+            this.transformer = transformer;
+        }
 
         inPlaceConfUtil = new InPlaceConfigurationUtil();
     }
@@ -138,6 +161,8 @@
             configurationData.setNaming(kernel.getNaming());
         }
 
+        transformer.transformDependencies(configurationData);
+        
         return configurationData;
     }
 
@@ -394,6 +419,8 @@
                 throw ioException;
             }
         }
+        
+        transformer.remove(configId);
     }
 
     public List<ConfigurationInfo> listConfigurations() {
@@ -529,19 +556,7 @@
 //        }
 //    }
 //
-    public static final GBeanInfo GBEAN_INFO;
 
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
-    static {
-        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(RepositoryConfigurationStore.class,
"ConfigurationStore");
-        builder.addAttribute("kernel", Kernel.class, false);
-        builder.addAttribute("objectName", String.class, false);
-        builder.addAttribute("abstractName", AbstractName.class, false);
-        builder.addReference("Repository", WritableListableRepository.class, "Repository");
-        builder.setConstructor(new String[]{"kernel", "objectName", "abstractName", "Repository"});
-        GBEAN_INFO = builder.getBeanInfo();
-    }
+    public static final String GBEAN_REF_REPOSITORY = "Repository";
+    public static final String GBEAN_REF_CONFIG_DATA_TRANSFORMER = "ConfigurationDataTransformer";
 }

Modified: geronimo/server/trunk/framework/modules/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/pom.xml?rev=712325&r1=712324&r2=712325&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/pom.xml Fri Nov  7 16:37:34 2008
@@ -61,6 +61,7 @@
         <module>geronimo-jdbc</module>
         <module>geronimo-jmx-remoting</module>
         <module>geronimo-kernel</module>
+        <module>geronimo-config-groovy-transformer</module>
         <module>geronimo-management</module>
         <module>geronimo-naming</module>
         <module>geronimo-security</module>

Added: geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/RMockTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/RMockTestSupport.java?rev=712325&view=auto
==============================================================================
--- geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/RMockTestSupport.java
(added)
+++ geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/RMockTestSupport.java
Fri Nov  7 16:37:34 2008
@@ -0,0 +1,105 @@
+/**
+ *  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.testsupport;
+
+import java.io.File;
+
+import org.slf4j.Logger;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ * Provides support for tests.
+ *
+ * @version $Rev: 653782 $ $Date: 2008-05-07 00:10:14 +1000 (Wed, 07 May 2008) $
+ */
+public abstract class RMockTestSupport
+    extends RMockTestCase
+{
+
+    private final TestUtil testUtil;
+    
+    /**
+     * The base-directory which tests should be run from.
+     */
+    protected final File BASEDIR;
+    
+    /**
+     * Instance logger which tests should use to produce tracing information.
+     *
+     * <p>
+     * Unless you have a really good reason to, do not change this field from your sub-class.
+     * And if you do, please document why you have done so.
+     */
+    protected final Logger log;
+
+    
+    /**
+     * Constructor for tests that specify a specific test name.
+     *
+     * @see #TestSupport()  This is the prefered constructor for sub-classes to use.
+     */
+    protected RMockTestSupport(final String name) {
+        super(name);
+        
+        testUtil = new TestUtil(getClass());
+        
+        BASEDIR = testUtil.getBaseDir();
+        log = testUtil.getLog();
+        
+        log.info("Initialized");
+    }
+    
+    /**
+     * Default constructor.
+     */
+    protected RMockTestSupport() {
+        super();
+
+        testUtil = new TestUtil(getClass());
+        
+        BASEDIR = testUtil.getBaseDir();
+        log = testUtil.getLog();
+
+        log.info("Initialized");
+    }
+    
+    /**
+     * Resolve the given path to a file rooted to {@link #BASEDIR}.
+     *
+     * @param path  The path to resolve.
+     * @return      The resolved file for the given path.
+     */
+    protected final File resolveFile(final String path) {
+        return testUtil.resolveFile(path);
+    }
+    
+    /**
+     * Resolve the given path to a path rooted to {@link #BASEDIR}.
+     *
+     * @param path  The path to resolve.
+     * @return      The resolved path for the given path.
+     *
+     * @see #resolveFile(String)
+     */
+    protected final String resolvePath(final String path) {
+        return testUtil.resolvePath(path);
+    }
+}

Modified: geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestSupport.java?rev=712325&r1=712324&r2=712325&view=diff
==============================================================================
--- geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestSupport.java
(original)
+++ geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestSupport.java
Fri Nov  7 16:37:34 2008
@@ -24,7 +24,6 @@
 import junit.framework.TestCase;
 
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Provides support for tests.
@@ -34,17 +33,13 @@
 public abstract class TestSupport
     extends TestCase
 {
+
+    private final TestUtil testUtil;
+    
     /**
      * The base-directory which tests should be run from.
-     *
-     * @see #getBaseDir()   This field is initialized from the return of this method on instance
construction.
      */
-    protected final File BASEDIR = getBaseDir();
-    
-    //
-    // NOTE: Logging must be initialized after BASEDIR has been discovered, as it is used
-    //       by the log4j logging-config properties to set the target/test.log file.
-    //
+    protected final File BASEDIR;
     
     /**
      * Instance logger which tests should use to produce tracing information.
@@ -53,7 +48,8 @@
      * Unless you have a really good reason to, do not change this field from your sub-class.
      * And if you do, please document why you have done so.
      */
-    protected final Logger log = LoggerFactory.getLogger(getClass());
+    protected final Logger log;
+
     
     /**
      * Constructor for tests that specify a specific test name.
@@ -63,6 +59,11 @@
     protected TestSupport(final String name) {
         super(name);
         
+        testUtil = new TestUtil(getClass());
+        
+        BASEDIR = testUtil.getBaseDir();
+        log = testUtil.getLog();
+        
         log.info("Initialized");
     }
     
@@ -71,45 +72,17 @@
      */
     protected TestSupport() {
         super();
+
+        testUtil = new TestUtil(getClass());
         
+        BASEDIR = testUtil.getBaseDir();
+        log = testUtil.getLog();
+
         log.info("Initialized");
     }
     
-    /**
-     * Determine the value of <tt>${basedir}</tt>, which should be the base directory
of
-     * the module which the concreate test class is defined in.
-     *
-     * <p>
-     * If The system property <tt>basedir</tt> is already set, then that value
is used,
-     * otherwise we determine the value from the codesource of the containing concrete class
-     * and set the <tt>basedir</tt> system property to that value.
-     *
-     * @see #BASEDIR    This field is always initialized to the value which this method returns.
-     *
-     * @return  The base directory of the module which contains the concreate test class.
-     */
-    protected final File getBaseDir() {
-        File dir;
-
-        // If ${basedir} is set, then honor it
-        String tmp = System.getProperty("basedir");
-        if (tmp != null) {
-            dir = new File(tmp);
-        }
-        else {
-            // Find the directory which this class (or really the sub-class of TestSupport)
is defined in.
-            String path = getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
-
-            // We expect the file to be in target/test-classes, so go up 2 dirs
-            dir = new File(path).getParentFile().getParentFile();
-
-            // Set ${basedir} which is needed by logging to initialize
-            System.setProperty("basedir", dir.getPath());
-        }
-
-        // System.err.println("Base Directory: " + dir);
-
-        return dir;
+    protected File getBaseDir() {
+        return BASEDIR;
     }
     
     /**
@@ -119,19 +92,7 @@
      * @return      The resolved file for the given path.
      */
     protected final File resolveFile(final String path) {
-        assert path != null;
-        
-        File file = new File(path);
-        
-        // Complain if the file is already absolute... probably an error
-        if (file.isAbsolute()) {
-            log.warn("Given path is already absolute; nothing to resolve: {}", file);
-        }
-        else {
-            file = new File(BASEDIR, path);
-        }
-        
-        return file;
+        return testUtil.resolveFile(path);
     }
     
     /**
@@ -143,8 +104,6 @@
      * @see #resolveFile(String)
      */
     protected final String resolvePath(final String path) {
-        assert path != null;
-        
-        return resolveFile(path).getPath();
+        return testUtil.resolvePath(path);
     }
 }

Added: geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestUtil.java?rev=712325&view=auto
==============================================================================
--- geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestUtil.java
(added)
+++ geronimo/server/trunk/testsupport/testsupport-common/src/main/java/org/apache/geronimo/testsupport/TestUtil.java
Fri Nov  7 16:37:34 2008
@@ -0,0 +1,148 @@
+/*
+ * 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.testsupport;
+
+import java.io.File;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class TestUtil {
+
+    private final Class owningClass;
+
+    /**
+     * The base-directory which tests should be run from.
+     *
+     * @see #initBaseDir()   This field is initialized from the return of this method on
instance construction.
+     */
+    protected final File baseDir;
+    
+    /**
+     * Instance logger which tests should use to produce tracing information.
+     *
+     * <p>
+     * Unless you have a really good reason to, do not change this field from your sub-class.
+     * And if you do, please document why you have done so.
+     */
+    protected final Logger log;
+
+    
+    public TestUtil(Class owningClass) {
+        if (null == owningClass) {
+            throw new IllegalArgumentException("owningClass is required");
+        }
+        this.owningClass = owningClass;
+        
+        baseDir = initBaseDir();
+
+        //
+        // NOTE: Logging must be initialized after BASEDIR has been discovered, as it is
used
+        //       by the log4j logging-config properties to set the target/test.log file.
+        //
+        log = LoggerFactory.getLogger(owningClass);
+    }
+    
+    public File getBaseDir() {
+        return baseDir;
+    }
+
+    public Logger getLog() {
+        return log;
+    }
+
+    /**
+     * Determine the value of <tt>${basedir}</tt>, which should be the base directory
of
+     * the module which the concreate test class is defined in.
+     *
+     * <p>
+     * If The system property <tt>basedir</tt> is already set, then that value
is used,
+     * otherwise we determine the value from the codesource of the containing concrete class
+     * and set the <tt>basedir</tt> system property to that value.
+     *
+     * @see #baseDir    This field is always initialized to the value which this method returns.
+     *
+     * @return  The base directory of the module which contains the concreate test class.
+     */
+    protected final File initBaseDir() {
+        File dir;
+
+        // If ${basedir} is set, then honor it
+        String tmp = System.getProperty("basedir");
+        if (tmp != null) {
+            dir = new File(tmp);
+        }
+        else {
+            // Find the directory which this class (or really the sub-class of TestSupport)
is defined in.
+            String path = owningClass.getProtectionDomain().getCodeSource().getLocation().getFile();
+
+            // We expect the file to be in target/test-classes, so go up 2 dirs
+            dir = new File(path).getParentFile().getParentFile();
+
+            // Set ${basedir} which is needed by logging to initialize
+            System.setProperty("basedir", dir.getPath());
+        }
+
+        // System.err.println("Base Directory: " + dir);
+
+        return dir;
+    }
+    
+    /**
+     * Resolve the given path to a file rooted to {@link #baseDir}.
+     *
+     * @param path  The path to resolve.
+     * @return      The resolved file for the given path.
+     */
+    public final File resolveFile(final String path) {
+        assert path != null;
+        
+        File file = new File(path);
+        
+        // Complain if the file is already absolute... probably an error
+        if (file.isAbsolute()) {
+            log.warn("Given path is already absolute; nothing to resolve: {}", file);
+        }
+        else {
+            file = new File(baseDir, path);
+        }
+        
+        return file;
+    }
+    
+    /**
+     * Resolve the given path to a path rooted to {@link #baseDir}.
+     *
+     * @param path  The path to resolve.
+     * @return      The resolved path for the given path.
+     *
+     * @see #resolveFile(String)
+     */
+    public final String resolvePath(final String path) {
+        assert path != null;
+        
+        return resolveFile(path).getPath();
+    }
+
+}



Mime
View raw message