001 /*
002 * Copyright 2005-2006 Stephen J. McConnell.
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
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.metro;
020
021 import net.dpml.component.Provider;
022 import net.dpml.component.ControlException;
023
024 import net.dpml.lang.UnknownKeyException;
025
026 /**
027 * Local interface through which a component implementation may
028 * interact with subsidary parts.
029 *
030 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
031 * @version 1.2.0
032 */
033 public interface PartsManager
034 {
035 /**
036 * Return the array of keys used to identify internal parts.
037 * @return the part key array
038 */
039 String[] getKeys();
040
041 /**
042 * Return a local component handler.
043 * @param key the internal part key
044 * @return the local component handler
045 * @exception UnknownKeyException the key is not recognized
046 */
047 ComponentHandler getComponentHandler( String key ) throws UnknownKeyException;
048
049 /**
050 * Return an array of all component handlers.
051 * @return the local component handler array
052 */
053 ComponentHandler[] getComponentHandlers();
054
055 /**
056 * Return an array of all component handlers.
057 * @return the local component handler array
058 */
059 Provider[] getProviders();
060
061 /**
062 * Return an array of component handlers to the supplied service.
063 * @param service the service class to match against
064 * @return the local component handler array
065 */
066 Provider[] getProviders( Class service );
067
068 /**
069 * Return a component handler.
070 * @param key the internal component key
071 * @return the local component handler
072 */
073 Provider getProvider( String key ) throws UnknownKeyException;
074
075 /**
076 * Return an array of component handlers assignable to the supplied service.
077 * @param service the service class to match against
078 * @return the local component handler array
079 */
080 ComponentHandler[] getComponentHandlers( Class service );
081
082 /**
083 * Return the commissioned state of the part collection.
084 * @return true if commissioned else false
085 */
086 boolean isCommissioned();
087
088 /**
089 * Initiate the oprdered activation of all internal parts.
090 * @exception ControlException if an activation error occurs
091 */
092 void commission() throws ControlException;
093
094 /**
095 * Initiate deactivation of all internal parts.
096 */
097 void decommission();
098 }
099