2016-08-07 15:41:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
|
|
* and other contributors as indicated by the @author tags.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-08-08 16:32:36 +00:00
|
|
|
package org.keycloak.transaction;
|
2016-08-07 15:41:52 +00:00
|
|
|
|
2016-08-08 16:32:36 +00:00
|
|
|
import org.keycloak.Config;
|
|
|
|
import org.keycloak.models.KeycloakSessionFactory;
|
|
|
|
import org.keycloak.services.ServicesLogger;
|
2016-08-07 15:41:52 +00:00
|
|
|
|
|
|
|
import javax.naming.InitialContext;
|
|
|
|
import javax.naming.NamingException;
|
|
|
|
import javax.transaction.TransactionManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
|
|
|
* @version $Revision: 1 $
|
|
|
|
*/
|
2016-08-08 16:32:36 +00:00
|
|
|
public class JBossJtaTransactionManagerLookup implements JtaTransactionManagerLookup {
|
2016-08-07 15:41:52 +00:00
|
|
|
private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER;
|
|
|
|
private TransactionManager tm;
|
|
|
|
|
2016-08-08 16:32:36 +00:00
|
|
|
@Override
|
|
|
|
public TransactionManager getTransactionManager() {
|
|
|
|
return tm;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(Config.Scope config) {
|
2016-08-07 15:41:52 +00:00
|
|
|
try {
|
|
|
|
InitialContext ctx = new InitialContext();
|
|
|
|
tm = (TransactionManager)ctx.lookup("java:jboss/TransactionManager");
|
|
|
|
if (tm == null) {
|
|
|
|
logger.debug("Could not locate TransactionManager");
|
|
|
|
}
|
|
|
|
} catch (NamingException e) {
|
|
|
|
logger.debug("Could not load TransactionManager", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-08 16:32:36 +00:00
|
|
|
@Override
|
|
|
|
public void postInit(KeycloakSessionFactory factory) {
|
|
|
|
|
|
|
|
}
|
2016-08-07 15:41:52 +00:00
|
|
|
|
2016-08-08 16:32:36 +00:00
|
|
|
@Override
|
|
|
|
public String getId() {
|
|
|
|
return "jboss";
|
2016-08-07 15:41:52 +00:00
|
|
|
}
|
|
|
|
}
|