org.apache.cocoon.portal.wsrp.adapter
Class WSRPAdapter

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.portal.impl.AbstractComponent
          extended byorg.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter
              extended byorg.apache.cocoon.portal.wsrp.adapter.WSRPAdapter
All Implemented Interfaces:
Contextualizable, CopletAdapter, Disposable, Initializable, LogEnabled, Parameterizable, PortalManagerAspect, Preloadable, Receiver, Serviceable, ThreadSafe

public class WSRPAdapter
extends AbstractCopletAdapter
implements Contextualizable, PortalManagerAspect, Serviceable, Initializable, Disposable, Parameterizable, Receiver

Adapter to use wsrp-portlets as coplets
It provides the wsrp support by initializing wsrp4j
The aspect/adapter can be configured at the portal manager.

Version:
$Id: WSRPAdapter.java 326220 2005-10-18 20:27:09Z cziegeler $

Nested Class Summary
static class WSRPAdapter.FormRewritingHandler
          This handler is triggered by a form element.
 
Field Summary
static String ATTRIBUTE_NAME_CONSUMER_MAP
          Key to store the consumer map into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_LAYOUT
          Key to store the layout for the wsrp portlet into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY
          Key to store the portlet instance key into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_PORTLET_KEY
          Key to store the portlet key into the coplet instance data objectt as a temporary attribute.
static String ATTRIBUTE_NAME_PORTLET_MODES
          Key to store the wsrp modes into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_PORTLET_TITLE
          Key to store the wsrp title into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_PORTLET_WINDOWSTATES
          Key to store the window states into the coplet instance data object as a temporary attribute.
static String ATTRIBUTE_NAME_USER
          Key to store the wsrp user into the coplet instance data object as a temporary attribute.
static String CONSUMER_URL
          Unique name of the consumer.
static String consumerAgent
          Name of the service.
protected  ConsumerEnvironmentImpl consumerEnvironment
          The consumer environment implementation.
protected  Context context
          The avalon context.
protected  ThreadLocal copletInstanceData
          Stores the current coplet instance data per thread.
protected  boolean initialized
          Initialized?
protected  ServiceManager manager
          The service locator.
protected  Parameters parameters
          The configuration for this adapter.
protected  PortalService service
          The portal service.
protected  ServletConfig servletConfig
          The servlet configuration.
protected  UserContextProvider userContextProvider
          The user context provider.
protected  String wsrpConfigLocation
          Location of the wsrp configuration.
protected  Configuration wsrpConfiguration
          The wsrp configuration.
 
Fields inherited from class org.apache.cocoon.portal.impl.AbstractComponent
portalService
 
Fields inherited from interface org.apache.cocoon.portal.PortalManagerAspect
ROLE
 
Fields inherited from interface org.apache.cocoon.portal.coplet.adapter.CopletAdapter
ROLE
 
Constructor Summary
WSRPAdapter()
           
 
Method Summary
 boolean addProducer(ProducerDescription desc)
          Add a new producer
protected  void checkInitialized()
          Check if we have read our configuration already.
 void contextualize(Context context)
           
 Object createObject(String className)
          Create a component.
 void dispose()
          Removes all portlets, producers and users out of the consumerEnvironment-registries
 Parameters getAdapterConfiguration()
          Get the adapter configuration.
 ConsumerEnvironmentImpl getConsumerEnvironment()
           
 CopletInstanceData getCurrentCopletInstanceData()
          Return the current coplet instance data
protected  oasis.names.tc.wsrp.v1.types.MarkupContext getMarkupContext(org.apache.wsrp4j.consumer.WSRPPortlet portlet, SimplePortletWindowSession windowSession, org.apache.wsrp4j.consumer.User user)
          Retrieves the markup generated by the portlet.
protected  String getPortletInstanceKey(org.apache.wsrp4j.consumer.PortletKey key, CopletInstanceData coplet, String userName)
          Creates a String consists of the producer-id_portlet-handle_coplet-id_user-name
 SimplePortletWindowSession getSimplePortletWindowSession(org.apache.wsrp4j.consumer.WSRPPortlet portlet, String portletInstanceKey, org.apache.wsrp4j.consumer.User user)
          After getting the userSession and groupSession it performs the getServiceDescription()-call
 Configuration getWsrpConfiguration()
          Get the wsrp configuration.
 void inform(WSRPEvent event, PortalService service)
          Gets all required information like portletKey, portletInstanceKey, userName, portletModes, windowStates, interactionState and the navigationalStat
After that it decides with the URL_TYPE to perform the performBlockingInteraction()-call or do some render- alternatively some resource-specific things
 void initialize()
          Sets the WSRPLogger, the producerConfig and the consumerEnvironment
 void login(CopletInstanceData coplet)
          Gets the required information of the producer, user, wsrp-portlet, window-states, window-modes
