下面列出了怎么用java.util.InvalidPropertiesFormatException的API类实例代码及写法,或者点击链接到github查看源代码。
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void startAndWait()
throws InterruptedException, IOException, GeneralSecurityException,
InvalidSnapshotException {
try {
List<ChannelFuture> channelFutures = start();
// Create and schedule metrics manager
MetricManager.scheduleMetrics(configManager);
System.out.println("Model server started."); // NOPMD
channelFutures.get(0).sync();
} catch (InvalidPropertiesFormatException e) {
logger.error("Invalid configuration", e);
} finally {
serverGroups.shutdown(true);
logger.info("Torchserve stopped.");
}
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
ProfilingPoint[] loadProfilingPoints(Lookup.Provider project)
throws IOException, InvalidPropertiesFormatException {
Properties properties = new Properties();
ProfilerStorage.loadProjectProperties(properties, project, getProfilingPointsStorage());
int index = 0;
List<ProfilingPoint> profilingPoints = new ArrayList();
while (properties.getProperty(index + "_" + ProfilingPoint.PROPERTY_NAME) != null) { // NOI18N
ProfilingPoint profilingPoint = loadProfilingPoint(project, properties, index);
if (profilingPoint != null) {
profilingPoints.add(profilingPoint);
} else {
ErrorManager.getDefault().log(ErrorManager.ERROR, "Invalid " + getType() + // NOI18N
" Profiling Point format at index " + index + // NOI18N
" in project " + ProjectUtilities.getDisplayName(project)); // NOI18N
}
index++;
}
return profilingPoints.toArray(new ProfilingPoint[0]);
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
/**
* Test loadFromXML with malformed documents
*/
static void testLoadWithMalformedDoc(Path dir) throws IOException {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.xml")) {
for (Path file: stream) {
System.out.println("testLoadWithMalformedDoc, file=" + file.getFileName());
try (InputStream in = Files.newInputStream(file)) {
Properties props = new Properties();
try {
props.loadFromXML(in);
throw new RuntimeException("InvalidPropertiesFormatException not thrown");
} catch (InvalidPropertiesFormatException x) {
System.out.println(x);
}
}
}
}
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException
{
this.properties = props;
try {
SAXParser parser = new SAXParserImpl();
parser.parse(in, this);
} catch (SAXException saxe) {
throw new InvalidPropertiesFormatException(saxe);
}
/**
* String xmlVersion = propertiesElement.getAttribute("version"); if
* (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
* InvalidPropertiesFormatException( "Exported Properties file format
* version " + xmlVersion + " is not supported. This java installation
* can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
* " may need to install a newer version of JDK.");
*/
}
@Override
public synchronized void loadFromXML( InputStream in ) throws IOException, InvalidPropertiesFormatException {
super.putAll( storageMap );
super.loadFromXML( in );
super.forEach( ( key, value ) -> storageMap.putIfAbsent( key, value ) );
super.clear();
}
@Override
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException
{
PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
handler.load(props, in);
}
public void validateConfigurations() throws InvalidPropertiesFormatException {
String blacklistVars = prop.getProperty(TS_BLACKLIST_ENV_VARS, "");
try {
blacklistPattern = Pattern.compile(blacklistVars);
} catch (PatternSyntaxException e) {
throw new InvalidPropertiesFormatException(e);
}
}
@Override
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException
{
PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
handler.load(props, in);
}
@PostConstruct
public void parseBrokers( ) throws InvalidPropertiesFormatException {
if(servers == null || servers.length == 0) {
servers = new String[] {"127.0.0.1"};
}
for (int i = 0; i < servers.length; i++) {
servers[i] = servers[i].trim();
if (!servers[i].matches(PATTERN)) {
throw new InvalidPropertiesFormatException("Invalid property! joyqueue.servers: " + String.join(",", servers));
}
}
logger.info("Using nameservers: {}.", String.join(",", servers));
}
@Override
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException
{
PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
handler.load(props, in);
}
public static Properties load(String...files) throws InvalidPropertiesFormatException, IOException {
Properties properties = new Properties();
for(String f : files) {
File file = FileHelper.getFile(f);
@Cleanup
InputStream input = new FileInputStream(file);
if(file.getPath().endsWith(".xml")){
properties.loadFromXML(input);
}else {
properties.load(input);
}
properties.putAll(properties);
}
return properties;
}
public static Properties load(String... files) throws InvalidPropertiesFormatException, IOException {
Properties properties = new Properties();
for (String f : files) {
File file = new File(f);
@Cleanup
InputStream input = new FileInputStream(file);
if (file.getPath().endsWith(".xml")) {
properties.loadFromXML(input);
} else {
properties.load(input);
}
properties.putAll(properties);
}
return properties;
}
public static Properties load(String... files) throws InvalidPropertiesFormatException, IOException {
Properties properties = new Properties();
for (String f : files) {
File file = FileHelpers.getFile(f);
@Cleanup
InputStream input = new FileInputStream(file);
if (file.getPath().endsWith(".xml")) {
properties.loadFromXML(input);
} else {
properties.load(input);
}
properties.putAll(properties);
}
return properties;
}
@Override
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException
{
PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
handler.load(props, in);
}
public void startAndWait() throws InterruptedException, IOException, GeneralSecurityException {
try {
List<ChannelFuture> channelFutures = start();
// Create and schedule metrics manager
MetricManager.scheduleMetrics(configManager);
System.out.println("Model server started."); // NOPMD
channelFutures.get(0).sync();
} catch (InvalidPropertiesFormatException e) {
logger.error("Invalid configuration", e);
} finally {
serverGroups.shutdown(true);
logger.info("Model server stopped.");
}
}
public void validateConfigurations() throws InvalidPropertiesFormatException {
String blacklistVars = prop.getProperty(MMS_BLACKLIST_ENV_VARS, "");
try {
blacklistPattern = Pattern.compile(blacklistVars);
} catch (PatternSyntaxException e) {
throw new InvalidPropertiesFormatException(e);
}
}
@Override
public void load(Properties props, InputStream in)
throws IOException, InvalidPropertiesFormatException
{
PropertiesDefaultHandler handler = new PropertiesDefaultHandler();
handler.load(props, in);
}