Singleton class instantiated several times

Hi all,
I am trying to implement an inter-applet communication using a singleton class for registering the applets. The applets are in different frames on my browser; they are placed in the same directory and they use the same java console, so I am pretty sure they are running on the same JVM...
However, when I register my applets, every applet creates its "own" registry class. I have put a message in the constructor of the register class to check what's happening:
public class AppletRegistry extends Applet 
    //static hashtable maintaining the applet map
    private static Hashtable appletMap;
    private static int ct=0;
    protected static AppletRegistry registry;
    protected AppletRegistry()
        appletMap = new Hashtable();
//  Returns the long instance of the registry. If there isn't a registry
//  yet, it creates one.
      public synchronized static AppletRegistry instance()
           if (registry == null) {
                     System.out.println("new register");
                registry = new AppletRegistry();
           return registry;
    //registers the given applet
    public void register(String name, Applet applet)
        appletMap.put(name, applet);
        ct++;
        System.out.println("Register: "+name+" "+Integer.toString(ct));
}The output "new register" appears for every applet I register... What am I doing wrong?
Thea

I must admit that I never heard of classloader until
now :-( (learning java for two or three months). Do
you know a good tutorial about using classloaders? I
have no idea where to start checking which
classloaders are used.
Thanks!
TheaHi,
I don't think there are much you can do about it. Two different applets can't share an instance.
/Kaj

Similar Messages

  • Synchronized Instance Methods in Singleton Class

    If I've a TransactionManager class that's a singleton; meaning one manager handling clients' transaction requests, do I need to synchronize all of the instance methods within that singleton class?
    My understanding is that I should; otherwise, there's a chance of data corruption when one thread tries to update, but another thread tries to delete the same record at the same time.

    Let's say that you have a singleton that is handling
    the printing in a desktop application. This could be
    time consuming and it will not probably be used too
    often. What's time consuming about instantiating the object?
    On the other hand you could not say that it
    will never be used.Exactly. If that were so, why write it?
    In a web application, response time is much more
    important than initialization time (which can be
    easily ignored). Never ignored. It's just a question of when you want to pay.
    Web app as opposed to desktop app? Does response time not matter for them?
    In this case, of course, eager
    initialization makes much more sense.I'm arguing that eager initialization always makes more sense. Lazy for singletons ought to be the exception, not the norm.
    %

  • Singleton class

    Hi everybody
    Need to programm a calculation project and got the advice to use an singleton class. What the h... is that, how does it work and what is it good for. Anyone who can give me code samples and a short explanation?

    Slight correction: There are two main ways to implement singleton. In the way fluca has shown, you have to synchronize getInstance. The other way is to assign the instance at declaration time, and skip the check for null in getInstance.
    These were just illustrated quite well by jschell or DrClap or jsalonen or somebody within the last few days, probably either on this forum or on New to Java Technology. (Might have been Advanced Lang Topics, but I doubt it). Do a search on Singleton and you'll find that thread (and a lot more, I imagine).
    Hi,
    well a singleton is a class, from which is
    instantiable only one object for every JVM.
    Tipically it's obtained dclaring private (or
    protected) the constructor, and using a static method
    (and an internal staic reference) to get the
    instance.
    For example:
    public class MySing
         private MySing()
         // reference to myself
         private static myself;
         // get the instance
         public static MySing getInstance()
              if(myself==null)
                   myself=new MySing();
              return myself;
    A singleton class is useful for object that must be
    used by various threads, but that at the same time
    needs to mantaine a particular
    coerence. For example, if you deploy a database 100%
    pure Java, then it must run as singleton, because two
    threads must obtain the same reference, and can't
    create two different database.
    Hope this helps

  • Singleton Class using a constructor not a getInstance method

    Hi,
    I have a class with a couple of contructors, the class is instantiated many times in the application.
    Is there any way by which I can return a single instance of the class when the contructor is called ?.
    I dont want to declare a get instance method to return a single instance is it somehow possible to do this in the contructor itself.
    This is done so I dont have to refactor the whole application and change all the places where this class is instantiated.
    Example
    XXXClass xxx = new XXXClass();
    every time new XXXClass() is called the single instance of the class must be returned.
    I dont want to implement
    XXXClass xxx = XXXClass.getInstance();
    Thanks in advance
    Rgds
    Pradeep Thomas

    The short answer to your question is No. If your class has accessible constructors and your code calls "new" then there will be multiple instances of the corresponding objects.
    Possible ways round your problem are to use static variables in place of instance variables or to use your existing class as a wrapper for another class that is instantiated only once. This second class should include all the variables and methods and the wrapper class would delegate all calls to it. This is not quite a singleton because there would still be multiple instances of the wrapper, but each instance would share the same variables and methods. You could also add a getInstance() method to the wrapper class so that new code could start to use it as a singleton.
    Other than that, it's time to refactor! Good Luck.

  • SINGLETON CLASSES QUESTIONS

    Hello,
    Could someone please explain what the following code does? How does it work? How can I use it in the real program?
    More importantly, if you are kind enough, please give me some examples how to use singleton class? Why do we have to use this class?
    I spent two days on this topic, Singleton, but my mind still goes blank.....
    thank you.
    public class Singleton
    static public Singleton getInstance()
    if(theInstance == null)
    theInstance = new Singleton();
    return theInstance;
    protected Singleton()
    //initializing instance fields
    //instance fields and methods
    private static Singleton theInstance = null;

    Hello,
    Could someone please explain what the following code
    does? The code defines a class called Singleton. :)
    How does it work? The static method "getInstance()" returns an object of type Singleton. Static methods can be called without having an instance of a class, so you can type:
    Singleton.getInstance();
    How can I use it in the
    real program?This class is pretty useless in a real program. The point of this class is to show you how the Singleton design pattern can be implemented in Java. Any useful Singleton object needs to have additional properties and methods. (Oh I know someone will say that you can still use this class for something, but I'm trying to explain something here...)
    More importantly, if you are kind enough, please give
    me some examples how to use singleton class? Sure, here's an example of a singleton: Suppose you want a debugging class that will simply write text to a file. You want to only have one instance of this class (i.e. you don't want to have multiple log files, you want to provide one single interface point for this):
    class LoggerSingleton
      private static final String LOGFILENAME = "log.txt";
      private BufferedWriter write = null;
      private LoggerSingleton instance;
      synchronized static public LoggerSingleton getInstance()
      { if(instance == null)  instance = new LoggerSingleton(LOGFILENAME);
        return instance;
      protected LoggerSingleton(String filename)
        try {
          write = new BufferedWriter(new FileWriter(filename));
          write.write("Log File Opened");
          write.newLine();
          write.flush();
        catch(IOException ioe)
          System.err.println("Error!  LoggerSingleton could not be initialized");
          ioe.printStackTrace(System.err);
          System.exit(1);
      public log(String text)
        write.write(text);
        write.newLine();
        write.flush();
    }This class will make sure you only have one log file and ensures that all classes are using it:
    class FirstClass {
      SecondClass second = new SecondClass();
      public FirstClass() {
        LoggerSingleton.getInstance().log("Inside FirstClass' constructor");
      public void func1() {
        LoggerSingleton.getInstance().log("Inside FirstClass.func1()");
    class SecondClass {
      public SecondClass() {
        LoggerSingleton.getInstance().log("Inside SecondClass' constructor");
    Why do we have to use this class?You don't have to use this class, but it is one technique to ensure that multiple instances of an object are not instantiated. It is also a technique to ensure that there is only one interface point across the application (you can also use a Singleton object to implement the Bridge and Factory design patterns). The Singleton technique is achieved by making the constructor protected, which means that only methods inside the class (and package) can construct instances of Singleton. The only time an instance of Singleton is constructed is the first time that getInstance() is called.
    I spent two days on this topic, Singleton, but my mind
    still goes blank.....
    Still blank?

  • Can not access the Instance Data of a Singleton class from MBean

    I am working against the deadline and i am sweating now. From past few days i have been working on a problem and now its the time to shout out.
    I have an application (let's call it "APP") and i have a "PerformanceStatistics" MBean written for APP. I also have a Singleton Data class (let's call it "SDATA") which provides some data for the MBean to access and calculate some application runtime stuff. Thus during the application startup and then in the application lifecysle, i will be adding data to the SDATA instance.So, this SDATA instance always has the data.
    Now, the problem is that i am not able to access any of the data or data structures from the PerformanceStatistics MBean. if i check the data structures when i am adding the data, all the structures contains data. But when i call this singleton instance from the MBean, am kind of having the empty data.
    Can anyone explain or have hints on what's happening ? Any help will be appreciated.
    I tried all sorts of DATA class being final and all methods being synchronized, static, ect.,, just to make sure. But no luck till now.
    Another unfortunate thing is that, i some times get different "ServicePerformanceData " instances (i.e. when i print the ServicePerformanceData.getInstance() they are different at different times). Not sure whats happening. I am running this application in WebLogic server and using the JConsole.
    Please see the detailed problem at @ http://stackoverflow.com/questions/1151117/can-not-access-the-instance-data-of-a-singleton-class-from-mbean
    I see related problems but no real solutions. Appreciate if anyone can throw in ideas.
    http://www.velocityreviews.com/forums/t135852-rmi-singletons-and-multiple-classloaders-in-weblogic.html
    http://www.theserverside.com/discussions/thread.tss?thread_id=12194
    http://www.jguru.com/faq/view.jsp?EID=1051835
    Thanks,
    Krishna

    I am working against the deadline and i am sweating now. From past few days i have been working on a problem and now its the time to shout out.
    I have an application (let's call it "APP") and i have a "PerformanceStatistics" MBean written for APP. I also have a Singleton Data class (let's call it "SDATA") which provides some data for the MBean to access and calculate some application runtime stuff. Thus during the application startup and then in the application lifecysle, i will be adding data to the SDATA instance.So, this SDATA instance always has the data.
    Now, the problem is that i am not able to access any of the data or data structures from the PerformanceStatistics MBean. if i check the data structures when i am adding the data, all the structures contains data. But when i call this singleton instance from the MBean, am kind of having the empty data.
    Can anyone explain or have hints on what's happening ? Any help will be appreciated.
    I tried all sorts of DATA class being final and all methods being synchronized, static, ect.,, just to make sure. But no luck till now.
    Another unfortunate thing is that, i some times get different "ServicePerformanceData " instances (i.e. when i print the ServicePerformanceData.getInstance() they are different at different times). Not sure whats happening. I am running this application in WebLogic server and using the JConsole.
    Please see the detailed problem at @ http://stackoverflow.com/questions/1151117/can-not-access-the-instance-data-of-a-singleton-class-from-mbean
    I see related problems but no real solutions. Appreciate if anyone can throw in ideas.
    http://www.velocityreviews.com/forums/t135852-rmi-singletons-and-multiple-classloaders-in-weblogic.html
    http://www.theserverside.com/discussions/thread.tss?thread_id=12194
    http://www.jguru.com/faq/view.jsp?EID=1051835
    Thanks,
    Krishna

  • Eth0 is being up and down for several time during boot

    My wicd doesn't connect to eth0 on the first attempt after boot up. It is configured to eth0 always have a higher priority to connect.
    My dmesg shows that eth0 being up and down for several time during boot. I have e1000e in my MODULES list.
    Here is my rc.conf
    # /etc/rc.conf - Main Configuration for Arch Linux
    # LOCALIZATION
    # LOCALE: available languages can be listed with the 'locale -a' command
    # DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon
    # startup and during the boot process. If set to 'no', the C locale is used.
    # HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result
    # in the hardware clock being left untouched (useful for virtualization)
    # Note: Using "localtime" is discouraged, using "" makes hwclock fall back
    # to the value in /var/lib/hwclock/adjfile
    # TIMEZONE: timezones are found in /usr/share/zoneinfo
    # Note: if unset, the value in /etc/localtime is used unchanged
    # KEYMAP: keymaps are found in /usr/share/kbd/keymaps
    # CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
    # CONSOLEMAP: found in /usr/share/kbd/consoletrans
    # USECOLOR: use ANSI color sequences in startup messages
    LOCALE="en_US.UTF-8"
    DAEMON_LOCALE="no"
    HARDWARECLOCK=""
    TIMEZONE="Asia/Hong_Kong"
    KEYMAP="us"
    CONSOLEFONT=
    CONSOLEMAP=
    USECOLOR="yes"
    # HARDWARE
    # MODULES: Modules to load at boot-up. Blacklisting is no longer supported.
    # Replace every !module by an entry as on the following line in a file in
    # /etc/modprobe.d:
    # blacklist module
    # See "man modprobe.conf" for details.
    MOD_AUTOLOAD="yes"
    MODULES=(acpi-cpufreq fuse tp_smapi vboxdrv e1000e)
    # Udev settle timeout (default to 30)
    UDEV_TIMEOUT=30
    # Scan for FakeRAID (dmraid) Volumes at startup
    USEDMRAID="no"
    # Scan for BTRFS volumes at startup
    USEBTRFS="no"
    # Scan for LVM volume groups at startup, required if you use LVM
    USELVM="no"
    # NETWORKING
    # HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
    HOSTNAME="antony-tp"
    # Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces.
    # Wired network setup
    # - interface: name of device (required)
    # - address: IP address (leave blank for DHCP)
    # - netmask: subnet mask (ignored for DHCP) (optional, defaults to 255.255.255.0)
    # - broadcast: broadcast address (ignored for DHCP) (optional)
    # - gateway: default route (ignored for DHCP)
    # Static IP example
    # interface=eth0
    # address=192.168.0.2
    # netmask=255.255.255.0
    # broadcast=192.168.0.255
    # gateway=192.168.0.1
    # DHCP example
    # interface=eth0
    # address=
    # netmask=
    # gateway=
    # Setting this to "yes" will skip network shutdown.
    # This is required if your root device is on NFS.
    NETWORK_PERSIST="yes"
    # Enable these netcfg profiles at boot-up. These are useful if you happen to
    # need more advanced network features than the simple network service
    # supports, such as multiple network configurations (ie, laptop users)
    # - set to 'menu' to present a menu during boot-up (dialog package required)
    # - prefix an entry with a ! to disable it
    # Network profiles are found in /etc/network.d
    # This requires the netcfg package
    #NETWORKS=(main)
    # DAEMONS
    # Daemons to start at boot-up (in this order)
    # - prefix a daemon with a ! to disable it
    # - prefix a daemon with a @ to start it up in the background
    # If something other takes care of your hardware clock (ntpd, dual-boot...)
    # you should disable 'hwclock' here.
    DAEMONS=(!hwclock syslog-ng dbus !network !dhcpcd rpcbind acpid @wicd nfs-common netfs @crond cups @laptop-mode @alsa @sensors ntpd @slim bluetooth)
    Here is a segment of my dmesg
    [ 2.759302] e1000e: Intel(R) PRO/1000 Network Driver - 1.5.1-k
    [ 2.759304] e1000e: Copyright(c) 1999 - 2011 Intel Corporation.
    [ 2.759338] e1000e 0000:00:19.0: PCI INT A -> GSI 20 (level, low) -> IRQ 20
    [ 2.759348] e1000e 0000:00:19.0: setting latency timer to 64
    [ 2.759467] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 2.766107] tpm_tis 00:0a: 1.2 TPM (device-id 0x0, rev-id 78)
    [ 2.766808] ACPI: AC Adapter [AC] (on-line)
    [ 2.776492] wmi: Mapper loaded
    [ 2.777212] mei: module is from the staging directory, the quality is unknown, you have been warned.
    [ 2.777781] thermal LNXTHERM:00: registered as thermal_zone0
    [ 2.777783] ACPI: Thermal Zone [THM0] (66 C)
    [ 2.778291] iTCO_vendor_support: vendor-support=0
    [ 2.780137] ACPI: Battery Slot [BAT0] (battery present)
    [ 2.780958] input: PC Speaker as /devices/platform/pcspkr/input/input4
    [ 2.781462] iTCO_wdt: Intel TCO WatchDog Timer Driver v1.07
    [ 2.781547] iTCO_wdt: Found a Cougar Point TCO device (Version=2, TCOBASE=0x0460)
    [ 2.781919] iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
    [ 2.783139] cfg80211: Calling CRDA to update world regulatory domain
    [ 2.789182] [drm] Initialized drm 1.1.0 20060810
    [ 2.789538] hub 4-1:1.0: USB hub found
    [ 2.789616] hub 4-1:1.0: 8 ports detected
    [ 2.792925] Non-volatile memory driver v1.3
    [ 2.795877] thinkpad_acpi: ThinkPad ACPI Extras v0.24
    [ 2.795879] thinkpad_acpi: http://ibm-acpi.sf.net/
    [ 2.795881] thinkpad_acpi: ThinkPad BIOS 8DET54WW (1.24 ), EC unknown
    [ 2.795882] thinkpad_acpi: Lenovo ThinkPad X220, model 4290NL5
    [ 2.797236] thinkpad_acpi: detected a 8-level brightness capable ThinkPad
    [ 2.797352] thinkpad_acpi: radio switch found; radios are enabled
    [ 2.797466] thinkpad_acpi: possible tablet mode switch found; ThinkPad in laptop mode
    [ 2.799752] thinkpad_acpi: rfkill switch tpacpi_bluetooth_sw: radio is unblocked
    [ 2.800067] Registered led device: tpacpi::thinklight
    [ 2.800091] Registered led device: tpacpi::power
    [ 2.800106] Registered led device: tpacpi::standby
    [ 2.800120] Registered led device: tpacpi::thinkvantage
    [ 2.800192] thinkpad_acpi: Standard ACPI backlight interface available, not loading native one
    [ 2.800254] thinkpad_acpi: Console audio control enabled, mode: monitor (read only)
    [ 2.801077] input: ThinkPad Extra Buttons as /devices/platform/thinkpad_acpi/input/input5
    [ 2.801162] sdhci: Secure Digital Host Controller Interface driver
    [ 2.801164] sdhci: Copyright(c) Pierre Ossman
    [ 2.801707] Intel(R) Wireless WiFi Link AGN driver for Linux, in-tree:
    [ 2.801709] Copyright(c) 2003-2011 Intel Corporation
    [ 2.801744] iwlwifi 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17
    [ 2.801753] iwlwifi 0000:03:00.0: setting latency timer to 64
    [ 2.801789] iwlwifi 0000:03:00.0: pci_resource_len = 0x00002000
    [ 2.801791] iwlwifi 0000:03:00.0: pci_resource_base = ffffc90005abc000
    [ 2.801793] iwlwifi 0000:03:00.0: HW Revision ID = 0x34
    [ 2.801877] iwlwifi 0000:03:00.0: irq 49 for MSI/MSI-X
    [ 2.801913] iwlwifi 0000:03:00.0: Detected Intel(R) Centrino(R) Advanced-N 6205 AGN, REV=0xB0
    [ 2.801962] iwlwifi 0000:03:00.0: L1 Disabled; Enabling L0S
    [ 2.802045] sdhci-pci 0000:0d:00.0: SDHCI controller found [1180:e822] (rev 7)
    [ 2.802067] sdhci-pci 0000:0d:00.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
    [ 2.802107] sdhci-pci 0000:0d:00.0: setting latency timer to 64
    [ 2.802118] _regulator_get: 0000:0d:00.0 supply vmmc not found, using dummy regulator
    [ 2.802188] Registered led device: mmc0::
    [ 2.803329] mmc0: SDHCI controller on PCI [0000:0d:00.0] using DMA
    [ 2.815226] iwlwifi 0000:03:00.0: device EEPROM VER=0x715, CALIB=0x6
    [ 2.815229] iwlwifi 0000:03:00.0: Device SKU: 0X1f0
    [ 2.815231] iwlwifi 0000:03:00.0: Valid Tx ant: 0X3, Valid Rx ant: 0X3
    [ 2.815247] iwlwifi 0000:03:00.0: Tunable channels: 13 802.11bg, 24 802.11a channels
    [ 2.845674] iwlwifi 0000:03:00.0: loaded firmware version 17.168.5.3 build 42301
    [ 2.845820] Registered led device: phy0-led
    [ 2.850630] ieee80211 phy0: Selected rate control algorithm 'iwl-agn-rs'
    [ 2.862431] usb 1-1.2: new low-speed USB device number 3 using ehci_hcd
    [ 2.943648] e1000e 0000:00:19.0: eth0: (PCI Express:2.5GT/s:Width x1) f0:de:f1:92:77:26
    [ 2.943651] e1000e 0000:00:19.0: eth0: Intel(R) PRO/1000 Network Connection
    [ 2.943712] e1000e 0000:00:19.0: eth0: MAC: 10, PHY: 11, PBA No: 1000FF-0FF
    [ 2.943734] mei 0000:00:16.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
    [ 2.943739] mei 0000:00:16.0: setting latency timer to 64
    [ 2.943817] mei 0000:00:16.0: irq 50 for MSI/MSI-X
    [ 2.944502] agpgart-intel 0000:00:00.0: Intel Sandybridge Chipset
    [ 2.945021] agpgart-intel 0000:00:00.0: detected gtt size: 2097152K total, 262144K mappable
    [ 2.946341] watchdog: INTCAMT: cannot register miscdev on minor=130 (err=-16).
    [ 2.946452] watchdog: error registering /dev/watchdog (err=-16).
    [ 2.946523] mei: unable to register watchdog device.
    [ 2.946598] agpgart-intel 0000:00:00.0: detected 65536K stolen memory
    [ 2.946692] agpgart-intel 0000:00:00.0: AGP aperture is 256M @ 0xe0000000
    [ 2.946734] i801_smbus 0000:00:1f.3: PCI INT C -> GSI 18 (level, low) -> IRQ 18
    [ 2.948359] snd_hda_intel 0000:00:1b.0: PCI INT A -> GSI 22 (level, low) -> IRQ 22
    [ 2.948422] snd_hda_intel 0000:00:1b.0: irq 51 for MSI/MSI-X
    [ 2.948444] snd_hda_intel 0000:00:1b.0: setting latency timer to 64
    [ 3.022245] usb 1-1.3: new full-speed USB device number 4 using ehci_hcd
    [ 3.172080] usb 1-1.4: new full-speed USB device number 5 using ehci_hcd
    [ 3.274597] Bluetooth: Core ver 2.16
    [ 3.274611] NET: Registered protocol family 31
    [ 3.274612] Bluetooth: HCI device and connection manager initialized
    [ 3.274614] Bluetooth: HCI socket layer initialized
    [ 3.274614] Bluetooth: L2CAP socket layer initialized
    [ 3.274618] Bluetooth: SCO socket layer initialized
    [ 3.275535] Bluetooth: Generic Bluetooth USB driver ver 0.6
    [ 3.276006] usbcore: registered new interface driver btusb
    [ 3.338454] usb 1-1.6: new high-speed USB device number 6 using ehci_hcd
    [ 3.444567] Linux media interface: v0.10
    [ 3.447387] Linux video capture interface: v2.00
    [ 3.448573] input: Logitech Trackball as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input6
    [ 3.448671] generic-usb 0003:046D:C404.0001: input,hidraw0: USB HID v1.10 Mouse [Logitech Trackball] on usb-0000:00:1a.0-1.2/input0
    [ 3.448690] usbcore: registered new interface driver usbhid
    [ 3.448691] usbhid: USB HID core driver
    [ 3.449136] uvcvideo: Found UVC 1.00 device Integrated Camera (04f2:b217)
    [ 3.450945] input: Integrated Camera as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/input/input7
    [ 3.450987] usbcore: registered new interface driver uvcvideo
    [ 3.450988] USB Video Class driver (1.1.1)
    [ 3.484049] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/input/input8
    [ 3.491137] HDMI status: Codec=3 Pin=5 Presence_Detect=0 ELD_Valid=0
    [ 3.491298] HDMI status: Codec=3 Pin=6 Presence_Detect=0 ELD_Valid=0
    [ 3.491486] HDMI status: Codec=3 Pin=7 Presence_Detect=0 ELD_Valid=0
    [ 3.491637] input: HDA Intel PCH HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
    [ 3.491709] input: HDA Intel PCH HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
    [ 3.491765] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
    [ 3.492050] i915 0000:00:02.0: power state changed by ACPI to D0
    [ 3.492053] i915 0000:00:02.0: power state changed by ACPI to D0
    [ 3.492059] i915 0000:00:02.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
    [ 3.492062] i915 0000:00:02.0: setting latency timer to 64
    [ 3.538056] mtrr: no more MTRRs available
    [ 3.538058] [drm] MTRR allocation failed. Graphics performance may suffer.
    [ 3.538266] i915 0000:00:02.0: irq 52 for MSI/MSI-X
    [ 3.538270] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
    [ 3.538271] [drm] Driver supports precise vblank timestamp query.
    [ 3.538292] vgaarb: device changed decodes: PCI:0000:00:02.0,olddecodes=io+mem,decodes=io+mem:owns=io+mem
    [ 3.664501] psmouse serio1: synaptics: Touchpad model: 1, fw: 8.0, id: 0x1e2b1, caps: 0xd001a3/0x940300/0x120c00
    [ 3.664518] psmouse serio1: synaptics: serio: Synaptics pass-through port at isa0060/serio1/input0
    [ 3.716317] input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio1/input/input12
    [ 4.407165] fbcon: inteldrmfb (fb0) is primary device
    [ 4.575259] Console: switching to colour frame buffer device 170x48
    [ 4.577042] fb0: inteldrmfb frame buffer device
    [ 4.577043] drm: registered panic notifier
    [ 4.607860] acpi device:01: registered as cooling_device4
    [ 4.607985] input: Video Bus as /devices/LNXSYSTM:00/device:00/PNP0A08:00/LNXVIDEO:00/input/input13
    [ 4.608039] ACPI: Video Device [VID] (multi-head: yes rom: no post: no)
    [ 4.608122] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
    [ 4.757243] EXT4-fs (sda3): re-mounted. Opts: discard
    [ 4.765917] EXT4-fs (sda4): mounted filesystem with ordered data mode. Opts: discard
    [ 4.776777] Adding 262140k swap on /dev/sda2. Priority:-1 extents:1 across:262140k SS
    [ 5.099467] NET: Registered protocol family 10
    [ 6.048650] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
    [ 6.098038] Bluetooth: RFCOMM TTY layer initialized
    [ 6.098055] Bluetooth: RFCOMM socket layer initialized
    [ 6.098057] Bluetooth: RFCOMM ver 1.11
    [ 6.278766] iwlwifi 0000:03:00.0: L1 Disabled; Enabling L0S
    [ 6.278893] iwlwifi 0000:03:00.0: Radio type=0x1-0x2-0x0
    [ 6.568639] iwlwifi 0000:03:00.0: L1 Disabled; Enabling L0S
    [ 6.568775] iwlwifi 0000:03:00.0: Radio type=0x1-0x2-0x0
    [ 6.684082] ADDRCONF(NETDEV_UP): wlan0: link is not ready
    [ 7.176563] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 7.226662] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 7.227110] ADDRCONF(NETDEV_UP): eth0: link is not ready
    [ 10.229345] IBM TrackPoint firmware: 0x0e, buttons: 3/3
    [ 10.490618] input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input14
    [ 10.817814] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
    [ 10.819315] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    [ 11.186166] iwlwifi 0000:03:00.0: L1 Disabled; Enabling L0S
    [ 11.186292] iwlwifi 0000:03:00.0: Radio type=0x1-0x2-0x0
    [ 11.313367] ADDRCONF(NETDEV_UP): wlan0: link is not ready
    [ 11.665342] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 11.717591] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 11.718042] ADDRCONF(NETDEV_UP): eth0: link is not ready
    [ 11.964795] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 12.017213] e1000e 0000:00:19.0: irq 48 for MSI/MSI-X
    [ 12.017720] ADDRCONF(NETDEV_UP): eth0: link is not ready
    [ 13.811264] EXT4-fs (sda3): re-mounted. Opts: discard,commit=0
    [ 13.826031] EXT4-fs (sda4): re-mounted. Opts: discard,commit=0
    [ 15.178905] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
    [ 15.180472] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    [ 25.663056] eth0: no IPv6 routers present
    Any hint for tracing the root of this problem? Thank you very much!

    Hi ...
    If you have moved the Safari application from the Applications folder, move it back.
    As far as the cache goes, there's a work around for that when you can't empty the Safari cache from the menu bar.
    Go to    ~/Library/Caches/com.aple.Safari.Cache.db.  Move the Cache.db file to the Trash.
    Try Safari.
    Mac OS X (10.7.2)   <  from your profile
    If that is corrrect, you need to update your system software. Click your Apple menu icon top left in your screen. From the drop down menu click Software
    Update ...
    ~ (Tilde) character represents the Home folder.
    For Lion v10.7x:  To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • How to make Singleton Class secure

    I have a Singleton class which I instantiate using reflection by a call to a public getInstance method that return the object from a private constructor. I have to use reflection as I dont have any other options since my class instantiation is decided on runtime. How will I secure other form instantiating the same class again by using reflection on my private constructor? Any ideas?

    How much do these different implementations of your singleton have in common? What I'm getting at is, is there some common code you could extract out of them all, and make that a singleton in it's own right? Needing to do this sort of hacking is often a sign you're fudging something together, that could be solved more elegantly. We use the Singleton pattern generally when the state of the object needs to exist exactly once. Can you extract that from the disparate objects?
    The singleton classes that I load do not have anything in common. They are all similar but unique, and independant in their own respect. I will have to decide only on what singleton object I have to load in runtime, based on certain criterion. This is done by reflection, by a call to the public getInstance() method of the respective singleton classes, since I am deciding on runtime. My problem is that can I prevent others from accessing my private constructor from outside the class using reflection, which enables them to create another duplicate object. Can I restrict them to use only my getInstance() method instead?? I know this is hacking to access the private members, but I want to know whether there is any way where I can restrict this hacking???In the above code I dont want these statements to work at any case
    java.lang.reflect.Constructor[] c = cl.getDeclaredConstructors();
    c[0].setAccessible(true);
    A anotherA  = (A) c[0].newInstance(new Object[]{"Duplicate"});

  • How to ensure singleton classes no longer exist

    hi all not sure if this is the right forum....
    I am writting an application that integrates another, I wish to stop and then restart the integrated application but it seems that the singleton classes of which there are quite a few ( each being statically initalised) do not disappear when I try to shut them dowm. (if I am shutting them down that is ...)
    is there a way to ensure these instances are terminated so I can restart the integrated application inside my application?
    is there a way to see what instances exist so I can see if in fact I am disposing of any?
    thanks for ur help

    is there a way to ensure these instances are
    terminated so I can restart the integrated application
    inside my application?
    is there a way to see what instances exist so I can
    see if in fact I am disposing of any?
    What exactly are you trying to achieve?
    Do these hold on to resources which you must clean first? Then you must have a clean/dispose method. There is no other option. You can use a registration class to make this easier.
    Do you simply want to reinitialize them? Then you could use a class loader but it probably going to take less time to simply do the same as above and add a reinit method to each. Again you can use a registration class to make this easier.

  • Posted this query several times but no reply. Please help me out

    Hi all,
    How to know whether a servlet had completely sent its response to the request.
    The problem what i am facing is, I send response to a client's request as a file.
    The byte by byte transfer happens, now if the client interrupts or cancels the operation, the response is not completed.
    At this stage how to know the response status. I am handling all exception, even then I am unable to trap the status.
    Please help me out.
    I have posted this query several times but no convincing reply till now. Hence please help me out.
    If somebody wants to see the code. I'll send it through mail.
    regards
    venkat

    Hi,
    thanks for the reply,
    Please check the code what I have written. The servlet if I execute in Javawebserver2.0 I could trap the exception. If the same servlet is running in weblogic 6.0 I am unable to get the exception.
    Please note that I have maintained counter and all necessary exception handling even then unable to trap the exception.
    //code//
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.security.*;
    public class TestServ extends HttpServlet
    Exception exception;
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException, UnavailableException
         int bytesRead=0;
         int count=0;
         byte[] buff=new byte[1];
    OutputStream out=res.getOutputStream ();
    res.setContentType( "application/pdf"); // MIME type for pdf doc
    String fileURL ="http://localhost:7001/soap.pdf";
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    boolean download=false;
         int fsize=0;
         res.setHeader("Content-disposition", "attachment; filename="+"soap.pdf" );
    try
                   URL url=new URL(fileURL);
         bis = new BufferedInputStream(url.openStream());
         fsize=bis.available();
         bos = new BufferedOutputStream(out);
    while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
              try
                        bos.write(bytesRead);
                        count +=bytesRead;
                        bos.flush();
                   }//end of try for while loop
                   catch(StreamCorruptedException ex)
                        System.out.println("Exception ="+ex);
                        setError(ex);
                        break;
                   catch(SocketException e)
                        setError(e);
                        break;
                   catch(Exception e)
                        System.out.println("Exception in while of TestServlet is " +e.getMessage());
                        if(e != null)
                             System.out.println("File not downloaded properly"+e);
                             setError(e);
                             break;
                        }//if ends
                   }//end of catch for while loop
    }//while ends
              Exception eError=getError();
              if(eError!=null)
                   System.out.println("\n\n\n\nFile Not DownLoaded properly\n\n\n\n");
              else if(bytesRead == -1)
              System.out.println("\n\n\n\ndownload \nsuccessful\n\n\n\n");
              else
              System.out.println("\n\n\n\ndownload not successful\n\n\n\n");
    catch(MalformedURLException e)
    System.out.println ( "Exception inside TestServlet is " +e.getMessage());
    catch(IOException e)
    System.out.println ( "IOException inside TestServlet is " +e.getMessage());
         finally
              try
         if (bis != null)
         bis.close();
         if (bos != null)
         {bos.close();}
              catch(Exception e)
                   System.out.println("here ="+e);
    }//doPost ends
    public void setError(Exception e)
         exception=e;
         System.out.println("\n\n\nException occurred is "+e+"\n\n\n");
    public Exception getError()
              return exception;
    }//class ends
    //ends
    regards,
    venakt

  • Singleton class issue

    I have a singleton class. A method in this class creates an array of structures. This class is shared across different process. So there is a chance that some one unknowigly calls the method to create the array of structures and hence the member variable may now points to another array of structure.
    Is there any way in Java to restict invoking of a function only once.
    A static variable with a check will solve this issue, but any other method so that calling of method itself becomes invalid to avoid RT usage?.

    Hi,
    I think, I understood know.
    You want to have a singleton holding a defined number of other objects (your arrays).
    This objects (your arrays) are semantically singletons itsself, because they should be constructed only once and than reused.
    Assuming I interpreted right, see my comments inline below.
    I know that who ever participate in this discussion is
    pretty sure about singleton class. Some of the code
    what I gave was irretating as Martin pointed out. So
    let me try to give more transparent code snippet,Thanks, that helped.
    >
    My aim :- I need a global object which is going to
    hold some arrays(data structures). This should be
    shared across various threads. (forget about the
    synchronousation part here). All these arrays won't be
    of same size, so I need methods for each
    datastructures to initialise to its required size.That's a little bit part of your problem, see below.
    My wayforward :- Create the global object as
    singleton. This object has methods for initialising
    different data structures.OK, fine.
    What is my doubt :- please see the following code
    fragment,
    public class Singleton {
    private Singleton singleton;
    private Singleton() {
    public static Singleton getInstance() {
    if (singleton == null) {
    singleton = new Singleton();
    return singleton;
    //other methods for the class
    private someObjType1 myArray1 = null;
    private someObjType2 myArray2 = null;
    private someObjType3 myArray3 = null; // etc....This "smells" like an candidate for another data structure, so that you don't have a fixed number of array.
    F.E.
    // Associate class of array elements (someObjTypeX) as keys with arrays of someObjTypeX
    private Map arrayMap = new HashMap();>
    public void CreateArray1(int size) {
    if (myArray1 == null) {
    myArray1 = new someObjType1[size];
    }Using the map, you create array should look like
    public void CreateArray(Class clazzOfArrayElem, int size)
      Object arr = arrayMap.get(clazzOfArrayElem)
      if(arr == null)
        arr = java.lang.reflect.Array.newInstance(clazzOfArrayElem, size);
        arrayMap.put(clazzOfArrayElem, arr);
    }Additionally the "ugliness" of this method results from the problem, that don't know the size of arrays at compile time.
    So it seem to be preferable to use a dynamic structure like a Vector instead of array. Then you don't have the need to pass the size in the accessor method.
    Then you can use a "cleaner" accessor method like
    public Vector getVector(Class clazzOfArrayElem)
      Vector vec = arrayMap.get(clazzOfArrayElem)
      if(vec == null)
        vec = new Vector();
        arrayMap.put(clazzOfArrayElem, vec); 
    return vec;
    }If you want to expose an array oriented interface f.e. for type safety you can have an accessor like
    public Object[] getAsArray(Class clazzOfArrayElem)
      Vector vec = arrayMap.get(clazzOfArrayElem)
      if(vec == null)
        vec = new Vector();
        arrayMap.put(clazzOfArrayElem, vec);
      arr = java.lang.reflect.Array.newInstance(clazzOfArrayElem, 0);
      return (Object[])vec.toArray(arr);
    // Real typesafe accessors as needed following
    public SomeClass1[] getAsArrayOfSomeClass1()
      return (SomeClass1[])getAsArray(SomeClass1.class);
    /.....This accessor for array interface have the additional advantage, that they return a copy of the data (only the internal arrays, no the object within the arrays!), so that a least a client using your class doesn't have access to your internal data (with the Vector he has).
    >
    // similarly for other data structures...
    So here CreateArray1 method will work fine because of
    the check myArray1 == null.
    Actual question :- Can I remove this check and
    restrick call to CreateArray1 more than one time ?.No. As I understood you want to have something like a "only-use-once-method". There is no such thing in Java I know of.
    But I don't see the need to remove this check. Reference comparison should have no real impact to the performance.
    this is going to benifit me for some other cases
    also.How?
    Hope this helps.
    Martin

  • Singleton Class using a constructor not a get Instance method ?

    Hi,
    I have a class with a couple of contructors, the class is instantiated many times in the application.
    Is there any way by which I can return a single instance of the class when the contructor is called ?.
    I dont want to declare a get instance method to return a single instance is it somehow possible to do this in the contructor itself.
    This is done so I dont have to refactor the whole application and change all the places where this class is instantiated.
    Example
    XXXClass xxx = new XXXClass();
    every time new XXXClass() is called the single instance of the class must be returned.
    I dont want to implement
    XXXClass xxx = XXXClass.getInstance();
    Thanks in advance
    Rgds
    Pradeep Thomas

    Pradeep ,
    You see a constructor does not return anything
    when you tell java
    String str = new String();
    It is into the reference str that a Object of the type String is assigned and used ..
    If you want a single instance to exist in your application ..the best way is to use the singelton approach.
    Alternatively you could create one static instance of the object in a parent class and all the classes that inherit from it will then share access .

  • Is the singleton class single in threads?

    I have a class designed by singleton pattern.
    I use this in many threads in one VM.
    I found every thread had a different instance.
    Why?
    And if I want to share information with different
    threads,how can I apply singleton in this context?

    I know why!
    In my singleton class,I don't add the keyword "synchronized".
    Code below:
    public static MySingleton getInstance(){
    if(instance == null){                       //miss the keyword "synchronized"
    instance = new MySingleTon();
    return instance;
    So when threads call this method at the same time,
    many instances created.

  • Singleton Classes in Java

    What are SingleTon Classes in Java and what are their applications?

    Singleton is a class in Java that can be instantiated only once after it's coded ... Applications can be many ...
    Say you are coding for a game of Poker, and the deck of cards is to be instantiated only once in the whole application ..

  • Error in creating singleton class

    Hi all:
    I am trying to create a singleton class. The code is the following:
    // begin
    class EdgeIntersectsException extends Exception{
    final static EdgeIntersectsException instance = new
    EdgeIntersectsException();
    private EdgeIntersectsException(){}
    // end
    But eclipse gives me error like this:
    the field instance cannot be declare static; static field can only be declare in static or top level types.
    I don't know why it happens to be like this. Any advice will help. Thank you in advance!

    What benefit do you get by making it a singleton?
    My program is not suppose to use concurrency, so
    , so a singleton design is good, because I am sure
    that the instance is going to be
    used by one thread at any time, and it also saves
    memory space. Being a Singleton has no impact on how many threads can execute code unless every method is synchronized and every member is private. Furthermore, if your program is not using concurrency then this is even more irrelevent because it would only matter if you were using concurrency.
    What logic is there that says only one of these
    things should exist in your system?
    I am not exactly sure here. If I make only one
    one instance of this exception, will it be faster to
    throw it? Currently, the only good thing
    I can think of is that it saves memory. (Since this
    kind of exception may be used a lot as the program
    runs.)If you can't identify a single meaningful reason to be doing something perhaps you should rethink doing it to begin with.

Maybe you are looking for

  • Adobe Premiere Pro CC 2014 opens then closes immediatly

    Hi, until today Premiere Pro has worked perfectly but when I turned on my computer this morning it tries to open and then instantly closes displaying no error message or anything, just randomly closes.... any help?

  • Event Handler not found -OIM 9102

    Hi Experts, I'm facing a problem while creating a user manually in OIM. Everytime I try to manually create a user, an error message is displayed on the GUI saying, "DOBJ.EVT_NOT_FOUND Event Handler not found". On checking the logs, this is what I get

  • Font not appearing on a mac

    I'm embedding a Helvetica Neue font with my text fields but it itsn't showing up on in Safari, it's a T1 font (postscript) is this a common problem does anyone know?

  • Coloring a table cell with swing

    Hello, I am trying to write a java program in swing. Basically I am setting up a table and adding labels to the table's cells. Rather than displaying the label, the table is inserting the labels' string value. Here is a compilable example: import jav

  • Storing users workspace information in XML

    Hi, I have to store users workspace information in XML file so that user can retreive it later. The information that needed to be stored can be any thing. This XML file will be stores in oracle back end. Well i am not totally well aware of XML advant