summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-14 11:26:43 (EDT)
committerEike Stepper2007-08-14 11:26:43 (EDT)
commitacba50594d3bec8c2c8f11150f75b6b85d2bbffb (patch)
tree912dae95ecdae134d59565c3cf4f73a47ff724b4
parente986deb21f8ecf211400f77549afc8c75efa6850 (diff)
downloadcdo-acba50594d3bec8c2c8f11150f75b6b85d2bbffb.zip
cdo-acba50594d3bec8c2c8f11150f75b6b85d2bbffb.tar.gz
cdo-acba50594d3bec8c2c8f11150f75b6b85d2bbffb.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/build.properties3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/plugin.xml12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.server/build.properties3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/plugin.xml5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/schema/storeFactories.exsd112
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreFactory.java (renamed from plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java)15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreProvider.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/CDO UI.launch2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml25
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java24
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java4
20 files changed, 426 insertions, 87 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
index 399a239..836d486 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.emf.cdo.server.db
+Bundle-SymbolicName: org.eclipse.emf.cdo.server.db;singleton:=true
Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.emf.cdo.server.internal.db.bundle.OM$Activator
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.emf.cdo.server.db/build.properties b/plugins/org.eclipse.emf.cdo.server.db/build.properties
index b3ba16b..0e3eda4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/build.properties
+++ b/plugins/org.eclipse.emf.cdo.server.db/build.properties
@@ -6,4 +6,5 @@ bin.includes = META-INF/,\
about.html,\
copyright.txt,\
epl-v10.html,\
- license.html
+ license.html,\
+ plugin.xml
diff --git a/plugins/org.eclipse.emf.cdo.server.db/plugin.xml b/plugins/org.eclipse.emf.cdo.server.db/plugin.xml
new file mode 100644
index 0000000..2e8ea0e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.emf.cdo.server.storeFactories">
+ <storeFactory
+ class="org.eclipse.emf.cdo.server.internal.db.DBStoreFactory"
+ storeType="db">
+ </storeFactory>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index ffd60fd..dace7b4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.IDBAdapter;
import javax.sql.DataSource;
@@ -26,14 +27,22 @@ public class DBStore extends Store
{
private static final String TYPE = "db";
+ private IDBAdapter dbAdapter;
+
private DataSource dataSource;
- public DBStore(String storeID, DataSource dataSource)
+ public DBStore(IDBAdapter dbAdapter, DataSource dataSource)
{
- super(TYPE, storeID);
+ super(TYPE);
+ this.dbAdapter = dbAdapter;
this.dataSource = dataSource;
}
+ public IDBAdapter getDBAdapter()
+ {
+ return dbAdapter;
+ }
+
public DataSource getDataSource()
{
return dataSource;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index 831f52f..26a132d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -10,30 +10,72 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.internal.server.StoreFactory;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreFactory;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+
+import javax.sql.DataSource;
+
+import java.util.Properties;
/**
* @author Eike Stepper
*/
-public class DBStoreFactory extends StoreFactory<DBStore>
+public class DBStoreFactory implements IStoreFactory
{
- public static final String TYPE = "db";
-
public DBStoreFactory()
{
- super(TYPE);
}
- public DBStore create(String description) throws ProductCreationException
+ public String getStoreType()
+ {
+ return "db";
+ }
+
+ public IStore createStore(Element storeConfig)
{
- return null;
+ IDBAdapter dbAdapter = getDBAdapter(storeConfig);
+ DataSource dataSource = getDataSource(storeConfig);
+ return new DBStore(dbAdapter, dataSource);
}
- public static DBStore get(IManagedContainer container, String description)
+ private IDBAdapter getDBAdapter(Element storeConfig)
{
- return (DBStore)container.getElement(PRODUCT_GROUP, TYPE, description);
+ NodeList dbAdapterConfigs = storeConfig.getElementsByTagName("dbAdapter");
+ if (dbAdapterConfigs.getLength() != 1)
+ {
+ throw new IllegalStateException("Exactly one dbAdapter must be configured for DB store");
+ }
+
+ Element dbAdapterConfig = (Element)dbAdapterConfigs.item(0);
+ String dbAdapterName = dbAdapterConfig.getAttribute("name");
+ return DBUtil.getDBAdapter(dbAdapterName);
+ }
+
+ private DataSource getDataSource(Element storeConfig)
+ {
+ NodeList dataSourceConfigs = storeConfig.getElementsByTagName("dataSource");
+ if (dataSourceConfigs.getLength() != 1)
+ {
+ throw new IllegalStateException("Exactly one dataSource must be configured for DB store");
+ }
+
+ Properties properties = new Properties();
+ Element dataSourceConfig = (Element)dataSourceConfigs.item(0);
+ NamedNodeMap attributes = dataSourceConfig.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++)
+ {
+ Attr attribute = (Attr)attributes.item(i);
+ properties.put(attribute.getName(), attribute.getValue());
+ }
+
+ return DBUtil.createDataSource(properties);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/build.properties b/plugins/org.eclipse.emf.cdo.server/build.properties
index 37a8aaf..24a4701 100644
--- a/plugins/org.eclipse.emf.cdo.server/build.properties
+++ b/plugins/org.eclipse.emf.cdo.server/build.properties
@@ -11,7 +11,8 @@ bin.includes = .,\
copyright.txt,\
epl-v10.html,\
license.html,\
- plugin.xml
+ plugin.xml,\
+ schema/
jars.compile.order = .
source.. = src/
output.. = bin/
diff --git a/plugins/org.eclipse.emf.cdo.server/plugin.xml b/plugins/org.eclipse.emf.cdo.server/plugin.xml
index 60532a4..0c8c9df 100644
--- a/plugins/org.eclipse.emf.cdo.server/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.server/plugin.xml
@@ -2,14 +2,11 @@
<?eclipse version="3.2"?>
<plugin>
+ <extension-point id="storeFactories" name="CDO Store Factories" schema="schema/storeFactories.exsd"/>
<extension
point="org.eclipse.net4j.util.factories">
<factory
- productGroup="org.eclipse.emf.cdo.server.repositories"
- type="default"
- class="org.eclipse.emf.cdo.internal.server.RepositoryFactory"/>
- <factory
productGroup="org.eclipse.net4j.serverProtocols"
type="cdo"
class="org.eclipse.emf.cdo.internal.server.protocol.CDOPluginProtocolFactory"/>
diff --git a/plugins/org.eclipse.emf.cdo.server/schema/storeFactories.exsd b/plugins/org.eclipse.emf.cdo.server/schema/storeFactories.exsd
new file mode 100644
index 0000000..571127d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/schema/storeFactories.exsd
@@ -0,0 +1,112 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.cdo.server">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.emf.cdo.server" id="storeFactories" name="CDO Store Factories"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="storeFactory" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="storeFactory">
+ <complexType>
+ <attribute name="storeType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.cdo.server.IStoreFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index e1fe6a6..54842b8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import java.text.MessageFormat;
@@ -52,7 +53,7 @@ public class Repository extends Container implements IRepository
private RevisionManager revisionManager = new RevisionManager(this);
- private Object[] elements = { packageManager, sessionManager, resourceManager, revisionManager };
+ private Object[] elements;
private long nextOIDValue = INITIAL_OID_VALUE;
@@ -62,9 +63,21 @@ public class Repository extends Container implements IRepository
public Repository(String name, IStore store)
{
+ if (StringUtil.isEmpty(name))
+ {
+ throw new IllegalArgumentException("name is null or empty");
+ }
+
+ if (store == null)
+ {
+ throw new IllegalArgumentException("store is null");
+ }
+
this.name = name;
this.store = store;
+
uuid = UUID.randomUUID().toString();
+ elements = new Object[] { packageManager, sessionManager, resourceManager, revisionManager, store };
}
public String getName()
@@ -158,21 +171,6 @@ public class Repository extends Container implements IRepository
}
@Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- if (store == null)
- {
- throw new IllegalStateException("No store for repository " + name);
- }
-
- if (!LifecycleUtil.isActive(store))
- {
- throw new IllegalStateException("Inactive store for repository " + name);
- }
- }
-
- @Override
protected void doActivate() throws Exception
{
super.doActivate();
@@ -180,11 +178,13 @@ public class Repository extends Container implements IRepository
sessionManager.activate();
resourceManager.activate();
revisionManager.activate();
+ LifecycleUtil.activate(store);
}
@Override
protected void doDeactivate() throws Exception
{
+ LifecycleUtil.deactivate(store);
revisionManager.deactivate();
resourceManager.deactivate();
sessionManager.deactivate();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
new file mode 100644
index 0000000..a460032
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryConfigurator.java
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.server;
+
+import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreFactory;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class RepositoryConfigurator
+{
+ public RepositoryConfigurator()
+ {
+ }
+
+ public IRepository[] configure(File configFile) throws ParserConfigurationException, SAXException, IOException,
+ CoreException
+ {
+ List<IRepository> repositories = new ArrayList();
+ Document document = getDocument(configFile);
+ NodeList elements = document.getElementsByTagName("repository");
+ for (int i = 0; i < elements.getLength(); i++)
+ {
+ Element repositoryConfig = (Element)elements.item(i);
+ IRepository repository = configureRepository(repositoryConfig);
+ repositories.add(repository);
+ }
+
+ return repositories.toArray(new IRepository[repositories.size()]);
+ }
+
+ protected IRepository configureRepository(Element repositoryConfig) throws CoreException
+ {
+ String repositoryName = repositoryConfig.getAttribute("name");
+ NodeList storeConfigs = repositoryConfig.getElementsByTagName("store");
+ if (storeConfigs.getLength() != 1)
+ {
+ throw new IllegalStateException("Exactly one store must be configured for repository " + repositoryName);
+ }
+
+ Element storeConfig = (Element)storeConfigs.item(0);
+ IStore store = configureStore(storeConfig);
+ return new Repository(repositoryName, store);
+ }
+
+ protected IStore configureStore(Element storeConfig) throws CoreException
+ {
+ String type = storeConfig.getAttribute("type");
+ IStoreFactory storeFactory = getStoreFactory(type);
+ return storeFactory.createStore(storeConfig);
+ }
+
+ protected IStoreFactory getStoreFactory(String type) throws CoreException
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, "storeFactories");
+ for (IConfigurationElement element : elements)
+ {
+ if (ObjectUtil.equals(element.getName(), "storeFactory"))
+ {
+ String storeType = element.getAttribute("storeType");
+ if (ObjectUtil.equals(storeType, type))
+ {
+ return (IStoreFactory)element.createExecutableExtension("class");
+ }
+ }
+ }
+
+ throw new IllegalStateException("Store factory not found: " + type);
+ }
+
+ protected Document getDocument(File configFile) throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(configFile);
+ return document;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
index c2d94f3..6dc65fb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -12,28 +12,22 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
+
/**
* @author Eike Stepper
*/
-public abstract class Store implements IStore
+public abstract class Store extends Lifecycle implements IStore
{
private String type;
- private String storeID;
-
- public Store(String type, String storeID)
+ public Store(String type)
{
this.type = type;
- this.storeID = storeID;
}
public String getType()
{
return type;
}
-
- public String getStoreID()
- {
- return storeID;
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
index f5d1be4..47ed4bf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
@@ -10,6 +10,11 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.bundle;
+import org.eclipse.emf.cdo.internal.server.RepositoryConfigurator;
+import org.eclipse.emf.cdo.server.IRepository;
+
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
@@ -41,6 +46,28 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
+ static void start() throws Exception
+ {
+ if (DEBUG.isEnabled())
+ {
+ DEBUG.trace(OM.class, "Configuring repositories");
+ }
+
+ RepositoryConfigurator configurator = new RepositoryConfigurator();
+ IRepository[] repositories = configurator.configure(OMPlatform.INSTANCE.getConfigFile("cdo.server.xml"));
+ for (IRepository repository : repositories)
+ {
+ if (DEBUG.isEnabled())
+ {
+ DEBUG.trace(OM.class, "Activating repository " + repository.getName());
+ }
+
+ LifecycleUtil.activate(repository);
+ IPluginContainer.INSTANCE.putElement("org.eclipse.emf.cdo.server.repositories", "default", repository.getName(),
+ repository);
+ }
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java
index eedbde4..685d425 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerUtil.java
@@ -13,7 +13,22 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.internal.server.RepositoryFactory;
import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocolFactory;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import java.io.File;
+import java.io.IOException;
/**
* @author Eike Stepper
@@ -30,4 +45,30 @@ public final class CDOServerUtil
container.registerFactory(new RepositoryFactory(storeProvider));
container.registerFactory(new CDOServerProtocolFactory(repositoryProvider));
}
+
+ public static Element getRepositoryConfig(String repositoryName) throws ParserConfigurationException, SAXException,
+ IOException
+ {
+ File configFile = OMPlatform.INSTANCE.getConfigFile("cdo.server.xml");
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(configFile);
+ NodeList elements = document.getElementsByTagName("repository");
+ for (int i = 0; i < elements.getLength(); i++)
+ {
+ Node node = elements.item(i);
+ if (node instanceof Element)
+ {
+ Element element = (Element)node;
+ String name = element.getAttribute("name");
+ if (ObjectUtil.equals(name, repositoryName))
+ {
+ return element;
+ }
+ }
+ }
+
+ throw new IllegalStateException("Repository config not found: " + repositoryName);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index 7b3e5c1..139c951 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -17,8 +17,6 @@ public interface IStore
{
public String getType();
- public String getStoreID();
-
public IStoreReader getReader();
public IStoreWriter getWriter(IView view);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreFactory.java
index 0bc150c..5122a0c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreFactory.java
@@ -8,21 +8,16 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.emf.cdo.internal.server;
+package org.eclipse.emf.cdo.server;
-import org.eclipse.emf.cdo.server.IStore;
-
-import org.eclipse.net4j.internal.util.factory.Factory;
+import org.w3c.dom.Element;
/**
* @author Eike Stepper
*/
-public abstract class StoreFactory<PRODUCT extends IStore> extends Factory<PRODUCT>
+public interface IStoreFactory
{
- public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.server.stores";
+ public String getStoreType();
- public StoreFactory(String type)
- {
- super(PRODUCT_GROUP, type);
- }
+ public IStore createStore(Element storeConfig);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreProvider.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreProvider.java
index 4fa9622..545934e 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreProvider.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreProvider.java
@@ -15,5 +15,5 @@ package org.eclipse.emf.cdo.server;
*/
public interface IStoreProvider
{
- public IStore getStore(String name);
+ public IStore getStore(String repositoryName);
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch b/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch
index f15f1ea..46a678e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch
+++ b/plugins/org.eclipse.emf.cdo.ui/CDO UI.launch
@@ -15,7 +15,7 @@
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.console&#13;&#10;-Dorg.aspectj.tracing.debug=true&#13;&#10;-Xms40m&#13;&#10;-Xmx512m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.console&#13;&#10;-Dorg.aspectj.tracing.debug=false&#13;&#10;-Dnet4j.config=${resource_loc:/org.eclipse.emf.cdo.ui/config}&#13;&#10;-Xms40m&#13;&#10;-Xmx512m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<stringAttribute key="selectedPlugin" value="org.eclipse.emf.cdo.server.db"/>
diff --git a/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml b/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
index d25e659..f340910 100644
--- a/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<repositoryManager>
+<repositories>
- <repository>
- <name>repo1</name>
- <store>
- <type>db</type>
- <instanceID>TEST0001</instanceID>
- <dbAdapter>derby</dbAdapter>
- <dataSource>
- <driverClass>org.apache.derby.jdbc.EmbeddedDataSource</driverClass>
- <databaseName>C:/temp/cdodb1</databaseName>
- <createDatabase>create</createDatabase>
- </dataSource>
- <mappingStrategy>
-
- </mappingStrategy>
+ <repository name="repo1">
+ <store type="db">
+ <dbAdapter type="derby"/>
+ <dataSource
+ driverClass="org.apache.derby.jdbc.EmbeddedDataSource"
+ databaseName="C:/temp/cdodb1"
+ createDatabase="create"/>
</store>
</repository>
-</repositoryManager> \ No newline at end of file
+</repositories> \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
index 042a78d..cf68113 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/ManagedContainer.java
@@ -181,6 +181,18 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
return result;
}
+ public IFactory getFactory(String productGroup, String factoryType)
+ {
+ FactoryKey key = new FactoryKey(productGroup, factoryType);
+ IFactory factory = getFactoryRegistry().get(key);
+ if (factory == null)
+ {
+ throw new FactoryNotFoundException("Factory not found: " + key);
+ }
+
+ return factory;
+ }
+
public boolean isEmpty()
{
return elementRegistry.isEmpty();
@@ -255,10 +267,6 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
return element;
}
- /**
- * TODO Replace usages by factories (BufferProvider, ExecutorService,
- * ProtocolFactoryRegistry)
- */
public Object putElement(String productGroup, String factoryType, String description, Object element)
{
ContainerEvent event = new ContainerEvent(this);
@@ -369,13 +377,7 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
protected Object createElement(String productGroup, String factoryType, String description)
{
- FactoryKey key = new FactoryKey(productGroup, factoryType);
- IFactory factory = getFactoryRegistry().get(key);
- if (factory == null)
- {
- throw new FactoryNotFoundException("Factory not found: " + key);
- }
-
+ IFactory factory = getFactory(productGroup, factoryType);
return factory.create(description);
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
index 68a6c0f..9983f4a 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
@@ -42,6 +42,10 @@ public interface IManagedContainer extends IContainer
public Set<String> getFactoryTypes(String productGroup);
+ public IFactory getFactory(String productGroup, String factoryType);
+
+ public Object putElement(String productGroup, String factoryType, String description, Object element);
+
public String[] getElementKey(Object element);
public Object[] getElements(String productGroup);