1 22 package org.jboss.ejb.plugins.cmp.jdbc; 23 24 import org.jboss.deployment.DeploymentException; 25 import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCQueryMetaData; 26 import org.jboss.logging.Logger; 27 28 39 public class JDBCCommandFactory 40 { 41 42 private final Logger log; 43 private final JDBCStoreManager manager; 44 45 public JDBCCommandFactory(JDBCStoreManager manager) throws Exception 46 { 47 this.manager = manager; 48 49 log = Logger.getLogger( 50 this.getClass().getName() + 51 "." + 52 manager.getContainer().getBeanMetaData().getEjbName()); 53 } 54 55 public JDBCQueryCommand createFindByPrimaryKeyQuery(JDBCQueryMetaData q) 56 throws DeploymentException 57 { 58 return new JDBCFindByPrimaryKeyQuery(manager, q); 59 } 60 61 public JDBCQueryCommand createFindAllQuery(JDBCQueryMetaData q) throws DeploymentException 62 { 63 return new JDBCFindAllQuery(manager, q); 64 } 65 66 public JDBCQueryCommand createDeclaredSQLQuery(JDBCQueryMetaData q) 67 throws DeploymentException 68 { 69 return new JDBCDeclaredSQLQuery(manager, q); 70 } 71 72 public JDBCQueryCommand createEJBQLQuery(JDBCQueryMetaData q) 73 throws DeploymentException 74 { 75 return new JDBCEJBQLQuery(manager, q); 76 } 77 78 public JDBCQueryCommand createDynamicQLQuery(JDBCQueryMetaData q) 79 throws DeploymentException 80 { 81 return new JDBCDynamicQLQuery(manager, q); 82 } 83 84 public JDBCQueryCommand createJBossQLQuery(JDBCQueryMetaData q) 85 throws DeploymentException 86 { 87 return new JDBCJBossQLQuery(manager, q); 88 } 89 90 public JDBCQueryCommand createFindByQuery(JDBCQueryMetaData q) 91 throws DeploymentException 92 { 93 return new JDBCFindByQuery(manager, q); 94 } 95 96 public JDBCLoadRelationCommand createLoadRelationCommand() 97 { 98 return new JDBCLoadRelationCommand(manager); 99 } 100 101 public JDBCDeleteRelationsCommand createDeleteRelationsCommand() 102 { 103 return new JDBCDeleteRelationsCommand(manager); 104 } 105 106 public JDBCInsertRelationsCommand createInsertRelationsCommand() 107 { 108 return new JDBCInsertRelationsCommand(manager); 109 } 110 111 113 public JDBCInitCommand createInitCommand() 114 { 115 return new JDBCInitCommand(manager); 116 } 117 118 public JDBCStartCommand createStartCommand() 119 { 120 return new JDBCStartCommand(manager); 121 } 122 123 public JDBCStopCommand createStopCommand() 124 { 125 return new JDBCStopCommand(manager); 126 } 127 128 public JDBCDestroyCommand createDestroyCommand() 129 { 130 return new JDBCDestroyCommand(manager); 131 } 132 133 135 public JDBCCreateBeanClassInstanceCommand 136 createCreateBeanClassInstanceCommand() throws Exception 137 { 138 139 return new JDBCCreateBeanClassInstanceCommand(manager); 140 } 141 142 public JDBCInitEntityCommand createInitEntityCommand() 143 { 144 return new JDBCInitEntityCommand(manager); 145 } 146 147 public JDBCFindEntityCommand createFindEntityCommand() 148 { 149 return new JDBCFindEntityCommand(manager); 150 } 151 152 public JDBCFindEntitiesCommand createFindEntitiesCommand() 153 { 154 return new JDBCFindEntitiesCommand(manager); 155 } 156 157 public JDBCCreateCommand createCreateEntityCommand() 158 throws DeploymentException 159 { 160 161 JDBCCreateCommand cec; 162 try 163 { 164 cec = (JDBCCreateCommand)manager.getMetaData(). 165 getEntityCommand().getCommandClass().newInstance(); 166 cec.init(manager); 167 } 168 catch(DeploymentException de) 169 { 170 throw de; 171 } 172 catch(Exception e) 173 { 174 throw new DeploymentException("Couldn't create entity command: ", e); 175 } 176 177 if(log.isDebugEnabled()) 178 log.debug("entity-command: " + manager.getMetaData().getEntityCommand()); 179 180 return cec; 181 } 182 183 184 public JDBCPostCreateEntityCommand createPostCreateEntityCommand() 185 { 186 187 return new JDBCPostCreateEntityCommand(manager); 188 189 } 190 191 192 public JDBCRemoveEntityCommand createRemoveEntityCommand() 193 throws DeploymentException 194 { 195 return new JDBCRemoveEntityCommand(manager); 196 } 197 198 public JDBCLoadEntityCommand createLoadEntityCommand() throws DeploymentException 199 { 200 return new JDBCLoadEntityCommand(manager); 201 } 202 203 public JDBCIsModifiedCommand createIsModifiedCommand() 204 { 205 return new JDBCIsModifiedCommand(manager); 206 } 207 208 public JDBCStoreEntityCommand createStoreEntityCommand() 209 { 210 return new JDBCStoreEntityCommand(manager); 211 } 212 213 public JDBCActivateEntityCommand createActivateEntityCommand() 215 { 216 return new JDBCActivateEntityCommand(manager); 217 } 218 219 public JDBCPassivateEntityCommand createPassivateEntityCommand() 220 { 221 return new JDBCPassivateEntityCommand(manager); 222 } 223 } 224 | Popular Tags |