]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics/src/org/simantics/internal/startup/StartupExtensions.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / internal / startup / StartupExtensions.java
1 /*******************************************************************************
2  * Copyright (c) 2015 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.internal.startup;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.simantics.PlatformException;
18 import org.simantics.internal.Activator;
19 import org.simantics.startup.IStartup;
20
21 /**
22  * @author Tuukka Lehtonen
23  */
24 public class StartupExtensions {
25
26     /**
27      * @return
28      */
29     public static StartupExtension[] getAllStartupExtensions() {
30         return Activator.getDefault().getStartupRegistry().getExtensions();
31     }
32
33     /**
34      * Consults all {@link IStartup} extensions retrieved from
35      * {@link #getAllStartupExtensions()} by invoking their
36      * {@link IStartup#preStartup()} method.
37      * 
38      * @throws PlatformException
39      */
40     public static void consultStartupExtensions() throws PlatformException {
41         for (StartupExtension ext : getAllStartupExtensions()) {
42             try {
43                 ext.newInstance().preStartup();
44             } catch (CoreException ex) {
45                 Activator.getDefault().getLog().log(
46                         new Status(IStatus.ERROR, Activator.PLUGIN_ID,
47                                 "Failed to instantiate startup extension class "
48                                         + ext.getClassName(), ex));
49             }
50         }
51     }
52
53 }