Search in sources :

Example 1 with JNDIRepositoryService

use of jp.ossc.nimbus.service.repository.JNDIRepositoryService 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.");
    }
}
Also used : JNDIRepositoryService(jp.ossc.nimbus.service.repository.JNDIRepositoryService) StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference)

Aggregations

Reference (javax.naming.Reference)1 StringRefAddr (javax.naming.StringRefAddr)1 JNDIRepositoryService (jp.ossc.nimbus.service.repository.JNDIRepositoryService)1