Post on 19-Apr-2015
1
16 a 18 de Junho – Anhembi – SP/SP
MIDP 3.0: O Futuro do Java ME
Marlon Luz e Luiz AnjosPor
2
AGENDA• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
3
Introdução• MIDP 1.0 Setembro – 2000
• MIDP 2.0 Novembro – 2002
• MIDP 3.0 ?
4
Introdução
• Formação Inicial – Março 2005
• Final Approval Ballot – Maio 2006
• 61 Empresas
• 10 Contribuidores individuais
5
Introdução
• RequisitosMIDP 1.0
2000MIDP 2.0
2002MIDP 2.1
2007MIDP 3.0
2008
Memória Volátil 32 Kb 128 Kb 128 Kb 1024 Kb
Tamanho de Tela 96x54 96x54 96x54 176x220
Configurações CLDC 1.0CLDC 1.0CLDC 1.1CDC 1.0
CLDC 1.1CDC 1.0
CLDC 1.1CLDC 1.1.1
CDC 1.1
6
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
7
Interface de Usuário
• Command
• Display
• File Selector
• Menu
• Notificações
• Tabbed Pane
Interface de Usuário
• Command– Localização exata– Habilitado/Desabilitado– Suporte à imagens– Mutável
9
Interface de Usuário• Display
– Display secundário
– Display.getDisplays(…)
– Características para um display secundário (SUPPORTS_COMMANDS, INPUT_EVENTS, FORMS, TICKER, TITLE, ALERTS, LISTS, TEXTBOXES, FILESELECTORS, TABBEDPANES)
10
Interface de Usuário
• Display– Estado sobre o hardware (ENABLED,
DISABLED, ABSENT)– Estado sobre o display (foreground,
background, visible)– Suporte a orientação paisagem
11
Interface de Usuário
• File Selector– Objetos Command default (OK, CANCEL)– Não permite novos Commands– Modos LOAD, SAVE e DIRECTORY– getDirectory(), getFile(),
setFilterExtensions(String extensions)
12
Interface de Usuário
• Menu
13
Interface de Usuário
• Menu– Container visual para objetos Command– Usado com a localização exata de um
Command– Choice.IMPLICIT– Pode conter sub-menus– CommandListener do objeto Displayable
14
Interface de Usuário• MenuMenu m, sm1, sm2;
Command cmd1, cmd2, cmd3;
m = new Menu(“Top Menu", "", menupict.gif);
sm1 = new Menu("Submenu 1", “", menupict.gif);
sm2 = new Menu("Submenu 2", “", menupict.gif);
cmd1 = new Command(“First",”", Command.ITEM, 1);
cmd2 = new Command(“Second",””, Command.ITEM, 1);
cmd3 = new Command("Third",”", Command.ITEM, 1);
m.append(cmd1);
m.append(sm1);
sm1.append(cmd2);
sm1.append(sm2);
sm2.append(cmd3);
15
Interface de Usuário
• Notificações– NotificationManager / Notification– MIDlet não controla UI– Dependente da implementação– post() para registrar notificações
16
Interface de Usuário
• Notificações
Notification n=NotificationManager.createNotification(nl);
n.setLabel("Mensagem não lida (1)");
n.setIcon("resources/mail1.jpg");
n.post();
17
Interface de Usuário
• Tabbed Pane– Objetos Screen separados por abas– List e Form– Objetos Command (Tab e seu conteúdo)
18
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
19
Categoria de MIDlets
• Screen Saver
• Auto Start
• Idle Screen
20
Categoria de MIDlets
• Screen Saver– Aplicação executada automaticamente– Device no estado de “Idle”– Identificação baseado em atributo
• MIDlet-Category-n: ScreenSaver– Ativação e desativação baseados em eventos– Usuário ciente do processo de atualização
21
Categoria de MIDlets
• Auto Start– “Power up” do device– Identificação baseada em atributo / permissão
• MIDlet-Category-n: autostart– Tentativa para reiniciar o MIDlet (AMS)– javax.microedition.midlet.AutoStartPermission
22
Categoria de MIDlets• Idle Screen
– Adiciona conteúdo para a tela de “Idle”
23
Categoria de MIDlets• Idle Screen
– Identificação baseada em atributo
• MIDlet-Category-n: IdleScreen
– IdleItem como elemento de UI
– IdleItem, subclasse de CustomItem
– Display.setIdleItem(idleItem)
24
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
25
Biblioteca Compartilhada
• LIBlet
26
Biblioteca Compartilhada
• LIBlet– Componente de Sofware– Não possui um contexto próprio– Atributos definidos nos arquivos JAD e JAR– Empacotado em um arquivo JAR– Dependências via atributo Dependency-<n>
27
Biblioteca Compartilhada
• LIBlet– Dependência circular
28
Biblioteca Compartilhada
• LIBlet
IMS MIDlet
Poc LIBlet JSR 281
29
Biblioteca Compartilhada• MIDlet
IMSMIDlet JADMIDlet-1: IMSMIDlet, icon.png, IMSMIDletMIDlet-Name: IP Multimedia AppMIDlet-Version: 1.0MIDlet-Vendor: Multi SysMIDlet-Jar-Size: 12123Dependency-1: microedition.ims; JCP; 1.0+; standardDependency-2: PocLib; Poc Sys, Inc.; 1.1.2; libletLIBlet-Dependency-JAD-URL-2:
http://www.pocsys.com/liblets/poclib.jadLIBlet-Dependency-Jar-SHA1-2:
501A202E919B9C98343FAD6F46842412F7A0A783
30
Biblioteca Compartilhada
• LIBlet
PocLib JAD
LIBlet-Name: PocLib
LIBlet-Version: 1.1.2
LIBlet-Vendor: Poc Sys, Inc.
LIBlet-Jar-Size: 12123
LIBlet-Jar-URL: http://www.pocsys.com/liblets/poclib.jar
31
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
32
Comunicação Inter-MIDlet
• Protocolo IMC– Conexão assíncrona– Cliente e Servidor– MIDlet UID (nome + vendedor + versão)– IMCConnection / IMCServerConnection– Permite Push Registry
33
Comunicação Inter-MIDlet
IMCConnection conn = (IMCConnection)Connector.open("imc:// *:com.foo.services.barServer:1.0;authmode=false");
try {DataOutputStream request = conn.openDataOutputStream();// escreve dados...request.flush();DataInputStream response = conn.openDataInputStream();// recupera dados...
} finally {conn.close();
}
34
Comunicação Inter-MIDletIMCServerConnection serverConn = (IMCServerConnection)Connector.open(
"imc://:com.foo.barServer:1.0;authmode=false;);while(true) {
IMCConnection conn = (IMCConnection) serverConn.acceptAndOpen();try {
String requestedVersion = conn.getRequestedServerVersion();DataInputStream requestData = conn.openDataInputStream();DataOutputStream responseData = conn.openDataOutputStream();// faz a leitura de dados a partir da inpustreamint requestType = requestData.readInt();...// trata a requisição...// escreve a resposta para output streamresponseData.writeUTF(“Olá, eu sou barServer");responseData.close();
} finally {conn.close();
}}
35
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
36
MIDlets Concorrentes
• Características– Implementação DEVE suportar que aplicações
executem simultaneamente– Dados estáticos não são compartilhados– Manipulação de erros– 1 MIDlet, 1 instância
37
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
38
Eventos
• Características– Mudanças no estado do sistema– Comunicação Aplicação x Aplicação– EventManager, EventData, EventPermission,
EventDataListener
39
Eventos• Características
– AUDIO_OUTPUT, BATTERY_CHARGING, BATTERY_LEVEL, BODY_OPEN, IDLE_SCREEN_MODE, SCREENSAVER_MODE, SYSTEM_STATE,VOICE_CALL
– Aplicações executadas automaticamente (1 instância)
– Registro estático / dinâmico para aplicações
40
Eventos
• Consultando um evento de sistemaEventManager ssm = EventManager.getInstance(this);
EventData battery = null;
try {
battery = ssm.getCurrent(BATTERY_LEVEL);
} catch (SecurityException e) {
..
}
int batteryLevel = battery.getInt();
41
Eventos
• Adicionando um EventListener
EventData battery;
boolean authmode = false;
EventManager ssm = EventManager.getInstance(this);
ssm.addEventListener(BATTERY_LEVEL, this, authmode, 10, 20);
42
Eventos• Manipulando um evento
handleEvent(EventData event) {String eventName = event.getName();int batteryLevel;
if (eventName.equals(BATTERY_LEVEL)) {batteryLevel = event.getInt();
}}
43
Eventos• Registro estático (App)
MIDlet-Name: PowerManagementMIDlet-Version: 1.0.1MIDlet-Vendor: FictionalCoMIDlet-1: PowerManager, /pwrmgt.png, com.fictionalco.PowerMgrMIDlet-Event-Launch-1: com.fictionalco.PowerMgr;authmode=false;
BATTERY_LEVEL=5,100MicroEdition-Profile: MIDP-3.0MicroEdition-Configuration: CLDC-1.1MIDlet-Jar-URL: http://www.fictionalco.com/SysUtils.jar
44
Eventos• Registro dinâmico (App)
EventData battery;boolean authmode = false;EventManager ssm = EventManager.getInstance(this);try {
ssm.registerApplication(BATTERY_LEVEL, "com.fictionalco.PowerMgr",
authmode, 0, 10);} catch (SecurityException e) {..}
45
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
46
Persistência• RMS
– Segurança• Algorítimo: AES 128-bit
– RMS Provisioning• Arquivos standalone / JAR da aplicação (MIDlet - LIBlet)• Persistent-Data-URL-1: data.rms overwrite encryptLocally• Persistent-Data-URL-2:
http://vendor.com/gamedata/coolgame.rms– Importação e Exportação– Tags
47
AGENDA
• Introdução
• Interface de Usuário
• Categoria de MIDlets
• Biblioteca Compartilhada
• Comunicação Inter-MIDlet
• MIDlets Concorrentes
• Eventos
• Persistência
48
Outras Mudanças• Interface de usuário
– Imagens Animadas– Splash Screen– Table Layout– TextInput– Font (TrueType)
• Segurança– Autorização de acesso em nível de aplicação
• Network– IPV6– Binding para adaptador de rede em nível de app– PUT e DELETE
49
MIDP 3.0:
O futuro do Java ME
Luiz Anjos – anjos.luiz@gmail.com
Marlon Luz – marlon.luz@lightmobile.com.br