View Javadoc

1   package org.apache.maven.continuum.management.redback;
2   
3   import org.apache.maven.continuum.management.DatabaseFactoryConfigurator;
4   import org.apache.maven.continuum.management.DatabaseParams;
5   import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
6   
7   import java.util.Iterator;
8   import java.util.Properties;
9   
10  /*
11   * Licensed to the Apache Software Foundation (ASF) under one
12   * or more contributor license agreements.  See the NOTICE file
13   * distributed with this work for additional information
14   * regarding copyright ownership.  The ASF licenses this file
15   * to you under the Apache License, Version 2.0 (the
16   * "License"); you may not use this file except in compliance
17   * with the License.  You may obtain a copy of the License at
18   *
19   *   http://www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing,
22   * software distributed under the License is distributed on an
23   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24   * KIND, either express or implied.  See the License for the
25   * specific language governing permissions and limitations
26   * under the License.
27   */
28  
29  /**
30   * @version $Id: DefaultDatabaseFactoryConfigurator.java 729479 2008-12-26 10:52:45Z olamy $
31   * @plexus.component role="org.apache.maven.continuum.management.DatabaseFactoryConfigurator" role-hint="redback"
32   */
33  public class DefaultDatabaseFactoryConfigurator
34      implements DatabaseFactoryConfigurator
35  {
36      /**
37       * @plexus.requirement role="org.codehaus.plexus.jdo.JdoFactory" role-hint="users"
38       */
39      protected DefaultConfigurableJdoFactory factory;
40  
41      public void configure( DatabaseParams params )
42      {
43          // Must occur before store is looked up
44          factory.setDriverName( params.getDriverClass() );
45          factory.setUserName( params.getUsername() );
46          factory.setPassword( params.getPassword() );
47          factory.setUrl( params.getUrl() );
48  
49          Properties properties = params.getProperties();
50          for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
51          {
52              String key = (String) i.next();
53              factory.setProperty( key, properties.getProperty( key ) );
54          }
55      }
56  }