Commit 1ceea3a7 authored by Daniele Romagnoli's avatar Daniele Romagnoli
Browse files

[GEOS-7177]: Support system property to enable JAIExt operations

parent 190b7a7b
......@@ -42,9 +42,37 @@ When supporting large images it is efficient to work on image subsets without lo
*It is quite important to remember that faster encoders are not necessarily going to visibly improve performance, if data loading and processing/rendering are dominating the response time, choosing a better encoder will likely not provide the expected benefits.*
**JAI/JAI-EXT Setup**-This panel can be used for choosing which operations may be registered as *JAI* or *JAI-EXT* ones. Users have to select the operations to move and then, when clicking on *Save*, GeoServer internally will replace the *JAI/JAI-EXT* operations and the associated *GeoTools* ones. The main difference between *JAI* and *JAI-EXT* operations is the support for external **ROIs** and image **NoData**.
JAI-EXT
-------
.. note:: More information about **JAI-EXT** may be found at the `JAI-EXT Project page <https://github.com/geosolutions-it/jai-ext>`_.
Quoting from `JAI-EXT Project page <https://github.com/geosolutions-it/jai-ext>`_, *JAI-EXT is an open-source project which aims to replace in the long term the JAI project*.
The main difference between *JAI* and *JAI-EXT* operations is the support for external **ROIs** and image **NoData** in *JAI-EXT*.
By default, **JAI-EXT** operations are disabled. Add the following java option to GeoServer startup script and restart GeoServer to have them enabled.
.. code-block:: xml
-Dorg.geotools.coverage.jaiext.enabled=true
Once done, the following panel will be available at the bottom of the JAI Settings page.
.. figure:: ../images/server_JAIEXT.png
:align: center
*JAI/JAIEXT Setup panel*
This panel can be used to chose which operations should be registered as *JAI* or *JAI-EXT* ones. Users can select the operations and move them from JAI-EXT to JAI list or viceversa.
.. figure:: ../images/server_JAIEXTops.png
:align: center
*JAI/JAIEXT Operations selection*
When clicking on *Save*, GeoServer internally will replace the *JAI/JAI-EXT* operations and the associated *GeoTools* ones.
.. warning:: Users should take care that *JAI* native libraries are not supported by *JAI-EXT*, since *JAI-EXT* is a pure Java API.
......@@ -7,6 +7,7 @@ package org.geoserver.wps;
import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
import static org.junit.Assert.fail;
import it.geosolutions.jaiext.JAIExt;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
......@@ -63,6 +64,7 @@ public abstract class WPSTestSupport extends GeoServerSystemTestSupport {
List<GridCoverage> coverages = new ArrayList<GridCoverage>();
static {
JAIExt.initJAIEXT(true, true);
Processors.addProcessFactory(MonkeyProcess.getFactory());
Processors.addProcessFactory(MultiRawProcess.getFactory());
Processors.addProcessFactory(MultiOutputEchoProcess.getFactory());
......
......@@ -12,6 +12,7 @@ import java.util.Set;
import java.util.TreeSet;
import org.geoserver.config.JAIEXTInfo;
import org.geotools.image.ImageWorker;
public class JAIEXTInfoImpl implements JAIEXTInfo {
......@@ -30,7 +31,7 @@ public class JAIEXTInfoImpl implements JAIEXTInfo {
private Set<String> jaiExtOperations = JAIEXT_OPS;
static {
JAIExt.initJAIEXT();
JAIExt.initJAIEXT(ImageWorker.isJaiExtEnabled());
populateOperations(JAIEXT_OPS);
}
......@@ -41,7 +42,9 @@ public class JAIEXTInfoImpl implements JAIEXTInfo {
if (jaiExtOperations == null) {
jaiExtOperations = JAIEXT_OPS;
}
populateOperations(jaiExtOperations);
if (ImageWorker.isJaiExtEnabled()) {
populateOperations(jaiExtOperations);
}
}
@Override
......@@ -71,7 +74,7 @@ public class JAIEXTInfoImpl implements JAIEXTInfo {
}
private static void populateOperations(Set<String> jaiExtOp) {
List<OperationItem> jaiextOps = JAIExt.getJAIEXTOperations();
List<OperationItem> jaiextOps = ImageWorker.isJaiExtEnabled() ? JAIExt.getJAIEXTOperations() : JAIExt.getJAIOperations();
for (OperationItem item : jaiextOps) {
String name = item.getName();
if (name.equalsIgnoreCase("algebric") || name.equalsIgnoreCase("operationConst")
......
......@@ -20,6 +20,7 @@ import org.geoserver.config.GeoServerInitializer;
import org.geoserver.config.JAIEXTInfo;
import org.geoserver.config.JAIInfo;
import org.geotools.coverage.processing.CoverageProcessor;
import org.geotools.image.ImageWorker;
import org.geotools.image.jai.Registry;
import com.sun.media.jai.util.SunTileCache;
......@@ -50,39 +51,40 @@ public class JAIInitializer implements GeoServerInitializer {
}
void initJAI(JAIInfo jai) {
JAI jaiDef = JAI.getDefaultInstance();
jai.setJAI( jaiDef );
// JAIEXT initialization
JAIExt.initJAIEXT();
if(jai.getJAIEXTInfo() != null){
JAIEXTInfo jaiext = jai.getJAIEXTInfo();
Set<String> jaiOperations = jaiext.getJAIOperations();
Set<String> jaiExtOperations = jaiext.getJAIEXTOperations();
if(jaiOperations != null && !jaiOperations.isEmpty()){
JAIExt.registerOperations(jaiOperations, false);
for(String opName : jaiOperations){
// Remove operations with old descriptors
CoverageProcessor.removeOperationFromProcessors(opName);
JAIExt.setJAIAcceleration(opName, true);
}
}
if(jaiExtOperations != null && !jaiExtOperations.isEmpty()){
Set<String> newJai = new TreeSet<String>(jaiExtOperations);
if (ImageWorker.isJaiExtEnabled()) {
if(jai.getJAIEXTInfo() != null){
JAIEXTInfo jaiext = jai.getJAIEXTInfo();
Set<String> jaiOperations = jaiext.getJAIOperations();
Set<String> jaiExtOperations = jaiext.getJAIEXTOperations();
if(jaiOperations != null && !jaiOperations.isEmpty()){
newJai.removeAll(jaiOperations);
}
for(String opName : newJai){
if(!JAIExt.isJAIExtOperation(opName)){
JAIExt.registerOperations(jaiOperations, false);
for(String opName : jaiOperations){
// Remove operations with old descriptors
CoverageProcessor.removeOperationFromProcessors(opName);
JAIExt.setJAIAcceleration(opName, true);
}
}
if(jaiExtOperations != null && !jaiExtOperations.isEmpty()){
Set<String> newJai = new TreeSet<String>(jaiExtOperations);
if(jaiOperations != null && !jaiOperations.isEmpty()){
newJai.removeAll(jaiOperations);
}
for(String opName : newJai){
if(!JAIExt.isJAIExtOperation(opName)){
// Remove operations with old descriptors
CoverageProcessor.removeOperationFromProcessors(opName);
}
}
JAIExt.registerOperations(newJai, true);
}
JAIExt.registerOperations(newJai, true);
// Update all the CoverageProcessor instances
CoverageProcessor.updateProcessors();
}
// Update all the CoverageProcessor instances
CoverageProcessor.updateProcessors();
}
//
......
......@@ -25,6 +25,7 @@ import org.geoserver.config.JAIEXTInfo;
import org.geoserver.config.JAIInfo;
import org.geoserver.config.JAIInfo.PngEncoderType;
import org.geoserver.web.wicket.ParamResourceModel;
import org.geotools.image.ImageWorker;
import com.sun.media.imageioimpl.common.PackageUtil;
......@@ -67,15 +68,22 @@ public class JAIPage extends ServerAdminPage {
CheckBox checkBoxMosaic = new CheckBox("allowNativeMosaic");
CheckBox checkBoxWarp = new CheckBox("allowNativeWarp");
JAIInfo info = (JAIInfo)jaiModel.getObject();
JAIEXTInfo je = info.getJAIEXTInfo();
JAIEXTInfo je = null;
boolean isJAIExtEnabled = ImageWorker.isJaiExtEnabled();
if (isJAIExtEnabled) {
je = info.getJAIEXTInfo();
}
boolean mosaicEnabled = je != null && !je.getJAIEXTOperations().contains("Mosaic");
boolean warpEnabled = je != null && !je.getJAIEXTOperations().contains("Warp");
checkBoxMosaic.setEnabled(mosaicEnabled);
checkBoxWarp.setEnabled(warpEnabled);
form.add(checkBoxMosaic);
form.add(checkBoxWarp);
form.add(new JAIEXTPanel("jaiext", jaiModel));
JAIEXTPanel jaiExtPanel = new JAIEXTPanel("jaiext", jaiModel);
if (!isJAIExtEnabled) {
jaiExtPanel.setVisible(false);
}
form.add(jaiExtPanel);
Button submit = new Button("submit", new StringResourceModel("submit", this, null)) {
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment