### StAX-to-SAX Pipeline (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index Illustrates a pipeline that starts with StAX components and transitions to SAX components using StAXToSAXPipelineAdapter. This is useful for mixing StAX and SAX processing stages. ```java Pipeline pipeStAX = new NonCachingPipeline(); pipeStAX.addComponent(new StAXGenerator(input)); pipeStAX.addComponent(new StAXToSAXPipelineAdapter()); pipeStAX.addComponent(new CleaningTransformer()); pipeStAX.addComponent(new XMLSerializer()); pipeStAX.setup(System.out); pipeStAX.execute(); ``` -------------------------------- ### GET /sample/parameter-passing/{id} Source: https://cocoon.apache.org/3.0/reference/html-single/index This JAX-RS resource handles GET requests to /sample/parameter-passing/{id}. It accepts a path parameter 'id' and an optional query parameter 'req-param'. It returns a response built using URLResponseBuilder. ```APIDOC ## GET /sample/parameter-passing/{id} ### Description Handles GET requests with a path parameter 'id' and an optional query parameter 'req-param'. Returns a response constructed by URLResponseBuilder. ### Method GET ### Endpoint /sample/parameter-passing/{id} ### Parameters #### Path Parameters - **id** (String) - Required - The identifier passed in the URI path. #### Query Parameters - **req-param** (String) - Optional - A request parameter. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **name** (String) - The name 'Donald Duck'. - **id** (String) - The value of the 'id' path parameter. - **reqparam** (String) - The value of the 'req-param' query parameter. - **runningMode** (String) - The value of the 'testProperty' from settings. #### Response Example ```json { "name": "Donald Duck", "id": "someId", "reqparam": "someValue", "runningMode": "someMode" } ``` ``` -------------------------------- ### Define and Mount Custom Cocoon Pipeline in Wicket (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index This example shows how to define a custom Cocoon pipeline by subclassing AbstractCocoonPipeline and then mounting it within a Wicket WebApplication. This approach allows for defining pipeline components programmatically. ```java import com.mycompany.MyCocoonPipeline; import org.apache.wicket.protocol.http.WebApplication; public class SomeWebApplication extends WebApplication @Override protected void init() { ... this.mount(new MyCocoonPipeline("/my-pipeline")); ... } } ``` ```java package com.mycompany; import org.apache.cocoon.wicket.AbstractCocoonPipeline; import org.apache.wicket.protocol.http.WebApplication; public class MyCocoonPipeline extends org.apache.cocoon.wicket.AbstractCocoonPipeline @Override protected void addComponents() { this.addComponent(new FileGenerator(this.getClass().getResource("test.xml"))); this.addComponent(new XSLTTransformer(this.getClass().getResource("test.xsl"))); this.addComponent(new XMLSerializer()); } } ``` -------------------------------- ### Configure Wicket Reader in Cocoon Sitemap (XML) Source: https://cocoon.apache.org/3.0/reference/html-single/index Illustrates how to configure the Wicket reader within the Cocoon sitemap. This setup uses a wildcard match to direct requests starting with 'my-wicket-app' to the Wicket reader, specifying the base path for correct URL calculation. ```xml ``` -------------------------------- ### JAX-RS Resource as Spring Bean Configuration (XML) Source: https://cocoon.apache.org/3.0/reference/html-single/index Configures a JAX-RS resource class as a Spring bean in an XML definition. This example shows how to define the bean, specify its class, and inject dependencies, such as the `Settings` bean, using property setters. ```xml ``` -------------------------------- ### JAX-RS Resource Definition with Parameter Binding (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index Defines a JAX-RS resource class with a GET endpoint that accepts path and query parameters. It demonstrates how to bind these parameters to method arguments and use them to construct a response, including retrieving settings via dependency injection. The `URLResponseBuilder` is used to construct the response, supporting servlet protocols. ```java @Path("/sample") public class SampleRestResource { private Settings settings; @GET @Path("/parameter-passing/{id}") public Response anotherService( @PathParam("id") String id, @QueryParam("req-param") String reqParam, @Context UriInfo uriInfo, @Context Request request) { Map data = new HashMap(); data.put("name", "Donald Duck"); data.put("id", id); data.put("reqparam", reqParam); data.put("runningMode", this.settings.getProperty("testProperty")); return URLResponseBuilder.newInstance("servlet:sample:/controller/screen", data) .build(); } public void setSettings(Settings settings) { this.settings = settings; } } ``` -------------------------------- ### Implement NullSerializer for StAX Event Consumption Source: https://cocoon.apache.org/3.0/reference/html-single/index This Java class, NullSerializer, implements StAXConsumer and Finisher interfaces to consume StAX events from a pipeline. It pulls events from a parent producer and includes methods for pipeline setup and output stream configuration. ```java public class NullSerializer extends AbstractStAXPipelineComponent implements StAXConsumer, Finisher { private StAXProducer parent; public void initiatePullProcessing() { try { while (this.parent.hasNext()) { XMLEvent event = this.parent.nextEvent(); /* serialize Event */ } } catch (XMLStreamException e) { throw new ProcessingException("Error during writing output elements.", e); } } public void setParent(StAXProducer parent) { this.parent = parent; } public String getContentType() ; public void setOutputStream(OutputStream outputStream) ; } ``` -------------------------------- ### Build and Execute a SAX Pipeline with Java Components Source: https://cocoon.apache.org/3.0/reference/html-single/index Demonstrates the creation of a NonCachingPipeline and the addition of SAX-based XML components: an XMLGenerator, two XSLTTransformers, and an XMLSerializer. The pipeline is then set up with an output stream and executed. ```java Pipeline pipeline = new NonCachingPipeline(); pipeline.addComponent(new XMLGenerator("")); pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("/test1.xslt"))); pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("/test2.xslt"))); pipeline.addComponent(new XMLSerializer()); pipeline.setup(System.out); pipeline.execute(); ``` -------------------------------- ### Wrap SAX in StAX Pipeline (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index Demonstrates how to use existing SAX components within a StAX pipeline by wrapping them with SAXForStAXPipelineWrapper. This allows for the integration of SAX components but may introduce overhead due to StAX->SAX->StAX conversion. ```java Pipeline pipeStAX = new NonCachingPipeline(); pipeStAX.addComponent(new StAXGenerator(input)); pipeStAX.addComponent(new SAXForStAXPipelineWrapper(new CleaningTransformer())); pipeStAX.addComponent(new StAXSerializer()); pipeStAX.setup(System.out); pipeStAX.execute(); ``` -------------------------------- ### Instantiate CocoonSAXPipeline as Wicket WebComponent (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index Demonstrates how to instantiate and configure CocoonSAXPipeline as a Wicket WebComponent. This involves adding generators and transformers to the pipeline, which is then added to a Wicket WebPage. The pipeline is serialized as XHTML, with an XHTMLSerializer added implicitly. ```java import org.apache.cocoon.pipeline.NonCachingPipeline; import org.apache.cocoon.sax.SAXPipelineComponent; import org.apache.cocoon.sax.component.StringGenerator; import org.apache.cocoon.sax.component.XSLTTransformer; import org.apache.cocoon.wicket.CocoonSAXPipeline; import org.apache.wicket.markup.html.WebPage; public class Homepage extends WebPage { public Homepage() { CocoonSAXPipeline pipeline = new CocoonSAXPipeline("cocoon-pipeline-component", new NonCachingPipeline()); pipeline.addComponent(new StringGenerator("hello, Cocoon!")); pipeline.addComponent(new XSLTTransformer( this.getClass().getResource("transform.xslt"))); this.add(pipeline); } } ``` -------------------------------- ### Mount Cocoon Sitemap in Wicket Application (Java) Source: https://cocoon.apache.org/3.0/reference/html-single/index Demonstrates how to mount a Cocoon sitemap as an IRequestTargetUrlCodingStrategy within a Wicket WebApplication. This allows Wicket to handle requests directed to the specified mount path using the provided sitemap. ```java import org.apache.cocoon.wicket.target.CocoonSitemap; import org.apache.wicket.protocol.http.WebApplication; public class SomeWebApplication extends WebApplication { @Override protected void init() { ... this.mount(new CocoonSitemap("/sitemap", "/sitemap.xmap.xml")); ... } } ``` -------------------------------- ### Implement a Navigator for XML Event Criteria in Java Source: https://cocoon.apache.org/3.0/reference/html-single/index This Java code shows how to implement a custom Navigator interface. The `fulfillsCriteria` method should return true if an XMLEvent meets the navigator's specific conditions, and `isActive` indicates the navigator's current state. This is used to simplify XML processing in transformers. ```java import javax.xml.stream.events.XMLEvent; public class MyNavigator implements Navigator { public boolean fulfillsCriteria(XMLEvent event) { return false; } public boolean isActive() { return false; } } ``` -------------------------------- ### Cache Entry Monitor - Auto Refresh Configuration Source: https://cocoon.apache.org/3.0/reference/html-single/index Manages the automatic refresh of cache entry monitoring data. Allows enabling and disabling auto-refresh and setting the refresh interval. ```APIDOC ## Cache Entry Monitor Auto Refresh ### Description This section details how to configure and manage the automatic refresh functionality for the Cache Entry Monitor module. Auto-refresh ensures that MBeans are kept up-to-date with the current cache state. ### Enable Auto Refresh #### Method POST #### Endpoint `/cache/enableAutoRefresh #### Parameters ##### Query Parameters - **period** (long) - Required - The refresh interval in milliseconds. #### Request Example ``` POST /cache/enableAutoRefresh?period=60000 ``` ### Disable Auto Refresh #### Method POST #### Endpoint `/cache/disableAutoRefresh #### Request Example ``` POST /cache/disableAutoRefresh ``` ### Manually Perform Refresh #### Method POST #### Endpoint `/cache/performRefreshAction #### Request Example ``` POST /cache/performRefreshAction ``` ``` -------------------------------- ### Configure Wicket Web Application Bean (Spring XML) Source: https://cocoon.apache.org/3.0/reference/html-single/index Defines a Wicket web application as a Spring bean in an XML configuration file. This bean is expected to be loaded automatically when the bean definition file is placed in `META-INF/cocoon/spring`. ```xml ``` -------------------------------- ### Perform Custom Action on Cache Entries Source: https://cocoon.apache.org/3.0/reference/html-single/index Allows for custom actions to be performed on cache entries that match specified criteria. Requires an implementation of the `CacheAction` interface. ```APIDOC ## POST /cache/performActionOnCaches ### Description Enables the execution of custom actions on cache entries that meet specified criteria. This method takes parameters similar to the `list` and `clear` operations, plus a `CacheAction` implementation. ### Method POST ### Endpoint `/cache/performActionOnCaches ### Parameters #### Query Parameters - **minSize** (long) - Optional - Minimum size of cache entries to consider. - **maxSize** (long) - Optional - Maximum size of cache entries to consider. - **minDate** (String) - Optional - Minimum date threshold for cache entries. - **maxDate** (String) - Optional - Maximum date threshold for cache entries. - **filter1** (String) - Optional - Additional filter criteria. - **filter2** (String) - Optional - Additional filter criteria. - **action** (CacheAction) - Required - An implementation of the `CacheAction` interface defining the action to perform. ### Request Example ``` POST /cache/performActionOnCaches?minSize=500&action=MyCustomCacheAction ``` ### Response #### Success Response (200) - **result** (String) - The result of the custom action performed on the cache entries. #### Response Example ```json { "result": "Action completed successfully." } ``` ``` -------------------------------- ### Cache Entry Operations Source: https://cocoon.apache.org/3.0/reference/html-single/index Provides operations to interact with individual cache entries, such as retrieving the cache key, value, size, and setting a new value. ```APIDOC ## Cache Entry Operations ### Description These operations allow for detailed inspection and modification of individual cache entries managed by the Cache Entry Monitor. ### Get Cache Key #### Method GET #### Endpoint `/cache/entry/{entryId}/key #### Response ##### Success Response (200) - **cacheKey** (CacheKey) - The unique identifier for the cache entry. ### Get Cache Value #### Method GET #### Endpoint `/cache/entry/{entryId}/value #### Response ##### Success Response (200) - **cacheValue** (Object) - The value stored in the cache entry. ### Set Cache Value #### Method POST #### Endpoint `/cache/entry/{entryId}/value #### Parameters ##### Request Body - **newValue** (String) - Required - The new value to set for the cache entry. #### Response ##### Success Response (200) - **success** (boolean) - `true` if the value was updated successfully. ### Get Entry Size #### Method GET #### Endpoint `/cache/entry/{entryId}/size #### Response ##### Success Response (200) - **size** (String) - A human-readable representation of the cache entry's size. ``` -------------------------------- ### Java 1.5 StAX Dependency (Maven) Source: https://cocoon.apache.org/3.0/reference/html-single/index Specifies the Maven dependency required to use StAX with Java 1.5. The wstx-asl artifact from org.codehaus.woodstox is necessary because the reference implementation depends on JAXP 1.4, which is not included in Java 1.5. ```xml org.codehaus.woodstox wstx-asl 3.2.7 ``` -------------------------------- ### Implement StAX Generator using AbstractStAXProducer in Java Source: https://cocoon.apache.org/3.0/reference/html-single/index This Java code demonstrates how to implement a custom StAX Generator by extending AbstractStAXProducer. It initializes an XMLEventReader from an InputStream and provides methods to check for the next event and retrieve it. This is useful for producing XML events in a pipeline. ```java import java.io.InputStream; import java.net.URL; import javax.xml.stream.FactoryConfigurationError; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; import org.apache.cocoon.pipeline.SetupException; import org.apache.cocoon.pipeline.component.Starter; public class MyStAXGenerator extends AbstractStAXProducer implements Starter { private XMLEventReader reader; public MyStAXGenerator(InputStream inputStream) { try { this.reader = XMLInputFactory.newInstance().createXMLEventReader(inputStream); } catch (XMLStreamException e) { throw new SetupException("Error during setup an XMLEventReader on the inputStream", e); } catch (FactoryConfigurationError e) { throw new SetupException("Error during setup the XMLInputFactory for creating an XMLEventReader", e); } } public void execute() { this.getConsumer().initiatePullProcessing(); } public boolean hasNext() { return this.reader.hasNext(); } public XMLEvent nextEvent() throws XMLStreamException { return this.reader.nextEvent(); } public XMLEvent peek() throws XMLStreamException { return this.reader.peek(); } } ``` -------------------------------- ### Implement DaisyLinkRewriteTransformer for XML Event Transformation Source: https://cocoon.apache.org/3.0/reference/html-single/index This Java transformer extends AbstractStAXTransformer to process XML events. It identifies anchor elements, collects link information using navigators, rewrites attributes, and emits events. It handles nested link information and returns unparsed events. ```java public class DaisyLinkRewriteTransformer extends AbstractStAXTransformer { @Override protected void produceEvents() throws XMLStreamException { while (this.getParent().hasNext()) { XMLEvent event = this.getParent().nextEvent(); if (this.anchorNavigator.fulfillsCriteria(event)) { ArrayList innerContent = new ArrayList(); LinkInfo linkInfo = this.collectLinkInfo(innerContent); if(linkInfo != null) { linkInfo.setNavigationPath(this.getAttributeValue(event.asStartElement(), PUBLISHER_NS,"navigationPath")); this.rewriteAttributesAndEmitEvent(event.asStartElement(),linkInfo); if(innerContent.size() != 0) { this.addAllEventsToQueue(innerContent); } } /* ... */ } /* ... */ } } private LinkInfo collectLinkInfo(List events) throws XMLStreamException { Navigator linkInfoNavigator = new InSubtreeNavigator(LINK_INFO_EL); Navigator linkInfoPartNavigator = new FindStartElementNavigator(LINK_PART_INFO_EL); LinkInfo linkInfo = null; while (this.getParent().hasNext()) { XMLEvent event = this.getParent().peek(); if (linkInfoNavigator.fulfillsCriteria(event)) { event = this.getParent().nextEvent(); if (linkInfoPartNavigator.fulfillsCriteria(event)) { /* ... */ String fileName = this.getAttributeValue(event.asStartElement(),"fileName"); if (!"".equals(fileName)) { linkInfo.setFileName(fileName); } } /* ... */ } else if (event.isCharacters()) { events.add(this.getParent().nextEvent()); } else { return linkInfo; } } return linkInfo; } private void rewriteAttributesAndEmitEvent(StartElement event, LinkInfo linkInfo) ; } ``` -------------------------------- ### Add Cocoon-Wicket Dependency to Maven Project Source: https://cocoon.apache.org/3.0/reference/html-single/index This snippet shows how to add the cocoon-wicket dependency to your Maven project's pom.xml file. Ensure you are using a compatible version of Cocoon. ```xml org.apache.cocoon.wicket cocoon-wicket 3.0.0-alpha-2 ``` -------------------------------- ### Flexible Cache Entry Removal Source: https://cocoon.apache.org/3.0/reference/html-single/index Performs a search and removal of cache entries based on multiple criteria. This operation requires the same parameters as the `list` operation. ```APIDOC ## POST /cache/clear ### Description Removes cache entries based on a flexible set of criteria, including size and date ranges. This operation mirrors the parameters of the `list` operation for defining the search criteria. ### Method POST ### Endpoint `/cache/clear ### Parameters #### Query Parameters - **minSize** (long) - Optional - Minimum size of cache entries to consider. - **maxSize** (long) - Optional - Maximum size of cache entries to consider. - **minDate** (String) - Optional - Minimum date threshold for cache entries. - **maxDate** (String) - Optional - Maximum date threshold for cache entries. - **filter1** (String) - Optional - Additional filter criteria. - **filter2** (String) - Optional - Additional filter criteria. ### Request Example ``` POST /cache/clear?minSize=100&maxSize=1000&minDate=2023-10-26T00:00:00Z ``` ### Response #### Success Response (200) - **success** (boolean) - `true` if all matching entries were removed successfully, `false` if an error occurred. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Cocoon-Rest Maven Dependency (Maven) Source: https://cocoon.apache.org/3.0/reference/html-single/index Shows how to add the cocoon-rest module as a dependency in a Maven project. This is a prerequisite for integrating JAX-RS services into a Cocoon application. ```xml org.apache.cocoon.rest cocoon-rest ``` -------------------------------- ### Configure CocoonJAXRSServlet for JAX-RS REST Endpoints Source: https://cocoon.apache.org/3.0/reference/html-single/index This XML configuration defines a Spring bean for CocoonJAXRSServlet, exposing JAX-RS REST endpoints. It specifies the mount path, context path, connections to other services, and a list of REST resources. ```xml ``` -------------------------------- ### Clear Cache Entries Smaller Than Size Source: https://cocoon.apache.org/3.0/reference/html-single/index Removes all cache entries whose size is smaller than the specified value. The operation stops and returns false upon the first failure. ```APIDOC ## POST /cache/clearAllSmallerThen ### Description Removes all cache entries that are smaller than the specified size. Returns `true` if all entries were successfully removed, `false` otherwise. ### Method POST ### Endpoint `/cache/clearAllSmallerThen ### Parameters #### Query Parameters - **size** (long) - Required - The maximum size threshold for cache entries to be removed. ### Request Example ``` POST /cache/clearAllSmallerThen?size=512 ``` ### Response #### Success Response (200) - **success** (boolean) - `true` if all entries were removed successfully, `false` if an error occurred during removal. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Clear Cache Entries Older Than Date Source: https://cocoon.apache.org/3.0/reference/html-single/index Removes all cache entries that are older than the specified date string. The operation stops and returns false upon the first failure. ```APIDOC ## POST /cache/clearAllOlderThen ### Description Removes all cache entries that are older than the specified date. Returns `true` if all entries were successfully removed, `false` otherwise. ### Method POST ### Endpoint `/cache/clearAllOlderThen ### Parameters #### Query Parameters - **date** (String) - Required - The date threshold. Entries older than this date will be removed. ### Request Example ``` POST /cache/clearAllOlderThen?date=2023-10-27T10:00:00Z ``` ### Response #### Success Response (200) - **success** (boolean) - `true` if all entries were removed successfully, `false` if an error occurred during removal. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Clear Cache Entries Greater Than Size Source: https://cocoon.apache.org/3.0/reference/html-single/index Removes all cache entries whose size is greater than the specified value. The operation stops and returns false upon the first failure. ```APIDOC ## POST /cache/clearAllGreatherThen ### Description Removes all cache entries that are larger than the specified size. Returns `true` if all entries were successfully removed, `false` otherwise. ### Method POST ### Endpoint `/cache/clearAllGreatherThen ### Parameters #### Query Parameters - **size** (long) - Required - The minimum size threshold for cache entries to be removed. ### Request Example ``` POST /cache/clearAllGreatherThen?size=1024 ``` ### Response #### Success Response (200) - **success** (boolean) - `true` if all entries were removed successfully, `false` if an error occurred during removal. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Clear Cache Entries Younger Than Date Source: https://cocoon.apache.org/3.0/reference/html-single/index Removes all cache entries that are younger than the specified date string. The operation stops and returns false upon the first failure. ```APIDOC ## POST /cache/clearAllYoungerThen ### Description Removes all cache entries that are younger than the specified date. Returns `true` if all entries were successfully removed, `false` otherwise. ### Method POST ### Endpoint `/cache/clearAllYoungerThen ### Parameters #### Query Parameters - **date** (String) - Required - The date threshold. Entries younger than this date will be removed. ### Request Example ``` POST /cache/clearAllYoungerThen?date=2023-10-27T10:00:00Z ``` ### Response #### Success Response (200) - **success** (boolean) - `true` if all entries were removed successfully, `false` if an error occurred during removal. #### Response Example ```json { "success": true } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.