refactor(plugins): SPI workspace-only e remoção de menus legados
Remove GuiManager e pitiupi.models.Menus; atualiza chat/screencast, docs e testes (ConfigLoader, TcpConnectionManager). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7c8a476253
commit
42e70af48b
33 files changed
+104
-444
No files matched your search
+1
-1
@@ -16,7 +16,7 @@ Entrada na raiz do repositório: [README.md](../README.md).
|
||||
| --- | --- |
|
||||
| **Aluno (TP)** | [documentation/00_quickstart.md](documentation/00_quickstart.md) → [10_tutorial_plugin.md](documentation/10_tutorial_plugin.md) → [17_tutorial_ping_aula.md](documentation/17_tutorial_ping_aula.md) → [11_plugins_referencia.md](documentation/11_plugins_referencia.md) |
|
||||
| **Monitor / docência** | [documentation/01_visao_disciplina_e_tp.md](documentation/01_visao_disciplina_e_tp.md) → [15_testes_e_gate.md](documentation/15_testes_e_gate.md) |
|
||||
| **Desenvolvedor** | [documentation/13_guia_dev_e_agente.md](documentation/13_guia_dev_e_agente.md) → [14_arquitetura_e_manutencao.md](documentation/14_arquitetura_e_manutencao.md) |
|
||||
| **Desenvolvedor** | [documentation/13_guia_desenvolvimento.md](documentation/13_guia_desenvolvimento.md) → [14_arquitetura_e_manutencao.md](documentation/14_arquitetura_e_manutencao.md) |
|
||||
| **Professor / banca** | [documentation/16_fundamentacao_redes.md](documentation/16_fundamentacao_redes.md) → [references/README.md](references/README.md) |
|
||||
|
||||
**Idioma:** documentação em PT-BR; pacotes e classes Java como no código.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
| D7 | Plugins via JAR + Java SPI | Carregamento dinâmico sem recompilar o núcleo | [09_sistema_de_plugins.md](documentation/09_sistema_de_plugins.md) |
|
||||
| D8 | Classloader por JAR de plugin | Isolar dependências; desserialização com `PluginObjectInputStream` | [09_sistema_de_plugins.md](documentation/09_sistema_de_plugins.md) |
|
||||
| D9 | Plugins em `PITIUPI_HOME/plugins` | Dados do usuário fora do clone Git; `PITIUPI_HOME` ou `~/pitiupi` | [00_quickstart.md](documentation/00_quickstart.md) |
|
||||
| D10 | Erros com `ErrorCode` | Mensagens PT na UI; `PitiupiException` no domínio | [13_guia_dev_e_agente.md](documentation/13_guia_dev_e_agente.md) |
|
||||
| D10 | Erros com `ErrorCode` | Mensagens PT na UI; `PitiupiException` no domínio | [13_guia_desenvolvimento.md](documentation/13_guia_desenvolvimento.md) |
|
||||
| D11 | Reinício após instalar/remover JAR | Mutar `plugins/` exige reiniciar o app para recarregar SPI | [04_inicializacao_e_gui.md](documentation/04_inicializacao_e_gui.md) |
|
||||
| D16 | UI em abas; sem `JFrame` de plugin | Conteúdo na `MainShellFrame`; galeria e peer actions abrem abas | [04_inicializacao_e_gui.md](documentation/04_inicializacao_e_gui.md) |
|
||||
| D17 | Goodbye + timeout de presença | `GoodbyeMessage` em multicast ao fechar; timeout ~15 s mantido | [08_heartbeat_e_presenca.md](documentation/08_heartbeat_e_presenca.md) |
|
||||
|
||||
@@ -16,7 +16,7 @@ Cada equipe/aluno entrega um **módulo Java separado** que:
|
||||
|
||||
1. Compila para JAR e carrega via `pitiupi/plugins/`.
|
||||
2. Define mensagens (`extends Message`) e o fluxo entre peers.
|
||||
3. Integra menus/janelas via `GuiManager`.
|
||||
3. Integra UI na aba central via `PluginWorkspace` e peer actions na lista lateral.
|
||||
4. Inclui README do módulo (build + protocolo).
|
||||
|
||||
Exemplos de tema: chat temático, tabuleiro (xadrez/damas), compartilhamento de arquivo, quiz síncrono.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Sistema de plugins
|
||||
|
||||
O sistema de plugins permite extensão modular sem alterar o núcleo. O contrato
|
||||
está em `pitiupi.models.Plugin` (classe abstrata).
|
||||
O sistema de plugins permite extensão modular sem alterar o núcleo. O contrato está em `pitiupi.models.Plugin` (classe abstrata).
|
||||
|
||||
**Breaking change (pós-v1):** plugins devem implementar apenas `createPlugin(ConnectionManager, PluginWorkspace)`. A API antiga com `GuiManager` e menus por categoria foi removida.
|
||||
|
||||
## Interface Plugin
|
||||
|
||||
@@ -11,8 +12,7 @@ Métodos obrigatórios:
|
||||
| --- | --- |
|
||||
| `getName()`, `getAuthor()`, `getVersion()`, `getIdentifier()` | Identificação (o `identifier` distingue plugins em conexões TCP dedicadas) |
|
||||
| `getDisplayName()` | Texto na galeria e título de aba (padrão: `getName()`) |
|
||||
| `createPlugin(ConnectionManager, PluginWorkspace)` | Inicialização na shell: painel na aba, peer actions, rede |
|
||||
| `createPlugin(ConnectionManager, GuiManager)` | Legado — adapter na carga; não usar em plugins novos |
|
||||
| `createPlugin(ConnectionManager, PluginWorkspace)` | Inicialização: `bindShellWorkspaceContent`, `installPeerActions`, rede |
|
||||
| `getMessages()` | Lista de classes `Message` que o plugin desserializa |
|
||||
| `receiveMessage(Message)` | Processamento após o `PluginManager` identificar o tipo |
|
||||
|
||||
|
||||
@@ -12,9 +12,24 @@ Este guia complementa [09_sistema_de_plugins.md](09_sistema_de_plugins.md). Use
|
||||
|
||||
```java
|
||||
public class MeuPlugin extends Plugin {
|
||||
private PluginWorkspace workspace;
|
||||
|
||||
@Override
|
||||
public void createPlugin(ConnectionManager cm, GuiManager gui) {
|
||||
// registrar menus, abrir janelas
|
||||
public void createPlugin(ConnectionManager cm, PluginWorkspace workspace) {
|
||||
this.workspace = workspace;
|
||||
MeuPanel panel = new MeuPanel(cm);
|
||||
bindShellWorkspaceContent(panel);
|
||||
installPeerActions(workspace.peerActions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installPeerActions(PeerActionsRegistrar registrar) {
|
||||
registrar.register(PeerAction.of(
|
||||
"meuplugin.abrir",
|
||||
"Abrir",
|
||||
PeerActionTarget.ALL_PEERS,
|
||||
target -> workspace.openOrFocusTab(getIdentifier(), getDisplayName())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,25 +64,9 @@ Arquivo `src/META-INF/services/pitiupi.models.Plugin`:
|
||||
pacote.MeuPlugin
|
||||
```
|
||||
|
||||
## 5. Categoria no menu
|
||||
## 5. Registrar no catálogo
|
||||
|
||||
Escolha onde o plugin aparece na barra **Plugin**:
|
||||
|
||||
| `MenuCategory` | Uso |
|
||||
| --- | --- |
|
||||
| `Social` | Chat, presença |
|
||||
| `Jogos` | Jogos entre peers |
|
||||
| `Streaming` | Screen cast, mídia |
|
||||
|
||||
Exemplo:
|
||||
|
||||
```java
|
||||
guiManager.createMenu(MenuCategory.Jogos, new MeuMenu(...));
|
||||
```
|
||||
|
||||
## 6. Registrar no catálogo
|
||||
|
||||
Adicione uma entrada em [`plugins.registry.json`](../../plugins.registry.json) na raiz do repo:
|
||||
Adicione uma entrada em [`plugins.registry.json`](../../plugins.registry.json):
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -81,29 +80,15 @@ Adicione uma entrada em [`plugins.registry.json`](../../plugins.registry.json) n
|
||||
|
||||
O `id` é o que você passa para `./scripts/pitiupi.sh run --plugins xadrez`.
|
||||
|
||||
## 7. Build e instalação
|
||||
## 6. Build e instalação
|
||||
|
||||
```bash
|
||||
./scripts/pitiupi.sh build --plugins xadrez
|
||||
# ou, manualmente:
|
||||
cd pitiupi.xadrez && ant jar
|
||||
ln -sf ../../pitiupi.xadrez/dist/pitiupi.xadrez.jar ../pitiupi/plugins/xadrez.jar
|
||||
```
|
||||
|
||||
Reinicie o Pitiupi após trocar JARs.
|
||||
JARs de runtime ficam em `PITIUPI_HOME/plugins` (ver [00_quickstart.md](00_quickstart.md)).
|
||||
|
||||
## 8. Teste
|
||||
## 7. Próximos passos
|
||||
|
||||
Duas instâncias, mesma rede, portas distintas se no mesmo host. Ver [00_quickstart.md](00_quickstart.md).
|
||||
|
||||
## TCP dedicado (avançado)
|
||||
|
||||
Se o plugin precisa de canal TCP com handshake por `getIdentifier()`, estude `plugins/chat` (`receivePrivateConnection`, `receiveBytes`). Use `MessageDispatcher` para envios didáticos. Ver [11_plugins_referencia.md](11_plugins_referencia.md).
|
||||
|
||||
## Erros frequentes
|
||||
|
||||
| Problema | Causa provável |
|
||||
| --- | --- |
|
||||
| Plugin não aparece | SPI ausente ou JAR fora de `plugins/` |
|
||||
| `ClassNotFoundException` na recepção | Classe da mensagem não no JAR do remetente/destino |
|
||||
| Peers não se veem | Multicast bloqueado — [appendix_portas_e_multicast.md](appendix_portas_e_multicast.md) |
|
||||
- [11_plugins_referencia.md](11_plugins_referencia.md) — chat e screenCast
|
||||
- [17_tutorial_ping_aula.md](17_tutorial_ping_aula.md) — plugin didático Ping (opcional, fora do commit)
|
||||
@@ -1,34 +1,15 @@
|
||||
# Menus, peer actions e transportes
|
||||
# Menus e ações na lista (histórico)
|
||||
|
||||
## Interface atual (shell v1)
|
||||
Na v1 atual, plugins **não** registram menus na barra superior nem submenus legados por categoria.
|
||||
|
||||
Plugins de referência **não** dependem da barra de menus superior para o fluxo principal:
|
||||
## Como expor ações hoje
|
||||
|
||||
- **Galeria** na aba **Plugins** abre cada extensão em aba própria (fechável com ×).
|
||||
- **Peer actions** na lista **Usuários nesta rede** (clique em um peer ou em **Todos**) agrupam ações de todos os plugins instalados.
|
||||
- Dentro da aba do plugin, **`PluginRoutingPanel`** padroniza destino (sala geral vs IP), forma de envio (multicast UDP, UDP unicast, TCP) e texto de ajuda.
|
||||
1. **Galeria Plugins** — abre a aba central do plugin.
|
||||
2. **Lista lateral** — clique em um peer ou em **Todos** → menu com **peer actions** registradas por cada plugin (`PeerActionBroker`).
|
||||
3. **`PluginWorkspace.openOrFocusTab`** — dentro do handler da peer action ou após carregar o painel.
|
||||
|
||||
Ver [04_inicializacao_e_gui.md](04_inicializacao_e_gui.md) e [09_sistema_de_plugins.md](09_sistema_de_plugins.md).
|
||||
## Catálogo `menuCategory`
|
||||
|
||||
## MenuCategory (legado)
|
||||
O campo `menuCategory` em [`plugins.registry.json`](../../plugins.registry.json) (`Social`, `Jogos`, `Streaming`) serve apenas ao script `./scripts/pitiupi.sh` para filtrar build/run — não cria menus Swing.
|
||||
|
||||
Enum em `pitiupi.models.Menus.MenuCategory` (`Jogos`, `Social`, `Streaming`) ainda aparece no **catálogo** (`menuCategory` em `plugins.registry.json`) e em plugins antigos que chamam `GuiManager.createMenu(...)`.
|
||||
|
||||
Novos plugins devem preferir `PluginWorkspace` + peer actions. O menu da shell expõe apenas **Ajuda → Sobre**.
|
||||
|
||||
## Unicast vs multicast na aplicação
|
||||
|
||||
| Modo | API típica | Semântica |
|
||||
| --- | --- | --- |
|
||||
| Multicast | `MessageDispatcher` / `SocketUDP.sendMulticast` | Todos no grupo na porta configurada |
|
||||
| Unicast UDP | envio para IP de um peer | Um destinatário, sem estabelecer TCP |
|
||||
| TCP | `ConnectionManager` / `SocketTCP` | Canal com framing 4+N bytes |
|
||||
|
||||
Detalhes de rede: [05_udp_multicast.md](05_udp_multicast.md), [06_tcp_conexoes.md](06_tcp_conexoes.md).
|
||||
|
||||
## Referência de código
|
||||
|
||||
- Chat e screencast: peer actions em `ChatPlugin` e `ScreenCastPlugin`.
|
||||
- Envio unificado: `pitiupi.application.messaging.MessageDispatcher` e `TransportMode`.
|
||||
|
||||
O antigo plugin **mpChat** foi unificado no módulo `plugins/chat` (mensagens `LegacyMpChatMessage` para compatibilidade TCP privado). Ver [11_plugins_referencia.md](11_plugins_referencia.md) e decisão D19 no [decision-register.md](../decision-register.md).
|
||||
Referência de plugins: [11_plugins_referencia.md](11_plugins_referencia.md).
|
||||
+5
-7
@@ -1,6 +1,6 @@
|
||||
# Guia para desenvolvedor e agente
|
||||
# Guia para desenvolvimento
|
||||
|
||||
Esta documentação descreve **apenas** a ferramenta Pitiupi neste repositório: build, rede, plugins e convenções de código. Quem clona o projeto não precisa de pastas ou ferramentas de meta-desenvolvimento externas; mantenha referências técnicas e tutoriais limitados ao que está em `docs/` e no código do próprio repo.
|
||||
Esta documentação descreve a ferramenta Pitiupi neste repositório: build, rede, plugins e convenções de código.
|
||||
|
||||
## Leitura mínima antes de mudar código
|
||||
|
||||
@@ -21,23 +21,21 @@ Esta documentação descreve **apenas** a ferramenta Pitiupi neste repositório:
|
||||
|
||||
## Gate de build
|
||||
|
||||
Compilar núcleo e os dois plugins do catálogo:
|
||||
|
||||
```bash
|
||||
cd pitiupi && ant jar && ant test
|
||||
cd plugins/chat && ant jar
|
||||
cd plugins/screencast && ant jar
|
||||
```
|
||||
|
||||
Ou na raiz do clone: `./scripts/pitiupi.sh build --all`.
|
||||
Ou na raiz: `./scripts/pitiupi.sh build --all`.
|
||||
|
||||
Requer JDK e Ant no PATH. Teste manual em rede: [15_testes_e_gate.md](15_testes_e_gate.md).
|
||||
Testes manuais em rede: [15_testes_e_gate.md](15_testes_e_gate.md).
|
||||
|
||||
## Convenções
|
||||
|
||||
- Código e identificadores em inglês (pacotes `pitiupi.*`).
|
||||
- Documentação em português (BR) em `docs/`.
|
||||
- Evitar alterar o núcleo para necessidades de um único plugin — preferir extensão via `Plugin`.
|
||||
- Evitar alterar o núcleo para um único plugin — preferir extensão via `Plugin` e `PluginWorkspace`.
|
||||
|
||||
## Decisões e débitos
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
| Usuários online, peer actions | `pitiupi.presentation.shell.NetworkUsersPanel`, `PeerActionBroker` |
|
||||
| Facade rede para plugins | `pitiupi.control.ConnectionManager` |
|
||||
| Workspace na aba (SPI) | `pitiupi.api.plugin.PluginWorkspace`, `ShellPluginWorkspace` |
|
||||
| Menus legados (adapter) | `pitiupi.control.GuiManager` — deprecado; preferir peer actions |
|
||||
| UDP | `pitiupi.net.udp.SocketUDP` |
|
||||
| TCP servidor e mapa de conexões | `pitiupi.net.tcp.SocketTCP`, `TcpConnectionManager` |
|
||||
| Conexão TCP por peer | `pitiupi.net.tcp.TcpConnection` |
|
||||
@@ -18,8 +17,6 @@
|
||||
| Heartbeat | `pitiupi.control.HeartbeatManager`, `HeartbeatMessage` |
|
||||
| Carregar JARs, despacho | `pitiupi.control.plugins.PluginManager` |
|
||||
| Contrato plugin | `pitiupi.models.Plugin`, `pitiupi.models.Messages.Message` |
|
||||
| Menus por categoria | `pitiupi.models.Menus.*` |
|
||||
|
||||
## Dependências entre módulos
|
||||
|
||||
```
|
||||
|
||||
@@ -10,6 +10,8 @@ cd pitiupi && ant test
|
||||
|
||||
Falha se `java`, `javac` ou Ant estiverem ausentes.
|
||||
|
||||
Pacotes com testes automatizados (JUnit 5): `platform` (`PitiupiHome`, `ConfigLoader`), `plugins.store`, `application.presence`, `application.peeractions`, `application.invites`, `application.messaging`, `application.activity`, `presentation.shell`, `control` (goodbye), `net.tcp` (fechamento de conexões), `models`.
|
||||
|
||||
## Gate de build (produto)
|
||||
|
||||
Na raiz do clone:
|
||||
|
||||
@@ -20,7 +20,7 @@ Referência para **código Java**, **rede P2P** e **plugins**. Índice geral: [d
|
||||
| 11 | [11_plugins_referencia.md](11_plugins_referencia.md) | chat e screencast |
|
||||
| 17 | [17_tutorial_ping_aula.md](17_tutorial_ping_aula.md) | Exercício Ping (aula) |
|
||||
| 12 | [12_menus_unicast_multicast.md](12_menus_unicast_multicast.md) | MenuCategory e ações |
|
||||
| 13 | [13_guia_dev_e_agente.md](13_guia_dev_e_agente.md) | Leitura para dev/agente |
|
||||
| 13 | [13_guia_desenvolvimento.md](13_guia_desenvolvimento.md) | Guia de desenvolvimento |
|
||||
| 14 | [14_arquitetura_e_manutencao.md](14_arquitetura_e_manutencao.md) | Onde editar cada comportamento |
|
||||
| 15 | [15_testes_e_gate.md](15_testes_e_gate.md) | Build gate e testes manuais |
|
||||
| 16 | [16_fundamentacao_redes.md](16_fundamentacao_redes.md) | Teoria ↔ código |
|
||||
|
||||
Reference in new issue
Block a user