use of org.apache.openejb.jee.Property$JAXB.writeProperty in project tomee by apache.
the class ConvertJMSConnectionFactoryDefinitions method setProperties.
private void setProperties(final JMSConnectionFactory d, final Properties p) {
for (final Property property : d.getProperty()) {
final String key = property.getName();
final String value = property.getValue();
put(p, key, value);
}
}
use of org.apache.openejb.jee.Property$JAXB.writeProperty in project tomee by apache.
the class ConvertJMSDestinationDefinitions method setProperties.
private void setProperties(final JMSDestination d, final Properties p) {
for (final Property property : d.getProperty()) {
final String key = property.getName();
final String value = property.getValue();
put(p, key, value);
}
}
use of org.apache.openejb.jee.Property$JAXB.writeProperty in project tomee by apache.
the class ConvertDataSourceDefinitions method setProperties.
private void setProperties(final DataSource d, final Properties p) {
for (final Property property : d.getProperty()) {
final String key = property.getName();
final String value = property.getValue();
put(p, key, value);
}
}
use of org.apache.openejb.jee.Property$JAXB.writeProperty in project tomee by apache.
the class DataSource$JAXB method _read.
public static final DataSource _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final DataSource dataSource = new DataSource();
context.beforeUnmarshal(dataSource, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<Property> property = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("data-sourceType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, DataSource.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, dataSource);
dataSource.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: descriptions
final Text descriptionsItem = readText(elementReader, context);
if (descriptions == null) {
descriptions = new ArrayList<Text>();
}
descriptions.add(descriptionsItem);
} else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.name = name;
} else if (("class-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: className
final String classNameRaw = elementReader.getElementAsString();
final String className;
try {
className = Adapters.collapsedStringAdapterAdapter.unmarshal(classNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.className = className;
} else if (("server-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: serverName
final String serverNameRaw = elementReader.getElementAsString();
final String serverName;
try {
serverName = Adapters.collapsedStringAdapterAdapter.unmarshal(serverNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.serverName = serverName;
} else if (("port-number" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: portNumber
final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
dataSource.portNumber = portNumber;
} else if (("database-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: databaseName
final String databaseNameRaw = elementReader.getElementAsString();
final String databaseName;
try {
databaseName = Adapters.collapsedStringAdapterAdapter.unmarshal(databaseNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.databaseName = databaseName;
} else if (("url" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: url
final String urlRaw = elementReader.getElementAsString();
final String url;
try {
url = Adapters.collapsedStringAdapterAdapter.unmarshal(urlRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.url = url;
} else if (("user" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: user
final String userRaw = elementReader.getElementAsString();
final String user;
try {
user = Adapters.collapsedStringAdapterAdapter.unmarshal(userRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.user = user;
} else if (("password" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: password
final String passwordRaw = elementReader.getElementAsString();
final String password;
try {
password = Adapters.collapsedStringAdapterAdapter.unmarshal(passwordRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
dataSource.password = password;
} else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: property
final Property propertyItem = readProperty(elementReader, context);
if (property == null) {
property = dataSource.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<Property>();
}
}
property.add(propertyItem);
} else if (("login-timeout" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: loginTimeout
final Integer loginTimeout = Integer.valueOf(elementReader.getElementAsString());
dataSource.loginTimeout = loginTimeout;
} else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: transactional
final Boolean transactional = ("1".equals(elementReader.getElementAsString()) || "true".equals(elementReader.getElementAsString()));
dataSource.transactional = transactional;
} else if (("isolation-level" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: isolationLevel
final IsolationLevel isolationLevel = parseIsolationLevel(elementReader, context, elementReader.getElementAsString());
if (isolationLevel != null) {
dataSource.isolationLevel = isolationLevel;
}
} else if (("initial-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: initialPoolSize
final Integer initialPoolSize = Integer.valueOf(elementReader.getElementAsString());
dataSource.initialPoolSize = initialPoolSize;
} else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: maxPoolSize
final Integer maxPoolSize = Integer.valueOf(elementReader.getElementAsString());
dataSource.maxPoolSize = maxPoolSize;
} else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: minPoolSize
final Integer minPoolSize = Integer.valueOf(elementReader.getElementAsString());
dataSource.minPoolSize = minPoolSize;
} else if (("max-idle-time" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: maxIdleTime
final Integer maxIdleTime = Integer.valueOf(elementReader.getElementAsString());
dataSource.maxIdleTime = maxIdleTime;
} else if (("max-statements" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: maxStatements
final Integer maxStatements = Integer.valueOf(elementReader.getElementAsString());
dataSource.maxStatements = maxStatements;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
}
}
if (descriptions != null) {
try {
dataSource.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, DataSource.class, "setDescriptions", Text[].class, e);
}
}
if (property != null) {
dataSource.property = property;
}
context.afterUnmarshal(dataSource, LifecycleCallback.NONE);
return dataSource;
}
use of org.apache.openejb.jee.Property$JAXB.writeProperty in project tomee by apache.
the class JMSConnectionFactory$JAXB method _read.
public static final JMSConnectionFactory _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final JMSConnectionFactory JMSConnectionFactory = new JMSConnectionFactory();
context.beforeUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
List<Property> property = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("jms-connection-factoryType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, JMSConnectionFactory.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, JMSConnectionFactory);
JMSConnectionFactory.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: descriptions
final Text descriptionsItem = readText(elementReader, context);
if (descriptions == null) {
descriptions = new ArrayList<Text>();
}
descriptions.add(descriptionsItem);
} else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.name = name;
} else if (("class-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.className = name;
} else if (("interface-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.className = name;
} else if (("resource-adapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.resourceAdapter = name;
} else if (("user" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.user = name;
} else if (("password" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.password = name;
} else if (("client-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
final String nameRaw = elementReader.getElementAsString();
final String name;
try {
name = Adapters.collapsedStringAdapterAdapter.unmarshal(nameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
JMSConnectionFactory.clientId = name;
} else if (("max-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
JMSConnectionFactory.maxPoolSize = portNumber;
} else if (("min-pool-size" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
final Integer portNumber = Integer.valueOf(elementReader.getElementAsString());
JMSConnectionFactory.minPoolSize = portNumber;
} else if (("transactional" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
JMSConnectionFactory.transactional = Boolean.parseBoolean(elementReader.getElementAsString());
} else if (("property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: property
final Property propertyItem = readProperty(elementReader, context);
if (property == null) {
property = JMSConnectionFactory.property;
if (property != null) {
property.clear();
} else {
property = new ArrayList<>();
}
}
property.add(propertyItem);
} else if (!Boolean.getBoolean("tomee.xml.passthrough")) {
// so to pass if not important
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "class-name"), new QName("http://java.sun.com/xml/ns/javaee", "server-name"), new QName("http://java.sun.com/xml/ns/javaee", "port-number"), new QName("http://java.sun.com/xml/ns/javaee", "database-name"), new QName("http://java.sun.com/xml/ns/javaee", "url"), new QName("http://java.sun.com/xml/ns/javaee", "user"), new QName("http://java.sun.com/xml/ns/javaee", "password"), new QName("http://java.sun.com/xml/ns/javaee", "property"), new QName("http://java.sun.com/xml/ns/javaee", "login-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "transactional"), new QName("http://java.sun.com/xml/ns/javaee", "isolation-level"), new QName("http://java.sun.com/xml/ns/javaee", "initial-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "min-pool-size"), new QName("http://java.sun.com/xml/ns/javaee", "max-idle-time"), new QName("http://java.sun.com/xml/ns/javaee", "max-statements"));
}
}
if (descriptions != null) {
try {
JMSConnectionFactory.description.set(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, JMSConnectionFactory.class, "setDescriptions", Text[].class, e);
}
}
if (property != null) {
JMSConnectionFactory.property = property;
}
context.afterUnmarshal(JMSConnectionFactory, LifecycleCallback.NONE);
return JMSConnectionFactory;
}
Aggregations