blob: 93b7f6f849b2a02d8a39db6cb341247c01281f16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/***************************************************************************
* Copyright (c) 2004 - 2008 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.internal.cdo;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
import org.eclipse.net4j.internal.util.factory.Factory;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.emf.common.util.URI;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* @author Eike Stepper
*/
public class CDOSessionFactory extends Factory
{
public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.sessions";
public static final String TYPE = "cdo";
public CDOSessionFactory()
{
super(PRODUCT_GROUP, TYPE);
}
public CDOSession create(String description)
{
return createSession(getRepositoryName(description), isDisableLegacyObjects(description),
isAutomaticPackageRegistry(description), null);
}
public static String getRepositoryName(String description)
{
URI uri = URI.createURI(description);
IPath path = new Path(uri.path());
return path.segment(0);
}
public boolean isDisableLegacyObjects(String description)
{
return description.contains("disableLegacyObjects=true");
}
public boolean isAutomaticPackageRegistry(String description)
{
return description.contains("automaticPackageRegistry=true");
}
public static CDOSession get(IManagedContainer container, String description)
{
return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description);
}
public static CDOSessionImpl createSession(String repositoryName, boolean disableLegacyObjects,
boolean automaticPackageRegistry, IFailOverStrategy failOverStrategy)
{
CDOSessionImpl session = new CDOSessionImpl();
if (automaticPackageRegistry)
{
CDOPackageRegistryImpl.SelfPopulating packageRegistry = new CDOPackageRegistryImpl.SelfPopulating();
packageRegistry.setSession(session);
session.setPackageRegistry(packageRegistry);
}
session.setRepositoryName(repositoryName);
session.setDisableLegacyObjects(disableLegacyObjects);
session.setFailOverStrategy(failOverStrategy);
return session;
}
}
|