`MVCGroup.java`
`001 /* 002 * Copyright 2009-2012 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 017 package griffon.core; 018 019 import groovy.util.FactoryBuilderSupport; 020 021 import java.util.Map; 022 023 /** 024 * Defines an MVC group and its contents 025 * 026 * @author Andres Almiray 027 * @since 0.9.4 028 */ 029 public interface MVCGroup extends ApplicationHandler { 030 /** 031 * Returns the configuration of this group. 032 * 033 * @return the configuration used to instantiate this group. 034 */ 035 MVCGroupConfiguration getConfiguration(); 036 037 /** 038 * Returns the type of this group as set in the application's configuration. 039 * 040 * @return the type of the group 041 */ 042 String getMvcType(); 043 044 /** 045 * Returns the id of the group. 046 * Ids are used to uniquely identify a group instance. 047 * 048 * @return the id of this group. 049 */ 050 String getMvcId(); 051 052 /** 053 * Returns the Model portion of this group. 054 * 055 * @return a GriffonModel instance if the group has a model member, null otherwise 056 * @throws IllegalStateException if the group has been destroyed already 057 */ 058 GriffonModel getModel(); 059 060 /** 061 * Returns the View portion of this group. 062 * 063 * @return a GriffonView instance if the group has a view member, null otherwise 064 * @throws IllegalStateException if the group has been destroyed already 065 */ 066 GriffonView getView(); 067 068 /** 069 * Returns the Controller portion of this group. 070 * 071 * @return a GriffonController instance if the group has a controller member, null otherwise 072 * @throws IllegalStateException if the group has been destroyed already 073 */ 074 GriffonController getController(); 075 076 /** 077 * Returns the builder portion of this group. 078 * 079 * @return a FactoryBuilderSupport instance (typically an UberBuilder) 080 * @throws IllegalStateException if the group has been destroyed already 081 */ 082 FactoryBuilderSupport getBuilder(); 083 084 /** 085 * Returns the specified member type. 086 * 087 * @param name the type of member to retrieve 088 * @return the selected MVC member if a match is found, null otherwise 089 * @throws IllegalStateException if the group has been destroyed already 090 */ 091 Object getMember(String name); 092 093 /** 094 * Returns a read-only view of all instance members. 095 * 096 * @return an unmodifiable Map view of all members. 097 * @throws IllegalStateException if the group has been destroyed already 098 */ 099 Map<String, Object> getMembers(); 100 101 /** 102 * Destroys the current group. 103 * <strong>Should only be called once.</strong> 104 * 105 * @throws IllegalStateException if the group has been destroyed already 106 */ 107 void destroy(); 108 109 /** 110 * Returns whether this group has been destroyed or not. 111 * 112 * @return true if the group has not been destroyed yet, false otherwise 113 */ 114 boolean isAlive(); 115 116 /** 117 * Returns the result of the evaluation of the specified member if it's a Script. 118 * 119 * @param name the name of a member 120 * @return the last expression evaluated if the member is a Script, null otherwise. 121 */ 122 Object getScriptResult(String name); 123 124 /** 125 * Builds the target member if it's a Script, storing the result. 126 * 127 * @param name the name of a member 128 */ 129 void buildScriptMember(String name); 130 }`