blob: 80d5e6720e80203c1845e56f26aaf09eb25059ba (
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
85
86
87
88
89
90
91
92
93
94
95
|
/***************************************************************************
* 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.bundle;
import org.eclipse.emf.cdo.internal.server.RepositoryConfigurator;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.net4j.IAcceptor;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiApplication;
import org.eclipse.internal.net4j.Net4jConfigurator;
import java.io.File;
/**
* @author Eike Stepper
*/
public class CDOServerApplication extends OSGiApplication
{
public static final String ID = OM.BUNDLE_ID + ".app";
private IRepository[] repositories;
private IAcceptor[] acceptors;
public CDOServerApplication()
{
super(ID);
}
@Override
protected void doStart() throws Exception
{
super.doStart();
OM.LOG.info("CDO Server starting");
File configFile = OMPlatform.INSTANCE.getConfigFile("cdo-server.xml");
if (configFile != null && configFile.exists())
{
RepositoryConfigurator repositoryConfigurator = new RepositoryConfigurator(IPluginContainer.INSTANCE);
repositories = repositoryConfigurator.configure(configFile);
if (repositories == null || repositories.length == 0)
{
OM.LOG.warn("No repositories configured");
}
Net4jConfigurator net4jConfigurator = new Net4jConfigurator(IPluginContainer.INSTANCE);
acceptors = net4jConfigurator.configure(configFile);
if (acceptors == null || acceptors.length == 0)
{
OM.LOG.warn("No acceptors configured");
}
}
else
{
OM.LOG.warn("CDO server configuration not found: " + configFile.getAbsolutePath());
}
OM.LOG.info("CDO Server started");
}
@Override
protected void doStop() throws Exception
{
OM.LOG.info("CDO Server stopping");
if (acceptors != null)
{
for (IAcceptor acceptor : acceptors)
{
LifecycleUtil.deactivate(acceptor);
}
}
if (repositories != null)
{
for (IRepository repository : repositories)
{
LifecycleUtil.deactivate(repository);
}
}
OM.LOG.info("CDO Server stopped");
super.doStop();
}
}
|