Search in sources :

Example 1 with JMSPublishingTransportManager

use of org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager in project eclipselink by eclipse-ee4j.

the class SessionsFactory method buildJMSPublishingTransportManagerConfig.

/**
 * INTERNAL:
 */
protected void buildJMSPublishingTransportManagerConfig(JMSPublishingTransportManagerConfig tmConfig, RemoteCommandManager rcm) {
    JMSPublishingTransportManager tm = new JMSPublishingTransportManager(rcm);
    // Set the transport manager. This will initialize the DiscoveryManager
    rcm.setTransportManager(tm);
    processJMSTransportManagerConfig(tmConfig, tm);
}
Also used : JMSPublishingTransportManager(org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager)

Example 2 with JMSPublishingTransportManager

use of org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager in project eclipselink by eclipse-ee4j.

the class EntityManagerSetupImpl method updateCacheCoordination.

/**
 * Configure cache coordination using properties.
 */
protected void updateCacheCoordination(Map m, ClassLoader loader) {
    String protocol = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_PROTOCOL, m, this.session);
    String value = "";
    String property = "";
    try {
        if (protocol != null) {
            RemoteCommandManager rcm = new RemoteCommandManager(this.session);
            if (protocol.equalsIgnoreCase(CacheCoordinationProtocol.JGROUPS)) {
                property = PersistenceUnitProperties.COORDINATION_PROTOCOL;
                value = "org.eclipse.persistence.sessions.coordination.jgroups.JGroupsTransportManager";
                // Avoid compile and runtime dependency.
                Class<?> transportClass = findClassForProperty(value, PersistenceUnitProperties.COORDINATION_PROTOCOL, loader);
                TransportManager transport = (TransportManager) transportClass.getConstructor().newInstance();
                rcm.setTransportManager(transport);
                String config = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JGROUPS_CONFIG, m, this.session);
                if (config != null) {
                    transport.setConfig(config);
                }
            } else if (protocol.equalsIgnoreCase(CacheCoordinationProtocol.JMS) || protocol.equalsIgnoreCase(CacheCoordinationProtocol.JMSPublishing)) {
                JMSPublishingTransportManager transport = null;
                if (protocol.equalsIgnoreCase(CacheCoordinationProtocol.JMS)) {
                    transport = new JMSTopicTransportManager(rcm);
                } else {
                    transport = new JMSPublishingTransportManager(rcm);
                }
                rcm.setTransportManager(transport);
                String host = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JMS_HOST, m, this.session);
                if (host != null) {
                    transport.setTopicHostUrl(host);
                }
                String topic = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JMS_TOPIC, m, this.session);
                if (topic != null) {
                    transport.setTopicName(topic);
                }
                String factory = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JMS_FACTORY, m, this.session);
                if (factory != null) {
                    transport.setTopicConnectionFactoryName(factory);
                }
                String reuse_publisher = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JMS_REUSE_PUBLISHER, m, this.session);
                if (reuse_publisher != null) {
                    transport.setShouldReuseJMSTopicPublisher(reuse_publisher.equalsIgnoreCase("true"));
                }
            } else if (protocol.equalsIgnoreCase(CacheCoordinationProtocol.RMI) || protocol.equalsIgnoreCase(CacheCoordinationProtocol.RMIIIOP)) {
                if (protocol.equalsIgnoreCase(CacheCoordinationProtocol.RMIIIOP)) {
                    ((RMITransportManager) rcm.getTransportManager()).setIsRMIOverIIOP(true);
                }
                // Default protocol.
                String delay = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_RMI_ANNOUNCEMENT_DELAY, m, this.session);
                property = PersistenceUnitProperties.COORDINATION_RMI_ANNOUNCEMENT_DELAY;
                value = delay;
                if (delay != null) {
                    rcm.getDiscoveryManager().setAnnouncementDelay(Integer.parseInt(delay));
                }
                String multicast = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_RMI_MULTICAST_GROUP, m, this.session);
                if (multicast != null) {
                    rcm.getDiscoveryManager().setMulticastGroupAddress(multicast);
                }
                String port = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_RMI_MULTICAST_GROUP_PORT, m, this.session);
                property = PersistenceUnitProperties.COORDINATION_RMI_MULTICAST_GROUP_PORT;
                value = port;
                if (port != null) {
                    rcm.getDiscoveryManager().setMulticastPort(Integer.parseInt(port));
                }
                String timeToLive = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_RMI_PACKET_TIME_TO_LIVE, m, this.session);
                property = PersistenceUnitProperties.COORDINATION_RMI_PACKET_TIME_TO_LIVE;
                value = timeToLive;
                if (timeToLive != null) {
                    rcm.getDiscoveryManager().setPacketTimeToLive(Integer.parseInt(timeToLive));
                }
                String url = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_RMI_URL, m, this.session);
                if (url != null) {
                    rcm.setUrl(url);
                }
            } else {
                property = PersistenceUnitProperties.COORDINATION_PROTOCOL;
                value = protocol;
                Class<?> transportClass = findClassForProperty(protocol, PersistenceUnitProperties.COORDINATION_PROTOCOL, loader);
                rcm.setTransportManager((TransportManager) transportClass.getConstructor().newInstance());
            }
            String serializer = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_SERIALIZER, m, this.session);
            if (serializer != null) {
                property = PersistenceUnitProperties.COORDINATION_SERIALIZER;
                value = serializer;
                Class<?> transportClass = findClassForProperty(serializer, PersistenceUnitProperties.COORDINATION_SERIALIZER, loader);
                rcm.setSerializer((Serializer) transportClass.getConstructor().newInstance());
            }
            String naming = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_NAMING_SERVICE, m, this.session);
            if (naming != null) {
                if (naming.equalsIgnoreCase("jndi")) {
                    rcm.getTransportManager().setNamingServiceType(TransportManager.JNDI_NAMING_SERVICE);
                } else if (naming.equalsIgnoreCase("rmi")) {
                    rcm.getTransportManager().setNamingServiceType(TransportManager.REGISTRY_NAMING_SERVICE);
                }
            }
            String user = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JNDI_USER, m, this.session);
            if (user != null) {
                rcm.getTransportManager().setUserName(user);
            }
            String password = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JNDI_PASSWORD, m, this.session);
            if (password != null) {
                rcm.getTransportManager().setPassword(password);
            }
            String context = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_JNDI_CONTEXT, m, this.session);
            if (context != null) {
                rcm.getTransportManager().setInitialContextFactoryName(context);
            }
            String removeOnError = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_REMOVE_CONNECTION, m, this.session);
            if (removeOnError != null) {
                rcm.getTransportManager().setShouldRemoveConnectionOnError(removeOnError.equalsIgnoreCase("true"));
            }
            String asynch = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_ASYNCH, m, this.session);
            if (asynch != null) {
                rcm.setShouldPropagateAsynchronously(asynch.equalsIgnoreCase("true"));
            }
            String threadPoolSize = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_THREAD_POOL_SIZE, m, this.session);
            property = PersistenceUnitProperties.COORDINATION_THREAD_POOL_SIZE;
            value = threadPoolSize;
            if (threadPoolSize != null) {
                this.session.getServerPlatform().setThreadPoolSize(Integer.parseInt(threadPoolSize));
            }
            String channel = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.COORDINATION_CHANNEL, m, this.session);
            if (channel != null) {
                rcm.setChannel(channel);
            }
            this.session.setCommandManager(rcm);
            this.session.setShouldPropagateChanges(true);
        }
    } catch (ReflectiveOperationException | NumberFormatException exception) {
        this.session.handleException(ValidationException.invalidValueForProperty(value, property, exception));
    }
}
Also used : RMITransportManager(org.eclipse.persistence.sessions.coordination.rmi.RMITransportManager) JMSTopicTransportManager(org.eclipse.persistence.sessions.coordination.jms.JMSTopicTransportManager) RemoteCommandManager(org.eclipse.persistence.sessions.coordination.RemoteCommandManager) EntityManagerFactoryProvider.getConfigPropertyAsString(org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString) JMSTopicTransportManager(org.eclipse.persistence.sessions.coordination.jms.JMSTopicTransportManager) JMSPublishingTransportManager(org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager) TransportManager(org.eclipse.persistence.sessions.coordination.TransportManager) RMITransportManager(org.eclipse.persistence.sessions.coordination.rmi.RMITransportManager) JMSPublishingTransportManager(org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager)

Aggregations

JMSPublishingTransportManager (org.eclipse.persistence.sessions.coordination.jms.JMSPublishingTransportManager)2 EntityManagerFactoryProvider.getConfigPropertyAsString (org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString)1 RemoteCommandManager (org.eclipse.persistence.sessions.coordination.RemoteCommandManager)1 TransportManager (org.eclipse.persistence.sessions.coordination.TransportManager)1 JMSTopicTransportManager (org.eclipse.persistence.sessions.coordination.jms.JMSTopicTransportManager)1 RMITransportManager (org.eclipse.persistence.sessions.coordination.rmi.RMITransportManager)1