KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.jdon.bussinessproxy.TargetMetaDef;
19 import com.jdon.container.ContainerWrapper;
20 import com.jdon.container.finder.ContainerCallback;
21 import com.jdon.util.Debug;
22
23 /**
24  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
25  *
26  */

27 public class POJOObjectFactory {
28     private final static String JavaDoc module = POJOObjectFactory.class.getName();
29
30     private ContainerCallback containerCallback;
31     
32     /**
33      * @param containerCallback
34      */

35     public POJOObjectFactory(ContainerCallback containerCallback) {
36         super();
37         this.containerCallback = containerCallback;
38     }
39     
40     public Object JavaDoc create(TargetMetaDef targetMetaDef) throws Exception JavaDoc {
41         Object JavaDoc o = null;
42         try{
43             Debug.logVerbose("[JdonFramework] create new pojo Object for " + targetMetaDef.getName(), module);
44             ContainerWrapper containerWrapper = containerCallback.getContainerWrapper();
45             o = containerWrapper.getComponentNewInstance(targetMetaDef.getName());
46             Debug.logVerbose("[JdonFramework] create new pojo Object id " + o.hashCode(), module);
47         }catch(Exception JavaDoc ex){
48             Debug.logError("[JdonFramework]create error: " + ex, module);
49             throw new Exception JavaDoc(ex);
50         }catch(Throwable JavaDoc tw){
51             Debug.logError("[JdonFramework]create error: " + tw, module);
52             throw new Exception JavaDoc(tw);
53         }
54         return o; }
55
56
57 }
58
Popular Tags