001    package org.otfeed.j2ee.ra;
002    
003    import javax.resource.spi.ConnectionRequestInfo;
004    
005    import org.otfeed.OTConnectionSpec;
006    
007    public final class OtfeedConnectionRequestInfo extends OTConnectionSpec implements ConnectionRequestInfo {
008    
009            private static final long serialVersionUID = 4025396785700012294L;
010            
011            public static OtfeedConnectionRequestInfo merge(OTConnectionSpec major, OTConnectionSpec minor) {
012                    OtfeedConnectionRequestInfo out = new OtfeedConnectionRequestInfo();
013                    
014                    if(major.getUsername() != null) {
015                            out.setUsername(major.getUsername());
016                    } else {
017                            out.setUsername(minor.getUsername());
018                    }
019                    
020                    if(major.getPassword() != null) {
021                            out.setPassword(major.getPassword());
022                    } else {
023                            out.setPassword(minor.getPassword());
024                    }
025    
026                    if(major.getHostsString() != null) {
027                            out.setHostsString(major.getHostsString());
028                    } else {
029                            out.setHostsString(minor.getHostsString());
030                    }
031                    
032                    if(major.getHeartbeatInterval() != null) {
033                            out.setHeartbeatInterval(major.getHeartbeatInterval());
034                    } else {
035                            out.setHeartbeatInterval(minor.getHeartbeatInterval());
036                    }
037    
038                    return out;
039            }
040    }