XML-Encoder --  Constructors with arguments that are not properties

Hi, I have the problem that I need an argument to initialize the object. That argument isn't stored, to prevent problems with gc (Back-Ref.).
According to
http://java.sun.com/products/jfc/tsc/articles/persistence4/
I have to do something like this:
Encoder e = new XMLEncoder(System.out);
e.setPersistenceDelegate(Integer.class,
                         new PersistenceDelegate() {
    protected Expression instantiate(Object oldInstance,
                                      Encoder out) {
        return new Expression(oldInstance,
                              oldInstance.getClass(),
                              "new",
                              new Object[]{ oldInstance.toString() });
The preceding implementation uses the special method name "new" to refer to the Integer class's string constructor.The problem is that I don't know how to do that, cause I can't receive the needed value from the oldInstance.
To make it a little bit clearer, I have a structure like this.
Class A {
private B b;
A(){
b =  new B(this);
Class B{
B(final A a){
}Providing an empty public constructor would be the easiest but ugly solution, cause you offer an constructor which is not intended to be used anywhere, cause it leaves the object in an not valid state. For hibernate I have to provide such an empty constructor anyways, but at least it can be private.
So is there any other solution out there with limited complexity? You may assume that A will be stored and B is stored by reachability.
Thanks a lot in advance.
Greetings Michael
By the way: the link symbol seems to be broken, whats the plain text markup for that?

ejp wrote:
I don't want to, to avoid problems caused by Back-Ref's. They are hard to solve for the GC. No they're not.The Artcicle below tells different. It is in German and unfortunately not freely available.
Michael K. Klemke, Kersten AuelAbfallwirtschaft
Wissen, Performance-Optimierung,
iX 4/2005, Seite 102>
Also the pages about "Memory Leak Sources" especially "Instances of Inner Classes" are giving an indication, that you should avoid them, at least as long they are having different life cycles.
http://developers.sun.com/learning/javaoneonline/2007/pdf/TS-2906.pdf
By the way, if they weren't a problem, why should anyone use WeakReferences?
But a WeakReference or a SoftReference might be a solution for the above problem. Even I'm not quite sure how XMLEncoder threats them.
In the meantime I avoid the problem, by providing a standard constructor without any initialization code.
Introducing a back ref would lead to code like this:
Class A {
private B b;
A(){
b =  new B(this);
Class B{
private A a;
B(final A a){
this.a = a;
}This would be quite hard for the gc to solve, if at least one Instance is still referred form the outside. Even if there isn't an reference form outside, they are only collected if the gc is running longer and can care for such complex structures. Cause the first check if there isn't any active reference is left, won't be true for such constructs. Normally they are only collected just before an OutOfMemoryException.
I had inherited code form a former college (switched from C++ to Java) which was filled up with this kind of stuff and caused huge memory leaks.
So you should only use such an construct, if you are quite sure that they are having the same life-cycle and such a peace of code is an exemption and you can't avoid it.
Greetings Michael

Similar Messages

  • What will going to happend with app that are not ready for IOS 5?

    What will going to happend with app that are not ready for IOS 5?

    Most applications will work just fine.  I typically have 150 or so apps installed, and typically only 1 or 2 will "break".  The vast majority of apps will continue to operate just as well as before if not better.  iOS developers are privy to beta testing the upcoming OS, so the week or so before and after the official release you'll see a larger number of apps needing to be updated than normal.  Last night I updated 23 apps, and you'll see alot over the next week or two getting updates.  Most are making minor changes to take advantage of new APIs, or add a new feature based on a new function of the OS (like twitter integration into the OS for example).  Very few apps, (maybe 3-4 percent??) actually are getting updated because they're broken, but there will be a few.  Most of the time, any apps that would break will have already been addressed in an update prior to the release of the new OS, and you've probably already updated that app so that it will work seamlessly and perfectly after the update hits.

  • HT201272 What is it with songs that are not from the itunes store, but are coming from cd's and other download sources that all of a sudden do not play on my iphone and have a red stop button in a red round circle around them, behind the title?

    Songs that I have had previously downloaded from various other sources, but NOW ALL of a sudden they DO NOT PLAY on my IPHONE and DISPLAY a RED STOP BUTTON in a red round circle next to the title.  Everytime I click on it it DOESNT play.   What happen???? How can i get them to play.,   Why should i have to pay for the songs, and why are they in the ITUNES store and not in my regular playlist.

    Amazing steps you've done so far! The great news is this is very unlikely an issue with your iPhone.
    I've run into a similar issue lately as well. I narrowed it down to one song that was causing 30 songs not to sync. I removed the song from the sync list (unchecked it) and all 29 songs were able to sync.
    You may be running into a similar issue. This may be a problem with this version of iTunes, an issue with one song or a group of songs; hard to know for sure. It's important to narrow down and isolate the cause. Most imporantly get that music back on there!
    The way to narrow down the casue add just a few songs at a time (even 1, just to get that first sync finished). Manually syncing is what you'll need here.
    Plug in your iPhone, on the Summary screen (shows a picture of your iPhone, the iOS version, Restore iPhone....; etc). Under the Options area at the bottom choose to Manually Manage Videos and Music then choose Apply in the lower right. The music that's on your iPhone now should be removed from your iPhone now. You're now able to sync music manually.
    The link below explains how to drag the songs from the iTunes library on the computer on to your iPhone which will start the sync. Add just one song just to see if you can get 1 of those hundreds of songs on there. If you can, awesome! Keep adding until you find the song or group of songs that are causing this issue.
    http://support.apple.com/kb/HT1535
    Please let me know how things are going.
    Cheers!

  • How to enqueue a table with fileds that are not primary keys

    Hi,
    I am using the FM view_enqueue in order to lock a standard table. Now , the requirement is to restrict the lock based on compnay code.
    Since this is not a primary key in table veiav , I am unable to do this . More over, the development has to be done in a enhancement point.
    Below is the code:
    wa_VIMSELLIST-viewfield = 'NUMMBUKRS'.
    wa_VIMSELLIST-operator = 'EQ'.
    wa_VIMSELLIST-value = dd_bukrs-low.
    wa_VIMSELLIST-ddic = 'B'.
    APPEND wa_VIMSELLIST to lt_VIMSELLIST.
    if sy-tcode = 'VE01'.
    CALL FUNCTION 'VIEW_ENQUEUE'
      EXPORTING
       ACTION                     = P_ACTION
      ENQUEUE_MODE               = 'E'
       view_name                  = P_VIEW_NAME
       ENQUEUE_RANGE              = 'X'
    TABLES
       SELLIST                    = lt_VIMSELLIST
    EXCEPTIONS
       CLIENT_REFERENCE           = 1
       FOREIGN_LOCK               = 2
       INVALID_ACTION             = 3
       INVALID_ENQUEUE_MODE       = 4
       SYSTEM_FAILURE             = 5
       TABLE_NOT_FOUND            = 6
       OTHERS                     = 7

    HI,
    Make use of control-Break events.
    LOOP  ..................
    AT NEW company code.
    call FM ENQUEUEXXXXXXXXXXX
    ENDLOOP

  • Can you share files in the cloud with people who are not on the team?

    Just wondering if you can share files with people that are not on the team. The paid for team members.

    They have not upgraded to iOS 5

  • Is there a way to create a project with custom audio settings that are NOT only "Stereo" or "Surround"?

    Is there a way to create a project with custom audio settings that are NOT only "Stereo" or "Surround"?
    Thanks!
    -Adrian

    the old apps are on my computer but they have had upgrades since they were put on the ipod originally.  you think you would get a warning about this when you restored. I was not worried about losing the progress of the apps but i would have been worried about the app it self!!!!!

  • Since changing our computer I have been unable to download ebooks to my Reader Library I get a message Some file types associated with EPUB files are not associated with Reader Library; Waterstones suggest that I may have accidentally created a new Adobe

    When I try to download them from the Waterstones website I get a message saying:
    ‘Some file types associated with EPUB files are not associated with Reader Library.  Do you want to associate them now?  When I reply yes I get another message; ‘Configuration error unable to update EPUB files check network firewall and try again’.
    The ‘books’ are saved in the Download directory and I can’t transfer them from there to my E-Reader. I have not had any problems before, it was very simple; I saved the download and it automatically went into the Reader Library.
    I contacted HP and they said it is a software error and suggested I contact Waterstones.  I contacted Waterstones Customer Support and got the following response:
    As the error message is specifically mentioning the firewall it does sound like something in the firewall settings is stopping the download from taking place correctly. However, the files should not be being saved to the Download folder. It would be worth trying again by going to your Digital Order History on your Waterstones.com account and pressing the download button, and then making sure to press "Open" not "Save". When you press Open rather than Save it should give the option to open the file with Adobe Digital Editions. If the firewall message still comes up then I'm afraid something is blocking it on your end.
    If the above "Open" download method works but you then still get an error message it could possibly be that you have accidentally created a new Adobe ID when setting up on the new computer, rather than signing in with your old Adobe ID. It would be worth trying the aforementioned download technique again first, but if problems did still persist it would be worth calling Adobe themselves on 0207 365 0735, as they should be able to sort out any account issue.
      In response to the first para of Waterstones email I already do what they suggest I do press ‘Open’ not ‘Save’ but I don’t get the open with Adobe Digital Editions (we have installed Adobe Digital Editions on the new computer. Waterstones say we may have ‘accidentally created a new Adobe ID when setting up the new computer’ does that mean that we shouldn’t have installed Adobe Digital Editions on the new computer as it would have already been there? How do I sign in with my old Adobe ID? 

    Hi all after attampting to get some supoport from adobe by phone.... nice people infurating policys as far as support for digital editions or DRM is conserned... However I got no where with support.
    I ended up instaling Digital editions on my desktop PC and going through the motions of registering and borrowing a book then returning it. Then I trying on my iPad, Bluefire worked, Over drive did not so I completely removed Overdrive and reinstalled and re registered. all working now.
    Maybe some one at adobe did something. Maybe the install of the adobe DE client on a PC corrected what ever was out of wack with my account. Mayby the server that my account lives on did a scan disk and corrected a bad clustrer.
    What ever happend My account is actiove and working again. hope this helps others.

  • I can't texted people on iMessage that are not registered with iMessage

    hello,
    I have my iphone, ipad and mac book pro all link together with imessage my phone works fine but if i want to text a person from my mac book or my ipad that are not using an apple product it says the number is not registered with imessage how can i send regular texted with my mac book or ipad.
    thank you

    Hello there, DJ Jason B.
    The following Knowledge Base article provides clarification about how Messages works and which options are available:
    iOS: Using Messages
    http://support.apple.com/kb/ht3529
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • HT1349 I'll be able to store and share different files that are not page,numbers or keynote, like I'd with idisk?

    I'll be able to store and share different files that are not page,numbers or keynote, like I'd with idisk?

    Not going to happen the way you want it to.
    When you add a gift card balance to the Apple ID, it's available for the Apple ID.
    Probably best to create unique Apple ID's for each... this will also make things easier in the future as purchases are eternally tied to the Apple ID they were purchased with.

  • After clearing cash on mac applications won't lunch any more..I tried to delete apps like VLC player with app cleaner and again download and instal new but it's the same..goes for all apps that are not originally part of Yosemite. Please advise me?!

    After clearing cash on my mac ( Go to folder: ~/Library/Caches and clear all, than to Library/Cashes and clear all again) applications won't lunch any more..I tried to delete apps like VLC player, firefox.. with app cleaner and again download and install the new one but it's the same..goes for all apps that are not originally part of Yosemite. I have done this cash clean up very often on Maverick without any problems. This time I done it again because I could not open my web site, the server has blocked me and I was trying everything including deleting cash from mac. Please advise me what to do..?!? Thanks in advance.

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • I have a lot of contacts in my phone that are not mine. In addition, my contacts are showing up on peoples devices that I do not associate with. Why is this happening?

    I have a lot of contacts in my phone that are not mine. In addition, my contacts are showing up on peoples devices that I do not associate with. Why is this happening?

    Hey Raffiecat,
    Thanks for the question. If your iPod is setup to manually manage content, you can add content from multiple libraries:
    Managing content manually on iPhone, iPad, and iPod
    http://support.apple.com/kb/ht1535
    When manually managing content, you can add content from multiple libraries to your iPod or iPad. Even when manually managing music, some content may be available from only one library at time. This includes all content on iPhone and video content on iPod and iPad.
    You can also learn which content you can import to your new computer from your iPod:
    iTunes: Transferring media from your iPhone, iPad, iPod touch, or iPod
    http://support.apple.com/kb/HT1209
    Or, if you still have access to the previous computer, you can transfer your iTunes Library:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT4527
    Thanks,
    Matt M.

  • I've been given under warranty what us supposed to be a new iPhone 5. When I try and restore it from my iCloud it keeps asking me to sign in with two other Apple ID's that are not know to me. Why is this?

    I've been given under warranty what us supposed to be a new iPhone 5. When I try and restore it from my iCloud it keeps asking me to sign in with two other Apple ID's that are not know to me. Why is this?

    Adding to KC7GNM's remark (with which I agree), the iPhone 5 you received is very likely refurbished.  It is not brand new out-of-the-box, never before used.

  • Calculate Results As Average of Detailed Values That Are Not Zero... with hiearchies doesn't work

    Hi all,
    For the key figures, the option of "Calculate Results As Average of Detailed Values That Are Not Zero, Null, or Error" works fine for characteristics drilldown without hierarchies, but with hierarchies it simply doesn't work; instead of calculate the overall result as average, the system calculates it as SUM. It works like the option "Nothing Defined" where the results provided by the analytic engine are displayed. No local calculation takes place.
    How can I do to display the overall result of hierarchical drilldown of a characteristic as an average?
    Many thanks in advance!
    Abraham

    It is usually best to just keep it as simple as possible.  What do you think the code in the OR Array Elements does?  I imagine it is just a simple FOR loop with a variable to keep the latest OR.  So I would do what GerdW just showed with the FOR loop.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Ipad with ios5 shows only 1000 emails. Would like to see all that are not deleted.

    pad with ios5 shows only 1000 emails. Would like to see all that are not deleted. iCloud turned off for Mail. Using Outlook on MacBook.

    Just a historical note of interest, Yahoo Mail was one of the first IMAP Push providers on the original iphone, so they did at one time support IMAP. My guess is you will have to get the server settings from tech support, which you are paying for.
    But the gmail app is called gmail :-) and the technology that allows you to link it to a domain is known as google apps. (www.google.com/apps).
    But I would call Yahoo tech support and ask them what the proper way to set it up on an ipad or iphone is.
    If you built your website using Yahoo tools (ie. their website builder), you may find it difficult to move.
    The appropriate place to discuss moving web hosts is here. www.webhostingtalk.com
    Site5 was able to migrate my clients' sites for free from a non-Yahoo host, although if you do want e-mail make sure you specify that in the notes field. (MX)
    www.site5.com
    --Sam

  • We have some 3rd generations iPod touches that are note syncing with the computer we have. The original computer that the ipods was synced to is gone. We downloaded the itunes to the new computer and logged on as the same account and it won't sync.

    We have some 3rd generations iPod touches that are note syncing with the computer we have. The original computer that the ipods was synced to is gone. We downloaded the itunes to the new computer and logged on as the same account and it won't sync the applications we have.

    An iPod can pn;y sync wiht one iTunes kibrary and the new computer is a new iTunes library:
    - Transfer iTunes purchases to the computer by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - Transfer other music by using a third-party probgram like one of those dicussed here:
    Copy music from Ipod to new computer...: Apple Support Communities
    - Connect the iPod to the computer and make a backup by right clicking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup

Maybe you are looking for