1 package org.apache.turbine.services.assemblerbroker;
2
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23
24 import org.apache.turbine.modules.Assembler;
25 import org.apache.turbine.modules.Loader;
26 import org.apache.turbine.services.TurbineServices;
27 import org.apache.turbine.services.assemblerbroker.util.AssemblerFactory;
28 import org.apache.turbine.util.TurbineException;
29
30 /**
31 * An interface the Turbine Assembler service.
32 * See TurbineAssemblerBrokerService for more info.
33 *
34 * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
35 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
36 * @version $Id: TurbineAssemblerBroker.java 1199089 2011-11-08 03:14:28Z tv $
37 */
38 public abstract class TurbineAssemblerBroker
39 {
40 /**
41 * Utility method for accessing the service
42 * implementation
43 *
44 * @return An AssemblerBroker implementation instance
45 */
46 public static AssemblerBrokerService getService()
47 {
48 return (AssemblerBrokerService) TurbineServices.getInstance()
49 .getService(AssemblerBrokerService.SERVICE_NAME);
50 }
51
52 /**
53 * Register a new Assembler factory with this service.
54 *
55 * @param factory The actual Factory Object
56 */
57 public static <T extends Assembler> void registerFactory(AssemblerFactory<T> factory)
58 {
59 getService().registerFactory(factory);
60 }
61
62 /**
63 * Return an Assembler for a given type and object name.
64 *
65 * @param type The Type of Assembler we want
66 * @param name The name of the Assembler
67 *
68 * @return An Assembler Object.
69 *
70 * @throws TurbineException If a problem locating the Assembler occurred.
71 */
72 public static <T extends Assembler> T getAssembler(Class<T> type, String name)
73 throws TurbineException
74 {
75 return getService().getAssembler(type, name);
76 }
77
78 /**
79 * Get a Loader for the given assembler type
80 *
81 * @param type The Type of the Assembler
82 * @return A Loader instance for the requested type
83 */
84 public static <T extends Assembler> Loader<T> getLoader(Class<T> type)
85 {
86 return getService().getLoader(type);
87 }
88 }