01 /*
02 * Copyright 2010-2012 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package griffon.core;
17
18 import groovy.lang.MetaClass;
19 import org.slf4j.Logger;
20
21 /**
22 * Identifies an object as a Griffon artifact.<p>
23 * Griffon artifacts are usually placed under the special "griffon-app" directory
24 * that every application has. They are also grouped together in in a subdirectory that
25 * clearly identifies their nature. For example "griffon-app/controllers" contains all
26 * Controller artifacts.<p>
27 * Implementing this interface for a custom artifact definition is highly recommended
28 * but not enforced.
29 *
30 * @author Andres Almiray
31 * @since 0.9.1
32 */
33 public interface GriffonArtifact extends ApplicationHandler, ThreadingHandler, MVCHandler, ResourceHandler {
34 /**
35 * Creates a new instance of the specified class and type.
36 *
37 * @param clazz the Class to be instantiated
38 * @param type a logical type, such as 'controller'. May be null.
39 * @return the newly created instance
40 */
41 Object newInstance(Class clazz, String type);
42
43 /**
44 * Gets the {@code MetaClass} of this artifact.<p>
45 * It should delegate to its GriffonClass to get the real MetaClass.
46 *
47 * @return The MetaClass for this Griffon class
48 */
49 MetaClass getMetaClass();
50
51 /**
52 * Returns the <tt>GriffonClass</tt> associated with this artifact.
53 *
54 * @return the <tt>GriffonClass</tt> associated with this artifact
55 */
56 GriffonClass getGriffonClass();
57
58 /**
59 * Returns a Logger instance suitable for this Artifact.<p>
60 * The Logger is configured with the following prefix 'griffon.app.<type>'
61 * where <type> stands for the artifact's type.<p>
62 * Example: the Logger for class com.acme.SampleController will be configured for
63 * 'griffon.app.controller.com.acme.SampleController'.
64 *
65 * @return a Logger instance associated with this artifact.
66 * @since 0.9.2
67 */
68 Logger getLog();
69 }
|