use of javax.naming.StringRefAddr in project tomcat by apache.
the class SharedPoolDataSource method getReference.
/**
* Creates a new {@link Reference} to a {@link SharedPoolDataSource}.
*/
@Override
public Reference getReference() throws NamingException {
final Reference ref = new Reference(getClass().getName(), SharedPoolDataSourceFactory.class.getName(), null);
ref.add(new StringRefAddr("instanceKey", getInstanceKey()));
return ref;
}
use of javax.naming.StringRefAddr in project druid by alibaba.
the class DruidDataSource method getReference.
public Reference getReference() throws NamingException {
final String className = getClass().getName();
// XXX: not robust
final String factoryName = className + "Factory";
Reference ref = new Reference(className, factoryName, null);
ref.add(new StringRefAddr("instanceKey", instanceKey));
ref.add(new StringRefAddr("url", this.getUrl()));
ref.add(new StringRefAddr("username", this.getUsername()));
ref.add(new StringRefAddr("password", this.getPassword()));
// TODO ADD OTHER PROPERTIES
return ref;
}
use of javax.naming.StringRefAddr in project druid by alibaba.
the class DruidDataSourceFactoryTest method test_factory.
public void test_factory() throws Exception {
DruidDataSourceFactory factory = new DruidDataSourceFactory();
Reference ref = new Reference(DataSource.class.getName());
ref.add(new StringRefAddr(DruidDataSourceFactory.PROP_REMOVEABANDONED, "true"));
ref.add(new StringRefAddr(DruidDataSourceFactory.PROP_MAXACTIVE, "20"));
Hashtable<String, String> env = new Hashtable<String, String>();
dataSource = (DruidDataSource) factory.getObjectInstance(ref, null, null, env);
Assert.assertTrue(dataSource.isRemoveAbandoned());
Assert.assertEquals(20, dataSource.getMaxActive());
}
use of javax.naming.StringRefAddr in project jackrabbit by apache.
the class RegistryHelper method registerRepository.
/**
* Binds a configured repository to the given JNDI context.
* This method creates a {@link BindableRepository BindableRepository}
* instance using the given configuration information, and binds
* it to the given JNDI context.
*
* @param ctx context where the repository should be registered (i.e. bound)
* @param name the name to register the repository with
* @param configFilePath path to the configuration file of the repository
* @param repHomeDir repository home directory
* @param overwrite if <code>true</code>, any existing binding with the given
* name will be overwritten; otherwise a <code>NamingException</code> will
* be thrown if the name is already bound
* @throws RepositoryException if the repository cannot be created
* @throws NamingException if the repository cannot be registered in JNDI
*/
public static void registerRepository(Context ctx, String name, String configFilePath, String repHomeDir, boolean overwrite) throws NamingException, RepositoryException {
Reference reference = new Reference(Repository.class.getName(), BindableRepositoryFactory.class.getName(), // no classpath defined
null);
reference.add(new StringRefAddr(BindableRepository.CONFIGFILEPATH_ADDRTYPE, configFilePath));
reference.add(new StringRefAddr(BindableRepository.REPHOMEDIR_ADDRTYPE, repHomeDir));
// always create instance by using BindableRepositoryFactory
// which maintains an instance cache;
// see http://issues.apache.org/jira/browse/JCR-411 for details
Object obj = new BindableRepositoryFactory().getObjectInstance(reference, null, null, null);
if (overwrite) {
ctx.rebind(name, obj);
} else {
ctx.bind(name, obj);
}
}
use of javax.naming.StringRefAddr in project wildfly by wildfly.
the class NamingContextTestCase method testLookupReference.
@Test
public void testLookupReference() throws Exception {
final Name name = new CompositeName("test");
final Reference reference = new Reference(String.class.getName(), new StringRefAddr("blah", "test"), TestObjectFactory.class.getName(), null);
namingStore.bind(name, reference);
Object result = namingContext.lookup(name);
assertEquals("test", result);
// the same with security permissions
result = testActionPermission(JndiPermission.ACTION_LOOKUP, namingContext, "test");
assertEquals("test", result);
}
Aggregations