Alternative to "javafx.io.Resource" and "javafx.io.Storage" in JavaFX 2.2?

Silverlight has a sandboxed file storage location as well as a facility to store key/value pairs.
It looks like JavaFX had some similar tools in 1.x, but they appear to be gone in 2.2.
Can anyone point me toward an alternative for both services?
Thanks,
Michael

Here you go.... I think this is almost reusable as is (my method logging methods need to be removed, and the directory for standalone persistence needs to be changed for your implementation).
PersistenceApi
public interface PersistenceApi {
    public InputStream getInputStream(String fileName);
    public boolean createNewFile(String fileName);
    public OutputStream getOutputStream(String fileName);
}PersistenceManager.... its like a factory, responsible for determining whether or not in Webstart mdoe or not and instantiating the correct implementation of PersistenceApi (not thread safe)
public class PersistenceManager {
    //static variables
    private static PersistenceApi persistence;
    //public functions
    public static PersistenceApi getPersistenceApi() {
        if (persistence == null) {
            String homeDir = null;
            try {
                homeDir = System.getProperty(game.CONSTANTS.STANDALONE_INSTALL_DIR_SYSTEM_PROPERTY);
            } catch (SecurityException e) {
                game.Log.debug("in PersistenceManager.getPersistenceApi, got exception");
            if (homeDir != null) {//...in standalone mode
                game.Log.debug("in PersistenceManager.getPersistenceApi, in standalone mode, homeDir == " + homeDir);
                persistence = new StandalonePersistence();
            } else {//...in web start mode
                game.Log.debug("in PersistenceManager.getPersistenceApi, in web start mode");
                persistence = new JnlpPersistence();
        return persistence;
}JnlpPersistence
public class JnlpPersistence implements PersistenceApi {
    //private variables
    private URL codeBase = null;
    private static PersistenceService persistenceService = null;
    //constructors
    JnlpPersistence() {
        setCodeBase();
        makePersistenceService();
    //private functions
    private void makePersistenceService() {
        if (persistenceService == null) {
            try {
                persistenceService = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService");
            } catch (UnavailableServiceException e) {
                game.Log.debug("in JnlpPersistence.makePersistenceService(), got exception while getting instance of PersistenceService.  " + e.getMessage());
        assert persistenceService != null;
    private void setCodeBase() {
        if (codeBase == null) {
            BasicService bs;
            try {
                bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
                codeBase = bs.getCodeBase();
            } catch (UnavailableServiceException e) {
                game.Log.debug("in JnlpPersistence.setCodeBase(), got exception while getting codeBase from.  " + e.getMessage());
        assert codeBase != null;
    //public functions
    @Override
    public InputStream getInputStream(String fileName) {
        String thisMethodsName = "in JnlpPersistence.getInputStream(), ";
        URL newFileUrl;
        FileContents newFc;
        try {
            newFileUrl = new URL(codeBase.toExternalForm() + fileName);
            newFc = persistenceService.get(newFileUrl);
            if (newFc == null) {
                game.Log.debug(thisMethodsName + "filecontents is null for filename = " + fileName);
                return null;
            if (!newFc.canRead()) {
                game.Log.debug(thisMethodsName + "filecontents is not readable for filename = " + fileName);
                return null;
        } catch (Exception e) {
            game.Log.debug(thisMethodsName + "caught exception while getting filecontents for filename = " + fileName + ".  " + e.getMessage());
            return null;
        InputStream is;
        try {
            is = newFc.getInputStream();
        } catch (Exception e) {
            game.Log.debug(thisMethodsName + "caught exception while getting input stream for filename = " + fileName + ".  " + e.getMessage());
            return null;
        return is;
    @Override
    public boolean createNewFile(String fileName) {
        URL newFileUrl;
        try {
            newFileUrl = new URL(codeBase.toExternalForm() + fileName);
            persistenceService.create(newFileUrl, CONSTANTS.MAX_PROFILE_FILE_SIZE);
        } catch (Exception e) {
            game.Log.debug("in JnlpPersistence.createNewFile, got exception while creating file with name = " + fileName + ".  " + e.getMessage());
            return false;
        return true;
    @Override
    public OutputStream getOutputStream(String fileName) {
        String thisMethodsName = "in JnlpPersistence.getOutputStream, ";
        URL newFileUrl;
        FileContents newFc;
        try {
            newFileUrl = new URL(codeBase.toExternalForm() + fileName);
            newFc = persistenceService.get(newFileUrl);
            if (newFc == null) {
                game.Log.debug(thisMethodsName + "filecontents is null for filename = " + fileName);
                return null;
            if (!newFc.canWrite()) {
                game.Log.debug(thisMethodsName + "filecontents is not writeable for filename = " + fileName);
                return null;
        } catch (Exception ex) {
            game.Log.debug(thisMethodsName + "caught exception while getting filecontents for filename = " + fileName + ".  " + ex.getMessage());
            return null;
        OutputStream os;
        try {
            os = newFc.getOutputStream(true);
        } catch (Exception e) {
            game.Log.debug(thisMethodsName + "caught exception while getting OutputStream for filename = " + fileName + ".  " + e.getMessage());
            return null;
        return os;
}StandalonePersistence
public class StandalonePersistence implements PersistenceApi {
    //private variables
    private final String SAVE_DIR = ".tm" + CONSTANTS.PATH_DELIMITTER;
    private String savePath;
    private File savePathFile;
    //constructor
    StandalonePersistence() {
        savePath = System.getProperty(game.CONSTANTS.STANDALONE_INSTALL_DIR_SYSTEM_PROPERTY) + CONSTANTS.PATH_DELIMITTER + SAVE_DIR;
        savePathFile = new File(this.savePath);
        if (savePathFile.exists() == false) {
            savePathFile.mkdir();
    //public functions
    @Override
    public InputStream getInputStream(String fileName) {
        String thisMethod = "in StandalonePersistence.getInputStream, ";
        File file = new File(savePath + CONSTANTS.PATH_DELIMITTER + fileName);
        if (file.exists() == false) {
            game.Log.debug(thisMethod + "file does not exist");
            return null;
        if (file.canRead() == false) {
            game.Log.error(thisMethod + "file is not readable");
            return null;
        InputStream is = null;
        try {
            is = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            game.Log.error(thisMethod + "got exception while getting inputStream. " + e.getMessage());
        return is;
    @Override
    public boolean createNewFile(String fileName) {
        File file = new File(savePath + CONSTANTS.PATH_DELIMITTER + fileName);
        try {
            return file.createNewFile();
        } catch (IOException ex) {
            game.Log.error("in StandalonePersistence.createNewFile, got exception while creating file " + fileName + ".  " + ex.getMessage());
            return false;
    @Override
    public OutputStream getOutputStream(String fileName) {
        String thisMethod = "in StandalonePersistence.getOutputStream, ";
        File file = new File(savePath + CONSTANTS.PATH_DELIMITTER + fileName);
        if (file.exists() == false) {
            game.Log.debug(thisMethod + "file does not exist");
            if (this.createNewFile(fileName) == false) {
                return null;
            game.Log.debug(thisMethod + "created new file");
        if (file.canWrite() == false) {
            game.Log.error(thisMethod + "file is not writable");
            return null;
        OutputStream os = null;
        try {
            os = new FileOutputStream(file);
        } catch (FileNotFoundException e) {
            game.Log.error(thisMethod + "got exception while getting outputStream. " + e.getMessage());
        return os;
}Edited by: jmart on Aug 30, 2012 11:17 AM
Edited by: jmart on Aug 30, 2012 11:20 AM

Similar Messages

  • Running JavaFX as client and connecting though Database

    Hello,
    I am searching for the feasibility of JavaFX for a client.I want to run JavaFX on client machine(can be multiple clients) and through some middle layer I want to connect it through database server etc.
    How is this possible.?

    csh wrote:
    I guess you find plenty of samples in the net on how to use a WebService from a pure Java client.If one knows to look for the JAX-RS (reference implementation: Jersey) or JAX-WS (reference implementation: Metro) APIs. I'd prefer JAX-RS because it is very easy to use, IF you take the time to read up about RESTful webservices.

  • Alternative resources and alternative modes with CTM

    Hi everybody,
    we are trying to figure out, whether CTM supports alternative resources and alternative modes.
    Does anyone know if it is possible or has even implmented the functionality?
    Thank you in advance for your help.
    Best regards
    Mitch

    Hi Mitch,
    It depends on what CTM profile you are using. 1) Bucket based or 2) Time continuous.
    1) Bucket based : You will have to use SNP PDS and SNP PDS do not support alternative modes.
    Alternative resources are not supported at all in SNP. 
    As an alternative, You can use the BAdi /SAPAPO/CURTO_SNP with CIF_IMPORT parameter to create multiple PDSes in case there is alternative resource in routing/recipe.
    2) TIme continuous: You will use CTM PDS.
    PPDS PDS supports alternative resources. I am entirely not sure about CTM PDS.
    I will check out, if I can find out.
    Which CTM profile you are using?

  • Javafx 2.0 and ejb 3.x

    Hi,
    Does javafx 2.0 supports ejb injection. I am trying to inject ejb using annotation in fxController. It is simply not recognizing class ejb. Is it supposed to be done in old fashioned way using Service Locator.
    Could someone direct me to the literature related with javafx 2.0 and ejb.
    Thanks
    Sarad

    Hi Sarad,
    Injecting stuff (whether it is via EJB or Spring or whatever) usually requires that the bean is loaded (i.e. newed) via some context. In FXML the Controller is created via the FXMLLoader so unfortunately you can't easily inject into it. This is a bit of a problem for a few of us and there is an open feature request being considered for future releases: http://javafx-jira.kenai.com/browse/RT-16724. You may want to up-vote if this is important for you.
    At this stage of the game I would suggest your best bet is to have your controller look up your EJB via JNDI (as per the unit test in http://openejb.apache.org/3.0/injection-of-other-ejbs-example.html) and then have your controller delegate calls onto the EJB. You will likely want to thread the calls onto this as well, using JFX's Task or Service.
    Hope that helps,
    zonski
    Did you find this answer useful? If so, please mark as 'Correct' or 'Helpful'.

  • SQL 2012 SP1 - How to determine a query that causes Error 8623 in SQL Log: The query processor ran out of internal resources and could not produce a query plan. This is a rare event...

    We are getting multiple 8623 Errors in SQL Log while running Vendor's software.
    How can you catch which Query causes the error?
    I tried to catch it using SQL Profiler Trace but it doesn't show which Query/Sp is the one causing an error. 
    I also tried to use Extended Event session to catch it, but it doesn't create any output either.
    Error:
    The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that
    reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
    Extended Event Session that I used;
    CREATE EVENT SESSION
        overly_complex_queries
    ON SERVER
    ADD EVENT sqlserver.error_reported
        ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
        WHERE ([severity] = 16
    AND [error_number] = 8623)
    ADD TARGET package0.asynchronous_file_target
    (SET filename = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xel' ,
        metadatafile = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xem',
        max_file_size = 10,
        max_rollover_files = 5)
    WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
    GO
    -- Start the session
    ALTER EVENT SESSION overly_complex_queries
        ON SERVER STATE = START
    GO
    It creates only .xel file, but not .xem
    Any help/advice is greatly appreciated

    Hi VK_DBA,
    According to your error message, about which query statement may fail with error message 8623, as other post, you can use trace flag 4102 & 4118 for overcoming this error. Another way is looking for queries with very long IN lists, a large number of
    UNIONs, or a large number of nested sub-queries. These are the most common causes of this particular error message.
    The error 8623 occurs when attempting to select records through a query with a large number of entries in the "IN" clause (> 10,000). For avoiding this error, I suggest that you could apply the latest Cumulative Updates media for SQL Server 2012 Service
    Pack 1, then simplify the query. You may try divide and conquer approach to get part of the query working (as temp table) and then add extra joins / conditions. Or You could try to run the query using the hint option (force order), option (hash join), option
    (merge join) with a plan guide.
    For more information about error 8623, you can review the following article.
    http://blogs.technet.com/b/mdegre/archive/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • TREX Installation, Error in phase - Install TREX web resources and finalize

    Hello,
    Platforms:
    SO - Win 2008 (R2) X64
    During the last phase "Install TREX web resources and finalize instance" in installation process of TREX 7.1, it show me a weird error...
    It seems that was some problem during the creation of sap start service of this new instance... but that is weird because I checked at services.msc and that service SAPTSM_02 and nothing seems wrong with it, it seems that was well created and it is in Started mode!... I checked firewall settings (all of them are in OFF status), I also checked CUA settings (is stopped)...
    I searched for this error and I found the following SDN forum:
    SAPNW EHP1 SR1
    I already press the retry button but it always show me the same error.
    During this phase the SAPInst window show some information and in there I see this two:
    creating sap start service of instance TSM/TRX02...
    service not correcttly installed.
    It is very weird thing!
    I will post some log files such as sapstartsrv.exe and sapinst.log.
    sapstartsrv.exe:
    Test call to Service failed: 80080005
    CO_E_SERVER_EXEC_FAILURE: Server execution failed
    Service not correctly installed
    sapinst.log:
    INFO 2012-01-20 16:29:24.446
    Creating file C:Program Filessapinst_instdirNW702STANDALONETREXCIsapstartsrv.exe.log.
    INFO 2012-01-20 16:29:24.457
    Output of F:usrsapTSMTRX02exesapstartsrv.exe -stdin is written to the logfile sapstartsrv.exe.log.
    WARNING 2012-01-20 16:31:41.182
    Execution of the command "F:usrsapTSMTRX02exesapstartsrv.exe -stdin" finished with return code -1. Output:
    Test call to Service failed: 80080005
    CO_E_SERVER_EXEC_FAILURE: Server execution failed
    Service not correctly installed.
    ERROR 2012-01-20 16:31:41.380
    MOS-01011  'F:/usr/sap/TSM/TRX02/exe/sapstartsrv.exe' returned with '-1'.
    ERROR 2012-01-20 16:31:41.381
    MOS-01011  'F:/usr/sap/TSM/TRX02/exe/sapstartsrv.exe' returned with '-1'.
    ERROR 2012-01-20 16:31:41.470
    FCO-00011  The step createService with step key |TREX_NW_CI_MAIN|ind|ind|TREX|ind|0|0|TREX_MAIN|ind|ind|TREX|ind|0|0|createService was executed with status ERROR ( Last error reported by the step :'F:/usr/sap/TSM/TRX02/exe/sapstartsrv.exe' returned with '-1'.).
    Can you help me please, how can I solve this?
    Kind regards,
    JDimas

    Hello Arjun Venkateswarlu,
    1).Is your Windows Firwall is enabled ? Disable the windows Firewall and also restart SAPinst
    - As I said the windows firewall is disable (OFF)
    2). Make sure that <sid>adm belongs to the local admins or Better provide the domain admin rights to the id which you are using for installation if it is domain installation.
    - All the created users during this installation belongs to local admins. This isn´t a domain installation!
    3). Try Restarting the installation by stopping and starting Windows and restart SAPINST and coninue Old Installation again.
    - I already did that... but it continues to show me the same error!
    Any other tip?
    Kind regards,
    JDimas

  • Hello everybody,i've forgot my apple password and i wanted to reset it to a new one but i also forgot the security question and the alternative email does not work and i am really need to log in to my apple i d because my iPhone 4g won't  let me access it

    Hello everybody,i've forgot my apple password and i wanted to reset it to a new one but i also forgot the security question and the alternative email does not work and i am really need to log in to my apple i d because my iPhone 4g won't  let me access it so anyone can help me with it or can i put another apple id to it without putting the first password?THANKS FOR YOUR HELP.

    Then call AppleCare and talk to someone in account security.

  • Project Online - Can't Delete Resource and User from Delete Enterprise Objects

    I would like to link a resource account to a user account but I ran into an error: "The resource account
    is already in use.".  This is a known issue which I attempted to resolve by following the instructions in KB2881398.
    However when deleting the selected resource from Delete Enterprise Objects I get a message indicating success ("The
    selected Resources and Users have been deleted.") but the duplicate user is still in the listing in Delete Enterprise Objects and when attempting to link the remaining resource to a user logon account I still get the error
    "The resource account is already in use."
    Why is the user not deleted even though Delete Enterprise Objects reports success and how can I delete these duplicates to be able to successfully link the account?

    Hi,
    This might be due to your Exchange Sync issue, where your project workspace is unable to delete that user from local DB. Try following steps to diagnose the problem:
    1) Go to your Resource Pool, DELETE a resource.
    2) While resource is being Deleted, open another window 
    Server Settings -> Manage Queue Jobs
    3) Here you can view the progress of your current Resource Deletion update, check if all goes smooth and your Resource is deleted successfully by showing process completion 100% :
     ( to view any error look at the
    last column of table on Manage Queue Job page)
    4) Cross check your Resource by running Resource Availability Report.
    Basically this will give you a fair idea of your resource deletion problems and how system is responding to it.
    Regards

  • One user: "Safari is missing important resources and should be reinstalled"

    I have just installed the Safari 3 Beta and when I open the browser it say:
    "Safari is missing important resources and should be reinstalled."
    And its on all sites I try to visit.
    I have tried to (un)install it 3 times and same problem.
    And the scary: Its only on one user. (There not are administrator)
    I have the (nearly) same problem when I'd installed FireFox 2.
    I solved the problem by create a new user, but I really won't do that again. (Have a lot of stuff to move)
    - Josso
    PS: And sorry for my bad english, I'm a boy from Denmark - Europe.
    Windows Vista Home Premium   Windows Vista  

    I have marked my message as "Solved" cause its now solved, but I get a new problem:
    Safari can’t open the page “http://www.apple.com/startpage”. The error was: “unknown error” ((null):10022) Please choose Report Bugs to Apple from the Help menu, note the error number, and describe what you did before you saw this message.
    I think I saw the problem in another thread so I'll searching.
    Thanks for help. =D

  • Safari is missing important resources and should be reinstalled

    I'm getting the following message in Safari with a "clean" install of Leopard.
    Safari is missing important resources and should be reinstalled.
    I can get to some pages, but not others. Any idea why I'd be getting this? Google searches report this as being seen in Safari for Windows and non-US instances, I'm definitely in the US and not using it in Windows.

    I am experiencing the same problems on my old iMac. (G4 longneck). It will not open any browser window and asks for a clean install. The problem is how to install? Go to the product page on the Apple site and there is only a download for the Windows version.
    Very frustrating.

  • TS1424 I have downloaded a series of prison break but 3 episodes are saying "you do not have permission to access the requested resource" and "this episode can not be downloaded at this time" any idea how to fix this please??

    I have downloaded a series of prison break but 3 episodes are saying "you do not have permission to access the requested resource" and "this episode can not be downloaded at this time" any idea how to fix this please??

    I got this error with my iPad 3, my wife's iPhone 4, but not with my iPhone 4s.

  • Alternative data source for EO and VO

    It is usually the requirement to customize the Entity Objects and View Objects so that they can work with data sources different than database schema objects (tables, views,...), some examples are Web Service or Oracle Coherence cache.
    I have developed mini projects using both data sources mentioned, by overriding relevant methods in the implementation EO and VO classes. There is one limitation I realize when developing these projects. Although both the EO and VO rely directly and completely on the alternative data sources (Web Service and Coherence), still there must be a schema object existing in the local database to back the EO and VO. This is because I still have to call super methods from ViewObjImpl and EntityImpl, and these methods are still doing some operations with the schema objects, and without these objects, ORA-00942: table or view does not exist will be thrown.
    For example, after overriding executeQueryForCollection in ViewObjImpl to take data from web service, it is still necessary to call super.executeQueryForCollection so that data will actually appear on the web page, and without the schema objects, this method will throw ORA-00942.
    My question is, is there any way to completely eliminate the need of schema objects in EO and VO? I know the answer (if exist) will be complicated but I'm willing to explore.
    Thanks.

    Thanks Timo,
    I figured out how to achieve this.
    Basically when creating the EO, I did not specify the schema object in the first step, and for each attribute that I created in the wizard, I also unchecked the checkbox "persistent". I could then create VO based on this EO and override all the necessary methods in the EO and VO so they can do CRUD operations via Web Service.
    In the case of only creating an VO (read-only, for retrieving/reading data only), I could also mark each attribute as "transient" by checking a checkbox in the creation wizard.
    Edited by: nhd on May 7, 2013 8:01 PM

  • VoiceOver Resources and Links

    Here’s some VoiceOver resources and links:
    http://home.adelphia.net/~bmss/vo/
    Please let me know what you think!

    From URL: http://www.sighted.com/software/macosx.htm
    Index Braille and Sighted Electronics Announce Braille for Mac
    OS X version 10.4 “Tiger”
    November 15, 2005. Index Braille AB located in Gammelstadt Sweden and
    Sighted Electronics Inc. located in Westwood New Jersey, have collaborated to
    make a Braille translation application for Mac OS X Tiger. Using the Index
    Braille Embosser (printer), any user will now have complete Braille embossing
    capabilities for Mac OS X applications.
    Per Burman, Director of Engineering at Index Braille, stated, "We have
    developed the CUPS (Common UNIX Printer Driver) for the Index line of Braille
    embossers enabling full Unicode support for Grade Two Braille for Mac OS X.”
    According to Mr. Burman, "By January we will have Grade Two Braille
    translation with limited Braille formatting providing computer Braille production for the first time in Mac OS X.” A complete formatting functionality will ship in March.
    Because of Apple’s strong presence in the school systems it was decided to
    concentrate on Mathematics functions and the Nemeth Braille Mathematics
    code as we progress with future development.
    Apple’s Mac OS X Tiger desktop technology with the VoiceOver feature
    enables equal access for the Blind.
    By David Pillischer
    Sighted Electronics, Inc.

  • Overlapping events for resources and locations

    Has anyone been able to configure iCal Server's Resources and Locations to NOT accept invitations if the resource or location is busy?
    I am hoping the resource or location is intelligent enough to decline an invitation if it is already busy.
    Any help would be appreciated.
    Thank you,
    Ray

    I've run into this problem as well. I can't believe that there's no solution to this. It seems to me to be a pretty obvious need for any scheduling software.
    Why even have a location and resource database, if users can make any event appointment for that location or resource regardless if it's available or not?

  • When to use @Resource and when to use @EJB for dependency injection

    Hi,
    When do you use
    @Resource and when do you use @EJB for dependency injection?
    Thanks

    Captain obvious: Use @EJB for injection of EJBs, and @Resource for everything else.
    There was a discussion about this very topic quite recently, perhaps you can find it through the search.

Maybe you are looking for

  • PDF ERROR! ICC Based color space contains/ alternate key

    Can somebody help me? When I put in Rip (Agfa Apogee X) a pdf I receive the follow error: ICC Based color space contains/ alternate key. I don t know where is the problem? There Is a problem with pdf? or it is a problem in my Rip? how can I solve thi

  • AP Accrual Report

    Hi Experts, I am just wondering that is there any standard SAP report for the PO Accrual details.  Appreciate your valued suggestions. Thanks, RPC.

  • Error adding partner function

    I am a newbie. I am trying to configure SD on my IDES. I am at the point of adding partner function (Z9) to the partner procedure (ZAG) but I am getting an error message: "Partner function Z9 cannot be used for partner procedures" I cannot find the a

  • I can't get rid of Cinema Plus malware.

    It's infected Firefox (37.0.1) and Safari (8.0.5) I'm running a Mac Mini w/ 10.10.3; 3ghz i7; 16megs of ram; Intel Iris 1536 MB graphics card. Help. Thanks.

  • Quicktime movie opens really slowly...

    I just uploaded a movie to my website, and the big "Q" logo shows for a REALLY long time before the player shows up. What causes this, and how can I fix it? You can see what I'm talking about at http://web.mac.com/nicolejbutler THANKS in advance! --N