1 15 16 package com.jdon.bussinessproxy.target; 17 18 19 import com.jdon.bussinessproxy.TargetMetaDef; 20 import com.jdon.servicelocator.web.ServiceLocator; 21 import com.jdon.util.Debug; 22 23 29 30 public class DefaultTargetServiceFactory implements TargetServiceFactory { 31 32 private final static String module = DefaultTargetServiceFactory.class.getName(); 33 34 private EJBObjectFactory eJBObjectFactory ; 35 private POJOObjectFactory pOJOObjectFactory; 36 37 38 public DefaultTargetServiceFactory(POJOObjectFactory pOJOObjectFactory) { 39 this.pOJOObjectFactory = pOJOObjectFactory; 40 } 41 42 private void initEJBObjectFactory(){ 43 try { 44 ServiceLocator serviceLocator = new ServiceLocator(); 45 this.eJBObjectFactory = new EJBObjectFactory(serviceLocator); 46 } catch (Exception e) { 47 Debug.logError("[JdonFramework] EJBObjectFactory init error: " +e , module); 48 } 49 } 50 51 public Object create(TargetMetaDef targetMetaDef) { 52 Object o = null; 53 try{ 54 if (targetMetaDef.isEJB()) { 55 if (eJBObjectFactory == null) 56 initEJBObjectFactory(); 57 o = eJBObjectFactory.create(targetMetaDef); 58 }else{ 59 o = pOJOObjectFactory.create(targetMetaDef); 60 } 61 }catch(Exception ex){ 62 Debug.logError("[JdonFramework]create error: " + ex, module); 63 } 64 return o; 65 } 66 67 68 public Object destroy(TargetMetaDef targetMetaDef) { 69 return null; 70 } 71 72 73 } 74 | Popular Tags |