KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > tomcat > tc6 > deployers > TomcatDeployer


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
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.web.tomcat.tc6.deployers;
23
24 import java.io.File JavaDoc;
25 import java.net.URL JavaDoc;
26 import java.net.URLClassLoader JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.Properties JavaDoc;
30
31 import javax.management.Attribute JavaDoc;
32 import javax.management.MBeanServer JavaDoc;
33 import javax.management.Notification JavaDoc;
34 import javax.management.NotificationListener JavaDoc;
35 import javax.management.ObjectInstance JavaDoc;
36 import javax.management.ObjectName JavaDoc;
37 import javax.naming.InitialContext JavaDoc;
38 import javax.naming.NamingException JavaDoc;
39 import javax.security.jacc.PolicyContext JavaDoc;
40
41 import org.apache.catalina.Lifecycle;
42 import org.apache.catalina.connector.Connector;
43 import org.apache.tomcat.util.modeler.Registry;
44 import org.jboss.deployers.spi.deployer.DeploymentUnit;
45 import org.jboss.metadata.WebMetaData;
46 import org.jboss.mx.util.MBeanServerLocator;
47 import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
48 import org.jboss.system.server.Server;
49 import org.jboss.system.server.ServerImplMBean;
50 import org.jboss.virtual.VirtualFile;
51 import org.jboss.web.deployers.AbstractWarDeployer;
52 import org.jboss.web.deployers.AbstractWarDeployment;
53 import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
54 import org.jboss.web.tomcat.tc6.TomcatInjectionContainer;
55 import org.jboss.web.tomcat.tc6.session.SessionIDGenerator;
56
57
58 /**
59  * A concrete implementation of the AbstractWarDeployer that creates
60  * {@link #TomcatDeployment} instances as the web application bean
61  * representation.
62  *
63  * @see #getDeployment(DeploymentUnit, WebMetaData)
64  *
65  * @author Scott.Stark@jboss.org
66  * @author Costin Manolache
67  * @author Wonne.Keysers@realsoftware.be
68  * @author Dimitris.Andreadis@jboss.org
69  * @version $Revision: 56809 $
70  * @see org.jboss.web.deployers.AbstractWarDeployer
71  */

