KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > AbstractDCBFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.share.configbean;
20
21 import javax.enterprise.deploy.spi.DConfigBean JavaDoc;
22 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
23 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
24 import javax.enterprise.deploy.model.DDBean JavaDoc;
25 import javax.enterprise.deploy.model.DDBeanRoot JavaDoc;
26 import javax.enterprise.deploy.model.DeployableObject JavaDoc;
27 import javax.enterprise.deploy.model.J2eeApplicationObject JavaDoc;
28
29 import org.netbeans.modules.j2ee.sun.share.Constants;
30
31
32 /**
33  *
34  * @author Peter Williams
35  * @author Vince Kraemer
36  */

37 public abstract class AbstractDCBFactory implements DCBFactory, Constants {
38     
39     abstract protected Class JavaDoc getClass(DDBean JavaDoc ddBean, Base dcbParent) throws ConfigurationException JavaDoc;
40
41     public Base createDCB(DDBean JavaDoc ddBean, Base dcbParent) throws ConfigurationException JavaDoc {
42         Class JavaDoc dcbClass = getClass(ddBean, dcbParent);
43 // System.out.println(this.getClass().getName()+"('" + dcbClass.getName() + "': createDCB");
44
// System.out.println(" dDBean.getXpath()=="+ddBean.getXpath());
45
// System.out.println(" .getText()=="+((ddBean.getText() != null) ? ddBean.getText() : "(null)"));
46
// System.out.println(" Parent DCB: "+ dcbParent.getClass().getName());
47

48         Base newDCB = null;
49 // Throwable cause = null;
50

51         try {
52             newDCB = (Base) dcbClass.newInstance();
53             newDCB.init(ddBean, dcbParent);
54         } catch(InstantiationException JavaDoc ex) {
55             Object JavaDoc [] args = new Object JavaDoc [1];
56             args[0] = dcbClass.getName();
57             throw Utils.makeCE("ERR_UnexpectedInstantiateException", args, ex); // NOI18N
58
} catch(IllegalAccessException JavaDoc ex) {
59             Object JavaDoc [] args = new Object JavaDoc [1];
60             args[0] = dcbClass.getName();
61             throw Utils.makeCE("ERR_UnexpectedIllegalAccessException", args, ex); // NOI18N
62
} catch (RuntimeException JavaDoc ex) {
63             throw Utils.makeCE("ERR_UnexpectedRuntimeException", null, ex); // NOI18N
64
}
65         
66 // if (null == newDCB) {
67
// try {
68
// //getErrorClass().
69
// newDCB = new Error();
70
// newDCB.init(ddBean, dcbParent);
71
// } catch (Throwable t) {
72
// String message = "Could not instantiate the error class bean: Error";
73
// jsr88Logger.severe(message);
74
// throw new ConfigurationException(message);
75
// }
76
// } else {
77
// if (null != cause)
78
// jsr88Logger.throwing("a","b",cause);
79
// }
80

81         return newDCB;
82     }
83 }
84
Popular Tags