/*
* Copyright 2001-2006 C:1 Financial Services GmbH
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License Version 2.1, as published by the Free Software Foundation.
*
* This software 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
*/
package de.finix.contelligent.components;
import java.util.LinkedList;
import java.util.List;
import de.finix.contelligent.ComponentPath;
import de.finix.contelligent.ExternalRelationSource;
import de.finix.contelligent.ModificationVetoException;
import de.finix.contelligent.logging.LoggingService;
import de.finix.contelligent.render.Renderable;
import de.finix.contelligent.render.Renderer;
import de.finix.contelligent.render.TransformerRenderer;
public class CRemoteTransformer extends Folder implements Renderable, ExternalRelationSource {
final static org.apache.log4j.Logger log = LoggingService.getLogger(CRemoteTransformer.class);
private Renderer renderer;
private ComponentPath xmlPath;
public ComponentPath getXmlPath() {
return xmlPath;
}
public void setXmlPath(ComponentPath xmlPath) {
this.xmlPath = xmlPath;
}
public void postCreate() throws Exception {
try {
renderer = new TransformerRenderer(this, xmlPath, true);
} catch (Exception e) {
log.error("postCreate of RemoteTransformer: " + getComponentContext().getPath().toPath());
throw e;
}
}
public boolean isDynamic() {
return false;
}
public Renderer getRenderer() {
return renderer;
}
/*
* (non-Javadoc)
*
* @see de.finix.contelligent.ExternalRelationSource#relatedPaths()
*/
public List relatedPaths() {
LinkedList list = new LinkedList();
if (xmlPath != null) {
list.addLast(xmlPath);
}
return list;
}
/*
* (non-Javadoc)
*
* @see de.finix.contelligent.ExternalRelationSource#relatedPaths(java.util.List)
*/
public void relatedPaths(List newTargetPaths) throws ModificationVetoException {
if (newTargetPaths != null) {
if (newTargetPaths.size() == 0 && xmlPath != null) {
throw new ModificationVetoException("illegal state (a)");
} else if (newTargetPaths.size() == 1) {
ComponentPath path = (ComponentPath) newTargetPaths.get(0);
xmlPath = path;
} else {
throw new ModificationVetoException("illegal state (b)");
}
} else {
throw new ModificationVetoException("illegal state(c)");
}
}
}
|