blob: 195014105a11cc144d6c77f591aabbc0b90626b1 (
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
|
/*
* Copyright (c) 2007-2009, 2011-2013, 2018 Eike Stepper (Berlin, Germany) and others.
* 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
* Christian W. Damus (CEA) - private plug-in container instances
* Christian W. Damus (CEA) - bug 399641: container-aware factories
*/
package org.eclipse.net4j.internal.util.container;
import org.eclipse.net4j.internal.util.factory.PluginFactoryRegistry;
import org.eclipse.net4j.util.container.IElementProcessor;
import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.container.ManagedContainer;
import org.eclipse.net4j.util.factory.IFactory;
import org.eclipse.net4j.util.factory.IFactoryKey;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.log.OMLogger;
import org.eclipse.net4j.util.registry.IRegistry;
import java.util.List;
/**
* @author Eike Stepper
*/
public class PluginContainer extends ManagedContainer implements IPluginContainer
{
private static PluginContainer instance;
public PluginContainer()
{
}
/**
* @since 3.8
*/
@Override
protected String getTypeName()
{
return "PluginContainer"; //$NON-NLS-1$
}
@Override
protected IRegistry<IFactoryKey, IFactory> createFactoryRegistry()
{
return new PluginFactoryRegistry(this);
}
@Override
protected List<IElementProcessor> createPostProcessors()
{
return new PluginElementProcessorList();
}
public static void dispose()
{
if (instance != null)
{
LifecycleUtil.deactivate(instance, OMLogger.Level.WARN);
instance = null;
}
}
public static synchronized PluginContainer getInstance()
{
if (instance == null)
{
PluginContainer container = new PluginContainer();
container.setName("INSTANCE");
container.activate();
instance = container; // Leave instance==null in case of a Throwable in activate()
}
return instance;
}
}
|