01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.util.assemble;
18:
19: import java.io.File;
20:
21: import org.apache.pluto.util.assemble.ear.EarAssembler;
22: import org.apache.pluto.util.assemble.file.FileAssembler;
23: import org.apache.pluto.util.assemble.war.WarAssembler;
24:
25: /**
26: * The pluto assembler factory that creates an assembler.
27: * @version 1.0
28: * @since Nov 8, 2004
29: */
30: public class AssemblerFactory {
31:
32: /** The singleton factory instance. */
33: private static final AssemblerFactory FACTORY = new AssemblerFactory();
34:
35: /**
36: * Private constructor that prevents external instantiation.
37: */
38: private AssemblerFactory() {
39: // Do nothing.
40: }
41:
42: /**
43: * Returns the singleton factory instance.
44: * @return the singleton factory instance.
45: */
46: public static AssemblerFactory getFactory() {
47: return FACTORY;
48: }
49:
50: // Public Methods ----------------------------------------------------------
51:
52: /**
53: * Creates an assembler to assemble a portlet app WAR file to a web app WAR
54: * file deployable to pluto.
55: * @param config the assembler configuration.
56: * @return an assembler instance.
57: */
58: public Assembler createAssembler(AssemblerConfig config) {
59: File source = config.getSource();
60:
61: if (source == null) {
62: return new FileAssembler();
63: }
64:
65: if (source.getName().toLowerCase().endsWith(".war")) {
66: return new WarAssembler();
67: }
68:
69: if (source.getName().toLowerCase().endsWith(".ear")) {
70: return new EarAssembler();
71: }
72:
73: return new FileAssembler();
74: }
75:
76: }
|