Permalink
Browse files

Gestion de la persistenace des runtimes.

  • Loading branch information...
1 parent 1ac1dcd commit 6e8994612d68bd2064ceb6f5d95781532851d7de @angelozerr angelozerr committed Sep 7, 2012
Showing with 456 additions and 11 deletions.
  1. +13 −0 com.orientechnologies.orient/pom.xml
  2. +2 −1 fr.opensagres.nosql.ide.core/plugin.properties
  3. +3 −1 fr.opensagres.nosql.ide.core/plugin.xml
  4. +95 −0 fr.opensagres.nosql.ide.core/schema/runtimeFactories.exsd
  5. +6 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/Platform.java
  6. +19 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/extensions/AbstractRuntimeFactory.java
  7. +11 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/extensions/IRuntimeFactory.java
  8. +21 −0 ...pensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/extensions/IRuntimeFactoryRegistry.java
  9. +145 −0 ...s.nosql.ide.core/src/fr/opensagres/nosql/ide/core/internal/extensions/RuntimeFactoryRegistry.java
  10. +51 −0 ...res.nosql.ide.core/src/fr/opensagres/nosql/ide/core/internal/settings/RuntimesContentHandler.java
  11. +3 −5 ...pensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/internal/settings/RuntimesSettings.java
  12. +23 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/AbstractServerRuntime.java
  13. +5 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/IServerRuntime.java
  14. +1 −0 fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/settings/RuntimesConstants.java
  15. +8 −0 fr.opensagres.nosql.ide.mongodb.core/plugin.xml
  16. +17 −0 ...ongodb.core/src/fr/opensagres/nosql/ide/mongodb/core/internal/extensions/MongoRuntimeFactory.java
  17. +1 −0 fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.java
  18. +1 −0 fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.properties
  19. +31 −4 ...gres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/InstalledRuntimesBlock.java
