001package jmri.jmrit.permission; 002 003 004import java.util.Arrays; 005import java.util.Set; 006 007import jmri.InstanceInitializer; 008import jmri.PermissionManager; 009import jmri.implementation.AbstractInstanceInitializer; 010 011import org.openide.util.lookup.ServiceProvider; 012 013/** 014 * Provide the usual default implementations for the 015 * {@link jmri.InstanceManager}. 016 * <P> 017 * Not all {@link jmri.InstanceManager} related classes are provided by this 018 * class. See the discussion in {@link jmri.InstanceManager} of initialization 019 * methods. 020 * <hr> 021 * This file is part of JMRI. 022 * <P> 023 * JMRI is free software; you can redistribute it and/or modify it under the 024 * terms of version 2 of the GNU General Public License as published by the Free 025 * Software Foundation. See the "COPYING" file for a copy of this license. 026 * <P> 027 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 028 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 029 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 030 * 031 * @author Bob Jacobsen Copyright (C) 2001, 2008, 2014 032 * @since 2.9.4 033 */ 034@ServiceProvider(service = InstanceInitializer.class) 035public class PermissionInstanceInitializer extends AbstractInstanceInitializer { 036 037 @Override 038 public <T> Object getDefault(Class<T> type) { 039 040 // In order for getDefault() to be called for a particular manager, 041 // the manager also needs to be added to the method getInitalizes() 042 // below. 043 044 if (type == PermissionManager.class) { 045 return new DefaultPermissionManager().init(); 046 } 047 048 return super.getDefault(type); 049 } 050 051 @Override 052 public Set<Class<?>> getInitalizes() { 053 Set<Class<?>> set = super.getInitalizes(); 054 set.addAll(Arrays.asList( 055 PermissionManager.class 056 )); 057 return set; 058 } 059 060}