MVCGroupManager.java
001 /*
002  * Copyright 2010-2013 the original author or authors.
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 package griffon.core;
017 
018 import groovy.util.FactoryBuilderSupport;
019 
020 import java.util.Map;
021 
022 /**
023  * Manages the configuration and instantiation of MVC groups.
024  *
025  @author Andres Almiray
026  @since 0.9.4
027  */
028 public interface MVCGroupManager extends MVCHandler, ApplicationHandler {
029     /**
030      * Creates an MVCConfiguration instance with the given arguments.
031      *
032      @param mvcType the name of the MVC group
033      @param members members of the group
034      @param config  additional configuration required by the group
035      @return a ready-to-use MVCGroupConfiguration instance
036      */
037     MVCGroupConfiguration newMVCGroupConfiguration(String mvcType, Map<String, String> members, Map<String, Object> config);
038 
039     /**
040      * Clones an existing MVCGroupConfiguration, optionally overriding additional config values.
041      *
042      @param mvcType the name of the configuration to clone
043      @param config  additional config parameters to be set on the configuration
044      @return a ready-to-use MVCGroupConfiguration instance
045      @since 0.9.5
046      */
047     MVCGroupConfiguration cloneMVCGroupConfiguration(String mvcType, Map<String, Object> config);
048 
049     /**
050      * Creates a new MVCGroup instance.
051      *
052      @param configuration the configuration of the group
053      @param mvcId         the id to use for the group
054      @param members       the instance members of the group
055      @return a ready-to-use MVCGroup instance
056      */
057     MVCGroup newMVCGroup(MVCGroupConfiguration configuration, String mvcId, Map<String, Object> members);
058 
059     /**
060      * Initializes this manager with the group configurations provided by the application and addons.
061      *
062      @param configurations available group configurations
063      */
064     void initialize(Map<String, MVCGroupConfiguration> configurations);
065 
066     void addConfiguration(MVCGroupConfiguration configuration);
067 
068     void removeConfiguration(MVCGroupConfiguration configuration);
069 
070     void removeConfiguration(String name);
071 
072     Map<String, MVCGroupConfiguration> getConfigurations();
073 
074     Map<String, MVCGroup> getGroups();
075 
076     MVCGroupConfiguration findConfiguration(String mvcType);
077 
078     MVCGroup findGroup(String mvcId);
079 
080     MVCGroup getAt(String mvcId);
081 
082     /**
083      * Returns all currently available model instances, keyed by group name.<p>
084      *
085      @return a Map of all currently instantiated models.
086      */
087     Map<String, ? extends GriffonModel> getModels();
088 
089     /**
090      * Returns all currently available view instances, keyed by group name.<p>
091      *
092      @return a Map of all currently instantiated views.
093      */
094     Map<String, ? extends GriffonView> getViews();
095 
096     /**
097      * Returns all currently available controller instances, keyed by group name.<p>
098      *
099      @return a Map of all currently instantiated controllers.
100      */
101     Map<String, ? extends GriffonController> getControllers();
102 
103     /**
104      * Returns all currently available builder instances, keyed by group name.<p>
105      *
106      @return a Map of all currently instantiated builders.
107      */
108     Map<String, ? extends FactoryBuilderSupport> getBuilders();
109 }