private static ConfigurationBuilder createBuilder(String className, ClassLoader classLoader) { Class<? extends ConfigurationBuilder> builderClass; try { builderClass = Class.forName(className, true, classLoader) .asSubclass(ConfigurationBuilder.class); return builderClass.newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } }
private Schema getSchema(InputStream is) { Source schemaFile = new StreamSource(is); SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = null; try { schema = factory.newSchema(schemaFile); } catch (SAXException ex) { throw new ConfigurationException(new Message("SCHEMA_CREATION_ERROR_EXC", LOG), ex); } return schema; }
private Object invokeGetter(Object beanObject, String name) { String methodName = JAXBUtils.nameToIdentifier(name, JAXBUtils.IdentifierType.GETTER); try { Method m = beanObject.getClass().getMethod("isSet", new Class[] {String.class}); Object o = m.invoke(beanObject, new Object[] {name}); if (!((Boolean)o).booleanValue()) { return null; } m = beanObject.getClass().getMethod(methodName, new Class[] {}); return m.invoke(beanObject); } catch (Exception ex) { throw new ConfigurationException(new Message("BEAN_INCOVATION_EXC", LOG), ex); } }
public Configuration getConfiguration(String namespaceUri, String id) { Map<String, Configuration> instances = configurations.get(namespaceUri); if (null == instances) { if (null == getModel(namespaceUri)) { throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri)); } return null; } return instances.get(id); }
public String getXMLSchemaBaseType(String typeName) { if (!hasType(typeName)) { throw new ConfigurationException(new Message("TYPE_NOT_DEFINED_IN_NAMESPACE_EXC", LOG, typeName, namespaceURI)); } return typeDefinitions.get(typeName); }
throw new ConfigurationException(new Message("BEAN_INCOVATION_EXC", LOG), ex);
return new QName(s); } else if (index == 0) { throw new ConfigurationException(new Message("ILLEGAL_QNAME_EXC", LOG, s)); throw new ConfigurationException(new Message("ILLEGAL_PREFIX_EXC", LOG, s)); throw new ConfigurationException(new Message("ILLEGAL_QNAME_EXC", LOG, s));
public ConfigurationProvider createDefaultProvider(Configuration configuration) { String className = getDefaultProviderClassName(); Class<? extends ConfigurationProvider> providerClass; try { providerClass = Class.forName(className).asSubclass(ConfigurationProvider.class); ConfigurationProvider provider = providerClass.newInstance(); provider.init(configuration); return provider; } catch (ConfigurationException ex) { throw ex; } catch (Exception ex) { throw new ConfigurationException(new Message("DEFAULT_PROVIDER_INSTANTIATION_EXC", LOG), ex); } }
return builderClass; } catch (Exception ex) { throw new ConfigurationException(ex);
throw new ConfigurationException(new Message("MISSING_PACKAGE_NAME_EXC", LOG, namespaceURI));
public InputSource resolveEntity(String publicId, String systemId) throws IOException { if (systemId != null && systemId.equals(DTD_SYSTEM_ID)) { InputStream is = ResourceManagerImpl.instance().getResourceAsStream(getDtdFile()); if (is == null) { throw new ConfigurationException(new Message("COULD_NOT_RESOLVE_BEANS_DTD_EXC", LOG, DTD_SYSTEM_ID)); } InputSource source = new InputSource(is); source.setPublicId(publicId); source.setSystemId(systemId); return source; } // Use the default behavior -> download from website or wherever. return null; }
public float getFloat(String name) { Object obj = getObject(name); if (null == obj) { throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name)); } try { return ((Float)obj).floatValue(); } catch (ClassCastException ex) { QName type = model.getDefinition(name).getType(); throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type)); } }
throw new ConfigurationException(msg, ex); if (null == path) { Message msg = new Message("FILE_OPEN_ERROR_EXC", LOG, location); throw new ConfigurationException(msg); throw new ConfigurationException(new Message("SCHEMA_LOCATION_ERROR_EXC", LOG, location));
throw new ConfigurationException(new Message("DEFAULT_PROVIDER_INSTANTIATION_EXC", LOG), ex); } catch (IOException ex) { throw new ConfigurationException(new Message("DEFAULT_PROVIDER_INSTANTIATION_EXC", LOG), ex);
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; } }
public short getShort(String name) { Object obj = getObject(name); if (null == obj) { throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name)); } try { return ((Short)obj).shortValue(); } catch (ClassCastException ex) { QName type = model.getDefinition(name).getType(); throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type)); } }
public double getDouble(String name) { Object obj = getObject(name); if (null == obj) { throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name)); } try { return ((Double)obj).doubleValue(); } catch (ClassCastException ex) { QName type = model.getDefinition(name).getType(); throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type)); } }
public int getInt(String name) { Object obj = getObject(name); if (null == obj) { throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name)); } try { return ((Integer)obj).intValue(); } catch (ClassCastException ex) { QName type = model.getDefinition(name).getType(); throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type)); } }
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; }
public long getLong(String name) { Object obj = getObject(name); if (null == obj) { throw new ConfigurationException(new Message("ITEM_NO_VALUE_EXC", BUNDLE, name)); } try { return ((Long)obj).longValue(); } catch (ClassCastException ex) { QName type = model.getDefinition(name).getType(); throw new ConfigurationException(new Message("ITEM_TYPE_MISMATCH_EXC", BUNDLE, name, type)); } }