You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by es...@apache.org on 2007/08/25 21:35:37 UTC
svn commit: r569721 [2/3] - in /portals/wsrp4j/trunk/producer: ./
src/java/org/apache/wsrp4j/producer/configapp/controller/
src/java/org/apache/wsrp4j/producer/configapp/exception/
src/java/org/apache/wsrp4j/producer/configapp/model/delegate/ src/java/...
Modified: portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletInvokerImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletInvokerImpl.java?rev=569721&r1=569720&r2=569721&view=diff
==============================================================================
--- portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletInvokerImpl.java (original)
+++ portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletInvokerImpl.java Sat Aug 25 12:35:34 2007
@@ -22,452 +22,480 @@
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
+import oasis.names.tc.wsrp.v1.types.GetMarkup;
import oasis.names.tc.wsrp.v1.types.MarkupContext;
+import oasis.names.tc.wsrp.v1.types.MarkupParams;
import oasis.names.tc.wsrp.v1.types.MarkupResponse;
import oasis.names.tc.wsrp.v1.types.NamedString;
-import oasis.names.tc.wsrp.v1.types.UpdateResponse;
-import oasis.names.tc.wsrp.v1.types.GetMarkup;
import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
+import oasis.names.tc.wsrp.v1.types.PortletContext;
+import oasis.names.tc.wsrp.v1.types.RuntimeContext;
+import oasis.names.tc.wsrp.v1.types.UpdateResponse;
-import org.apache.pluto.om.entity.PortletEntity;
-import org.apache.pluto.om.window.PortletWindow;
-import org.apache.pluto.om.window.PortletWindowCtrl;
-import org.apache.pluto.om.window.PortletWindowList;
-import org.apache.pluto.om.window.PortletWindowListCtrl;
-import org.apache.pluto.portalImpl.core.PortalEnvironment;
-import org.apache.pluto.portalImpl.om.window.impl.PortletWindowImpl;
-import org.apache.pluto.portalImpl.services.portletentityregistry.
- PortletEntityRegistry;
-import org.apache.pluto.portalImpl.util.ObjectID;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.spi.optional.PortletRegistryService;
+import org.apache.wsrp4j.commons.exception.WSRPException;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.ConsumerConfiguredPortlet;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.Portlet;
import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletInvoker;
-
-import org.apache.wsrp4j.producer.provider.pluto.interfaces.PlutoProvider;
-import org.apache.wsrp4j.producer.provider.pluto.interfaces.
- WSRPDynamicInformationProvider;
-
+import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletPool;
import org.apache.wsrp4j.commons.producer.util.Base64;
import org.apache.wsrp4j.commons.producer.util.MapDeserializer;
import org.apache.wsrp4j.commons.producer.util.MapSerializer;
import org.apache.wsrp4j.commons.producer.util.ServletAccess;
-
-import org.apache.wsrp4j.commons.util.LocaleHelper;
import org.apache.wsrp4j.commons.util.Constants;
-import org.apache.wsrp4j.commons.util.Utility;
-
+import org.apache.wsrp4j.commons.util.LocaleHelper;
+import org.apache.wsrp4j.producer.provider.pluto.interfaces.AttrKeys;
/**
- * <p>This class implements the PortletInvoker interface. It should only be
- * instantiated within an implementation of the
- * Provider interface.</p>
- * <p>The provided invokePortlet method ...</p>
- *
+ * <p>
+ * This class implements the PortletInvoker interface. It should only be
+ * instantiated within an implementation of the Provider interface.
+ * </p>
+ * <p>
+ * The provided invokePortlet method ...
+ * </p>
+ *
* @see PortletInvoker
* @version $Id$
- **/
-public class PortletInvokerImpl implements PortletInvoker {
-
- private static final Log log = LogFactory.getLog(PortletInvokerImpl.class);
+ */
+public class PortletInvokerImpl implements PortletInvoker
+{
- // provider
- private PlutoProvider provider;
+ private static final Log LOG = LogFactory.getLog( PortletInvokerImpl.class );
+ private final PortletContainer container;
+ private PortletPool pool = null;
+ private PortletRegistryService registrySvc = null;
- /**
- * private constructor
- */
- private PortletInvokerImpl() {
- // private
+ PortletInvokerImpl( PortletContainer container, PortletPool pool, PortletRegistryService registrySvc )
+ {
+ if ( container == null )
+ {
+ final String msg = "Portlet container must not be null";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ if ( pool == null )
+ {
+ final String msg = "Portlet pool must not be null";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ if ( registrySvc == null )
+ {
+ final String msg = "Portlet registry service must not be null";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ this.container = container;
+ this.registrySvc = registrySvc;
+ this.pool = pool;
}
-
- /**
- * Creates a new PortletInvokerImpl-object. To be called within
- * an implementation of the abstract factory Provider.
- */
- public static PortletInvokerImpl create(PlutoProvider provider) {
-
- PortletInvokerImpl portletInvoker = new PortletInvokerImpl();
- portletInvoker.provider = provider;
-
- return portletInvoker;
- }
-
+
/**
* @see org.apache.wsrp4j.commons.producer.provider.interfaces.PortletInvoker#invokeGetMarkup(oasis.names.tc.wsrp.v1.types.GetMarkup)
*/
- public MarkupResponse invokeGetMarkup(GetMarkup request) {
-
- String MN = "invokeGetMarkup";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
+ public MarkupResponse invokeGetMarkup( GetMarkup request )
+ {
+ MarkupParams markupParams = request.getMarkupParams();
+ RuntimeContext runtimeContext = request.getRuntimeContext();
+ PortletContext portletContext = request.getPortletContext();
+ PortletWindow window = null;
+ try
+ {
+ window = getPortletWindow( markupParams, runtimeContext, portletContext );
+ }
+ catch ( Exception e )
+ {
+ String msg = "invokeGetMarkup failed: " + e.getMessage();
+ LOG.error( msg );
+ throw new RuntimeException( msg, e );
}
-
- // get PortletID from PortletContext
- String portletID = request.getPortletContext().getPortletHandle();
- PortletEntity portletEntity =
- PortletEntityRegistry.getPortletEntity(
- ObjectID.createFromString(portletID));
- PortletWindow win = null;
- String instanceKey =
- request.getRuntimeContext().getPortletInstanceKey();
- // determine window
- if (instanceKey != null) {
- win = getPortletWindow(portletEntity, instanceKey);
- } else {
- win = getPortletWindow(portletEntity, portletID);
- }
-
- Locale usedLocale = LocaleHelper.getLocale(
- request.getMarkupParams().getLocales()[0]);
-
+
+
+ Locale usedLocale = LocaleHelper.getLocale( request.getMarkupParams().getLocales()[0] );
+
StoredResponse servletResponse = new StoredResponse();
- HttpServletRequest servletRequestOrig =
- ServletAccess.getServletRequest();
+ HttpServletRequest servletRequestOrig = ServletAccess.getServletRequest();
+
// need to have a PortalEnvironment in request
// the constructor does this
- PortalEnvironment env =
- new PortalEnvironment(servletRequestOrig, servletResponse,
- ServletAccess.getServlet().getServletConfig());
-
- HttpServletRequest servletRequest =
- new WSRPServletRequestWrapperImpl(
- servletRequestOrig,
- win,
- usedLocale,
- request.getMarkupParams().getMimeTypes()[0],
- getMarkupParams(request));
-
- try {
+// PortalEnvironment env = new PortalEnvironment( servletRequestOrig, servletResponse, ServletAccess.getServlet()
+// .getServletConfig() );
+//
+ HttpServletRequest servletRequest = new WSRPServletRequestWrapperImpl( servletRequestOrig, usedLocale,
+ request.getMarkupParams().getMimeTypes()[0], getMarkupParams( request ) );
+
+ try
+ {
// set char encoding, default to UTF-8
- String[] charSets =
- request.getMarkupParams().getMarkupCharacterSets();
+ String[] charSets = request.getMarkupParams().getMarkupCharacterSets();
String charEncoding = null;
- if (charSets != null) {
+ if ( charSets != null )
+ {
charEncoding = charSets[0];
- } else {
+ }
+ else
+ {
charEncoding = Constants.UTF_8;
}
-
- servletRequest.setCharacterEncoding(charEncoding);
-
- //servletRequest.setCharacterEncoding(request.getMarkupParams().
- // getMarkupCharacterSets()[0]);
- } catch (java.io.UnsupportedEncodingException e) {
+
+ servletRequest.setCharacterEncoding( charEncoding );
+
+ // servletRequest.setCharacterEncoding(request.getMarkupParams().
+ // getMarkupCharacterSets()[0]);
}
-
- servletResponse.setLocale(usedLocale);
- servletResponse.setContentType(
- request.getMarkupParams().getMimeTypes()[0]);
-
+ catch ( java.io.UnsupportedEncodingException e )
+ {
+ LOG.warn( "Unable to set character encoding on servlet request: " + e.getMessage() );
+ }
+
+ servletResponse.setLocale( usedLocale );
+ servletResponse.setContentType( request.getMarkupParams().getMimeTypes()[0] );
+
// put getMarkup-request and Provider in servletRequest
- servletRequest.setAttribute(
- WSRPDynamicInformationProvider.REQUEST, request);
- servletRequest.setAttribute(
- WSRPDynamicInformationProvider.PROVIDER, this.provider);
-
+ servletRequest.setAttribute( AttrKeys.REQUEST, request );
+ //servletRequest.setAttribute( AttrKeys.PROVIDER, this.provider );
+
String markup = "Error occured while invoking portlet service!";
String locale = null;
-
- try {
- provider.getPortletContainer().renderPortlet(win, servletRequest,
- servletResponse);
-
+
+ try
+ {
+ //provider.getPortletContainer().renderPortlet( win, servletRequest, servletResponse );
+ container.doRender( window, servletRequest, servletResponse );
markup = servletResponse.getOutputBufferAsString();
-
+ LOG.debug( "Servlet Response: " + markup );
locale = servletResponse.getLocale().toString();
-
- } catch (Throwable t) {
+ }
+ catch ( Exception e )
+ {
locale = Constants.LOCALE_EN_US;
-
- if (log.isErrorEnabled()) {
- log.error("Call of portletService() failed!", t);
- }
-
+ LOG.error( "Portlet rendering failed: [" + e.getMessage() + "]", e );
}
-
+
// build MarkupResponse
MarkupResponse markupResponse = new MarkupResponse();
-
+
// set markupContext in markupResponse
- if (markup != null) {
+ if ( markup != null )
+ {
MarkupContext markupContext = new MarkupContext();
- markupContext.setMarkupString(markup);
- markupContext.setLocale(locale);
- markupContext.setMimeType(servletRequest.getContentType());
- markupResponse.setMarkupContext(markupContext);
- }
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+ markupContext.setMarkupString( markup );
+ markupContext.setLocale( locale );
+ markupContext.setMimeType( servletRequest.getContentType() );
+ markupResponse.setMarkupContext( markupContext );
}
+ LOG.debug( "Markup response: " + markupResponse.getMarkupContext().getMarkupString() );
return markupResponse;
}
-
+
/**
* @see org.apache.wsrp4j.commons.producer.provider.interfaces.PortletInvoker#invokePerformBlockingInteraction(oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction)
*/
- public BlockingInteractionResponse invokePerformBlockingInteraction(
- PerformBlockingInteraction request) {
-
- String MN = "invokePerformBlockingInteraction";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- // get portletID from PortletContext
- String portletID = request.getPortletContext().getPortletHandle();
- // get Portlet from PortletEntityRegistry by id
- PortletEntity portletEntity =
- PortletEntityRegistry.getPortletEntity(
- ObjectID.createFromString(portletID));
- PortletWindow win = null;
- String instanceKey =
- request.getRuntimeContext().getPortletInstanceKey();
-
- if (instanceKey != null) {
- win = getPortletWindow(portletEntity, instanceKey);
- } else {
- win = getPortletWindow(portletEntity, portletID);
+ public BlockingInteractionResponse invokePerformBlockingInteraction( PerformBlockingInteraction request )
+ {
+ MarkupParams markupParams = request.getMarkupParams();
+ RuntimeContext runtimeContext = request.getRuntimeContext();
+ PortletContext portletContext = request.getPortletContext();
+ PortletWindow window = null;
+ try
+ {
+ window = getPortletWindow( markupParams, runtimeContext, portletContext );
+ }
+ catch ( Exception e )
+ {
+ String msg = "invokeGetMarkup failed: " + e.getMessage();
+ LOG.error( msg );
+ throw new RuntimeException( msg, e );
}
-
- Locale usedLocale = LocaleHelper.getLocale(
- request.getMarkupParams().getLocales()[0]);
-
+
+ Locale usedLocale = LocaleHelper.getLocale( request.getMarkupParams().getLocales()[0] );
+
StoredResponse servletResponse = new StoredResponse();
- HttpServletRequest servletRequestOrig =
- ServletAccess.getServletRequest();
- // need to have a PortalEnvironment in request
- // the constructor does this
- PortalEnvironment env =
- new PortalEnvironment(servletRequestOrig, servletResponse,
- ServletAccess.getServlet().getServletConfig());
-
- HttpServletRequest servletRequest =
- new WSRPServletRequestWrapperImpl(
- servletRequestOrig,
- win,
- usedLocale,
- request.getMarkupParams().getMimeTypes()[0],
- getInteractionParams(request));
+ HttpServletRequest servletRequestOrig = ServletAccess.getServletRequest();
+
+ HttpServletRequest servletRequest = new WSRPServletRequestWrapperImpl( servletRequestOrig, usedLocale,
+ request.getMarkupParams().getMimeTypes()[0], getInteractionParams( request ) );
+ servletRequest.setAttribute( AttrKeys.REQUEST, request );
- try {
+ try
+ {
// set char encoding, default to UTF-8
- String[] charSets =
- request.getMarkupParams().getMarkupCharacterSets();
+ String[] charSets = request.getMarkupParams().getMarkupCharacterSets();
String charEncoding = null;
- if (charSets != null) {
+ if ( charSets != null )
+ {
charEncoding = charSets[0];
- } else {
+ }
+ else
+ {
charEncoding = Constants.UTF_8;
}
-
- servletRequest.setCharacterEncoding(charEncoding);
- } catch (java.io.UnsupportedEncodingException e) {
+
+ servletRequest.setCharacterEncoding( charEncoding );
}
-
- servletResponse.setLocale(usedLocale);
-
- // put performBlockingInteraction-request and Provider in servletRequest
- servletRequest.setAttribute(
- WSRPDynamicInformationProvider.REQUEST, request);
- servletRequest.setAttribute(
- WSRPDynamicInformationProvider.PROVIDER, this.provider);
-
+ catch ( java.io.UnsupportedEncodingException e )
+ {
+ }
+
+ servletResponse.setLocale( usedLocale );
+
String markup = "";
String locale = "";
-
- try {
-
- provider.getPortletContainer().processPortletAction(win,
- servletRequest, servletResponse);
-
+
+ try
+ {
+ container.doAction( window, servletRequest, servletResponse );
markup = servletResponse.getOutputBufferAsString();
locale = servletResponse.getLocale().toString();
-
- } catch (Throwable e) {
- if (log.isErrorEnabled()) {
- log.error("Call of performPortletAction() failed!", e);
- }
}
-
+ catch ( Throwable e )
+ {
+ String msg = "performBlockingInteraction failed: " + e.getMessage();
+ LOG.error( msg );
+ throw new RuntimeException( msg, e );
+ }
+
// create new BlockingInteractionResponse
- BlockingInteractionResponse blockingInteractionResponse =
- new BlockingInteractionResponse();
-
+ BlockingInteractionResponse blockingInteractionResponse = new BlockingInteractionResponse();
+
// new UpdateResponse
UpdateResponse updateResponse = new UpdateResponse();
-
+
// set the nav state
// get render params from servlet request and serialize the map
String navState = null;
- Map renderParams = (Map) servletRequest.getAttribute(
- WSRPDynamicInformationProvider.RENDER_PARAMS);
- if (renderParams != null) {
- try {
- navState = Base64.encode(MapSerializer.serialize(renderParams));
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Could not serialize and " +
- "encode render params", e);
- }
+ Map renderParams = (Map) servletRequest.getAttribute( AttrKeys.RENDER_PARAMS );
+ if ( renderParams != null )
+ {
+ try
+ {
+ navState = Base64.encode( MapSerializer.serialize( renderParams ) );
+ }
+ catch ( IOException e )
+ {
+ String msg = "Could not encode render parameters: " + e.getMessage();
+ LOG.error( msg );
+ throw new RuntimeException( msg, e );
}
}
-
- updateResponse.setNavigationalState(navState);
-
+
+ updateResponse.setNavigationalState( navState );
+
// set markupContext in interactionResponse
- if ((markup != null) && (markup.length() != 0)) {
+ if ( ( markup != null ) && ( markup.length() != 0 ) )
+ {
MarkupContext markupContext = new MarkupContext();
- markupContext.setLocale(locale);
- markupContext.setMimeType(servletRequest.getContentType());
- markupContext.setMarkupString(markup);
- updateResponse.setMarkupContext(markupContext);
+ markupContext.setLocale( locale );
+ markupContext.setMimeType( servletRequest.getContentType() );
+ markupContext.setMarkupString( markup );
+ updateResponse.setMarkupContext( markupContext );
}
-
+
// set the updateResponse of the blockingInteraction
- blockingInteractionResponse.setUpdateResponse(updateResponse);
- blockingInteractionResponse.setRedirectURL(null);
- blockingInteractionResponse.setExtensions(null);
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
+ blockingInteractionResponse.setUpdateResponse( updateResponse );
+ blockingInteractionResponse.setRedirectURL( null );
+ blockingInteractionResponse.setExtensions( null );
+
return blockingInteractionResponse;
}
-
+
/**
- * Internal method
- * Return the portlet window for a portlet entity with a particular
- * identifier
- * @param portletEntity the portlet entity
- * @param id String representing a portlet window idendtifier
+ * Internal method Return the portlet window for a portlet entity with a
+ * particular identifier
+ *
+ * @param portletEntity
+ * the portlet entity
+ * @param id
+ * String representing a portlet window idendtifier
*/
- private PortletWindow getPortletWindow(PortletEntity portletEntity,
- String id) {
-
- String MN = "getPortletWindow";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- PortletWindow win = null;
-
- PortletWindowList windows = portletEntity.getPortletWindowList();
-
- if (windows.get(ObjectID.createFromString(id)) != null) {
- win = windows.get(ObjectID.createFromString(id));
- } else {
- win = new PortletWindowImpl(id);
- ((PortletWindowCtrl)win).setPortletEntity(portletEntity);
- ((PortletWindowListCtrl)portletEntity.getPortletWindowList()).
- add(win);
-
- if (log.isInfoEnabled()) {
- log.info("New portlet window created!");
- }
-
- }
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
- return win;
-
- }
+// private PortletWindow getPortletWindow( PortletEntity portletEntity, String id )
+// {
+//
+// String MN = "getPortletWindow";
+//
+// if ( log.isDebugEnabled() )
+// {
+// log.debug( Utility.strEnter( MN ) );
+// }
+//
+// PortletWindow win = null;
+//
+// PortletWindowList windows = portletEntity.getPortletWindowList();
+//
+// if ( windows.get( ObjectID.createFromString( id ) ) != null )
+// {
+// win = windows.get( ObjectID.createFromString( id ) );
+// }
+// else
+// {
+// win = new PortletWindowImpl( id );
+// ( (PortletWindowCtrl) win ).setPortletEntity( portletEntity );
+// ( (PortletWindowListCtrl) portletEntity.getPortletWindowList() ).add( win );
+//
+// if ( log.isInfoEnabled() )
+// {
+// log.info( "New portlet window created!" );
+// }
+//
+// }
+//
+// if ( log.isDebugEnabled() )
+// {
+// log.debug( Utility.strExit( MN ) );
+// }
+//
+// return win;
+//
+// }
- private Map getMarkupParams(GetMarkup markupRequest) {
+ private PortletWindow getPortletWindow( MarkupParams params, RuntimeContext runtimeContext, PortletContext portletContext )
+ throws WSRPException, PortletContainerException
+ {
+ String appId = null;
+ String portletName = null;
+
+ // Look up the portlet from the JSR 168 container
+ // registry service.
+
+ // We need to use the portlet handle of the producer
+ // offered portlet to look up from the registry service.
+
+ String portletHandle = portletContext.getPortletHandle();
+ Portlet portlet = pool.get( portletHandle );
+ if ( portlet instanceof ConsumerConfiguredPortlet )
+ {
+ String parentHandle = ( (ConsumerConfiguredPortlet) portlet ).getParentHandle();
+ appId = parentHandle.substring( 0, parentHandle.lastIndexOf( "/" ) );
+ portletName = parentHandle.substring( parentHandle.lastIndexOf( "/" ) + 1 );
+ }
+ else
+ {
+ appId = portletHandle.substring( 0, portletHandle.lastIndexOf( "/" ) );
+ portletName = portletHandle.substring( portletHandle.lastIndexOf( "/" ) + 1 );
+ }
+
+ String instanceKey = runtimeContext.getPortletInstanceKey();
+
+ PortletWindow window = new org.apache.wsrp4j.producer.provider.pluto.driver.PortletWindowImpl( portletName,
+ appId, ModesMap.forWsrpMode( params.getMode() ),
+ WindowStateMap.forWsrpWindowState( params.getWindowState() ), instanceKey );
+
+ return window;
+ }
+
+ private Map getMarkupParams( GetMarkup markupRequest )
+ {
Map navParams = new HashMap();
-
- String naviStateStr =
- markupRequest.getMarkupParams().getNavigationalState();
- if (naviStateStr != null) {
-
- byte[] desMap = Base64.decode(naviStateStr);
-
+
+ String naviStateStr = markupRequest.getMarkupParams().getNavigationalState();
+ if ( naviStateStr != null )
+ {
+
+ byte[] desMap = Base64.decode( naviStateStr );
+
Map naviState = null;
- try {
- naviState = MapDeserializer.deserialize(desMap);
- } catch (IOException iox) {
- } catch (ClassNotFoundException classNotFoundEx) {
- }
-
- if (naviState != null) {
- navParams.putAll(naviState);
+ try
+ {
+ naviState = MapDeserializer.deserialize( desMap );
+ }
+ catch ( IOException iox )
+ {
+ }
+ catch ( ClassNotFoundException classNotFoundEx )
+ {
+ }
+
+ if ( naviState != null )
+ {
+ navParams.putAll( naviState );
}
}
-
+
return navParams;
}
-
- private Map getInteractionParams(
- PerformBlockingInteraction blockingInteractionRequest) {
-
+
+ private Map getInteractionParams( PerformBlockingInteraction blockingInteractionRequest )
+ {
+
Map actionParams = new HashMap();
-
- String actionStateStr =
- blockingInteractionRequest.getInteractionParams().
- getInteractionState();
- if (actionStateStr != null) {
-
- byte[] desMap = Base64.decode(actionStateStr);
-
+
+ String actionStateStr = blockingInteractionRequest.getInteractionParams().getInteractionState();
+ if ( actionStateStr != null )
+ {
+
+ byte[] desMap = Base64.decode( actionStateStr );
+
Map actionState = null;
- try {
- actionState = MapDeserializer.deserialize(desMap);
- } catch (IOException iox) {
- } catch (ClassNotFoundException classNotFoundEx) {
+ try
+ {
+ actionState = MapDeserializer.deserialize( desMap );
+ }
+ catch ( IOException iox )
+ {
}
-
- if (actionState != null) {
- actionParams.putAll(actionState);
+ catch ( ClassNotFoundException classNotFoundEx )
+ {
+ }
+
+ if ( actionState != null )
+ {
+ actionParams.putAll( actionState );
}
}
-
- actionParams.putAll(getFormParameters(blockingInteractionRequest.
- getInteractionParams().getFormParameters()));
-
+
+ actionParams
+ .putAll( getFormParameters( blockingInteractionRequest.getInteractionParams().getFormParameters() ) );
+
return actionParams;
}
-
+
/**
- * Internal method.
- * Return the FORM parameters as Map
- * @param params array of NamedString objects
+ * Internal method. Return the FORM parameters as Map
+ *
+ * @param params
+ * array of NamedString objects
* @return java.util.Map containing the FORM parameters and values
*/
- private static Map getFormParameters(NamedString[] params) {
-
+ private static Map getFormParameters( NamedString[] params )
+ {
+
HashMap tmp = new HashMap();
-
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
+
+ if ( params != null )
+ {
+ for ( int i = 0; i < params.length; i++ )
+ {
String parameterName = params[i].getName();
- if (tmp.containsKey(parameterName)) {
+ if ( tmp.containsKey( parameterName ) )
+ {
// Handle case in which parameter name has multiple values
- String[] currentValues = (String[])tmp.get(parameterName);
- String[] newValues = new String[currentValues.length+1];
- System.arraycopy(currentValues, 0, newValues, 0,
- currentValues.length);
+ String[] currentValues = (String[]) tmp.get( parameterName );
+ String[] newValues = new String[currentValues.length + 1];
+ System.arraycopy( currentValues, 0, newValues, 0, currentValues.length );
newValues[currentValues.length] = params[i].getValue();
- tmp.put(parameterName, newValues);
- } else {
- String[] values = { params[i].getValue()};
- tmp.put(parameterName, values);
+ tmp.put( parameterName, newValues );
+ }
+ else
+ {
+ String[] values = { params[i].getValue() };
+ tmp.put( parameterName, values );
}
}
}
-
+
return tmp;
}
-
+
}
Modified: portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletPoolImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletPoolImpl.java?rev=569721&r1=569720&r2=569721&view=diff
==============================================================================
--- portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletPoolImpl.java (original)
+++ portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletPoolImpl.java Sat Aug 25 12:35:34 2007
@@ -15,621 +15,531 @@
*/
package org.apache.wsrp4j.producer.provider.pluto.driver;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import java.util.NoSuchElementException;
import java.util.Set;
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import org.apache.pluto.om.entity.PortletEntity;
-import org.apache.pluto.om.entity.PortletEntityList;
-
-import org.apache.pluto.portalImpl.om.entity.impl.PortletEntityImpl;
-import org.apache.pluto.portalImpl.om.entity.impl.PortletEntityListImpl;
-
-import org.apache.pluto.portalImpl.services.portletentityregistry.
- PortletEntityRegistryServiceFileImpl;
-
-import org.apache.pluto.portalImpl.util.ObjectID;
-import org.apache.pluto.portalImpl.util.Properties;
-
-import org.apache.wsrp4j.commons.producer.provider.interfaces.
- ConsumerConfiguredPortlet;
-import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletPool;
-import org.apache.wsrp4j.commons.producer.provider.interfaces.
- ProducerOfferedPortlet;
-import org.apache.wsrp4j.commons.producer.provider.interfaces.
- Provider;
-import org.apache.wsrp4j.commons.producer.provider.interfaces.Portlet;
-import org.apache.wsrp4j.commons.producer.provider.driver.
- ConsumerConfiguredPortletImpl;
-import org.apache.wsrp4j.commons.producer.provider.driver.
- ProducerOfferedPortletImpl;
-
-import org.apache.wsrp4j.producer.provider.pluto.interfaces.PlutoPortletPool;
-
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.spi.optional.PortletRegistryEvent;
+import org.apache.pluto.spi.optional.PortletRegistryListener;
+import org.apache.pluto.spi.optional.PortletRegistryService;
import org.apache.wsrp4j.commons.exception.ErrorCodes;
import org.apache.wsrp4j.commons.exception.WSRPException;
-import org.apache.wsrp4j.commons.exception.WSRPXHelper;
-
import org.apache.wsrp4j.commons.persistence.PersistentDataObject;
-import org.apache.wsrp4j.commons.persistence.ProducerPersistentFactory;
import org.apache.wsrp4j.commons.persistence.PersistentHandler;
-import org.apache.wsrp4j.commons.persistence.driver.PersistentAccess;
-
+import org.apache.wsrp4j.commons.persistence.ProducerPersistentFactory;
+import org.apache.wsrp4j.commons.producer.provider.driver.ConsumerConfiguredPortletImpl;
+import org.apache.wsrp4j.commons.producer.provider.driver.ProducerOfferedPortletImpl;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.ConsumerConfiguredPortlet;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.Portlet;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletPool;
+import org.apache.wsrp4j.commons.producer.provider.interfaces.ProducerOfferedPortlet;
import org.apache.wsrp4j.commons.util.HandleGenerator;
-import org.apache.wsrp4j.commons.util.HandleGeneratorFactory;
-import org.apache.wsrp4j.commons.util.impl.HandleGeneratorFactoryImpl;
-
-import org.apache.wsrp4j.commons.util.Utility;
-
/**
- * <p>This class implements the PortletPool interface. ProducerOfferedPortlets
- * and ConsumerConfiguredPortlets are kept within different hashmaps
- * associating portlet handles (keys) with portlet-objects (values). See
- * interfaces ProducerOfferedPortlet and ConsumerConfiguredPortlet.</p>
- * <p>TODO:
+ * <p>
+ * This class implements the PortletPool interface. ProducerOfferedPortlets and
+ * ConsumerConfiguredPortlets are kept within different hashmaps associating
+ * portlet handles (keys) with portlet-objects (values). See interfaces
+ * ProducerOfferedPortlet and ConsumerConfiguredPortlet.
+ * </p>
+ * <p>
+ * TODO:
* <ul>
- * <li>Synchronization aspects are not considered so far. This could be
- * achieved by using a hashtable instead of a hashmap.
- * </li>
+ * <li>Synchronization aspects are not considered so far. This could be
+ * achieved by using a hashtable instead of a hashmap. </li>
* </ul>
* </p>
- *
+ *
* @see PortletPool
* @version $Id$
*/
-public class PortletPoolImpl extends PortletEntityRegistryServiceFileImpl
- implements PlutoPortletPool {
-
- private static final Log log = LogFactory.getLog(PortletPoolImpl.class);
-
- // provider
- private Provider provider;
- //handle generator
- private HandleGenerator handleGenerator;
-
- // persistence
- private PersistentDataObject persistentDataObject;
- private PersistentHandler persistentHandler;
-
- //holds consumer configured portlets
- private Map consumerConfiguredPortlets = new HashMap();
- //holds producer offered portlets
- private Map producerOfferedPortlets = new HashMap();
-
- // TODO: read this value from a property file
- private static boolean REGISTRATION_REQUIRED = false;
-
+public class PortletPoolImpl implements PortletPool
+{
/**
- * Private constructor of PortletPoolImpl.
- *
- * Creates a HashMap for the ProducerOfferedPortlet and
- * ConsumerConfiguredPortlet object instances. If the subdirectory for the
- * persistent file store is not already available, it will be created. If
- * the file store is available, it will be scanned for xml files to be
- * restored to ProducerOfferedPortlet objects.
- * See the restore() method for more details.
+ * Logger
*/
- public PortletPoolImpl() {
- super();
-
- String MN = "PortletPoolImpl";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- HandleGeneratorFactory handleGenFactory =
- new HandleGeneratorFactoryImpl();
- handleGenerator = handleGenFactory.getHandleGenerator();
-
- // restore registration objects from persistent file store
-
- try {
- ProducerPersistentFactory persistentFactory =
- PersistentAccess.getProducerPersistentFactory();
- persistentHandler = persistentFactory.getPersistentHandler();
- persistentDataObject =
- persistentFactory.getConsumerConfiguredPortletList();
-
+ private static final Log LOG = LogFactory.getLog( PortletPoolImpl.class );
+
+ /**
+ * Handle Generator
+ */
+ private HandleGenerator handleGenerator = null;
+
+ /**
+ * Persistence handling
+ */
+ private PersistentDataObject persistentDataObject = null;
+
+ private PersistentHandler persistentHandler = null;
+
+ /**
+ * PortletRegistry
+ */
+ private PortletRegistryService portletRegistry = null;
+
+ /**
+ * Map of consumer configured portlets.
+ */
+ private Map /* String handle, ConsumerConfiguredPortlet portlet */consumerConfiguredPortlets = new HashMap();
+
+ /**
+ * Map of producer offered portlets.
+ */
+ private Map /* String handle, ProducerOfferedPortlet portlet */producerOfferedPortlets = new HashMap();
+
+ /**
+ * If registration is required TODO: read this value from a property file
+ */
+ private static boolean REGISTRATION_REQUIRED = false;
+
+ /**
+ * Creates a HashMap for the ProducerOfferedPortlet and
+ * ConsumerConfiguredPortlet object instances. If the subdirectory for the
+ * persistent file store is not already available, it will be created. If
+ * the file store is available, it will be scanned for xml files to be
+ * restored to ProducerOfferedPortlet objects. See the restore() method for
+ * more details.
+ */
+ public PortletPoolImpl( HandleGenerator handleGenerator, ProducerPersistentFactory persistenceFactory,
+ PortletRegistryService portletRegistry )
+ {
+ if ( handleGenerator == null )
+ {
+ final String msg = "The handle generator must not be null.";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ if ( persistenceFactory == null )
+ {
+ final String msg = "The persistence factory must not be null.";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ if ( portletRegistry == null )
+ {
+ final String msg = "The portlet registry must not be null.";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+
+ this.handleGenerator = handleGenerator;
+ this.portletRegistry = portletRegistry;
+
+
+ // restore registration objects from persistent store
+
+ try
+ {
+ this.persistentHandler = persistenceFactory.getPersistentHandler();
+ this.persistentDataObject = persistenceFactory.getConsumerConfiguredPortletList();
restore();
-
- } catch (WSRPException e) {
- if (log.isErrorEnabled()) {
- log.error("PortletPoolImpl constructor failed!", e);
- }
- //TODO: throw exception
+ init();
}
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+ catch ( Exception e )
+ {
+ String msg = "Unable to restore registration information from persistent store: ";
+ Throwable cause = e.getCause();
+ if ( cause != null )
+ {
+ LOG.warn( msg + cause.getMessage() );
+ }
+ else
+ {
+ LOG.warn( msg + e.getMessage() );
+ }
+ //throw new RuntimeException( msg + e.getMessage(), e );
}
-
}
-
+
/**
* Initialize the portlet pool
- * @param servletConfig servlet configuration
+ *
+ * @param servletConfig
+ * servlet configuration
* @param properties
*/
- public void init(ServletConfig servletConfig, Properties properties)
- throws Exception {
+ private synchronized void init( ) throws Exception
+ {
+ LOG.info( "**** Initializing WSRP4J Portlet Pool ****" );
- String MN = "init";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- super.init(servletConfig, properties);
-
- //TODO: get consumerConfiguredIDs from persistence
+ // TODO: get consumerConfiguredIDs from persistence
Set consumerConfiguredIDs = new java.util.HashSet();
-
- Iterator portlets = getPortletEntities().keySet().iterator();
-
- while (portlets.hasNext()) {
- String id = (String)portlets.next();
- PortletEntity portletEntity =
- getPortletEntity(ObjectID.createFromString(id));
-
- if (consumerConfiguredIDs.contains(id)) {
-
- ConsumerConfiguredPortletImpl portlet =
- new ConsumerConfiguredPortletImpl();
- portlet.setPortletHandle(portletEntity.getId().toString());
- portlet.setParentHandle(null);
- //TODO: where would we store this?
- consumerConfiguredPortlets.put(
- portlet.getPortletHandle(), portlet);
-
- } else {
-
- // TODO: do not store producer offered portlets
- ProducerOfferedPortletImpl portlet =
- new ProducerOfferedPortletImpl();
- portlet.setPortletHandle(portletEntity.getId().toString());
- portlet.setRegistrationRequired(REGISTRATION_REQUIRED);
- //TODO: get setting from some config
- producerOfferedPortlets.put(
- portlet.getPortletHandle(), portlet);
-
+
+ // Iterator portlets = getPortletEntities().keySet().iterator();
+ Iterator portletAppIds = portletRegistry.getRegisteredPortletApplicationIds();
+
+ while ( portletAppIds.hasNext() )
+ {
+ String appId = (String) portletAppIds.next();
+ PortletAppDD appDD = portletRegistry.getPortletApplicationDescriptor( appId );
+ for ( Iterator portlets = appDD.getPortlets().iterator(); portlets.hasNext(); )
+ {
+ PortletDD portletDD = (PortletDD) portlets.next();
+ String id = appId + "/" + portletDD.getPortletName();
+ if ( consumerConfiguredIDs.contains( id ) )
+ {
+ ConsumerConfiguredPortlet portlet = createConsumerConfigurePortlet( appId, portletDD );
+ consumerConfiguredPortlets.put( id, portlet );
+ }
+ else
+ {
+ ProducerOfferedPortlet portlet = createProducerOfferedPortlet( appId, portletDD );
+ producerOfferedPortlets.put( id, portlet );
+ }
}
-
- }
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
}
+ portletRegistry.addPortletRegistryListener( new PortletRegistryListenerImpl() );
+ LOG.info( "Added listener to portlet registry [" + portletRegistry + "]" );
+ LOG.info( "Initialized [" + consumerConfiguredPortlets.size() + "] consumer configured portlets." );
+ LOG.info( "Initialized [" + producerOfferedPortlets.size() + "] producer offered portlets." );
+ LOG.info( "**** WSRP4J Portlet Pool Initialized ****" );
}
-
+
/**
- * Return the provider
- * @return Provider
- */
- public Provider getProvider() {
- return provider;
- }
-
- /**
- * Set the provider
- * @param provider
- */
- public void setProvider(Provider provider) {
- this.provider = provider;
- }
-
- /**
- * <p>Clones the portlet (ProducerOffered or ConsumerConfiguredPortlet)
- * associated by portlet-handle. Only the portlet-object is cloned, not
- * the portlet-description the portlet references, i.e. the resulting
- * cloned portlet references the same portlet-description as its original.
- * </p>
- * <p>Assigns a new portletHandle to the clone to enable identification.
- * </p>
- * <p>Adds the new ConsumerConfiguredPortlet to the hashmap after cloning.
- * </p>
- *
- * @param portletHandle String identifying the portlet to be cloned.
- *
- * @return ConsumerConfiguredPortlet The portlet-clone.
- */
- public synchronized Portlet clone(String portletHandle) {
-
- String MN = "clone";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- String newID = handleGenerator.generateHandle();
- String newPortletHandle = "";
-
- // 1) clone portlet in JSR 168 portletPool
-
- // get portlet
- PortletEntity portletEntity = getPortletEntity(
- ObjectID.createFromString(portletHandle));
-
- WSRPPortletEntityImpl portletClone = null;
- ConsumerConfiguredPortlet clone = null;
- PortletEntityList portletEntityList = null;
-
- try {
- // copy attributes
- portletClone =
- (WSRPPortletEntityImpl)
- ((WSRPPortletEntityImpl)portletEntity).clone();
- portletClone.setId(newID);
-
- // add new portlet to portlet pool
- getPortletEntities().put(portletClone.getId().toString(),
- portletClone);
- portletEntityList =
- portletEntity.getPortletApplicationEntity().
- getPortletEntityList();
- ((PortletEntityListImpl)portletEntityList).add(portletClone);
-
- // get portletHandle
- newPortletHandle = portletClone.getId().toString();
-
- // 2) clone portlet in WSRP portletPool
-
- ConsumerConfiguredPortlet cce =
- (ConsumerConfiguredPortlet)
- consumerConfiguredPortlets.get(portletHandle);
-
- if (cce != null) {
+ * Clones the portlet (ProducerOffered or ConsumerConfiguredPortlet)
+ * associated by portlet-handle. Only the portlet-object is cloned, not the
+ * portlet-description the portlet references, i.e. the resulting cloned
+ * portlet references the same portlet-description as its original. <p/>
+ * Assigns a new portletHandle to the clone to enable identification. <p/>
+ * Adds the new ConsumerConfiguredPortlet to the hashmap after cloning.
+ *
+ * @param portletHandle
+ * String identifying the portlet to be cloned.
+ * @return ConsumerConfiguredPortlet The portlet-clone.
+ */
+ public synchronized Portlet clone( String portletHandle )
+ {
+ String newPortletHandle = handleGenerator.generateHandle();
+ ConsumerConfiguredPortlet clone = null;
+
+ try
+ {
+ ConsumerConfiguredPortlet cce = (ConsumerConfiguredPortlet) consumerConfiguredPortlets.get( portletHandle );
+
+ if ( cce != null )
+ {
// portlet to be cloned is a Consumer Configured Portlet
- clone = (ConsumerConfiguredPortlet)cce.clone();
- clone.setPortletHandle(newPortletHandle);
-
- } else {
+ clone = (ConsumerConfiguredPortlet) cce.clone();
+ clone.setPortletHandle( newPortletHandle );
+ }
+ else
+ {
// portlet to be cloned is a Producer Offered Portlet
clone = new ConsumerConfiguredPortletImpl();
-
- clone.setPortletHandle(newPortletHandle);
- clone.setParentHandle(portletHandle);
+ clone.setPortletHandle( newPortletHandle );
+ clone.setParentHandle( portletHandle );
}
-
+
// add clone to hashmap consumerConfiguredPortlets
- consumerConfiguredPortlets.put(newPortletHandle, clone);
-
+ consumerConfiguredPortlets.put( newPortletHandle, clone );
+
// store new clone to persistent file
persistentDataObject.clear();
- persistentDataObject.addObject(clone);
-
- } catch (Throwable t) {
- if (log.isErrorEnabled()) {
- log.error("Clone portlet failed!", t);
- }
+ persistentDataObject.addObject( clone );
}
-
- try {
-
+ catch ( Exception e )
+ {
+ // cleanup on error
+ consumerConfiguredPortlets.remove( newPortletHandle );
+ final String msg = "Unable to clone portlet identified by portletHandle [" + portletHandle + "]: ";
+ LOG.error( msg + e.getMessage(), e );
+ return null;
+ }
+
+ try
+ {
// store object to persistent store
- store(persistentDataObject);
-
- // persist objects in PortletEntityRegistryServiceFile
- super.store();
-
- } catch (Exception e) {
-
+ store( persistentDataObject );
+ }
+ catch ( Exception e )
+ {
// cleanup on error
- consumerConfiguredPortlets.remove(newPortletHandle);
- if(portletEntityList != null) {
- ((PortletEntityListImpl)portletEntityList).remove(portletClone);
- }
-
- //TODO: throw exception
-
+ consumerConfiguredPortlets.remove( newPortletHandle );
+ final String msg = "Unable to persist portlet [" + newPortletHandle + "] (cloned from [" + portletHandle + "]): ";
+ LOG.error( msg + e.getMessage(), e );
+ return null;
}
-
+
// TODO: clone portletState within PortletStateManager?
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
+
return clone;
-
}
-
+
/**
* Returns all ProducerOfferedPortlet objects.
- *
- * @return Iterator of an portlet collection
+ *
+ * @return Iterator of an portlet collection
*/
- public Iterator getAllProducerOfferedPortlets() {
-
- String MN = "getAllProducerOfferedPortlets";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- Iterator portlets = getPortletEntities().keySet().iterator();
- LinkedList result = new LinkedList();
-
- while (portlets.hasNext()) {
- try {
- String id = (String)portlets.next();
- PortletEntity portletEntity =
- getPortletEntity(ObjectID.createFromString(id));
-
- if (!consumerConfiguredPortlets.containsKey(id)) {
- ProducerOfferedPortlet portlet =
- new ProducerOfferedPortletImpl();
- portlet.setPortletHandle(portletEntity.getId().toString());
- portlet.setRegistrationRequired(REGISTRATION_REQUIRED);
-
- result.add(portlet);
- }
- } catch (NoSuchElementException e) {
- // TODO
- e.printStackTrace();
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
- return result.iterator();
+ public Iterator getAllProducerOfferedPortlets( )
+ {
+ Map copy = new HashMap( producerOfferedPortlets.size() );
+ for ( Iterator entries = producerOfferedPortlets.entrySet().iterator(); entries.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String portletId = (String) entry.getKey();
+ ProducerOfferedPortlet copiedPortlet = copyProducerOfferedPortlet( (ProducerOfferedPortlet) entry
+ .getValue() );
+ copy.put( portletId, copiedPortlet );
+ }
+ return copy.values().iterator();
}
-
+
/**
- * Returns all ConsumerConfiguredPortlets currently stored in
- * the hashmap consumerConfiguredPortlets.
- *
- * @return Iterator of an portlet collection containing all portlets.
- */
- public Iterator getAllConsumerConfiguredPortlets() {
-
- return consumerConfiguredPortlets.values().iterator();
-
+ * Returns all ConsumerConfiguredPortlets currently stored in the hashmap
+ * consumerConfiguredPortlets.
+ *
+ * @return Iterator of an portlet collection containing all portlets.
+ */
+ public Iterator getAllConsumerConfiguredPortlets( )
+ {
+ Map copy = new HashMap( consumerConfiguredPortlets.size() );
+ for ( Iterator entries = consumerConfiguredPortlets.entrySet().iterator(); entries.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String portletId = (String) entry.getKey();
+ ConsumerConfiguredPortlet copiedPortlet = copyConsumerConfiguredPortlet( (ConsumerConfiguredPortlet) entry
+ .getValue() );
+ copy.put( portletId, copiedPortlet );
+ }
+ return copy.values().iterator();
}
-
+
/**
* Returns a certain portlet identified by portletHandle.
- *
- * @param portletHandle String representing the portletHandle.
- *
- * @return ProducerOfferedPortlet object associated with portletHandle.
+ *
+ * @param portletHandle
+ * String representing the portletHandle.
+ * @return ProducerOfferedPortlet object associated with portletHandle.
+ * @throws WSRPException
+ * if portletHandle is not found
*/
- public Portlet get(String portletHandle)
- throws WSRPException {
-
- String MN = "get";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
+ public Portlet get( String portletHandle ) throws WSRPException
+ {
Portlet portlet = null;
-
- if (consumerConfiguredPortlets.containsKey(portletHandle)) {
+
+ if ( consumerConfiguredPortlets.containsKey( portletHandle ) )
+ {
// portlet is a consumer configured portlet
- portlet = (Portlet) consumerConfiguredPortlets.get(portletHandle);
- } else {
+ portlet = (Portlet) consumerConfiguredPortlets.get( portletHandle );
+ }
+ else
+ {
// portlet is a producer offered portlet
- // ensure that corresponding portlet exists
- if (getPortletEntities().containsKey(portletHandle)) {
-
- ProducerOfferedPortlet poe = new ProducerOfferedPortletImpl();
- poe.setPortletHandle(portletHandle);
- poe.setRegistrationRequired(REGISTRATION_REQUIRED);
-
- portlet = poe;
-
- } else {
-
- // portlet not found
- WSRPXHelper.throwX(log, ErrorCodes.GET_PORTLET_FAILED);
-
- }
+ portlet = (Portlet) producerOfferedPortlets.get( portletHandle );
}
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+
+ if ( portlet == null )
+ {
+ // portlet wasn't found
+ String msg = "Portlet with handle [" + portletHandle + "] was not found.";
+ WSRPException e = new WSRPException( ErrorCodes.GET_PORTLET_FAILED );
+ LOG.error( msg, e );
+ throw e;
}
-
+
return portlet;
}
-
+
/**
* Deletes the portlet identified by portletHandle from the PortletPool.
- * Only consumer configured portlets can be deleted, NOT producer offered
- * ones. After update, the persistent file store is refreshed.
- * Deletes all existing portlet sessions (SessionHandler) and portlet states
+ * Only consumer configured portlets can be deleted, NOT producer offered
+ * ones. After update, the persistent file store is refreshed. Deletes all
+ * existing portlet sessions (SessionHandler) and portlet states
* (PortletStateManager) as well.
- *
- * @param portletHandle String representing the portletHandle.
- *
- * @return Boolean indicating if deletion was successful. Returns false if
+ *
+ * @param portletHandle
+ * String representing the portletHandle.
+ *
+ * @return Boolean indicating if deletion was successful. Returns false if
* the portlet handle refers to a producer offered portlet.
*/
- public synchronized boolean destroy(String portletHandle) {
-
- String MN = "destroy";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- boolean retVal = true;
-
- ConsumerConfiguredPortlet cce =
- (ConsumerConfiguredPortlet)
- consumerConfiguredPortlets.get(portletHandle);
-
+ public synchronized boolean destroy( String portletHandle )
+ {
+ ConsumerConfiguredPortlet portlet = (ConsumerConfiguredPortlet) consumerConfiguredPortlets.get( portletHandle );
+
// TODO: delete portlet states as well
- // PortletStateManager portletStateManager =
- // provider.getPortletStateManager();
-
- // ensure that the portlet to be deleted is a consumer configured
+ // PortletStateManager portletStateManager =
+ // provider.getPortletStateManager();
+
+ // ensure that the portlet to be deleted is a consumer configured
// portlet
- if (cce != null) {
-
- // 1) delete portlet in portlet pool
-
- // get portlet
- PortletEntityImpl portletEntity =
- (PortletEntityImpl)getPortletEntity(
- ObjectID.createFromString(portletHandle));
-
- if (portletEntity != null) {
-
- getPortletEntities().remove(portletEntity.getId().toString());
-
- PortletEntityList portletEntityList =
- portletEntity.getPortletApplicationEntity().
- getPortletEntityList();
- ((PortletEntityListImpl) portletEntityList).
- remove(portletEntity);
-
- try {
-
- // update persistent objects in
- // PortletEntityRegistryServiceFile
- super.store();
-
- // 2) delete corresponding consumer configured portlet in
- // portlet pool
-
- // remove cce
- consumerConfiguredPortlets.remove(portletHandle);
-
- // TODO: destroy portlet states as well
- // portletStateManager.destroy(portletHandle);
-
- // delete the persistentFileStore for this portlet
- persistentDataObject.clear();
- persistentDataObject.addObject(cce);
- delete(persistentDataObject);
- } catch (IOException ee) {
- retVal = false;
- } catch (WSRPException e) {
- retVal = false;
- }
+ if ( portlet != null )
+ {
+ // TODO: destroy portlet states as well
+ // portletStateManager.destroy(portletHandle);
+
+ // delete the persistentFileStore for this portlet
+ persistentDataObject.clear();
+ persistentDataObject.addObject( portlet );
+ try
+ {
+ delete( persistentDataObject );
}
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+ catch ( WSRPException e )
+ {
+ String msg = "Unable to delete consumer configured portlet referenced by handle [" + portletHandle
+ + "]: ";
+ LOG.error( msg + e.getMessage() );
+ // deletion was not successfull.
+ return false;
}
-
- return retVal;
-
- }
- // deleting a producer offered portlet is not allowed
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+
+ // only remove if the persistent data was also removed
+ consumerConfiguredPortlets.remove( portletHandle );
+
+ return true;
}
-
+
+ // the portlet wasn't found, or was not a consumer configured portlet.
return false;
-
}
-
+
/**
* Deletes several portlets from the portlet pool.
- *
- * @param portletHandles Iterator of portletHandles.
- *
- * @return Iterator of portlet handles refering to those portlets
- * that could not be deleted (e.g. producer offered portlets)
- */
- public Iterator destroySeveral(Iterator portletHandles) {
-
- String MN = "destroySeveral";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- LinkedList result = new LinkedList();
-
- while (portletHandles.hasNext()) {
- try {
- String handle = portletHandles.next().toString();
- if (!destroy(handle)) {
- result.add(handle);
- }
- } catch (NoSuchElementException e) {
- // TODO
+ *
+ * @param portletHandles
+ * Iterator of portletHandles.
+ * @return Iterator of portlet handles refering to those portlets that could
+ * not be deleted (e.g. producer offered portlets)
+ */
+ public Iterator destroySeveral( Iterator portletHandles )
+ {
+ List result = new ArrayList();
+ while ( portletHandles.hasNext() )
+ {
+ String handle = portletHandles.next().toString();
+ if ( !destroy( handle ) )
+ {
+ result.add( handle );
}
}
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
return result.iterator();
}
-
+
/**
* Store the object to persistent store
- *
+ *
* @param persistentDataObject
* @throws WSRPException
*/
- private void store(PersistentDataObject persistentDataObject)
- throws WSRPException {
-
- persistentHandler.store(persistentDataObject);
+ private void store( PersistentDataObject persistentDataObject ) throws WSRPException
+ {
+ persistentHandler.store( persistentDataObject );
}
-
+
/**
- * Restores all available ConsumerConfiguredPortlets from persistent file
+ * Restores all available ConsumerConfiguredPortlets from persistent file
* store
- *
+ *
* @throws WSRPException
*/
- private void restore() throws WSRPException {
-
- String MN = "restore";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
+ private void restore( ) throws WSRPException
+ {
consumerConfiguredPortlets.clear();
-
- persistentDataObject =
- persistentHandler.restoreMultiple(persistentDataObject);
-
+ persistentDataObject = persistentHandler.restoreMultiple( persistentDataObject );
Iterator iterator = persistentDataObject.getObjects();
-
- while (iterator.hasNext()) {
- ConsumerConfiguredPortlet cce =
- (ConsumerConfiguredPortlet) iterator.next();
- consumerConfiguredPortlets.put(cce.getPortletHandle(), cce);
+ while ( iterator.hasNext() )
+ {
+ ConsumerConfiguredPortlet cce = (ConsumerConfiguredPortlet) iterator.next();
+ consumerConfiguredPortlets.put( cce.getPortletHandle(), cce );
}
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
- }
-
}
-
+
+ private ConsumerConfiguredPortlet createConsumerConfigurePortlet( String portletAppId, PortletDD portletDD )
+ {
+ String portletId = portletAppId + "/" + portletDD.getPortletName();
+ ConsumerConfiguredPortlet portlet = new ConsumerConfiguredPortletImpl();
+ portlet.setPortletHandle( portletId );
+ portlet.setParentHandle( null );
+ return portlet;
+ }
+
+ private ProducerOfferedPortlet createProducerOfferedPortlet( String portletAppId, PortletDD portletDD )
+ {
+ String portletId = portletAppId + "/" + portletDD.getPortletName();
+ ProducerOfferedPortlet portlet = new ProducerOfferedPortletImpl();
+ portlet.setPortletHandle( portletId );
+ portlet.setRegistrationRequired( REGISTRATION_REQUIRED );
+ return portlet;
+ }
+
+ private ProducerOfferedPortlet copyProducerOfferedPortlet( ProducerOfferedPortlet portletToCopy )
+ {
+ ProducerOfferedPortlet copy = new ProducerOfferedPortletImpl();
+ copy.setPortletHandle( portletToCopy.getPortletHandle() );
+ copy.setRegistrationRequired( REGISTRATION_REQUIRED );
+ return copy;
+ }
+
+ private ConsumerConfiguredPortlet copyConsumerConfiguredPortlet( ConsumerConfiguredPortlet portletToCopy )
+ {
+ ConsumerConfiguredPortlet copy = new ConsumerConfiguredPortletImpl();
+ copy.setPortletHandle( portletToCopy.getPortletHandle() );
+ copy.setParentHandle( portletToCopy.getParentHandle() );
+ return copy;
+ }
+
/**
* Delete the object from persistent store
- *
+ *
* @param persistentDataObject
*/
- private void delete(PersistentDataObject persistentDataObject)
- throws WSRPException {
-
- persistentHandler.delete(persistentDataObject);
+ private void delete( PersistentDataObject persistentDataObject ) throws WSRPException
+ {
+ persistentHandler.delete( persistentDataObject );
+ }
+
+ private class PortletRegistryListenerImpl implements PortletRegistryListener
+ {
+
+ public synchronized void portletApplicationRegistered( PortletRegistryEvent e )
+ {
+ LOG.debug( "Received portlet application registered event for [" + e.getApplicationId() + "]" );
+ PortletAppDD appDD = e.getPortletApplicationDescriptor();
+ String appId = e.getApplicationId();
+ for ( Iterator i = appDD.getPortlets().iterator(); i.hasNext(); )
+ {
+ PortletDD portletDD = (PortletDD) i.next();
+ String portletId = appId + "/" + portletDD.getPortletName();
+ LOG.debug( "Registering portlet with id [" + portletId + "]" );
+ producerOfferedPortlets.put( portletId, createProducerOfferedPortlet( appId, portletDD ) );
+ }
+ }
+
+ public synchronized void portletApplicationRemoved( PortletRegistryEvent e )
+ {
+ LOG.debug( "Received portlet application removed event for [" + e.getApplicationId() + "]" );
+ PortletAppDD appDD = e.getPortletApplicationDescriptor();
+ String appId = e.getApplicationId();
+ for ( Iterator i = appDD.getPortlets().iterator(); i.hasNext(); )
+ {
+ PortletDD portletDD = (PortletDD) i.next();
+ String portletId = appId + "/" + portletDD.getPortletName();
+ if ( producerOfferedPortlets.containsKey( portletId ) )
+ {
+ LOG.debug( "Unregistering producer offered portlet with id [" + portletId + "]" );
+ producerOfferedPortlets.remove( portletId );
+ }
+
+ if ( consumerConfiguredPortlets.containsKey( portletId ) )
+ {
+ // use destroy(), as it handles scoping issues
+ // TODO: deal with cloned children/parents?
+ LOG.debug( "Unregistering consumer configured portlet with id [" + portletId + "]" );
+ destroy( portletId );
+ }
+ }
+ }
}
-
+
}
Modified: portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletStateImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletStateImpl.java?rev=569721&r1=569720&r2=569721&view=diff
==============================================================================
--- portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletStateImpl.java (original)
+++ portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletStateImpl.java Sat Aug 25 12:35:34 2007
@@ -19,12 +19,11 @@
import java.io.StringWriter;
import java.util.HashMap;
-import org.w3c.dom.Element;
-
import oasis.names.tc.wsrp.v1.types.ModelDescription;
import oasis.names.tc.wsrp.v1.types.PropertyList;
import org.apache.wsrp4j.commons.producer.provider.interfaces.PortletState;
+import org.w3c.dom.Element;
/**
Modified: portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletURLProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletURLProviderImpl.java?rev=569721&r1=569720&r2=569721&view=diff
==============================================================================
--- portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletURLProviderImpl.java (original)
+++ portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/PortletURLProviderImpl.java Sat Aug 25 12:35:34 2007
@@ -23,25 +23,17 @@
import javax.portlet.WindowState;
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.pluto.services.information.PortletURLProvider;
-
import oasis.names.tc.wsrp.v1.types.PortletContext;
import oasis.names.tc.wsrp.v1.types.RuntimeContext;
import oasis.names.tc.wsrp.v1.types.UserContext;
-import org.apache.wsrp4j.commons.util.Utility;
-
-import org.apache.wsrp4j.commons.producer.provider.interfaces.Provider;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.spi.PortletURLProvider;
import org.apache.wsrp4j.commons.producer.provider.interfaces.URLComposer;
-
import org.apache.wsrp4j.commons.producer.util.Base64;
import org.apache.wsrp4j.commons.producer.util.MapSerializer;
-
-import org.apache.wsrp4j.producer.provider.pluto.interfaces.
- WSRPDynamicInformationProvider;
+import org.apache.wsrp4j.producer.provider.pluto.interfaces.AttrKeys;
@@ -51,40 +43,63 @@
* @see org.apache.pluto.services.information.PortletURLProvider
* @version $Id$
*/
-public class PortletURLProviderImpl implements PortletURLProvider {
+public class PortletURLProviderImpl implements PortletURLProvider
+{
- private static final Log log =
- LogFactory.getLog(PortletURLProviderImpl.class);
+ /**
+ * Logger
+ */
+ private static final Log LOG = LogFactory.getLog( PortletURLProviderImpl.class );
- //servlet request
- private HttpServletRequest request;
+ /**
+ * Servlet request
+ */
+ private HttpServletRequest request = null;
- //portlet mode
- private PortletMode mode;
+ /**
+ * Portlet mode
+ */
+ private PortletMode mode = null;
- //portlet window state
- private WindowState state;
+ /**
+ * Portlet window state
+ */
+ private WindowState state = null;
- //action
+ /**
+ * Is this an action url?
+ */
private boolean action = false;
- //secure
+ /**
+ * Is this url secure (using https)
+ */
private boolean secure = false;
- // render params
- private Map parameters;
-
- //provider
- private Provider provider;
+ /**
+ * Render parameters
+ */
+ private Map parameters = null;
+
+ /**
+ * URL Composer
+ */
+ private URLComposer urlComposer = null;
- // wsrp runtime context
- private RuntimeContext runtimeContext;
+ /**
+ * WSRP runtime context
+ */
+ private RuntimeContext runtimeContext = null;
- // wsrp user context
- private UserContext userContext;
+ /**
+ * WSRP user context
+ */
+ private UserContext userContext = null;
- // wsrp portlet context
- private PortletContext portletContext;
+ /**
+ * WSRP portlet context
+ */
+ private PortletContext portletContext = null;
/**
* Default constructor
@@ -93,22 +108,24 @@
*/
public PortletURLProviderImpl(
HttpServletRequest request,
- Provider provider,
+ URLComposer urlComposer,
RuntimeContext runtimeContext,
PortletContext portletContext,
- UserContext userContext) {
+ UserContext userContext )
+ {
this.request = request;
- this.provider = provider;
+ this.urlComposer = urlComposer;
this.runtimeContext = runtimeContext;
this.portletContext = portletContext;
- this.userContext = userContext;
+ this.userContext = userContext;
}
/**
* Set the portlet mode
* @param mode portlet mode
*/
- public void setPortletMode(PortletMode mode) {
+ public void setPortletMode( PortletMode mode )
+ {
this.mode = mode;
}
@@ -116,28 +133,38 @@
* Set the portlet window state
* @param state portlet window state
*/
- public void setWindowState(WindowState state) {
+ public void setWindowState( WindowState state )
+ {
this.state = state;
}
/**
* Set a flag that an action should be encoded
*/
- public void setAction() {
- action = true;
+ public void setAction( boolean action )
+ {
+ this.action = action;
+ }
+
+ public boolean isSecureSupported()
+ {
+ // TODO: revist isSecureSupported()
+ return false;
}
/**
* Set a flag that security is turned on
*/
- public void setSecure() {
+ public void setSecure()
+ {
secure = true;
}
/**
* Set a flag that all render parameters should be cleared
*/
- public void clearParameters() {
+ public void clearParameters()
+ {
// ignore
}
@@ -145,148 +172,126 @@
* Set action parameters
* @param parameters java.util.Map
*/
- public void setParameters(Map parameters) {
+ public void setParameters( Map parameters )
+ {
this.parameters = parameters;
// since we are not served correctly from the portleturl implementation
// we convert all values in the map to arrays of type string
+ // TODO: do we really need to do this?
convertToArrayMap();
// in addition store as request attribute
// needed to allow our portlet invoker to set navigational state after
// action processing returned
- request.setAttribute(WSRPDynamicInformationProvider.RENDER_PARAMS,
- this.parameters);
+ request.setAttribute( AttrKeys.RENDER_PARAMS, this.parameters );
}
/**
* Returns a String representation of a URL
* @return java.lang.String
*/
- public String toString() {
-
- final String MN = "toString";
-
- if (log.isDebugEnabled()) {
- log.debug(Utility.strEnter(MN));
- }
-
- if (mode == null) {
+ public String toString()
+ {
+ if ( mode == null )
+ {
//WSRP4J-54 missing view is ok, retain current mode
- //mode = PortletMode.VIEW;
-
- if (log.isDebugEnabled()) {
- log.debug("PortletMode is null. " +
- "Setting portlet mode to 'view'");
- }
+ LOG.debug( "PortletMode is null." );
}
- if (state == null) {
+ if ( state == null )
+ {
// WSRP4J-54 missing state is ok, portlet will retain current state
- //state = WindowState.NORMAL;
-
- if (log.isDebugEnabled()) {
- log.debug("WindowState is null. Setting window state " +
- "to 'normal'");
- }
+ LOG.debug( "WindowState is null." );
}
- String url = "";
- URLComposer urlComposer = provider.getURLComposer();
+ String url = "";
- // create urls
- if (action) {
-
+ // create the url
+ if ( action )
+ {
String actionStateStr = null;
- try {
-
- actionStateStr =
- Base64.encode(MapSerializer.serialize(parameters));
-
- } catch (IOException iox) {
+ try
+ {
+ actionStateStr = Base64.encode( MapSerializer.serialize( parameters ) );
+ }
+ catch ( IOException e )
+ {
//TODO: pass exception to consumer
-
- if (log.isErrorEnabled()) {
- log.error("IOException occured during serialization of " +
- "parameter map to interaction state.", iox);
- }
+ final String msg = "IOException occured during serialization of parameter map to interaction state: ";
+ LOG.error( msg + e.getMessage(), e );
}
- //TBD: introduce mode / state mapping class instead of string
- //appending...
+
+ // TODO: introduce mode / state mapping class instead of string appending
url = urlComposer.createBlockingActionURL(
//WSRP4J-54
//"wsrp:" + mode.toString(),
- (mode != null) ? "wsrp:" + mode.toString() : null,
+ ( mode != null) ? "wsrp:" + mode.toString() : null,
null,
actionStateStr,
//WSRP4J-54
//"wsrp:" + state.toString(),
- (state != null) ? "wsrp:" + state.toString() : null,
+ ( state != null ) ? "wsrp:" + state.toString() : null,
this.secure,
this.runtimeContext,
this.portletContext,
- this.userContext);
- } else {
+ this.userContext );
+ }
+ else
+ {
String naviStateStr = null;
- try {
-
- naviStateStr =
- Base64.encode(MapSerializer.serialize(parameters));
-
- } catch (IOException iox) {
+ try
+ {
+ naviStateStr = Base64.encode( MapSerializer.serialize( parameters ) );
+ }
+ catch ( IOException e )
+ {
//TODO: pass exception to consumer
-
- if (log.isErrorEnabled()) {
- log.error("IOException occured during serialization of " +
- "parameter map to navigational state.", iox);
- }
+ final String msg = "IOException occured during serialization of parameter map to navigational state: ";
+ LOG.error( msg + e.getMessage(), e );
}
- url =
- urlComposer.createRenderURL(
+ url = urlComposer.createRenderURL(
//WSRP4J-54
//"wsrp:" + mode.toString(),
- (mode != null) ? "wsrp:" + mode.toString() : null,
+ ( mode != null ) ? "wsrp:" + mode.toString() : null,
naviStateStr,
//WSRP4J-54
//"wsrp:" + state.toString(),
- (state != null) ? "wsrp:" + state.toString() : null,
+ ( state != null ) ? "wsrp:" + state.toString() : null,
this.secure,
this.runtimeContext,
this.portletContext,
- this.userContext);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("url: " + url);
+ this.userContext );
}
- if (log.isDebugEnabled()) {
- log.debug(Utility.strExit(MN));
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Portlet URL [" + url + "]" );
}
return url;
}
/**
- * Internal method
* Converts parameter values represented as String objects to
* parameter values represented by an array of (a single) String object.
*/
- private void convertToArrayMap() {
-
- if (this.parameters != null) {
-
+ private void convertToArrayMap()
+ {
+ if ( this.parameters != null )
+ {
Iterator keys = this.parameters.keySet().iterator();
- while (keys != null && keys.hasNext()) {
-
- String key = (String)keys.next();
- Object value = this.parameters.get(key);
- if (value instanceof String) {
- String[] values = new String[] {(String)value };
- this.parameters.put(key, values);
+ while ( keys != null && keys.hasNext() )
+ {
+ String key = (String) keys.next();
+ Object value = this.parameters.get( key );
+ if ( value instanceof String )
+ {
+ String[] values = new String[] { (String) value };
+ this.parameters.put( key, values );
}
}
}
Modified: portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderFactoryImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderFactoryImpl.java?rev=569721&r1=569720&r2=569721&view=diff
==============================================================================
--- portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderFactoryImpl.java (original)
+++ portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/ProviderFactoryImpl.java Sat Aug 25 12:35:34 2007
@@ -15,29 +15,49 @@
*/
package org.apache.wsrp4j.producer.provider.pluto.driver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.wsrp4j.commons.producer.provider.interfaces.Provider;
import org.apache.wsrp4j.commons.producer.provider.interfaces.ProviderFactory;
+import org.apache.wsrp4j.producer.provider.pluto.interfaces.PlutoProvider;
/**
- * <p>This class implements the ProviderFactory-interface.</p>
- *
+ * Creates {@link PlutoProvider} objects. Note that each invocation of
+ * <code>getProvider()</code> returns the same instance of <code>PlutoProvider</code>.
+ *
* @version $Id$
*/
-public class ProviderFactoryImpl implements ProviderFactory {
-
- private static ProviderImpl provider;
-
+public class ProviderFactoryImpl implements ProviderFactory
+{
/**
- * Returns an instance of Provider by calling the constructor
- * of the corresponding class implementing the Provider-Interface
- *
- * @return Provider Provider-instance.
+ * Logger
*/
- public Provider getProvider() {
- if (provider == null) {
- provider = ProviderImpl.create();
- }
- return provider;
+ private static final Log LOG = LogFactory.getLog( ProviderFactoryImpl.class );
+
+ /**
+ * Pluto provider
+ */
+ private static PlutoProvider provider = null;
+
+ public ProviderFactoryImpl()
+ {
+ // no-arg public constructor.
+ }
+
+ public ProviderFactoryImpl( PlutoProvider provider )
+ {
+ if ( provider == null )
+ {
+ final String msg = "Pluto provider must not be null.";
+ LOG.error( msg );
+ throw new IllegalArgumentException( msg );
+ }
+ this.provider = provider;
}
+
+ public Provider getProvider()
+ {
+ return provider;
+ }
}