Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / services / monitor / ModuleInstance.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java
new file mode 100644 (file)
index 0000000..33c282e
--- /dev/null
@@ -0,0 +1,114 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.services.monitor.ModuleInstance\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.services.monitor;\r
+\r
+import org.apache.derby.iapi.services.monitor.PersistentService;\r
+\r
+import java.util.Properties;\r
+\r
+/**\r
+       A description of an instance of a module.\r
+*/\r
+\r
+\r
+class ModuleInstance {\r
+\r
+       /*\r
+       ** Fields.\r
+       */\r
+\r
+       /**\r
+               The module instance\r
+       */\r
+       protected Object instance;\r
+\r
+       /**\r
+               name of module, can be null\r
+       */\r
+       protected String                identifier;\r
+\r
+       /**\r
+               the top-level service this module lives in, can be null or the service itself\r
+       */\r
+       protected Object        topLevelService;\r
+\r
+       /**\r
+               the actual service to which I belong, could be null.\r
+       */\r
+       protected Object        service;\r
+\r
+       /*\r
+       ** Constructor\r
+       */\r
+\r
+       protected ModuleInstance(Object instance, String identifier,\r
+                       Object service, Object topLevelService)\r
+       {\r
+               super();\r
+               this.instance = instance;\r
+               this.identifier = identifier;\r
+               this.topLevelService = topLevelService;\r
+               this.service = service;\r
+\r
+       }\r
+\r
+       protected ModuleInstance(Object instance) {\r
+\r
+               this(instance, null, null, null);\r
+       }\r
+\r
+       protected boolean isTypeAndName(PersistentService serviceType, \r
+               Class factoryInterface, String otherCanonicalName)\r
+       {\r
+               // see if the correct interface is implemented\r
+               if (!factoryInterface.isInstance(instance))\r
+                       return false;\r
+\r
+               if ((serviceType != null) && (otherCanonicalName != null))\r
+                       return serviceType.isSameService(identifier, otherCanonicalName);\r
+\r
+\r
+               // see if the identifiers match\r
+               if (otherCanonicalName != null) {\r
+                       if (identifier == null)\r
+                               return false;\r
+                       if (!otherCanonicalName.equals(identifier))\r
+                               return false;\r
+               } else if (identifier != null) {\r
+                       return false;\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
+       protected String getIdentifier() {\r
+               return identifier;\r
+       }\r
+\r
+       protected Object getTopLevelService() {\r
+               return topLevelService;\r
+       }\r
+\r
+       protected Object getInstance() {\r
+               return instance;\r
+       }\r
+}\r