Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: alext on February 12, 2009, 12:45:25 am

Title: Accessing the running instance of EA from Java
Post by: alext on February 12, 2009, 12:45:25 am
Does someone know what the Java equivalent is for the follwing code:

using System.Runtime.InteropServices;
...
object obj = Marshal.GetActiveObject("EA.App");
EA.App app = obj as EA.App;
EA.Repository rep = app.Repository;

This is supposed to get a reference to the running instance of EA.

Thanks! :exclamation
Title: Re: Accessing the running instance of EA from Java
Post by: Oliver F. on February 12, 2009, 02:31:12 am
From a quick glance at my code:

Code: [Select]

org.sparx.EARepository eaRepository = new org.sparx.Repository();
if (eaRepository == null)
            {
                //error handling here...
                return false;
            }

        if (!eaRepository.OpenFile(CONNECTION))
        {
             //error handling here...
            return false;
        }

Note that this will not give you access to a running instance but opens a new instance (defined in the connection string). AFAIK there is no way to access the running instance from JAVA via the DCOM bridge.

Oliver
Title: Re: Accessing the running instance of EA from Java
Post by: alext on February 12, 2009, 03:25:40 am
Thanks for your reply Oliver, but this seems to throw me an error when I do a Repository.GetModels().
I get an "Internal application error".
If I open a Repository through openFile...I have no Issues (not always at least), but I would like to get the Models for the open instance of EA.

My plan is to open a network repository and then use it as if it where sitting on my local machine...for this I need a current running EA instance
reference.

Thanks!
Title: Re: Accessing the running instance of EA from Java
Post by: Oliver F. on February 12, 2009, 03:56:36 am
Quote
If I open a Repository through openFile...I have no Issues (not always at least), but I would like to get the Models for the open instance of EA.

As I said above- afaik you can not access an already open instance from the JAVA API.
I'd be glad if someone can prove me wrong here as I need that functionality, too.

Oliver
Title: Re: Accessing the running instance of EA from Java
Post by: Eve on February 12, 2009, 08:08:18 am
Sorry, it's not currently possible.