Search in sources :

Example 6 with ActivationConfigProperty

use of org.apache.openejb.jee.ActivationConfigProperty in project tomee by apache.

the class ActivationConfig$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ActivationConfig activationConfig, RuntimeContext context) throws Exception {
    if (activationConfig == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ActivationConfig.class != activationConfig.getClass()) {
        context.unexpectedSubclass(writer, activationConfig, ActivationConfig.class);
        return;
    }
    context.beforeMarshal(activationConfig, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = activationConfig.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(activationConfig, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = activationConfig.getDescriptions();
    } catch (final Exception e) {
        context.getterError(activationConfig, "descriptions", ActivationConfig.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(activationConfig, "descriptions");
            }
        }
    }
    // ELEMENT: activationConfigProperty
    final List<ActivationConfigProperty> activationConfigProperty = activationConfig.activationConfigProperty;
    if (activationConfigProperty != null) {
        for (final ActivationConfigProperty activationConfigPropertyItem : activationConfigProperty) {
            if (activationConfigPropertyItem != null) {
                writer.writeStartElement(prefix, "activation-config-property", "http://java.sun.com/xml/ns/javaee");
                writeActivationConfigProperty(writer, activationConfigPropertyItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(activationConfig, "activationConfigProperty");
            }
        }
    }
    context.afterMarshal(activationConfig, LifecycleCallback.NONE);
}
Also used : ActivationConfigProperty$JAXB.readActivationConfigProperty(org.apache.openejb.jee.ActivationConfigProperty$JAXB.readActivationConfigProperty) ActivationConfigProperty$JAXB.writeActivationConfigProperty(org.apache.openejb.jee.ActivationConfigProperty$JAXB.writeActivationConfigProperty) CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 7 with ActivationConfigProperty

use of org.apache.openejb.jee.ActivationConfigProperty in project tomee by apache.

the class OpenEjb2Conversion method convertMdbConfigs.

public final void convertMdbConfigs(final EjbJar ejbJar, final OpenejbJarType openejbJarType) {
    final Map<String, MessageDrivenBean> mdbs = new TreeMap<>();
    for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
        if (!(enterpriseBean instanceof MessageDrivenBean)) {
            continue;
        }
        mdbs.put(enterpriseBean.getEjbName(), (MessageDrivenBean) enterpriseBean);
    }
    for (final org.apache.openejb.jee.oejb2.EnterpriseBean enterpriseBean : openejbJarType.getEnterpriseBeans()) {
        if (!(enterpriseBean instanceof MessageDrivenBeanType)) {
            continue;
        }
        final MessageDrivenBeanType bean = (MessageDrivenBeanType) enterpriseBean;
        final MessageDrivenBean mdb = mdbs.get(bean.getEjbName());
        if (mdb == null) {
            // todo warn no such ejb in the ejb-jar.xml
            continue;
        }
        final ActivationConfigType activationConfigType = bean.getActivationConfig();
        if (activationConfigType != null) {
            ActivationConfig activationConfig = mdb.getActivationConfig();
            if (activationConfig == null) {
                activationConfig = new ActivationConfig();
                mdb.setActivationConfig(activationConfig);
            }
            for (final ActivationConfigPropertyType propertyType : activationConfigType.getActivationConfigProperty()) {
                final ActivationConfigProperty property = new ActivationConfigProperty(propertyType.getActivationConfigPropertyName(), propertyType.getActivationConfigPropertyValue());
                activationConfig.getActivationConfigProperty().add(property);
            }
        }
    }
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) MessageDrivenBeanType(org.apache.openejb.jee.oejb2.MessageDrivenBeanType) TreeMap(java.util.TreeMap) ActivationConfig(org.apache.openejb.jee.ActivationConfig) ActivationConfigProperty(org.apache.openejb.jee.ActivationConfigProperty) ActivationConfigPropertyType(org.apache.openejb.jee.oejb2.ActivationConfigPropertyType) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ActivationConfigType(org.apache.openejb.jee.oejb2.ActivationConfigType)

Aggregations

ActivationConfig (org.apache.openejb.jee.ActivationConfig)5 ActivationConfigProperty (org.apache.openejb.jee.ActivationConfigProperty)5 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)4 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)3 Properties (java.util.Properties)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 ActivationConfigProperty$JAXB.readActivationConfigProperty (org.apache.openejb.jee.ActivationConfigProperty$JAXB.readActivationConfigProperty)2 ActivationConfigProperty$JAXB.writeActivationConfigProperty (org.apache.openejb.jee.ActivationConfigProperty$JAXB.writeActivationConfigProperty)2 Text$JAXB.readText (org.apache.openejb.jee.Text$JAXB.readText)2 Text$JAXB.writeText (org.apache.openejb.jee.Text$JAXB.writeText)2 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)2 ResourceLink (org.apache.openejb.jee.oejb3.ResourceLink)2 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)1 QName (javax.xml.namespace.QName)1 MessageDrivenBeanInfo (org.apache.openejb.assembler.classic.MessageDrivenBeanInfo)1