How to garantee that static data is initialized ?

Hi,
In order to implement the Prototype design pattern in Java I would like to automatically register the subclasses of Prototype to a static array of prototypes in the Prototype class.
In C++ I use a static member in each subclass which is initialized by a static method which registers a prototype in the array of prototypes.
It works in C++ because static data are initialized before main() is called.
In Java though, to guarantee that static data is initialized it seems that each subclass needs to be loaded first which defeats the idea of automatic registration.
Another solution to avoid mentionning subclasses names in the Prototype class would be to rely on the relfection API to get all its subclasses but I did not find any method to do that.
Any hint ?
Thanks in advance

It depends what you call a key. In database systems a
key is part of the data you are looking for.
In order to get a specific prototype one of course
needs information.
Do we disagree here ?If you read the Prototype design pattern you will understand what I mean by key.
The objective of the Prototype pattern is to decouple
client code from which classes implement (or subclass)
the Prototype interface (or abstract class).
I disagree. It is a creational pattern. The intent of the Prototype pattern is to create a prototypical instance and create new objects by copying the prototype. The intent is not to decouple client code.
Let's get back to my original question : is there a
way in Java to register a class automatically to the
collection of prototypes ?
Using the reflection API gives an alternative solution
(thanks to schapel).And I restate my orignal solution as my answer. Why would you want look through all or your classes to determine which ones where prototypes (sorry schapel)?
If you have a known number of prototype subclasses then you can create and intialize them when the Prototype class is loaded.
If not then you can use the key to determine if the prototype has been loaded, if not then the Prototype class can load the class. In this case, with some creativitity, you can create a key that meets your needs.
It seems that you are dependent on the Prototype class containing all of the prototype classes at load time because you are using them to create user interface components. So your client (use interface) is directly coupled to your implementation of the Prototype, exactly what you said the Prototype design pattern incorrectly was intended to do.

