| [news.eclipse.modeling.mdt.uml2.uml] Re: Component, Port and Interface |
Hi Kenn,
Component component = umlfactory.createComponent();
component.setName("ProviderComponent");
Interface inter1 = umlfactory.createInterface();
inter1.setName("Provide1");
Interface inter2 = umlfactory.createInterface();
inter2.setName("Provide2");
Port port = umlfactory.createPort();
port.setName("ProvidePort");I can set only one interface as port type with port.setType(). How I get add both interfaces to the provided reference list of the port?
Thanks in advance Christian
Christian,
I'm quite sure this question has been asked on the newsgroup before... The provided and required interfaces of components and ports are derived, i.e. they are calculated from other properties. The Javadoc for Port#getProvideds(), for example, looks like this:
Returns the value of the 'Provided' reference list. The list contents are of type org.eclipse.uml2.uml.Interface. References the interfaces specifying the set of operations and receptions which the classifier offers to its environment, and which it will handle either directly or by forwarding it to a part of its internal structure. This association is derived from the interfaces realized by the type of the port or by the type of the port, if the port was typed by an interface.
See Also:
org.eclipse.uml2.uml.UMLPackage.getPort_Provided()
Returns:
the value of the 'Provided' reference list.
@model
type="org.eclipse.uml2.uml.Interface" transient="true" changeable="false" volatile="true" derived="true" ordered="false"
@generated
So, to add a provided interface to a port, you would type the port with the desired interface or with a classifier that realizes (has an interface realization relationship with) the desired interface.
Kenn
"Christian Hein" <hein.@xxxxxxxxxxxxxxxx> wrote in message news:elu99v$tpi$1@xxxxxxxxxxxxxxxxxxxxHi all,
I have the following code:
UML2Factory umlfactory = UML2Factory.eINSTANCE;
Component component = umlfactory.createComponent(); component.setName("ProviderComponent");
Interface interf = umlfactory.createInterface(); interf.setName("HelloWorld");
Port port = umlfactory.createPort(); port.setName("Source");
But in the following line I get an UnsupportedOperationException port.getProvideds().add(interf);
I wonder if somebody can answer how to add this interface to the list of provided interfaces of the port.
Thanks in advance
Christian