--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.services.monitor.ProtocolKey\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.error.StandardException;\r
+import org.apache.derby.iapi.services.monitor.Monitor;\r
+\r
+\r
+/**\r
+ A class that represents a key for a module search.\r
+*/\r
+\r
+\r
+class ProtocolKey {\r
+\r
+ /*\r
+ ** Fields.\r
+ */\r
+\r
+ /**\r
+ The class of the factory\r
+ */\r
+ protected Class factoryInterface;\r
+\r
+ /**\r
+ name of module, can be null\r
+ */\r
+ protected String identifier;\r
+\r
+ /*\r
+ ** Constructor\r
+ */\r
+\r
+ protected ProtocolKey(Class factoryInterface, String identifier)\r
+ {\r
+ super();\r
+ this.factoryInterface = factoryInterface;\r
+ this.identifier = identifier;\r
+ }\r
+\r
+ static ProtocolKey create(String className, String identifier) throws StandardException {\r
+\r
+ Throwable t;\r
+ try {\r
+ return new ProtocolKey(Class.forName(className), identifier);\r
+ //Added by Jeff Huang\r
+ //TODO: FIXIT\r
+\r
+ } catch (ClassNotFoundException cnfe) {\r
+ t = cnfe;\r
+ } catch (IllegalArgumentException iae) {\r
+ t = iae;\r
+ }\r
+\r
+ throw Monitor.exceptionStartingModule(t); \r
+ }\r
+\r
+ /*\r
+ ** Methods required to use this key\r
+ */\r
+\r
+ protected Class getFactoryInterface() {\r
+ return factoryInterface;\r
+ }\r
+\r
+ protected String getIdentifier() {\r
+ return identifier;\r
+ }\r
+\r
+ /*\r
+ **\r
+ */\r
+\r
+ public int hashCode() {\r
+ return factoryInterface.hashCode() +\r
+ (identifier == null ? 0 : identifier.hashCode());\r
+ }\r
+\r
+ public boolean equals(Object other) {\r
+ if (other instanceof ProtocolKey) {\r
+ ProtocolKey otherKey = (ProtocolKey) other;\r
+\r
+ if (factoryInterface != otherKey.factoryInterface)\r
+ return false;\r
+\r
+ if (identifier == null) {\r
+ if (otherKey.identifier != null)\r
+ return false;\r
+ } else {\r
+\r
+ if (otherKey.identifier == null)\r
+ return false;\r
+\r
+ if (!identifier.equals(otherKey.identifier))\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public String toString() {\r
+\r
+ return factoryInterface.getName() + " (" + identifier + ")";\r
+ }\r
+}\r