DESY ACOP Beans Home

com.cosylab.application
Class DefaultPlugInManager

java.lang.Object
  extended by com.cosylab.application.DefaultPlugInManager
All Implemented Interfaces:
PlugInManager

public class DefaultPlugInManager
extends java.lang.Object
implements PlugInManager

Deafultimplementation of a PlugInManager interface.

Version:
$$id$$
Author:
Igor Kriznar (igor.kriznar&x40;cosylab.com)

Constructor Summary
DefaultPlugInManager()
          A default constructor for the plug-in manager.
 
Method Summary
 PlugIn acquirePlugIn(java.lang.Class plugType)
          Returns a plugin with plugType type.
 void addPlugInListener(PlugInListener l)
          Adds a plugin listener.
 void destroy()
          Destroys this cosy panel.
 java.lang.String getName()
           
 ApplicationPanel getOwnerPanel()
          Returns the parent of this manager.
 PlugIn getPlugIn(java.lang.Class plugType)
          Returns a plugin with a given type.
 PlugInListener[] getPlugInListeners()
          Returns a list of all plugin listeners, as required by Java 1.4 Beans specs.
 PlugIn[] getPlugIns()
          Returns all plugins managed by this cosy component.
 void installPlugIn(java.lang.Class plugType)
          Installs a new plugin.
 boolean isDestroyed()
          Returns true iff this panel has been destroyed.
 void removePlugIn(java.lang.Class plugType)
          Removes plugin from meneger.
 void removePlugInListener(PlugInListener l)
          Removes a plugin listener.
 void setOwnerPanel(ApplicationPanel panel)
          Sets logical parent to this manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPlugInManager

public DefaultPlugInManager()
A default constructor for the plug-in manager.

Method Detail

getOwnerPanel

public ApplicationPanel getOwnerPanel()
Returns the parent of this manager.

Specified by:
getOwnerPanel in interface PlugInManager
Returns:
the logical parent of this

isDestroyed

public final boolean isDestroyed()
Returns true iff this panel has been destroyed.

Returns:
boolean true if destroyed

destroy

public final void destroy()
Destroys this cosy panel. If already destroyed, this method returns NOP. If plugin has visual component, first is from parent removed plugins visual component, tha is plugin destroyed.

All plug-ins are destroyed before managers destroyed flag is set to true and destruction completes.


installPlugIn

public final void installPlugIn(java.lang.Class plugType)
                         throws PlugInException
Installs a new plugin. Checks if the plugType parameter is valid, otherwise a PlugInException is thrown; checks if the state of this object is valid; checks if the cyclic installation is occuring; checks if the plug has already been installed. If all these checks are passed, a new instance of the plugin is created, added as a child of this cosy panel, and the installPlugIn method of the plugin is invoked. If it completes successfully, the cosy listeners are notified about the new plugin. If it fails, the plugin is removed from the cosy component children of this panel.

Specified by:
installPlugIn in interface PlugInManager
Parameters:
plugType - the class representing the plug, which must implement PlugIn interface
Throws:
PlugInException - if the plug installation fails
java.lang.NullPointerException - if input is null
java.lang.IllegalStateException - if no parent is set
See Also:
PlugInManager.installPlugIn(Class)

getPlugIns

public PlugIn[] getPlugIns()
Returns all plugins managed by this cosy component.

Specified by:
getPlugIns in interface PlugInManager
Returns:
PlugIn[] a list of plug ins
See Also:
PlugInManager.getPlugIns()

getPlugIn

public PlugIn getPlugIn(java.lang.Class plugType)
Returns a plugin with a given type. Since plugins are installed by their type and installations with the same type are not allowed, the designation by type is unique.

Specified by:
getPlugIn in interface PlugInManager
Parameters:
plugType - the type of the plug to look up
Returns:
PlugIn the plugin instance of null if no plugin with the specified type was found
Throws:
java.lang.NullPointerException - if input is null
See Also:
PlugInManager.getPlugIn(Class)

addPlugInListener

public void addPlugInListener(PlugInListener l)
Adds a plugin listener.

Specified by:
addPlugInListener in interface PlugInManager
Parameters:
l - a listener object
See Also:
PlugInManager.addPlugInListener(PlugInListener)

removePlugInListener

public void removePlugInListener(PlugInListener l)
Removes a plugin listener.

Specified by:
removePlugInListener in interface PlugInManager
Parameters:
l - a listener object
See Also:
PlugInManager.removePlugInListener(PlugInListener)

getPlugInListeners

public PlugInListener[] getPlugInListeners()
Returns a list of all plugin listeners, as required by Java 1.4 Beans specs.

Specified by:
getPlugInListeners in interface PlugInManager
Returns:
PlugInListener[] an array of listeners
See Also:
PlugInManager.getPlugInListeners()

removePlugIn

public void removePlugIn(java.lang.Class plugType)
Removes plugin from meneger. First removes plugin visual component from parent, then calls destroy() and then sets parent to null.

Specified by:
removePlugIn in interface PlugInManager
Parameters:
plugType - to be removed
See Also:
com.cosylab.gui.core.PlugInManager#removePlugIn(java.lang.Class)

setOwnerPanel

public void setOwnerPanel(ApplicationPanel panel)
Sets logical parent to this manager.

Specified by:
setOwnerPanel in interface PlugInManager
See Also:
com.cosylab.gui.core.CosyComponent#setCosyPanelParent(com.cosylab.gui.core.CosyApplicationPanel)

getName

public java.lang.String getName()

acquirePlugIn

public PlugIn acquirePlugIn(java.lang.Class plugType)
                     throws PlugInException
Description copied from interface: PlugInManager
Returns a plugin with plugType type. If manager does not have recquired plugub, trys to install it first.

Specified by:
acquirePlugIn in interface PlugInManager
Returns:
PlugIn the plugin of type plugType or null
Throws:
PlugInException


Copyright © 2010. All Rights Reserved.