All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.milyn.javabean.dynamic.ext.BeanClassLookup Maven / Gradle / Ivy

There is a newer version: 1.7.1
Show newest version
/*
 * Milyn - Copyright (C) 2006 - 2010
 *
 *  This library 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 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:
 *  http://www.gnu.org/licenses/lgpl.txt
 */

package org.milyn.javabean.dynamic.ext;

import org.milyn.SmooksException;
import org.milyn.cdr.SmooksConfigurationException;
import org.milyn.cdr.SmooksResourceConfiguration;
import org.milyn.cdr.extension.ExtensionContext;
import org.milyn.container.ExecutionContext;
import org.milyn.delivery.dom.DOMVisitBefore;
import org.milyn.javabean.ext.BeanConfigUtil;
import org.w3c.dom.Element;

/**
 * Bean class lookup visitor.
 * 

* Used during processing of the extended DMB configuration * for looking up the actual bean runtime Class from the beanId * specified on the on the . * * [email protected] */ public class BeanClassLookup implements DOMVisitBefore { public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { // The current config on the stack must be ... ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); SmooksResourceConfiguration dmbWriterConfig = extensionContext.getResourceStack().peek(); if(dmbWriterConfig.getStringParameter("beanClass") == null) { String beanId = dmbWriterConfig.getStringParameter("beanId"); if(beanId == null) { throw new SmooksConfigurationException("One of the 'beanClass' or 'beanId' attributes must be configured on the configuration."); } SmooksResourceConfiguration beanCreatorConfig = BeanConfigUtil.findBeanCreatorConfig(beanId, executionContext); if(beanCreatorConfig == null) { throw new SmooksConfigurationException("Cannot find configuration for beanId '" + beanId + "' for . Reordered after config."); } String beanClass = beanCreatorConfig.getStringParameter(BeanConfigUtil.BEAN_CLASS_CONFIG); if(beanClass == null) { throw new SmooksConfigurationException("Cannot create find BeanWriter for beanId '" + beanId + "'. The associated configuration does not define a bean Class name."); } dmbWriterConfig.setParameter(BeanConfigUtil.BEAN_CLASS_CONFIG, beanClass); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy