cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r662197 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java
Date Sun, 01 Jun 2008 11:04:40 GMT
Author: aadamchik
Date: Sun Jun  1 04:04:39 2008
New Revision: 662197

URL: http://svn.apache.org/viewvc?rev=662197&view=rev
Log:
CAY-943 Support multiple cayenne.xml files in the project
(new configuration stub)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java?rev=662197&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/MultiProjectConfiguration.java
Sun Jun  1 04:04:39 2008
@@ -0,0 +1,104 @@
+/*****************************************************************
+ *   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.cayenne.conf;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+
+import org.apache.cayenne.ConfigurationException;
+import org.apache.cayenne.util.ResourceLocator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A Configuration implementation that creates a single virtual runtime project out of
+ * multiple Cayenne configurations.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public class MultiProjectConfiguration extends Configuration {
+
+    private static final Log logger = LogFactory.getLog(MultiProjectConfiguration.class);
+
+    protected ResourceFinder resourceFinder;
+
+    public MultiProjectConfiguration() {
+        this.resourceFinder = new ClasspathResourceFinder();
+    }
+
+    @Override
+    public void initialize() throws Exception {
+
+        logger.debug("initialize starting.");
+
+        InputStream in = this.getDomainConfiguration();
+        if (in == null) {
+            StringBuilder msg = new StringBuilder();
+            msg.append("[").append(this.getClass().getName()).append(
+                    "] : Domain configuration file \"").append(
+                    this.getDomainConfigurationName()).append("\" is not found.");
+
+            throw new ConfigurationException(msg.toString());
+        }
+
+        ConfigLoaderDelegate delegate = this.getLoaderDelegate();
+        if (delegate == null) {
+            delegate = new RuntimeLoadDelegate(this, this.getLoadStatus());
+        }
+
+        ConfigLoader loader = new ConfigLoader(delegate);
+
+        try {
+            loader.loadDomains(in);
+        }
+        finally {
+            this.setLoadStatus(delegate.getStatus());
+            in.close();
+        }
+
+        logger.debug("initialize finished.");
+    }
+
+    /**
+     * Returns a collection of all available unit descriptor URLs. Unit descriptors
+     * (usually cayenne.xml files) are looked up using the internal resource locator.
+     * 
+     * @since 3.0
+     */
+    protected Collection<URL> getUnitDescriptors() {
+        return resourceFinder.getResources(getDomainConfigurationName());
+    }
+
+    @Override
+    protected InputStream getMapConfiguration(String name) {
+        return null;
+    }
+
+    @Override
+    protected ResourceLocator getResourceLocator() {
+        return null;
+    }
+
+    @Override
+    protected InputStream getViewConfiguration(String location) {
+        return null;
+    }
+}



Mime
View raw message