Aug 7, 2008 1:40 PM
Lost Beginner - Exposing Java Objects to COM
Hi There,
I'm very new to all things COM and comfyj, so please bear with me.
I've read the documentation and posts on this forum, but I think I am lacking some basic knowledge which I hope you will be able to kindly help me with.
For example, I have two classes in Java: Manager.class and Player.class defined simply as:
What is the correct way to expose both those classes so that they could be accessed through the com interface?
I know that I can return Strings as com.jniwrapper.win32.automation.types.BStr, how about Vector,int, boolean, etc...?
If I define a ManagerComServer, is it possible to have access to my Player class through the COM interface also?
I would like to mimic something like:
Thank you for any help or pointers to help,
Best regards,
Fabricio.
I'm very new to all things COM and comfyj, so please bear with me.
I've read the documentation and posts on this forum, but I think I am lacking some basic knowledge which I hope you will be able to kindly help me with.
For example, I have two classes in Java: Manager.class and Player.class defined simply as:
public class Player {
protected String name;
protected int age;
protected boolean injured;
public Player( String name, int age, boolean injured ) {
this.name = name;
this.age = age;
this.injured = injured;
}
public String getName() { return name; }
public void setName(String n) { this.name = n; }
public boolean isInjured() { return injured; }
public void setInjured(boolean b) { this.injured = b; }
public int getAge() { return age; }
public void setAge(int age) { this.age - age; }
}
public class Manager {
protected Vector<Player> players = new Vector<Player>();
protected String managerName = "John";
protected boolean active = true;
protected int age = 30;
public Manager() {
players.add( new Player("Player 1", 30, false) );
players.add( new Player("Player 2", 30, true) );
}
public Vector<Player> getPlayers() { return players; }
public String getManagerName() { return managerName; }
public void setManagerName(String n) { this.managerName = n; }
public boolean isActive() { return active; }
public void setActive(boolean b) { this.active = b; }
public int getAge() { return age; }
public void setAge(int age) { this.age - age; }
}
What is the correct way to expose both those classes so that they could be accessed through the com interface?
I know that I can return Strings as com.jniwrapper.win32.automation.types.BStr, how about Vector,int, boolean, etc...?
If I define a ManagerComServer, is it possible to have access to my Player class through the COM interface also?
I would like to mimic something like:
Manager manager = new Manager();
String mName = manager.getManagerName();
Player player = manager.getPlayers().get(0);
String pName = player.getName();
int pAge = player.getAge();
player.setInjured(false);
boolean pInjured = player.isInjured();
Thank you for any help or pointers to help,
Best regards,
Fabricio.