72 public class TomcatDeployer extends AbstractWarDeployer
73    implements NotificationListener JavaDoc, TomcatDeployerMBean
74 {
75    // Constants -----------------------------------------------------
76
public static final String JavaDoc NAME = "TomcatDeployer";
77
78    /**
79     * Default value for property <code>cacheName</code>. This name will be used by JBossCache exclusively
80     * for Tomcat clustering, e.g., session and sso replication.
81     */

82    public static final String JavaDoc DEFAULT_CACHE_NAME =
83       "jboss.cache:service=TomcatClusteringCache";
84
85    /** The web app context implementation class */
86    private String JavaDoc contextClassName =
87       "org.apache.catalina.core.StandardContext";
88
89    /**
90     * Configurable map of tomcat authenticators
91     * Keyed in by the http auth method that gets
92     * plugged into the Context Config and then into the StandardContext
93     */

94    private Properties JavaDoc authenticators = null;
95
96    /**
97     * Domain for tomcat6 mbeans
98     */

99    private String JavaDoc catalinaDomain = "Catalina";
100
101    /**
102     * ObjectName of a shared TreeCache used for clustered session replication
103     * and clustered single-sign-on
104     */

105    private String JavaDoc cacheName = DEFAULT_CACHE_NAME;
106
107    /**
108     * The fully qualified name of the class that will be used for session
109     * management if <tt>distributable</tt> is set to true.
110     */

111    protected String JavaDoc managerClass = "org.jboss.web.tomcat.tc6.session.JBossCacheManager";
112
113    /**
114     * With IntervalSnapshotManager use this interval (in ms)
115     * for snapshotting
116     */

117    private int snapshotInterval = 1000;
118
119    /**
120     * Which snapshot mode should be used in clustered environment?
121     * Default: instant
122     */

123    private String JavaDoc snapshotMode = "instant"; // instant or interval
124

125    /**
126     * Should the clustering code use a local cache for the sessions?
127     */

128    private boolean useLocalCache = true;
129
130    /**
131     * Whether we are using Apache MOD_JK(2) module or not
132     */

133    private boolean useJK = false;
134
135    /**
136     * A flag indicating if the JBoss Loader should be used
137     */

138    private boolean useJBossWebLoader = true;
139    
140    /**
141     * JBAS-3358: Work directory shouldn't be deleted on Context Destroy
142     */

143    private boolean deleteWorkDirOnContextDestroy = false;
144    
145    /**
146     * JBAS-2283: Provide custom header based auth support
147     */

148    private String JavaDoc httpHeaderForSSOAuth = null;
149    private String JavaDoc sessionCookieForSSOAuth = null;
150
151
152    /**
153     * The server xml configuration file name
154     */

155    private String JavaDoc serverConfigFile = "server.xml";
156
157    /**
158     * Get the request attribute name under which the JAAS Subject is store
159     */

160    private String JavaDoc subjectAttributeName = null;
161
162    /**
163     * Flag indicating whether web-app specific context xmls may set the privileged flag.
164     */

165    private boolean allowSelfPrivilegedWebApps = false;
166
167    /** The service used to flush authentication cache on session invalidation. */
168    private JaasSecurityManagerServiceMBean secMgrService;
169    
170    /** */
171    private String JavaDoc[] filteredPackages;
172
173    public TomcatDeployer()
174    {
175    }
176
177    public String JavaDoc getName()
178    {
179       return NAME;
180    }
181
182
183    public String JavaDoc getManagerClass()
184    {
185       return managerClass;
186    }
187
188    public void setManagerClass(String JavaDoc managerClass)
189    {
190       this.managerClass = managerClass;
191    }
192
193
194    public String JavaDoc getDomain()
195    {
196       return this.catalinaDomain;
197    }
198
199    public Properties JavaDoc getAuthenticators()
200    {
201       return this.authenticators;
202    }
203
204    public void setAuthenticators(Properties JavaDoc prop)
205    {
206       this.authenticators = prop;
207       log.debug("Passed set of authenticators=" + prop);
208    }
209
210    /**
211     * The most important atteribute - defines the managed domain.
212     * A catalina instance (engine) corresponds to a JMX domain, that's
213     * how we know where to deploy webapps.
214     *
215     * @param catalinaDomain the domain portion of the JMX ObjectNames
216     */

217    public void setDomain(String JavaDoc catalinaDomain)
218    {
219       this.catalinaDomain = catalinaDomain;
220    }
221
222    public void setContextMBeanCode(String JavaDoc className)
223    {
224       this.contextClassName = className;
225    }
226
227    public String JavaDoc getContextMBeanCode()
228    {
229       return contextClassName;
230    }
231
232    /**
233     * Set the snapshot interval in milliseconds for snapshot mode = interval
234     */

235    public void setSnapshotInterval(int interval)
236    {
237       this.snapshotInterval = interval;
238    }
239
240    /**
241     * Get the snapshot interval
242     */

243    public int getSnapshotInterval()
244    {
245       return this.snapshotInterval;
246    }
247
248    /**
249     * Set the snapshot mode. Currently supported: instant or interval
250     */

251    public void setSnapshotMode(String JavaDoc mode)
252    {
253       this.snapshotMode = mode;
254    }
255
256    /**
257     * Get the snapshot mode
258     */

259    public String JavaDoc getSnapshotMode()
260    {
261       return this.snapshotMode;
262    }
263
264    /**
265     * Gets the JMX object name of a shared TreeCache to be used for clustered
266     * single-sign-on.
267     *
268     * @see #DEFAULT_CACHE_NAME
269     * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
270     */

271    public String JavaDoc getCacheName()
272    {
273       return cacheName;
274    }
275
276    /**
277     * Gets the JMX object name of a shared TreeCache to be used for clustered
278     * single-sign-on.
279     * <p/>
280     * <b>NOTE:</b> TreeCache must be deployed before this service.
281     *
282     * @see #DEFAULT_CACHE_NAME
283     * @see org.jboss.web.tomcat.tc6.sso.TreeCacheSSOClusterManager
284     */

285    public void setCacheName(String JavaDoc cacheName)
286    {
287       this.cacheName = cacheName;
288    }
289
290    public boolean isUseLocalCache()
291    {
292       return useLocalCache;
293    }
294
295    public void setUseLocalCache(boolean useLocalCache)
296    {
297       this.useLocalCache = useLocalCache;
298    }
299
300    public boolean isUseJK()
301    {
302       return useJK;
303    }
304
305    public void setUseJK(boolean useJK)
306    {
307       this.useJK = useJK;
308    }
309
310    public boolean getDeleteWorkDirOnContextDestroy()
311    {
312       return deleteWorkDirOnContextDestroy;
313    }
314
315    public void setDeleteWorkDirOnContextDestroy(boolean deleteFlag)
316    {
317       this.deleteWorkDirOnContextDestroy = deleteFlag;
318    }
319    
320    public String JavaDoc getHttpHeaderForSSOAuth()
321    {
322       return httpHeaderForSSOAuth;
323    }
324     
325    public void setHttpHeaderForSSOAuth(String JavaDoc httpHeader)
326    {
327        this.httpHeaderForSSOAuth = httpHeader;
328    }
329    
330    public String JavaDoc getSessionCookieForSSOAuth()
331    {
332        return sessionCookieForSSOAuth;
333    }
334    
335    public void setSessionCookieForSSOAuth(String JavaDoc sessionC)
336    {
337       this.sessionCookieForSSOAuth = sessionC;
338    }
339    
340    /**
341     * The SessionIdAlphabet is the set of characters used to create a session Id
342     */

343    public void setSessionIdAlphabet(String JavaDoc sessionIdAlphabet)
344    {
345        SessionIDGenerator.getInstance().setSessionIdAlphabet(sessionIdAlphabet);
346    }
347
348    /**
349     * The SessionIdAlphabet is the set of characters used to create a session Id
350     */

351    public String JavaDoc getSessionIdAlphabet()
352    {
353        return SessionIDGenerator.getInstance().getSessionIdAlphabet();
354    }
355
356    public boolean getUseJBossWebLoader()
357    {
358       return useJBossWebLoader;
359    }
360
361    public void setUseJBossWebLoader(boolean flag)
362    {
363       this.useJBossWebLoader = flag;
364    }
365
366    public String JavaDoc getConfigFile()
367    {
368       return serverConfigFile;
369    }
370
371    public void setConfigFile(String JavaDoc configFile)
372    {
373       this.serverConfigFile = configFile;
374    }
375
376    public String JavaDoc getSubjectAttributeName()
377    {
378       return this.subjectAttributeName;
379    }
380
381    public void setSubjectAttributeName(String JavaDoc name)
382    {
383       this.subjectAttributeName = name;
384    }
385
386    public boolean isAllowSelfPrivilegedWebApps()
387    {
388       return allowSelfPrivilegedWebApps;
389    }
390
391    public void setAllowSelfPrivilegedWebApps(boolean allowSelfPrivilegedWebApps)
392    {
393       this.allowSelfPrivilegedWebApps = allowSelfPrivilegedWebApps;
394    }
395
396    public void setSecurityManagerService(JaasSecurityManagerServiceMBean mgr)
397    {
398       this.secMgrService = mgr;
399    }
400
401    public String JavaDoc[] getFilteredPackages()
402    {
403       return filteredPackages;
404    }
405    public void setFilteredPackages(String JavaDoc[] pkgs)
406    {
407       this.filteredPackages = pkgs;
408    }
409
410    /**
411     * Start the deployer. This sets up the tomcat core.
412     */

413    public void start()
414       throws Exception JavaDoc
415    {
416       super.start();
417
418       log.debug("Starting tomcat deployer");
419       MBeanServer JavaDoc server = super.getServer();
420       System.setProperty("catalina.ext.dirs",
421          (System.getProperty("jboss.server.home.dir")
422          + File.separator + "lib"));
423
424       String JavaDoc objectNameS = catalinaDomain + ":type=server";
425       ObjectName JavaDoc objectName = new ObjectName JavaDoc(objectNameS);
426
427       // Set the modeler Registry MBeanServer to the that of the tomcat service
428
Registry.getRegistry().setMBeanServer(server);
429
430       Registry.getRegistry().registerComponent(Class.forName("org.apache.catalina.startup.Catalina").newInstance(),
431               objectName, "org.apache.catalina.startup.Catalina");
432       /*
433       server.createMBean("org.apache.tomcat.util.modeler.BaseModelMBean",
434          objectName,
435          new Object[]{"org.apache.catalina.startup.Catalina"},
436          new String[]{"java.lang.String"});
437          */

438
439       server.setAttribute(objectName, new Attribute JavaDoc
440          ("catalinaHome",
441             System.getProperty("jboss.server.home.dir")));
442       server.setAttribute(objectName, new Attribute JavaDoc
443          ("configFile", serverConfigFile));
444       server.setAttribute(objectName, new Attribute JavaDoc
445          ("useNaming", new Boolean JavaDoc(false)));
446       server.setAttribute(objectName, new Attribute JavaDoc
447          ("useShutdownHook", new Boolean JavaDoc(false)));
448       server.setAttribute(objectName, new Attribute JavaDoc
449          ("await", new Boolean JavaDoc(false)));
450       server.setAttribute(objectName, new Attribute JavaDoc
451          ("redirectStreams", new Boolean JavaDoc(false)));
452
453       server.invoke(objectName, "create", new Object JavaDoc[]{},
454          new String JavaDoc[]{});
455
456       server.invoke(objectName, "start", new Object JavaDoc[]{},
457          new String JavaDoc[]{});
458
459       // Configure any SingleSignOn valves
460

461       ObjectName JavaDoc ssoQuery = new ObjectName JavaDoc(catalinaDomain + ":type=Valve,*");
462       Iterator JavaDoc iterator = server.queryMBeans(ssoQuery, null).iterator();
463       while (iterator.hasNext())
464       {
465          ObjectName JavaDoc ssoObjectName =
466             ((ObjectInstance JavaDoc) iterator.next()).getObjectName();
467          String JavaDoc name = ssoObjectName.getKeyProperty("name");
468
469          /* Ensure that the SingleSignOn valve requires that each
470             request be reauthenticated to the security mgr. Should not
471             be neccessary now that we cache the principal in the session.
472          if ((name != null) && (name.indexOf("SingleSignOn") >= 0))
473          {
474             log.info("Turning on reauthentication of each request on " +
475                      ssoObjectName);
476             server.setAttribute(ssoObjectName, new Attribute
477                ("requireReauthentication", Boolean.TRUE));
478          }
479          */

480
481          // If the valve is a ClusteredSingleSignOn and we have a shared
482
// TreeCache configured, configure the valve to use the shared one
483
if (cacheName != null && "ClusteredSingleSignOn".equals(name))
484          {
485             String JavaDoc tcName = (String JavaDoc) server.getAttribute(ssoObjectName,
486                "treeCacheName");
487             tcName = (tcName != null ? tcName : DEFAULT_CACHE_NAME);
488             ObjectName JavaDoc ssoCacheName = new ObjectName JavaDoc(tcName);
489             // Only override if the valve's cacheName property was not
490
// explicitly set in server.xml to a non-default value
491
if (ssoCacheName.equals(new ObjectName JavaDoc(DEFAULT_CACHE_NAME)))
492             {
493                log.info("Setting the cache name to " + cacheName +
494                   " on " + ssoObjectName);
495                server.setAttribute(ssoObjectName,
496                   new Attribute JavaDoc("treeCacheName", cacheName));
497             }
498          }
499       }
500       
501       //Set up the authenticators in JNDI such that they can be configured for web apps
502
InitialContext JavaDoc ic = new InitialContext JavaDoc();
503       try
504       {
505         ic.bind("TomcatAuthenticators", this.authenticators);
506       }
507       catch(NamingException JavaDoc ne)
508       {
509         if(log.isTraceEnabled())
510            log.trace("Binding Authenticators to JNDI failed",ne);
511       }
512       finally
513       {
514           try{ ic.close();}catch(NamingException JavaDoc nee){}
515       }
516
517       // Register the web container JACC PolicyContextHandlers
518
HttpServletRequestPolicyContextHandler handler = new HttpServletRequestPolicyContextHandler();
519       PolicyContext.registerHandler(HttpServletRequestPolicyContextHandler.WEB_REQUEST_KEY,
520          handler, true);
521
522       // If we are hot-deployed *after* the overall server is started
523
// we'll never receive Server.START_NOTIFICATION_TYPE, so check
524
// with the Server and start the connectors immediately, if this is the case.
525
// Otherwise register to receive the server start-up notification.
526
Boolean JavaDoc started = (Boolean JavaDoc)server.getAttribute(ServerImplMBean.OBJECT_NAME, "Started");
527       if (started.booleanValue() == true)
528       {
529          log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
530                "' already started, starting connectors now");
531
532          startConnectors();
533       }
534       else
535       {
536          // Register for notification of the overall server startup
537
log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
538                "' not started, registering for start-up notification");
539
540          server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
541       }
542    }
543
544
545    public void stop()
546       throws Exception JavaDoc
547    {
548       MBeanServer JavaDoc server = super.getServer();
549       String JavaDoc objectNameS = catalinaDomain + ":type=server";
550       ObjectName JavaDoc objectName = new ObjectName JavaDoc(objectNameS);
551
552       server.invoke(objectName, "stop", new Object JavaDoc[]{},
553          new String JavaDoc[]{});
554
555       server.invoke(objectName, "destroy", new Object JavaDoc[]{},
556          new String JavaDoc[]{});
557
558       server.unregisterMBean(objectName);
559
560       MBeanServer JavaDoc server2 = server;
561
562       // Unregister any remaining jboss.web or Catalina MBeans
563
ObjectName JavaDoc queryObjectName = new ObjectName JavaDoc
564          (catalinaDomain + ":*");
565       Iterator JavaDoc iterator =
566          server2.queryMBeans(queryObjectName, null).iterator();
567       while (iterator.hasNext())
568       {
569          ObjectInstance JavaDoc oi = (ObjectInstance JavaDoc) iterator.next();
570          ObjectName JavaDoc toRemove = oi.getObjectName();
571          // Exception: Don't unregister the service right now
572
if (!"WebServer".equals(toRemove.getKeyProperty("service")))
573          {
574             if (server2.isRegistered(toRemove))
575             {
576                server2.unregisterMBean(toRemove);
577             }
578          }
579       }
580       queryObjectName = new ObjectName JavaDoc("Catalina:*");
581       iterator = server2.queryMBeans(queryObjectName, null).iterator();
582       while (iterator.hasNext())
583       {
584          ObjectInstance JavaDoc oi = (ObjectInstance JavaDoc) iterator.next();
585          ObjectName JavaDoc name = oi.getObjectName();
586          server2.unregisterMBean(name);
587       }
588       super.stop();
589    }
590
591    /**
592     * Start the tomcat service connectors.
593     */

594    public void startConnectors() throws Exception JavaDoc
595    {
596       MBeanServer JavaDoc server = super.getServer();
597       ObjectName JavaDoc service = new ObjectName JavaDoc(catalinaDomain + ":type=Service,serviceName=jboss.web");
598       Object JavaDoc[] args = {};
599       String JavaDoc[] sig = {};
600       Connector[] connectors = (Connector[]) server.invoke(service,
601          "findConnectors", args, sig);
602       for (int n = 0; n < connectors.length; n++)
603       {
604          Lifecycle lc = (Lifecycle) connectors[n];
605          lc.start();
606       }
607       /* TODO:
608       // Notify listeners that connectors have started processing requests
609       sendNotification(new Notification(TOMCAT_CONNECTORS_STARTED,
610             this, getNextNotificationSequenceNumber()));
611       */

612    }
613
614    /**
615     * Stop the tomcat service connectors.
616     */

617    public void stopConnectors() throws Exception JavaDoc
618    {
619       MBeanServer JavaDoc server = super.getServer();
620       ObjectName JavaDoc service = new ObjectName JavaDoc(catalinaDomain + ":type=Service,serviceName=jboss.web");
621       Object JavaDoc[] args = {};
622       String JavaDoc[] sig = {};
623       Connector[] connectors = (Connector[]) server.invoke(service,
624          "findConnectors", args, sig);
625       for (int n = 0; n < connectors.length; n++)
626       {
627          Lifecycle lc = (Lifecycle) connectors[n];
628          lc.stop();
629       }
630    }
631
632    /**
633     * Used to receive notification of the server start msg so the tomcat
634     * connectors can be started after all web apps are deployed.
635     */

