You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/09/02 12:52:05 UTC
syncope git commit: [SYNCOPE-689] Adjusting Spring initialization to
work also with JBoss / Wildfly
Repository: syncope
Updated Branches:
refs/heads/master a707cc9cc -> 8a1abd4e7
[SYNCOPE-689] Adjusting Spring initialization to work also with JBoss / Wildfly
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/8a1abd4e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/8a1abd4e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/8a1abd4e
Branch: refs/heads/master
Commit: 8a1abd4e7c8dd70b01dbbc050f6b5fe680ae7554
Parents: a707cc9
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Sep 2 12:51:26 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Sep 2 12:51:26 2015 +0200
----------------------------------------------------------------------
.../client/lib/RestClientExceptionMapper.java | 90 ++++++++-----
.../common/lib/types/ClientExceptionType.java | 8 +-
.../syncope/core/logic/init/LoggerLoader.java | 2 -
.../misc/spring/ApplicationContextProvider.java | 11 --
.../DomainTransactionInterceptorInjector.java | 38 ++++++
.../src/main/resources/domains.xml | 4 +-
.../rest/cxf/RestServiceExceptionMapper.java | 10 +-
.../core/logic/init/CamelRouteLoader.java | 39 ++----
.../resources/jboss/domains/MasterDomain.xml | 4 +-
.../main/resources/jboss/domains/TwoDomain.xml | 131 +++++++++++++++++++
10 files changed, 251 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientExceptionMapper.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientExceptionMapper.java b/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientExceptionMapper.java
index 6233f6c..6649524 100644
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientExceptionMapper.java
+++ b/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientExceptionMapper.java
@@ -19,10 +19,12 @@
package org.apache.syncope.client.lib;
import java.security.AccessControlException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@@ -31,6 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
import org.apache.syncope.common.lib.SyncopeClientCompositeException;
import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.ErrorTO;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.rest.api.RESTHeaders;
import org.slf4j.Logger;
@@ -55,11 +58,9 @@ public class RestClientExceptionMapper implements ExceptionMapper<Exception>, Re
SyncopeClientCompositeException scce = checkSyncopeClientCompositeException(response);
if (scce != null) {
// 1. Check for client (possibly composite) exception in HTTP header
- if (scce.getExceptions().size() == 1) {
- ex = scce.getExceptions().iterator().next();
- } else {
- ex = scce;
- }
+ ex = scce.getExceptions().size() == 1
+ ? scce.getExceptions().iterator().next()
+ : scce;
} else if (statusCode == Response.Status.UNAUTHORIZED.getStatusCode()) {
// 2. Map SC_UNAUTHORIZED
ex = new AccessControlException("Remote unauthorized exception");
@@ -76,42 +77,69 @@ public class RestClientExceptionMapper implements ExceptionMapper<Exception>, Re
}
private SyncopeClientCompositeException checkSyncopeClientCompositeException(final Response response) {
- List<String> exTypesInHeaders = response.getStringHeaders().get(RESTHeaders.ERROR_CODE);
- if (exTypesInHeaders == null) {
- LOG.debug("No " + RESTHeaders.ERROR_CODE + " provided");
- return null;
- }
- List<String> exInfos = response.getStringHeaders().get(RESTHeaders.ERROR_INFO);
+ SyncopeClientCompositeException compException = SyncopeClientException.buildComposite();
- final SyncopeClientCompositeException compException = SyncopeClientException.buildComposite();
-
- Set<String> handledExceptions = new HashSet<>();
- for (String exTypeAsString : exTypesInHeaders) {
- ClientExceptionType exceptionType = null;
+ // Attempts to read ErrorTO or List<ErrorTO> as entity...
+ List<ErrorTO> errors = null;
+ try {
+ ErrorTO error = response.readEntity(ErrorTO.class);
+ if (error != null) {
+ errors = Collections.singletonList(error);
+ }
+ } catch (Exception e) {
+ LOG.debug("Could not read {}, attempting to read composite...", ErrorTO.class.getName(), e);
+ }
+ if (errors == null) {
try {
- exceptionType = ClientExceptionType.fromHeaderValue(exTypeAsString);
- } catch (IllegalArgumentException e) {
- LOG.error("Unexpected value of " + RESTHeaders.ERROR_CODE + ": " + exTypeAsString, e);
+ errors = response.readEntity(new GenericType<List<ErrorTO>>() {
+ });
+ } catch (Exception e) {
+ LOG.debug("Could not read {} list, attempting to read headers...", ErrorTO.class.getName(), e);
}
- if (exceptionType != null) {
- handledExceptions.add(exTypeAsString);
+ }
- final SyncopeClientException clientException = SyncopeClientException.build(exceptionType);
+ // ...if not possible, attempts to parse response headers
+ if (errors == null) {
+ List<String> exTypesInHeaders = response.getStringHeaders().get(RESTHeaders.ERROR_CODE);
+ if (exTypesInHeaders == null) {
+ LOG.debug("No " + RESTHeaders.ERROR_CODE + " provided");
+ return null;
+ }
+ List<String> exInfos = response.getStringHeaders().get(RESTHeaders.ERROR_INFO);
- if (exInfos != null && !exInfos.isEmpty()) {
- for (String element : exInfos) {
- if (element.startsWith(exceptionType.getHeaderValue())) {
- clientException.getElements().add(StringUtils.substringAfter(element, ":"));
+ Set<String> handledExceptions = new HashSet<>();
+ for (String exTypeAsString : exTypesInHeaders) {
+ ClientExceptionType exceptionType = null;
+ try {
+ exceptionType = ClientExceptionType.fromHeaderValue(exTypeAsString);
+ } catch (IllegalArgumentException e) {
+ LOG.error("Unexpected value of " + RESTHeaders.ERROR_CODE + ": " + exTypeAsString, e);
+ }
+ if (exceptionType != null) {
+ handledExceptions.add(exTypeAsString);
+
+ SyncopeClientException clientException = SyncopeClientException.build(exceptionType);
+ if (exInfos != null && !exInfos.isEmpty()) {
+ for (String element : exInfos) {
+ if (element.startsWith(exceptionType.name())) {
+ clientException.getElements().add(StringUtils.substringAfter(element, ":"));
+ }
}
}
+ compException.addException(clientException);
}
- compException.addException(clientException);
}
- }
- exTypesInHeaders.removeAll(handledExceptions);
- if (!exTypesInHeaders.isEmpty()) {
- LOG.error("Unmanaged exceptions: " + exTypesInHeaders);
+ exTypesInHeaders.removeAll(handledExceptions);
+ if (!exTypesInHeaders.isEmpty()) {
+ LOG.error("Unmanaged exceptions: " + exTypesInHeaders);
+ }
+ } else {
+ for (ErrorTO error : errors) {
+ SyncopeClientException clientException = SyncopeClientException.build(error.getType());
+ clientException.getElements().addAll(error.getElements());
+ compException.addException(clientException);
+ }
}
if (compException.hasExceptions()) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
index 3fcef86..d85d1b6 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/ClientExceptionType.java
@@ -80,7 +80,7 @@ public enum ClientExceptionType {
public static ClientExceptionType fromHeaderValue(final String exceptionTypeHeaderValue) {
ClientExceptionType result = null;
for (ClientExceptionType type : values()) {
- if (exceptionTypeHeaderValue.equals(type.getHeaderValue())) {
+ if (exceptionTypeHeaderValue.equals(type.name())) {
result = type;
}
}
@@ -92,12 +92,8 @@ public enum ClientExceptionType {
return result;
}
- public String getHeaderValue() {
- return name();
- }
-
public String getInfoHeaderValue(final String value) {
- return getHeaderValue() + ":" + value;
+ return name() + ":" + value;
}
public Response.Status getResponseStatus() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java b/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
index 6187959..c4c1928 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
@@ -37,7 +37,6 @@ import org.apache.syncope.core.persistence.api.SyncopeLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
@Component
public class LoggerLoader implements SyncopeLoader {
@@ -53,7 +52,6 @@ public class LoggerLoader implements SyncopeLoader {
return 300;
}
- @Transactional
@Override
public void load() {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java
index 2a21281..e67dcd6 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java
@@ -18,12 +18,10 @@
*/
package org.apache.syncope.core.misc.spring;
-import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.transaction.interceptor.TransactionInterceptor;
public class ApplicationContextProvider implements ApplicationContextAware {
@@ -43,16 +41,8 @@ public class ApplicationContextProvider implements ApplicationContextAware {
: BEAN_FACTORY;
}
- private static void enableDomainTransactionInterceptor() {
- for (String name : getBeanFactory().getBeanNamesForType(TransactionInterceptor.class)) {
- BeanDefinition bd = getBeanFactory().getBeanDefinition(name);
- bd.setBeanClassName(DomainTransactionInterceptor.class.getName());
- }
- }
-
public static void setBeanFactory(final DefaultListableBeanFactory beanFactory) {
BEAN_FACTORY = beanFactory;
- enableDomainTransactionInterceptor();
}
/**
@@ -63,6 +53,5 @@ public class ApplicationContextProvider implements ApplicationContextAware {
@Override
public void setApplicationContext(final ApplicationContext ctx) {
CTX = (ConfigurableApplicationContext) ctx;
- enableDomainTransactionInterceptor();
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptorInjector.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptorInjector.java b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptorInjector.java
new file mode 100644
index 0000000..d9d772b
--- /dev/null
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptorInjector.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.syncope.core.misc.spring;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.transaction.interceptor.TransactionInterceptor;
+
+/**
+ * Replaces Spring's {@link TransactionInterceptor} with {@link DomainTransactionInterceptor}.
+ */
+public class DomainTransactionInterceptorInjector implements BeanFactoryPostProcessor {
+
+ @Override
+ public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ BeanDefinition bd = beanFactory.getBeanDefinition(TransactionInterceptor.class.getName() + "#0");
+ bd.setBeanClassName(DomainTransactionInterceptor.class.getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/core/persistence-jpa/src/main/resources/domains.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/domains.xml b/core/persistence-jpa/src/main/resources/domains.xml
index 43fce14..5d6b5ab 100644
--- a/core/persistence-jpa/src/main/resources/domains.xml
+++ b/core/persistence-jpa/src/main/resources/domains.xml
@@ -23,7 +23,9 @@ under the License.
http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath*:domains/*Domain.xml"/>
-
+
+ <bean class="org.apache.syncope.core.misc.spring.DomainTransactionInterceptorInjector"/>
+
<bean id="commonEMFConf" class="org.apache.syncope.core.persistence.jpa.spring.CommonEntityManagerFactoryConf">
<property name="packagesToScan" value="org.apache.syncope.core.persistence.jpa.entity"/>
<property name="validationMode" value="NONE"/>
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
index 18f6101..3307f66 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
@@ -133,7 +133,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
// process JAX-RS validation errors
if (builder == null && ex instanceof ValidationException) {
builder = builder(validationEM.toResponse((ValidationException) ex)).
- header(RESTHeaders.ERROR_CODE, ClientExceptionType.RESTValidation.getHeaderValue()).
+ header(RESTHeaders.ERROR_CODE, ClientExceptionType.RESTValidation.name()).
header(RESTHeaders.ERROR_INFO, ClientExceptionType.RESTValidation.getInfoHeaderValue(
ExceptionUtils.getRootCauseMessage(ex)));
@@ -171,7 +171,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
private ResponseBuilder getSyncopeClientExceptionResponse(final SyncopeClientException ex) {
ResponseBuilder builder = Response.status(ex.getType().getResponseStatus());
- builder.header(RESTHeaders.ERROR_CODE, ex.getType().getHeaderValue());
+ builder.header(RESTHeaders.ERROR_CODE, ex.getType().name());
ErrorTO error = new ErrorTO();
error.setStatus(ex.getType().getResponseStatus().getStatusCode());
@@ -194,7 +194,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
List<ErrorTO> errors = new ArrayList<>();
for (SyncopeClientException sce : ex.getExceptions()) {
- builder.header(RESTHeaders.ERROR_CODE, sce.getType().getHeaderValue());
+ builder.header(RESTHeaders.ERROR_CODE, sce.getType().name());
ErrorTO error = new ErrorTO();
error.setStatus(sce.getType().getResponseStatus().getStatusCode());
@@ -237,7 +237,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
: ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
- builder.header(RESTHeaders.ERROR_CODE, exType.getHeaderValue());
+ builder.header(RESTHeaders.ERROR_CODE, exType.name());
ErrorTO error = new ErrorTO();
error.setStatus(exType.getResponseStatus().getStatusCode());
@@ -295,7 +295,7 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, R
private ResponseBuilder builder(final ClientExceptionType hType, final String msg) {
ResponseBuilder builder = Response.status(hType.getResponseStatus()).
- header(RESTHeaders.ERROR_CODE, hType.getHeaderValue()).
+ header(RESTHeaders.ERROR_CODE, hType.name()).
header(RESTHeaders.ERROR_INFO, hType.getInfoHeaderValue(msg));
ErrorTO error = new ErrorTO();
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/ext/camel/logic/src/main/java/org/apache/syncope/core/logic/init/CamelRouteLoader.java
----------------------------------------------------------------------
diff --git a/ext/camel/logic/src/main/java/org/apache/syncope/core/logic/init/CamelRouteLoader.java b/ext/camel/logic/src/main/java/org/apache/syncope/core/logic/init/CamelRouteLoader.java
index 97bb299..4ee6c50 100644
--- a/ext/camel/logic/src/main/java/org/apache/syncope/core/logic/init/CamelRouteLoader.java
+++ b/ext/camel/logic/src/main/java/org/apache/syncope/core/logic/init/CamelRouteLoader.java
@@ -19,23 +19,19 @@
package org.apache.syncope.core.logic.init;
import java.io.StringWriter;
-import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.core.misc.spring.ResourceWithFallbackLoader;
import org.apache.syncope.core.persistence.api.DomainsHolder;
import org.apache.syncope.core.persistence.api.SyncopeLoader;
-import org.apache.syncope.core.persistence.api.entity.CamelEntityFactory;
import org.apache.syncope.core.persistence.api.entity.CamelRoute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
-import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -63,9 +59,6 @@ public class CamelRouteLoader implements SyncopeLoader {
@Autowired
private DomainsHolder domainsHolder;
- @Autowired
- private CamelEntityFactory entityFactory;
-
private boolean loaded = false;
@Override
@@ -73,7 +66,6 @@ public class CamelRouteLoader implements SyncopeLoader {
return 1000;
}
- @Transactional
@Override
public void load() {
synchronized (this) {
@@ -91,13 +83,6 @@ public class CamelRouteLoader implements SyncopeLoader {
}
}
- private boolean loadRoutesFor(final DataSource dataSource, final AnyTypeKind anyTypeKind) {
- final String sql = String.format("SELECT * FROM %s WHERE ANYTYPEKIND = ?", CamelRoute.class.getSimpleName());
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
- final List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, new Object[] { anyTypeKind.name() });
- return rows.isEmpty();
- }
-
private String nodeToString(final Node content, final DOMImplementationLS domImpl) {
StringWriter writer = new StringWriter();
try {
@@ -115,11 +100,13 @@ public class CamelRouteLoader implements SyncopeLoader {
private void loadRoutes(
final String domain, final DataSource dataSource, final Resource resource, final AnyTypeKind anyTypeKind) {
- if (loadRoutesFor(dataSource, anyTypeKind)) {
- String query = String.format("INSERT INTO %s(NAME, ANYTYPEKIND, CONTENT) VALUES (?, ?, ?)",
- CamelRoute.class.getSimpleName());
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+ boolean shouldLoadRoutes = jdbcTemplate.queryForList(
+ String.format("SELECT * FROM %s WHERE ANYTYPEKIND = ?", CamelRoute.class.getSimpleName()),
+ new Object[] { anyTypeKind.name() }).
+ isEmpty();
+ if (shouldLoadRoutes) {
try {
DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
DOMImplementationLS domImpl = (DOMImplementationLS) reg.getDOMImplementation("LS");
@@ -134,18 +121,14 @@ public class CamelRouteLoader implements SyncopeLoader {
String routeContent = nodeToString(routeNodes.item(s), domImpl);
String routeId = ((Element) routeElement).getAttribute("id");
- CamelRoute route = entityFactory.newCamelRoute();
- route.setAnyTypeKind(anyTypeKind);
- route.setKey(routeId);
- route.setContent(routeContent);
-
- jdbcTemplate.update(query, new Object[] { routeId, anyTypeKind.name(), routeContent });
+ jdbcTemplate.update(
+ String.format("INSERT INTO %s(NAME, ANYTYPEKIND, CONTENT) VALUES (?, ?, ?)",
+ CamelRoute.class.getSimpleName()),
+ new Object[] { routeId, anyTypeKind.name(), routeContent });
LOG.info("[{}] Route successfully loaded: {}", domain, routeId);
}
- } catch (DataAccessException e) {
- LOG.error("[{}] While trying to store queries", domain, e);
} catch (Exception e) {
- LOG.error("[{}] Route load failed {}", domain, e.getMessage());
+ LOG.error("[{}] Route load failed", domain, e);
}
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/fit/core-reference/src/main/resources/jboss/domains/MasterDomain.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/jboss/domains/MasterDomain.xml b/fit/core-reference/src/main/resources/jboss/domains/MasterDomain.xml
index 35eacdc..e11e928 100644
--- a/fit/core-reference/src/main/resources/jboss/domains/MasterDomain.xml
+++ b/fit/core-reference/src/main/resources/jboss/domains/MasterDomain.xml
@@ -116,7 +116,7 @@ under the License.
<property name="jpaPropertyMap">
<map>
<entry key="openjpa.MetaDataFactory"
- value="jpa(URLs=vfs:${project.build.directory}/cargo/configurations/wildfly8x/deployments/syncope.war/WEB-INF/classes, Resources=${Master.orm)"/>
+ value="jpa(URLs=vfs:${project.build.directory}/cargo/configurations/wildfly9x/deployments/syncope.war/WEB-INF/classes, Resources=${Master.orm})"/>
</map>
</property>
</bean>
@@ -128,4 +128,4 @@ under the License.
<tx:annotation-driven transaction-manager="MasterTransactionManager"/>
-</beans>
\ No newline at end of file
+</beans>
http://git-wip-us.apache.org/repos/asf/syncope/blob/8a1abd4e/fit/core-reference/src/main/resources/jboss/domains/TwoDomain.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/jboss/domains/TwoDomain.xml b/fit/core-reference/src/main/resources/jboss/domains/TwoDomain.xml
new file mode 100644
index 0000000..205553f
--- /dev/null
+++ b/fit/core-reference/src/main/resources/jboss/domains/TwoDomain.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+
+ <bean id="TwoContentXML" class="org.apache.syncope.core.misc.spring.ResourceWithFallbackLoader">
+ <property name="primary" value="file:${content.directory}/domains/TwoContent.xml"/>
+ <property name="fallback" value="classpath:domains/TwoContent.xml"/>
+ </bean>
+ <bean id="TwoProperties" class="org.apache.syncope.core.misc.spring.ResourceWithFallbackLoader">
+ <property name="primary" value="file:${content.directory}/domains/Two.properties"/>
+ <property name="fallback" value="classpath:domains/Two.properties"/>
+ </bean>
+ <bean id="TwoDatabaseSchema" class="java.lang.String">
+ <constructor-arg value="${Two.schema}"/>
+ </bean>
+
+ <!-- Use JNDI datasource as default but, when not available, revert to
+ local datasource, with different properties for execution and testing.
+ In any case, get all JDBC connections with a determined isolation level. -->
+ <bean id="TwoDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
+ <property name="jndiName" value="java:comp/env/jdbc/syncopeTwoDataSource"/>
+ <property name="defaultObject" ref="localTwoDataSource"/>
+ </bean>
+
+ <bean id="localTwoDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="${Two.driverClassName}"/>
+ <property name="url" value="${Two.url}"/>
+ <property name="username" value="${Two.username}"/>
+ <property name="password" value="${Two.password}"/>
+ <!-- connection pool configuration - transaction isolation, default READ_COMMITTED (see SYNCOPE-202) -->
+ <property name="defaultTransactionIsolation">
+ <util:constant static-field="${Two.pool.defaultTransactionIsolation:java.sql.Connection.TRANSACTION_READ_COMMITTED}"/>
+ </property>
+ <!-- connection pool configuration - default values taken from BasicDataSource default values -->
+ <property name="initialSize" value="${Two.pool.initialSize:0}"/>
+ <property name="maxTotal" value="${Two.pool.maxActive:8}"/>
+ <property name="maxIdle" value="${Two.pool.maxIdle:8}"/>
+ <property name="minIdle" value="${Two.pool.minIdle:0}"/>
+ <property name="maxWaitMillis" value="${Two.pool.maxWait:-1}"/>
+ <property name="validationQuery" value="${Two.pool.validationQuery}"/>
+ <property name="validationQueryTimeout" value="${Two.pool.validationQueryTimeout:-1}"/>
+ <property name="testOnBorrow" value="${Two.pool.testOnBorrow:true}"/>
+ <property name="testOnReturn" value="${Two.pool.testOnReturn:false}"/>
+ <property name="testWhileIdle" value="${Two.pool.testWhileIdle:false}"/>
+ <property name="timeBetweenEvictionRunsMillis" value="${Two.pool.timeBetweenEvictionRunsMillis:-1}"/>
+ <property name="numTestsPerEvictionRun" value="${Two.pool.numTestsPerEvictionRun:3}"/>
+ <property name="minEvictableIdleTimeMillis" value="${Two.pool.minEvictableIdleTimeMillis:1800000}"/>
+ <property name="removeAbandonedOnBorrow" value="${Two.pool.removeAbandoned:false}"/>
+ <property name="removeAbandonedOnMaintenance" value="${Two.pool.removeAbandoned:false}"/>
+ <property name="removeAbandonedTimeout" value="${Two.pool.removeAbandonedTimeout:300}"/>
+ <property name="logAbandoned" value="${Two.pool.logAbandoned:false}"/>
+ </bean>
+
+ <bean class="org.springframework.jdbc.datasource.init.DataSourceInitializer">
+ <property name="dataSource" ref="TwoDataSource"/>
+ <property name="enabled" value="true"/>
+ <property name="databasePopulator">
+ <bean class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
+ <property name="continueOnError" value="true"/>
+ <property name="ignoreFailedDrops" value="true"/>
+ <property name="sqlScriptEncoding" value="UTF-8"/>
+ <property name="scripts">
+ <array>
+ <value type="org.springframework.core.io.Resource">
+ classpath:/audit/${Two.audit.sql}
+ </value>
+ </array>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="TwoEntityManagerFactory"
+ class="org.apache.syncope.core.persistence.jpa.spring.DomainEntityManagerFactoryBean">
+ <property name="mappingResources">
+ <list>
+ <value>${Two.orm}</value>
+ </list>
+ </property>
+ <property name="persistenceUnitName" value="Two"/>
+ <property name="dataSource" ref="TwoDataSource"/>
+ <property name="jpaVendorAdapter">
+ <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
+ <property name="showSql" value="false"/>
+ <property name="generateDdl" value="true"/>
+ <property name="databasePlatform" value="${Two.databasePlatform}"/>
+ </bean>
+ </property>
+ <property name="commonEntityManagerFactoryConf" ref="commonEMFConf"/>
+ <property name="jpaPropertyMap">
+ <map>
+ <entry key="openjpa.MetaDataFactory"
+ value="jpa(URLs=vfs:${project.build.directory}/cargo/configurations/wildfly9x/deployments/syncope.war/WEB-INF/classes, Resources=${Two.orm})"/>
+ </map>
+ </property>
+ </bean>
+
+ <bean id="TwoTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="TwoEntityManagerFactory"/>
+ <qualifier value="Two"/>
+ </bean>
+
+ <tx:annotation-driven transaction-manager="TwoTransactionManager"/>
+
+</beans>