001 package org.apache.turbine.services.assemblerbroker;
002
003
004 /*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements. See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership. The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License. You may obtain a copy of the License at
012 *
013 * http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied. See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024 import org.apache.turbine.modules.Assembler;
025 import org.apache.turbine.modules.Loader;
026 import org.apache.turbine.services.TurbineServices;
027 import org.apache.turbine.services.assemblerbroker.util.AssemblerFactory;
028 import org.apache.turbine.util.TurbineException;
029
030 /**
031 * An interface the Turbine Assembler service.
032 * See TurbineAssemblerBrokerService for more info.
033 *
034 * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
035 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
036 * @version $Id: TurbineAssemblerBroker.java 743071 2009-02-10 19:37:33Z tv $
037 */
038 public abstract class TurbineAssemblerBroker
039 {
040 /**
041 * Utility method for accessing the service
042 * implementation
043 *
044 * @return An AssemblerBroker implementation instance
045 */
046 public static AssemblerBrokerService getService()
047 {
048 return (AssemblerBrokerService) TurbineServices.getInstance()
049 .getService(AssemblerBrokerService.SERVICE_NAME);
050 }
051
052 /**
053 * Register a new Assembler factory with this service.
054 *
055 * @param type The type of Assembler Factory
056 * @param factory The actual Factory Object
057 */
058 public static void registerFactory(String type, AssemblerFactory factory)
059 {
060 getService().registerFactory(type, factory);
061 }
062
063 /**
064 * Return an Assembler for a given type and object name.
065 *
066 * @param type The Type of Assember we want
067 * @param name The name of the Assembler
068 *
069 * @return An Assembler Object.
070 *
071 * @throws TurbineException If a problem locating the Assember occured.
072 */
073 public static Assembler getAssembler(String type, String name)
074 throws TurbineException
075 {
076 return getService().getAssembler(type, name);
077 }
078
079 /**
080 * Get a Loader for the given assembler type
081 *
082 * @param type The Type of the Assembler
083 * @return A Loader instance for the requested type
084 */
085 public static Loader getLoader(String type)
086 {
087 return getService().getLoader(type);
088 }
089 }