@@ -0,0 +1,13 @@
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>com.orientechnologies.orient</artifactId>
+
+ <packaging>eclipse-plugin</packaging>
+ <parent>
+ <groupId>fr.opensagres.mongodb-ide</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
@@ -14,4 +14,5 @@ providerName=Opensagres
# Extension Point
serverTypesContributionName=NoSQL Server types contribution.
serverFactoriesContributionName=NoSQL Server factories contribution.
-serverRunnersContributionName=NoSQL Server runners contribution.
+serverRunnersContributionName=NoSQL Server runners contribution.
+runtimeFactoriesContributionName=NoSQL Runtime factories contribution.
@@ -8,5 +8,7 @@
schema="schema/serverFactories.exsd" />
<extension-point id="serverRunners" name="%serverRunnersContributionName"
schema="schema/serverRunners.exsd" />
-
+ <extension-point id="runtimeFactories" name="%runtimeFactoriesContributionName"
+ schema="schema/runtimeFactories.exsd" />
+
</plugin>
@@ -0,0 +1,95 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="fr.opensagres.nosql.ide.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="fr.opensagres.nosql.ide.core" id="runtimeFactories" name="Runtime Factories."/>
+ </appinfo>
+ <documentation>
+ Extension point for add NoSQL Runtime Factories.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="runtimeFactory" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="runtimeFactory">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="serverType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="fr.opensagres.nosql.ide.core.serverTypes/serverType/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":fr.opensagres.nosql.ide.core.extensions.IRuntimeFactory"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
@@ -1,10 +1,12 @@
package fr.opensagres.nosql.ide.core;
+import fr.opensagres.nosql.ide.core.extensions.IRuntimeFactoryRegistry;
import fr.opensagres.nosql.ide.core.extensions.IServerFactoryRegistry;
import fr.opensagres.nosql.ide.core.extensions.IServerRunnerRegistry;
import fr.opensagres.nosql.ide.core.extensions.IServerTypeRegistry;
import fr.opensagres.nosql.ide.core.internal.ServerManager;
import fr.opensagres.nosql.ide.core.internal.ServerRuntimeManager;
+import fr.opensagres.nosql.ide.core.internal.extensions.RuntimeFactoryRegistry;
import fr.opensagres.nosql.ide.core.internal.extensions.ServerFactoryRegistry;
import fr.opensagres.nosql.ide.core.internal.extensions.ServerRunnerRegistry;
import fr.opensagres.nosql.ide.core.internal.extensions.ServerTypeRegistry;
@@ -37,4 +39,8 @@ public static IShellCommandManagerRegistry getShellCommandManagerRegistry() {
return ShellCommandManagerRegistry.getInstance();
}
+ public static IRuntimeFactoryRegistry getRuntimeFactoryRegistry() {
+ return RuntimeFactoryRegistry.getInstance();
+ }
+
}
@@ -0,0 +1,19 @@
+package fr.opensagres.nosql.ide.core.extensions;
+
+import org.xml.sax.Attributes;
+
+import fr.opensagres.nosql.ide.core.model.IServerRuntime;
+import fr.opensagres.nosql.ide.core.settings.RuntimesConstants;
+
+public abstract class AbstractRuntimeFactory implements IRuntimeFactory {
+
+ public IServerRuntime create(Attributes attributes) throws Exception {
+ String id = attributes.getValue(RuntimesConstants.ID_ATTR);
+ String name = attributes.getValue(RuntimesConstants.NAME_ATTR);
+ String path = attributes.getValue(RuntimesConstants.PATH_ATTR);
+ return doCreate(id, name, path, attributes);
+ }
+
+ protected abstract IServerRuntime doCreate(String id, String name,
+ String path, Attributes attributes) throws Exception;
+}
@@ -0,0 +1,11 @@
+package fr.opensagres.nosql.ide.core.extensions;
+
+import org.xml.sax.Attributes;
+
+import fr.opensagres.nosql.ide.core.model.IServerRuntime;
+
+public interface IRuntimeFactory {
+
+ IServerRuntime create(Attributes attributes) throws Exception;
+
+}
@@ -0,0 +1,21 @@
+package fr.opensagres.nosql.ide.core.extensions;
+
+import java.util.Collection;
+
+public interface IRuntimeFactoryRegistry extends IRegistry {
+
+ /**
+ * Return the {@link IRuntimeFactory} retrieved by the given id.
+ *
+ * @param id
+ * @return
+ */
+ IRuntimeFactory getFactory(IServerType serverType);
+
+ /**
+ * Return the list of the {@link IRuntimeFactory}.
+ *
+ * @return
+ */
+ Collection<IRuntimeFactory> getFactories();
+}
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (C) 2012 Angelo Zerr <angelo.zerr@gmail.com>, Pascal Leclercq <pascal.leclercq@gmail.com>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Angelo ZERR - initial API and implementation
+ * Pascal Leclercq - initial API and implementation
+ *******************************************************************************/
+package fr.opensagres.nosql.ide.core.internal.extensions;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+import fr.opensagres.nosql.ide.core.extensions.AbstractRegistry;
+import fr.opensagres.nosql.ide.core.extensions.IRuntimeFactory;
+import fr.opensagres.nosql.ide.core.extensions.IRuntimeFactoryRegistry;
+import fr.opensagres.nosql.ide.core.extensions.IServerType;
+import fr.opensagres.nosql.ide.core.internal.Activator;
+import fr.opensagres.nosql.ide.core.internal.Trace;
+
+/**
+ * Registry which holds instance of {@link IRuntimeFactory} created by the
+ * fr.opensagres.nosql.ide.core.runtimeFactorys" extension point.
+ *
+ */
+public class RuntimeFactoryRegistry extends AbstractRegistry implements
+ IRuntimeFactoryRegistry {
+
+ private static final IRuntimeFactoryRegistry INSTANCE = new RuntimeFactoryRegistry();
+
+ private static final String SERVER_FACTORY_ELT = "runtimeFactory";
+ public static final String SERVER_TYPE_ATTR = "serverType";
+ private static final String SERVER_FACTORIES_EXTENSION_POINT = "runtimeFactories";
+
+ public static IRuntimeFactoryRegistry getInstance() {
+ return INSTANCE;
+ }
+
+ private Map<IServerType, IRuntimeFactory> runtimeFactories = new HashMap<IServerType, IRuntimeFactory>();
+
+ /**
+ * Return the {@link IRuntimeFactory} retrieved by the given id.
+ *
+ * @param id
+ * @return
+ */
+ public IRuntimeFactory getFactory(IServerType serverType) {
+ if (serverType == null) {
+ throw new IllegalArgumentException();
+ }
+ loadRegistryIfNedded();
+ return runtimeFactories.get(serverType);
+ }
+
+ /**
+ * Return the list of the {@link IRuntimeFactory}.
+ *
+ * @return
+ */
+ public Collection<IRuntimeFactory> getFactories() {
+ loadRegistryIfNedded();
+ return runtimeFactories.values();
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ parseRuntimeFactoryManagers(cf);
+ } else {
+ // TODO : remove references
+ }
+
+ }
+
+ protected synchronized void loadRegistry() {
+ if (isRegistryIntialized()) {
+ return;
+ }
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ getPluginId(), getExtensionPoint());
+ parseRuntimeFactoryManagers(cf);
+ }
+ }
+
+ /**
+ * Parse elements of the extension poit and create for each server element
+ * an instance of {@link IRuntimeFactory}.
+ *
+ * <pre>
+ * <extension
+ * point="fr.opensagres.nosql.ide.core.runtimeFactorys">
+ * <runtimeFactory
+ * id="fr.opensagres.nosql.ide.mongodb.core"
+ * name="%runtimeFactory.name">
+ * </runtimeFactory>
+ * </extension>
+ * </pre>
+ *
+ * @param cf
+ */
+ private void parseRuntimeFactoryManagers(IConfigurationElement[] cf) {
+ for (IConfigurationElement ce : cf) {
+ IServerType serverType = null;
+ String serverTypeId = null;
+ IRuntimeFactory factory = null;
+ if (SERVER_FACTORY_ELT.equals(ce.getName())) {
+ serverTypeId = ce.getAttribute(SERVER_TYPE_ATTR);
+ serverType = fr.opensagres.nosql.ide.core.Platform
+ .getServerTypeRegistry().getType(serverTypeId);
+ try {
+ factory = (IRuntimeFactory) ce
+ .createExecutableExtension(CLASS_ATTR);
+ runtimeFactories.put(serverType, factory);
+ } catch (CoreException e) {
+ Trace.trace(Trace.STRING_SEVERE, e.getMessage());
+ }
+ }
+ }
+ }
+
+ @Override
+ protected String getPluginId() {
+ return Activator.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return SERVER_FACTORIES_EXTENSION_POINT;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 6e89946

Please sign in to comment.