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

org.jboss.managed.plugins.ManagedDeploymentImpl Maven / Gradle / Ivy

/*
 * JBoss, Home of Professional Open Source
 * Copyright 2007, Red Hat Middleware LLC, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * 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 software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.managed.plugins;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;

/**
 * A simple ManagedDeployment bean implementation
 * 
 * @author [email protected]
 * @version $Revision: 68394 $
 */
public class ManagedDeploymentImpl implements ManagedDeployment, Serializable
{
   private static final long serialVersionUID = 1;
   /** The full deployment name */
   private String name;
   /** The simple deployment name */
   private String simpleName;
   /** The set of types assigned to the deployment */
   private Set types;
   /** The profile service phase for the deployment */
   private DeploymentPhase phase;
   /** The parent deployment if any */
   private ManagedDeployment parent;
   /** The deployment ManagedObjects */
   private Map unitMOs;
   /** The flattened map of all ManagedObject properties */   
   private Map properties;
   /** The ManagedComponent wrappers for ManagedObjects marked as components */
   private Map components = new HashMap();
   /** The child deployemnts */
   private List children = new ArrayList();
   
   public ManagedDeploymentImpl(String name, String simpleName, DeploymentPhase phase,
         ManagedDeployment parent, Map unitMOs)
   {
      this.name = name;
      this.simpleName = simpleName;
      this.phase = phase;
      this.parent = parent;
      this.unitMOs = unitMOs;
      properties = new HashMap();
      for(ManagedObject mo : unitMOs.values())
      {
         properties.putAll(mo.getProperties());
      }
      if(parent != null)
      {
         parent.getChildren().add(this);
      }
   }

   public String getName()
   {
      return name;
   }
   public String getSimpleName()
   {
      return simpleName;
   }

   public boolean addType(String type)
   {
      return types.add(type);
   }
   public Set getTypes()
   {
      return types;
   }
   public void setTypes(Set types)
   {
      this.types = types;
   }

   public DeploymentPhase getDeploymentPhase()
   {
      return phase;
   }
   public ManagedDeployment getParent()
   {
      return parent;
   }

   public Set getComponentTemplateNames()
   {
      // TODO Auto-generated method stub
      return null;
   }
   public void addComponent(String name, ManagedComponent comp)
   {
      components.put(name, comp);
   }
   public ManagedComponent getComponent(String name)
   {
      return components.get(name);
   }

   public Map getComponents()
   {
      return components;
   }

   public boolean removeComponent(String name)
   {
      ManagedComponent mc = components.remove(name);
      return mc != null;
   }

   public Set getDeploymentTemplateNames()
   {
      // TODO Auto-generated method stub
      return null;
   }
   public List getChildren()
   {
      return children;
   }

   public ManagedDeployment addModule(String deplymentBaseName, DeploymentTemplateInfo info)
   {
      // TODO Auto-generated method stub
      return null;
   }

   public Map getProperties()
   {
      return properties;
   }

   public ManagedProperty getProperty(String name)
   {
      return properties.get(name);
   }

   public Set getPropertyNames()
   {
      return properties.keySet();
   }

   public Set getManagedObjectNames()
   {
      return unitMOs.keySet();
   }
   public Map getManagedObjects()
   {
      return unitMOs;
   }
   public ManagedObject getManagedObject(String name)
   {
      return unitMOs.get(name);
   }

   public String toString()
   {
      StringBuilder tmp = new StringBuilder(super.toString());
      tmp.append('{');
      tmp.append("name=");
      tmp.append(getName());
      tmp.append(", types=");
      tmp.append(types);
      tmp.append(", phase=");
      tmp.append(phase);
      tmp.append(", parent=");
      if( parent != null )
      {
         tmp.append("ManagedDeployment@");
         tmp.append(System.identityHashCode(parent));
      }
      else
      {
         tmp.append("null");
      }
      tmp.append(", components=");
      tmp.append(components);
      tmp.append(", children=");
      tmp.append(children);
      tmp.append('}');
      return tmp.toString();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy