Thread: [Ikvm-developers] Am I doing this right
Brought to you by:
jfrijters
|
From: Graham O. <gra...@on...> - 2013-06-18 20:04:10
|
Hi Team
I have written a program using the Cisco API for the Call Manager phone
system. The API comes as a jtapi.jar
I have converted the jtapi.jar to a jtapi.dll and my program works
great.
The problem I have is that there are lots of versions of Call Manager
and you have to use the matching jtapi.jar file, so I was looking into
loading the jtapi.jar at run time then I can just load whatever version
is installed.
These are from VS2010 so using the dll I have this
try
{
CiscoJtapiVersion jv = new CiscoJtapiVersion();
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
And loading at Run Time I have this:
// Create a URL instance for every jar file that you need
java.net.URL url = new
java.net.URL("file:C:\\Windows\\Java\\lib\\jtapi.jar");
// Create an array of all URLS
java.net.URL[] urls = { url };
// Create a ClassLoader
java.net.URLClassLoader loader = new java.net.URLClassLoader(urls);
try
{
// load the Class
java.lang.Class cl = java.lang.Class.forName("CiscoJtapiVersion",
true, loader);
// Create a Object via Java reflection
Type type = ikvm.runtime.Util.getInstanceTypeFromClass(cl);
dynamic jv = type.GetConstructor(new Type[] { }).Invoke(null);
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
My question is:
Am I going about this the right way?
I assume I need to define all my objects as dynamic as there is no way
of getting a static reference
Defining the objects as dynamic makes it a bit unforgiving of any typo's
etc.
Thanks
Graham Old
Software Integration
ddi 01582 420950 (single number reach)
ONI Plc is a Cisco GOLD Certified Partner specialising in:
Advanced Unified Communications
Advanced Wireless LAN
Advanced Routing & Switching
Advanced Security
Registered in England No. 2698057'
CONFIDENTIALITY
This e-mail, its content and any files transmitted with it are intended
solely for the addressee(s) and are confidential and may be legally
privileged. If you are not the intended recipient, any use, disclosure
or copying of this document is unauthorised. If you have received this
document in error please immediately notify the sender on +44 1582
429999 and delete this email from your computer. Thank you
|
|
From: Jeroen F. <je...@su...> - 2013-06-19 05:33:18
|
Hi Graham,
This is the right approach in general, but in specific cases there may be improvements possible if the dynamic parts implements a statically known interface.
I don't know much about jtapi.jar, but in a jtapi.jar I have there is a javax.telephony package. It might be possible to write your code (mostly) in terms of this interface and then statically compile a dll that contains just the javax.telephony classes. If you then use the assembly class loader of this assembly as the parent of your URLClassLoader that loads jtapi.jar, the statically compiled javax.telephony classes will be used.
Regards,
Jeroen
From: Graham Old [mailto:gra...@on...]
Sent: Tuesday, June 18, 2013 21:52
To: ikv...@li...
Subject: [Ikvm-developers] Am I doing this right
Hi Team
I have written a program using the Cisco API for the Call Manager phone system. The API comes as a jtapi.jar
I have converted the jtapi.jar to a jtapi.dll and my program works great.
The problem I have is that there are lots of versions of Call Manager and you have to use the matching jtapi.jar file, so I was looking into loading the jtapi.jar at run time then I can just load whatever version is installed.
These are from VS2010 so using the dll I have this
try
{
CiscoJtapiVersion jv = new CiscoJtapiVersion();
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
And loading at Run Time I have this:
// Create a URL instance for every jar file that you need
java.net.URL url = new java.net.URL("file:C:\\Windows\\Java\\lib\\jtapi.jar");
// Create an array of all URLS
java.net.URL[] urls = { url };
// Create a ClassLoader
java.net.URLClassLoader loader = new java.net.URLClassLoader(urls);
try
{
// load the Class
java.lang.Class cl = java.lang.Class.forName("CiscoJtapiVersion", true, loader);
// Create a Object via Java reflection
Type type = ikvm.runtime.Util.getInstanceTypeFromClass(cl);
dynamic jv = type.GetConstructor(new Type[] { }).Invoke(null);
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
My question is:
Am I going about this the right way?
I assume I need to define all my objects as dynamic as there is no way of getting a static reference
Defining the objects as dynamic makes it a bit unforgiving of any typo's etc.
Thanks
Graham Old
Software Integration
ddi 01582 420950 (single number reach)
ONI Plc is a Cisco GOLD Certified Partner specialising in:
Advanced Unified Communications
Advanced Wireless LAN
Advanced Routing & Switching
Advanced Security
Registered in England No. 2698057'
CONFIDENTIALITY
This e-mail, its content and any files transmitted with it are intended solely for the addressee(s) and are confidential and may be legally privileged. If you are not the intended recipient, any use, disclosure or copying of this document is unauthorised. If you have received this document in error please immediately notify the sender on +44 1582 429999 and delete this email from your computer. Thank you
|
|
From: Graham O. <gra...@on...> - 2013-06-19 11:27:49
|
Hi Jeroen
I suspect the jtapi.jar you have is the one I sent you when it would not
convert into a dll.
You are correct that this is all based on the Java TAPI interface but
Cisco have extended a lot of the calls. One of the problems is knowing
when you should use a standard Java call or one of Cisco's extended
calls.
I think that trying to convert everything to a dynamic object is going
to be very difficult to program and nearly impossible to maintain. This
is monitoring phones and is very much about events whenever a phone
changes state.
I was thinking that I could try to exec ikvmc at the program start and
have it convert whatever jatpi.jar is installed into the correct
jtapi.dll for my program. This runs as a windows service so start up
time is not important.
Has anyone tried this approach?
Regards
Graham
From: Jeroen Frijters [mailto:je...@su...]
Sent: 19 June 2013 06:33
To: Graham Old; ikv...@li...
Subject: RE: Am I doing this right
Hi Graham,
This is the right approach in general, but in specific cases there may
be improvements possible if the dynamic parts implements a statically
known interface.
I don't know much about jtapi.jar, but in a jtapi.jar I have there is a
javax.telephony package. It might be possible to write your code
(mostly) in terms of this interface and then statically compile a dll
that contains just the javax.telephony classes. If you then use the
assembly class loader of this assembly as the parent of your
URLClassLoader that loads jtapi.jar, the statically compiled
javax.telephony classes will be used.
Regards,
Jeroen
From: Graham Old [mailto:gra...@on...]
Sent: Tuesday, June 18, 2013 21:52
To: ikv...@li...
Subject: [Ikvm-developers] Am I doing this right
Hi Team
I have written a program using the Cisco API for the Call Manager phone
system. The API comes as a jtapi.jar
I have converted the jtapi.jar to a jtapi.dll and my program works
great.
The problem I have is that there are lots of versions of Call Manager
and you have to use the matching jtapi.jar file, so I was looking into
loading the jtapi.jar at run time then I can just load whatever version
is installed.
These are from VS2010 so using the dll I have this
try
{
CiscoJtapiVersion jv = new CiscoJtapiVersion();
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
And loading at Run Time I have this:
// Create a URL instance for every jar file that you need
java.net.URL url = new
java.net.URL("file:C:\\Windows\\Java\\lib\\jtapi.jar");
// Create an array of all URLS
java.net.URL[] urls = { url };
// Create a ClassLoader
java.net.URLClassLoader loader = new java.net.URLClassLoader(urls);
try
{
// load the Class
java.lang.Class cl = java.lang.Class.forName("CiscoJtapiVersion",
true, loader);
// Create a Object via Java reflection
Type type = ikvm.runtime.Util.getInstanceTypeFromClass(cl);
dynamic jv = type.GetConstructor(new Type[] { }).Invoke(null);
label1.Text = jv.getVersionName();
label2.Text = jv.getVersion();
label3.Text = jv.getMinorVersion().ToString();
label4.Text = jv.getMajorVersion().ToString();
}
catch (Exception ex)
{
label4.Text = ex.Message;
}
My question is:
Am I going about this the right way?
I assume I need to define all my objects as dynamic as there is no way
of getting a static reference
Defining the objects as dynamic makes it a bit unforgiving of any typo's
etc.
Thanks
Graham Old
Software Integration
ddi 01582 420950 (single number reach)
ONI Plc is a Cisco GOLD Certified Partner specialising in:
Advanced Unified Communications
Advanced Wireless LAN
Advanced Routing & Switching
Advanced Security
Registered in England No. 2698057'
CONFIDENTIALITY
This e-mail, its content and any files transmitted with it are intended
solely for the addressee(s) and are confidential and may be legally
privileged. If you are not the intended recipient, any use, disclosure
or copying of this document is unauthorised. If you have received this
document in error please immediately notify the sender on +44 1582
429999 and delete this email from your computer. Thank you
|
|
From: Volker B. <vb...@in...> - 2013-06-19 11:50:01
|
Hi Graham,
I would suggest the follow solution:
* define an interface .NET
* create stub jar file from this interface
* Write a Java implementation of this .NET interface as a bridge
* in this Java class you can access the additional cisco stuff
* Create a jar file from the cisco bridge
* Add both jar files to your UrlClassLoader
* Now you need only create your Java class instance and cast it to
your .NET interface
Volker
Am 19.06.2013 13:27, schrieb Graham Old:
>
> Hi Jeroen
>
> I suspect the jtapi.jar you have is the one I sent you when it would
> not convert into a dll.
>
> You are correct that this is all based on the Java TAPI interface but
> Cisco have extended a lot of the calls. One of the problems is knowing
> when you should use a standard Java call or one of Cisco's extended calls.
>
> I think that trying to convert everything to a dynamic object is going
> to be very difficult to program and nearly impossible to maintain.
> This is monitoring phones and is very much about events whenever a
> phone changes state.
>
> I was thinking that I could try to exec ikvmc at the program start and
> have it convert whatever jatpi.jar is installed into the correct
> jtapi.dll for my program. This runs as a windows service so start up
> time is not important.
>
> Has anyone tried this approach?
>
> Regards
>
> Graham
>
> *From:*Jeroen Frijters [mailto:je...@su...]
> *Sent:* 19 June 2013 06:33
> *To:* Graham Old; ikv...@li...
> *Subject:* RE: Am I doing this right
>
> Hi Graham,
>
> This is the right approach in general, but in specific cases there may
> be improvements possible if the dynamic parts implements a statically
> known interface.
>
> I don't know much about jtapi.jar, but in a jtapi.jar I have there is
> a javax.telephony package. It might be possible to write your code
> (mostly) in terms of this interface and then statically compile a dll
> that contains just the javax.telephony classes. If you then use the
> assembly class loader of this assembly as the parent of your
> URLClassLoader that loads jtapi.jar, the statically compiled
> javax.telephony classes will be used.
>
> Regards,
>
> Jeroen
>
> *From:*Graham Old [mailto:gra...@on...]
> *Sent:* Tuesday, June 18, 2013 21:52
> *To:* ikv...@li...
> <mailto:ikv...@li...>
> *Subject:* [Ikvm-developers] Am I doing this right
>
> Hi Team
>
> I have written a program using the Cisco API for the Call Manager
> phone system. The API comes as a jtapi.jar
>
> I have converted the jtapi.jar to a jtapi.dll and my program works great.
>
> The problem I have is that there are lots of versions of Call Manager
> and you have to use the matching jtapi.jar file, so I was looking into
> loading the jtapi.jar at run time then I can just load whatever
> version is installed.
>
> These are from VS2010 so using the dll I have this
>
> try
>
> {
>
> CiscoJtapiVersion jv = new CiscoJtapiVersion();
>
> label1.Text = jv.getVersionName();
>
> label2.Text = jv.getVersion();
>
> label3.Text = jv.getMinorVersion().ToString();
>
> label4.Text = jv.getMajorVersion().ToString();
>
> }
>
> catch(Exception ex)
>
> {
>
> label4.Text = ex.Message;
>
> }
>
> And loading at Run Time I have this:
>
> // Create a URL instance for every jar file that you need
>
> java.net.URL url = new
> java.net.URL("file:C:\\Windows\\Java\\lib\\jtapi.jar");
>
> // Create an array of all URLS
>
> java.net.URL[] urls = { url };
>
> // Create a ClassLoader
>
> java.net.URLClassLoader loader = new java.net.URLClassLoader(urls);
>
> try
>
> {
>
> // load the Class
>
> java.lang.Class cl = java.lang.Class.forName("CiscoJtapiVersion",
> true, loader);
>
> // Create a Object via Java reflection
>
> Type type = ikvm.runtime.Util.getInstanceTypeFromClass(cl);
>
> dynamic jv = type.GetConstructor(new Type[] { }).Invoke(null);
>
> label1.Text = jv.getVersionName();
>
> label2.Text = jv.getVersion();
>
> label3.Text = jv.getMinorVersion().ToString();
>
> label4.Text = jv.getMajorVersion().ToString();
>
> }
>
> catch(Exception ex)
>
> {
>
> label4.Text = ex.Message;
>
> }
>
> My question is:
>
> Am I going about this the right way?
>
> I assume I need to define all my objects as dynamic as there is no way
> of getting a static reference
>
> Defining the objects as dynamic makes it a bit unforgiving of any
> typo's etc.
>
> Thanks
>
> Graham Old
>
> Software Integration
>
> ddi 01582 420950 (single number reach)
>
> ONI Plc is a Cisco GOLD Certified Partner specialising in:
>
> Advanced Unified Communications
>
> Advanced Wireless LAN
>
> Advanced Routing & Switching
>
> Advanced Security
>
> Registered in England No. 2698057'
>
> CONFIDENTIALITY
>
> This e-mail, its content and any files transmitted with it are
> intended solely for the addressee(s) and are confidential and may be
> legally privileged. If you are not the intended recipient, any use,
> disclosure or copying of this document is unauthorised. If you have
> received this document in error please immediately notify the sender
> on +44 1582 429999 and delete this email from your computer. Thank you
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
>
>
> _______________________________________________
> Ikvm-developers mailing list
> Ikv...@li...
> https://lists.sourceforge.net/lists/listinfo/ikvm-developers
|
|
From: Jeroen F. <je...@su...> - 2013-06-19 11:54:15
|
Graham Old wrote: > I was thinking that I could try to exec ikvmc at the program start and > have it convert whatever jatpi.jar is installed into the correct > jtapi.dll for my program. This runs as a windows service so start up > time is not important. That is certainly possible. I also like Volker's suggestion. Regards, Jeroen |