001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.components;
019:
020: import java.util.LinkedList;
021: import java.util.List;
022:
023: import de.finix.contelligent.ComponentPath;
024: import de.finix.contelligent.ExternalRelationSource;
025: import de.finix.contelligent.ModificationVetoException;
026: import de.finix.contelligent.logging.LoggingService;
027: import de.finix.contelligent.render.Renderable;
028: import de.finix.contelligent.render.Renderer;
029: import de.finix.contelligent.render.TransformerRenderer;
030:
031: public class CRemoteTransformer extends Folder implements Renderable,
032: ExternalRelationSource {
033: final static org.apache.log4j.Logger log = LoggingService
034: .getLogger(CRemoteTransformer.class);
035:
036: private Renderer renderer;
037:
038: private ComponentPath xmlPath;
039:
040: public ComponentPath getXmlPath() {
041: return xmlPath;
042: }
043:
044: public void setXmlPath(ComponentPath xmlPath) {
045: this .xmlPath = xmlPath;
046: }
047:
048: public void postCreate() throws Exception {
049: try {
050: renderer = new TransformerRenderer(this , xmlPath, true);
051: } catch (Exception e) {
052: log.error("postCreate of RemoteTransformer: "
053: + getComponentContext().getPath().toPath());
054: throw e;
055: }
056: }
057:
058: public boolean isDynamic() {
059: return false;
060: }
061:
062: public Renderer getRenderer() {
063: return renderer;
064: }
065:
066: /*
067: * (non-Javadoc)
068: *
069: * @see de.finix.contelligent.ExternalRelationSource#relatedPaths()
070: */
071: public List relatedPaths() {
072: LinkedList list = new LinkedList();
073: if (xmlPath != null) {
074: list.addLast(xmlPath);
075: }
076: return list;
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see de.finix.contelligent.ExternalRelationSource#relatedPaths(java.util.List)
083: */
084: public void relatedPaths(List newTargetPaths)
085: throws ModificationVetoException {
086: if (newTargetPaths != null) {
087: if (newTargetPaths.size() == 0 && xmlPath != null) {
088: throw new ModificationVetoException("illegal state (a)");
089: } else if (newTargetPaths.size() == 1) {
090: ComponentPath path = (ComponentPath) newTargetPaths
091: .get(0);
092: xmlPath = path;
093: } else {
094: throw new ModificationVetoException("illegal state (b)");
095: }
096: } else {
097: throw new ModificationVetoException("illegal state(c)");
098: }
099: }
100: }
|