/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.dd;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


/**
 * Represents the ejb-jar.xml deployment descriptor for the 2.1 schema
 *
 * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
 * @version <tt>$Revision: 1.5.2.4 $</tt>
 */
public class EjbJarDD
{

   // ejb-jar.xml
   private String version;

   private String displayName;

   private Relationships relationships;

   private AssemblyDescriptor assemblyDescriptor;

   // jboss.xml
   private String securityDomain;

   private LoaderRepository loaderRepository;
   
   private List<InvokerProxyBinding> invokerProxyBindings = new ArrayList();

   // both
   private EnterpriseBeans enterpriseBeans;
   
   public void addInvokerProxyBinding(InvokerProxyBinding binding)
   {
      invokerProxyBindings.add(binding);
   }
   
   public List getInvokerProxyBindings()
   {
      return invokerProxyBindings;
   }
   
   public InvokerProxyBinding findInvokerProxyBinding(String name)
   {
      Iterator bindings = invokerProxyBindings.iterator();
      while (bindings.hasNext())
      {
         InvokerProxyBinding binding = (InvokerProxyBinding)bindings.next();
         if (binding.getName().equals(name))
            return binding;
      }
      
      return null;
   }

   public LoaderRepository getLoaderRepository()
   {
      return loaderRepository;
   }

   public void setLoaderRepository(LoaderRepository loaderRepository)
   {
      this.loaderRepository = loaderRepository;
   }

   public String getSecurityDomain()
   {
      return securityDomain;
   }

   public void setSecurityDomain(String securityDomain)
   {
      this.securityDomain = securityDomain;
   }

   public String getVersion()
   {
      return version;
   }

   public void setVersion(String version)
   {
      this.version = version;
   }

   public String getDisplayName()
   {
      return displayName;
   }

   public void setDisplayName(String displayName)
   {
      this.displayName = displayName;
   }

   public EnterpriseBeans getEnterpriseBeans()
   {
      return enterpriseBeans;
   }

   public void setEnterpriseBeans(EnterpriseBeans enterpriseBeans)
   {
      this.enterpriseBeans = enterpriseBeans;
   }

   public Relationships getRelationships()
   {
      return relationships;
   }

   public void setRelationships(Relationships relationships)
   {
      this.relationships = relationships;
   }

   public AssemblyDescriptor getAssemblyDescriptor()
   {
      return assemblyDescriptor;
   }

   public void setAssemblyDescriptor(AssemblyDescriptor assemblyDescriptor)
   {
      this.assemblyDescriptor = assemblyDescriptor;
   }

   public String toString()
   {
      StringBuffer sb = new StringBuffer(100);
      sb.append('[');
      sb.append("version=").append(version);
      sb.append(",");
      sb.append("displayName=").append(displayName);
      sb.append(']');
      return sb.toString();
   }
}
