Java源码示例:com.sun.tools.internal.ws.resources.WscompileMessages
示例1
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例2
/**
* Parses a token to a file (or a set of files)
* and add them as {@link InputSource} to the specified list.
*
* @param suffix If the given token is a directory name, we do a recusive search
* and find all files that have the given suffix.
*/
private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException {
Object src;
try {
src = Util.getFileOrURL(name);
} catch (IOException e) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_NOT_A_FILE_NOR_URL(name));
}
if (src instanceof URL) {
target.add(absolutize(new InputSource(Util.escapeSpace(((URL) src).toExternalForm()))));
} else {
File fsrc = (File) src;
if (fsrc.isDirectory()) {
addRecursive(fsrc, suffix, target);
} else {
target.add(absolutize(fileToInputSource(fsrc)));
}
}
}
示例3
public void validate() throws BadCommandLineException {
if(nonclassDestDir == null)
nonclassDestDir = destDir;
if (!protocols.contains(protocol)) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INVALID_PROTOCOL(protocol, protocols));
}
if (endpoints.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_MISSING_FILE());
}
if (protocol == null || protocol.equalsIgnoreCase(X_SOAP12) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_SOAP_12_WITHOUT_EXTENSION());
}
if (nonstdProtocols.containsKey(protocol) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_PROTOCOL_WITHOUT_EXTENSION(protocol));
}
if (inlineSchemas && !genWsdl) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INLINE_SCHEMAS_ONLY_WITH_WSDL());
}
validateEndpointClass();
validateArguments();
}
示例4
public void validate() throws BadCommandLineException {
if(nonclassDestDir == null)
nonclassDestDir = destDir;
if (!protocols.contains(protocol)) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INVALID_PROTOCOL(protocol, protocols));
}
if (endpoints.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_MISSING_FILE());
}
if (protocol == null || protocol.equalsIgnoreCase(X_SOAP12) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_SOAP_12_WITHOUT_EXTENSION());
}
if (nonstdProtocols.containsKey(protocol) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_PROTOCOL_WITHOUT_EXTENSION(protocol));
}
if (inlineSchemas && !genWsdl) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INLINE_SCHEMAS_ONLY_WITH_WSDL());
}
validateEndpointClass();
validateArguments();
}
示例5
List<String> getJavacOptions(List<String> existingOptions, WsimportListener listener) {
List<String> result = new ArrayList<String>();
for (String o: javacOptions) {
if (o.contains("=") && !o.startsWith("A")) {
int i = o.indexOf('=');
String key = o.substring(0, i);
if (existingOptions.contains(key)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(key));
} else {
result.add(key);
result.add(o.substring(i + 1));
}
} else {
if (existingOptions.contains(o)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(o));
} else {
result.add(o);
}
}
}
return result;
}
示例6
List<String> getJavacOptions(List<String> existingOptions, WsimportListener listener) {
List<String> result = new ArrayList<String>();
for (String o: javacOptions) {
if (o.contains("=") && !o.startsWith("A")) {
int i = o.indexOf('=');
String key = o.substring(0, i);
if (existingOptions.contains(key)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(key));
} else {
result.add(key);
result.add(o.substring(i + 1));
}
} else {
if (existingOptions.contains(o)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(o));
} else {
result.add(o);
}
}
}
return result;
}
示例7
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例8
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例9
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例10
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例11
/**
* Parses a token to a file (or a set of files)
* and add them as {@link InputSource} to the specified list.
*
* @param suffix If the given token is a directory name, we do a recusive search
* and find all files that have the given suffix.
*/
private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException {
Object src;
try {
src = Util.getFileOrURL(name);
} catch (IOException e) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_NOT_A_FILE_NOR_URL(name));
}
if (src instanceof URL) {
target.add(absolutize(new InputSource(Util.escapeSpace(((URL) src).toExternalForm()))));
} else {
File fsrc = (File) src;
if (fsrc.isDirectory()) {
addRecursive(fsrc, suffix, target);
} else {
target.add(absolutize(fileToInputSource(fsrc)));
}
}
}
示例12
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例13
/**
* Parses a token to a file (or a set of files)
* and add them as {@link InputSource} to the specified list.
*
* @param suffix If the given token is a directory name, we do a recusive search
* and find all files that have the given suffix.
*/
private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException {
Object src;
try {
src = Util.getFileOrURL(name);
} catch (IOException e) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_NOT_A_FILE_NOR_URL(name));
}
if (src instanceof URL) {
target.add(absolutize(new InputSource(Util.escapeSpace(((URL) src).toExternalForm()))));
} else {
File fsrc = (File) src;
if (fsrc.isDirectory()) {
addRecursive(fsrc, suffix, target);
} else {
target.add(absolutize(fileToInputSource(fsrc)));
}
}
}
示例14
public void validate() throws BadCommandLineException {
if(nonclassDestDir == null)
nonclassDestDir = destDir;
if (!protocols.contains(protocol)) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INVALID_PROTOCOL(protocol, protocols));
}
if (endpoints.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_MISSING_FILE());
}
if (protocol == null || protocol.equalsIgnoreCase(X_SOAP12) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_SOAP_12_WITHOUT_EXTENSION());
}
if (nonstdProtocols.containsKey(protocol) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_PROTOCOL_WITHOUT_EXTENSION(protocol));
}
if (inlineSchemas && !genWsdl) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INLINE_SCHEMAS_ONLY_WITH_WSDL());
}
validateEndpointClass();
validateArguments();
}
示例15
public void validate() throws BadCommandLineException {
if(nonclassDestDir == null)
nonclassDestDir = destDir;
if (!protocols.contains(protocol)) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INVALID_PROTOCOL(protocol, protocols));
}
if (endpoints.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_MISSING_FILE());
}
if (protocol == null || protocol.equalsIgnoreCase(X_SOAP12) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_SOAP_12_WITHOUT_EXTENSION());
}
if (nonstdProtocols.containsKey(protocol) && !isExtensionMode()) {
throw new BadCommandLineException(WscompileMessages.WSGEN_PROTOCOL_WITHOUT_EXTENSION(protocol));
}
if (inlineSchemas && !genWsdl) {
throw new BadCommandLineException(WscompileMessages.WSGEN_INLINE_SCHEMAS_ONLY_WITH_WSDL());
}
validateEndpointClass();
validateArguments();
}
示例16
List<String> getJavacOptions(List<String> existingOptions, WsimportListener listener) {
List<String> result = new ArrayList<String>();
for (String o: javacOptions) {
if (o.contains("=") && !o.startsWith("A")) {
int i = o.indexOf('=');
String key = o.substring(0, i);
if (existingOptions.contains(key)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(key));
} else {
result.add(key);
result.add(o.substring(i + 1));
}
} else {
if (existingOptions.contains(o)) {
listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(o));
} else {
result.add(o);
}
}
}
return result;
}
示例17
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
//try MEX
MetaDataResolver resolver;
ServiceDescriptor serviceDescriptor = null;
for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
resolver = resolverFactory.metadataResolver(options.entityResolver);
try {
serviceDescriptor = resolver.resolve(new URI(systemId));
//we got the ServiceDescriptor, now break
if (serviceDescriptor != null)
break;
} catch (URISyntaxException e) {
throw new ParseException(e);
}
}
if (serviceDescriptor != null) {
errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
return parseMetadata(systemId, serviceDescriptor);
} else {
errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
}
return null;
}
示例18
public void error(SAXParseException e) {
if(debug)
e.printStackTrace();
hasError = true;
if((e.getSystemId() == null && e.getPublicId() == null) && (e.getCause() instanceof UnknownHostException)) {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.toString()), e);
} else {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.getMessage()), e);
}
}
示例19
public void validate() throws BadCommandLineException {
if (wsdls.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_MISSING_FILE());
}
if(wsdlLocation !=null && clientjar != null) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_WSDLLOCATION_CLIENTJAR());
}
if(wsdlLocation == null){
wsdlLocation = wsdls.get(0).getSystemId();
}
}
示例20
private void parseProxy(String text) throws BadCommandLineException {
int i = text.lastIndexOf('@');
int j = text.lastIndexOf(':');
if (i > 0) {
proxyAuth = text.substring(0, i);
if (j > i) {
proxyHost = text.substring(i + 1, j);
proxyPort = text.substring(j + 1);
} else {
proxyHost = text.substring(i + 1);
proxyPort = "8080";
}
} else {
//no auth info
if (j < 0) {
//no port
proxyHost = text;
proxyPort = "8080";
} else {
proxyHost = text.substring(0, j);
proxyPort = text.substring(j + 1);
}
}
try {
Integer.valueOf(proxyPort);
} catch (NumberFormatException e) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_PROXY(text));
}
}
示例21
public void error(SAXParseException e) {
if(debug)
e.printStackTrace();
hasError = true;
if((e.getSystemId() == null && e.getPublicId() == null) && (e.getCause() instanceof UnknownHostException)) {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.toString()), e);
} else {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.getMessage()), e);
}
}
示例22
private File getWSDLDownloadDir() {
File wsdlDir = new File(options.destDir, WSDL_PATH);
boolean created = wsdlDir.mkdirs();
if (options.verbose && !created) {
listener.message(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(wsdlDir));
}
return wsdlDir;
}
示例23
private void validateArguments() throws BadCommandLineException {
if (!genWsdl) {
if (serviceName != null) {
throw new BadCommandLineException(WscompileMessages.WSGEN_WSDL_ARG_NO_GENWSDL(SERVICENAME_OPTION));
}
if (portName != null) {
throw new BadCommandLineException(WscompileMessages.WSGEN_WSDL_ARG_NO_GENWSDL(PORTNAME_OPTION));
}
}
}
示例24
protected void usage(Options options) {
// Just don't see any point in passing WsgenOptions
// BadCommandLineException also shouldn't have options
if (options == null)
options = this.options;
if (options instanceof WsgenOptions) {
System.out.println(WscompileMessages.WSGEN_HELP("WSGEN",
((WsgenOptions)options).protocols,
((WsgenOptions)options).nonstdProtocols.keySet()));
System.out.println(WscompileMessages.WSGEN_USAGE_EXTENSIONS());
System.out.println(WscompileMessages.WSGEN_USAGE_EXAMPLES());
}
}
示例25
private void parseProxy(String text) throws BadCommandLineException {
int i = text.lastIndexOf('@');
int j = text.lastIndexOf(':');
if (i > 0) {
proxyAuth = text.substring(0, i);
if (j > i) {
proxyHost = text.substring(i + 1, j);
proxyPort = text.substring(j + 1);
} else {
proxyHost = text.substring(i + 1);
proxyPort = "8080";
}
} else {
//no auth info
if (j < 0) {
//no port
proxyHost = text;
proxyPort = "8080";
} else {
proxyHost = text.substring(0, j);
proxyPort = text.substring(j + 1);
}
}
try {
Integer.valueOf(proxyPort);
} catch (NumberFormatException e) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_PROXY(text));
}
}
示例26
public void error(SAXParseException e) {
if(debug)
e.printStackTrace();
hasError = true;
if((e.getSystemId() == null && e.getPublicId() == null) && (e.getCause() instanceof UnknownHostException)) {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.toString()), e);
} else {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.getMessage()), e);
}
}
示例27
public void validate() throws BadCommandLineException {
if (wsdls.isEmpty()) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_MISSING_FILE());
}
if(wsdlLocation !=null && clientjar != null) {
throw new BadCommandLineException(WscompileMessages.WSIMPORT_WSDLLOCATION_CLIENTJAR());
}
if(wsdlLocation == null){
wsdlLocation = wsdls.get(0).getSystemId();
}
}
示例28
public void error(SAXParseException e) {
if(debug)
e.printStackTrace();
hasError = true;
if((e.getSystemId() == null && e.getPublicId() == null) && (e.getCause() instanceof UnknownHostException)) {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.toString()), e);
} else {
print(WscompileMessages.WSIMPORT_ERROR_MESSAGE(e.getMessage()), e);
}
}
示例29
/**
* Get an implementation class annotated with @WebService annotation.
*/
private void validateEndpointClass() throws BadCommandLineException {
Class clazz = null;
for(String cls : endpoints){
clazz = getClass(cls);
if (clazz == null)
continue;
if (clazz.isEnum() || clazz.isInterface() ||
clazz.isPrimitive()) {
continue;
}
isImplClass = true;
WebService webService = (WebService) clazz.getAnnotation(WebService.class);
if(webService == null)
continue;
break;
}
if(clazz == null){
throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoints.get(0)));
}
if(!isImplClass){
throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_MUST_BE_IMPLEMENTATION_CLASS(clazz.getName()));
}
endpoint = clazz;
validateBinding();
}
示例30
private void validateArguments() throws BadCommandLineException {
if (!genWsdl) {
if (serviceName != null) {
throw new BadCommandLineException(WscompileMessages.WSGEN_WSDL_ARG_NO_GENWSDL(SERVICENAME_OPTION));
}
if (portName != null) {
throw new BadCommandLineException(WscompileMessages.WSGEN_WSDL_ARG_NO_GENWSDL(PORTNAME_OPTION));
}
}
}