Package net.sf.xbus.technical

Source Code of net.sf.xbus.technical.SenderFactory

package net.sf.xbus.technical;

import net.sf.xbus.base.core.Constants;
import net.sf.xbus.base.core.XException;
import net.sf.xbus.base.core.config.Configuration;
import net.sf.xbus.base.core.reflection.ReflectionSupport;
import net.sf.xbus.base.xbussystem.XBUSSystem;

/**
* The class <code>SenderFactory</code> is used to dynamically create senders
* to neighbor systems.
* <p />
* It implements the <b>Factory</b>-Design-Pattern.
*/
public class SenderFactory
{
  /**
   * The appropriate {@link Sender} for the given destination will be created.
   * The name of the class is read from the
   * {@link net.sf.xbus.base.core.config.Configuration}.
   *
   * @param destination name of the interface definition
   * @throws XException if something goes wrong
   */
  public static Sender createSender(XBUSSystem destination) throws XException
  {
    Configuration config = Configuration.getInstance();
    String senderClassShortname = config.getValue(Constants.CHAPTER_SYSTEM,
        destination.getName(), "Sender");
    String senderClass = Configuration.getClass("Sender",
        senderClassShortname);

    Class[] conArgsClass = new Class[]
    {destination.getClass()};
    Object[] conArgs = new Object[]
    {destination};
    return (Sender) ReflectionSupport.createObject(senderClass,
        conArgsClass, conArgs);
  }
}
TOP

Related Classes of net.sf.xbus.technical.SenderFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.