IDataBase::NewUID and IDataBase::Instantiate

Hi!
I'm a little bit confused. Reading about persistent objects I found three different descriptions of how to do it.
UID uid = db->NewUID(kBoss);
and then
(1) found in IDynPnPanelManager from the SDK
IDynPnPanelManager *interface = (Interface*)db->Instantiate(uid, IID);
or
(2) the description of Instantiate in the API compendium says "Normally this is called from InterfacePtr, instead of directly." So I guess this is meant:
InterfacePtr<Interface> interface(db, uid, IID);
or
(3) programming guide, page 69 says "Before you instantiate a new object, use the InterfacePtr template to retrieve one of the object's interfaces. Pass the returned InterfacePtr to the IDatabase::Instantiate method, which calls the database to instantiate the object." So I'd expect I've to write
InterfacePtr<Interface> interface(db, uid, IID);
IDynPnPanelManager *interface = (Interface*)db->Instantiate(interface, IID);
Also though the return type of Instantiate is given with "IPMUnknown*", the doc says it can also return a reference to the object. How can I handle it if it can return a pointer or a reference?
Or am I thinking to complicate?
Martin

I tried to load .indd file with exactly the same code. This time, IDataBase object could open the file without an error, even though it should have raised a 'kInvalidFileFormatError' error.
This suggests me that SetMagicBytes() is not working as expected.
I also tried to set the MgicByte bytes manually as below. But still getting the same behaviour.
static DBUtils::MagicBytes myDatabaseBytes = { 'I', 'n', 'D', 'n', 'P', 'd', 'f', 'S'};
Any help would be greatly appreciated.
Thanks,
JP

