cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r412068 - in /incubator/cayenne/main/branches/PROTO-3.0: modeler-plugin/ modeler/ modeler/modeler-launcher/ modeler/modeler-launcher/src/ modeler/modeler-launcher/src/main/ modeler/modeler-launcher/src/main/java/ modeler/modeler-launcher/sr...
Date Tue, 06 Jun 2006 10:30:51 GMT
Author: aadamchik
Date: Tue Jun  6 03:30:49 2006
New Revision: 412068

URL: http://svn.apache.org/viewvc?rev=412068&view=rev
Log:
organizing plungins to a modeler assembly

Added:
    incubator/cayenne/main/branches/PROTO-3.0/modeler/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/assembly.xml
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.classpath
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.project
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/pom.xml
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/CayennePluginEngine.java
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/Launcher.java
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/
      - copied from r412063, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/.classpath
      - copied unchanged from r412067, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/.classpath
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/.project
      - copied unchanged from r412067, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/.project
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/.settings/
      - copied from r412067, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/.settings/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/pom.xml
      - copied, changed from r412067, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/pom.xml
    incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/src/
      - copied from r412067, incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/src/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/pom.xml
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/
      - copied from r412063, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/.classpath
      - copied unchanged from r412067, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/.classpath
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/.project
      - copied unchanged from r412067, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/.project
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/.settings/
      - copied from r412067, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/.settings/
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/pom.xml
      - copied, changed from r412067, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/pom.xml
    incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/src/
      - copied from r412067, incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/src/
