use of org.apache.openejb.jee.FacesValidator$JAXB.writeFacesValidator in project tomee by apache.
the class FacesConfig$JAXB method _read.
public static final FacesConfig _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesConfig facesConfig = new FacesConfig();
context.beforeUnmarshal(facesConfig, LifecycleCallback.NONE);
List<FacesApplication> application = null;
List<FacesOrdering> ordering = null;
List<FacesAbsoluteOrdering> absoluteOrdering = null;
List<FacesFactory> factory = null;
List<FacesComponent> component = null;
List<FacesConverter> converter = null;
List<FacesManagedBean> managedBean = null;
List<String> name = null;
List<FacesNavigationRule> navigationRule = null;
List<FacesReferencedBean> referencedBean = null;
List<FacesRenderKit> renderKit = null;
List<FacesLifecycle> lifecycle = null;
List<FacesValidator> validator = null;
List<FacesBehavior> behavior = null;
List<FacesExtension> facesConfigExtension = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-configType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesConfig.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, facesConfig);
facesConfig.id = id;
} else if (("version" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: version
facesConfig.version = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
} else if (("metadata-complete" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: metadataComplete
final Boolean metadataComplete = ("1".equals(attribute.getValue()) || "true".equals(attribute.getValue()));
facesConfig.metadataComplete = metadataComplete;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"), new QName("", "version"), new QName("", "metadata-complete"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("application" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: application
final FacesApplication applicationItem = readFacesApplication(elementReader, context);
if (application == null) {
application = facesConfig.application;
if (application != null) {
application.clear();
} else {
application = new ArrayList<FacesApplication>();
}
}
application.add(applicationItem);
} else if (("ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ordering
final FacesOrdering orderingItem = readFacesOrdering(elementReader, context);
if (ordering == null) {
ordering = facesConfig.ordering;
if (ordering != null) {
ordering.clear();
} else {
ordering = new ArrayList<FacesOrdering>();
}
}
ordering.add(orderingItem);
} else if (("absolute-ordering" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: absoluteOrdering
final FacesAbsoluteOrdering absoluteOrderingItem = readFacesAbsoluteOrdering(elementReader, context);
if (absoluteOrdering == null) {
absoluteOrdering = facesConfig.absoluteOrdering;
if (absoluteOrdering != null) {
absoluteOrdering.clear();
} else {
absoluteOrdering = new ArrayList<FacesAbsoluteOrdering>();
}
}
absoluteOrdering.add(absoluteOrderingItem);
} else if (("factory" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: factory
final FacesFactory factoryItem = readFacesFactory(elementReader, context);
if (factory == null) {
factory = facesConfig.factory;
if (factory != null) {
factory.clear();
} else {
factory = new ArrayList<FacesFactory>();
}
}
factory.add(factoryItem);
} else if (("component" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: component
final FacesComponent componentItem = readFacesComponent(elementReader, context);
if (component == null) {
component = facesConfig.component;
if (component != null) {
component.clear();
} else {
component = new ArrayList<FacesComponent>();
}
}
component.add(componentItem);
} else if (("converter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: converter
final FacesConverter converterItem = readFacesConverter(elementReader, context);
if (converter == null) {
converter = facesConfig.converter;
if (converter != null) {
converter.clear();
} else {
converter = new ArrayList<FacesConverter>();
}
}
converter.add(converterItem);
} else if (("managed-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: managedBean
final FacesManagedBean managedBeanItem = readFacesManagedBean(elementReader, context);
if (managedBean == null) {
managedBean = facesConfig.managedBean;
if (managedBean != null) {
managedBean.clear();
} else {
managedBean = new ArrayList<FacesManagedBean>();
}
}
managedBean.add(managedBeanItem);
} else if (("name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: name
String nameItemRaw = null;
if (!elementReader.isXsiNil()) {
nameItemRaw = elementReader.getElementAsString();
}
final String nameItem;
try {
nameItem = Adapters.collapsedStringAdapterAdapter.unmarshal(nameItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (name == null) {
name = facesConfig.name;
if (name != null) {
name.clear();
} else {
name = new ArrayList<String>();
}
}
name.add(nameItem);
} else if (("navigation-rule" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: navigationRule
final FacesNavigationRule navigationRuleItem = readFacesNavigationRule(elementReader, context);
if (navigationRule == null) {
navigationRule = facesConfig.navigationRule;
if (navigationRule != null) {
navigationRule.clear();
} else {
navigationRule = new ArrayList<FacesNavigationRule>();
}
}
navigationRule.add(navigationRuleItem);
} else if (("referenced-bean" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: referencedBean
final FacesReferencedBean referencedBeanItem = readFacesReferencedBean(elementReader, context);
if (referencedBean == null) {
referencedBean = facesConfig.referencedBean;
if (referencedBean != null) {
referencedBean.clear();
} else {
referencedBean = new ArrayList<FacesReferencedBean>();
}
}
referencedBean.add(referencedBeanItem);
} else if (("render-kit" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: renderKit
final FacesRenderKit renderKitItem = readFacesRenderKit(elementReader, context);
if (renderKit == null) {
renderKit = facesConfig.renderKit;
if (renderKit != null) {
renderKit.clear();
} else {
renderKit = new ArrayList<FacesRenderKit>();
}
}
renderKit.add(renderKitItem);
} else if (("lifecycle" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: lifecycle
final FacesLifecycle lifecycleItem = readFacesLifecycle(elementReader, context);
if (lifecycle == null) {
lifecycle = facesConfig.lifecycle;
if (lifecycle != null) {
lifecycle.clear();
} else {
lifecycle = new ArrayList<FacesLifecycle>();
}
}
lifecycle.add(lifecycleItem);
} else if (("validator" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: validator
final FacesValidator validatorItem = readFacesValidator(elementReader, context);
if (validator == null) {
validator = facesConfig.validator;
if (validator != null) {
validator.clear();
} else {
validator = new ArrayList<FacesValidator>();
}
}
validator.add(validatorItem);
} else if (("behavior" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: behavior
final FacesBehavior behaviorItem = readFacesBehavior(elementReader, context);
if (behavior == null) {
behavior = facesConfig.behavior;
if (behavior != null) {
behavior.clear();
} else {
behavior = new ArrayList<FacesBehavior>();
}
}
behavior.add(behaviorItem);
} else if (("faces-config-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: facesConfigExtension
final FacesExtension facesConfigExtensionItem = readFacesExtension(elementReader, context);
if (facesConfigExtension == null) {
facesConfigExtension = facesConfig.facesConfigExtension;
if (facesConfigExtension != null) {
facesConfigExtension.clear();
} else {
facesConfigExtension = new ArrayList<FacesExtension>();
}
}
facesConfigExtension.add(facesConfigExtensionItem);
} else if ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI()) {
// just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
// TODO: read it if we need it (= classes to add to injectable classes, other file to parse to find them etc...)
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "application"), new QName("http://java.sun.com/xml/ns/javaee", "ordering"), new QName("http://java.sun.com/xml/ns/javaee", "absolute-ordering"), new QName("http://java.sun.com/xml/ns/javaee", "factory"), new QName("http://java.sun.com/xml/ns/javaee", "component"), new QName("http://java.sun.com/xml/ns/javaee", "converter"), new QName("http://java.sun.com/xml/ns/javaee", "managed-bean"), new QName("http://java.sun.com/xml/ns/javaee", "name"), new QName("http://java.sun.com/xml/ns/javaee", "navigation-rule"), new QName("http://java.sun.com/xml/ns/javaee", "referenced-bean"), new QName("http://java.sun.com/xml/ns/javaee", "render-kit"), new QName("http://java.sun.com/xml/ns/javaee", "lifecycle"), new QName("http://java.sun.com/xml/ns/javaee", "validator"), new QName("http://java.sun.com/xml/ns/javaee", "behavior"), new QName("http://java.sun.com/xml/ns/javaee", "faces-config-extension"));
}
}
if (application != null) {
facesConfig.application = application;
}
if (ordering != null) {
facesConfig.ordering = ordering;
}
if (absoluteOrdering != null) {
facesConfig.absoluteOrdering = absoluteOrdering;
}
if (factory != null) {
facesConfig.factory = factory;
}
if (component != null) {
facesConfig.component = component;
}
if (converter != null) {
facesConfig.converter = converter;
}
if (managedBean != null) {
facesConfig.managedBean = managedBean;
}
if (name != null) {
facesConfig.name = name;
}
if (navigationRule != null) {
facesConfig.navigationRule = navigationRule;
}
if (referencedBean != null) {
facesConfig.referencedBean = referencedBean;
}
if (renderKit != null) {
facesConfig.renderKit = renderKit;
}
if (lifecycle != null) {
facesConfig.lifecycle = lifecycle;
}
if (validator != null) {
facesConfig.validator = validator;
}
if (behavior != null) {
facesConfig.behavior = behavior;
}
if (facesConfigExtension != null) {
facesConfig.facesConfigExtension = facesConfigExtension;
}
context.afterUnmarshal(facesConfig, LifecycleCallback.NONE);
return facesConfig;
}
use of org.apache.openejb.jee.FacesValidator$JAXB.writeFacesValidator in project tomee by apache.
the class FacesApplication$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final FacesApplication facesApplication, RuntimeContext context) throws Exception {
if (facesApplication == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (FacesApplication.class != facesApplication.getClass()) {
context.unexpectedSubclass(writer, facesApplication, FacesApplication.class);
return;
}
context.beforeMarshal(facesApplication, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = facesApplication.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: actionListener
final List<String> actionListenerRaw = facesApplication.actionListener;
if (actionListenerRaw != null) {
for (final String actionListenerItem : actionListenerRaw) {
String actionListener = null;
try {
actionListener = Adapters.collapsedStringAdapterAdapter.marshal(actionListenerItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "actionListener", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (actionListener != null) {
writer.writeStartElement(prefix, "action-listener", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(actionListener);
writer.writeEndElement();
}
}
}
// ELEMENT: defaultRenderKitId
final List<String> defaultRenderKitIdRaw = facesApplication.defaultRenderKitId;
if (defaultRenderKitIdRaw != null) {
for (final String defaultRenderKitIdItem : defaultRenderKitIdRaw) {
String defaultRenderKitId = null;
try {
defaultRenderKitId = Adapters.collapsedStringAdapterAdapter.marshal(defaultRenderKitIdItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "defaultRenderKitId", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (defaultRenderKitId != null) {
writer.writeStartElement(prefix, "default-render-kit-id", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(defaultRenderKitId);
writer.writeEndElement();
}
}
}
// ELEMENT: messageBundle
final List<String> messageBundleRaw = facesApplication.messageBundle;
if (messageBundleRaw != null) {
for (final String messageBundleItem : messageBundleRaw) {
String messageBundle = null;
try {
messageBundle = Adapters.collapsedStringAdapterAdapter.marshal(messageBundleItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "messageBundle", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (messageBundle != null) {
writer.writeStartElement(prefix, "message-bundle", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(messageBundle);
writer.writeEndElement();
}
}
}
// ELEMENT: navigationHandler
final List<String> navigationHandlerRaw = facesApplication.navigationHandler;
if (navigationHandlerRaw != null) {
for (final String navigationHandlerItem : navigationHandlerRaw) {
String navigationHandler = null;
try {
navigationHandler = Adapters.collapsedStringAdapterAdapter.marshal(navigationHandlerItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "navigationHandler", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (navigationHandler != null) {
writer.writeStartElement(prefix, "navigation-handler", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(navigationHandler);
writer.writeEndElement();
}
}
}
// ELEMENT: viewHandler
final List<String> viewHandlerRaw = facesApplication.viewHandler;
if (viewHandlerRaw != null) {
for (final String viewHandlerItem : viewHandlerRaw) {
String viewHandler = null;
try {
viewHandler = Adapters.collapsedStringAdapterAdapter.marshal(viewHandlerItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "viewHandler", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (viewHandler != null) {
writer.writeStartElement(prefix, "view-handler", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(viewHandler);
writer.writeEndElement();
}
}
}
// ELEMENT: stateManager
final List<String> stateManagerRaw = facesApplication.stateManager;
if (stateManagerRaw != null) {
for (final String stateManagerItem : stateManagerRaw) {
String stateManager = null;
try {
stateManager = Adapters.collapsedStringAdapterAdapter.marshal(stateManagerItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "stateManager", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (stateManager != null) {
writer.writeStartElement(prefix, "state-manager", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(stateManager);
writer.writeEndElement();
}
}
}
// ELEMENT: elResolver
final List<String> elResolverRaw = facesApplication.elResolver;
if (elResolverRaw != null) {
for (final String elResolverItem : elResolverRaw) {
String elResolver = null;
try {
elResolver = Adapters.collapsedStringAdapterAdapter.marshal(elResolverItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "elResolver", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (elResolver != null) {
writer.writeStartElement(prefix, "el-resolver", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(elResolver);
writer.writeEndElement();
}
}
}
// ELEMENT: propertyResolver
final List<String> propertyResolverRaw = facesApplication.propertyResolver;
if (propertyResolverRaw != null) {
for (final String propertyResolverItem : propertyResolverRaw) {
String propertyResolver = null;
try {
propertyResolver = Adapters.collapsedStringAdapterAdapter.marshal(propertyResolverItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "propertyResolver", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (propertyResolver != null) {
writer.writeStartElement(prefix, "property-resolver", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(propertyResolver);
writer.writeEndElement();
}
}
}
// ELEMENT: variableResolver
final List<String> variableResolverRaw = facesApplication.variableResolver;
if (variableResolverRaw != null) {
for (final String variableResolverItem : variableResolverRaw) {
String variableResolver = null;
try {
variableResolver = Adapters.collapsedStringAdapterAdapter.marshal(variableResolverItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "variableResolver", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (variableResolver != null) {
writer.writeStartElement(prefix, "variable-resolver", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(variableResolver);
writer.writeEndElement();
}
}
}
// ELEMENT: resourceHandler
final List<String> resourceHandlerRaw = facesApplication.resourceHandler;
if (resourceHandlerRaw != null) {
for (final String resourceHandlerItem : resourceHandlerRaw) {
String resourceHandler = null;
try {
resourceHandler = Adapters.collapsedStringAdapterAdapter.marshal(resourceHandlerItem);
} catch (final Exception e) {
context.xmlAdapterError(facesApplication, "resourceHandler", CollapsedStringAdapter.class, List.class, List.class, e);
}
if (resourceHandler != null) {
writer.writeStartElement(prefix, "resource-handler", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(resourceHandler);
writer.writeEndElement();
}
}
}
// ELEMENT: systemEventListener
final List<FacesSystemEventListener> systemEventListener = facesApplication.systemEventListener;
if (systemEventListener != null) {
for (final FacesSystemEventListener systemEventListenerItem : systemEventListener) {
if (systemEventListenerItem != null) {
writer.writeStartElement(prefix, "system-event-listener", "http://java.sun.com/xml/ns/javaee");
writeFacesSystemEventListener(writer, systemEventListenerItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: localeConfig
final List<FacesLocaleConfig> localeConfig = facesApplication.localeConfig;
if (localeConfig != null) {
for (final FacesLocaleConfig localeConfigItem : localeConfig) {
if (localeConfigItem != null) {
writer.writeStartElement(prefix, "locale-config", "http://java.sun.com/xml/ns/javaee");
writeFacesLocaleConfig(writer, localeConfigItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: resourceBundle
final FacesApplicationResourceBundle resourceBundle = facesApplication.resourceBundle;
if (resourceBundle != null) {
writer.writeStartElement(prefix, "resource-bundle", "http://java.sun.com/xml/ns/javaee");
writeFacesApplicationResourceBundle(writer, resourceBundle, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(facesApplication, "resourceBundle");
}
// ELEMENT: applicationExtension
final List<FacesApplicationExtension> applicationExtension = facesApplication.applicationExtension;
if (applicationExtension != null) {
for (final FacesApplicationExtension applicationExtensionItem : applicationExtension) {
if (applicationExtensionItem != null) {
writer.writeStartElement(prefix, "application-extension", "http://java.sun.com/xml/ns/javaee");
writeFacesApplicationExtension(writer, applicationExtensionItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: defaultValidators
final List<FacesValidator> defaultValidators = facesApplication.defaultValidators;
if (defaultValidators != null) {
for (final FacesValidator defaultValidatorsItem : defaultValidators) {
if (defaultValidatorsItem != null) {
writer.writeStartElement(prefix, "default-validators", "http://java.sun.com/xml/ns/javaee");
writeFacesValidator(writer, defaultValidatorsItem, context);
writer.writeEndElement();
}
}
}
context.afterMarshal(facesApplication, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.FacesValidator$JAXB.writeFacesValidator in project tomee by apache.
the class FacesConfig$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final FacesConfig facesConfig, RuntimeContext context) throws Exception {
if (facesConfig == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (FacesConfig.class != facesConfig.getClass()) {
context.unexpectedSubclass(writer, facesConfig, FacesConfig.class);
return;
}
context.beforeMarshal(facesConfig, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = facesConfig.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConfig, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ATTRIBUTE: version
final String versionRaw = facesConfig.version;
if (versionRaw != null) {
String version = null;
try {
version = Adapters.collapsedStringAdapterAdapter.marshal(versionRaw);
} catch (final Exception e) {
context.xmlAdapterError(facesConfig, "version", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "version", version);
}
// ATTRIBUTE: metadataComplete
final Boolean metadataComplete = facesConfig.metadataComplete;
if (metadataComplete != null) {
writer.writeAttribute("", "", "metadata-complete", Boolean.toString(metadataComplete));
}
// ELEMENT: application
final List<FacesApplication> application = facesConfig.application;
if (application != null) {
for (final FacesApplication applicationItem : application) {
writer.writeStartElement(prefix, "application", "http://java.sun.com/xml/ns/javaee");
if (applicationItem != null) {
writeFacesApplication(writer, applicationItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: ordering
final List<FacesOrdering> ordering = facesConfig.ordering;
if (ordering != null) {
for (final FacesOrdering orderingItem : ordering) {
writer.writeStartElement(prefix, "ordering", "http://java.sun.com/xml/ns/javaee");
if (orderingItem != null) {
writeFacesOrdering(writer, orderingItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: absoluteOrdering
final List<FacesAbsoluteOrdering> absoluteOrdering = facesConfig.absoluteOrdering;
if (absoluteOrdering != null) {
for (final FacesAbsoluteOrdering absoluteOrderingItem : absoluteOrdering) {
if (absoluteOrderingItem != null) {
writer.writeStartElement(prefix, "absolute-ordering", "http://java.sun.com/xml/ns/javaee");
writeFacesAbsoluteOrdering(writer, absoluteOrderingItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: factory
final List<FacesFactory> factory = facesConfig.factory;
if (factory != null) {
for (final FacesFactory factoryItem : factory) {
writer.writeStartElement(prefix, "factory", "http://java.sun.com/xml/ns/javaee");
if (factoryItem != null) {
writeFacesFactory(writer, factoryItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: component
final List<FacesComponent> component = facesConfig.component;
if (component != null) {
for (final FacesComponent componentItem : component) {
writer.writeStartElement(prefix, "component", "http://java.sun.com/xml/ns/javaee");
if (componentItem != null) {
writeFacesComponent(writer, componentItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: converter
final List<FacesConverter> converter = facesConfig.converter;
if (converter != null) {
for (final FacesConverter converterItem : converter) {
writer.writeStartElement(prefix, "converter", "http://java.sun.com/xml/ns/javaee");
if (converterItem != null) {
writeFacesConverter(writer, converterItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: managedBean
final List<FacesManagedBean> managedBean = facesConfig.managedBean;
if (managedBean != null) {
for (final FacesManagedBean managedBeanItem : managedBean) {
if (managedBeanItem != null) {
writer.writeStartElement(prefix, "managed-bean", "http://java.sun.com/xml/ns/javaee");
writeFacesManagedBean(writer, managedBeanItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: name
final List<String> nameRaw = facesConfig.name;
if (nameRaw != null) {
for (final String nameItem : nameRaw) {
String name = null;
try {
name = Adapters.collapsedStringAdapterAdapter.marshal(nameItem);
} catch (final Exception e) {
context.xmlAdapterError(facesConfig, "name", CollapsedStringAdapter.class, List.class, List.class, e);
}
writer.writeStartElement(prefix, "name", "http://java.sun.com/xml/ns/javaee");
if (name != null) {
writer.writeCharacters(name);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: navigationRule
final List<FacesNavigationRule> navigationRule = facesConfig.navigationRule;
if (navigationRule != null) {
for (final FacesNavigationRule navigationRuleItem : navigationRule) {
if (navigationRuleItem != null) {
writer.writeStartElement(prefix, "navigation-rule", "http://java.sun.com/xml/ns/javaee");
writeFacesNavigationRule(writer, navigationRuleItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: referencedBean
final List<FacesReferencedBean> referencedBean = facesConfig.referencedBean;
if (referencedBean != null) {
for (final FacesReferencedBean referencedBeanItem : referencedBean) {
if (referencedBeanItem != null) {
writer.writeStartElement(prefix, "referenced-bean", "http://java.sun.com/xml/ns/javaee");
writeFacesReferencedBean(writer, referencedBeanItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: renderKit
final List<FacesRenderKit> renderKit = facesConfig.renderKit;
if (renderKit != null) {
for (final FacesRenderKit renderKitItem : renderKit) {
if (renderKitItem != null) {
writer.writeStartElement(prefix, "render-kit", "http://java.sun.com/xml/ns/javaee");
writeFacesRenderKit(writer, renderKitItem, context);
writer.writeEndElement();
}
}
}
// ELEMENT: lifecycle
final List<FacesLifecycle> lifecycle = facesConfig.lifecycle;
if (lifecycle != null) {
for (final FacesLifecycle lifecycleItem : lifecycle) {
writer.writeStartElement(prefix, "lifecycle", "http://java.sun.com/xml/ns/javaee");
if (lifecycleItem != null) {
writeFacesLifecycle(writer, lifecycleItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: validator
final List<FacesValidator> validator = facesConfig.validator;
if (validator != null) {
for (final FacesValidator validatorItem : validator) {
writer.writeStartElement(prefix, "validator", "http://java.sun.com/xml/ns/javaee");
if (validatorItem != null) {
writeFacesValidator(writer, validatorItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: behavior
final List<FacesBehavior> behavior = facesConfig.behavior;
if (behavior != null) {
for (final FacesBehavior behaviorItem : behavior) {
writer.writeStartElement(prefix, "behavior", "http://java.sun.com/xml/ns/javaee");
if (behaviorItem != null) {
writeFacesBehavior(writer, behaviorItem, context);
} else {
writer.writeXsiNil();
}
writer.writeEndElement();
}
}
// ELEMENT: facesConfigExtension
final List<FacesExtension> facesConfigExtension = facesConfig.facesConfigExtension;
if (facesConfigExtension != null) {
for (final FacesExtension facesConfigExtensionItem : facesConfigExtension) {
if (facesConfigExtensionItem != null) {
writer.writeStartElement(prefix, "faces-config-extension", "http://java.sun.com/xml/ns/javaee");
writeFacesExtension(writer, facesConfigExtensionItem, context);
writer.writeEndElement();
}
}
}
context.afterMarshal(facesConfig, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.FacesValidator$JAXB.writeFacesValidator in project tomee by apache.
the class FacesApplication$JAXB method _read.
public static final FacesApplication _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final FacesApplication facesApplication = new FacesApplication();
context.beforeUnmarshal(facesApplication, LifecycleCallback.NONE);
List<String> actionListener = null;
List<String> defaultRenderKitId = null;
List<String> messageBundle = null;
List<String> navigationHandler = null;
List<String> viewHandler = null;
List<String> stateManager = null;
List<String> elResolver = null;
List<String> propertyResolver = null;
List<String> variableResolver = null;
List<String> resourceHandler = null;
List<FacesSystemEventListener> systemEventListener = null;
List<FacesLocaleConfig> localeConfig = null;
List<FacesApplicationExtension> applicationExtension = null;
List<FacesValidator> defaultValidators = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("faces-config-applicationType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, FacesApplication.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, facesApplication);
facesApplication.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 (("action-listener" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: actionListener
final String actionListenerItemRaw = elementReader.getElementAsString();
final String actionListenerItem;
try {
actionListenerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(actionListenerItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (actionListener == null) {
actionListener = facesApplication.actionListener;
if (actionListener != null) {
actionListener.clear();
} else {
actionListener = new ArrayList<String>();
}
}
actionListener.add(actionListenerItem);
} else if (("default-render-kit-id" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: defaultRenderKitId
final String defaultRenderKitIdItemRaw = elementReader.getElementAsString();
final String defaultRenderKitIdItem;
try {
defaultRenderKitIdItem = Adapters.collapsedStringAdapterAdapter.unmarshal(defaultRenderKitIdItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (defaultRenderKitId == null) {
defaultRenderKitId = facesApplication.defaultRenderKitId;
if (defaultRenderKitId != null) {
defaultRenderKitId.clear();
} else {
defaultRenderKitId = new ArrayList<String>();
}
}
defaultRenderKitId.add(defaultRenderKitIdItem);
} else if (("message-bundle" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageBundle
final String messageBundleItemRaw = elementReader.getElementAsString();
final String messageBundleItem;
try {
messageBundleItem = Adapters.collapsedStringAdapterAdapter.unmarshal(messageBundleItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (messageBundle == null) {
messageBundle = facesApplication.messageBundle;
if (messageBundle != null) {
messageBundle.clear();
} else {
messageBundle = new ArrayList<String>();
}
}
messageBundle.add(messageBundleItem);
} else if (("navigation-handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: navigationHandler
final String navigationHandlerItemRaw = elementReader.getElementAsString();
final String navigationHandlerItem;
try {
navigationHandlerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(navigationHandlerItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (navigationHandler == null) {
navigationHandler = facesApplication.navigationHandler;
if (navigationHandler != null) {
navigationHandler.clear();
} else {
navigationHandler = new ArrayList<String>();
}
}
navigationHandler.add(navigationHandlerItem);
} else if (("view-handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: viewHandler
final String viewHandlerItemRaw = elementReader.getElementAsString();
final String viewHandlerItem;
try {
viewHandlerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(viewHandlerItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (viewHandler == null) {
viewHandler = facesApplication.viewHandler;
if (viewHandler != null) {
viewHandler.clear();
} else {
viewHandler = new ArrayList<String>();
}
}
viewHandler.add(viewHandlerItem);
} else if (("state-manager" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: stateManager
final String stateManagerItemRaw = elementReader.getElementAsString();
final String stateManagerItem;
try {
stateManagerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(stateManagerItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (stateManager == null) {
stateManager = facesApplication.stateManager;
if (stateManager != null) {
stateManager.clear();
} else {
stateManager = new ArrayList<String>();
}
}
stateManager.add(stateManagerItem);
} else if (("el-resolver" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: elResolver
final String elResolverItemRaw = elementReader.getElementAsString();
final String elResolverItem;
try {
elResolverItem = Adapters.collapsedStringAdapterAdapter.unmarshal(elResolverItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (elResolver == null) {
elResolver = facesApplication.elResolver;
if (elResolver != null) {
elResolver.clear();
} else {
elResolver = new ArrayList<String>();
}
}
elResolver.add(elResolverItem);
} else if (("property-resolver" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: propertyResolver
final String propertyResolverItemRaw = elementReader.getElementAsString();
final String propertyResolverItem;
try {
propertyResolverItem = Adapters.collapsedStringAdapterAdapter.unmarshal(propertyResolverItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (propertyResolver == null) {
propertyResolver = facesApplication.propertyResolver;
if (propertyResolver != null) {
propertyResolver.clear();
} else {
propertyResolver = new ArrayList<String>();
}
}
propertyResolver.add(propertyResolverItem);
} else if (("variable-resolver" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: variableResolver
final String variableResolverItemRaw = elementReader.getElementAsString();
final String variableResolverItem;
try {
variableResolverItem = Adapters.collapsedStringAdapterAdapter.unmarshal(variableResolverItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (variableResolver == null) {
variableResolver = facesApplication.variableResolver;
if (variableResolver != null) {
variableResolver.clear();
} else {
variableResolver = new ArrayList<String>();
}
}
variableResolver.add(variableResolverItem);
} else if (("resource-handler" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceHandler
final String resourceHandlerItemRaw = elementReader.getElementAsString();
final String resourceHandlerItem;
try {
resourceHandlerItem = Adapters.collapsedStringAdapterAdapter.unmarshal(resourceHandlerItemRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
if (resourceHandler == null) {
resourceHandler = facesApplication.resourceHandler;
if (resourceHandler != null) {
resourceHandler.clear();
} else {
resourceHandler = new ArrayList<String>();
}
}
resourceHandler.add(resourceHandlerItem);
} else if (("system-event-listener" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: systemEventListener
final FacesSystemEventListener systemEventListenerItem = readFacesSystemEventListener(elementReader, context);
if (systemEventListener == null) {
systemEventListener = facesApplication.systemEventListener;
if (systemEventListener != null) {
systemEventListener.clear();
} else {
systemEventListener = new ArrayList<FacesSystemEventListener>();
}
}
systemEventListener.add(systemEventListenerItem);
} else if (("locale-config" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: localeConfig
final FacesLocaleConfig localeConfigItem = readFacesLocaleConfig(elementReader, context);
if (localeConfig == null) {
localeConfig = facesApplication.localeConfig;
if (localeConfig != null) {
localeConfig.clear();
} else {
localeConfig = new ArrayList<FacesLocaleConfig>();
}
}
localeConfig.add(localeConfigItem);
} else if (("resource-bundle" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceBundle
final FacesApplicationResourceBundle resourceBundle = readFacesApplicationResourceBundle(elementReader, context);
facesApplication.resourceBundle = resourceBundle;
} else if (("application-extension" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: applicationExtension
final FacesApplicationExtension applicationExtensionItem = readFacesApplicationExtension(elementReader, context);
if (applicationExtension == null) {
applicationExtension = facesApplication.applicationExtension;
if (applicationExtension != null) {
applicationExtension.clear();
} else {
applicationExtension = new ArrayList<FacesApplicationExtension>();
}
}
applicationExtension.add(applicationExtensionItem);
} else if (("default-validators" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: defaultValidators
final FacesValidator defaultValidatorsItem = readFacesValidator(elementReader, context);
if (defaultValidators == null) {
defaultValidators = facesApplication.defaultValidators;
if (defaultValidators != null) {
defaultValidators.clear();
} else {
defaultValidators = new ArrayList<FacesValidator>();
}
}
defaultValidators.add(defaultValidatorsItem);
} else {
// just here ATM to not prevent users to get JSF 2.2 feature because we can't read it
// TODO: handle it properly
// context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "action-listener"), new QName("http://java.sun.com/xml/ns/javaee", "default-render-kit-id"), new QName("http://java.sun.com/xml/ns/javaee", "message-bundle"), new QName("http://java.sun.com/xml/ns/javaee", "navigation-handler"), new QName("http://java.sun.com/xml/ns/javaee", "view-handler"), new QName("http://java.sun.com/xml/ns/javaee", "state-manager"), new QName("http://java.sun.com/xml/ns/javaee", "el-resolver"), new QName("http://java.sun.com/xml/ns/javaee", "property-resolver"), new QName("http://java.sun.com/xml/ns/javaee", "variable-resolver"), new QName("http://java.sun.com/xml/ns/javaee", "resource-handler"), new QName("http://java.sun.com/xml/ns/javaee", "system-event-listener"), new QName("http://java.sun.com/xml/ns/javaee", "locale-config"), new QName("http://java.sun.com/xml/ns/javaee", "resource-bundle"), new QName("http://java.sun.com/xml/ns/javaee", "application-extension"), new QName("http://java.sun.com/xml/ns/javaee", "default-validators"));
}
}
if (actionListener != null) {
facesApplication.actionListener = actionListener;
}
if (defaultRenderKitId != null) {
facesApplication.defaultRenderKitId = defaultRenderKitId;
}
if (messageBundle != null) {
facesApplication.messageBundle = messageBundle;
}
if (navigationHandler != null) {
facesApplication.navigationHandler = navigationHandler;
}
if (viewHandler != null) {
facesApplication.viewHandler = viewHandler;
}
if (stateManager != null) {
facesApplication.stateManager = stateManager;
}
if (elResolver != null) {
facesApplication.elResolver = elResolver;
}
if (propertyResolver != null) {
facesApplication.propertyResolver = propertyResolver;
}
if (variableResolver != null) {
facesApplication.variableResolver = variableResolver;
}
if (resourceHandler != null) {
facesApplication.resourceHandler = resourceHandler;
}
if (systemEventListener != null) {
facesApplication.systemEventListener = systemEventListener;
}
if (localeConfig != null) {
facesApplication.localeConfig = localeConfig;
}
if (applicationExtension != null) {
facesApplication.applicationExtension = applicationExtension;
}
if (defaultValidators != null) {
facesApplication.defaultValidators = defaultValidators;
}
context.afterUnmarshal(facesApplication, LifecycleCallback.NONE);
return facesApplication;
}
Aggregations