-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7224 from asoldano/JBWS-3846
- Loading branch information
Showing
12 changed files
with
367 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
...s/server-integration/src/main/java/org/jboss/as/webservices/deployers/ConfigResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2015, Red Hat, Inc., 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.as.webservices.deployers; | ||
|
||
import java.io.IOException; | ||
import java.lang.annotation.Annotation; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.List; | ||
|
||
import org.jboss.jandex.AnnotationInstance; | ||
import org.jboss.jandex.AnnotationValue; | ||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.metadata.javaee.spec.ParamValueMetaData; | ||
import org.jboss.metadata.web.jboss.JBossWebMetaData; | ||
import org.jboss.vfs.VirtualFile; | ||
import org.jboss.ws.api.annotation.EndpointConfig; | ||
import org.jboss.ws.common.configuration.AbstractCommonConfigResolver; | ||
import org.jboss.ws.common.integration.WSConstants; | ||
import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData; | ||
|
||
public class ConfigResolver extends AbstractCommonConfigResolver { | ||
|
||
private final ClassInfo epClassInfo; | ||
private final String className; | ||
private final String annotationConfigName; | ||
private final String annotationConfigFile; | ||
private final String descriptorConfigName; | ||
private final String descriptorConfigFile; | ||
private final VirtualFile root; | ||
private final boolean isWar; | ||
|
||
public ConfigResolver(ClassInfo epClassInfo, JBossWebservicesMetaData jwmd, JBossWebMetaData jbwebmd, VirtualFile root, boolean isWar) { | ||
this.epClassInfo = epClassInfo; | ||
this.className = epClassInfo.name().toString(); | ||
List<AnnotationInstance> annotations = epClassInfo.annotations().get( | ||
DotName.createSimple(EndpointConfig.class.getName())); | ||
if (annotations != null && !annotations.isEmpty()) { | ||
AnnotationInstance ann = annotations.get(0); | ||
AnnotationValue av = ann.value("configName"); | ||
this.annotationConfigName = av != null ? av.asString() : null; | ||
av = ann.value("configFile"); | ||
this.annotationConfigFile = av != null ? av.asString() : null; | ||
} else { | ||
this.annotationConfigName = null; | ||
this.annotationConfigFile = null; | ||
} | ||
String f = null; | ||
String n = null; | ||
if (jbwebmd != null && jbwebmd.getContextParams() != null) { | ||
for (ParamValueMetaData pvmd : jbwebmd.getContextParams()) { | ||
if (WSConstants.JBOSSWS_CONFIG_NAME.equals(pvmd.getParamName())) { | ||
n = pvmd.getParamValue(); | ||
} | ||
if (WSConstants.JBOSSWS_CONFIG_FILE.equals(pvmd.getParamName())) { | ||
f = pvmd.getParamValue(); | ||
} | ||
} | ||
} | ||
this.descriptorConfigFile = f != null ? f : (jwmd != null ? jwmd.getConfigFile() : null); | ||
this.descriptorConfigName = n != null ? n : (jwmd != null ? jwmd.getConfigName() : null); | ||
this.root = root; | ||
this.isWar = isWar; | ||
} | ||
|
||
@Override | ||
protected String getEndpointClassName() { | ||
return className; | ||
} | ||
|
||
@Override | ||
protected <T extends Annotation> boolean isEndpointClassAnnotated(Class<T> annotation) { | ||
return epClassInfo.annotations().containsKey(DotName.createSimple(annotation.getName())); | ||
} | ||
|
||
@Override | ||
protected String getEndpointConfigNameFromAnnotation() { | ||
return annotationConfigName; | ||
} | ||
|
||
@Override | ||
protected String getEndpointConfigFileFromAnnotation() { | ||
return annotationConfigFile; | ||
} | ||
|
||
@Override | ||
protected String getEndpointConfigNameOverride() { | ||
return descriptorConfigName; | ||
} | ||
|
||
@Override | ||
protected String getEndpointConfigFileOverride() { | ||
return descriptorConfigFile; | ||
} | ||
|
||
@Override | ||
protected URL getConfigFile(String configFileName) throws IOException { | ||
return root.getChild(configFileName).asFileURL(); | ||
} | ||
|
||
@Override | ||
protected URL getDefaultConfigFile(String defaultConfigFileName) { | ||
URL url = null; | ||
if (isWar) { | ||
url = asFileURL(root.getChild("/WEB-INF/classes/" + defaultConfigFileName)); | ||
} | ||
if (url == null) { | ||
url = asFileURL(root.getChild("/" + defaultConfigFileName)); | ||
} | ||
return url; | ||
} | ||
|
||
private URL asFileURL(VirtualFile vf) { | ||
URL url = null; | ||
if (vf != null && vf.exists()) { | ||
try { | ||
url = vf.asFileURL(); | ||
} catch (MalformedURLException e) { | ||
// ignore | ||
} | ||
} | ||
return url; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...integration/src/main/java/org/jboss/as/webservices/deployers/WSEndpointConfigMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2015, Red Hat, Inc., 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.as.webservices.deployers; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.jboss.wsf.spi.metadata.config.EndpointConfig; | ||
|
||
/** | ||
* Defines mapping of endpoints and their config. | ||
* | ||
* @author <a href="mailto:alessio.soldano@jboss.com">Alessio Soldano</a> | ||
*/ | ||
public final class WSEndpointConfigMapping { | ||
|
||
private final Map<String, EndpointConfig> endpointConfigMap = new HashMap<String, EndpointConfig>(); | ||
|
||
/** | ||
* Registers endpoint and its config. | ||
* | ||
* @param endpointClass WS endpoint | ||
* @param config Config with endpoint | ||
*/ | ||
public void registerEndpointConfig(final String endpointClass, final EndpointConfig config) { | ||
if ((endpointClass == null) || (config == null)) { | ||
throw new IllegalArgumentException(); | ||
} | ||
endpointConfigMap.put(endpointClass, config); | ||
} | ||
|
||
/** | ||
* Returns config associated with WS endpoint. | ||
* | ||
* @param endpointClass to get associated config | ||
* @return associated config | ||
*/ | ||
public EndpointConfig getConfig(final String endpointClass) { | ||
return endpointConfigMap.get(endpointClass); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return endpointConfigMap.size() == 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.