| Method from org.jboss.deployment.XSLSubDeployer Detail: |
public boolean accepts(DeploymentInfo di) {
String urlStr = di.url.toString();
return (packageSuffix != null && (urlStr.endsWith(packageSuffix) || urlStr.endsWith(packageSuffix + "/")))
|| (ddSuffix != null && urlStr.endsWith(ddSuffix));
}
|
public void create(DeploymentInfo di) throws DeploymentException {
delegate.create(di);
}
|
protected void createService() throws Exception {
super.createService();
delegate = (SubDeployer) MBeanProxyExt.create(SubDeployer.class, delegateName, server);
TransformerFactory tf = TransformerFactory.newInstance();
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(validateDTDs);
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(xslUrl);
StreamSource ss = new StreamSource(is);
templates = tf.newTemplates(ss);
log.debug("Created templates: " + templates);
}
|
public void destroy(DeploymentInfo di) throws DeploymentException {
delegate.destroy(di);
}
|
protected void destroyService() throws Exception {
templates = null;
super.destroyService();
}
|
protected void findDd(DeploymentInfo di) throws DeploymentException {
try
{
DocumentBuilder db = dbf.newDocumentBuilder();
String urlStr = di.url.toString();
String shortURL = ServerConfigUtil.shortUrlFromServerHome(urlStr);
JBossEntityResolver resolver = new JBossEntityResolver();
db.setEntityResolver(resolver);
db.setErrorHandler(new JBossErrorHandler(shortURL, resolver));
if (ddSuffix != null && urlStr.endsWith(ddSuffix))
di.document = db.parse(di.url.openStream());
}
catch (SAXException se)
{
throw new DeploymentException("Could not parse dd", se);
}
catch (IOException ioe)
{
throw new DeploymentException("Could not read dd", ioe);
}
catch (ParserConfigurationException pce)
{
throw new DeploymentException("Could not create document builder for dd", pce);
}
}
|
public String getDdSuffix() {
return ddSuffix;
}
|
public ObjectName getDelegateName() {
return delegateName;
}
|
public String getPackageSuffix() {
return packageSuffix;
}
|
public boolean getValidateDTDs() {
return validateDTDs;
}
|
public String getXslUrl() {
return xslUrl;
}
|
public void init(DeploymentInfo di) throws DeploymentException {
if (di.document == null)
findDd(di);
try
{
Transformer trans = templates.newTransformer();
String urlStr = di.url.toString();
String shortURL = ServerConfigUtil.shortUrlFromServerHome(urlStr);
trans.setErrorListener(new JBossErrorHandler(shortURL, null));
Source s = new DOMSource(di.document);
DOMResult r = new DOMResult();
setParameters(trans);
trans.transform(s, r);
di.document = (Document) r.getNode();
if (log.isDebugEnabled())
{
log.debug("transformed into doc: " + di.document);
String docStr = DOMWriter.printNode(di.document, true);
int index = docStr.toLowerCase().indexOf("password");
if (index != -1)
{
docStr = maskPasswords(docStr, index);
}
log.debug("transformed into doc: " + docStr);
}
}
catch (TransformerException ce)
{
throw new DeploymentException("Problem with xsl transformation", ce);
}
delegate.init(di);
}
|
public void setDdSuffix(String ddSuffix) {
this.ddSuffix = ddSuffix;
}
|
public void setDelegateName(ObjectName delegateName) {
this.delegateName = delegateName;
}
|
public void setPackageSuffix(String packageSuffix) {
this.packageSuffix = packageSuffix;
}
|
protected void setParameters(Transformer trans) throws TransformerException {
//override to set document names etc.
}
|
public void setValidateDTDs(boolean validate) {
this.validateDTDs = validate;
}
|
public void setXslUrl(String xslUrl) {
this.xslUrl = xslUrl;
}
|
public void start(DeploymentInfo di) throws DeploymentException {
delegate.start(di);
}
|
public void stop(DeploymentInfo di) throws DeploymentException {
delegate.stop(di);
}
|