Removed:
    incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/
    incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/assembly.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/assembly.xml?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/assembly.xml (added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/assembly.xml Tue Jun  6 03:30:49 2006
@@ -0,0 +1,5 @@
+<assembly>
	<id>modeler-minimal</id>
	<formats>
		<format>jar</format>
</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
+		<fileSet>
			<directory>modeler-launcher/target/classes</directory>
		<outputDirectory>/</outputDirectory>
		</fileSet>
		<fileSet>
	
	<directory>swing-plugin/target</directory>
			<outputDirectory>/</outputDirectory>
+			<includes>
            	<include>*.jar</include>
			</includes>
	</fileSet>
+		<fileSet>
			<directory>modeler-plugin/target</directory>
			<outputDirectory>/</outputDirectory>
+			<includes>
            	<include>*.jar</include>
			</includes>
	</fileSet>
	</fileSets>
	<dependencySets>
		<dependencySet>
			<outputDirectory>/</outputDirectory>
		<unpack>true</unpack>
			<scope>runtime</scope>
		</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.classpath
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.classpath?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.classpath (added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.classpath Tue Jun
 6 03:30:49 2006
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.project
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.project?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.project (added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/.project Tue Jun  6
03:30:49 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>modeler-launcher</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/pom.xml?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/pom.xml (added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/pom.xml Tue Jun  6
03:30:49 2006
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cayenne</groupId>
+  <artifactId>modeler-launcher</artifactId>
+  <packaging>jar</packaging>
+  <version>3.0-SNAPSHOT</version>
+  <name>CayenneModeler Plugin Launcher</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+		<dependency>
+			<groupId>org.platonos</groupId>
+			<artifactId>plugin-engine</artifactId>
+			<version>1.1-SNAPSHOT</version>
+		</dependency>
+  </dependencies>
+  
+    <repositories>
+		<repository>
+			<id>objectstyle</id>
+			<name>ObjectStyle Public Maven2 repo</name>
+			<url>http://objectstyle.org/maven2</url>
+		</repository>
+	</repositories>
+</project>

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/CayennePluginEngine.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/CayennePluginEngine.java?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/CayennePluginEngine.java
(added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/CayennePluginEngine.java
Tue Jun  6 03:30:49 2006
@@ -0,0 +1,109 @@
+/*
+ *  Copyright 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.
+ */
+package org.apache.cayenne.modeler.launcher;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.platonos.pluginengine.PluginEngine;
+import org.platonos.pluginengine.PluginEngineException;
+import org.platonos.pluginengine.logging.ILogger;
+import org.platonos.pluginengine.logging.LoggerLevel;
+
+/**
+ * An extension of PluginEngine that allows to store arbitrary attributes in the engine
+ * and also load plugins from CLASSPATH.
+ * 
+ * @author andrus
+ */
+public class CayennePluginEngine extends PluginEngine {
+
+    public static final String PLUGIN_LOCATION = "plugin.xml";
+
+    protected Map attributes = new HashMap();
+
+    public CayennePluginEngine(String uid, ILogger logger) {
+        super(uid, logger);
+    }
+
+    public CayennePluginEngine(String uid) {
+        super(uid);
+    }
+
+    /**
+     * Loads all plugin descriptors that are available to the current ClassLoader.
+     */
+    public void loadBundledPlugins() {
+        Enumeration urls;
+
+        try {
+            urls = Thread.currentThread().getContextClassLoader().getResources(
+                    PLUGIN_LOCATION);
+
+        }
+        catch (IOException e) {
+            throw new RuntimeException("Error reading plugins infor from ClassLoader", e);
+        }
+
+        while (urls.hasMoreElements()) {
+            URL pluginURL = (URL) urls.nextElement();
+            try {
+                // TODO, andrus, 6/5/2006 - plugins loaded in this fashion will
+                // only be able to resolve classes from the same filesystem
+                // folder as plugin.xml. Will need a specialized ClassLoader for
+                // this case.
+                loadPluginXML(pluginURL);
+            }
+            catch (PluginEngineException ex) {
+                getLogger().log(
+                        LoggerLevel.SEVERE,
+                        "Error loading Plugin archive from URL: " + pluginURL,
+                        ex);
+            }
+        }
+    }
+
+    /**
+     * Returns a previously stored attribute for a given key or null if no attribute
+     * matches the key.
+     */
+    public Object getAttribute(String key) {
+        if (key == null) {
+            throw new NullPointerException("Invalid argument: key");
+        }
+
+        return (String) attributes.get(key);
+    }
+
+    public void setAttribute(String key, Object value) {
+        if (key == null) {
+            throw new NullPointerException("Invalid argument: key");
+        }
+
+        attributes.put(key, value);
+    }
+
+    public void removeAttribute(String key) {
+        if (key == null) {
+            throw new NullPointerException("Invalid argument: key");
+        }
+
+        attributes.remove(key);
+    }
+}

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/Launcher.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/Launcher.java?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/Launcher.java
(added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-launcher/src/main/java/org/apache/cayenne/modeler/launcher/Launcher.java
Tue Jun  6 03:30:49 2006
@@ -0,0 +1,109 @@
+/*
+ *  Copyright 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.
+ */
+package org.apache.cayenne.modeler.launcher;
+
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import org.platonos.pluginengine.Plugin;
+import org.platonos.pluginengine.logging.LoggerLevel;
+
+/**
+ * Starts a plugin shell for a Swing application.
+ */
+public class Launcher {
+
+    public static final String COMMAND_LINE_ATTRIBUTE = "command.line";
+
+    static final String ENGINE_NAME = "Cayenne Plugin Engine";
+
+    /**
+     * A property specifying a location of the plugins directory. It can be a comma
+     * separated list of directories. If not set, current directory is used.
+     */
+    public static final String PLUGINS_DIR_PROPERTY = "cayenne.plugins.dirs";
+
+    public static final String LOCALE_PROPERTY = "cayenne.ui.locale";
+
+    public static void main(String[] args) {
+
+        CayennePluginEngine pluginEngine = new CayennePluginEngine(ENGINE_NAME);
+        pluginEngine.setAttribute(COMMAND_LINE_ATTRIBUTE, args);
+
+        // set default locale
+        String locale = System.getProperty(LOCALE_PROPERTY);
+        if (locale != null) {
+
+            StringTokenizer toks = new StringTokenizer(locale, "_");
+
+            if (toks.hasMoreTokens()) {
+                // note that default local parts must be empty strings, not nulls...
+                String language = "";
+                String country = "";
+                String variant = "";
+
+                language = toks.nextToken();
+
+                if (toks.hasMoreTokens()) {
+                    country = toks.nextToken();
+
+                    if (toks.hasMoreTokens()) {
+                        variant = toks.nextToken();
+                    }
+                }
+
+                Locale.setDefault(new Locale(language, country, variant));
+            }
+
+        }
+
+        // load plugins from ClassPath
+        pluginEngine.loadBundledPlugins();
+
+        // load plugins from extra directories
+        String pluginDirectories = System.getProperty(PLUGINS_DIR_PROPERTY);
+        if (pluginDirectories != null) {
+            StringTokenizer toks = new StringTokenizer(pluginDirectories, ",");
+            while (toks.hasMoreTokens()) {
+                pluginEngine.loadPlugins(toks.nextToken());
+            }
+        }
+
+        pluginEngine.start();
+
+        boolean hasStartedPlugins = false;
+        Iterator it = pluginEngine.getPlugins().iterator();
+        while (it.hasNext()) {
+            Plugin p = (Plugin) it.next();
+            if (p.isStarted()) {
+                hasStartedPlugins = true;
+                break;
+            }
+        }
+
+        // either no plugins configured, all all of them failed to start.
+        if (!hasStartedPlugins) {
+            pluginEngine.getLogger().log(
+                    LoggerLevel.INFO,
+                    "No plugins started, exiting",
+                    null);
+
+            // must explicitly kill all UI threads
+            System.exit(0);
+        }
+    }
+}

Copied: incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/pom.xml (from r412067,
incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/pom.xml)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/pom.xml?p2=incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/pom.xml&p1=incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/pom.xml&r1=412067&r2=412068&rev=412068&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler-plugin/pom.xml (original)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/modeler-plugin/pom.xml Tue Jun  6 03:30:49
2006
@@ -5,7 +5,7 @@
   <artifactId>modeler-plugin</artifactId>
   <packaging>jar</packaging>
   <version>3.0-SNAPSHOT</version>
-  <name>Maven Quick Start Archetype</name>
+  <name>CayenneModeler Plugin</name>
   <url>http://maven.apache.org</url>
   
 	<dependencies>
@@ -30,4 +30,12 @@
 			<scope>provided</scope>
 		</dependency>
 	</dependencies>
+	
+	<repositories>
+		<repository>
+			<id>objectstyle</id>
+			<name>ObjectStyle Public Maven2 repo</name>
+			<url>http://objectstyle.org/maven2</url>
+		</repository>
+	</repositories>
 </project>

Added: incubator/cayenne/main/branches/PROTO-3.0/modeler/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/pom.xml?rev=412068&view=auto
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/modeler/pom.xml (added)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/pom.xml Tue Jun  6 03:30:49 2006
@@ -0,0 +1,18 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.cayenne</groupId>
+	<artifactId>modeler</artifactId>
+	<packaging>pom</packaging>
+	<version>3.0-SNAPSHOT</version>
+	<name>CayenneModeler Assembly</name>
+	<url>http://incubator.apache.org/cayenne/</url>
+
+	<modules>
+		<module>modeler-launcher</module>
+		<module>swing-plugin</module>
+		<module>modeler-plugin</module>
+	</modules>
+	
+	<build>
		<plugins>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
			<configuration>
					<descriptor>assembly.xml</descriptor>
					<finalName>modeler</finalName>
				<outputDirectory>target</outputDirectory>
					<workDirectory>target/assembly/work</workDirectory>
			</configuration>
			</plugin>
		</plugins>
	</build>
+</project>

Copied: incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/pom.xml (from r412067,
incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/pom.xml)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/pom.xml?p2=incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/pom.xml&p1=incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/pom.xml&r1=412067&r2=412068&rev=412068&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/swing-plugin/pom.xml (original)
+++ incubator/cayenne/main/branches/PROTO-3.0/modeler/swing-plugin/pom.xml Tue Jun  6 03:30:49
2006
@@ -5,15 +5,9 @@
   <artifactId>swing-plugin</artifactId>
   <packaging>jar</packaging>
   <version>3.0-SNAPSHOT</version>
-  <name>Maven Quick Start Archetype</name>
+  <name>Generic Swing Plugin</name>
   <url>http://maven.apache.org</url>
 	<dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>3.8.1</version>
-			<scope>test</scope>
-		</dependency>
     
 		<!-- provided dependencies -->
 		<dependency>



Mime
View raw message