jbossws.diff ./modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 46,47d45 < import org.jboss.wsf.stack.cxf.deployment.WSDLDefinitionJndiUrlFilter; < import org.jboss.wsf.stack.cxf.deployment.WSDLDefinitionFilterManager; 136,140d133 < // providing a filter to customize information in the wsdl. < WSDLDefinitionFilterManager defMgr = new WSDLDefinitionFilterManager(); < defMgr.addDefinitionFilter(new WSDLDefinitionJndiUrlFilter()); < holder.getBus().setExtension(defMgr, org.apache.cxf.wsdl11.WSDLDefinitionFilter.class); < 145d137 < ./modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/WSDLDefinitionFilterManager.java +/* + * JBoss, Home of Professional Open Source. + * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.wsf.stack.cxf.deployment; + +import org.apache.cxf.wsdl11.WSDLDefinitionFilter; + +import javax.wsdl.Definition; +import java.util.ArrayList; +import java.util.List; + +/** + * User: rsearls + * Date: 6/17/14 + */ +public class WSDLDefinitionFilterManager implements org.apache.cxf.wsdl11.WSDLDefinitionFilter { + + private List filterList = new ArrayList(); + + public void addDefinitionFilter(WSDLDefinitionFilter defFilter) { + if (defFilter != null) { + filterList.add(defFilter); + } + } + + public void removeDefinitionFilter(WSDLDefinitionFilter defFilter) { + if (defFilter != null) { + filterList.remove(defFilter); + } + } + + @Override + public void execute(Definition def) { + for (WSDLDefinitionFilter filter : filterList) { + filter.execute(def); + } + } +} + ./modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/WSDLDefinitionJndiUrlFilter.java +/* + * JBoss, Home of Professional Open Source. + * Copyright 2013, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.wsf.stack.cxf.deployment; + +import com.ibm.wsdl.ServiceImpl; +import org.apache.cxf.common.util.StringUtils; +import org.apache.cxf.transport.jms.wsdl.JndiURLType; +import org.apache.cxf.wsdl11.WSDLDefinitionFilter; + +import javax.wsdl.Definition; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * + * User: rsearls + * Date: 6/17/14 + */ +public class WSDLDefinitionJndiUrlFilter implements WSDLDefinitionFilter { + private final String DELIMITER = "@"; + + @Override + public void execute(Definition def) { + + if (def != null) { + Map servicesMap = def.getServices(); + ArrayList extList = new ArrayList(); + // collect all extended service elements to be evaluated. + for (ServiceImpl s : (Collection)servicesMap.values()) { + List sList = s.getExtensibilityElements(); + if (sList != null){ + extList.addAll(sList); + } + } + + // Evaluate all JndiURL elements and replace value as appropriate. + for (Object obj : extList) { + if (obj != null && obj instanceof JndiURLType) { + String value = ((JndiURLType) obj).getValue(); + int startIndx = value.indexOf(DELIMITER); + int endIndx = value.lastIndexOf(DELIMITER); + if (startIndx > -1 && endIndx > -1 && startIndx+1 < endIndx){ + String propName = value.substring(startIndx+1, endIndx); + if(!StringUtils.isEmpty(propName)){ + // get user's value from the system. + String envValue = System.getProperty(propName); + if(!StringUtils.isEmpty(envValue)){ + String srcStr = value.substring(startIndx, endIndx+1); + ((JndiURLType) obj).setValue(value.replace(srcStr, envValue)); + } + } + } + } + } + } + } +} cxf.patch diff --git a/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionFilter.java b/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionFilter.java new file mode 100644 index 0000000..b666d55 --- /dev/null +++ b/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionFilter.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.wsdl11; + +import javax.wsdl.Definition; + +/** + * Allow CXF consumer to post process the wsdl file after CXF reads it. + * + * User: rsearls + * Date: 6/17/14 + */ +public interface WSDLDefinitionFilter { + void execute(Definition def); +} diff --git a/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java b/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java index e294429..745897c 100644 --- a/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java +++ b/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java @@ -262,7 +262,13 @@ public class WSDLManagerImpl implements WSDLManager { } else { def = reader.readWSDL(wsdlLocator); } - + + // allow cxf consumer to customize wsdl. + WSDLDefinitionFilter defFilter = bus.getExtension(WSDLDefinitionFilter.class); + if (defFilter != null) { + defFilter.execute(def); + } + synchronized (definitionsMap) { definitionsMap.put(url, def); }