KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > bussinessproxy > target > DefaultTargetServiceFactory


1 /**
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6
7  http://www.apache.org/licenses/LICENSE-2.0
8
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

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 /**
24  * Factory that create target service object
25  *
26  *
27  * @author banq
28  */

29
30 public class DefaultTargetServiceFactory implements TargetServiceFactory {
31
32     private final static String JavaDoc 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 JavaDoc e) {
47             Debug.logError("[JdonFramework] EJBObjectFactory init error: " +e , module);
48         }
49     }
50     
51     public Object JavaDoc create(TargetMetaDef targetMetaDef) {
52         Object JavaDoc 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 JavaDoc ex){
62             Debug.logError("[JdonFramework]create error: " + ex, module);
63         }
64         return o;
65     }
66         
67     
68     public Object JavaDoc destroy(TargetMetaDef targetMetaDef) {
69         return null;
70     }
71     
72
73 }
74
Popular Tags