Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[JBWS-3524]:Resolve system property references in jboss-webservices.xml

  • Loading branch information...
commit 6ed7df1f8d1341afeb3a934d16f3dbe2d6e448cd 1 parent 1a0e0b5
maerqiang maerqiang authored stuartwdouglas committed
7 ...tion/src/main/java/org/jboss/as/webservices/deployers/JBossWebservicesDescriptorDeploymentProcessor.java
@@ -26,15 +26,16 @@
26 26 import java.io.IOException;
27 27 import java.net.URL;
28 28
  29 +import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement;
29 30 import org.jboss.as.server.deployment.Attachments;
30 31 import org.jboss.as.server.deployment.DeploymentPhaseContext;
31 32 import org.jboss.as.server.deployment.DeploymentUnit;
32 33 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
33 34 import org.jboss.as.server.deployment.DeploymentUnitProcessor;
34 35 import org.jboss.as.server.deployment.module.ResourceRoot;
  36 +import org.jboss.as.webservices.metadata.JBossWebservicesPropertyReplaceFactory;
35 37 import org.jboss.as.webservices.util.WSAttachmentKeys;
36 38 import org.jboss.vfs.VirtualFile;
37   -import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesFactory;
38 39 import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
39 40
40 41 /**
@@ -50,7 +51,9 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
50 51 final URL jbossWebservicesDescriptorURL = getJBossWebServicesDescriptorURL(deploymentRoot);
51 52
52 53 if (jbossWebservicesDescriptorURL != null) {
53   - final JBossWebservicesMetaData jbossWebservicesMD = JBossWebservicesFactory.load(jbossWebservicesDescriptorURL);
  54 + final JBossWebservicesPropertyReplaceFactory webservicesFactory = new JBossWebservicesPropertyReplaceFactory(
  55 + jbossWebservicesDescriptorURL, JBossDescriptorPropertyReplacement.propertyReplacer(unit));
  56 + final JBossWebservicesMetaData jbossWebservicesMD = webservicesFactory.load(jbossWebservicesDescriptorURL);
54 57 unit.putAttachment(WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY, jbossWebservicesMD);
55 58 }
56 59 }
7 ...tegration/src/main/java/org/jboss/as/webservices/deployers/WebservicesDescriptorDeploymentProcessor.java
@@ -26,15 +26,16 @@
26 26 import java.io.IOException;
27 27 import java.net.URL;
28 28
  29 +import org.jboss.as.ee.structure.JBossDescriptorPropertyReplacement;
29 30 import org.jboss.as.server.deployment.Attachments;
30 31 import org.jboss.as.server.deployment.DeploymentPhaseContext;
31 32 import org.jboss.as.server.deployment.DeploymentUnit;
32 33 import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
33 34 import org.jboss.as.server.deployment.DeploymentUnitProcessor;
34 35 import org.jboss.as.server.deployment.module.ResourceRoot;
  36 +import org.jboss.as.webservices.metadata.WebservicesPropertyReplaceFactory;
35 37 import org.jboss.as.webservices.util.WSAttachmentKeys;
36 38 import org.jboss.vfs.VirtualFile;
37   -import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
38 39 import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
39 40
40 41 /**
@@ -51,7 +52,9 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
51 52 final URL webservicesDescriptorURL = getWebServicesDescriptorURL(deploymentRoot);
52 53
53 54 if (webservicesDescriptorURL != null) {
54   - final WebservicesMetaData webservicesMD = WebservicesFactory.load(webservicesDescriptorURL);
  55 + final WebservicesPropertyReplaceFactory webservicesFactory = new WebservicesPropertyReplaceFactory(
  56 + webservicesDescriptorURL, JBossDescriptorPropertyReplacement.propertyReplacer(unit));
  57 + final WebservicesMetaData webservicesMD = webservicesFactory.load(webservicesDescriptorURL);
55 58 unit.putAttachment(WSAttachmentKeys.WEBSERVICES_METADATA_KEY, webservicesMD);
56 59 }
57 60 }
56 ...-integration/src/main/java/org/jboss/as/webservices/metadata/JBossWebservicesPropertyReplaceFactory.java
... ... @@ -0,0 +1,56 @@
  1 +/*
  2 + * JBoss, Home of Professional Open Source.
  3 + * Copyright 2013, Red Hat Middleware LLC, and individual contributors
  4 + * as indicated by the @author tags. See the copyright.txt file in the
  5 + * distribution for a 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.as.webservices.metadata;
  23 +
  24 +import static org.jboss.wsf.spi.util.StAXUtils.elementAsString;
  25 +
  26 +import java.net.URL;
  27 +
  28 +import javax.xml.stream.XMLStreamException;
  29 +import javax.xml.stream.XMLStreamReader;
  30 +
  31 +import org.jboss.metadata.property.PropertyReplacer;
  32 +import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesFactory;
  33 +
  34 +/**
  35 + * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
  36 + */
  37 +public class JBossWebservicesPropertyReplaceFactory extends JBossWebservicesFactory {
  38 +
  39 + private PropertyReplacer replacer;
  40 +
  41 +
  42 + public JBossWebservicesPropertyReplaceFactory(final URL descriptorURL, final PropertyReplacer propertyReplacer) {
  43 + super(descriptorURL);
  44 + replacer = propertyReplacer;
  45 + }
  46 +
  47 + @Override
  48 + public String getElementText(XMLStreamReader reader) throws XMLStreamException {
  49 + String res = elementAsString(reader);
  50 + if (res != null && replacer != null) {
  51 + res = replacer.replaceProperties(res);
  52 + }
  53 + return res;
  54 + }
  55 +
  56 +}
56 ...erver-integration/src/main/java/org/jboss/as/webservices/metadata/WebservicesPropertyReplaceFactory.java
... ... @@ -0,0 +1,56 @@
  1 +/*
  2 + * JBoss, Home of Professional Open Source.
  3 + * Copyright 2013, Red Hat Middleware LLC, and individual contributors
  4 + * as indicated by the @author tags. See the copyright.txt file in the
  5 + * distribution for a 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.as.webservices.metadata;
  23 +
  24 +import static org.jboss.wsf.spi.util.StAXUtils.elementAsString;
  25 +
  26 +import java.net.URL;
  27 +
  28 +import javax.xml.stream.XMLStreamException;
  29 +import javax.xml.stream.XMLStreamReader;
  30 +
  31 +import org.jboss.metadata.property.PropertyReplacer;
  32 +import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
  33 +
  34 +/**
  35 + * @author <a href="mailto:ema@redhat.com">Jim Ma</a>
  36 + */
  37 +public class WebservicesPropertyReplaceFactory extends WebservicesFactory {
  38 +
  39 + private PropertyReplacer replacer;
  40 +
  41 +
  42 + public WebservicesPropertyReplaceFactory(final URL descriptorURL, final PropertyReplacer propertyReplacer) {
  43 + super(descriptorURL);
  44 + replacer = propertyReplacer;
  45 + }
  46 +
  47 + @Override
  48 + public String getElementText(XMLStreamReader reader) throws XMLStreamException {
  49 + String res = elementAsString(reader);
  50 + if (res != null && replacer != null) {
  51 + res = replacer.replaceProperties(res);
  52 + }
  53 + return res;
  54 + }
  55 +
  56 +}

0 comments on commit 6ed7df1

Please sign in to comment.
Something went wrong with that request. Please try again.