Search in sources :

Example 1 with OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter

use of org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter in project tomee by apache.

the class ConnectorProxyNoNoArgConstructorTest method connector.

@Module
public Connector connector() {
    final ConnectionDefinition connectionDefinition = new ConnectionDefinition();
    connectionDefinition.setId("cf");
    connectionDefinition.setConnectionImplClass(MyCon.class.getName());
    connectionDefinition.setConnectionInterface(MyConAPI.class.getName());
    connectionDefinition.setConnectionFactoryImplClass(MyMcf.class.getName());
    connectionDefinition.setConnectionFactoryInterface(ConnectionFactory.class.getName());
    connectionDefinition.setManagedConnectionFactoryClass(MyMcf.class.getName());
    final OutboundResourceAdapter out = new OutboundResourceAdapter();
    out.getConnectionDefinition().add(connectionDefinition);
    final ResourceAdapter ra = new ResourceAdapter();
    ra.setResourceAdapterClass(MyRa.class.getName());
    ra.setOutboundResourceAdapter(out);
    final Connector connector = new Connector();
    connector.setVersion("1.7");
    connector.setResourceAdapter(ra);
    return connector;
}
Also used : Connector(org.apache.openejb.jee.Connector) ConnectionFactory(javax.resource.cci.ConnectionFactory) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) ConnectionDefinition(org.apache.openejb.jee.ConnectionDefinition) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) Module(org.apache.openejb.testing.Module)

Example 2 with OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter

use of org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter in project tomee by apache.

the class ConnectorProxyTest method connector.

@Module
public Connector connector() {
    final ConnectionDefinition connectionDefinition = new ConnectionDefinition();
    connectionDefinition.setId("cf");
    connectionDefinition.setConnectionImplClass(MyCon.class.getName());
    connectionDefinition.setConnectionInterface(MyConAPI.class.getName());
    connectionDefinition.setConnectionFactoryImplClass(MyMcf.class.getName());
    connectionDefinition.setConnectionFactoryInterface(ConnectionFactory.class.getName());
    connectionDefinition.setManagedConnectionFactoryClass(MyMcf.class.getName());
    final OutboundResourceAdapter out = new OutboundResourceAdapter();
    out.getConnectionDefinition().add(connectionDefinition);
    final ResourceAdapter ra = new ResourceAdapter();
    ra.setResourceAdapterClass(MyRa.class.getName());
    ra.setOutboundResourceAdapter(out);
    final Connector connector = new Connector();
    connector.setVersion("1.7");
    connector.setResourceAdapter(ra);
    return connector;
}
Also used : Connector(org.apache.openejb.jee.Connector) ConnectionFactory(javax.resource.cci.ConnectionFactory) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) ConnectionDefinition(org.apache.openejb.jee.ConnectionDefinition) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) Module(org.apache.openejb.testing.Module)

Example 3 with OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter

use of org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter in project tomee by apache.

the class GetterConnectorTest method connector.

@Module
public Connector connector() {
    final ConfigProperty configProperty = new ConfigProperty();
    configProperty.setConfigPropertyName("conf");
    configProperty.setConfigPropertyType(String.class.getName());
    configProperty.setConfigPropertyValue("GetterConnectorTest");
    final ConnectionDefinition connectionDefinition = new ConnectionDefinition();
    connectionDefinition.setConnectionFactoryImplClass(MyMcf.class.getName());
    connectionDefinition.setConnectionInterface(ConnectionFactory.class.getName());
    final OutboundResourceAdapter out = new OutboundResourceAdapter();
    out.getConnectionDefinition().add(connectionDefinition);
    final ResourceAdapter ra = new ResourceAdapter();
    ra.setResourceAdapterClass(MyRa.class.getName());
    ra.getConfigProperty().add(configProperty);
    final Connector connector = new Connector();
    connector.setVersion("1.7");
    connector.setResourceAdapter(ra);
    return connector;
}
Also used : Connector(org.apache.openejb.jee.Connector) ValidatingManagedConnectionFactory(javax.resource.spi.ValidatingManagedConnectionFactory) ConnectionFactory(javax.resource.cci.ConnectionFactory) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) ConnectionDefinition(org.apache.openejb.jee.ConnectionDefinition) ConfigProperty(org.apache.openejb.jee.ConfigProperty) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) OutboundResourceAdapter(org.apache.openejb.jee.OutboundResourceAdapter) Module(org.apache.openejb.testing.Module)

Example 4 with OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter

use of org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter 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 5 with OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter

use of org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter 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)

Aggregations

ConnectionDefinition (org.apache.openejb.jee.ConnectionDefinition)4 Connector (org.apache.openejb.jee.Connector)4 OutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter)4 ResourceAdapter (org.apache.openejb.jee.ResourceAdapter)4 ConnectionFactory (javax.resource.cci.ConnectionFactory)3 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 Module (org.apache.openejb.testing.Module)3 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)2 AdminObject$JAXB.readAdminObject (org.apache.openejb.jee.AdminObject$JAXB.readAdminObject)2 AdminObject$JAXB.writeAdminObject (org.apache.openejb.jee.AdminObject$JAXB.writeAdminObject)2 ConfigProperty (org.apache.openejb.jee.ConfigProperty)2 ConfigProperty$JAXB.readConfigProperty (org.apache.openejb.jee.ConfigProperty$JAXB.readConfigProperty)2 ConfigProperty$JAXB.writeConfigProperty (org.apache.openejb.jee.ConfigProperty$JAXB.writeConfigProperty)2 InboundResourceadapter$JAXB.readInboundResourceadapter (org.apache.openejb.jee.InboundResourceadapter$JAXB.readInboundResourceadapter)2 InboundResourceadapter$JAXB.writeInboundResourceadapter (org.apache.openejb.jee.InboundResourceadapter$JAXB.writeInboundResourceadapter)2 OutboundResourceAdapter$JAXB.readOutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter$JAXB.readOutboundResourceAdapter)2 OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter (org.apache.openejb.jee.OutboundResourceAdapter$JAXB.writeOutboundResourceAdapter)2 SecurityPermission$JAXB.readSecurityPermission (org.apache.openejb.jee.SecurityPermission$JAXB.readSecurityPermission)2 SecurityPermission$JAXB.writeSecurityPermission (org.apache.openejb.jee.SecurityPermission$JAXB.writeSecurityPermission)2 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)2