[ https://issues.apache.org/jira/browse/PIVOT-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13034794#comment-13034794 ]
Andrei Pozolotin commented on PIVOT-743: ---------------------------------------- APPLETS: 1) re: "The issues you describe could very easily be due to the plugin implementation on Linux" 2) I verified this page: http://www.carrotgarden.com:8080/webstart-carrot-bug-pivot-applet-static-staging/index-applet.jsp?plugin=V1 on: * windows 7 (6.1 b 7600) java version "1.6.0_23" Java(TM) SE Runtime Environment (build 1.6.0_23-b05) Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode) - firefox 4.0.1 - internet explorer 8.0.7600 - google chrome 11.0.696.68 * ubuntu 10.04 2.6.32-29-generic #58-Ubuntu SMP Fri Feb 11 20:52:10 UTC 2011 x86_64 GNU/Linux java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) - firefox 3.6.17 - google chrome 11.0.696.68 * macosx 10.6.7 java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode) - firefox 3.6.6 - google chrome 11.0.696.68 - safari 5.0.5 3) and confirmed that "counter still goes up"; which means that the perferred way you use to start all your pivot apps: http://pivot.apache.org/demos/kitchen-sink.html var attributes = { code:"org.apache.pivot.wtk.BrowserApplicationContext$HostApplet", width:"100%", height:"100%" }; var libraries = []; libraries.push("/lib/pivot-core-2.0.jar"); libraries.push("/lib/pivot-wtk-2.0.jar"); libraries.push("/lib/pivot-wtk-terra-2.0.jar"); libraries.push("/lib/pivot-tutorials-2.0.jar"); libraries.push("/lib/svgSalamander-tiny.jar"); attributes.archive = libraries.join(","); var parameters = { codebase_lookup:false, application_class_name:'org.apache.pivot.tutorials.KitchenSink' }; var javaArguments = ["-Dsun.awt.noerasebackground=true","-Dsun.awt.erasebackgroundonresize=true"]; parameters.java_arguments = javaArguments.join(" "); deployJava.runApplet(attributes, parameters, "1.6"); 4) which is so called "legacy plugin mode", will share all static fields between applet invocations, even if you navigate away form applet and then come back (the timeout is about 2 minutes for jvm to expire, when there are no active applets, but static fields are still active before jvm expires) 5) re "The static fields are there by design"; indeed, I understand; I am merely asking to improve the design; what I would ideally want is: a) instaniate all of pivot as a single instance via spi; b) no static fields - based singletons inside pivot framework; c) pivot caches watever it wants in singletons (which are not static fields); > pivot & static > -------------- > > Key: PIVOT-743 > URL: https://issues.apache.org/jira/browse/PIVOT-743 > Project: Pivot > Issue Type: Improvement > Affects Versions: 2.0 > Reporter: Andrei Pozolotin > Fix For: 2.1 > > > Greg, hello: > 1) in this example you say: > http://pivot.apache.org/tutorials/list-buttons.html > "Note that this example makes use of the global resource cache to store the > loaded images." > 2) which reminds of the "java evil singleton pattern" > http://java.sun.com/developer/technicalArticles/Programming/singletons/ > http://www.ibm.com/developerworks/webservices/library/co-single/index.html > http://beust.com/weblog/2011/03/10/rehabilitating-the-singleton-pattern/ > http://tech.puredanger.com/2007/07/03/pattern-hate-singleton/ > and the consensus seems to be: > "Singletons are fine as long as you don't implement them with static" > 3) and pivot uses them freely; few examples > public abstract class ApplicationContext { > protected static ArrayList<Display> displays = new ArrayList<Display>(); > protected static ArrayList<Application> applications = new > ArrayList<Application>(); > private static HashMap<URI, Object> resourceCache = new HashMap<URI, > Object>(); > private static ResourceCacheDictionary resourceCacheDictionary = new > ResourceCacheDictionary(); > public abstract class Theme { > private static Theme theme = null; > 4) do you think is it feasible to convert all of pivot into SPI: > ServiceLoader<PivotFrameworkFactory> loader = > ServiceLoader.load(PivotFrameworkFactory.class); > PivotFrameworkFactory factory = loader.iterator().next(); > Map<String, Object> config = new HashMap<String, Object>(); > PivotFramework framework = factory.newFramework(config); > 5) the two use cases that affect me now: > a) applet reload shares static > b) pivot + osgi (not sure yet if I can find a workaround; possibly depends on > what you do about PIVOT-742 PIVOT-22) > thank you; > Andrei -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira