org.ops4j.pax.wicket.util
Class AbstractContentSource<E extends org.apache.wicket.Component>

java.lang.Object
  extended by org.ops4j.pax.wicket.util.AbstractContentSource<E>
All Implemented Interfaces:
ContentSource<E>, org.osgi.service.cm.ManagedService
Direct Known Subclasses:
FranchiseeContentSource

public abstract class AbstractContentSource<E extends org.apache.wicket.Component>
extends java.lang.Object
implements ContentSource<E>, org.osgi.service.cm.ManagedService


Field Summary
 
Fields inherited from interface org.ops4j.pax.wicket.api.ContentSource
AGGREGATION_POINT, APPLICATION_NAME, BASIC_ROLES, DESTINATION_UNKNOWN, DESTINATIONS, HOMEPAGE_CLASSNAME, MOUNTPOINT, PAGE_ID, PAGE_NAME, REQUIRED_ROLES, SOURCE_ID
 
Constructor Summary
protected AbstractContentSource(org.osgi.framework.BundleContext bundleContext, java.lang.String wicketId, java.lang.String applicationName)
          Construct an instance with AbstractContentSource.
 
Method Summary
 E createSourceComponent(java.lang.String wicketId)
          Create the wicket component represented by this ContentSource instance.
 E createSourceComponent(java.lang.String wicketId, org.apache.wicket.MarkupContainer parent)
          Create the wicket component represented by this ContentSource instance.
protected abstract  E createWicketComponent(java.lang.String wicketId)
          Create component with the specified wicketId.
protected
<C extends org.apache.wicket.MarkupContainer>
E
createWicketComponent(java.lang.String wicketId, C parent)
          Default implementation that ignores the parent component.
 java.lang.String getApplicationName()
          Returns the application name.
protected  PaxWicketAuthentication getAuthentication()
          Returns the Authentication of the current request.
 org.apache.wicket.authorization.strategies.role.Roles getBasicRoles()
           
 java.lang.String[] getDestinations()
          Returns the destinations.
 org.apache.wicket.authorization.strategies.role.Roles getRequiredRoles()
           
 java.lang.String getSourceId()
          Returns the content source id.
