Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
groupdefiner [2014/08/21 18:37] endler [Architecture] |
groupdefiner [2017/07/21 03:08] (current) |
||
---|---|---|---|
Line 10: | Line 10: | ||
===== Usage ===== | ===== Usage ===== | ||
- | Explicar aqui como utilizar. Quais são as principais interfaces, elementos etc. Dar um rápido exemplo de como utilizar. Se possível e aplicável fazer um breve "hello world". | + | O GroupDefiner possui apenas um construtor, onde deve ser passado uma implementação do GroupSelector. A interface GroupSelector é mostrada abaixo. |
- | <file java Hello.java> | + | <file java GroupSelector.java> |
- | public | + | public |
- | | + | /** |
- | // Teste | + | * Method used by GroupDefiner to obtains the GroupType of the Group Selection Module |
- | | + | * |
- | } | + | * @return The GroupType of the Group Selection Module |
+ | */ | ||
+ | | ||
+ | |||
+ | | ||
+ | * Processes the Mobile Node´s group membership using the Context Update (CxtU) message | ||
+ | * | ||
+ | * @param nodeMessage Context Update (CxtU) message produced by Mobile Node | ||
+ | * @return A set that holds the Mobile Node´s group membership | ||
+ | */ | ||
+ | public Set< | ||
} | } | ||
</ | </ | ||
- | * '' | + | O ID de um grupo é uma chave composta que possui um inteiro representando o tipo do grupo e outro inteiro que representa o grupo. Desta forma é possível criar tipos diferentes de grupos. |
- | * '' | + | * '' |
+ | * '' | ||
+ | |||
+ | Há ainda a opção de um GroupSelector que possui, além dos métodos acima, o conceito de grupos proibidos. Um grupo proibido pode ser mapeado, por exemplo, como áreas que o MN não deve entrar. O GroupSelector com suporte a grupos proibidos é mostrado abaixo. | ||
+ | |||
+ | <file java GroupSelector.java> | ||
+ | public interface GroupSelectorSupportingProhibitedGroups extends GroupSelector { | ||
+ | |||
+ | /** | ||
+ | * Processes the Mobile Node´s prohibited group membership using the Context Update (CxtU) message | ||
+ | | ||
+ | * @param nodeMessage Context Update (CxtU) message produced by Mobile Node | ||
+ | * @return A set that holds the Mobile Node´s group membership | ||
+ | */ | ||
+ | public Set< | ||
+ | |||
+ | /** | ||
+ | * Tests if a group is a prohibited group | ||
+ | | ||
+ | * @param groupId | ||
+ | * @return Return if a group is a prohibited group or not | ||
+ | */ | ||
+ | public boolean isProhibitedGroup(int groupId); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Implementado o GroupSelector, | ||
+ | |||
+ | <file java GroupDefinerMock.java> | ||
+ | public class GroupDefinerMock { | ||
+ | |||
+ | /** | ||
+ | * @param args | ||
+ | */ | ||
+ | public static void main(final String[] args) { | ||
+ | new GroupDefiner(new GroupSelectorMock()); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | A classe GroupSelectorMock é como segue: | ||
+ | |||
+ | <file java GroupSelectorMock.java> | ||
+ | public class GroupSelectorMock implements GroupSelector { | ||
+ | |||
+ | @Override | ||
+ | public int getGroupType() { | ||
+ | return 10; | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public Set< | ||
+ | System.out.println(nodeMessage.toString()); | ||
+ | |||
+ | return new TreeSet< | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
===== Architecture ===== | ===== Architecture ===== | ||
The GroupDefiner internally consists of a generic message processing part, and an application-specific part, the //Group selection module//. The generic part is responsible for reading any application message disseminated in the DDS domain, recording the current groups associated with the message and handing the message' | The GroupDefiner internally consists of a generic message processing part, and an application-specific part, the //Group selection module//. The generic part is responsible for reading any application message disseminated in the DDS domain, recording the current groups associated with the message and handing the message' |