本文整理汇总了Java中javax.xml.bind.PropertyException类的典型用法代码示例。如果您正苦于以下问题:Java PropertyException类的具体用法?Java PropertyException怎么用?Java PropertyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyException类属于javax.xml.bind包,在下文中一共展示了PropertyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadProperties
import javax.xml.bind.PropertyException; //导入依赖的package包/类
/**
* Returns user properties from path under ${catalina.home}. The user Properties must comply with standard properties rules.
*
* @param propertiesPath
* the path to user property
* @return Properties {@Link Properties}
* @throws PropertyException
*
*/
// TODO: resolve dependencies to catalina.home - make more generic
public static Properties loadProperties(final String propertiesPath) throws PropertyException {
if (propertiesPath == null || propertiesPath.length() == 0) {
throw new PropertyException("propertiesPath may not be empty or null");
}
final String catalinaHome = System.getProperty("catalina.home", System.getProperty("user.dir"));
String propPath = propertiesPath.replace("\\", "/").replaceAll("/+", "/");
if (propPath.indexOf("/") == -1) {
propPath = "/" + propPath;
}
final String propertyPath = catalinaHome + propPath;
final Properties properties = new Properties();
try (FileInputStream fi = new FileInputStream(new File(propertyPath));) {
properties.load(fi);
} catch (final IOException e) {
throw new PropertyException("properties not found at this location");
}
return properties;
}
示例2: getRuntimeProperties
import javax.xml.bind.PropertyException; //导入依赖的package包/类
/**
* Return runtime properties of given {@code runtimeProperties}. Looks first, if application is running on a dev machine and returns in this case the
* properties from the resource context. Otherwise a lookup in properties folder in webapps context is fullfilled.
*
* @param runtimeProperties
* @return properties {@link Properties}
* @throws PropertyException
*/
public static Properties getRuntimeProperties(final String runtimeProperties) throws PropertyException {
if (runtimeProperties == null || runtimeProperties.length() == 0) {
throw new PropertyException("path may not be empty or null");
}
final Properties properties = new Properties();
final String fileType = runtimeProperties.substring(runtimeProperties.lastIndexOf(".") + 1, runtimeProperties.length());
final File propFile = readFile(runtimeProperties);
try (FileInputStream fi = new FileInputStream(propFile);) {
if ("xml".equals(fileType)) {
properties.loadFromXML(fi);
} else {
properties.load(fi);
}
} catch (final IOException e) {
System.err.println(ProjectProperty.class.getSimpleName() + " IOException for " + runtimeProperties + " " + e.getMessage());
}
return properties;
}
示例3: loadDsNameAndOffset
import javax.xml.bind.PropertyException; //导入依赖的package包/类
/**
* read dbSourceName from ZK and set into DataSourceInfo
*
* @param dsInfo (in)
* @return
* @throws Exception
*/
public void loadDsNameAndOffset(DataSourceInfo dsInfo) throws Exception {
// read dbSourceName
String path = topologyRoot + "/" + Constants.DISPATCHER_RAW_TOPICS_PROPERTIES;
Properties raw_topics = zkService.getProperties(path);
String dbSourceName = raw_topics.getProperty(Constants.DISPATCHER_DBSOURCE_NAME);
if (dbSourceName == null) {
throw new PropertyException("配置参数文件内容不能为空! " + Constants.DISPATCHER_DBSOURCE_NAME);
}
String dataTopicOffset = raw_topics.getProperty(Constants.DISPATCHER_OFFSET);
if (dataTopicOffset == null) {
throw new PropertyException("配置参数文件内容不能为空! " + Constants.DISPATCHER_OFFSET);
}
dsInfo.setDbSourceName(dbSourceName);
dsInfo.setDataTopicOffset(dataTopicOffset);
}
示例4: InfluxSink
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public InfluxSink() throws IOException, PropertyException {
Properties configProps = ConfUtils.getProps(CONFIG_PROPERTIES);
String dbURL = configProps.getProperty(Constants.InfluxDB.DB_URL);
String dbName = configProps.getProperty(Constants.InfluxDB.DB_NAME);
tableName = configProps.getProperty(Constants.InfluxDB.TABLE_NAME);
if (dbURL == null) {
throw new PropertyException("配置参数文件内容不能为空! " + Constants.InfluxDB.DB_URL);
}
if (dbName == null) {
throw new PropertyException("配置参数文件内容不能为空! " + Constants.InfluxDB.DB_NAME);
}
if (tableName == null) {
throw new PropertyException("配置参数文件内容不能为空! " + Constants.InfluxDB.TABLE_NAME);
}
postURL = String.format("%s/write?db=%s", dbURL, dbName);
initPost();
}
示例5: setProperty
import javax.xml.bind.PropertyException; //导入依赖的package包/类
@Override
public void setProperty(String name, Object value) throws PropertyException {
if(name.equals(FACTORY)) {
coordinator.setFactories(value);
return;
}
if(name.equals(IDResolver.class.getName())) {
idResolver = (IDResolver)value;
return;
}
if(name.equals(ClassResolver.class.getName())) {
coordinator.classResolver = (ClassResolver)value;
return;
}
if(name.equals(ClassLoader.class.getName())) {
coordinator.classLoader = (ClassLoader)value;
return;
}
super.setProperty(name, value);
}
示例6: getProperty
import javax.xml.bind.PropertyException; //导入依赖的package包/类
@Override
public Object getProperty(String name) throws PropertyException {
if( INDENT_STRING.equals(name) )
return indent;
if( ENCODING_HANDLER.equals(name) || ENCODING_HANDLER2.equals(name) )
return escapeHandler;
if( PREFIX_MAPPER.equals(name) )
return prefixMapper;
if( XMLDECLARATION.equals(name) )
return !isFragment();
if( XML_HEADERS.equals(name) )
return header;
if( C14N.equals(name) )
return c14nSupport;
if ( OBJECT_IDENTITY_CYCLE_DETECTION.equals(name))
return serializer.getObjectIdentityCycleDetection();
return super.getProperty(name);
}
示例7: getProperty
import javax.xml.bind.PropertyException; //导入依赖的package包/类
/**
* Default implementation of the getProperty method handles
* the four defined properties in Marshaller. If a provider
* needs to support additional provider specific properties,
* it should override this method in a derived class.
*/
public Object getProperty( String name )
throws PropertyException {
if( name == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "name" ) );
}
// recognize and handle four pre-defined properties.
if( JAXB_ENCODING.equals(name) )
return getEncoding();
if( JAXB_FORMATTED_OUTPUT.equals(name) )
return isFormattedOutput()?Boolean.TRUE:Boolean.FALSE;
if( JAXB_NO_NAMESPACE_SCHEMA_LOCATION.equals(name) )
return getNoNSSchemaLocation();
if( JAXB_SCHEMA_LOCATION.equals(name) )
return getSchemaLocation();
if( JAXB_FRAGMENT.equals(name) )
return isFragment()?Boolean.TRUE:Boolean.FALSE;
throw new PropertyException(name);
}
示例8: marshallData
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public static void marshallData(IndoorFeaturesType ifs) throws JAXBException {
File file = new File("indoorExample.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(IndoorFeaturesType.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
try {
jaxbMarshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new IndoorGMLNamespaceMapper());
} catch (PropertyException e) {
// In case another JAXB implementation is used
e.printStackTrace();
}
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(ifs, file);
jaxbMarshaller.marshal(ifs, System.out);
}
示例9: marshallData
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public static void marshallData(FeatureCollectionType ifs) throws JAXBException {
File file = new File("gmltest.gml");
JAXBContext jaxbContext = JAXBContext.newInstance(FeatureCollectionType.class, CustomPointFeatureMember.class, CustomLineFeatureMember.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
try {
jaxbMarshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new GMLNamespaceMapper());
} catch (PropertyException e) {
// In case another JAXB implementation is used
e.printStackTrace();
}
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
net.opengis.gml.v_3_2_1.ObjectFactory gmlObjfact = new net.opengis.gml.v_3_2_1.ObjectFactory();
JAXBElement<?> elem = gmlObjfact.createFeatureCollection(ifs);
jaxbMarshaller.marshal(elem, file);
jaxbMarshaller.marshal(elem, System.out);
}
示例10: storeMethod
import javax.xml.bind.PropertyException; //导入依赖的package包/类
private static void storeMethod(String unisonXMLFile, TremoloType tt,
String ksPath, KeyStore ks) throws KeyStoreException, IOException,
NoSuchAlgorithmException, CertificateException,
FileNotFoundException, JAXBException, PropertyException {
logger.info("Storing the keystore");
ks.store(new FileOutputStream(ksPath), tt.getKeyStorePassword().toCharArray());
logger.info("Saving the unison xml file");
JAXBContext jc = JAXBContext.newInstance("com.tremolosecurity.config.xml");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
OutputStream os = new FileOutputStream(unisonXMLFile);
JAXBElement<TremoloType> root = new JAXBElement<TremoloType>(new QName("http://www.tremolosecurity.com/tremoloConfig","tremoloConfig","tns"),TremoloType.class,tt);
marshaller.marshal(root, os);
os.flush();
os.close();
}
示例11: buildMarshaller
import javax.xml.bind.PropertyException; //导入依赖的package包/类
@Override
public <T> Marshaller buildMarshaller(T src, @Nullable Map<String, Object> marshallerProps) throws JAXBException {
Marshaller marshaller = this.findTypeMetadata(src.getClass()).getContext().getContext().createMarshaller();
Map<String, Object> mergedMarshallerProps = new HashMap<>(this.defaultMarshallerProps);
if (!MapUtils.isEmpty(marshallerProps)) {
mergedMarshallerProps.putAll(marshallerProps);
}
Object marshallerPropValue;
for (String marshallerPropName : mergedMarshallerProps.keySet()) {
marshallerPropValue = mergedMarshallerProps.get(marshallerPropName);
try {
marshaller.setProperty(marshallerPropName, marshallerPropValue);
} catch (PropertyException e) {
throw new JAXBException(String.format("Unable to set JAXB marshaller property (name=%s) value: %s", marshallerPropName, marshallerPropValue),
e);
}
}
return marshaller;
}
示例12: buildUnmarshaller
import javax.xml.bind.PropertyException; //导入依赖的package包/类
@Override
public <T> Unmarshaller buildUnmarshaller(Class<T> resultClass, @Nullable Map<String, Object> unmarshallerProps) throws JAXBException {
Unmarshaller unmarshaller = this.findTypeMetadata(resultClass).getContext().getContext().createUnmarshaller();
Map<String, Object> mergedUnmarshallerProps = new HashMap<>(this.defaultUnmarshallerProps);
if (!MapUtils.isEmpty(unmarshallerProps)) {
mergedUnmarshallerProps.putAll(unmarshallerProps);
}
Object unmarshallerPropValue;
for (String unmarshallerPropName : mergedUnmarshallerProps.keySet()) {
unmarshallerPropValue = mergedUnmarshallerProps.get(unmarshallerPropName);
try {
unmarshaller.setProperty(unmarshallerPropName, unmarshallerPropValue);
} catch (PropertyException e) {
throw new JAXBException(
String.format("Unable to set JAXB unmarshaller property (name=%s) value: %s", unmarshallerPropName, unmarshallerPropValue), e);
}
}
return unmarshaller;
}
示例13: unmarshalProcessModel
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public ProcessModel unmarshalProcessModel(File procSchmInFile) throws JAXBException, PropertyException, FileNotFoundException,
IOException {
String pkgName = ProcessModel.class.getCanonicalName().toString();
pkgName = pkgName.substring(0, pkgName.lastIndexOf('.'));
JAXBContext jaxbCtx = JAXBContext.newInstance(pkgName);
Unmarshaller unmarsh = jaxbCtx.createUnmarshaller();
unmarsh.setEventHandler(
new ValidationEventHandler() {
public boolean handleEvent(ValidationEvent event) {
throw new RuntimeException(event.getMessage(),
event.getLinkedException());
}
});
ProcessModel proMod = (ProcessModel) unmarsh.unmarshal(procSchmInFile);
MetaConstraintUtils.createHierarchicalLinks(proMod.getAllConstraints());
return proMod;
}
示例14: marshalProcessModel
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public void marshalProcessModel(ProcessModel processModel, File procSchmOutFile) throws JAXBException, PropertyException, FileNotFoundException, IOException {
String pkgName = processModel.getClass().getCanonicalName().toString();
pkgName = pkgName.substring(0, pkgName.lastIndexOf('.'));
JAXBContext jaxbCtx = JAXBContext.newInstance(pkgName);
Marshaller marsh = jaxbCtx.createMarshaller();
marsh.setProperty("jaxb.formatted.output", true);
StringWriter strixWriter = new StringWriter();
marsh.marshal(processModel, strixWriter);
strixWriter.flush();
StringBuffer strixBuffer = strixWriter.getBuffer();
// OINK
// strixBuffer.replace(
// strixBuffer.indexOf(">", strixBuffer.indexOf("?>") + 3),
// strixBuffer.indexOf(">", strixBuffer.indexOf("?>") + 3),
// " xmlns=\"" + ProcessModel.MINERFUL_XMLNS + "\"");
FileWriter strixFileWriter = new FileWriter(procSchmOutFile);
strixFileWriter.write(strixBuffer.toString());
strixFileWriter.flush();
strixFileWriter.close();
}
示例15: setNamespaceWrapper
import javax.xml.bind.PropertyException; //导入依赖的package包/类
public static void setNamespaceWrapper(final Map<String, String> nspref,
Marshaller marshaller) throws PropertyException {
Object mapper = null;
if (marshaller.getClass().getName().contains(".internal.")) {
mapper = createNamespaceWrapper(nspref);
if (mapper == null) {
LOG.log(Level.INFO, "Could not create namespace mapper for JDK internal"
+ " JAXB implementation.");
} else {
marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",
mapper);
}
} else {
try {
Class<?> cls = Class.forName("org.apache.cxf.jaxb.NamespaceMapper");
mapper = cls.getConstructor(Map.class).newInstance(nspref);
} catch (Exception ex) {
LOG.log(Level.INFO, "Could not create NamespaceMapper", ex);
}
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
mapper);
}
}