Skip to content

Commit

Permalink
8153944: wsimport and wsgen usage messages not printed
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, lancea, aefimov
  • Loading branch information
Mandy Chung committed May 31, 2016
1 parent de5a80c commit a5844d5
Show file tree
Hide file tree
Showing 40 changed files with 456 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,6 +25,9 @@

package com.sun.istack.internal.localization;

import java.util.Locale;
import java.util.ResourceBundle;

/**
* Localizable message.
*
Expand All @@ -51,6 +54,9 @@ public interface Localizable {
public Object[] getArguments();
public String getResourceBundleName();

public default ResourceBundle getResourceBundle(Locale locale) {
return null;
}

/**
* Special constant that represents a message that
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,25 +25,43 @@

package com.sun.istack.internal.localization;

import com.sun.istack.internal.localization.LocalizableMessageFactory.ResourceBundleSupplier;

import java.util.Arrays;
import java.util.Locale;
import java.util.ResourceBundle;

/**
* @author WS Development Team
*/
public final class LocalizableMessage implements Localizable {

private final String _bundlename;
private final ResourceBundleSupplier _rbSupplier;

private final String _key;
private final Object[] _args;

public LocalizableMessage(String bundlename, String key, Object... args) {
_bundlename = bundlename;
_rbSupplier = null;
_key = key;
if(args==null)
args = new Object[0];
_args = args;
}

public LocalizableMessage(String bundlename, ResourceBundleSupplier rbSupplier,
String key, Object... args) {
_bundlename = bundlename;
_rbSupplier = rbSupplier;
_key = key;
if(args==null)
args = new Object[0];
_args = args;
}


public String getKey() {
return _key;
}
Expand All @@ -55,4 +73,12 @@ public Object[] getArguments() {
public String getResourceBundleName() {
return _bundlename;
}

@Override
public ResourceBundle getResourceBundle(Locale locale) {
if (_rbSupplier == null)
return null;

return _rbSupplier.getResourceBundle(locale);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,19 +25,37 @@

package com.sun.istack.internal.localization;

import java.util.Locale;
import java.util.ResourceBundle;

/**
* @author WS Development Team
*/
public class LocalizableMessageFactory {

private final String _bundlename;
private final ResourceBundleSupplier _rbSupplier;

public LocalizableMessageFactory(String bundlename) {
_bundlename = bundlename;
_rbSupplier = null;
}

public LocalizableMessageFactory(String bundlename, ResourceBundleSupplier rbSupplier) {
_bundlename = bundlename;
_rbSupplier = rbSupplier;
}

public Localizable getMessage(String key, Object... args) {
return new LocalizableMessage(_bundlename, key, args);
return new LocalizableMessage(_bundlename, _rbSupplier, key, args);
}

public interface ResourceBundleSupplier {
/**
* Gets the ResourceBundle.
* @param locale the requested bundle's locale
* @return ResourceBundle
*/
ResourceBundle getResourceBundle(Locale locale);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,6 +25,7 @@

package com.sun.istack.internal.localization;

import com.sun.istack.internal.localization.LocalizableMessageFactory.ResourceBundleSupplier;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -61,12 +62,20 @@ public String localize(Localizable l) {
// this message is not localizable
return (String) l.getArguments()[0];
}

String bundlename = l.getResourceBundleName();

try {
ResourceBundle bundle =
(ResourceBundle) _resourceBundles.get(bundlename);

if (bundle == null) {
bundle = l.getResourceBundle(_locale);
if (bundle != null) {
_resourceBundles.put(bundlename, bundle);
}
}

if (bundle == null) {
try {
bundle = ResourceBundle.getBundle(bundlename, _locale);
Expand Down Expand Up @@ -151,5 +160,4 @@ private String getDefaultMessage(Localizable l) {
}
return sb.toString();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class LocalizationMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.policy.privateutil.Localization");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.policy.privateutil.Localization";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, LocalizationMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableWSP_0017_UNABLE_TO_ACCESS_POLICY_SOURCE_MODEL_PLUS_REASON(Object arg0, Object arg1) {
return messageFactory.getMessage("WSP_0017_UNABLE_TO_ACCESS_POLICY_SOURCE_MODEL_PLUS_REASON", arg0, arg1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class AddressingMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.resources.addressing");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.resources.addressing";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, AddressingMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableNON_ANONYMOUS_RESPONSE_ONEWAY() {
return messageFactory.getMessage("nonAnonymous.response.oneway");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class BindingApiMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.resources.bindingApi");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.resources.bindingApi";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, BindingApiMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableBINDING_API_NO_FAULT_MESSAGE_NAME() {
return messageFactory.getMessage("binding.api.no.fault.message.name");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class ClientMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.resources.client");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.resources.client";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, ClientMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableFAILED_TO_PARSE(Object arg0, Object arg1) {
return messageFactory.getMessage("failed.to.parse", arg0, arg1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class DispatchMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.resources.dispatch");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.resources.dispatch";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, DispatchMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableINVALID_NULLARG_XMLHTTP_REQUEST_METHOD(Object arg0, Object arg1) {
return messageFactory.getMessage("invalid.nullarg.xmlhttp.request.method", arg0, arg1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,16 +29,24 @@
import com.sun.istack.internal.localization.LocalizableMessageFactory;
import com.sun.istack.internal.localization.Localizer;

import java.util.Locale;
import java.util.ResourceBundle;


/**
* Defines string formatting method for each constant in the resource file
*
*/
public final class EncodingMessages {

private final static LocalizableMessageFactory messageFactory = new LocalizableMessageFactory("com.sun.xml.internal.ws.resources.encoding");
private final static String BUNDLE_NAME = "com.sun.xml.internal.ws.resources.encoding";
private final static LocalizableMessageFactory messageFactory =
new LocalizableMessageFactory(BUNDLE_NAME, EncodingMessages::getResourceBundle);
private final static Localizer localizer = new Localizer();

private static ResourceBundle getResourceBundle(Locale locale) {
return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}

public static Localizable localizableFAILED_TO_READ_RESPONSE(Object arg0) {
return messageFactory.getMessage("failed.to.read.response", arg0);
}
Expand Down
Loading

0 comments on commit a5844d5

Please sign in to comment.