[tx-control] Register the recovery service before the ResourceProvider so that recovery is always available before someone uses the service

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk@1753812 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java b/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
index 7f0ac5d..aa10760 100644
--- a/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
+++ b/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
@@ -206,23 +206,21 @@
 				try {
 					JDBCConnectionProviderImpl provider = new JDBCConnectionProviderFactoryImpl().getProviderFor(service,
 							jdbcProperties, providerProperties);
-					reg = context
-							.registerService(JDBCConnectionProvider.class, provider, getServiceProperties());
-
-					
 					String recoveryId = (String) providerProperties.get(OSGI_RECOVERY_IDENTIFIER);
 					if(recoveryId !=null) {
 						if(toBoolean(providerProperties, XA_ENLISTMENT_ENABLED, true)) {
 							LOG.warn("A JDBCResourceProvider has been configured with a recovery identifier {} but it has also been configured not to use XA transactions. No recovery will be available.", recoveryId);
 						} else {
 							reg2 = context.registerService(RecoverableXAResource.class, 
-											new RecoverableXAResourceImpl(recoveryId, provider, 
-													(String) providerProperties.get("recovery.user"),
-													(String) providerProperties.get(".recovery.password)")), 
-													getServiceProperties());
+									new RecoverableXAResourceImpl(recoveryId, provider, 
+											(String) providerProperties.get("recovery.user"),
+											(String) providerProperties.get(".recovery.password)")), 
+									getServiceProperties());
 						}
 					}
-					
+					reg = context
+							.registerService(JDBCConnectionProvider.class, provider, getServiceProperties());
+
 					ServiceRegistration<JDBCConnectionProvider> oldReg;
 					ServiceRegistration<RecoverableXAResource> oldReg2;