]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.services/src/org/simantics/db/services/AdaptionServiceInitializer.java
Speeding up platform startup time
[simantics/platform.git] / bundles / org.simantics.db.services / src / org / simantics / db / services / AdaptionServiceInitializer.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 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  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.services;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.simantics.db.Session;
17 import org.simantics.db.adaption.AdaptionService;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.services.adaption.AdapterRegistry2;
20 import org.simantics.db.services.adaption.AdaptionService2;
21 import org.simantics.db.services.internal.Activator;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * @author Tuukka Lehtonen
27  */
28 public class AdaptionServiceInitializer implements ServiceInitializer {
29
30     private static final Logger LOGGER = LoggerFactory.getLogger(AdaptionServiceInitializer.class);
31
32     public IStatus initialize(final Session s) {
33         LOGGER.info("Initializing");
34         AdaptionService2 service = new AdaptionService2();
35         s.registerService(AdaptionService.class, service);
36         try {
37                 AdapterRegistry2 registry = new AdapterRegistry2();
38                 registry.initialize(Activator.getDefault().getContext());
39             LOGGER.info("Updating");
40             registry.updateAdaptionService(s, service);
41             return Status.OK_STATUS;
42         } catch (DatabaseException e) {
43             IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "AdaptionRegistry2 instantiation failed, see exception for details.", e);
44             return status;
45         }
46     }
47
48 }