Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c238435bec53d7803056a19def50c04e4ba97d7c (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
/*******************************************************************************
 * Copyright (c) 2005, 2018 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.provisional.frameworkadmin;

import java.lang.reflect.InvocationTargetException;

/**
 * Factory class for creating FrameworkAdmin object from Java programs.
 * 
 * @see FrameworkAdmin
 */
public abstract class FrameworkAdminFactory {
	abstract protected FrameworkAdmin createFrameworkAdmin()
			throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException,
			InvocationTargetException, NoSuchMethodException, SecurityException;

	// proposed method: only for ConfiguratorManipulatorFactory, magic system
	// property is used.
	public static FrameworkAdmin getInstance(String className)
			throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException,
			InvocationTargetException, NoSuchMethodException, SecurityException {
		FrameworkAdminFactory factory = (FrameworkAdminFactory) Class.forName(className).getDeclaredConstructor()
				.newInstance();
		return factory.createFrameworkAdmin();
	}

	// // method 3: two magic system properties are used.
	// public static FrameworkAdmin getInstance() throws InstantiationException,
	// IllegalAccessException, ClassNotFoundException {
	// String className =
	// System.getProperty("org.eclipse.equinox.internal.provisional.frameworkadmin.frameworkAdminFactory");
	// if (className == null)
	// throw new ClassNotFoundException("System property keyed by
	// \"org.eclipse.equinox.internal.provisional.frameworkadmin.frameworkAdminFactory\"
	// is not set.");
	// FrameworkAdminFactory factory = (FrameworkAdminFactory)
	// Class.forName(className).newInstance();
	// return (FrameworkAdmin) factory.createFrameworkAdmin();
	// }

	// // method 1: no magic system properties are used.
	//
	// public static FrameworkAdmin getInstance(String className, String
	// configuratorManipulatorFactoryName) throws InstantiationException,
	// IllegalAccessException, ClassNotFoundException {
	// ExtendedFrameworkAdminFactory factory = (ExtendedFrameworkAdminFactory)
	// Class.forName(className).newInstance();
	// return (FrameworkAdmin)
	// factory.createFrameworkAdmin(configuratorManipulatorFactoryName);
	// }

}

Back to the top