KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > containers > builder > BaseContainerBuilder


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.ejb.containers.builder;
25
26 import java.lang.reflect.Method JavaDoc;
27
28 import java.net.InetAddress JavaDoc;
29
30 import java.util.logging.Logger JavaDoc;
31 import java.util.logging.Level JavaDoc;
32
33 import com.sun.ejb.spi.sfsb.initialization.PersistenceStrategyBuilder;
34 import com.sun.ejb.spi.sfsb.initialization.SFSBContainerInitialization;
35 import com.sun.ejb.spi.sfsb.util.CheckpointPolicy;
36
37 import com.sun.ejb.base.container.util.CacheProperties;
38
39 import com.sun.ejb.base.sfsb.util.CheckpointPolicyImpl;
40 import com.sun.ejb.base.sfsb.util.ScrambledKeyGenerator;
41 import com.sun.ejb.base.sfsb.util.SimpleKeyGenerator;
42
43 import com.sun.ejb.containers.BaseContainer;
44 import com.sun.ejb.containers.StatefulSessionContainer;
45
46 import com.sun.enterprise.config.ConfigContext;
47
48 import com.sun.enterprise.deployment.EjbDescriptor;
49 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
50
51 import com.sun.enterprise.SecurityManager;
52 import com.sun.enterprise.util.Utility;
53
54 import com.sun.logging.LogDomains;
55
56 /**
57  * (Abstract)Base class for all ContainerBuilders
58  *
59  * @author Mahesh Kannan
60  */

61 public abstract class BaseContainerBuilder {
62
63     protected static Logger JavaDoc _logger =
64     LogDomains.getLogger(LogDomains.EJB_LOGGER);
65
66     protected EjbDescriptor ejbDescriptor;
67     protected ClassLoader JavaDoc loader;
68     protected BaseContainer baseContainer;
69
70     //Following two variables are used for constructing SFSBUUIDUtil
71
private byte[] ipAddress;
72     private int port;
73
74     public BaseContainerBuilder() {
75     }
76
77     public final void buildContainer(EjbDescriptor ejbDescriptor,
78         ClassLoader JavaDoc loader, ConfigContext dynamicConfigContext)
79     throws Exception JavaDoc
80     {
81     this.ejbDescriptor = ejbDescriptor;
82     this.loader = loader;
83
84     readDescriptor();
85
86     baseContainer = createContainer(ejbDescriptor, loader); //abstract method
87
buildComponents(dynamicConfigContext); //abstract method
88
}
89     
90     public final BaseContainer getContainer() {
91     return baseContainer;
92     }
93
94     //Currently not called from ContainerFactoryImpl.
95
public final void postInitialize(SecurityManager JavaDoc sm) {
96     //baseContainer.setSecurityManager(sm);
97

98     boolean hasHome = !(ejbDescriptor instanceof EjbMessageBeanDescriptor);
99     if (hasHome) {
100         //Currently BaseContainer.initializeHome is protected.
101
//baseContainer.initializeHome();
102
}
103     }
104
105     ///////////////// Protected methods /////////////////
106

107     protected abstract BaseContainer createContainer(
108         EjbDescriptor ejbDescriptor, ClassLoader JavaDoc loader)
109     throws Exception JavaDoc;
110
111     protected abstract void buildComponents(ConfigContext dynamicConfigContext)
112     throws Exception JavaDoc;
113
114     protected byte[] getIPAddress() {
115     return this.ipAddress;
116     }
117
118     protected int getPort() {
119     return this.port;
120     }
121
122     ////////////////// Private methods //////////////////
123

124     private void readDescriptor() {
125     //FIXME: Read from domain.xml iiop-service ip-addr
126
this.ipAddress = new byte[4];
127     try {
128         this.ipAddress = InetAddress.getLocalHost().getAddress();
129     } catch (Exception JavaDoc ex) {
130         long val = System.identityHashCode(ipAddress)
131         + System.currentTimeMillis();
132         Utility.longToBytes(val, this.ipAddress, 0);
133     }
134
135     //FIXME: Read from domain.xml
136
this.port = 8080;
137     }
138
139 }
140
Popular Tags