code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit 4750450f authored by Ard Schrijvers's avatar Ard Schrijvers

REPO-1811 To the RepositoryImpl add a Journal ConnectionHelper accessor

Via this Journal ConnectionHelper we can access the Journal DataSource
via the ConnectionHelperDataSourceAccessor.

Admittedly, a bit clumsy but we need access to the Journal DataSource
because we need to know whether we are dealing with a database *and*
whether we have a clustered setup : Only in that case, the lock mechanism
has to be upgraded from in memory locking to db base locking because
needs to be cluster wide
parent dfa6f279
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* 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.
*/
package org.apache.jackrabbit.core.journal;
import org.apache.jackrabbit.core.util.db.ConnectionHelper;
import org.onehippo.repository.journal.JournalConnectionHelperAccessor;
public class JournalConnectionHelperAccessorImpl implements JournalConnectionHelperAccessor {
private ConnectionHelper connectionHelper;
public JournalConnectionHelperAccessorImpl(final DatabaseJournal journal) {
if (journal != null) {
connectionHelper = journal.conHelper;
}
}
public ConnectionHelper getConnectionHelper() {
return connectionHelper;
}
}
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* 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.
*/
package org.apache.jackrabbit.core.util.db;
import javax.sql.DataSource;
public class ConnectionHelperDataSourceAccessor {
private ConnectionHelperDataSourceAccessor(){
}
public static DataSource getDataSource(final ConnectionHelper connectionHelper) {
return connectionHelper.dataSource;
}
}
......@@ -39,7 +39,9 @@ import org.apache.jackrabbit.core.config.RepositoryConfig;
import org.apache.jackrabbit.core.config.WorkspaceConfig;
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.journal.DatabaseJournal;
import org.apache.jackrabbit.core.journal.ExternalRepositorySyncRevisionServiceImpl;
import org.apache.jackrabbit.core.journal.JournalConnectionHelperAccessorImpl;
import org.apache.jackrabbit.core.lock.LockManagerImpl;
import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
import org.apache.jackrabbit.core.observation.ObservationDispatcher;
......@@ -59,6 +61,7 @@ import org.hippoecm.repository.query.lucene.ServicingSearchIndex;
import org.hippoecm.repository.security.HippoSecurityManager;
import org.onehippo.repository.InternalHippoRepository;
import org.onehippo.repository.journal.ExternalRepositorySyncRevisionService;
import org.onehippo.repository.journal.JournalConnectionHelperAccessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -73,6 +76,7 @@ public class RepositoryImpl extends org.apache.jackrabbit.core.RepositoryImpl im
protected boolean isStarted = false;
private ExternalRepositorySyncRevisionService externalRepositorySyncRevisionService;
private JournalConnectionHelperAccessor journalConnectionHelperAccessor;
protected RepositoryImpl(RepositoryConfig repConfig) throws RepositoryException {
super(repConfig);
......@@ -294,6 +298,19 @@ public class RepositoryImpl extends org.apache.jackrabbit.core.RepositoryImpl im
return externalRepositorySyncRevisionService;
}
/**
* @return JournalConnectionHelperAccessor is a journal connection is available and otherwise null
* @throws RepositoryException
*/
public synchronized JournalConnectionHelperAccessor getJournalConnectionHelperAccessor() throws RepositoryException {
sanityCheck();
if (journalConnectionHelperAccessor == null) {
ClusterNode clusterNode = context.getClusterNode();
journalConnectionHelperAccessor = new JournalConnectionHelperAccessorImpl(clusterNode == null ? null : (DatabaseJournal)clusterNode.getJournal());
}
return journalConnectionHelperAccessor;
}
@Override
protected HippoWorkspaceInfo getWorkspaceInfo(final String workspaceName) throws RepositoryException {
return (HippoWorkspaceInfo) super.getWorkspaceInfo(workspaceName);
......
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* 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.
*/
package org.onehippo.repository.journal;
import org.apache.jackrabbit.core.util.db.ConnectionHelper;
public interface JournalConnectionHelperAccessor {
/**
* @return the {@link ConnectionHelper} and {@code null} if not present (for example when not in cluster setup)
*/
ConnectionHelper getConnectionHelper();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment