org.ow2.petals.se.xslt.model.XsltConfiguration Maven / Gradle / Ivy
/**
* Copyright (c) 2010-2012 EBM WebSourcing, 2012-2016 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.se.xslt.model;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* A bean to store configuration elements for XSLT service-unit.
* @author Vincent Zurczak - EBM WebSourcing
*/
public class XsltConfiguration {
/**
* Static integer used to generate identifiers.
*/
private static AtomicInteger idCounter = new AtomicInteger();
/**
* The configuration identifier (generated, never null).
*/
private final int id;
/**
* The path of the XSL style sheet in the SU directory.
*/
private final String xslPath;
/**
* The transformer factory class name to use.
*/
private final String transformerFactoryClassName;
/**
* The minimum size of the transformer pool (the number of transformers created at the start of the SU)
*/
private final int transformerPoolSizeMin;
/**
* The maximum size of the transformer pool (the limit number of transformers created by the pool)
*/
private final int transformerPoolSizeMax;
/**
* The path of the SU root directory.
*/
private final String suInstallRoot;
/**
* The name of the attachment when the transformation result is returned attached.
*/
private final String outputAttachmentName;
/**
* The end-point name associated with this configuration.
*/
private final String endpointName;
/**
* The service-unit associated with this configuration.
*/
private final String serviceUnitName;
/**
* A map to store XSL parameters.
*/
private final Map paramNameToParamBean = new HashMap();
/**
* Constructor.
*
* @param xslPath
* the XSL path
* @param transformerFactoryClassName
* the transformer factory class name
* @param suInstallRoot
* the path of the SU root directory
* @param outputAttachmentName
* the output attachment's name
* @param endpointName
* the end-point name
* @param serviceUnitName
* the service-unit name
* @param paramNameToParamBean
* the XSL parameters as a non-null map
*
* key = parameter name, value = parameter bean
*
*/
public XsltConfiguration(
String xslPath,
String transformerFactoryClassName,
int transformerPoolSizeMin,
int transformerPoolSizeMax,
String suInstallRoot,
String outputAttachmentName,
String endpointName,
String serviceUnitName, Map paramNameToParamBean) {
// Create the ID
this.id = idCounter.getAndIncrement();
// Store values
this.xslPath = xslPath;
this.transformerFactoryClassName = transformerFactoryClassName;
this.transformerPoolSizeMin = transformerPoolSizeMin;
this.transformerPoolSizeMax = transformerPoolSizeMax;
this.suInstallRoot = suInstallRoot;
this.endpointName = endpointName;
this.serviceUnitName = serviceUnitName;
this.outputAttachmentName = outputAttachmentName;
this.paramNameToParamBean.putAll(paramNameToParamBean);
}
/**
* @return the xslPath
*/
public String getXslPath() {
return this.xslPath;
}
/**
* @return the transformerFactoryClassName
*/
public String getTransformerFactoryClassName() {
return this.transformerFactoryClassName;
}
/**
* @return the transformerPoolSizeMin
*/
public int getTransformerPoolSizeMin() {
return this.transformerPoolSizeMin;
}
/**
* @return the transformerPoolSizeMax
*/
public int getTransformerPoolSizeMax() {
return this.transformerPoolSizeMax;
}
/**
* @return the suInstallRoot
*/
public String getSuInstallRoot() {
return this.suInstallRoot;
}
/**
* @return the outputAttachmentName
*/
public String getOutputAttachmentName() {
return this.outputAttachmentName;
}
/**
* @return the endpointName
*/
public String getEndpointName() {
return this.endpointName;
}
/**
* @return the serviceUnitName
*/
public String getServiceUnitName() {
return this.serviceUnitName;
}
/**
* @return the map that associates (XSL) parameter names to (XSL) parameter
* beans
*/
public Map getParamNameToParamBean() {
return this.paramNameToParamBean;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals( Object obj ) {
return obj != null
&& obj instanceof XsltConfiguration
&& ((XsltConfiguration) obj).id == this.id;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return this.id;
}
}