KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > embedded > EJB3StandaloneDeployment


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.embedded;
23
24 import java.util.Iterator JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.security.jacc.PolicyConfiguration JavaDoc;
28 import javax.management.MBeanServer JavaDoc;
29 import org.jboss.ejb3.DependencyPolicy;
30 import org.jboss.ejb3.DeploymentUnit;
31 import org.jboss.ejb3.service.ServiceContainer;
32 import org.jboss.ejb3.Container;
33 import org.jboss.ejb3.Ejb3Deployment;
34 import org.jboss.ejb3.MCDependencyPolicy;
35 import org.jboss.ejb3.MCKernelAbstraction;
36 import org.jboss.ejb3.security.JaccHelper;
37 import org.jboss.kernel.Kernel;
38
39 /**
40  * Use this class when you want to manually specify classes you want deployed.
41  *
42  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
43  * @version $Revision: 46098 $
44  */

45 public class EJB3StandaloneDeployment extends Ejb3Deployment
46 {
47    public EJB3StandaloneDeployment(DeploymentUnit di, Kernel kernel, MBeanServer JavaDoc mbeanServer)
48    {
49       super(di, null);
50    
51       defaultSFSBDomain = "Embedded Stateful Bean";
52       kernelAbstraction = new MCKernelAbstraction(kernel, mbeanServer);
53       this.mbeanServer = mbeanServer;
54    }
55    
56    public void setMbeanServer(MBeanServer JavaDoc mbeanServer)
57    {
58       super.setMbeanServer(mbeanServer);
59       
60       kernelAbstraction.setMbeanServer(mbeanServer);
61    }
62
63    protected void putJaccInService(PolicyConfiguration JavaDoc pc, DeploymentUnit unit)
64    {
65       /*
66       try
67       {
68          pc.commit();
69       }
70       catch (Exception e)
71       {
72          throw new RuntimeException(e);
73       }\
74       */

75    }
76
77    protected PolicyConfiguration JavaDoc createPolicyConfiguration() throws Exception JavaDoc
78    {
79       return JaccHelper.initialiseJacc(getJaccContextId());
80    }
81
82 /*
83    protected Map getDefaultPersistenceProperties()
84    {
85       try
86       {
87          Properties hb = new Properties();
88          InputStream hbstream = di.getResourceLoader().getResourceAsStream("default.persistence.properties");
89          hb.load(hbstream);
90          hbstream.close();
91          return hb;
92       }
93       catch (IOException e)
94       {
95          throw new RuntimeException(e);
96       }
97    }
98
99
100    @Override
101    protected void registerContainer(Container container) throws Exception
102    {
103       super.registerContainer(container);
104       container.create();
105    }
106
107    @Override
108    public void start() throws Exception
109    {
110       try
111       {
112       super.start();
113       ArrayList<Container> serviceBeans = new ArrayList<Container>();
114       Iterator it = containers.keySet().iterator();
115       while (it.hasNext())
116       {
117          ObjectName on = (ObjectName) it.next();
118          Container con = (Container) containers.get(on);
119          if (con instanceof ServiceManager || con instanceof ServiceContainer)
120          {
121             serviceBeans.add(con);
122          }
123          else
124          {
125             con.start();
126          }
127       }
128       for (Container con : serviceBeans)
129       {
130          con.start();
131       }
132       } catch (Exception e)
133       {
134          e.printStackTrace();
135          throw e;
136       }
137    }
138
139
140    @Override
141    public void stop() throws Exception
142    {
143       Iterator it = containers.keySet().iterator();
144       while (it.hasNext())
145       {
146          ObjectName on = (ObjectName) it.next();
147          Container con = (Container) containers.get(on);
148          con.stop();
149       }
150       super.stop();
151    }
152
153    @Override
154    public void destroy() throws Exception
155    {
156       super.destroy();
157
158       Iterator it = containers.keySet().iterator();
159       while (it.hasNext())
160       {
161          ObjectName on = (ObjectName) it.next();
162          Container con = (Container) containers.get(on);
163          con.destroy();
164       }
165    }
166
167    protected void startEntityManagerDeployment()
168    {
169       if (entityDeployment != null)
170       {
171          try
172          {
173             entityDeployment.start();
174          }
175          catch (Exception e)
176          {
177             throw new RuntimeException(e);
178          }
179       }
180    }
181
182    protected void stopEntityManagerDeployment()
183    {
184       if (entityDeployment != null)
185       {
186          try
187          {
188             entityDeployment.stop();
189          }
190          catch (Exception e)
191          {
192             throw new RuntimeException(e);
193          }
194       }
195    }
196
197 */

198
199    public DependencyPolicy createDependencyPolicy()
200    {
201       return new MCDependencyPolicy();
202    }
203    
204 // @Override
205
// public void start() throws Exception
206
// {
207
// System.err.println("EJB3StandaloneDeployment.start");
208
// super.start();
209
// for(Object o : ejbContainers.values())
210
// {
211
// Container con = (Container) o;
212
// if(con instanceof ServiceContainer)
213
// con.start();
214
// }
215
// }
216
}
217
Popular Tags