List of usage examples for javax.naming Reference Reference
public Reference(String className, String factory, String factoryLocation)
From source file:org.nuxeo.runtime.datasource.DataSourceDescriptor.java
public void bindSelf(Context naming) throws NamingException { if (xaDataSource != null) { String xaName = DataSourceHelper.relativize(getName() + "-xa"); poolReference = new Reference(XADataSource.class.getName(), PoolFactory.class.getName(), null); poolReference.add(new StringRefAddr("dataSourceJNDI", xaName)); xaReference = new Reference(Framework.expandVars(xaDataSource), GenericNamingResourcesFactory.class.getName(), null); for (Entry<String, String> e : properties.entrySet()) { String key = e.getKey(); String value = Framework.expandVars(e.getValue()); StringRefAddr addr = new StringRefAddr(key, value); xaReference.add(addr);/*from w w w . ja va 2s . c om*/ } naming.bind(DataSourceHelper.getDataSourceJNDIName(xaName), xaReference); } else if (dataSource != null) { poolReference = new Reference(DataSource.class.getName(), PoolFactory.class.getName(), null); final String name = Framework.expandVars(dataSource); poolReference.add(new StringRefAddr("dataSourceJNDI", DataSourceHelper.getDataSourceJNDIName(name))); } else if (driverClasssName != null) { poolReference = new Reference(DataSource.class.getName(), PoolFactory.class.getName(), null); } else { throw new RuntimeException( "Datasource " + getName() + " should have xaDataSource or driverClassName attribute"); } for (Entry<String, String> e : properties.entrySet()) { String key = e.getKey(); String value = Framework.expandVars(e.getValue()); StringRefAddr addr = new StringRefAddr(key, value); poolReference.add(addr); } NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); String attrName = attr.getNodeName(); String value = Framework.expandVars(attr.getNodeValue()); StringRefAddr addr = new StringRefAddr(attrName, value); poolReference.add(addr); } LogFactory.getLog(DataSourceDescriptor.class).info("binding " + getName()); String jndiName = DataSourceHelper.getDataSourceJNDIName(getName()); naming.bind(jndiName, poolReference); // create pooled naming.lookup(jndiName); }
From source file:org.nuxeo.runtime.jtajca.NuxeoContainer.java
/** * Install naming and bind transaction and connection management factories "by hand". *//* w w w .jav a 2 s . c om*/ protected static void install() throws NamingException { if (installContext != null) { throw new RuntimeException("Nuxeo container already installed"); } installContext = new InstallContext(); log.trace("Installing nuxeo container", installContext); rootContext = new NamingContext(); parentContext = InitialContextAccessor.getInitialContext(); if (parentContext != null && parentContext != rootContext) { installTransactionManager(parentContext); } else { addDeepBinding(nameOf("TransactionManager"), new Reference(TransactionManager.class.getName(), NuxeoTransactionManagerFactory.class.getName(), null)); installTransactionManager(rootContext); } }
From source file:org.sonar.server.database.JndiDatabaseConnector.java
private Reference createDatasourceReference() { try {/*from ww w . jav a2 s .co m*/ Reference ref = new Reference(DataSource.class.getName(), UniqueDatasourceFactory.class.getName(), null); Configuration dsConfig = getConfiguration().subset("sonar.jdbc"); for (Iterator<String> it = dsConfig.getKeys(); it.hasNext();) { String key = it.next(); String value = dsConfig.getString(key); ref.add(new StringRefAddr(key, value)); // backward compatibility if (value != null && key.equals("user")) { ref.add(new StringRefAddr("username", value)); } if (value != null && key.equals("driver")) { ref.add(new StringRefAddr("driverClassName", value)); } } return ref; } catch (Exception e) { throw new RuntimeException("Cannot create the JDBC datasource", e); } }
From source file:org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource.java
public Reference getDataSourceFactoryReference() throws DataSourceException { if (dataSourceFactoryReference == null) { dataSourceFactoryReference = new Reference("org.apache.tomcat.jdbc.pool.DataSource", "org.apache.tomcat.jdbc.pool.DataSourceFactory", null); Map<String, String> poolConfigMap = RDBMSDataSourceUtils .extractPrimitiveFieldNameValuePairs(poolProperties); Iterator<Entry<String, String>> poolConfigMapIterator = poolConfigMap.entrySet().iterator(); while (poolConfigMapIterator.hasNext()) { Entry<String, String> pairs = poolConfigMapIterator.next(); dataSourceFactoryReference.add(new StringRefAddr(pairs.getKey(), pairs.getValue())); }//from ww w.jav a 2s . co m } return dataSourceFactoryReference; }