1 21 22 package org.opensubsystems.core.persist.db; 23 24 import java.util.List ; 25 26 import org.opensubsystems.core.error.OSSDynamicClassException; 27 import org.opensubsystems.core.error.OSSException; 28 import org.opensubsystems.core.persist.DataFactory; 29 import org.opensubsystems.core.util.ClassFactory; 30 import org.opensubsystems.core.util.GlobalConstants; 31 32 43 public class DatabaseFactoryClassFactory extends ClassFactory 44 { 45 48 protected void verifyInstance( 49 Object objInstance 50 ) throws OSSException 51 { 52 if ((objInstance != null) && (!(objInstance instanceof DataFactory)) 55 && (!(objInstance instanceof DatabaseFactory))) 56 { 57 throw new OSSDynamicClassException("Instantiated class " + 58 " doesn't implements DataFactory" + 59 " and DatabaseFactory" + 60 " interface and is of type " + 61 objInstance.getClass().getName()); 62 63 } 64 } 65 66 69 protected void createDefaultClassNames( 70 String strClassIdentifier, 71 String strModifier, 72 List lstClassNames 73 ) throws OSSException 74 { 75 int iIndex; 76 int iIndex2; 77 StringBuffer sbClassName = new StringBuffer (); 78 79 81 iIndex = strClassIdentifier.lastIndexOf('.'); 83 iIndex2 = strClassIdentifier.lastIndexOf("Factory"); 85 if (GlobalConstants.ERROR_CHECKING) 86 { 87 assert iIndex2 != -1 88 : "The factory class identifier is expected to end with name Factory"; 89 } 90 if (iIndex2 != -1) 92 { 93 sbClassName.append(strClassIdentifier.substring(0, iIndex + 1)); 95 sbClassName.append("db."); 96 sbClassName.append(strClassIdentifier.substring(iIndex + 1, iIndex2)); 97 sbClassName.append("DatabaseFactory"); 98 lstClassNames.add(sbClassName.toString()); 99 } 100 } 101 } 102
| Popular Tags
|