]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/ServiceLocator.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / ServiceLocator.java
index 110064d120f332be9cc1f799c57645f7ba3421d2..cdfc82079ad005beedda47dbf73fb7bb760a5a00 100644 (file)
@@ -1,92 +1,92 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.db;\r
-\r
-import org.simantics.db.exception.ServiceNotFoundException;\r
-\r
-/**\r
- * <p>\r
- * A component with which one or more services are registered. The services can\r
- * be retrieved from this locator using the class representing the interface the\r
- * service must implement as a key. For example:\r
- * </p>\r
- * \r
- * <pre>\r
- * SomeService service = session.getService(SomeService.class);\r
- * </pre>\r
- * \r
- * <p>\r
- * If you want your service be disposed when the {@link ServiceLocator} is\r
- * disposed, make your service implement {@link Disposable}.\r
- * </p>\r
- * \r
- * <p>\r
- * Implementations must be thread-safe.\r
- * </p>\r
- * \r
- * <p>\r
- * This interface is not to be implemented or extended by clients.\r
- * </p>\r
- * \r
- * <strong>NOTE:</strong> this is a blatant copy of IServiceLocator in\r
- * org.eclipse.ui.services, but for the purposes of the DB connection interface.\r
- * \r
- * @see Disposable\r
- * \r
- * @author eclipse.org\r
- * @author Tuukka Lehtonen\r
- */\r
-public interface ServiceLocator {\r
-\r
-    /**\r
-     * Retrieves the service corresponding to the given API.\r
-     * \r
-     * @param api This is the interface that the service implements and was\r
-     *        registered with using {@link #registerService(Class, Object)}.\r
-     *        Must not be <code>null</code>.\r
-     * @return the requested service\r
-     * @throws ServiceNotFoundException if a requested service is not available\r
-     */\r
-    public <T> T getService(Class<T> api) throws ServiceNotFoundException;\r
-\r
-    /**\r
-     * Tries to retrieve the service corresponding to the given API.\r
-     * \r
-     * @param api\r
-     *            This is the interface that the service implements. Must not be\r
-     *            <code>null</code>.\r
-     * @return The service, or <code>null</code> if no such service could be\r
-     *         found.\r
-     */\r
-    public <T> T peekService(Class<T> api);\r
-\r
-    /**\r
-     * Whether this service exists within the scope of this service locator.\r
-     * This does not include looking for the service within the scope of the\r
-     * parents. This method can be used to determine whether a particular\r
-     * service supports nesting in this scope.\r
-     * \r
-     * @param api\r
-     *            This is the interface that the service implements. Must not be\r
-     *            <code>null</code>.\r
-     * @return <code>true</code> iff the service locator can find a service\r
-     *         for the given API; <code>false</code> otherwise.\r
-     */\r
-    public boolean hasService(Class<?> api);\r
-\r
-    /**\r
-     * @param api the api that must be implemented by the specified service\r
-     * @param service the service implementation\r
-     */\r
-    public <T> void registerService(Class<T> api, T service);\r
-\r
-}\r
+/*******************************************************************************
+ * 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;
+
+/**
+ * <p>
+ * 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:
+ * </p>
+ * 
+ * <pre>
+ * SomeService service = session.getService(SomeService.class);
+ * </pre>
+ * 
+ * <p>
+ * If you want your service be disposed when the {@link ServiceLocator} is
+ * disposed, make your service implement {@link Disposable}.
+ * </p>
+ * 
+ * <p>
+ * Implementations must be thread-safe.
+ * </p>
+ * 
+ * <p>
+ * This interface is not to be implemented or extended by clients.
+ * </p>
+ * 
+ * <strong>NOTE:</strong> 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 <code>null</code>.
+     * @return the requested service
+     * @throws ServiceNotFoundException if a requested service is not available
+     */
+    public <T> T getService(Class<T> 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
+     *            <code>null</code>.
+     * @return The service, or <code>null</code> if no such service could be
+     *         found.
+     */
+    public <T> T peekService(Class<T> 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
+     *            <code>null</code>.
+     * @return <code>true</code> iff the service locator can find a service
+     *         for the given API; <code>false</code> otherwise.
+     */
+    public boolean hasService(Class<?> api);
+
+    /**
+     * @param api the api that must be implemented by the specified service
+     * @param service the service implementation
+     */
+    public <T> void registerService(Class<T> api, T service);
+
+}