use of javax.naming.RefAddr in project tomcat by apache.
the class PerUserPoolDataSourceFactory method getNewInstance.
// Avoid warnings on deserialization
@SuppressWarnings("unchecked")
@Override
protected InstanceKeyDataSource getNewInstance(final Reference ref) throws IOException, ClassNotFoundException {
final PerUserPoolDataSource pupds = new PerUserPoolDataSource();
RefAddr refAddr = ref.get("defaultMaxTotal");
if (refAddr != null && refAddr.getContent() != null) {
pupds.setDefaultMaxTotal(parseInt(refAddr));
}
refAddr = ref.get("defaultMaxIdle");
if (refAddr != null && refAddr.getContent() != null) {
pupds.setDefaultMaxIdle(parseInt(refAddr));
}
refAddr = ref.get("defaultMaxWaitMillis");
if (refAddr != null && refAddr.getContent() != null) {
pupds.setDefaultMaxWait(Duration.ofMillis(parseInt(refAddr)));
}
refAddr = ref.get("perUserDefaultAutoCommit");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserDefaultAutoCommit((Map<String, Boolean>) deserialize(serialized));
}
refAddr = ref.get("perUserDefaultTransactionIsolation");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserDefaultTransactionIsolation((Map<String, Integer>) deserialize(serialized));
}
refAddr = ref.get("perUserMaxTotal");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserMaxTotal((Map<String, Integer>) deserialize(serialized));
}
refAddr = ref.get("perUserMaxIdle");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserMaxIdle((Map<String, Integer>) deserialize(serialized));
}
refAddr = ref.get("perUserMaxWaitMillis");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserMaxWaitMillis((Map<String, Long>) deserialize(serialized));
}
refAddr = ref.get("perUserDefaultReadOnly");
if (refAddr != null && refAddr.getContent() != null) {
final byte[] serialized = (byte[]) refAddr.getContent();
pupds.setPerUserDefaultReadOnly((Map<String, Boolean>) deserialize(serialized));
}
return pupds;
}
use of javax.naming.RefAddr in project tomcat by apache.
the class SharedPoolDataSourceFactory method getNewInstance.
@Override
protected InstanceKeyDataSource getNewInstance(final Reference ref) {
final SharedPoolDataSource spds = new SharedPoolDataSource();
final RefAddr ra = ref.get("maxTotal");
if (ra != null && ra.getContent() != null) {
spds.setMaxTotal(Integer.parseInt(ra.getContent().toString()));
}
return spds;
}
use of javax.naming.RefAddr in project druid by alibaba.
the class DruidDataSourceFactoryTest method test_factory.
@SuppressWarnings("serial")
public void test_factory() throws Exception {
DruidDataSourceFactory factory = new DruidDataSourceFactory();
Assert.assertNull(factory.getObjectInstance(null, null, null, null));
Assert.assertNull(factory.getObjectInstance(new Reference("javax.sql.Date"), null, null, null));
Reference ref = new Reference("javax.sql.DataSource");
ref.add(new RefAddr("user") {
@Override
public Object getContent() {
return null;
}
});
ref.add(new RefAddr("defaultReadOnly") {
@Override
public Object getContent() {
return Boolean.TRUE;
}
});
factory.getObjectInstance(ref, null, null, new Hashtable<Object, Object>());
}
use of javax.naming.RefAddr in project rabbitmq-jms-client by rabbitmq.
the class RMQConnectionFactoryTest method removeRefProperty.
/**
* Remove property from a Reference (as a RefAddr)
*
* @param ref - the reference
* @param propertyName - the name of the property to remove
*/
private static void removeRefProperty(Reference ref, String propertyName) {
if (propertyName == null)
return;
int numProps = ref.size();
for (int i = 0; i < numProps; ++i) {
RefAddr ra = ref.get(i);
if (ra.getType().equals(propertyName)) {
ref.remove(i--);
numProps--;
}
}
}
Aggregations