Similar Messages

  • Servlets/JDBC - Connect to database ONCE and not in every servlet - How?

    Hello, I'm using servlets and JDBC.
    In every servlet , i connect to the database and then i close the connection, but this is not ptactical.
    I would like to connect to the database once (at the beginning) when container starts and then close the connection.
    How am i supposed to do that?
    Thanks, in advance!

    Bad idea. Don't do that. The connection will timeout sooner or later (depends on DB used, it's usually around 30 mins) and your application will crash.
    You should always acquire and close the connection (and statement and resultset!) in the shortest possible scope. To improve connecting performance just use connection pooling.
    Create a DAO class which does all the task and just instantiate and assign it as Servlet class variable during Servlet's init() method. For more insights and code samples start here: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    To go back to your fundamental question, doing some stuff during startup and shutdown of webapp, you could use the ServletContextListener for this. But again, do NOT do this to get hold of an external resource such as a connection! It's receipt for trouble.

  • Memory leak and char[] ?

    Hello all,
    I'm not sure whether this post should be here or in WebLogic section, so correct me if I'm wrong.
    I'm working on JDeveloper 11.1.1.3 while deployments are made on standalone WebLogic 10.3.3. This thing occurred in previous versions also.
    With every deployment WebLogic increases it's used memory until the famous PermGen space error, which is after about 5-6 deployments.
    I'm doing my best to understand how to use memleak detection tools. I've switched JDev and WL from Sun jdk which was used before to JRockit, same thing happens. Both JDev's memory profiler and JRockit mission control show something that I really do not understand. char[] uses around 30% of heap space and keeps growing with deployments, next is String with 8%. I never use char in app.
    Am I looking at the wrong thing? Is it normal for char[] to increase on WebLogic on deployments? Does anyone know how to check other things and what to check? Someone on other forums mentioned it would be useful to check if ApplicationContext keeps initializing over again on deployments. Does anyone know how to check this?
    One more thing, I have successfully deployed app on Tomcat, and Tomcat said there is a memory leak in app, but could not tell anything specific.
    I'm kinda lost in this :(

    It is normal for the PermGen space of the Sun's JVM to get filled after several re-deployments. PermGen stands for "permanent generational". This space is used by classes that is unlikely to need to be garbage-collected, so they are placed in this memory space that is never garbage-collected (for example, the Class instances). When you redeploy an application, a new class loader instance is used and it instantiates new Class instances that fill up the PermGen space. But why this happens on JRockit either, I could not explain.
    We have experienced memory leaks related to classes and components that use native memory. For example, we have had significant memory leak when using Oracle's JDBC OCI driver. We were not able to solve this problem, so we switched to JDBC Thin driver (which is very performant and stable today comparing to some years ago). If you are using Oracle JRockit, you can monitor the overall memory usage by the following JRockit command executed at OS command line:
    jrcmd <jrockit_pid> print_memusage>where <jrockit_pid> should be replaced by the JVM process ID.
    If you suspect existence of native memory leaks, then have a look at the article Thanks for the memory for explanations about how Java uses native memory.
    Dimitar

  • Member function and member procedure inside an object type in Oracle.

    Hi All,
    Please do have a look at these codes and help me understand. I have no idea about this member function and member procedure. How do they work? Please explain me about this.
    Regards,
    BS2012
    create type foo_type as object (
      foo number,
      member procedure proc(p in number),
      member function  func(p in number) return number
    create type body foo_type as
      member procedure proc(p in number) is begin
        foo := p*2;
      end proc;
      member function func(p in number) return number is begin
        return foo/p;
      end func;
    end;
    /

    Methods are just like functions or procedures in a package, except they're not in a package, their part of an object type.
    The object has attributes (which are the variables declared in it).
    To use such an object you would do things like this...
    SQL> set serverout on
    SQL>
    SQL> declare
      2    v_foo foo_type;
      3    v_val number;
      4  begin
      5    v_foo := foo_type(20); -- instantiate the object and initialize the object attributes
      6    v_foo.proc(20); -- call the object method (proc)
      7    v_val := v_foo.func(4); -- call the object method (func)
      8    dbms_output.put_line(v_val);
      9  end;
    10  /
    10
    PL/SQL procedure successfully completed.The Type definition you've declared creates the object class, but not actually an object itself.
    To actually have an object you need to declare a variable of that object class type, and then instantiate it. When you instantiate the object you need to initialize all the attributes (generally you can pass null if required for each of them to initialize them).
    Once you have your object instantiated, you can call the methods within that object as demonstrated above, a bit like calling functions and procedures in a package, except they are methods within the object type itself, and therefore called directly by referencing them from the variable.
    The documentation goes into a lot more detail of objects if you look it up.

  • EJBContainer (glassfish v 3.0 impl) and JUnit, jndi lookup is impossible!!!

    Hello,
    i hope to find a solution, but i think there's something wrong:
    i did my JUnit test case and i instantiate the glassfish v3 EJBContainer in my @BeforeClass method
    running the test, deploy messages are something like this:
    INFO: Portable JNDI names for EJB PhaseHandler : [java:global/ejb-app4338883541443661181/classes/MyEJB!my.package.MyEJB, java:global/ejb-app4338883541443661181/classes/MyEJB]i would like to lookup for the ejb in my @Before methods... but... which jndi name should i use to fetch the EJB if the app name is random?
    i've tried some tries:
    java:global/classes/MyEJB (read from a tutorial)
    java:app/classes/MyEJB (thought it could work but.. no it doesn't)
    java:module/MyEJB (failed :/ )
    any suggestion? any help will be greatly appreciated
    follows my maven dependency configuration
        <repositories>
            <repository>
                <id>maven2-repository.dev.java.net</id>
                <name>Java.net Repository for Maven</name>
                <url>http://download.java.net/maven/glassfish</url>
                <layout>default</layout>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.extras</groupId>
                <artifactId>glassfish-embedded-all</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>6.0</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>
        </dependencies>and this is my test case:
        @BeforeClass
        public static void startContainer() {
            container = EJBContainer.createEJBContainer();
        @AfterClass
        public static void stopContainer() {
            if (container != null) {
                container.close();
         * @throws NamingException
        @Before
        public void setup() throws NamingException {
            myEjb =(MyEJB)container.getContext().lookup(
                    "which jndi should i use?");
        }

    i did my JUnit test case and i instantiate the glassfish v3 EJBContainer in my @BeforeClass methodWhat is "your jUnit test case"?
    You don't have to implement jUnit tests, and if you do, you generally benefit to have more than one.
    Moreover, you shouldn't think it as "doing jUnit test cases", but merely as "doing unit-testing using jUnit"

  • [iphone] sub ViewController in UITableView and Interface Builder

    Hello,
    I created a UITableView-based application and now I would like to display a simple view after selecting a cell (drilldown feature).
    I create a xib file in Interface Builder by following the guide "Configuring the Views for Additional Navigation Levels" in http://tinyurl.com/6cdh2k and I instantiate my controller using the method describe here http://tinyurl.com/5ft7ug
    in my method didSelectRowAtIndexPath :
    ViewStoryController *detailStoryController = [[ViewStoryController alloc] initWithNibName:@"StoryDetails" bundle:nil];
    detailStoryController.story = story;
    [[self navigationController] pushViewController:detailStoryController animated:YES];
    But my screen is blank but for the navigation bar. I think it must something about init/load methods etc ... I missed something ?
    Matthieu

    Hello,
    I created a UITableView-based application and now I would like to display a simple view after selecting a cell (drilldown feature).
    I create a xib file in Interface Builder by following the guide "Configuring the Views for Additional Navigation Levels" in http://tinyurl.com/6cdh2k and I instantiate my controller using the method describe here http://tinyurl.com/5ft7ug
    in my method didSelectRowAtIndexPath :
    ViewStoryController *detailStoryController = [[ViewStoryController alloc] initWithNibName:@"StoryDetails" bundle:nil];
    detailStoryController.story = story;
    [[self navigationController] pushViewController:detailStoryController animated:YES];
    But my screen is blank but for the navigation bar. I think it must something about init/load methods etc ... I missed something ?
    Matthieu

  • JAXB instantiates extra HashSet layer

    This is a hard thing to describe, but I'll try. I'm looking at the datatypeconverter samples in JAXB 2.0 distribution. Inside the complex type POType, there is a field called items (of type Items). Now I just want to change it to a Set, so I created an Adapter class, like this:
    package primer.myPo;
    import javax.xml.bind.annotation.adapters.XmlAdapter;
    import java.util.*;
    public class SetAdapter
        extends XmlAdapter<Items, java.util.Set>
        public java.util.Set unmarshal(Items value) {
            Set<Items.Item> s = new java.util.concurrent.CopyOnWriteArraySet<Items.Item>();
            List<Items.Item> l = value.getItem();
            for (Iterator<Items.Item> ite = l.listIterator(); ite.hasNext(); ) {
                   Items.Item item = ite.next();
                   s.add(item);
            return s;
        public Items marshal(java.util.Set value) {
            Items i = new Items();
            List<Items.Item> l = i.getItem();
            for (Iterator ite = value.iterator(); ite.hasNext(); ) {
                   l.add((Items.Item)ite.next());
              return i;
    }And then within POType, I change the data type of items, like this:
    public class POType {
        @XmlJavaTypeAdapter(SetAdapter .class)
        private java.util.Set items;
        public java.util.Set getItems() {
            return items;
        public void setItems(java.util.Set value) {
            this.items = value;
        }The XML structure is the same as in the JAXB sample:
    <purchaseOrder orderDate="1999-10-20">
       <items>
           <item>...</item>
           <item>...</item>
       </items>
    </purchaseOrder>This setup does seem to work (marshalling/unmarshalling) with no exception. But the problem as I find out is, POType.items is not a CopyOnWriteArraySet of Items.Item as one expects, but a HashSet of CopyOnWriteArraySet<Items.Item>. In other words, there is an added layer of indirection (the HashSet). In fact, the method setItems is never even called. It seems to me, JAXB sees that items is of type java.util.Set, and internally instantiate it with a HashSet. All these are done hidden from view.
    Where did this HashSet come from? Why wasn't POType.items simply assigned the Set object created by my Adapter? And how can it do that when the field is private?

    This is a hard thing to describe, but I'll try. I'm looking at the datatypeconverter samples in JAXB 2.0 distribution. Inside the complex type POType, there is a field called items (of type Items). Now I just want to change it to a Set, so I created an Adapter class, like this:
    package primer.myPo;
    import javax.xml.bind.annotation.adapters.XmlAdapter;
    import java.util.*;
    public class SetAdapter
        extends XmlAdapter<Items, java.util.Set>
        public java.util.Set unmarshal(Items value) {
            Set<Items.Item> s = new java.util.concurrent.CopyOnWriteArraySet<Items.Item>();
            List<Items.Item> l = value.getItem();
            for (Iterator<Items.Item> ite = l.listIterator(); ite.hasNext(); ) {
                   Items.Item item = ite.next();
                   s.add(item);
            return s;
        public Items marshal(java.util.Set value) {
            Items i = new Items();
            List<Items.Item> l = i.getItem();
            for (Iterator ite = value.iterator(); ite.hasNext(); ) {
                   l.add((Items.Item)ite.next());
              return i;
    }And then within POType, I change the data type of items, like this:
    public class POType {
        @XmlJavaTypeAdapter(SetAdapter .class)
        private java.util.Set items;
        public java.util.Set getItems() {
            return items;
        public void setItems(java.util.Set value) {
            this.items = value;
        }The XML structure is the same as in the JAXB sample:
    <purchaseOrder orderDate="1999-10-20">
       <items>
           <item>...</item>
           <item>...</item>
       </items>
    </purchaseOrder>This setup does seem to work (marshalling/unmarshalling) with no exception. But the problem as I find out is, POType.items is not a CopyOnWriteArraySet of Items.Item as one expects, but a HashSet of CopyOnWriteArraySet<Items.Item>. In other words, there is an added layer of indirection (the HashSet). In fact, the method setItems is never even called. It seems to me, JAXB sees that items is of type java.util.Set, and internally instantiate it with a HashSet. All these are done hidden from view.
    Where did this HashSet come from? Why wasn't POType.items simply assigned the Set object created by my Adapter? And how can it do that when the field is private?

  • Child and Parent Threads

    I have a parent thread class PThread which
    instantiates some child threads CThread in its run()
    method..
    Now Child threads need to give their status/information
    back to Parent thread periodically.
    Can I child thread callback any function of Parent
    thread

    Actually in my case, 1 parent Thread is running and it instantiates multiple child Threads (the number will be decided based on input from some file)....Now these Child Threads are doing some measurements...Each Child Thread is maintaining a bool variable
    "isActive"...If the measurement is not bein taken, it sets the isActive flag to false, otherwise true...(Different Child threads have their own "isActive" Status)...
    Now, there are Some other classes in System who are interested in knowing which Measurements are Active....(that means they want to know the status of Individual Child threads).....These classes are
    interacting with Parent class only....
    That's why I wanted individual Childs to update their current status
    periodically to Parent , so that when Parent is asked this information
    from Other classes, it can Consolidate and present the data....
    This was the only purpose, why I asked whether we can call from
    inside Child Thread, any functon of Parent Thread..
    What I understood from your comments that if Child Thread has access to Parent Thread's Object....(wich should be passed to it during new),
    it can callback Parent's functions.
    That should solve the purpose.....
    Regarding stopping of threads, Parent thread is itself gets information/interrupt from some other class to stop itself... when it
    gets the information, it will stops the Child threads too...I was thinking of calling some stop()
    function of individual child threads which will call their interrupt()..
    And at the end I will call the interrupt() of Parent class....
    I don't know much about usage of join(), so will have to study more
    about how can I do it better.
    Also one thing more:-
    Both Child and Parent Thread classes are extending Thread.
    They don't have to extend from any other class...I have to
    write specific functionality in run() function of parent and class.
    Should I change it to runnable....Why did you advised against
    extending threads

  • Referenced and Referencing Component Usages Must Address the Same Component

    Hi,
    I have a main component MC and it has two used componenents - IBLC and IVAC (interfaces for model and visual compoenents).
    I get the actual model component name from a table and I instantiate it as follows:
    instantiate model component
    DATA: l_ref_model_usage TYPE REF TO if_wd_component_usage,
    l_my_initial_usage type ref to IF_WD_COMPONENT_USAGE.
    L_MY_INITIAL_USAGE = wd_this->wd_cpuse_iblc( ).
    l_ref_model_usage = L_MY_INITIAL_USAGE->CREATE_COMP_USAGE_OF_SAME_TYPE(
    NAME = Item_Modelcomp ).
    Components VC1 and VC2 etc implement IVAC.
    Since I want to use the same instance of Item_Modelcomp in VC1 and VC2, I use the set_model(and from that I call method enter_referencing_mode) method as follows in MC.
    l_ref_interfacecontroller->set_model( model_usage = l_ref_model_usage ).
    Now in set_model method in VC1, I am using Item_Modelcomp as used component and not IBLC because I want to use the Item_Modelcomp context, but it expects IBLC as the used component(even though Item_Modelcomp implements IBLC) and hence gives the error "Referenced and Referencing Component Usages Must Address the Same Component".
    Any solution for this issue?
    Thanks and Regards,
    Srini.

    Hi Srinivasa,
    >I thought model compoenents are the ideal way to share
    >context across different visual components.
    Yeah, we though the same in the beginning. Later on we learned that:
      - it's not worth having the overhead of another WD component in most cases since you need to call the business logic nonetheless
      - declaring nodes as public is like having public attributes at a class - which can be really bad thing
      - there are lots of side effects regarding one component affecting the other one indirectly by having both mapped to the same model component
    In general, using model components should be avoided. There might be rare cases, where it makes sense to use them, but mostly it's not worth the effort.
    Best regards,
    Thomas

  • Memory on java cards

    Hi, i wonder how can i know the space that an applet use on the card, i want a .cap that is 3K size and i what to know if i instantiate this app on the card how much memory it will consume (the .cap and the instantiate).

    Hello
    the size of the load block (what goes through LOAD commands) is a very good estimate.
    You can't know for sure because it depends on how the card is implemented internally. Usually it's a tiny bit smaller than the load block.

  • Load Class in Interface Builder 3

    Hello,
    i am trying to get started with Cocoa after having worked a while with Xcode & smaller AppleScript based projects.
    As my idea was to create a menubar-based (NSStatusItem) service app for myself i started with this tutorial:
    http://files.semaja2.net/NSStatusItem%20-%20ObjC.html
    Unfortunaly it seems like there was a change in Interface Builder regarding loading Classes from Version 2 to IB version 3
    The tutorial tells me to (about the middle of the tutorial):
    Rename the “NSMenu1” to “StatusItem”, following this in “Interface Builder” >>choose from the menu “Classes > Read Files..” now select the AppController.h >>file, Once the file has been read it should change out project view to “Classes” >>from here find the AppController item and right click on it and select >>“Instantiate AppController”:
    I was able to follow the tutorial until there without problems but it looks like the Classes-Tab is gone in IB 3.x.
    So i feel somehow unable to finish this small tutorial.
    how would i do this step in Interface Builder 3.x ?
    Any help is heavily appreciated.
    Best regards
    fidel

    fidel-castro wrote:
    I was able to follow the tutorial until there without problems but it looks like the Classes-Tab is gone in IB 3.x.
    So i feel somehow unable to finish this small tutorial.
    how would i do this step in Interface Builder 3.x ?
    You're right, this has changed. I'm currently using IB 3.1.1 but I believe the changes appeared in IB 3.
    Once you've done the "Read class files" and selected your AppController.h file IB should know about your class.
    In order to instantiate your AppController in IB first go to the Library window and find the "NSObject" (it will appear as a blue cube). Drag one of these NSObject's from the Library window and drop it into your MainMenu.xib window along with the other icons that appear there (File's Owner, First Responder, Application... etc).
    Now you will have created an instance of an NSObject in your MainMenu.xib file. And, since your AppController class is a subclass of NSObject (and IB knows this since you've had it read in your AppController.h file) you can now change this NSObject instance into an instance of your AppController.
    Select the NSObject icon in the MainMenu.xib window then go to IB's Inspector window and click on the next to last icon in the top tool bar. This should change the Inspector window's title bar to say "Object Identity" and the Class Identity in the first text field should be set to NSObject. You should be able to type "AppController" into this field (or click the popup and it should show up in the popup list. Once you've done this it will transform the NSObject instance into an AppController instance.
    You'll see another slight difference between IB 3.x and the tutorial when you do the <Control>-Drag between items to connect up the outlets and actions. Instead of finalizing the connections in the Inspector window like the tutorial says you'll get a small popup window right next to the item you're connecting to that will list the available outlets/actions you can connect to. Simply click the one you want. You can still double-check your connections in the inspector window though.
    Steve

  • Illegal access error at runtime

    Hi,
    I am getting an illegal access error while trying to call a method.
    - Class1 tries to call method on Class2.
    - Method has package visibility
    - Both classes are in same package.
    - Class1 is being invoked by a class in a Web Application which is
    in a completely different package. Class1 gets invoked properly
    and then instantiates Class2. It then tries to call the method on
    Class2.
    - Compiler is compiling successfully i.e. no compile time errors
    Any clues?
    Env:
    JDK 1.4.2_01
    App Server Tomcat 4.0.6
    Thanks
    Reg
    Aashish

    Hi,
    I am getting an illegal access error while trying to
    call a method.
    - Class1 tries to call method on Class2.
    - Method has package visibility
    - Both classes are in same package.
    - Class1 is being invoked by a class in a Web
    Application which is
    in a completely different package. Class1 gets
    s invoked properly
    and then instantiates Class2. It then tries to call
    l the method on
    Class2.
    - Compiler is compiling successfully i.e. no compile
    time errors
    Any clues?
    Env:
    JDK 1.4.2_01
    App Server Tomcat 4.0.6
    Thanks
    Reg
    AashishThe problem is the Class1 and Class2 are being loaded by different classloaders. Because of this, they are considered to be in different packages by the VM, and hence the IllegalAccessError.
    To correct this, make sure both classes are only available in a single classloader context. So if these classes are only used by the WebApp, include them in a jar in WEB-INF/lib or WEB-INF/classes..
    If yyou need access to these across multiple webapps, or by some other non-webapp classes, place them in the /common/lib directory for Tomcat.
    Whatever you do, MAKE SURE THEY AREN'T avaialble in BOTH! Which is what appears to be the problem now.

  • How can I add rows to a JTable based on an Abstract Table Model?

    I have done this ...
    public class myui extends JPanel {
    private AbstractTableModel jTable1Model;
    blah blah
            jTable1Model = new AbstractTableModel() {
                 String[] column = new String[]{"TID", "Name", "Address"};
                 Vector<Vector<Object>> table = new Vector<Vector<Object>>();
                 @Override
                 public int getRowCount() {
                      return table.size();
                 @Override
                 public int getColumnCount() {
                      return column.length;
                 @Override
                 public String getColumnName(int col) {
                      return column[col];
                 @Override
                 public Object getValueAt(int row, int column) {
                      return table.get(row).get(column);
                 @Override
                 public void setValueAt(Object value, int row, int column) {
                      table.get(row).set(column, value);
                      fireTableCellUpdated(row, column);
                 public void insertRow() {
                      Vector<Object> columns = new Vector<Object>();
                      columns.add(null);columns.add(null);columns.add(null);
                      table.add(columns);
                      fireTableRowsInserted(0, table.size());
    blah blah
        public synchronized void ImportVisitorDataToJTable1(Object value, int row, int col) {
            jTable1Model.InsertRow();  <-----///// This line not being recognised as a valid member function call
           jTable1.setValueAt(value, row, col);
    }I thought to insert a row I can define a function in the abstracttablemodel class and then instantiate the class and override or create new methods that I can use.
    But after instantiating the class and overriding appropriately and adding the insertRow function, when I try to use it in ImportVisitorDataToJTable1 as seen above its not being recognized as a funtion of jTable1Model

    1. respect naming conventions. Example: myui --> MyUI, ImportVisitorDataToJTable1 -->importVisitorDataToJTable1
    2. convert Anonymous to Member: AbstractTableModel --> MyTableModel
    3. row parameter makes no sense here as it depends on current row count:
        public synchronized void importVisitorDataToJTable1(Object value, int col) {
            int row = jTable1Model.getRowCount();4. here is a more adequate "fireTable.."-call for insertRow:
    fireTableRowsInserted(table.size() - 1, table.size() - 1);
    5. check if you can take advantage using DefaultTableModel as suggested by Maxideon.

  • Remote interface distribution

    Hi,
    I am just learning to use RMI, have a typical setup, Server and Client and everything works fine, BUT.......
    I have compiled my remote classes, ie RmtServer, RmtServerImpl, then run the rmiregistry
    and then started the service, so far so good.
    I then compile etc the Client class and run
    My question is this, I am currently working from the same directory for all classes, I would like to truly
    distribute the client and server. Do I need to put a copy of the RmtServer interface on the client?
    Currently in my client I have the line:
    RmtServer server = (RmtServer)Naming.lookup("rmi://" + serverHost + "/ProjectServer");
    I have been reading about dynamic class loading but I am slightly confused!!!
    It says that the stubs created by running "rmic" on the server classes can be loaded dynamically, thats great, but the stubs created and the RmtServer interface are not the same thing. If I have to have a "local" copy of every interface I want to use then it seems a bit limited.
    My impression was that I could specify a location for a class repositry on a remote machine and then
    instantiate classes from the server on the local machine! So then I would only need to have one interface on the client to enable me to connect to the server for the first time!!!
    Im really confused as people can probably tell. Any help would be really appreciated

    The purpose of dynamic loading is really so that you don't have to distribute the stub, or the implementation classes of any interfaces.
    You can certainly load the remote interface dynamically from the codebase in the client, e.g. with URLClassLoader, but you will also have to have already loaded all the classes that use the remote interface the same way, rather than via the system class loader. Otherwise they won't load (NoClassDefFoundError). You can download the entire client actually, and this is not a bad way to go: see the the RMI 1.1 Specification, 'Bootstrapping the client', for details (if you can find it: try http://java.sun.com/products/archive/jdk/1.1/index.html), and the RMI-USERS archives of about five-six years ago for discussions (see http://archives.java.sun.com/archives/rmi-users.html). The description of this was removed from the 1.2 specification for some reason, and I did encounter problems migrating a 1.1 bootstrap client to 1.2, so beware.

  • "Module Domains" confusion

    Dear all,
    I'm currently playing around with Flex modules api and got
    very confused with the "Module Domains" section on the Adobe docs.
    It's under:
    Adobe Flex 3 Help -> Advanced Flex Programming ->
    Creating Modular Applications -> Modular applications overview
    -> Module domains.
    In that section, it basically talks about how class
    definitions can be "owned" by modules, how it affects the
    mysteriously undocumented "SingletonManager" thingy, and how
    singletons such as PopupManager might not work due to ownage. I've
    read through this section at least 5 times and have done quite a
    lot of testing but still couldn't figure out exactly what it means.
    Well, here is my questions below and I hope someone can shed my
    some insights or point me to a more detailed documentation
    regarding this topic:
    1. The doc says, "Because a module is loaded into a child
    domain, it owns class definitions that are not in the main
    application's domain."
    What does it mean by class definitions being "owned"? As far
    as i know, parent-child ApplicationDomain relationship is
    constructed in such a way that class definitions on child domains
    are overridden by the same (usually newer) class definitions on
    parent domain, but I don't understand what it means by "owning" it.
    This also leads to my 2nd question below.
    2. The docs then went on saying "For example, the first
    module to load the PopUpManager class becomes the owner of the
    PopUpManager class for the entire application because it registers
    the manager with the SingletonManager. If another module later
    tries to use the PopUpManager, Adobe ® Flash® Player
    throws an exception."
    Well I've tried to replicate this scenario by creating 2
    modules and have each of them calling PopUpManager.createPopUp() on
    creationComplete event. I loaded up both modules from my shell
    application and the popups from both modules worked, i.e., i see 2
    popups on screen. But according to the docs, I should get an
    exception when the 2nd module tries to run
    PopUpManager.createPopUp(). So why is this not the case?
    3. The docs also says, "This technique also applies to
    components. The module that first uses the component owns that
    component's class definition in its domain."
    So, I assume what it means is that such restriction affects
    not just singletons but normal objects as well. I tried another
    test by having module1 instantiates an object of classA, pass it on
    to module2, and then try to access it from module2. According to
    docs, I should also get an exception from the player; however, this
    is not the case. I was able to access the classA instance from
    module2 with no errors. Consequently, I also tried to instantiate
    classA from module1 and then instantiate another instance of classA
    from module2, and that also worked.
    As you can see, I'm really confused about almost everything
    mentioned in this "module domains" section and how it affects us in
    real life. Of course it's all nice and well that all my tests
    worked and no exceptions are thrown, but I really wish to get to
    the bottom of this and understand what "module domains" really
    implies in all these scenarios.
    Thanks,
    Aaron

    hotscripts.com would be a good starting place.
    Otherwise you'll probably need to farm out the work to
    someone who can
    program in the language of choice for your web host.

Maybe you are looking for