PolicyConfigParserpublic final class PolicyConfigParser extends Object Reads a policy configuration file and returns the WSDL model generated from it. |
Fields Summary |
---|
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger | LOGGER | private static final String | SERVLET_CONTEXT_CLASSNAME | private static final String | JAR_PREFIX | private static final String | WAR_PREFIX |
Methods Summary |
---|
public static com.sun.xml.ws.policy.PolicyMap | extractPolicyMap(com.sun.xml.ws.api.model.wsdl.WSDLModel model)Utility method that tries to retrieve a {@link PolicyMap} object from a given
{@link WSDLModel}. When succesfull, {@link PolicyMap} instance is returned,
otherwise result is {@code null}.
LOGGER.entering(model);
PolicyMap result = null;
try {
if (model != null) {
final WSDLPolicyMapWrapper wrapper = model.getExtension(WSDLPolicyMapWrapper.class);
if (wrapper != null) {
result = wrapper.getPolicyMap();
}
}
return result;
} finally {
LOGGER.exiting(result);
}
| public static com.sun.xml.ws.policy.PolicyMap | parse(java.lang.String configFileIdentifier, com.sun.xml.ws.api.server.Container container, com.sun.xml.ws.policy.PolicyMapMutator mutators)This is a helper method that returns directly {@link PolicyMap} instance populated
from information in WSIT config file. For more details on the whole process see
{@link #parseModel(String, Container, PolicyMapMutator[]) parseModel}
method.
LOGGER.entering(configFileIdentifier, container, mutators);
PolicyMap map = null;
try {
return map = extractPolicyMap(parseModel(configFileIdentifier, container, mutators));
} finally {
LOGGER.exiting(map);
}
| public static com.sun.xml.ws.policy.PolicyMap | parse(java.net.URL configFileUrl, boolean isClient, com.sun.xml.ws.policy.PolicyMapMutator mutators)This is a helper method that returns directly {@link PolicyMap} instance populated
from information in WSIT config file. For more details on the whole process see
{@link #parseModel(URL, boolean, PolicyMapMutator[]) parseModel}
method.
LOGGER.entering(configFileUrl, isClient, mutators);
PolicyMap map = null;
try {
return map = extractPolicyMap(parseModel(configFileUrl, isClient, mutators));
} finally {
LOGGER.exiting(map);
}
| public static com.sun.xml.ws.api.model.wsdl.WSDLModel | parseModel(java.lang.String configFileIdentifier, com.sun.xml.ws.api.server.Container container, com.sun.xml.ws.policy.PolicyMapMutator mutators)The function uses {@code configFileIdentifier} parameter to construct a WSIT config
file name according to following pattern:
wsit-[configFileIdentifier].xml
After constructing the WSIT config file name, the function tries to find the WSIT
config file and read it from the following locations:
- {@code WEB-INF} - for servlet-based web service implementations
- {@code META-INF} - for EJB-based web service implementations
- {@code classpath} - for web service clients
If the file is found it is parsed and resulting {@link WSDLModel} object containig the
populated {@link PolicyMap} instance is returned. If config file is not found, warning
message is logged and {@code null} is returned as a result of this function call. In case
of any other problems that may occur while reading the WSIT config file, a
{@link PolicyException} is thrown.
Since {@link PolicyMap} object is immutable as such, this function gives you also a chance
to register your own {@link PolicyMapMutator} objects so that you are able to modify the
{@link PolicyMap} object later if needed.
LOGGER.entering(configFileIdentifier, container, mutators);
WSDLModel model = null;
try {
final String configFileName = PolicyUtils.ConfigFile.generateFullName(configFileIdentifier);
LOGGER.finest(LocalizationMessages.WSP_1037_CONFIG_FILE_IS(configFileName));
Object context = null;
if (container != null) {
try {
final Class<?> contextClass = Class.forName(SERVLET_CONTEXT_CLASSNAME);
context = container.getSPI(contextClass);
} catch (ClassNotFoundException e) {
LOGGER.fine(LocalizationMessages.WSP_1043_CAN_NOT_FIND_CLASS(SERVLET_CONTEXT_CLASSNAME));
}
LOGGER.finest(LocalizationMessages.WSP_1036_CONTEXT_IS(context));
}
URL configFileUrl = null;
final boolean isClientConfig = PolicyConstants.CLIENT_CONFIGURATION_IDENTIFIER.equals(configFileIdentifier);
String examinedPath;
if (context == null || isClientConfig) {
examinedPath = JAR_PREFIX + configFileName;
configFileUrl = PolicyUtils.ConfigFile.loadFromClasspath(examinedPath);
if (configFileUrl == null && isClientConfig) {
examinedPath = examinedPath + File.pathSeparator + " " + configFileName;
configFileUrl = PolicyUtils.ConfigFile.loadFromClasspath(configFileName);
}
} else {
examinedPath = WAR_PREFIX + configFileName;
configFileUrl = PolicyUtils.ConfigFile.loadFromContext(examinedPath, context);
}
if (configFileUrl == null) {
LOGGER.config(LocalizationMessages.WSP_1035_COULD_NOT_LOCATE_WSIT_CFG_FILE(configFileIdentifier, examinedPath));
} else {
model = parseModel(configFileUrl, isClientConfig, mutators);
LOGGER.info(LocalizationMessages.WSP_1049_LOADED_WSIT_CFG_FILE(configFileUrl.toExternalForm()));
}
return model;
} finally {
LOGGER.exiting(model);
}
| public static com.sun.xml.ws.api.model.wsdl.WSDLModel | parseModel(java.net.URL configFileUrl, boolean isClient, com.sun.xml.ws.policy.PolicyMapMutator mutators)Reads the WSIT config from a file denoted by {@code configFileUrl} parameter.
If the file exists it is parsed and resulting {@link WSDLModel} object containig the
populated {@link PolicyMap} instance is returned. If config file for given {@link URL}
does not exist or in case of any other problems that may occur while reading the
WSIT config file, a {@link PolicyException} is thrown.
LOGGER.entering(configFileUrl, isClient, mutators);
WSDLModel model = null;
try {
if (null == configFileUrl) {
throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_1028_FAILED_TO_READ_NULL_WSIT_CFG()));
}
final SDDocumentSource doc = SDDocumentSource.create(configFileUrl);
final XMLEntityResolver.Parser parser = new XMLEntityResolver.Parser(doc);
model = WSDLModel.WSDLParser.parse(
parser,
new PolicyConfigResolver(),
isClient,
new WSDLParserExtension[] { new PolicyWSDLParserExtension(true, mutators) }
);
return model;
} catch (XMLStreamException ex) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_1002_WSIT_CFG_FILE_PROCESSING_FAILED(configFileUrl.toString()), ex));
} catch (IOException ex) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_1002_WSIT_CFG_FILE_PROCESSING_FAILED(configFileUrl.toString()), ex));
} catch (SAXException ex) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_1002_WSIT_CFG_FILE_PROCESSING_FAILED(configFileUrl.toString()), ex));
} finally {
LOGGER.exiting(model);
}
|
|