001/* 002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Kevin Leturc 018 */ 019package org.nuxeo.ecm.core.storage.marklogic; 020 021import org.nuxeo.ecm.core.storage.dbs.DBSRepositoryService; 022import org.nuxeo.runtime.api.Framework; 023import org.nuxeo.runtime.model.ComponentInstance; 024import org.nuxeo.runtime.model.DefaultComponent; 025 026/** 027 * Service holding the configuration for MarkLogic repositories. 028 * 029 * @since 8.3 030 */ 031public class MarkLogicRepositoryService extends DefaultComponent { 032 033 private static final String XP_REPOSITORY = "repository"; 034 035 @Override 036 public void registerContribution(Object contrib, String xpoint, ComponentInstance contributor) { 037 if (XP_REPOSITORY.equals(xpoint)) { 038 addContribution((MarkLogicRepositoryDescriptor) contrib); 039 } else { 040 throw new RuntimeException("Unknown extension point: " + xpoint); 041 } 042 } 043 044 @Override 045 public void unregisterContribution(Object contrib, String xpoint, ComponentInstance contributor) { 046 if (XP_REPOSITORY.equals(xpoint)) { 047 removeContribution((MarkLogicRepositoryDescriptor) contrib); 048 } else { 049 throw new RuntimeException("Unknown extension point: " + xpoint); 050 } 051 } 052 053 protected void addContribution(MarkLogicRepositoryDescriptor descriptor) { 054 Framework.getService(DBSRepositoryService.class).addContribution(descriptor, MarkLogicRepositoryFactory.class); 055 } 056 057 protected void removeContribution(MarkLogicRepositoryDescriptor descriptor) { 058 Framework.getService(DBSRepositoryService.class).removeContribution(descriptor, 059 MarkLogicRepositoryFactory.class); 060 } 061 062}