KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > deployment > jboss > GenericDeployer


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.deployment.jboss;
10
11 import org.jboss.deployment.DeploymentException;
12 import org.jboss.deployment.DeploymentInfo;
13 import org.jboss.deployment.SubDeployerSupport;
14
15 /**
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.3 $
18  */

19 public class GenericDeployer
20    extends SubDeployerSupport
21    implements GenericDeployerMBean
22 {
23
24    /** . */
25    private String JavaDoc[] acceptedSuffixes;
26
27    /** . */
28    private ServerDeployerMBean serverDeployer;
29
30    public ServerDeployerMBean getServerDeployer()
31    {
32       return serverDeployer;
33    }
34
35    public void setServerDeployer(ServerDeployerMBean serverDeployer)
36    {
37       this.serverDeployer = serverDeployer;
38    }
39
40    public String JavaDoc[] getAcceptedSuffixes()
41    {
42       return acceptedSuffixes;
43    }
44
45    public void setAcceptedSuffixes(String JavaDoc[] acceptedSuffixes)
46    {
47       this.acceptedSuffixes = acceptedSuffixes;
48    }
49
50    public boolean accepts(DeploymentInfo di)
51    {
52       String JavaDoc urlStr = di.url.toString();
53       for (int i = 0;i < acceptedSuffixes.length;i++)
54       {
55          String JavaDoc suffix = acceptedSuffixes[i];
56          if (urlStr.endsWith(suffix))
57          {
58             return true;
59          }
60       }
61       return false;
62    }
63
64    public void init(DeploymentInfo di) throws DeploymentException
65    {
66
67       DeploymentFactory factory = serverDeployer.findFactory(di.url);
68       if (factory == null)
69       {
70          // Warn
71
}
72       else
73       {
74          Deployment deployment = factory.newInstance(serverDeployer.getServetManager(), di.url, null, null);
75          di.metaData = deployment;
76       }
77    }
78
79    public void create(DeploymentInfo di) throws DeploymentException
80    {
81       ((Deployment)di.metaData).create();
82    }
83
84    public void start(DeploymentInfo di) throws DeploymentException
85    {
86       ((Deployment)di.metaData).start();
87    }
88
89    public void stop(DeploymentInfo di) throws DeploymentException
90    {
91       ((Deployment)di.metaData).stop();
92    }
93
94    public void destroy(DeploymentInfo di) throws DeploymentException
95    {
96       ((Deployment)di.metaData).destroy();
97    }
98 }
99
Popular Tags