636    public void handleNotification(Notification JavaDoc msg, Object JavaDoc handback)
637    {
638       String JavaDoc type = msg.getType();
639       if (type.equals(Server.START_NOTIFICATION_TYPE))
640       {
641          log.debug("Saw " + type + " notification, starting connectors");
642          try
643          {
644             startConnectors();
645          }
646          catch (Exception JavaDoc e)
647          {
648             log.warn("Failed to startConnectors", e);
649          }
650       }
651    }
652
653    /**
654     * A trival extension of URLClassLoader that uses an empty URL[] as its
655     * classpath so that all work is delegated to its parent.
656     */

657    static class ENCLoader extends URLClassLoader JavaDoc
658    {
659       private boolean parentFirst;
660
661       ENCLoader(URL JavaDoc[] urls, ClassLoader JavaDoc parent, boolean parentFirst)
662       {
663          super(urls, parent);
664          this.parentFirst = parentFirst;
665       }
666
667       protected synchronized Class JavaDoc<?> loadClass(String JavaDoc name, boolean resolve) throws ClassNotFoundException JavaDoc
668       {
669          if (parentFirst) return super.loadClass(name, resolve);
670          try
671          {
672             Class JavaDoc clazz = findClass(name);
673             if (resolve) {
674                 resolveClass(clazz);
675             }
676             return clazz;
677          }
678          catch (ClassNotFoundException JavaDoc e)
679          {
680             return getParent().loadClass(name);
681          }
682       }
683
684    }
685
686    public static ClassLoader JavaDoc getTmpLoader(URL JavaDoc warURL, ClassLoader JavaDoc parent, boolean parentFirst) throws Exception JavaDoc
687    {
688
689       String JavaDoc path = warURL.getFile();
690       ArrayList JavaDoc<URL JavaDoc> list = new ArrayList JavaDoc<URL JavaDoc>();
691       File JavaDoc classesDir = new File JavaDoc(path, "WEB-INF/classes");
692       if (classesDir.exists())
693       {
694          list.add(classesDir.toURL());
695       }
696       File JavaDoc libDir = new File JavaDoc(path, "WEB-INF/lib");
697       if (libDir.exists())
698       {
699          File JavaDoc[] jars = libDir.listFiles();
700          int length = jars != null ? jars.length : 0;
701          for (int j = 0; j < length; j++)
702          {
703             File JavaDoc jar = jars[j];
704             if(jar.getAbsolutePath().endsWith(".jar"))
705             {
706                list.add(jar.toURL());
707             }
708          }
709       }
710       ENCLoader loader = new ENCLoader(list.toArray(new URL JavaDoc[list.size()]), parent, parentFirst);
711       return loader;
712
713    }
714
715    /**
716     * Create a tomcat war deployment bean for the deployment unit/metaData.
717     * @param unit - the current web app deployment unit
718     * @param metaData - the parsed metdata for the web app deployment
719     * @return TomcatDeployment instnace
720     */

