To More Specific Class & Plugin Architecture

Hello there,
I have a plugin architecture and I want to load a particular class on demand, when a user clicks a button etc.
I can do this using 'Get LV Class Default Value.vi' knowing the path of the .lvclass file, and I can then use the 'To More Specific Class' vi to cast it from type LV Object to the specific class I know it to be.
However if I have 30 different classes with this method I would have to have 30 different class constants in a case structure so I can cast to the right one.  This works but it means all the classes are loaded into memory when the program is run, even though the user may never want to use most of them, which is a waste of time/memory.
Is there a better way of doing this please?
Thanks,
Martin

I wonder if minute 4:00 in Michael's video will help you. It avoids the constants, as long as all the classes are descendants of a common class:
http://vishots.com/005-visv-labview-class-factory-pattern/

Similar Messages

  • To more specific class: Cant find strict numeric, only numeric

    Im trying to read a control property by reference from some controls that are in a cluster.
    I want to cast the property's reference to a more specific class: strict numeric, but I can only find 'Numeric' which leaves me with variant data.
    Any help?
    Solved!
    Go to Solution.

    Hello,
    I think you can't (not fully sure though). What you can do is get the "Representation" property, that tells you if it's I32 or DBL or else (as an enum) and with this information you can get the value from the variant.
    See :
    Hope this helps
    EDIT :
    Oh... I see now that there IS a way, thanks for that pincpanther :-o
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • To more specific class for waveform chart

    Dear All
    In the attached VI diagram the "To more specific class" gives an error messag:
    LabVIEW:  Type mismatch: Object cannot be type casted to the specified type.
    so it can not work for my waveform chart. I think I changed some properties or some thing similar for my chart that can not work with this routine because it works for new instances of waveform charts but whatever I try to find the difference between my waveform chart and a new instance of waveform chart I don't not find any difference.
     Do you have any clue?
    Best regards
    Afshin
    Attachments:
    VI2.JPG ‏59 KB

    Try to use the "Controls[]" and the "ClassName" property instead. See attachment.
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    WaveformChart.JPG ‏61 KB
    WaveformChart_85.vi ‏18 KB
    WaveformChart_85_CTL.ctl ‏9 KB

  • To more specific class: all return error after upgrade from LV2011 to 2012

    I have working projects/executables built in labview 2011. When loading the exact same project in 2012 EVERY 'to more specific class' returns an error.
    For example, making a generic control reference into a 'numeric'.
    Redoing the exact same action makes no difference. What has changed in LV2012?

    Can you post an example VI containing such code? Please post the original 2011 code.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Refnum more specific class error

    I am trying to make a general control reference number into the more specific TabControl refnumber, but when I try using the "To More Specific Class" VI with a TabControl reference constant, I get the following error:
    Code: 1057
    Error:  Type mismatch: Object cannot be type casted to the specified type.
    I have posted a picture of what I am trying to do (the false case just passes the boolean through).
    Is there a reason that I am not able to nake the more general control reference into a TabControl refnum?
    Thanks.
    --Robert
    Message Edited by knapkerd on 06-19-2008 11:28 AM
    Message Edited by knapkerd on 06-19-2008 11:28 AM
    Attachments:
    more_specific_class.PNG ‏11 KB

    knapkerd wrote:
    Is there a reason that I am not able to nake the more general control reference into a TabControl refnum?
    Yes, there is.
    What you're attempting to cast is not the tab control, but its owner, which would be either the panel or the pane. If you use the control reference it should work.
    As a side point, a simpler way to do this would simply be to type cast until you get no error (instead of comparing to the class name). If you need more than one class you can wire the string directly into the case structure selector.
    Try to take over the world!

  • To more specific class - cursor reference - error 1057

    I must be missing something very stupid here. Why is this cast not working? Thanks!

    There are other questions to be answered:
    1. Does the cursor exist on the graph?
    2. What other errors are you getting earlier in the process?
    3. Have you tried probing the cursor reference before you did the cast to a generic type?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • ClassLoading in plugin architecture

    I'm developing a Java Desktop Application with a plugin architecture. I'd like to know of any good resources for information on how to use ClassLoaders to implement different schemes of plugin isolation and sharing.
    Examples:
    Sharing Each plugin depends on the application's public API jar, and classes loaded from here must be shared between the application and all plugins.
    Isolation Plugin A may be built using version 0.2.4.1 of a third-party Xxx.jar while plugin B is built using version 1.0.0.2 of Xxx.jar, which is incompatible with the earlier version. The two plugins must be isolated from each other, so that each loads the classes from its own version of Xxx.jar.
    There are probably many other issues that my plugin mechanism needs to take care of. The application is not supposed to support hot-swapping of plugins.
    Any help and/or references will be highly appreciated.
    Edited by: nygaard on May 29, 2009 10:30 AM

    nygaard wrote:
    Here are two more things, I'd like to support:
    Plugin/application isolation Plugin A uses third-party Xxx.jar which in turn depends on version 1.2.3.4 of log4j.jar. The application itself uses version 0.1.2.3 of log4j.jar which is incompatible with 1.2.3.4.this is a little more complicated, but doable. basically, you will have to have some bootstrapping startup code for you application which only includes a few jars in the main application classloader (not including anything you want to be isolated). basically, you initial classpath should only have a bootstrap jar and any common interfaces (presumably you will have some plugin API). your bootstraping code should then load your main application in a new classloader (we'll call it the app classloader to distinguish) which has the main classloader as its parent. your plugins should be loaded with the parent classloader being the main classloader, not the app classloader.
    Plugin/plugin sharing Plugin A may depend on plugin B and should be allowed to use classes found there.this makes things a little stickier. does A just need to use classes from B, or does it need to interact with B (two different things)? the former is easy (just sharing jar files). the latter is much more difficult, and may require some custom classloading implementation. Also, you will need some sort of discovery mechanism (way for A to "lookup" B within the application).
    Edited by: jtahlborn on May 29, 2009 11:41 AM

  • Plugin Architecture / Modular Design

    I'm trying to find some more information on creating a plugin capable program architecture. I would like to learn how to design a program so that it can later be extended/enhanced by plugins/modules. I would like for a compiled version of my program to be able to access these plugins.
    Has anyone completed a similar task with Java? Can anyone point me in the right direction to start learning more?
    Thank you for your help!
    DesQuite

    To be more explicit, the typical method of creating a "plugin architecture" is to use a combination of interfaces and reflection. For example, if I want to allow developers to create a forum plugin that displays a special footer, I might create an interface that looks like this:
    * A plugin interface. Developers should implement
    * this interface, and register their class.
    public interface ForumFooterWriter {
    * Writes the footer contents to the stream.
    public void writeFooter( PrintStream stream );
    Then you provide a means for the developers to 'register' their plugin. This can be as simple as them editing a properties/xml file and creating an entry with their class name. For example,
    --- Begin plugin.properties
    footerPlugin=com.foo.MyFooterPlugin
    --- End plugin.properties
    Then, you can read the file, and instantiate the plugins. For example,
    /** Your code.
    void writeFooter( PrintStream out ) {
    Properties p = new Properties();
    p.load( "plugin.properties" );
    String footerPlugin = p.getProperty( "footerPlugin" );
    Class footerPluginClass = Class.forName( "footerPlugin" );
    ForumFooterWriter ffw = ( ForumFooterWriter ) footerPluginClass.newInstance();
    ffw.writeFooter( out );
    Note, that if you want people to be able to change which plugins are registered, or just be able to re-compile a plugin and have the effect take place without restarting your app, you'll have to add some more complexity to the above (for example, using your own custom class loader), but this ought to be enough to get you started.
    God bless,
    -Toby Reyelts

  • ClassLoaders in a plugin architecture

    Hello everybody,
    I'm developing an application which is to be launched via webstart (running in all-permissions mode) and has to implement a plugin architecture.
    The structure I've come up with so far is this:
    - every plugin is packaged in a different jar, which can be loaded/unloaded at runtime (this is a spec), thus not appearing in the jnlp.
    - The core classes of the application (the "launcher") are sealed into a jar which is listed in the jnlp, and gets the all-permissions privilege.
    - Among the core classes there's a Plugin abstract class which all plugins must extend in order to be launched by the application
    - each plugin can declare dependencies, meaning that it can use other plugins classes, which are loaded before the plugin itself
    Plugins are written by different developers, hence the need to define a Plugin class..
    My problem is with classloaders: right now I'm using a custom classloader which extends URLClassLoader and adds the URL pointing to every plugin jar when it is loaded using URLClassLoader's addURL() method.
    Everything seemed to work fine, but recently I got a java.lang.NoSuchMethodException when a plugin B tried to access the constructor of a plugin A class. The pluginA class extends one of my Plugin abstract classes and the constructor requires an Object as argument.
    To give you an idea of what causes the Exception:
    Plugin A class
    public class PluginAObject2 extends Plugin {
      public PluginAObject2(Object data) {
        super(data); // this calls one of my abstract classes
    Plugin B class
    String foo = "foo";
    PluginAObject1 object1 = new PluginAObject1(PluginAObject1.A_STATIC_FIELD, foo);
    PluginAObject2 object2 = new PluginAObject2(object1); // this causes the NoSuchMethodException
    [...]My questions are:
    - is the NoSuchMethodException thrown because of the super() call in PluginA constructor? My abstract classes are loaded by JNLPClassLoader, is it possible that classB's object1 is not recognized as a subclass of Object because java.lang.Object in JNLPClassLoader is not the same as java.lang.Object in my custom classloader?
    - if so how can I correct the error?
    - if not, can you give me a hint on what's wrong with this?
    Please don't tell me that I have to change the whole approach to the problem, unless it is really the only way to go through this issue...
    Thanks,
    mb

    Thanks jschell,
    still I have some things I don't quite understand..
    jschell wrote:
    You can't do that. You have the following situation.
    Class A loaded via classloader X
    Class B loaded via classloader Y.
    I always use the same custom classloader, having a static reference to it in my "core" classes, calling its addURL(plugin_jar_directory) method every time a plugin must be loaded before it is actually loaded. Something like
    class PluginLoader {
      static CustomClassLoader loader;
      private loadPlugin(JarFile jar, String pluginName) {   
        loader.addURL(jar);
        loader.loadClass(jar, pluginName);
    }I have only 2 classloaders: the JNLPClassLoader and one instance of, say, CustomClassLoader. Which is classloader X and classloader Y in this case?
    jschell wrote:
    One of the following would be needed.
    Class B and A loaded via classloader Z.
    Class A loaded via classloader Z1 and a child of that loads classloader Z2 which loads class B. (Thus Z1 is a parent of Z2.)
    Before using my custom class loader I used to create a new URLClassLoader for every plugin chaining them in a parent-child fashion. The resulting classloader chain looked something like
    + com.sun.jnlp.JNLPClassLoader
      + java.net.URLClassLoader plugin A
        + java.net.URLClassLoader plugin B
          + java.net.URLClassLoader plugin C   and so on, but I had to face the same issue.
    One last thing I don't get: if A and B cannot see each other, why is java.lang.NoSuchMethodError thrown instead of java.lang.ClassNotFoundException in the first line of the two of plugin B I posted before?
    Since I have to extract the manifest of the jar files to know which dependencies they declare and some other things (version, main-class and so on.. we use a custom manifest) could it be that classes inside the jar are loaded by the JNLPClassLoader, which is the classloader of my core classes? I just extract the manifest and do nothing on the classes, so it would sound weird to me but... I'm a bit lost
    Thanks in advance,
    regards
    mb

  • Re: More specific to two questions

     

    Hi everybody,
    I have been watching this debate with interest. I encountered similar
    situation and realised that even after calling the method
    ReleaseDistReference on DistObjectMgr, the object is live ( Probably
    some time before garbage collection kicks in) and can be binded using
    ObjectLocationManager.BindObject() method. This caused some problems to
    us. This object is not invalidated for further use. Can somebody from
    Forte answer this ?
    Pradnesh Dange
    Indus Consultancy Services
    140, E.Ridgewood Ave.
    Paramus, NJ 07652
    Ph: 201-261-3100 (x-234)
    Fax: 201-261-1399
    From: Shi-Long Yin[SMTP:[email protected]]
    Reply To: Shi-Long Yin
    Sent: Tuesday, December 22, 1998 12:19 PM
    To: Boris Berezetsky; 'Forte Users Mailing list'
    Subject: Re: More specific to two questions
    Hi, Boris
    Your helps are really appreciated!
    I've already read this part and other relevant materials of Forte
    document.
    So far, what I understand is if an object is anchored, the garbage
    collector
    will be not automatically applied to it. You must explicitly add it
    to the
    list of the garbage collection.
    Also, many thanks to all who have helped me in this topic.
    Merry Christmas!
    Shi-Long
    Boris Berezetsky wrote:
    Hi, Shi-Long
    I'm not sure if this has been mentioned already, but just in case...
    Take a look at ReleaseDistReference method of DistObjectMgr class.
    The following is an excert from Forte Help on the topic:
    "This method is needed because the distributed object manager keepsa
    list of all anchored objects that have been handed out asdistributed
    references, or are anchored objects that are being used asdistributed
    references in other partitions. Invoking the ReleaseDistReferencemethod
    lets the distributed object manager remove the object from itsinternal
    list, which can then allow memory management to occur on theobject."
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Why is the static method in the superclass more specific?

    Why is the static method in the superclass more specific than the static method in the subclass? After all, int is a subtype of long, but Base is not a subtype of Sub.
    class Base {
        static void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        static void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }The first example compiles without error.
    Output: Base
    class Base {
        void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }In the second example, both instance methods are applicable and accessible (JLS 15.12.2.1), but neither is more specific (JLS 12.2.2), so we get a compiler error as expected.
    : reference to m is ambiguous,
    both method m(int) in Base and method m(long) in Sub match
    sub.m(i);
    ^
    1 error
    Why don�t we get a compiler error for the static methods?

    Thank you for your ideas.
    ====
    OUNOS:
    I don't get Sylvia's response. This is about static methods, what are instances are needed for??Yes, the question is about static methods. I included the example with non-static methods for a comparison. According to JLS 15.12.2, both examples should cause a compiler error.
    And why you create a Sub object to call the method, and dont just call "Sub.m(..)"Yes, it would make more sense to call Sub.m(i). Let�s change it. Now, I ask the same question. Why is there no compiler error?
    ====
    DANPERKINS:
    The error in your logic stems from calling static methods on instances, as ounos pointed out. Solution: don't. You won't see any more ambiguities.A static member of a class may also be accessed via a reference to an object of that class. It is not an error. (The value of the reference can even be null.)
    Originally I was looking only at the case with non-static methods. Therefore, I used sub.m(i). Once I understood that case, I added the static modifiers. When posting my question, I wish I had also changed sub.m to Sub.m. Either way, according to JLS 15.12.2, a compiler error should occur due to ambiguous method invocation.
    ====
    SILVIAE:
    The question was not about finding an alternative approach that doesn't throw up an ambiguity. The question related to why, in the particular situations described, the ambiguity arises in only one of them.
    Yes.
    Proposing an alternative approach doesn't address the question.
    Yes.
    ====
    If anyone is really interested, here is some background to the question. Some people studying for a Sun Java certificate were investigating some subtleties of method invocations:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=019182
    I remember seeing the non-static case discussed in this forum once before in a more practical context. jschell probably knows the link.

  • LabVIEW 2015 - Fast File Format and PlugIn Architecture

    In LabVIEW 2015 the new "fast file format" was introduced:
    "Improving Load Time for LabVIEW-Built Applications and Shared Libraries.
    You can build stand-alone applications (EXE) and DLLs that load faster by using the fast file format in LabVIEW. <...> When you enable the fast file format, LabVIEW does not use the Application Builder object cache"
    The question about PlugIn architecture, when lot of SubVIs called dynamically (for example, from external LLBs) from relative small core application. What I observed is - the size of the executable with this option was significantly reduced (roughly twice) and the core application itself starts faster, but PlugIns load time is the same regardless from this option (I understand why - when application fully loaded then Dynamic calls just "normal" LabVIEW code and therefore this option takes no effect). Unfortunately in code distribution build spec (as well as in packed libraries) this option is not available.
    Is it possible to get "fast" application also for PlugIn-based architecture and get LLBs or packed libraries in "fast file format"? Can someone explain, what means "LabVIEW does not use the Application Builder object cache" and how this "fast load" mechanism technically working?
    Thank you in advance,
    Andrey.

    Andrey_Dmitriev wrote:
    In LabVIEW 2015 the new "fast file format" was introduced:
    Is it possible to get "fast" application also for PlugIn-based architecture and get LLBs or packed libraries in "fast file format"? Can someone explain, what means "LabVIEW does not use the Application Builder object cache" and how this "fast load" mechanism technically working?
    Thank you in advance,
    Andrey.
    Hey Andrey!  It's good to see that you guys have been getting some good mileage out of this project.  I'll go through your questions in order ...
    1) These optimization are actually always enabled by default for packed project libraries. In fact, the load time benefits for packed libraries should generally be better than what you observe for .EXEs and .DLLs!
    2) The app builder cache is something that is enabled for EXEs and DLLs that works to cache the results of previous compiles when the source has not been updated.  It is somewhat analogous to the .obj object files generated by a C++ compiler.
    3) I won't get into too many nitty gritty details but the gist of it is... LabVIEWs various non optimized file formats are treated somewhat similarly to the way that we treat 'loose' VIs. In a DLL/EXE/LVLibp we know at build time what the contents and dependencies of a given built binary are going to be.  With this knowledge we can go ahead and construct something that is more similar to a statically linked PE or ELF file (clearly we're not using either of those) while the analogy is not 100% perfect it's the best I can do without going into a couple pages worth of description   In addition to these basic file format changes we did a large amount of work on implementing a new loader which is able to take advantage of the large amounts of precomputed file data that is now included in the format which enabled us to cut a lot of corners that were there previously.

  • Plugin architecture

    hi everybody
    first of all, sorry if I posted this topic in the wrong forum, but I haven't found a better one for this!
    down to business: I need a good/easy/robust/stable/everything-else-we-look-for-in-a-good-software plugin architecture to develop an application... right now a commercial one, and in the future a free one.
    I've found Java Plugin Framework (JPF)... it seems a very good solution, despite its short lifetime.
    anyway, I need more alternatives, to make a choice that best matches my needs, you know...
    does anybody can point out some other alternatives? I'll be very grateful!
    thanks for your attention!

    What type of "plugging in" do you envision/desire?hum... reading all the messages so far, maybe some people misunderstood what I meant to say...
    I'm looking for a plugin framework which I can include into my application, in order to allow it to be extended by third-party plugins using my application's API (I'll get flamed by posting such description :P )
    it's just like Eclipse, jEdit, Netbeans or Winamp that allow plugins extensions. maybe someone thought that I wanted to make my application as a plugin...
    looking for it, I have only found JPF - http://jpf.sourceforge.net/ -, which fits exactly in this funcion... but anyway I want to evaluate other alternatives...
    I think this time is clear ;)

  • Teststand 2012 plugin architecture

    Hi all,
    Any tutorials on teststand 2012 plugin architecture. I searched on net but could find only few white papers and video tutorial which gives you an overview.
    Thanks

    You have three options:
    A. Make your plug-in a result processor, even if it doesn't process results. This allows it to be inserted and configured in the Result Processing Dialog Box.
    B. Make your plug-in an Addon. See http://zone.ni.com/reference/en-XX/help/370052K-01/tsfundamentals/infotopics/pmpconfiguring/,  Model Plug-in Add-ons and Addons.cfg section.
    C. Create your own configuration file:
    For option (C), you can create additional model plug-in configuration files in the following ways:
    1. Call the DisplayModelPluginDialogEx function from ModelSupport2.dll as defined in ResultProcessing.h to display a dialog that creates and edits a configuration file.
    Note that this dialog will be programmatically customizable in a future version of TestStand. Also, the complete source code is already provided.
    2. Copy an existing configuration file to a new file name. Open the new file in a text editor. Replace any occurrence of the previous file name with the new file name. Thus, you could use the Result Processing Dialog Box to create a ResultProcessing.cfg file with your plug-in in it and then copy the file before removing your plug-in from the dialog.
    3. Create a configuration file programmatically using the TestStand API. You create a Model Plug-in configuration file with an instance of the PropertyObjectFile class with a file type of FileType_PropertyObjectFile. The PropertyObjectFile.Data property of the file must be of type NI_ModelPluginConfigurationSet. Currently there is no example of this, but the source code in ResultProcessing.c performs similar actions.

  • How to modify a specific class in jar file ?

    I've downloaded a jar file for applet, the jar file works fine... but when I extract a specific class file from the jar file and just recompie it from my IDE (Eclipse) without even making any change and then compress again jar class files including the new modified class file instead of the old one (without any modifications to other classes)... then I get
    (NoSuchMethodError ) exception whenever methods of other classes are invoked from within the modified class !!
    ...The manifist file of the jar file reads the following line
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    I thought it means that jar class files were built using JDK 1.4.0_01 ...I used JDK 1.5.0_01 in my IDE...
    I thought JRE incompatiblity was the reason of the problem so I downloaded JRE 1.4.0_01 and used it to build this class file... but i got the same exception..
    so what is the main reason of the problem ? ...should I make changes to IDX files accompanying applet jar files ??
    If no, then how can I overcome this problem and be able to change and rebuild a specific class from this jar file ?
    (I cannot rebuild all classes in jar because there are errors I cannot resolve !!)

    Could you please clarify: do you want to run your project or a project from an independent jar?
    In the first case just select Run Project from the project context menu or select a class with main method and click Run File in the class context menu.
    Regarding the second case:
    - I don't think there is such a feature in the IDE (running third party jars is not an IDE function). Could you explain why you need this?

Maybe you are looking for