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 java.util.Collections;
020 import java.util.List;
021
022 /**
023 * Helper class capable of dealing with artifacts and their handlers.
024 *
025 * @author Andres Almiray
026 */
027 public interface ArtifactManager extends ApplicationHandler {
028 GriffonClass[] EMPTY_GRIFFON_CLASS_ARRAY = new GriffonClass[0];
029 List<GriffonClass> EMPTY_GRIFFON_CLASS_LIST = Collections.<GriffonClass>emptyList();
030
031 /**
032 * Registers an ArtifactHandler by type.<p>
033 * Should call initialize() on the handler.
034 *
035 * @param handler an ArtifactHandler
036 */
037 void registerArtifactHandler(ArtifactHandler handler);
038
039 /**
040 * Removes an ArtifactHandler by type.
041 *
042 * @param handler an ArtifactHandler
043 */
044 void unregisterArtifactHandler(ArtifactHandler handler);
045
046 /**
047 * Reads the artifacts definitions file from the classpath.<p>
048 * Should call initialize() on artifact handlers if there are any
049 * registered already.
050 */
051 void loadArtifactMetadata();
052
053 /**
054 * Finds an artifact by name and type.<p>
055 * Example: findGriffonClass("Book", "controller") will return an
056 * artifact class that describes BookController.
057 *
058 * @param name the name of the artifact, e.g. 'Book'
059 * @param type the type of the artifact, e.g. 'controller'
060 * @return the GriffonClass associated with the artifact is there's a match, null otherwise.
061 */
062 GriffonClass findGriffonClass(String name, String type);
063
064 /**
065 * Finds an artifact by class and type.<p>
066 * Example: findGriffonClass(BookController, "controller") will return an
067 * artifact class that describes BookController.
068 *
069 * @param clazz the name of the artifact, e.g. com.acme.BookController
070 * @param type the type of the artifact, e.g. 'controller'
071 * @return the GriffonClass associated with the artifact is there's a match, null otherwise.
072 */
073 GriffonClass findGriffonClass(Class clazz, String type);
074
075 /**
076 * Finds an artifact by class.<p>
077 * Example: findGriffonClass(aBookControllerInstance) will return an
078 * artifact class that describes BookController.
079 *
080 * @param obj an artifact instance
081 * @return the GriffonClass associated with the artifact is there's a match, null otherwise.
082 */
083 GriffonClass findGriffonClass(Object obj);
084
085 /**
086 * Finds an artifact by class.<p>
087 * Example: findGriffonClass(BookController) will return an
088 * artifact class that describes BookController.
089 *
090 * @param clazz a Class instance
091 * @return the GriffonClass associated with the artifact is there's a match, null otherwise.
092 */
093 GriffonClass findGriffonClass(Class clazz);
094
095 /**
096 * Finds an artifact by name.<p>
097 * Example: findGriffonClass("BookController") will return an
098 * artifact class that describes BookController.
099 *
100 * @param fqnClassName full qualified class name
101 * @return the GriffonClass associated with the artifact is there's a match, null otherwise.
102 */
103 GriffonClass findGriffonClass(String fqnClassName);
104
105 /**
106 * Finds all artifacts of an specific type.<p>
107 * Example: getClassesOfType("controller") will return all
108 * artifact classes that describe controllers.
109 *
110 * @param type an artifact type, e.g. 'controller'
111 * @return a List of matching artifacts or an empty List if no match. Never returns null.
112 */
113 List<GriffonClass> getClassesOfType(String type);
114
115 /**
116 * Finds all artifact classes.<p>
117 *
118 * @return a List of all available GriffonClass instances. Never returns null.
119 */
120 List<GriffonClass> getAllClasses();
121 }
|