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;
18:
19: import org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21: import org.apache.pluto.core.PortletContainerImpl;
22: import org.apache.pluto.core.DefaultOptionalContainerServices;
23: import org.apache.pluto.util.ArgumentUtility;
24:
25: /**
26: * Factory used to create new PortletContainer instances. The factor constructs
27: * the underlying pluto container implementation by using the the given
28: * container services.
29: *
30: * @version 1.0
31: * @since Sep 18, 2004
32: */
33: public class PortletContainerFactory {
34:
35: /** Logger. */
36: private static final Log LOG = LogFactory
37: .getLog(PortletContainerFactory.class);
38:
39: /** Singleton instance of the <code>PortletContainerFactory</code>. */
40: private static final PortletContainerFactory FACTORY = new PortletContainerFactory();
41:
42: /**
43: * Accessor method for the singleton instance of the
44: * <code>PortletContainerFactory</code>.
45: * @return singleton instance of the PortletContainerFactory
46: */
47: public static PortletContainerFactory getInstance() {
48: return FACTORY;
49: }
50:
51: /**
52: * Private constructor that prevents external instantiation.
53: */
54: private PortletContainerFactory() {
55: // Do nothing.
56: }
57:
58: /**
59: * Create a container with the given containerName, initialized from the given
60: * servlet config, and using the given container services.
61: * @param containerName the name of the portlet container.
62: * @param requiredServices the required portlet container services.
63: * @return newly created PortletContainer instance.
64: * @throws PortletContainerException
65: */
66: public PortletContainer createContainer(String containerName,
67: RequiredContainerServices requiredServices)
68: throws PortletContainerException {
69: return createContainer(containerName, requiredServices,
70: new DefaultOptionalContainerServices());
71: }
72:
73: public PortletContainer createContainer(String containerName,
74: RequiredContainerServices requiredServices,
75: OptionalContainerServices optionalServices) {
76:
77: ArgumentUtility.validateNotNull("requiredServices",
78: requiredServices);
79: ArgumentUtility
80: .validateNotEmpty("containerName", containerName);
81:
82: DefaultOptionalContainerServices optionalServicesWrapper = new DefaultOptionalContainerServices(
83: optionalServices);
84: PortletContainer container = new PortletContainerImpl(
85: containerName, requiredServices,
86: optionalServicesWrapper);
87:
88: if (LOG.isInfoEnabled()) {
89: LOG.info("Portlet Container [" + containerName
90: + "] created.");
91: }
92: return container;
93: }
94: }
|