use of javax.naming.StringRefAddr in project h2database by h2database.
the class JdbcDataSource method getReference.
/**
* Get a new reference for this object, using the current settings.
*
* @return the new reference
*/
@Override
public Reference getReference() {
debugCodeCall("getReference");
String factoryClassName = JdbcDataSourceFactory.class.getName();
Reference ref = new Reference(getClass().getName(), factoryClassName, null);
ref.add(new StringRefAddr("url", url));
ref.add(new StringRefAddr("user", userName));
ref.add(new StringRefAddr("password", convertToString(passwordChars)));
ref.add(new StringRefAddr("loginTimeout", String.valueOf(loginTimeout)));
ref.add(new StringRefAddr("description", description));
return ref;
}
use of javax.naming.StringRefAddr in project nimbus by nimbus-org.
the class WrappedDataSourceService method startService.
/**
* 開始処理を行う。<p>
*
* @exception Exception 開始処理に失敗した場合
*/
public void startService() throws Exception {
if (sourceJNDIName == null) {
throw new IllegalArgumentException("SourceJNDIName is null.");
}
if (wrappedJNDIName == null) {
throw new IllegalArgumentException("WrappedJNDIName is null.");
}
if (jndiRepositoryServiceName != null) {
jndiRepository = (Repository) ServiceManagerFactory.getServiceObject(jndiRepositoryServiceName);
}
if (jndiRepository == null) {
JNDIRepositoryService jndiRepositoryService = new JNDIRepositoryService();
jndiRepositoryService.create();
jndiRepositoryService.start();
jndiRepository = jndiRepositoryService;
}
if (getConnectionWrapperClassName() != null) {
connectionWrapperClass = Class.forName(getConnectionWrapperClassName(), true, NimbusClassLoader.getInstance());
}
if (connectionWrapperProperties != null && connectionWrapperProperties.size() != 0) {
properties = new LinkedHashMap();
final Iterator props = connectionWrapperProperties.keySet().iterator();
while (props.hasNext()) {
final String propName = (String) props.next();
final Object val = connectionWrapperProperties.get(propName);
final Property property = PropertyFactory.createProperty(propName);
properties.put(property, val);
}
}
if (getSourceDataSource() == null) {
throw new IllegalArgumentException("SourceJNDIName can not get from JNDIRepository.");
}
StringRefAddr addr = new StringRefAddr("nimbus/service", getServiceNameObject().toString());
reference = new Reference(getClass().getName(), addr, WrappedDataSourceObjectFactory.class.getName(), null);
if (!jndiRepository.register(wrappedJNDIName, reference)) {
throw new IllegalArgumentException("WrappedJNDIName can not register to JNDIRepository.");
}
}
use of javax.naming.StringRefAddr in project derby by apache.
the class ClientDataSource method addBeanProperties.
/**
* Add Java Bean properties to the reference using
* StringRefAddr for each property. List of bean properties
* is defined from the public getXXX() methods on this object
* that take no arguments and return short, int, boolean or String.
* The StringRefAddr has a key of the Java bean property name,
* converted from the method name. E.g. traceDirectory for
* traceDirectory.
*
* @param ref The referenced object
*/
private void addBeanProperties(Reference ref) {
Properties p = getProperties(this);
Enumeration<?> e = p.propertyNames();
while (e.hasMoreElements()) {
String propName = (String) e.nextElement();
Object value = p.getProperty(propName);
if (value != null) {
ref.add(new StringRefAddr(propName, value.toString()));
}
}
}
use of javax.naming.StringRefAddr in project jaybird by FirebirdSQL.
the class FBAbstractCommonDataSource method updateReference.
/**
* Updates the supplied reference with RefAddr properties relevant to this class.
*
* @param ref Reference to update
* @param instance Instance of this class to obtain values
*/
protected static void updateReference(Reference ref, FBAbstractCommonDataSource instance) {
synchronized (instance.lock) {
ref.add(new StringRefAddr(REF_DESCRIPTION, instance.getDescription()));
ref.add(new StringRefAddr(REF_SERVER_NAME, instance.getServerName()));
if (instance.getPortNumber() != 0) {
ref.add(new StringRefAddr(REF_PORT_NUMBER, Integer.toString(instance.getPortNumber())));
}
ref.add(new StringRefAddr(REF_DATABASE_NAME, instance.getDatabaseName()));
byte[] data = DataSourceFactory.serialize(instance.connectionProperties);
ref.add(new BinaryRefAddr(REF_PROPERTIES, data));
}
}
use of javax.naming.StringRefAddr in project activemq-artemis by apache.
the class JNDIReferenceFactory method createReference.
/**
* Create a Reference instance from a JNDIStorable object
*
* @param instanceClassName
* The name of the class that is being created.
* @param po
* The properties object to use when configuring the new instance.
*
* @return Reference
*
* @throws NamingException if an error occurs while creating the new instance.
*/
public static Reference createReference(String instanceClassName, JNDIStorable po) throws NamingException {
Reference result = new Reference(instanceClassName, JNDIReferenceFactory.class.getName(), null);
try {
Properties props = po.getProperties();
for (Enumeration iter = props.propertyNames(); iter.hasMoreElements(); ) {
String key = (String) iter.nextElement();
result.add(new StringRefAddr(key, props.getProperty(key)));
}
} catch (Exception e) {
throw new NamingException(e.getMessage());
}
return result;
}
Aggregations