protected  E onAuthorizationFailed(java.lang.String wicketId)
          This method is called when the Authorization of the ContentSource has failed.
 org.osgi.framework.ServiceRegistration register()
          Register the specified AbstractContentSource instance.
 void setApplicationName(java.lang.String applicationName)
          Sets the application name.
 void setDestination(java.lang.String... destinationIds)
          Sets the destination id.
 void setRoles(org.apache.wicket.authorization.strategies.role.Roles requiredRoles, org.apache.wicket.authorization.strategies.role.Roles basicRoles)
           
 void updated(java.util.Dictionary config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractContentSource

protected AbstractContentSource(org.osgi.framework.BundleContext bundleContext,
                                java.lang.String wicketId,
                                java.lang.String applicationName)
                         throws java.lang.IllegalArgumentException
Construct an instance with AbstractContentSource.

Parameters:
bundleContext - The bundle context. This argument must not be null.
wicketId - The WicketId. This argument must not be null or empty.
applicationName - The application name. This argument must not be null or empty.
Throws:
java.lang.IllegalArgumentException - Thrown if one or some or all arguments are null.
Since:
1.0.0
Method Detail

getDestinations

public final java.lang.String[] getDestinations()
Returns the destinations.

Specified by:
getDestinations in interface ContentSource<E extends org.apache.wicket.Component>
Returns:
The destinations.
Since:
1.0.0

setDestination

public final void setDestination(java.lang.String... destinationIds)
                          throws java.lang.IllegalArgumentException
Sets the destination id.

Parameters:
destinationIds - The destination ids. This argument must not be null.
Throws:
java.lang.IllegalArgumentException - Thrown if the destinationId argument is not null.
Since:
1.0.0

createSourceComponent

public final E createSourceComponent(java.lang.String wicketId)
                                                                  throws java.lang.IllegalArgumentException
Create the wicket component represented by this ContentSource instance. This method must not return null object.

General convention:

Specified by:
createSourceComponent in interface ContentSource<E extends org.apache.wicket.Component>
Parameters:
wicketId - The wicket id. This argument must not be null.
Returns:
The wicket component represented by this ContentSource instance, or null if user has no access to this ContentSource.
Throws:
java.lang.IllegalArgumentException - Thrown if the wicketId argument is null.
Since:
1.0.0

createSourceComponent

public final E createSourceComponent(java.lang.String wicketId,
                                     org.apache.wicket.MarkupContainer parent)
                                                                  throws java.lang.IllegalArgumentException
Description copied from interface: ContentSource
Create the wicket component represented by this ContentSource instance. This method must not return null object.

Specified by:
createSourceComponent in interface ContentSource<E extends org.apache.wicket.Component>
Parameters:
wicketId - The wicket id. This argument must not be null.
parent - the parent MarkupContainer
Returns:
The wicket component represented by this ContentSource instance, or null if user has no access to this ContentSource.
Throws:
java.lang.IllegalArgumentException - Thrown if the wicketId argument is null.

onAuthorizationFailed

protected E onAuthorizationFailed(java.lang.String wicketId)
This method is called when the Authorization of the ContentSource has failed.

Parameters:
wicketId - The WicketId of the content to be created.
Returns:
null by default. Override to return a customized protected component, such as a label without the link.

getSourceId

public final java.lang.String getSourceId()
Returns the content source id.

Specified by:
getSourceId in interface ContentSource<E extends org.apache.wicket.Component>
Returns:
The content source id.
Since:
1.0.0

getApplicationName

public final java.lang.String getApplicationName()
Returns the application name.

Returns:
The application name.
Since:
1.0.0

getAuthentication

protected PaxWicketAuthentication getAuthentication()
Returns the Authentication of the current request. It is possible to obtain the Username of the logged in user as well as which roles that this user has assigned to it.

Returns:
the Authentication of the current request.

setApplicationName

public final void setApplicationName(java.lang.String applicationName)
                              throws java.lang.IllegalArgumentException
Sets the application name.

Parameters:
applicationName - The application name. This argument must not be null.
Throws:
java.lang.IllegalArgumentException - Thrown if the applicationName argument is null.
Since:
1.0.0

createWicketComponent

protected abstract E createWicketComponent(java.lang.String wicketId)
                                                                        throws java.lang.IllegalArgumentException
Create component with the specified wicketId.

General convention:

Parameters:
wicketId - The WicketId. This argument must not be null.
Returns:
The wicket component with the specified wicketId.
Throws:
java.lang.IllegalArgumentException - Thrown if the either or both arguments are null.
Since:
1.0.0

createWicketComponent

protected <C extends org.apache.wicket.MarkupContainer> E createWicketComponent(java.lang.String wicketId,
                                                                                C parent)
                                                               throws java.lang.IllegalArgumentException
Default implementation that ignores the parent component. Override this if you want to inject the parent component into your created Wicket Component

Parameters:
wicketId - The WicketId. This argument must not be null.
parent - the parent MarkupContainer
Returns:
The wicket component with the specified wicketId.
Throws:
java.lang.IllegalArgumentException - Thrown if the either or both arguments are null.

updated

public final void updated(java.util.Dictionary config)
Specified by:
updated in interface org.osgi.service.cm.ManagedService

register

public final org.osgi.framework.ServiceRegistration register()
Register the specified AbstractContentSource instance.

Returns:
The specified AbstractContentSource.
Since:
1.0.0

getRequiredRoles

public org.apache.wicket.authorization.strategies.role.Roles getRequiredRoles()

getBasicRoles

public org.apache.wicket.authorization.strategies.role.Roles getBasicRoles()

setRoles

public final void setRoles(org.apache.wicket.authorization.strategies.role.Roles requiredRoles,
                           org.apache.wicket.authorization.strategies.role.Roles basicRoles)


Copyright © 2008. All Rights Reserved.