--- /dev/null
+/*******************************************************************************\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.exception;\r
+\r
+import org.simantics.db.ServiceLocator;\r
+\r
+/**\r
+ * Thrown by {@link ServiceLocator} when requested services are unavailable.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ServiceNotFoundException extends RuntimeDatabaseException {\r
+\r
+ private static final long serialVersionUID = 2454410258587204157L;\r
+\r
+ private final ServiceLocator locator;\r
+ private final Class<?> clazz;\r
+\r
+ public ServiceNotFoundException(ServiceLocator locator, Class<?> clazz, String message) {\r
+ super(message);\r
+ this.locator = locator;\r
+ this.clazz = clazz;\r
+ }\r
+\r
+ public ServiceNotFoundException(ServiceLocator locator, Class<?> clazz) {\r
+ this.locator = locator;\r
+ this.clazz = clazz;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(clazz.getName()).append(" is not available in ").append(locator.toString());\r
+ String msg = getMessage();\r
+ if (msg != null)\r
+ sb.append(" - ").append(msg);\r
+ return sb.toString();\r
+ }\r
+\r
+}\r