--- /dev/null
+package org.apache.archiva.redback.common.jdo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
+import org.codehaus.plexus.redback.configuration.UserConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * UserConfigurableJdoFactory
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@Service( "jdoFactory#users" )
+public class UserConfigurableJdoFactory
+ extends DefaultConfigurableJdoFactory
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ @Inject
+ @Named( value = "userConfiguration" )
+ private UserConfiguration config;
+
+ private String getConfigString( String key, String currentValue, String defaultValue )
+ {
+ String valueFromSysProps = System.getProperty( "redback." + key );
+ if (StringUtils.isNotEmpty( valueFromSysProps ))
+ {
+ return valueFromSysProps;
+ }
+ String value = null;
+ if ( StringUtils.isNotEmpty( currentValue ) )
+ {
+ value = config.getString( key, currentValue );
+ }
+ else
+ {
+ value = config.getString( key, defaultValue );
+ }
+ // do some interpolation as we can have some ${plexus.home} etc...
+ StringSearchInterpolator interpolator = new StringSearchInterpolator();
+ interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) );
+
+ try
+ {
+ return interpolator.interpolate( value );
+ }
+ catch ( InterpolationException e )
+ {
+ // ignore interpolation issue
+ log.warn( "skip issue during interpolation " + e.getMessage() );
+ return value;
+ }
+ }
+
+ @PostConstruct
+ public void initialize()
+ {
+ String jdbcDriverName =
+ getConfigString( "jdbc.driver.name", super.getDriverName(), "org.apache.derby.jdbc.EmbeddedDriver" );
+ String jdbcUrl =
+ getConfigString( "jdbc.url", super.getUrl(), "jdbc:derby:${plexus.home}/database;create=true" );
+
+ String jdbcUsername = getConfigString( "jdbc.username", super.getUserName(), "sa" );
+ String jdbcPassword = getConfigString( "jdbc.password", super.getPassword(), "" );
+
+ super.setDriverName( jdbcDriverName );
+ super.setUrl( jdbcUrl );
+ super.setUserName( jdbcUsername );
+ super.setPassword( jdbcPassword );
+
+ if ( StringUtils.isEmpty( super.persistenceManagerFactoryClass ) )
+ {
+ super.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" );
+ }
+
+ if ( ( super.otherProperties == null ) || super.otherProperties.isEmpty() )
+ {
+ super.setProperty( "org.jpox.autoCreateSchema", "true" );
+ super.setProperty( "org.jpox.validateSchema", "false" );
+ super.setProperty( "org.jpox.validateTables", "false" );
+ super.setProperty( "org.jpox.validateConstraints", "false" );
+ super.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );
+ super.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" );
+ }
+
+ super.initialize();
+ }
+
+ public UserConfiguration getConfig()
+ {
+ return config;
+ }
+
+ public void setConfig( UserConfiguration config )
+ {
+ this.config = config;
+ }
+}
--- /dev/null
+package org.apache.archiva.redback.common.jdo.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jdo.PersistenceManager;
+
+import org.jpox.AbstractPersistenceManagerFactory;
+import org.jpox.ClassLoaderResolver;
+import org.jpox.plugin.ConfigurationElement;
+import org.jpox.plugin.Extension;
+import org.jpox.store.rdbms.RDBMSManager;
+
+/**
+ * A extension to JPOX store manager that allows counting the SQL queries
+ *
+ * @author Carlos Sanchez <a href="mailto:carlos@apache.org">
+ */
+public class StoreManagerDebug
+ extends RDBMSManager
+{
+ private static int counter;
+
+ public StoreManagerDebug( ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, String userName,
+ String password )
+ {
+ super( clr, pmf, userName, password );
+ }
+
+ /**
+ * This method will change JPOX store manager extension so it uses our class instead of whatever is configured in
+ * the plugin.xml
+ *
+ * @param pmf
+ */
+ public static void setup( AbstractPersistenceManagerFactory pmf )
+ {
+ /* set our own Store Manager to allow counting SQL statements */
+ Extension[] extensions =
+ pmf.getPMFContext().getPluginManager().getExtensionPoint( "org.jpox.store_manager" ).getExtensions();
+ Extension e = extensions[0];
+ for ( ConfigurationElement element : e.getConfigurationElements() )
+ {
+ element.putAttribute( "class-name", StoreManagerDebug.class.getName() );
+ }
+ }
+
+ /**
+ * Get the currently configured store manager from JPOX. Will fail if
+ * {@link #setup(AbstractPersistenceManagerFactory)} is not called first.
+ *
+ * @param persistenceManager
+ * @return
+ */
+ public static StoreManagerDebug getConfiguredStoreManager( PersistenceManager persistenceManager )
+ {
+ return (StoreManagerDebug) ( (org.jpox.PersistenceManager) persistenceManager ).getStoreManager();
+ }
+
+ @Override
+ public int[] executeStatementBatch( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementBatch( stmt, ps );
+ }
+
+ @Override
+ public ResultSet executeStatementQuery( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementQuery( stmt, ps );
+ }
+
+ @Override
+ public int executeStatementUpdate( String stmt, PreparedStatement ps )
+ throws SQLException
+ {
+ counter++;
+ return super.executeStatementUpdate( stmt, ps );
+ }
+
+ public void resetCounter()
+ {
+ counter = 0;
+ }
+
+ public int counter()
+ {
+ return counter;
+ }
+}
+++ /dev/null
-package org.codehaus.plexus.redback.common.jdo;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.interpolation.InterpolationException;
-import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
-import org.codehaus.plexus.interpolation.StringSearchInterpolator;
-import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.redback.configuration.UserConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-/**
- * UserConfigurableJdoFactory
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-@Service( "jdoFactory#users" )
-public class UserConfigurableJdoFactory
- extends DefaultConfigurableJdoFactory
-{
-
- private Logger log = LoggerFactory.getLogger( getClass() );
-
- @Inject
- @Named( value = "userConfiguration" )
- private UserConfiguration config;
-
- private String getConfigString( String key, String currentValue, String defaultValue )
- {
- String valueFromSysProps = System.getProperty( "redback." + key );
- if (StringUtils.isNotEmpty( valueFromSysProps ))
- {
- return valueFromSysProps;
- }
- String value = null;
- if ( StringUtils.isNotEmpty( currentValue ) )
- {
- value = config.getString( key, currentValue );
- }
- else
- {
- value = config.getString( key, defaultValue );
- }
- // do some interpolation as we can have some ${plexus.home} etc...
- StringSearchInterpolator interpolator = new StringSearchInterpolator();
- interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) );
-
- try
- {
- return interpolator.interpolate( value );
- }
- catch ( InterpolationException e )
- {
- // ignore interpolation issue
- log.warn( "skip issue during interpolation " + e.getMessage() );
- return value;
- }
- }
-
- @PostConstruct
- public void initialize()
- {
- String jdbcDriverName =
- getConfigString( "jdbc.driver.name", super.getDriverName(), "org.apache.derby.jdbc.EmbeddedDriver" );
- String jdbcUrl =
- getConfigString( "jdbc.url", super.getUrl(), "jdbc:derby:${plexus.home}/database;create=true" );
-
- String jdbcUsername = getConfigString( "jdbc.username", super.getUserName(), "sa" );
- String jdbcPassword = getConfigString( "jdbc.password", super.getPassword(), "" );
-
- super.setDriverName( jdbcDriverName );
- super.setUrl( jdbcUrl );
- super.setUserName( jdbcUsername );
- super.setPassword( jdbcPassword );
-
- if ( StringUtils.isEmpty( super.persistenceManagerFactoryClass ) )
- {
- super.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" );
- }
-
- if ( ( super.otherProperties == null ) || super.otherProperties.isEmpty() )
- {
- super.setProperty( "org.jpox.autoCreateSchema", "true" );
- super.setProperty( "org.jpox.validateSchema", "false" );
- super.setProperty( "org.jpox.validateTables", "false" );
- super.setProperty( "org.jpox.validateConstraints", "false" );
- super.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );
- super.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" );
- }
-
- super.initialize();
- }
-
- public UserConfiguration getConfig()
- {
- return config;
- }
-
- public void setConfig( UserConfiguration config )
- {
- this.config = config;
- }
-}
+++ /dev/null
-package org.codehaus.plexus.redback.common.jdo.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.jdo.PersistenceManager;
-
-import org.jpox.AbstractPersistenceManagerFactory;
-import org.jpox.ClassLoaderResolver;
-import org.jpox.plugin.ConfigurationElement;
-import org.jpox.plugin.Extension;
-import org.jpox.store.rdbms.RDBMSManager;
-
-/**
- * A extension to JPOX store manager that allows counting the SQL queries
- *
- * @author Carlos Sanchez <a href="mailto:carlos@apache.org">
- */
-public class StoreManagerDebug
- extends RDBMSManager
-{
- private static int counter;
-
- public StoreManagerDebug( ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, String userName,
- String password )
- {
- super( clr, pmf, userName, password );
- }
-
- /**
- * This method will change JPOX store manager extension so it uses our class instead of whatever is configured in
- * the plugin.xml
- *
- * @param pmf
- */
- public static void setup( AbstractPersistenceManagerFactory pmf )
- {
- /* set our own Store Manager to allow counting SQL statements */
- Extension[] extensions =
- pmf.getPMFContext().getPluginManager().getExtensionPoint( "org.jpox.store_manager" ).getExtensions();
- Extension e = extensions[0];
- for ( ConfigurationElement element : e.getConfigurationElements() )
- {
- element.putAttribute( "class-name", StoreManagerDebug.class.getName() );
- }
- }
-
- /**
- * Get the currently configured store manager from JPOX. Will fail if
- * {@link #setup(AbstractPersistenceManagerFactory)} is not called first.
- *
- * @param persistenceManager
- * @return
- */
- public static StoreManagerDebug getConfiguredStoreManager( PersistenceManager persistenceManager )
- {
- return (StoreManagerDebug) ( (org.jpox.PersistenceManager) persistenceManager ).getStoreManager();
- }
-
- @Override
- public int[] executeStatementBatch( String stmt, PreparedStatement ps )
- throws SQLException
- {
- counter++;
- return super.executeStatementBatch( stmt, ps );
- }
-
- @Override
- public ResultSet executeStatementQuery( String stmt, PreparedStatement ps )
- throws SQLException
- {
- counter++;
- return super.executeStatementQuery( stmt, ps );
- }
-
- @Override
- public int executeStatementUpdate( String stmt, PreparedStatement ps )
- throws SQLException
- {
- counter++;
- return super.executeStatementUpdate( stmt, ps );
- }
-
- public void resetCounter()
- {
- counter = 0;
- }
-
- public int counter()
- {
- return counter;
- }
-}
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
- <bean name="jdoFactory#users" class="org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory">
+ <bean name="jdoFactory#users" class="org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory">
<property name="config" ref="userConfiguration"/>
</bean>
</beans>
\ No newline at end of file
*/
import junit.framework.TestCase;
+import org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory;
import org.apache.archiva.redback.users.UserManager;
import org.apache.commons.lang.SystemUtils;
-import org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory;
import org.codehaus.plexus.redback.keys.AuthenticationKey;
import org.codehaus.plexus.redback.keys.KeyManager;
import org.codehaus.plexus.redback.keys.KeyManagerException;
<context:property-placeholder system-properties-mode="OVERRIDE"/>
- <bean name="jdoFactory#users" class="org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory">
+ <bean name="jdoFactory#users" class="org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory">
<property name="config" ref="userConfiguration"/>
<property name="driverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="url" value="jdbc:derby:${basedir}/target" />
<context:property-placeholder system-properties-mode="OVERRIDE"/>
- <bean name="jdoFactory#users" class="org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory">
+ <bean name="jdoFactory#users" class="org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory">
<property name="config" ref="userConfiguration"/>
<property name="driverName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:MailGeneratorTest" />
import net.sf.ehcache.CacheManager;
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.redback.common.jdo.test.StoreManagerDebug;
+import org.apache.archiva.redback.common.jdo.test.StoreManagerDebug;
import org.codehaus.plexus.redback.rbac.RBACManager;
import org.codehaus.plexus.redback.rbac.RbacManagerException;
import org.codehaus.plexus.redback.tests.AbstractRbacManagerTestCase;
*/
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.redback.common.jdo.test.StoreManagerDebug;
+import org.apache.archiva.redback.common.jdo.test.StoreManagerDebug;
import org.apache.archiva.redback.users.provider.test.AbstractUserManagerTestCase;
import org.jpox.AbstractPersistenceManagerFactory;
import org.jpox.SchemaTool;
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
- <bean name="jdoFactory#users" class="org.codehaus.plexus.redback.common.jdo.UserConfigurableJdoFactory">
+ <bean name="jdoFactory#users" class="org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory">
<property name="config" ref="userConfiguration"/>
<property name="driverName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:redback-users-tests" />