1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.services;
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;
26 * @author Tuukka Lehtonen
28 public class AdaptionServiceInitializer implements ServiceInitializer {
30 private static final Logger LOGGER = LoggerFactory.getLogger(AdaptionServiceInitializer.class);
32 public IStatus initialize(final Session s) {
33 LOGGER.info("Initializing");
34 AdaptionService2 service = new AdaptionService2();
35 s.registerService(AdaptionService.class, service);
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);