weaver 2004/08/01 08:37:59
Added: commons/src/java/org/apache/jetspeed/factory
JetspeedPortletFactoryProxy.java
Removed: commons/src/java/org/apache/jetspeed/factory
JetspeedPortletFactory.java
Log:
Changed to using the factory proxy. The actual factory is now down in /portal and
is assembled using Spring.
Revision Changes Path
1.1
jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/factory/JetspeedPortletFactoryProxy.java
Index: JetspeedPortletFactoryProxy.java
===================================================================
/*
* Copyright 2000-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.factory;
import javax.portlet.Portlet;
import javax.portlet.PortletException;
import javax.servlet.ServletConfig;
import org.apache.pluto.om.portlet.PortletDefinition;
/**
* The Jetspeed Portlet Factory is a facade the process of creating portlets.
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: JetspeedPortletFactoryProxy.java,v 1.1 2004/08/01 15:37:59 weaver
Exp $
*/
public final class JetspeedPortletFactoryProxy
{
private static PortletFactory portletFactory;
public JetspeedPortletFactoryProxy(PortletFactory portletFactory)
{
if(JetspeedPortletFactoryProxy.portletFactory == null)
{
JetspeedPortletFactoryProxy.portletFactory = portletFactory;
}
else
{
throw new IllegalStateException("The JetspeedPortletFactoryProxy can
only be called once.");
}
}
/**
* Gets a portlet by either creating it or returning a handle to it from the
portlet 'cache'
*
* @param portletDefinition The definition of the portlet
* @return Portlet
* @throws PortletException
*/
public static Portlet getPortlet(ServletConfig servletConfig, PortletDefinition
portletDefinition)
throws PortletException
{
verifyState();
return portletFactory.getPortlet(servletConfig, portletDefinition);
}
/**
* <p>
* loadPortletClass
* </p>
* Loads a Portlet class by first checking
Thread.currentThread().getContextClassLoader()
* then by checking all of the ClassLoaders in <code>classLoaders</code> until
the
* class is located or returns <code>null</code> if the Portlet class could not
be found.
*
* @param className
* @return
* @throws InstantiationException
* @throws IllegalAccessException
*/
public static Portlet loadPortletClass( String className ) throws
InstantiationException, IllegalAccessException
{
verifyState();
return portletFactory.loadPortletClass(className);
}
/**
*
* <p>
* addClassLoader
* </p>
*
* Adds a ClassLoader to the search path, <code>classLoaders</code>, of the
JetspeedPortletFactory.
*
* @param cl
*/
public static void addClassLoader(ClassLoader cl)
{
verifyState();
portletFactory.addClassLoader(cl);
}
public static void reset()
{
portletFactory = null;
}
private static void verifyState() throws IllegalStateException
{
if(portletFactory == null)
{
throw new IllegalStateException("JetspeedPorletFactory has not been
initialized. "+
"You must first invoke the constructor
with a valid PortletFactory instance.");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]