001/* 002 * Copyright 2017 Anyware Services 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 */ 016package org.ametys.plugins.odfsync.cdmfr; 017 018import java.util.Set; 019 020import org.w3c.dom.Document; 021 022import org.ametys.plugins.odfsync.cdmfr.transformers.CDMFrSyncTransformer; 023import org.ametys.runtime.plugin.ExtensionPoint; 024import org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint; 025 026/** 027 * {@link ExtensionPoint} for registering {@link CDMFrSyncTransformer}s. 028 */ 029public class CDMFrSyncExtensionPoint extends AbstractThreadSafeComponentExtensionPoint<CDMFrSyncTransformer> 030{ 031 /** Avalon Role */ 032 public static final String ROLE = CDMFrSyncExtensionPoint.class.getName(); 033 034 /** 035 * Get the transformer. 036 * @param document The document to parse 037 * @return the transformer 038 */ 039 public CDMFrSyncTransformer getTransformer(Document document) 040 { 041 Set<String> extensionsIds = getExtensionsIds(); 042 043 for (String id : extensionsIds) 044 { 045 CDMFrSyncTransformer transformer = getExtension(id); 046 if (transformer.supports(document)) 047 { 048 return transformer; 049 } 050 } 051 052 return null; 053 } 054}