721    @Override JavaDoc
722    public AbstractWarDeployment getDeployment(DeploymentUnit unit, WebMetaData metaData)
723       throws Exception JavaDoc
724    {
725       TomcatDeployment deployment = new TomcatDeployment();
726       DeployerConfig config = new DeployerConfig();
727       config.setDefaultSecurityDomain(this.defaultSecurityDomain);
728       config.setSubjectAttributeName(this.subjectAttributeName);
729       config.setServiceClassLoader(getClass().getClassLoader());
730       config.setManagerClass(this.managerClass);
731       config.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance);
732       config.setUnpackWars(this.unpackWars);
733       config.setLenientEjbLink(this.lenientEjbLink);
734       config.setCatalinaDomain(catalinaDomain);
735       config.setContextClassName(contextClassName);
736       config.setServiceName(null);
737       config.setSnapshotInterval(this.snapshotInterval);
738       config.setSnapshotMode(this.snapshotMode);
739       config.setUseLocalCache(this.useLocalCache);
740       config.setUseJK(this.useJK);
741       config.setSubjectAttributeName(this.subjectAttributeName);
742       config.setUseJBossWebLoader(this.useJBossWebLoader);
743       config.setAllowSelfPrivilegedWebApps(this.allowSelfPrivilegedWebApps);
744       config.setSecurityManagerService(this.secMgrService);
745       config.setFilteredPackages(filteredPackages);
746       
747       //Check if there are any xacml policy files
748
VirtualFile vf = unit.getMetaDataFile("jboss-xacml-policy.xml");
749       if(vf != null)
750         config.setXacmlPolicyURL(vf.toURL());
751       
752       deployment.setServer(super.getServer());
753       deployment.init(config);
754
755       return deployment;
756    }
757    
758    public void create() throws Exception JavaDoc
759    {
760       MBeanServer JavaDoc server = MBeanServerLocator.locateJBoss();
761       if (server != null)
762          server.registerMBean(this, OBJECT_NAME);
763    }
764
765    public void destroy() throws Exception JavaDoc
766    {
767       MBeanServer JavaDoc server = MBeanServerLocator.locateJBoss();
768       if (server != null)
769          server.unregisterMBean(OBJECT_NAME);
770    }
771 }
Popular Tags