X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db%2Fsrc%2Forg%2Fsimantics%2Fdb%2FServiceLocator.java;h=cdfc82079ad005beedda47dbf73fb7bb760a5a00;hb=refs%2Fchanges%2F38%2F238%2F2;hp=110064d120f332be9cc1f799c57645f7ba3421d2;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db/src/org/simantics/db/ServiceLocator.java b/bundles/org.simantics.db/src/org/simantics/db/ServiceLocator.java index 110064d12..cdfc82079 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/ServiceLocator.java +++ b/bundles/org.simantics.db/src/org/simantics/db/ServiceLocator.java @@ -1,92 +1,92 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db; - -import org.simantics.db.exception.ServiceNotFoundException; - -/** - *

- * A component with which one or more services are registered. The services can - * be retrieved from this locator using the class representing the interface the - * service must implement as a key. For example: - *

- * - *
- * SomeService service = session.getService(SomeService.class);
- * 
- * - *

- * If you want your service be disposed when the {@link ServiceLocator} is - * disposed, make your service implement {@link Disposable}. - *

- * - *

- * Implementations must be thread-safe. - *

- * - *

- * This interface is not to be implemented or extended by clients. - *

- * - * NOTE: this is a blatant copy of IServiceLocator in - * org.eclipse.ui.services, but for the purposes of the DB connection interface. - * - * @see Disposable - * - * @author eclipse.org - * @author Tuukka Lehtonen - */ -public interface ServiceLocator { - - /** - * Retrieves the service corresponding to the given API. - * - * @param api This is the interface that the service implements and was - * registered with using {@link #registerService(Class, Object)}. - * Must not be null. - * @return the requested service - * @throws ServiceNotFoundException if a requested service is not available - */ - public T getService(Class api) throws ServiceNotFoundException; - - /** - * Tries to retrieve the service corresponding to the given API. - * - * @param api - * This is the interface that the service implements. Must not be - * null. - * @return The service, or null if no such service could be - * found. - */ - public T peekService(Class api); - - /** - * Whether this service exists within the scope of this service locator. - * This does not include looking for the service within the scope of the - * parents. This method can be used to determine whether a particular - * service supports nesting in this scope. - * - * @param api - * This is the interface that the service implements. Must not be - * null. - * @return true iff the service locator can find a service - * for the given API; false otherwise. - */ - public boolean hasService(Class api); - - /** - * @param api the api that must be implemented by the specified service - * @param service the service implementation - */ - public void registerService(Class api, T service); - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db; + +import org.simantics.db.exception.ServiceNotFoundException; + +/** + *

+ * A component with which one or more services are registered. The services can + * be retrieved from this locator using the class representing the interface the + * service must implement as a key. For example: + *

+ * + *
+ * SomeService service = session.getService(SomeService.class);
+ * 
+ * + *

+ * If you want your service be disposed when the {@link ServiceLocator} is + * disposed, make your service implement {@link Disposable}. + *

+ * + *

+ * Implementations must be thread-safe. + *

+ * + *

+ * This interface is not to be implemented or extended by clients. + *

+ * + * NOTE: this is a blatant copy of IServiceLocator in + * org.eclipse.ui.services, but for the purposes of the DB connection interface. + * + * @see Disposable + * + * @author eclipse.org + * @author Tuukka Lehtonen + */ +public interface ServiceLocator { + + /** + * Retrieves the service corresponding to the given API. + * + * @param api This is the interface that the service implements and was + * registered with using {@link #registerService(Class, Object)}. + * Must not be null. + * @return the requested service + * @throws ServiceNotFoundException if a requested service is not available + */ + public T getService(Class api) throws ServiceNotFoundException; + + /** + * Tries to retrieve the service corresponding to the given API. + * + * @param api + * This is the interface that the service implements. Must not be + * null. + * @return The service, or null if no such service could be + * found. + */ + public T peekService(Class api); + + /** + * Whether this service exists within the scope of this service locator. + * This does not include looking for the service within the scope of the + * parents. This method can be used to determine whether a particular + * service supports nesting in this scope. + * + * @param api + * This is the interface that the service implements. Must not be + * null. + * @return true iff the service locator can find a service + * for the given API; false otherwise. + */ + public boolean hasService(Class api); + + /** + * @param api the api that must be implemented by the specified service + * @param service the service implementation + */ + public void registerService(Class api, T service); + +}