Similar Messages

  • I have a macbook pro with a broken video card. How do ensure that my data is completely erased before I sell it ?

    I have a macbook pro with a broken video card. How do ensure that my data is completely erased before I sell it ? Thanks

    1. Connect it to a monitor.
    2. Replace the hard drive.

  • How to add static data in ADF table using ADF 11g?

    Hi
    Can any one tell me how can I add static data in ADF table?
    Thanks

    You can try this one. I created this static table just for viewing purpose.
    Open Create View Object wizard
    Choose, “Rows populated programmatically, not based on a query” which is 3rd radio button option
    In Attribute tab, create some ‘Updatable’ Attributes
    Choose the AppModule in the final step.
    Drag and drop the view object as ADF table.
    Next, programmatically insert data in your backing bean.
            ApplicationModule applicationModule = this.getApplicationModuleForDataControl("TmpTableAppModuleDataControl");
            ViewObject vo = applicationModule.findViewObject("ProgViewObj1");
            Row newRow = vo.createRow();
            newRow.setAttribute("updAttr1", value1);
            newRow.setAttribute("updAttr2", value2);
            vo.insertRow(newRow);If you add this code in buton action you have to add button's partialTriggers to table id.

  • Reinitialization of static data by multiple applets

    Hi,
    I have a problem with initialization of shared static data by multiple applets. I have three applets running inside of different HTML frames in a multi-frame HTML framework. Applets are loaded as JAR files. In addition, every applet has one or two 3rd party JARs listed in the APPLET tag. Applets share the same codebase and run inside the same JVM.
    I use static data to perform the inter-applet communication. This is simply a static list of applet references that is being maintained in the base applet class (all applet classes are inherited from that class). The problem is that when applets get constructed, the static data in the base class sometimes gets reinitialized multiple times. As I understand, the static data should be initialized just once on initial load of the base applet class (applets have the same codebase).
    This problem seems to be caused by the race condition (applets initialize on different threads launched by the browser). Under some circumstances (I change the number and order of JARs, etc.) everything works fine. I can reproduce this problem on both Explorer 5.x and Netscape 4.7 (did not try others). I run applets using native browser's JVM.
    Has anybody had such problem before? Is it caused by the large number of JARs ? Is there any way to guarantee that static data will be initialized once in the multi-applet environment ?
    Thanks,
    hparfen

    Hi,
    Did you find something to solve your problem because I have exactly the same.
    Tony

  • How to send PR & PO data for materials through IDOC in XML

    Hi Experts,
    I am looking for a solution to send open PR & open PO related data for diffrent materials through as IDCO in XML file.
    Scenario is i have to show a report in a 3rd party system for open PR & open PR that too will come after selection some materials. That means select a materials & it will show all the open PO & related data in a report.
    The rough idea for the solution i got is I can save the data in XML file in the system. For this i have to send IDOC. but the problem is there is no message type for PR. IF i am not wrong i can extend the MATMAS05 for a segment that will have PR related info.
    Now what to do with that how to send the IDOC do i need to create another report to send IDOC or i can send the extended one through BD10. I tried it but it shows error message "0 communication idoc sent" so I dont no y such error is coming i think i am not filling the extended idoc. But again my QUestion is how to do that. If anyone have any other solution Please help me out of this.
    Regards,
    Nik

    Hi Alpesh,
    Thanks for your reply.
    My requirement is bit different. i have to send Open PR data for diffrent materials. In a 3rd party application user will search for few materials which will generate a report that will show the PR related data for those material.
    Same thing i have to do for PO & Sales order also.
    Can u please help me to provide the solution how can i proceed for it. U have given the Message type & a bapi how it will help in my issue?
    I got a suggesion from someone that extend message type matmas for PR, PO, SD related data & send the idoc. but i am confused how to pass that much data ina single IDOC.
    Regards,
    Nik

  • How to pull the table data into SAP BI

    hi all,
    i have connected to oracle database and i can see the view of the tables in sap BI.can u please help me out how to see the data inside the table and how to load that table data into info cube.

    Hi Vamshi ,
    In R3 there is a t-code RSDBC through that t-code you make your data source .
    I know you already make a connection between r3 and sql2000.
    in RSDBC in logical system name you enter your connection name,and in table /view u should enter sql table name and make sure the table name which u enter in this text box should be store in sql in capital letters and fields should be in capital letters.
    and generate your data source and execute it it show all the record .
    Thanks for material its really gud
    Ankit modi

  • How to synchronize concurrent access to static data in ABAP Objects

    Hi,
    1) First of all I mwould like to know the scope of static (class-data) data of an ABAP Objects Class: If changing a static data variable is that change visible to all concurrent processes in the same Application Server?
    2) If that is the case. How can concurrent access to such data (that can be shared between many processes) be controlled. In C one could use semaphores and in Java Synchronized methods and the monitor concept. But what controls are available in ABAP for controlling concurrent access to in-memory data?
    Many thanks for your help!
    Regards,
    Christian

    Hello Christian
    Here is an example that shows that the static attributes of a class are not shared between two reports that are linked via SUBMIT statement.
    *& Report  ZUS_SDN_OO_STATIC_ATTRIBUTES
    REPORT  zus_sdn_oo_static_attributes.
    DATA:
      gt_list        TYPE STANDARD TABLE OF abaplist,
      go_static      TYPE REF TO zcl_sdn_static_attributes.
    <i>* CONSTRUCTOR method of class ZCL_SDN_STATIC_ATTRIBUTES:
    **METHOD constructor.
    *** define local data
    **  DATA:
    **    ld_msg    TYPE bapi_msg.
    **  ADD id_count TO md_count.
    **ENDMETHOD.
    * Static public attribute MD_COUNT (type i), initial value = 1</i>
    PARAMETERS:
      p_called(1)  TYPE c  DEFAULT ' ' NO-DISPLAY.
    START-OF-SELECTION.
    <b>* Initial state of static attribute:
    *    zcl_sdn_static_attributes=>md_count = 0</b>
      syst-index = 0.
      WRITE: / syst-index, '. object: static counter=',
               zcl_sdn_static_attributes=>md_count.
      DO 5 TIMES.
    <b>*   Every time sy-index is added to md_count</b>
        CREATE OBJECT go_static
          EXPORTING
            id_count = syst-index.
        WRITE: / syst-index, '. object: static counter=',
                 zcl_sdn_static_attributes=>md_count.
    <b>*   After the 3rd round we start the report again (via SUBMIT)
    *   and return the result via list memory.
    *   If the value of the static attribute is not reset we would
    *   start with initial value of md_count = 7 (1+1+2+3).</b>
        IF ( p_called = ' '  AND
             syst-index = 3 ).
          SUBMIT zus_sdn_oo_static_attributes EXPORTING LIST TO MEMORY
            WITH p_called = 'X'
          AND RETURN.
          CALL FUNCTION 'LIST_FROM_MEMORY'
            TABLES
              listobject = gt_list
            EXCEPTIONS
              not_found  = 1
              OTHERS     = 2.
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          CALL FUNCTION 'DISPLAY_LIST'
    *       EXPORTING
    *         FULLSCREEN                  =
    *         CALLER_HANDLES_EVENTS       =
    *         STARTING_X                  = 10
    *         STARTING_Y                  = 10
    *         ENDING_X                    = 60
    *         ENDING_Y                    = 20
    *       IMPORTING
    *         USER_COMMAND                =
            TABLES
              listobject                  = gt_list
            EXCEPTIONS
              empty_list                  = 1
              OTHERS                      = 2.
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
      ENDDO.
    <b>* Result: in the 2nd run of the report (via SUBMIT) we get
    *         the same values for the static counter.</b>
    END-OF-SELECTION.
    Regards
      Uwe

  • How To Create Table with Static Data

    JDEV 10.1.3
    ADF BC
    ADF Faces
    I am trying to make some simple screen/screenflow diagrams to help flesh out some requirements. To do that, I need to make a table with static data that is not hooked up to a data source (because the data model has not yet been clearly defined, and I'm using the diagrams to help iterate the requirements).
    Is it possible to create a table that shows static data (i.e. a set of rows that does not come from a model data source, but rather is hardcoded.)
    If not, how does one create mock ups without actually implementing the data model?
    Thank you.

    Deepak, what specifically in those 2 links from Amis are useful? Those 2 posts are about bind variables, not static list of values?
    In response to the original poster, I'll attempt to help a little more.
    In the 11g release you can create VOs based on a static list of values. However in your case on 10.1.3, the best method I've found is to create a VO based on a SELECT <columns> FROM DUAL statement. The columns then include your dummy data. If you need more than one row, simply UNION ALL a number of SELECT statements together.
    What I haven't checked, is when you eventually transform the VO based on the SELECT DUAL statement into a VO based on an EO drawing real data from the database, is it an easy process? I recommend you try this out before committing to the approach above. Let us know how you go.
    Regards,
    CM.

  • HT1386 I have an older iPhone (3gs) and need to upgrade to a newer phone (4S).  I need to get my NOTES, CALENDAR, CONTACTS, PICTURES, etc backed up on iTunes so I can get that data loaded onto the new phone.  But not sure how to do that.

    I have an older iPhone (3gs) and need to upgrade to a newer phone (4S).  I need to get my NOTES, CALENDAR, CONTACTS, PICTURES, etc backed up on iTunes so I can get that data loaded onto the new phone.  But not sure how to do that.  When I open iTunes it has a button that say "Back Up iPhone", but I'm not sure what that does.  When I go into the sync options it say I have another user account and asks me if I want to merge of replace. I'm assuming it's trying to tell me I have an older iTunes Library, but don't know that.  Geez, maybe people over 60 shouldn't have iPhones, iTunes just bafles me.

    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf

  • I recently did an update for my iTunes and now when I try to open it, I get an error that says that my data execution prevention is not allowing it to open. How do I fix this issue?

    I recently did an update for my iTunes and now when I try to open it, I get an error that says that my data execution prevention is not allowing it to open. How do I fix this issue?

    Try updating your QuickTime to the most recent version. Does that clear up the DEP errors in iTunes?

  • HT4910 I have a simple question or 2. 1) how can I see what is on my icloud and how do I edit the data if I do not want it on icloud. 2) I have an app that I would like to update data - it doesn't appear to be doing that, how can I fix that? It is the mob

    1) how can I see what is on my icloud and how would I edit the data that is on it?
    2) I am having problems with an app syncing data with pc - how can I fix that? It is mobile noter.

    Welcome to the Apple Community.
    You can see what's in iCloud collectively at settings > iCloud > storage & back up > manage.... You can only edit the data through the appropriate app (contacts, calendars etc)
    For problems with 3rd party apps, contact the developer.

  • How do I access the data saved on my time capsule?  for example, if i try to view my photos it tells me that i have 2.4gb of photos and gives me the option to "view with iPhoto"....but when i click on "view with iPhoto" nothing happens...  thanks!

    how do i access the data stored on my time capsule?  for example, if i try to view a photo, i get the option to "view with iphoto" but when i click on "view with iphoto" nothing happens.  i'm having similar trouble openning up movies, music, etc.  it appears as though the files exist / saved on the time capsule (because i can see how much storage they consume), but i can't open them.  thanks!

    Unfortunately, Apple removed the feature to "browse backups" in Time Machine backups of iPhoto a few years ago.
    You have to restore the entire iPhoto library to a separate location to be able to "see" it, and then choose the specific images that you want use.
    For complete details, see #15 in Pondini's excellent support document Time Machine -- FAQ.  Check the information in the pink box there.
    Frequently Asked Questions

  • I have updated to maverick from mountain lion.initially my mac book pro was snow leopard.the multitrack touch pad swapping the page is not happening in finder,it is only working in safari.please help me how to get that swiping gesture in  finder

    i have updated to maverick from mountain lion.initially my mac book pro was snow leopard.the multitrack touch pad swapping the page to get back to previous page is not happening in finder,it is only working in safari.please help me how to get that swiping gesture in  finder

    Hi..
    I repled to you here >  https://discussions.apple.com/message/25598596#25598596
    Please do not start duplicate topics. It makes it that much harder to assist you.

  • I have made a burn folder with photos exported from I-photo.  It now shows in information, that the date is created and modified is different from the original digitized date.  How can I get the original date to show in the info from Finder?

    I have made a burn folder with photos exported from I-photo.  It now shows in information, that the date  created and modified is different from the original digitized date.  How can I get the original date to show in the info from Finder?

    The Finder reports File information. The date and time of the photo are in the Photo's Exif metadata. The Finder has no awareness of this. All photos apps on any system do.
    Regards
    TD

  • How to create a .mdf SQL Server database from a Data-Tier Application file that has data?

    This is a noob question, though I do use SQL Server databases all the time with Entity Framework when I code in C# using Visual Studio 2013.  The development environment is found below at [A].  I am trying to make a clone of a SQL Server 2008 R2
    database (.mdf)  that exists online.  I can read, connect and work with this database in Visual Studio 2013, but I wish to make a local copy of the database, as an .MDF file.  Somewhere in my notes I have a way of creating a local copy from
    an online database when using Visual Studio but I forgot how (it seems, reviewing my notes, that it deals with ADO.NET which is deprecated in Visual Studio 2013 these days, or so it seems).  So I'm looking for another way.  What I did was create
    (or export) a "Data-Tier Application File" from the online SQL Server database, with data, and it seems to have worked in that this Data-Tier Application file exists on my hard drive and seems to have data in it ("SQL Server Replication Snapshot"
    is the format it seems).  It contains skeleton code to create a database, but when I tried to execute it with SQL Server 2014 Management Studio, I got a bunch of errors.
    So my question is:
    1) Can I somehow create a .MDF SQL Server Database from an Data-Tier Application file that has data?  What tool do I use?  I saw this link, http://social.technet.microsoft.com/wiki/contents/articles/2639.how-to-use-data-tier-application-import-and-export-with-a-windows-azure-sql-database.aspx 
    and it relates to Azure, but is there a tool for C#Visual Studio 2013, standalone?
    2) If there's an easy way to create a .mdf SQL Server Database file from an online file, within SQL Server Management Studio?  I don't think so, since it would require Administrator permissions on the online server, which I don't have. I have permission
    to read, update, delete the online database file, but strangely not to download it (the service I use has a tool for backup, but not for download).
    3) same question as 2), but for Visual Studio 2013?  I don't think so, since I notice none of the templates even mentions ADO.NET anymore, but instead they go with Entity Framework.  Using EF I can of course do anything I want with the online database
    (CRUD), but it remains online.  Maybe there's a switch to make a local copy?  I guess I could write a short program to suck all the data out of the online database and put it into a new, duplicate database having the same tables, that I create on
    my localhost, but my question here is if there's an easier way than this, maybe a tool or command I can run from inside Visual Studio?
    Any advice on any of the above questions is appreciated.
    Thank you,
    Paul
    [A] Microsoft Visual Studio Professional 2013
    Version 12.0.21005.1 REL
    Microsoft .NET Framework
    Version 4.5.51641
    Microsoft Web Developer Tools 2013   2.0.40926.0
    SQL Server Data Tools   12.0.30919.1
    Microsoft SQL Server Data Tools
    Windows Azure Mobile Services Tools   1.0
    Windows Azure Mobile Services Tools

    Thanks but these links are too general to help.
    "2. what do you mean by online file?" - I mean the SQL Server database file is on a remote web server that I rent from, but I am not the administrator of.  I can access my database using SQL Server Authentication, but nothing more.
    Paul
    What do you mean by too general? It explains on how you can use data tier application to create and deploy databases
    May be this will help you to understand better
    http://www.databasejournal.com/features/mssql/article.php/3911041/Creating-Data-Tier-Applications--in-SQL-Server-2008-R2.htm
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • My phone is not working properly help

    hello people i got my cuz's old phone which is the curve 8900 and it totally lost all signal and i couldnt get it back until i asked a professional about it and i got it back. she said i should update the software but it i cant find a update for it.

  • Safari crashes on launch after Lion reinstall

    This is on a friend's mid 2010 Macbook Pro running Lion 10.7.5. The user had Safari on her desktop and I trashed it mistakenly thinking there was another copy in Applications. There was not. To get Safari back, I reinstalled Lion. This gave us Safari

  • "paste profile mismatch" ... what rendering intent is used?

    When using edit > convert to profile... one can choose 1 of 4 rendering intents (Photoshop CS3). Does anyone know which 2 of the 4 are used in the following situation ? paste profile mismatch You are pasting content copied from a document with a diff

  • Can anyone explain what the Samsung Galaxy 3 update was today?

    My Galaxy 3 updated today, and it says to go to verizon site for help, but I cannot find any info on what the update was for.  Can anyone help?

  • Special characters converted in wrong in Upper case ?

    Hello, In material description , some characters such as µ when converted into upper case it will be 'M' in stead of 'µ' . This is in SAP ECC unicode . But it's ok in R/3. So in this case, Is there any solution for this problem ? Thanks