and stores its into the copletInstanceData
After that it initiates the getServiceDescription()-call
 void logout(CopletInstanceData coplet)
          Releases all sessions (userSession, groupSession, portletSession)
 void parameterize(Parameters params)
           
protected  void performBlockingInteraction(org.apache.wsrp4j.consumer.WSRPPortlet portlet, SimplePortletWindowSession windowSession, org.apache.wsrp4j.consumer.User user, Request request)
          Performs an blocking interaction with the given portlet and session.
 void prepare(PortalManagerAspectPrepareContext aspectContext, PortalService service)
           
 void render(PortalManagerAspectRenderContext aspectContext, PortalService service, ContentHandler ch, Parameters parameters)
           
 void service(ServiceManager manager)
           
 void setCurrentCopletInstanceData(CopletInstanceData coplet)
          This sets the current coplet instance data for the thread
 void streamContent(CopletInstanceData coplet, ContentHandler contentHandler)
          Checks the values of the portlet-key and the user for current portlet-instance
After that all passed the getMarkup()-call will be initiated
 
Methods inherited from class org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter
destroy, getConfiguration, getConfiguration, init, renderErrorContent, toSAX
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_NAME_CONSUMER_MAP

public static final String ATTRIBUTE_NAME_CONSUMER_MAP
Key to store the consumer map into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY

public static final String ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY
Key to store the portlet instance key into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_PORTLET_KEY

public static final String ATTRIBUTE_NAME_PORTLET_KEY
Key to store the portlet key into the coplet instance data objectt as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_USER

public static final String ATTRIBUTE_NAME_USER
Key to store the wsrp user into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_LAYOUT

public static final String ATTRIBUTE_NAME_LAYOUT
Key to store the layout for the wsrp portlet into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_PORTLET_TITLE

public static final String ATTRIBUTE_NAME_PORTLET_TITLE
Key to store the wsrp title into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_PORTLET_MODES

public static final String ATTRIBUTE_NAME_PORTLET_MODES
Key to store the wsrp modes into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

ATTRIBUTE_NAME_PORTLET_WINDOWSTATES

public static final String ATTRIBUTE_NAME_PORTLET_WINDOWSTATES
Key to store the window states into the coplet instance data object as a temporary attribute.

See Also:
Constant Field Values

CONSUMER_URL

public static final String CONSUMER_URL
Unique name of the consumer.

See Also:
Constant Field Values

consumerAgent

public static final String consumerAgent
Name of the service.


context

protected Context context
The avalon context.


consumerEnvironment

protected ConsumerEnvironmentImpl consumerEnvironment
The consumer environment implementation.


copletInstanceData

protected final ThreadLocal copletInstanceData
Stores the current coplet instance data per thread.


servletConfig

protected ServletConfig servletConfig
The servlet configuration.


manager

protected ServiceManager manager
The service locator.


service

protected PortalService service
The portal service.


userContextProvider

protected UserContextProvider userContextProvider
The user context provider.


wsrpConfigLocation

protected String wsrpConfigLocation
Location of the wsrp configuration.


initialized

protected boolean initialized
Initialized?


wsrpConfiguration

protected Configuration wsrpConfiguration
The wsrp configuration.


parameters

protected Parameters parameters
The configuration for this adapter.

Constructor Detail

WSRPAdapter

public WSRPAdapter()
Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Overrides:
contextualize in class AbstractComponent
Throws:
ContextException
See Also:
Contextualizable.contextualize(org.apache.avalon.framework.context.Context)

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Overrides:
service in class AbstractComponent
Throws:
ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

parameterize

public void parameterize(Parameters params)
                  throws ParameterException
Specified by:
parameterize in interface Parameterizable
Throws:
ParameterException
See Also:
Parameterizable.parameterize(org.apache.avalon.framework.parameters.Parameters)

initialize

public void initialize()
                throws Exception
Sets the WSRPLogger, the producerConfig and the consumerEnvironment

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AbstractComponent
Throws:
Exception
See Also:
Initializable.initialize()

dispose

public void dispose()
Removes all portlets, producers and users out of the consumerEnvironment-registries

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractComponent
See Also:
Disposable.dispose()

login

public void login(CopletInstanceData coplet)
Gets the required information of the producer, user, wsrp-portlet, window-states, window-modes
and stores its into the copletInstanceData
After that it initiates the getServiceDescription()-call

Specified by:
login in interface CopletAdapter
Overrides:
login in class AbstractCopletAdapter
See Also:
AbstractCopletAdapter.login(org.apache.cocoon.portal.coplet.CopletInstanceData)

streamContent

public void streamContent(CopletInstanceData coplet,
                          ContentHandler contentHandler)
                   throws SAXException
Checks the values of the portlet-key and the user for current portlet-instance
After that all passed the getMarkup()-call will be initiated

