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.workspaces.project.modules; 017 018import java.util.List; 019import java.util.stream.Collectors; 020 021import org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint; 022 023/** 024 * Extension point for Workspace Modules Managers 025 */ 026public class WorkspaceModuleExtensionPoint extends AbstractThreadSafeComponentExtensionPoint<WorkspaceModule> 027{ 028 /** Avalon Role */ 029 public static final String ROLE = WorkspaceModuleExtensionPoint.class.getName(); 030 031 /** 032 * Get a workspace module 033 * @param moduleId The id of the module 034 * @param <M> The module type 035 * @return The workspace module 036 */ 037 @SuppressWarnings("unchecked") 038 public <M extends WorkspaceModule> M getModule(String moduleId) 039 { 040 return (M) getExtension(moduleId); 041 } 042 043 /** 044 * Get the list of available modules 045 * @return The modules 046 */ 047 public List<WorkspaceModule> getModules() 048 { 049 return getExtensionsIds().stream().map(id -> getExtension(id)).collect(Collectors.toList()); 050 } 051}