|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ops4j.pax.wicket.util.AbstractAggregatedSource<E>
public abstract class AbstractAggregatedSource<E extends org.apache.wicket.Component>
This is a convenient superclass for creation of a ContentAggregator.
Normal use only requires the overriding of a single abstract method;
protected abstract E createSourceComponent( String wicketId )
throws IllegalArgumentException;
The subclass looks something like this;
And the MyPanel handles the generation of the Wicket Panel instance. Example;
public class PrinterContentAggregator<E extends Component> extends AbstractContentAggregator
{
public PrinterContentAggregator( BundleContext context, String applicationName,
String aggregationPoint, String destination )
throws IllegalArgumentException
{
super( context, applicationName, aggregationPoint, destination );
}
protected abstract E createSourceComponent( String wicketId )
throws IllegalArgumentException
{
return new PrintersPanel( wicketId, this );
}
}
In the above example, we are wiring printer ContentSources to a printers panel. The rendering of each
Printer view is up to the wired printer, and the aggregator just need a little bit of html to define its own panel.
Something like this;
public class PrintersPanel extends Panel
{
private static final long serialVersionUID = 1L;
public static final String WICKET_ID_NAME_LABEL = "name";
private static final String WICKET_ID_PRINTER = "printer";
private static final String WICKET_ID_PRINTERS = "printers";
FloorPanel( String id, ContentAggregator container, Floor floor )
{
super( id, new Model( "printers" ) );
ListView listView = new ListView( WICKET_ID_PRINTERS )
{
private static final long serialVersionUID = 1L;
protected void populateItem( final ListItem item )
{
Component modelObject = (Component) item.getModelObject();
item.add( modelObject );
}
};
List<Component> printers = container.createComponents( WICKET_ID_PRINTER, listView );
if ( printers.isEmpty() )
{
Label tLabel = new Label( WICKET_ID_PRINTER, "No Printers are available at the moment." );
printers.add( tLabel );
}
Model listViewModel = new Model( (Serializable) printers );
listView.setModel( listViewModel );
add( listView );
}
}
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.sourceforge.net/"
xml:lang="en"
lang="en"
>
<body>
<wicket:panel>
<div class="printerspanel">
<div class="printer-row" wicket:id="printers">
<span class="printer-item" wicket:id="printer"></span>
</div>
</div>
</wicket:panel>
</body>
</html>
| Field Summary | |
|---|---|
protected Logger |
LOGGER
|
| 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 |
AbstractAggregatedSource(org.osgi.framework.BundleContext bundleContext,
java.lang.String applicationName,
java.lang.String aggregationPoint,
java.lang.String destination)
Construct an instance of AbstractContentAggregator with the specified arguments. |
| Method Summary | ||
|---|---|---|
void |
addContent(java.lang.String wicketId,
ContentSource source)
Add the specified source to this RootContentAggregator and mapped it as wicketId. |
|
protected abstract E |
createComponent(java.lang.String wicketId)
Create component represented by this AbstractContentAggregator with the specified wicketId. |
|
protected
|
createComponent(java.lang.String wicketId,
T parent)
Default implementation that ignores the parent component. |
|
protected java.util.List<org.apache.wicket.Component> |
createComponents(java.lang.String wicketId)
|
|
E |
createSourceComponent(java.lang.String wicketId)
Create the wicket component represented by this ContentSource instance. |
|
|
createSourceComponent(java.lang.String wicketId,
T parent)
Create the wicket component represented by this ContentSource instance. |
|
org.apache.wicket.Component |
createWiredComponent(java.lang.String sourceId,
java.lang.String wicketId)
|
|
void |
dispose()
Dispose this RootContentAggregator instance. |
|
protected void |
finalize()
|
|
java.lang.String |
getAggregationPointName()
Returns the aggregation point id of this AbstractContentAggregator instance. |
|
java.lang.String |
getApplicationName()
Returns the application name of this ContentAggregator instance belongs to. |
|
protected PaxWicketAuthentication |
getAuthentication()
Returns the Authentication of the current request. |
|
org.apache.wicket.authorization.strategies.role.Roles |
getBasicRoles()
|
|
protected org.osgi.framework.BundleContext |
getBundleContext()
Returns the BundleContext that this ContentAggregator belongs to. |
|
ContentSource<? extends org.apache.wicket.Component> |
getContentById(java.lang.String wicketId,
java.lang.String sourceId)
|
|
|
getContents(java.lang.String wicketId)
Returns list of ContentSource instnaces of the specified wicketId. |
|
java.lang.String[] |
getDestinations()
Returns the destination of this ContentSource instance. |
|
protected java.lang.Object |
getObjectProperty(java.lang.String key)
|
|
org.apache.wicket.authorization.strategies.role.Roles |
getRequiredRoles()
|
|
protected java.lang.String[] |
getServiceNames()
|
|
java.lang.String |
getSourceId()
Returns the source id. |
|
protected java.lang.String[] |
getStringArrayProperty(java.lang.String key)
|
|
protected java.lang.String |
getStringProperty(java.lang.String key,
java.lang.String defaultValue)
|
|
java.util.List<java.lang.String> |
getWiredSourceIds(java.lang.String wicketId,
java.util.Comparator<ContentSource> comparator)
|
|
protected void |
onDispose()
Override this method to handle additional dispose. |
|
protected void |
onUpdated(java.util.Dictionary config)
|
|
org.osgi.framework.ServiceRegistration |
register()
|
|
boolean |
removeContent(java.lang.String wicketId,
ContentSource content)
Remove the specified content to this RootContentAggregator and unmapped it as wicketId. |
|
void |
setAggregationPointName(java.lang.String aggregationPoint)
Set the aggregation id of this AbstractContentAggregator. |
|
void |
setApplicationName(java.lang.String applicationName)
Sets the application name of this AbstractContentAggregator instant belongs to. |
|
void |
setDestination(java.lang.String... destinations)
Set the destination of this ContentSource. |
|
protected void |
setProperty(java.lang.String key,
java.lang.Object value)
|
|
void |
setRoles(org.apache.wicket.authorization.strategies.role.Roles requiredRoles,
org.apache.wicket.authorization.strategies.role.Roles basicRoles)
|
|
void |
updated(java.util.Dictionary config)
|
|
protected void |
updateRegistration()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.ops4j.pax.wicket.api.ContentAggregator |
|---|
dispose, getAggregationPointName, getApplicationName |
| Methods inherited from interface org.ops4j.pax.wicket.internal.ContentTrackingCallback |
|---|
addContent, removeContent |
| Methods inherited from interface org.osgi.service.cm.ManagedService |
|---|
updated |
| Field Detail |
|---|
protected final Logger LOGGER
| Constructor Detail |
|---|
protected AbstractAggregatedSource(org.osgi.framework.BundleContext bundleContext,
java.lang.String applicationName,
java.lang.String aggregationPoint,
java.lang.String destination)
throws java.lang.IllegalArgumentException
AbstractContentAggregator with the specified arguments.
bundleContext - The bundle context. This argument must not be null.applicationName - The application name. This argument must not be null or empty.aggregationPoint - The aggregation point id. This argument must not be null or empty.destination - The destination id. This argument must not be null or empty.
java.lang.IllegalArgumentException - Thrown if one or some or all arguments are null or empty.| Method Detail |
|---|
public final java.lang.String getSourceId()
getSourceId in interface ContentSource<E extends org.apache.wicket.Component>public final java.lang.String[] getDestinations()
ContentSource instance. This method must not return null object.
getDestinations in interface ContentSource<E extends org.apache.wicket.Component>ContentSource instance.
public final void setDestination(java.lang.String... destinations)
throws java.lang.IllegalArgumentException
ContentSource.
Note: Destination property must not be set after this ContentSource instance is registered to OSGi
framework.
destinations - The destinations. This argument must not be null.
java.lang.IllegalArgumentException - Thrown if the specified destination argument is null or empty.protected java.lang.String[] getServiceNames()
public final E createSourceComponent(java.lang.String wicketId)
throws java.lang.IllegalArgumentException
ContentSource instance. This method must not return
null object.
General convention:
createSourceComponent in interface ContentSource<E extends org.apache.wicket.Component>wicketId - The wicket id. This argument must not be null.
ContentSource instance, or null if user has no access to
this ContentSource.
java.lang.IllegalArgumentException - Thrown if the wicketId argument is null.
public <T extends org.apache.wicket.MarkupContainer> E createSourceComponent(java.lang.String wicketId,
T parent)
throws java.lang.IllegalArgumentException
ContentSource instance. This method must not return
null object.
General convention:
createSourceComponent in interface ContentSource<E extends org.apache.wicket.Component>wicketId - The wicket id. This argument must not be null.parent - the parent MarkupContainer
ContentSource instance, or null if user has no access to
this ContentSource.
java.lang.IllegalArgumentException - Thrown if the wicketId argument is null.
protected abstract E createComponent(java.lang.String wicketId)
throws java.lang.IllegalArgumentException
AbstractContentAggregator with the specified wicketId.
General convention:
wicketId - The wicketId. This argument must not be null nor empty. It maps to the wicket:id of the
rendering process in Wicket.
AbstractContentAggregator.
java.lang.IllegalArgumentException - Thrown if argument is null.
protected <T extends org.apache.wicket.MarkupContainer> E createComponent(java.lang.String wicketId,
T parent)
Component
wicketId - The WicketId. This argument must not be null.parent - the parent MarkupContainer
wicketId.
java.lang.IllegalArgumentException - Thrown if the either or both arguments are null.public final org.apache.wicket.authorization.strategies.role.Roles getRequiredRoles()
public final org.apache.wicket.authorization.strategies.role.Roles getBasicRoles()
public final void setRoles(org.apache.wicket.authorization.strategies.role.Roles requiredRoles,
org.apache.wicket.authorization.strategies.role.Roles basicRoles)
protected final java.util.List<org.apache.wicket.Component> createComponents(java.lang.String wicketId)
public final java.lang.String getAggregationPointName()
AbstractContentAggregator instance. This method must not return
null object.
getAggregationPointName in interface ContentAggregatorpublic final void setAggregationPointName(java.lang.String aggregationPoint)
AbstractContentAggregator.
Note: aggregation id property must not be set after this AbstractContentAggregator instance is registered
to OSGi framework.
aggregationPoint - The aggregation point name. This argument must not be null.
java.lang.IllegalArgumentException - Thrown if the specified aggregationId argument is null or empty.public final java.lang.String getApplicationName()
ContentAggregator instance belongs to.
getApplicationName in interface ContentAggregatorContentAggregator instance belongs to.public final void setApplicationName(java.lang.String applicationName)
AbstractContentAggregator instant belongs to.
Note: Application name property must not be set after this AbstractContentAggregator instance is
registered to OSGi framework.
applicationName - The application name. This argument must not be null.
java.lang.IllegalArgumentException - Thrown if the specified applicationName argument is null or
empty.
public final void dispose()
throws java.lang.IllegalStateException
RootContentAggregator instance.
Note: Dispose does not unregister this RootContentAggregator, and ensure that dispose is only called
after this RootContentAggregator instance is unregistered from OSGi container.
dispose in interface ContentAggregatorjava.lang.IllegalStateException - Thrown if this content tracker has not been registered.ServiceRegistration.unregister()protected final org.osgi.framework.BundleContext getBundleContext()
public final void updated(java.util.Dictionary config)
throws org.osgi.service.cm.ConfigurationException
updated in interface org.osgi.service.cm.ManagedServiceorg.osgi.service.cm.ConfigurationExceptionprotected void onUpdated(java.util.Dictionary config)
public final void addContent(java.lang.String wicketId,
ContentSource source)
throws java.lang.IllegalArgumentException
source to this RootContentAggregator and mapped it as wicketId.
addContent in interface ContentTrackingCallbackwicketId - The wicket id. This argument must not be null or empty.source - The source. This argument must not be null.
java.lang.IllegalArgumentException - Thrown if one or both arguments are null.
public final boolean removeContent(java.lang.String wicketId,
ContentSource content)
throws java.lang.IllegalArgumentException
content to this RootContentAggregator and unmapped it as wicketId.
removeContent in interface ContentTrackingCallbackwicketId - The wicket id. This argument must not be null or empty.content - The content. This argument must not be null.
boolean indicator whether removal is successfull.
java.lang.IllegalArgumentException - Thrown if one or both arguments are null.
public final org.osgi.framework.ServiceRegistration register()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionprotected java.lang.String[] getStringArrayProperty(java.lang.String key)
protected java.lang.String getStringProperty(java.lang.String key,
java.lang.String defaultValue)
protected void setProperty(java.lang.String key,
java.lang.Object value)
protected void updateRegistration()
protected java.lang.Object getObjectProperty(java.lang.String key)
protected void onDispose()
public final java.util.List<java.lang.String> getWiredSourceIds(java.lang.String wicketId,
java.util.Comparator<ContentSource> comparator)
throws java.lang.IllegalArgumentException
wicketId - The WicketID that we want to find the wiring for.comparator - The sorting comparator.
java.lang.IllegalArgumentException - Thrown if the specified wicketId argument is null.createWiredComponent(String,String)
public final org.apache.wicket.Component createWiredComponent(java.lang.String sourceId,
java.lang.String wicketId)
throws java.lang.IllegalArgumentException
sourceId - The SourceID of the ContentSource that we want to create a component.wicketId - The WicketID of the component to be created by the ContentSource. This responds to the
wicket:id in the markup.
sourceId and wicketId.
java.lang.IllegalArgumentException - Thrown if the specified sourceId (or/and) wicketId argument is null.getWiredSourceIds(String,java.util.Comparator)
public final <V extends ContentSource> java.util.List<V> getContents(java.lang.String wicketId)
throws java.lang.IllegalArgumentException
ContentSource instnaces of the specified wicketId. Returns an empty list if
there is no content for the specified wicketId.
wicketId - The wicket id. This argument must not be null or empty.
ContentSource of the specified wicketId.
java.lang.IllegalArgumentException - if the wicketId is null or empty.protected PaxWicketAuthentication getAuthentication()
public final ContentSource<? extends org.apache.wicket.Component> getContentById(java.lang.String wicketId,
java.lang.String sourceId)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||