Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  * implied.
  *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.ops4j.pax.jdbc.pool.aries.impl;
 
 
Watches for DataSourceFactory services and creates/destroys a PooledDataSourceFactory for each existing DataSourceFactory
 
 public class DataSourceFactoryTracker extends
 
     private Logger LOG = LoggerFactory.getLogger(DataSourceFactoryTracker.class);
 
     private AriesTransactionManager tm;
 
     public DataSourceFactoryTracker(BundleContext context) {
         this(contextnull);
     }
 
         super(contextDataSourceFactory.classnull);
         this. = tm;
     }
 
     @Override
         ServiceReference<DataSourceFactoryreference) {
         if (reference.getProperty("pooled") != null) {
             // Make sure we do not react on our own service for the pooled factory
             return null;
         }
         DataSourceFactory dsf = .getService(reference);
         PooledDataSourceFactory pdsf = new PooledDataSourceFactory(dsf);
         Dictionary<StringObjectprops = createPropsForPoolingDataSourceFactory(reference);
         .debug("Registering PooledDataSourceFactory: " + props);
         return .registerService(DataSourceFactory.classpdsfprops);
     }
 
         ServiceReference<DataSourceFactoryreference) {
         Dictionary<StringObjectprops = new Hashtable<StringObject>();
         for (String key : reference.getPropertyKeys()) {
             if (!"service.id".equals(key)) {
                 props.put(keyreference.getProperty(key));
             }
         }
         props.put("pooled""true");
         if ( != null) {
             props.put("xa""true");
         }
         props.put(.getPoolDriverName(reference));
         return props;
     }
 
     private String getPoolDriverName(ServiceReference<DataSourceFactoryreference) {
         String origName = (Stringreference.getProperty(.);
         if (origName == null) {
             origName = (Stringreference.getProperty(.);
         }
         return origName + "-pool" + (( != null) ? "-xa" : "");
     }
 
     @Override
     public void modifiedService(ServiceReference<DataSourceFactoryreference,
         ServiceRegistration<DataSourceFactoryservice) {
 
     }
 
     @Override
     public void removedService(ServiceReference<DataSourceFactoryreference,
         ServiceRegistration<DataSourceFactoryservice) {
         .debug("Unregistering PooledDataSourceFactory: " + createPropsForPoolingDataSourceFactory(reference));
         service.unregister();
        .ungetService(reference);
    }
New to GrepCode? Check out our FAQ X