scs.core
Class ComponentContext

java.lang.Object
  extended by scs.core.ComponentContext

public class ComponentContext
extends Object

This class is the local representation of a SCS component. Its concept doesn't exist in the CORBA environment. As such, an instance of this class is considered a local instance of a component and gathers all of its facets, receptacles and meta-data. It also holds references to the ORB and POA used to create and activate its facets. Specifically in Java, this class is also responsible for generating connection id's for receptacles.


Field Summary
 int CONNECTION_LIMIT
          Limit of concurrent connections, per component.
static String ICOMPONENT_FACET_NAME
          Name used for the IComponent facet.
static String IMETAINTERFACE_FACET_NAME
          Name used for the IMetaInterface facet.
static String IRECEPTACLES_FACET_NAME
          Name used for the IReceptacles facet.
 
Constructor Summary
ComponentContext(ORB orb, POA poa, ComponentId id)
          Primary constructor.
 
Method Summary
 void addFacet(String name, String interfaceName, Servant servant)
          Adds a new facet to the component instance.
 void addReceptacle(String name, String interfaceName, boolean isMultiplex)
          Adds a new receptacle to the component instance.
 ComponentId getComponentId()
          Provides the ComponentId of this component instance.
 String getComponentIdAsString()
          Returns a stringified version of the component's id, concatenating its name with the version number and its platform spec.
 Facet getFacetByName(String name)
          Provides metadata about a specific facet.
 Collection<Facet> getFacets()
          Provides metadata about the component's facets.
 IComponent getIComponent()
          Provides a direct reference to the IComponent facet.
 ORB getORB()
          Returns the ORB.
 POA getPOA()
          Returns the POA.
 Receptacle getReceptacleByName(String name)
          Provides metadata about a specific receptacle.
 Collection<Receptacle> getReceptacles()
          Provides metadata about the component's receptacles.
 void removeFacet(String name)
          Removes a facet from the component.
 void removeReceptacle(String name)
          Removes a receptacle from the component.
 void updateFacet(String name, Servant servant)
          Changes the servant of a facet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICOMPONENT_FACET_NAME

public static final String ICOMPONENT_FACET_NAME
Name used for the IComponent facet.

See Also:
Constant Field Values

IRECEPTACLES_FACET_NAME

public static final String IRECEPTACLES_FACET_NAME
Name used for the IReceptacles facet.

See Also:
Constant Field Values

IMETAINTERFACE_FACET_NAME

public static final String IMETAINTERFACE_FACET_NAME
Name used for the IMetaInterface facet.

See Also:
Constant Field Values

CONNECTION_LIMIT

public final int CONNECTION_LIMIT
Limit of concurrent connections, per component. This'll probably be removed in the next version!

See Also:
Constant Field Values
Constructor Detail

ComponentContext

public ComponentContext(ORB orb,
                        POA poa,
                        ComponentId id)
                 throws SCSException
Primary constructor. The returned component instance will always have the three basic facets (IComponent, IReceptacles, IMetaInterface) instantiated. If the user wishes to use his own implementation of one of these facets, it's possible to replace them via the addFacet method. Other facets and receptacles can also be added. The returned instance of this class is considered a new SCS component instance.

Parameters:
orb - The ORB to be used when creating this component instance's facets.
poa - The POA to register this component instance's facets.
id - The type of this component.
Throws:
SCSException - If any error occurs. The exception shall contain another, more specific exception.
Method Detail

getComponentId

public ComponentId getComponentId()
Provides the ComponentId of this component instance. ComponentId's aren't instance identifiers; they specify a component's name, version and platform specification.

Returns:
The component's ComponentId

addFacet

public void addFacet(String name,
                     String interfaceName,
                     Servant servant)
              throws SCSException
Adds a new facet to the component instance. This method activates the facet with the POA associated to the component. Also, it checks for the existence of the _get_component() method. If it's not implemented, a warning will be logged. If the facet name already exists, the old facet will be replaced and deactivated within the component's POA.

Parameters:
name - The facet's name. This acts as the facet identifier within the component.
interfaceName - The facet's IDL interface.
servant - The facet implementation, not yet activated within the POA.
Throws:
SCSException - If an UserException is catched.

updateFacet

public void updateFacet(String name,
                        Servant servant)
                 throws SCSException
Changes the servant of a facet. This method deactivates the old servant and activates the new one. The facet remains with the same name and interface.

Parameters:
name - The existent facet's name.
servant - The new servant, not yet activated within the POA.
Throws:
SCSException - If an UserException is catched.

addReceptacle

public void addReceptacle(String name,
                          String interfaceName,
                          boolean isMultiplex)
                   throws ReceptacleAlreadyExistsException
Adds a new receptacle to the component instance. If the receptacle name already exists, the old receptacle will be replaced.

Parameters:
name - The receptacle's name. This acts as the receptacle identifier within the component.
interfaceName - The receptacle's IDL interface.
isMultiplex - True if the receptacle accepts more than one connection, false otherwise.
Throws:
ReceptacleAlreadyExistsException

removeFacet

public void removeFacet(String name)
                 throws SCSException
Removes a facet from the component. The facet is deactivated within the component's POA before being removed.

Parameters:
name - The name of the facet to be removed.
Throws:
SCSException - If an UserException is catched.

removeReceptacle

public void removeReceptacle(String name)
                      throws ReceptacleDoesNotExistException
Removes a receptacle from the component.

Parameters:
name - The name of the receptacle to be removed.
Throws:
ReceptacleDoesNotExistException

getFacets

public Collection<Facet> getFacets()
Provides metadata about the component's facets.

Returns:
An unmodifiable collection with the facet metadata.

getFacetByName

public Facet getFacetByName(String name)
Provides metadata about a specific facet.

Parameters:
name - The name of the facet.
Returns:
The facet metadata.

getReceptacles

public Collection<Receptacle> getReceptacles()
Provides metadata about the component's receptacles.

Returns:
An unmodifiable collection with the receptacle metadata.

getReceptacleByName

public Receptacle getReceptacleByName(String name)
Provides metadata about a specific receptacle.

Parameters:
name - The name of the receptacle.
Returns:
The receptacle metadata.

getIComponent

public IComponent getIComponent()
Provides a direct reference to the IComponent facet.

Returns:
The IComponent facet.

getComponentIdAsString

public String getComponentIdAsString()
Returns a stringified version of the component's id, concatenating its name with the version number and its platform spec.

Returns:
The stringified component's id.

getPOA

public POA getPOA()
Returns the POA.

Returns:
The POA.

getORB

public ORB getORB()
Returns the ORB.

Returns:
The ORB.


Copyright © 2014. All Rights Reserved.