Specified by:
streamContent in class AbstractCopletAdapter
Throws:
SAXException
See Also:
AbstractCopletAdapter.streamContent(org.apache.cocoon.portal.coplet.CopletInstanceData, org.xml.sax.ContentHandler)

logout

public void logout(CopletInstanceData coplet)
Releases all sessions (userSession, groupSession, portletSession)

Specified by:
logout in interface CopletAdapter
Overrides:
logout in class AbstractCopletAdapter
See Also:
AbstractCopletAdapter.logout(org.apache.cocoon.portal.coplet.CopletInstanceData)

getSimplePortletWindowSession

public SimplePortletWindowSession getSimplePortletWindowSession(org.apache.wsrp4j.consumer.WSRPPortlet portlet,
                                                                String portletInstanceKey,
                                                                org.apache.wsrp4j.consumer.User user)
                                                         throws org.apache.wsrp4j.exception.WSRPException
After getting the userSession and groupSession it performs the getServiceDescription()-call

Parameters:
portlet -
portletInstanceKey -
user -
Returns:
SimplePortletWindowSession
Throws:
org.apache.wsrp4j.exception.WSRPException

performBlockingInteraction

protected void performBlockingInteraction(org.apache.wsrp4j.consumer.WSRPPortlet portlet,
                                          SimplePortletWindowSession windowSession,
                                          org.apache.wsrp4j.consumer.User user,
                                          Request request)
Performs an blocking interaction with the given portlet and session.
If the response to this call is a redirect URL's it won't be followed.
An optionally returned markup context is store in the window session
and should be processed by the portlet driver instead of making a new
getMarkup() call.

Parameters:
portlet - The portlet on which this action should be performed
windowSession - The window session of the portlet on which the action should be performed
user - The user on which this action should be performed
request - The request with all required information for the call

getMarkupContext

protected oasis.names.tc.wsrp.v1.types.MarkupContext getMarkupContext(org.apache.wsrp4j.consumer.WSRPPortlet portlet,
                                                                      SimplePortletWindowSession windowSession,
                                                                      org.apache.wsrp4j.consumer.User user)
                                                               throws org.apache.wsrp4j.exception.WSRPException
Retrieves the markup generated by the portlet.

Parameters:
portlet -
windowSession -
user -
Returns:
The markup context.
Throws:
org.apache.wsrp4j.exception.WSRPException

getPortletInstanceKey

protected String getPortletInstanceKey(org.apache.wsrp4j.consumer.PortletKey key,
                                       CopletInstanceData coplet,
                                       String userName)
Creates a String consists of the producer-id_portlet-handle_coplet-id_user-name

Parameters:
key - includes the essential values
coplet - current CopletInstanceData-object
userName -
Returns:
the unique string which represents the portlet-instance

inform

public void inform(WSRPEvent event,
                   PortalService service)
Gets all required information like portletKey, portletInstanceKey, userName, portletModes, windowStates, interactionState and the navigationalStat
After that it decides with the URL_TYPE to perform the performBlockingInteraction()-call or do some render- alternatively some resource-specific things

See Also:
Receiver

prepare

public void prepare(PortalManagerAspectPrepareContext aspectContext,
                    PortalService service)
             throws ProcessingException
Specified by:
prepare in interface PortalManagerAspect
Throws:
ProcessingException
See Also:
PortalManagerAspect.prepare(org.apache.cocoon.portal.PortalManagerAspectPrepareContext, org.apache.cocoon.portal.PortalService)

render

public void render(PortalManagerAspectRenderContext aspectContext,
                   PortalService service,
                   ContentHandler ch,
                   Parameters parameters)
            throws SAXException
Specified by:
render in interface PortalManagerAspect
Throws:
SAXException
See Also:
PortalManagerAspect.render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)

getConsumerEnvironment

public ConsumerEnvironmentImpl getConsumerEnvironment()
Returns:
Returns the consumerEnvironmentImpl

addProducer

public boolean addProducer(ProducerDescription desc)
Add a new producer

Parameters:
desc - The producer description.
Returns:
Returns true if the producer could be added.

setCurrentCopletInstanceData

public void setCurrentCopletInstanceData(CopletInstanceData coplet)
This sets the current coplet instance data for the thread

Parameters:
coplet - The coplet instance data or null to clear the information.

getCurrentCopletInstanceData

public CopletInstanceData getCurrentCopletInstanceData()
Return the current coplet instance data

Returns:
Returns the instance or null.

checkInitialized

protected void checkInitialized()
Check if we have read our configuration already. If not, read the config and invoke the configure method.


getWsrpConfiguration

public Configuration getWsrpConfiguration()
Get the wsrp configuration.


getAdapterConfiguration

public Parameters getAdapterConfiguration()
Get the adapter configuration.


createObject

public Object createObject(String className)
                    throws Exception
Create a component.

Throws:
Exception


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.