KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > deployment > ds > DsSubDeployer


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.resource.deployment.ds;
23
24 import java.net.URL JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27
28 import org.jboss.deployment.DeploymentException;
29 import org.jboss.deployment.DeploymentInfo;
30 import org.jboss.deployment.ObjectModelFactorySimpleSubDeployerSupport;
31 import org.jboss.deployment.SARDeployerMBean;
32 import org.jboss.deployment.SubDeployer;
33 import org.jboss.mx.util.MBeanProxyExt;
34 import org.jboss.resource.deployment.ds.builder.DsMetaDataBuilder;
35 import org.jboss.resource.deployment.ds.builder.DsMetaDataBuilderFactory;
36 import org.jboss.xb.binding.ObjectModelFactory;
37
38 /**
39  * A DsSubDeployer.
40  *
41  * @author <a HREF="weston.price@jboss.com">Weston Price</a>
42  * @version $Revision: 45634 $
43  */

44 public class DsSubDeployer extends ObjectModelFactorySimpleSubDeployerSupport implements DsSubDeployerMBean
45 {
46
47    /** The delegateName */
48    protected ObjectName JavaDoc delegateName = SARDeployerMBean.OBJECT_NAME;
49
50    /** The packageSuffix */
51    protected String JavaDoc packageSuffix;
52
53    /** The ddSuffix */
54    protected String JavaDoc ddSuffix;
55
56    /** The delegate */
57    protected SubDeployer delegate;
58
59    /** The validateDtds */
60    private boolean validateDtds;
61    
62    private String JavaDoc builderName;
63    
64    private DsMetaDataBuilder builder = DsMetaDataBuilderFactory.getBuilder("");
65    
66    /**
67     * Create a new DsSubDeployer.
68     *
69     */

70    public DsSubDeployer()
71    {
72
73    }
74
75    public ObjectModelFactory getObjectModelFactory()
76    {
77       return new DsObjectModelFactory();
78    }
79
80    public String JavaDoc getExtension()
81    {
82       return null;
83    }
84
85    public String JavaDoc getMetaDataURL()
86    {
87       return null;
88    }
89
90    public String JavaDoc getObjectName(DeploymentInfo di) throws DeploymentException
91    {
92       return null;
93    }
94
95    public String JavaDoc getDeploymentClass()
96    {
97       return null;
98    }
99
100    public String JavaDoc getDdSuffix()
101    {
102       return ddSuffix;
103    }
104
105    public ObjectName JavaDoc getDelegateName()
106    {
107
108       return delegateName;
109
110    }
111
112    public String JavaDoc getPackageSuffix()
113    {
114       return packageSuffix;
115    }
116
117    public boolean getValidateDTDs()
118    {
119
120       return validateDtds;
121    }
122
123    public void setDdSuffix(String JavaDoc ddSuffix)
124    {
125
126       this.ddSuffix = ddSuffix;
127    }
128
129    public void setDelegateName(ObjectName JavaDoc delegateName)
130    {
131
132       this.delegateName = delegateName;
133    }
134
135    public void setPackageSuffix(String JavaDoc packageSuffix)
136    {
137
138       this.packageSuffix = packageSuffix;
139    }
140
141    public void setValidateDTDs(boolean validate)
142    {
143
144       this.validateDtds = validate;
145
146    }
147    
148    protected void parseMetaData(DeploymentInfo di, URL JavaDoc url) throws DeploymentException
149    {
150       try
151       {
152          di.metaData = builder.parse(url);
153       }
154       
155       catch (DsDeployerException e)
156       {
157          throw new DeploymentException(e.getMessage(), e);
158          
159       }
160       
161       
162    }
163
164    protected void startService() throws Exception JavaDoc
165    {
166       
167       builder = DsMetaDataBuilderFactory.getBuilder(builderName);
168       
169    
170    }
171
172    protected void createService() throws Exception JavaDoc
173    {
174
175       super.createService();
176
177       delegate = (SubDeployer) MBeanProxyExt.create(SubDeployer.class, delegateName, server);
178
179    }
180
181    protected void destroyService() throws Exception JavaDoc
182    {
183       super.destroyService();
184    }
185
186    public boolean accepts(DeploymentInfo di)
187    {
188
189       String JavaDoc urlStr = di.url.toString();
190       return (packageSuffix != null && (urlStr.endsWith(packageSuffix) || urlStr.endsWith(packageSuffix + "/")))
191             || (ddSuffix != null && urlStr.endsWith(ddSuffix));
192    }
193
194    public String JavaDoc getBuilderName()
195    {
196       return builderName;
197    }
198
199    public void setBuilderName(String JavaDoc builderName)
200    {
201       this.builderName = builderName;
202    }
203 }
204
Popular Tags