Search in sources :

Example 6 with ConfigProperty$JAXB.readConfigProperty

use of org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty in project tomee by apache.

the class ConnectionDefinition$JAXB method _read.

public static final ConnectionDefinition _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ConnectionDefinition connectionDefinition = new ConnectionDefinition();
    context.beforeUnmarshal(connectionDefinition, LifecycleCallback.NONE);
    List<ConfigProperty> configProperty = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("connection-definitionType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ConnectionDefinition.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, connectionDefinition);
            connectionDefinition.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 (("managedconnectionfactory-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: managedConnectionFactoryClass
            final String managedConnectionFactoryClassRaw = elementReader.getElementAsString();
            final String managedConnectionFactoryClass;
            try {
                managedConnectionFactoryClass = Adapters.collapsedStringAdapterAdapter.unmarshal(managedConnectionFactoryClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.managedConnectionFactoryClass = managedConnectionFactoryClass;
        } else if (("config-property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: configProperty
            final ConfigProperty configPropertyItem = readConfigProperty(elementReader, context);
            if (configProperty == null) {
                configProperty = connectionDefinition.configProperty;
                if (configProperty != null) {
                    configProperty.clear();
                } else {
                    configProperty = new ArrayList<ConfigProperty>();
                }
            }
            configProperty.add(configPropertyItem);
        } else if (("connectionfactory-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionFactoryInterface
            final String connectionFactoryInterfaceRaw = elementReader.getElementAsString();
            final String connectionFactoryInterface;
            try {
                connectionFactoryInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionFactoryInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionFactoryInterface = connectionFactoryInterface;
        } else if (("connectionfactory-impl-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionFactoryImplClass
            final String connectionFactoryImplClassRaw = elementReader.getElementAsString();
            final String connectionFactoryImplClass;
            try {
                connectionFactoryImplClass = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionFactoryImplClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionFactoryImplClass = connectionFactoryImplClass;
        } else if (("connection-interface" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionInterface
            final String connectionInterfaceRaw = elementReader.getElementAsString();
            final String connectionInterface;
            try {
                connectionInterface = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionInterfaceRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionInterface = connectionInterface;
        } else if (("connection-impl-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: connectionImplClass
            final String connectionImplClassRaw = elementReader.getElementAsString();
            final String connectionImplClass;
            try {
                connectionImplClass = Adapters.collapsedStringAdapterAdapter.unmarshal(connectionImplClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            connectionDefinition.connectionImplClass = connectionImplClass;
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "managedconnectionfactory-class"), new QName("http://java.sun.com/xml/ns/javaee", "config-property"), new QName("http://java.sun.com/xml/ns/javaee", "connectionfactory-interface"), new QName("http://java.sun.com/xml/ns/javaee", "connectionfactory-impl-class"), new QName("http://java.sun.com/xml/ns/javaee", "connection-interface"), new QName("http://java.sun.com/xml/ns/javaee", "connection-impl-class"));
        }
    }
    if (configProperty != null) {
        connectionDefinition.configProperty = configProperty;
    }
    context.afterUnmarshal(connectionDefinition, LifecycleCallback.NONE);
    return connectionDefinition;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ConfigProperty$JAXB.readConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty) ConfigProperty$JAXB.writeConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty) ArrayList(java.util.ArrayList) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 7 with ConfigProperty$JAXB.readConfigProperty

use of org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty in project tomee by apache.

the class ResourceAdapter$JAXB method _read.

public static final ResourceAdapter _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
    // Check for xsi:nil
    if (reader.isXsiNil()) {
        return null;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final ResourceAdapter resourceAdapter = new ResourceAdapter();
    context.beforeUnmarshal(resourceAdapter, LifecycleCallback.NONE);
    List<ConfigProperty> configProperty = null;
    List<AdminObject> adminObject = null;
    List<SecurityPermission> securityPermission = null;
    // Check xsi:type
    final QName xsiType = reader.getXsiType();
    if (xsiType != null) {
        if (("resourceadapterType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
            return context.unexpectedXsiType(reader, ResourceAdapter.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, resourceAdapter);
            resourceAdapter.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 (("resourceadapter-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: resourceAdapterClass
            final String resourceAdapterClassRaw = elementReader.getElementAsString();
            final String resourceAdapterClass;
            try {
                resourceAdapterClass = Adapters.collapsedStringAdapterAdapter.unmarshal(resourceAdapterClassRaw);
            } catch (final Exception e) {
                context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
                continue;
            }
            resourceAdapter.resourceAdapterClass = resourceAdapterClass;
        } else if (("config-property" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: configProperty
            final ConfigProperty configPropertyItem = readConfigProperty(elementReader, context);
            if (configProperty == null) {
                configProperty = resourceAdapter.configProperty;
                if (configProperty != null) {
                    configProperty.clear();
                } else {
                    configProperty = new ArrayList<ConfigProperty>();
                }
            }
            configProperty.add(configPropertyItem);
        } else if (("outbound-resourceadapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: outboundResourceAdapter
            final OutboundResourceAdapter outboundResourceAdapter = readOutboundResourceAdapter(elementReader, context);
            resourceAdapter.outboundResourceAdapter = outboundResourceAdapter;
        } else if (("inbound-resourceadapter" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: inboundResourceAdapter
            final InboundResourceadapter inboundResourceAdapter = readInboundResourceadapter(elementReader, context);
            resourceAdapter.inboundResourceAdapter = inboundResourceAdapter;
        } else if (("adminobject" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: adminObject
            final AdminObject adminObjectItem = readAdminObject(elementReader, context);
            if (adminObject == null) {
                adminObject = resourceAdapter.adminObject;
                if (adminObject != null) {
                    adminObject.clear();
                } else {
                    adminObject = new ArrayList<AdminObject>();
                }
            }
            adminObject.add(adminObjectItem);
        } else if (("security-permission" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
            // ELEMENT: securityPermission
            final SecurityPermission securityPermissionItem = readSecurityPermission(elementReader, context);
            if (securityPermission == null) {
                securityPermission = resourceAdapter.securityPermission;
                if (securityPermission != null) {
                    securityPermission.clear();
                } else {
                    securityPermission = new ArrayList<SecurityPermission>();
                }
            }
            securityPermission.add(securityPermissionItem);
        } else {
            context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "resourceadapter-class"), new QName("http://java.sun.com/xml/ns/javaee", "config-property"), new QName("http://java.sun.com/xml/ns/javaee", "outbound-resourceadapter"), new QName("http://java.sun.com/xml/ns/javaee", "inbound-resourceadapter"), new QName("http://java.sun.com/xml/ns/javaee", "adminobject"), new QName("http://java.sun.com/xml/ns/javaee", "security-permission"));
        }
    }
    if (configProperty != null) {
        resourceAdapter.configProperty = configProperty;
    }
    if (adminObject != null) {
        resourceAdapter.adminObject = adminObject;
    }
    if (securityPermission != null) {
        resourceAdapter.securityPermission = securityPermission;
    }
    context.afterUnmarshal(resourceAdapter, LifecycleCallback.NONE);
    return resourceAdapter;
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) Attribute(org.metatype.sxc.util.Attribute) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ConfigProperty$JAXB.readConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty) ConfigProperty$JAXB.writeConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty) OutboundResourceAdapter$JAXB.readOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.readOutboundResourceAdapter) OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) InboundResourceadapter$JAXB.readInboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter$JAXB.readInboundResourceadapter) InboundResourceadapter$JAXB.writeInboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter$JAXB.writeInboundResourceadapter) AdminObject$JAXB.readAdminObject(org.apache.openejb.jee.AdminObject$JAXB.readAdminObject) AdminObject$JAXB.writeAdminObject(org.apache.openejb.jee.AdminObject$JAXB.writeAdminObject) OutboundResourceAdapter$JAXB.readOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.readOutboundResourceAdapter) OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter) SecurityPermission$JAXB.writeSecurityPermission(org.apache.openejb.jee.SecurityPermission$JAXB.writeSecurityPermission) SecurityPermission$JAXB.readSecurityPermission(org.apache.openejb.jee.SecurityPermission$JAXB.readSecurityPermission) XoXMLStreamReader(org.metatype.sxc.util.XoXMLStreamReader)

Example 8 with ConfigProperty$JAXB.readConfigProperty

use of org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty in project tomee by apache.

the class ResourceAdapter$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ResourceAdapter resourceAdapter, RuntimeContext context) throws Exception {
    if (resourceAdapter == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ResourceAdapter.class != resourceAdapter.getClass()) {
        context.unexpectedSubclass(writer, resourceAdapter, ResourceAdapter.class);
        return;
    }
    context.beforeMarshal(resourceAdapter, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = resourceAdapter.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(resourceAdapter, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: resourceAdapterClass
    final String resourceAdapterClassRaw = resourceAdapter.resourceAdapterClass;
    String resourceAdapterClass = null;
    try {
        resourceAdapterClass = Adapters.collapsedStringAdapterAdapter.marshal(resourceAdapterClassRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(resourceAdapter, "resourceAdapterClass", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (resourceAdapterClass != null) {
        writer.writeStartElement(prefix, "resourceadapter-class", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(resourceAdapterClass);
        writer.writeEndElement();
    }
    // ELEMENT: configProperty
    final List<ConfigProperty> configProperty = resourceAdapter.configProperty;
    if (configProperty != null) {
        for (final ConfigProperty configPropertyItem : configProperty) {
            if (configPropertyItem != null) {
                writer.writeStartElement(prefix, "config-property", "http://java.sun.com/xml/ns/javaee");
                writeConfigProperty(writer, configPropertyItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: outboundResourceAdapter
    final OutboundResourceAdapter outboundResourceAdapter = resourceAdapter.outboundResourceAdapter;
    if (outboundResourceAdapter != null) {
        writer.writeStartElement(prefix, "outbound-resourceadapter", "http://java.sun.com/xml/ns/javaee");
        writeOutboundResourceAdapter(writer, outboundResourceAdapter, context);
        writer.writeEndElement();
    }
    // ELEMENT: inboundResourceAdapter
    final InboundResourceadapter inboundResourceAdapter = resourceAdapter.inboundResourceAdapter;
    if (inboundResourceAdapter != null) {
        writer.writeStartElement(prefix, "inbound-resourceadapter", "http://java.sun.com/xml/ns/javaee");
        writeInboundResourceadapter(writer, inboundResourceAdapter, context);
        writer.writeEndElement();
    }
    // ELEMENT: adminObject
    final List<AdminObject> adminObject = resourceAdapter.adminObject;
    if (adminObject != null) {
        for (final AdminObject adminObjectItem : adminObject) {
            if (adminObjectItem != null) {
                writer.writeStartElement(prefix, "adminobject", "http://java.sun.com/xml/ns/javaee");
                writeAdminObject(writer, adminObjectItem, context);
                writer.writeEndElement();
            }
        }
    }
    // ELEMENT: securityPermission
    final List<SecurityPermission> securityPermission = resourceAdapter.securityPermission;
    if (securityPermission != null) {
        for (final SecurityPermission securityPermissionItem : securityPermission) {
            if (securityPermissionItem != null) {
                writer.writeStartElement(prefix, "security-permission", "http://java.sun.com/xml/ns/javaee");
                writeSecurityPermission(writer, securityPermissionItem, context);
                writer.writeEndElement();
            }
        }
    }
    context.afterMarshal(resourceAdapter, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) ConfigProperty$JAXB.readConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty) ConfigProperty$JAXB.writeConfigProperty(org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext) InboundResourceadapter$JAXB.readInboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter$JAXB.readInboundResourceadapter) InboundResourceadapter$JAXB.writeInboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter$JAXB.writeInboundResourceadapter) OutboundResourceAdapter$JAXB.readOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.readOutboundResourceAdapter) OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter) AdminObject$JAXB.readAdminObject(org.apache.openejb.jee.AdminObject$JAXB.readAdminObject) AdminObject$JAXB.writeAdminObject(org.apache.openejb.jee.AdminObject$JAXB.writeAdminObject) SecurityPermission$JAXB.writeSecurityPermission(org.apache.openejb.jee.SecurityPermission$JAXB.writeSecurityPermission) SecurityPermission$JAXB.readSecurityPermission(org.apache.openejb.jee.SecurityPermission$JAXB.readSecurityPermission)

Example 9 with ConfigProperty$JAXB.readConfigProperty

use of org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty in project tomee by apache.

the class AppInfoBuilder method buildConnectorModules.

private void buildConnectorModules(final AppModule appModule, final AppInfo appInfo) throws OpenEJBException {
    final String appId = appModule.getModuleId();
    for (final ConnectorModule connectorModule : appModule.getConnectorModules()) {
        // 
        // DEVELOPERS NOTE:  if you change the id generation code here, you must change
        // the id generation code in AutoConfig$AppResources
        // 
        final Connector connector = connectorModule.getConnector();
        final ConnectorInfo connectorInfo = new ConnectorInfo();
        connectorInfo.description = connector.getDescription();
        connectorInfo.displayName = connector.getDisplayName();
        connectorInfo.path = connectorModule.getJarLocation();
        connectorInfo.moduleId = connectorModule.getModuleId();
        connectorInfo.watchedResources.addAll(connectorModule.getWatchedResources());
        connectorInfo.validationInfo = ValidatorBuilder.getInfo(connectorModule.getValidationConfig());
        connectorInfo.uniqueId = connectorModule.getUniqueId();
        connectorInfo.mbeans = connectorModule.getMbeans();
        final List<URL> libraries = connectorModule.getLibraries();
        for (final URL url : libraries) {
            final File file = toFile(url);
            try {
                connectorInfo.libs.add(file.getCanonicalPath());
            } catch (final IOException e) {
                throw new IllegalArgumentException("Invalid application lib path " + file.getAbsolutePath());
            }
        }
        final ResourceAdapter resourceAdapter = connector.getResourceAdapter();
        if (resourceAdapter.getResourceAdapterClass() != null) {
            final String id = this.getId(connectorModule);
            final String className = resourceAdapter.getResourceAdapterClass();
            final ServiceProvider provider = new ServiceProvider(className, id, "Resource");
            provider.getTypes().add(className);
            ServiceUtils.registerServiceProvider(appId, provider);
            final Resource resource = new Resource(id, className, appId + "#" + id);
            for (final ConfigProperty property : resourceAdapter.getConfigProperty()) {
                final String name = property.getConfigPropertyName();
                final String value = property.getConfigPropertyValue();
                if (value != null) {
                    resource.getProperties().setProperty(name, value);
                }
            }
            connectorInfo.resourceAdapter = this.configFactory.configureService(resource, ResourceInfo.class);
        }
        final OutboundResourceAdapter outbound = resourceAdapter.getOutboundResourceAdapter();
        if (outbound != null) {
            String transactionSupport = "none";
            final TransactionSupportType transactionSupportType = outbound.getTransactionSupport();
            if (transactionSupportType != null) {
                switch(transactionSupportType) {
                    case LOCAL_TRANSACTION:
                        transactionSupport = "local";
                        break;
                    case NO_TRANSACTION:
                        transactionSupport = "none";
                        break;
                    case XA_TRANSACTION:
                        transactionSupport = "xa";
                        break;
                }
            }
            for (final ConnectionDefinition connection : outbound.getConnectionDefinition()) {
                final String id = this.getId(connection, outbound, connectorModule);
                final String className = connection.getManagedConnectionFactoryClass();
                final String type = connection.getConnectionFactoryInterface();
                final ServiceProvider provider = new ServiceProvider(className, id, "Resource");
                provider.getTypes().add(type);
                ServiceUtils.registerServiceProvider(appId, provider);
                final Resource resource = new Resource(id, type, appId + "#" + id);
                final Properties properties = resource.getProperties();
                for (final ConfigProperty property : connection.getConfigProperty()) {
                    final String name = property.getConfigPropertyName();
                    final String value = property.getConfigPropertyValue();
                    if (value != null) {
                        properties.setProperty(name, value);
                    }
                }
                properties.setProperty("TransactionSupport", transactionSupport);
                if (connectorInfo.resourceAdapter != null) {
                    properties.setProperty("ResourceAdapter", connectorInfo.resourceAdapter.id);
                }
                final ResourceInfo resourceInfo = this.configFactory.configureService(resource, ResourceInfo.class);
                connectorInfo.outbound.add(resourceInfo);
            }
        }
        final InboundResourceadapter inbound = resourceAdapter.getInboundResourceAdapter();
        if (inbound != null) {
            for (final MessageListener messageListener : inbound.getMessageAdapter().getMessageListener()) {
                final String id = this.getId(messageListener, inbound, connectorModule);
                final Container container = new Container(id, "MESSAGE", null);
                final Properties properties = container.getProperties();
                properties.setProperty("ResourceAdapter", connectorInfo.resourceAdapter.id);
                properties.setProperty("MessageListenerInterface", messageListener.getMessageListenerType());
                properties.setProperty("ActivationSpecClass", messageListener.getActivationSpec().getActivationSpecClass());
                final MdbContainerInfo mdbContainerInfo = this.configFactory.configureService(container, MdbContainerInfo.class);
                connectorInfo.inbound.add(mdbContainerInfo);
            }
        }
        for (final AdminObject adminObject : resourceAdapter.getAdminObject()) {
            final String id = this.getId(adminObject, resourceAdapter, connectorModule);
            final String className = adminObject.getAdminObjectClass();
            final String type = adminObject.getAdminObjectInterface();
            final ServiceProvider provider = new ServiceProvider(className, id, "Resource");
            provider.getTypes().add(type);
            ServiceUtils.registerServiceProvider(appId, provider);
            final Resource resource = new Resource(id, type, appId + "#" + id);
            final Properties properties = resource.getProperties();
            for (final ConfigProperty property : adminObject.getConfigProperty()) {
                final String name = property.getConfigPropertyName();
                final String value = property.getConfigPropertyValue();
                if (value != null) {
                    properties.setProperty(name, value);
                }
            }
            final ResourceInfo resourceInfo = this.configFactory.configureService(resource, ResourceInfo.class);
            connectorInfo.adminObject.add(resourceInfo);
        }
        appInfo.connectors.add(connectorInfo);
    }
}
Also used : Connector(org.apache.openejb.jee.Connector) ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) ConnectionDefinition(org.apache.openejb.jee.ConnectionDefinition) ConnectorInfo(org.apache.openejb.assembler.classic.ConnectorInfo) TransactionSupportType(org.apache.openejb.jee.TransactionSupportType) Resource(org.apache.openejb.config.sys.Resource) MessageListener(org.apache.openejb.jee.MessageListener) IOException(java.io.IOException) Properties(java.util.Properties) URL(java.net.URL) Container(org.apache.openejb.config.sys.Container) ServiceProvider(org.apache.openejb.config.sys.ServiceProvider) ConfigProperty(org.apache.openejb.jee.ConfigProperty) MdbContainerInfo(org.apache.openejb.assembler.classic.MdbContainerInfo) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) InboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter) URLs.toFile(org.apache.openejb.util.URLs.toFile) File(java.io.File) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) AdminObject(org.apache.openejb.jee.AdminObject)

Example 10 with ConfigProperty$JAXB.readConfigProperty

use of org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty in project tomee by apache.

the class AnnotationDeployerTest method testConfigProperties.

@Test
public void testConfigProperties() throws Exception {
    final ClassFinder finder = new ClassFinder(TestAdminObject.class);
    final List<ConfigProperty> configProperty = new ArrayList<ConfigProperty>();
    final Object object = new Object() {

        public List<ConfigProperty> getConfigProperty() {
            return configProperty;
        }
    };
    new AnnotationDeployer.DiscoverAnnotatedBeans().process(null, TestAdminObject.class.getName(), object);
    Assert.assertEquals(2, configProperty.size());
    Assert.assertEquals("myNumber", configProperty.get(0).getConfigPropertyName());
    Assert.assertEquals("java.lang.Integer", configProperty.get(0).getConfigPropertyType());
    Assert.assertEquals("myProperty", configProperty.get(1).getConfigPropertyName());
    Assert.assertEquals("java.lang.String", configProperty.get(1).getConfigPropertyType());
    Assert.assertEquals("This is a test", configProperty.get(1).getConfigPropertyValue());
}
Also used : ConfigProperty(org.apache.openejb.jee.ConfigProperty) ClassFinder(org.apache.xbean.finder.ClassFinder) ArrayList(java.util.ArrayList) AdministeredObject(javax.resource.spi.AdministeredObject) Test(org.junit.Test)

Aggregations

CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)8 ConfigProperty$JAXB.readConfigProperty (org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty)8 ConfigProperty$JAXB.writeConfigProperty (org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty)8 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)8 ArrayList (java.util.ArrayList)4 QName (javax.xml.namespace.QName)4 ConfigProperty (org.apache.openejb.jee.ConfigProperty)3 Attribute (org.metatype.sxc.util.Attribute)3 XoXMLStreamReader (org.metatype.sxc.util.XoXMLStreamReader)3 AdminObject$JAXB.readAdminObject (org.apache.openejb.jee.AdminObject$JAXB.readAdminObject)2 AdminObject$JAXB.writeAdminObject (org.apache.openejb.jee.AdminObject$JAXB.writeAdminObject)2 ConnectionDefinition (org.apache.openejb.jee.ConnectionDefinition)2 Connector (org.apache.openejb.jee.Connector)2 InboundResourceadapter$JAXB.readInboundResourceadapter (org.apache.openejb.jee.InboundResourceadapter$JAXB.readInboundResourceadapter)2 InboundResourceadapter$JAXB.writeInboundResourceadapter (org.apache.openejb.jee.InboundResourceadapter$JAXB.writeInboundResourceadapter)2 OutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter)2 OutboundResourceAdapter$JAXB.readOutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter$JAXB.readOutboundResourceAdapter)2 OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter)2 RequiredConfigProperty$JAXB.readRequiredConfigProperty (org.apache.openejb.jee.RequiredConfigProperty$JAXB.readRequiredConfigProperty)2 RequiredConfigProperty$JAXB.writeRequiredConfigProperty (org.apache.openejb.jee.RequiredConfigProperty$JAXB.writeRequiredConfigProperty)2