GetInstance

is this method a part of an API for a particular class or interface? or is it just a commonly given name for a method in a singleton design pattern?
Can someone explain to me how it works? for instance:
Calendar c = Calendar.getInstance();is that just returning a reference to the calendar object in the Calendar class?
SomeObject o = new SomeObject();o is now an instance of SomeObject, isn't it?

is this method a part of an API for a particular class
or interface? Several, actually.
or is it just a commonly given name for
a method in a singleton design pattern?Yep. Factories too.
Can someone explain to me how it works? for instance:
Calendar c = Calendar.getInstance();is that just returning a reference to the calendar
object in the Calendar class?Well, it depends on which class, obviously, but for Calendar, here's the source. (It comes with the SDK download):
    public static Calendar getInstance()
        return createCalendar(TimeZone.getDefault(), Locale.getDefault());
and createCalendar is
    private static Calendar createCalendar(TimeZone zone,
                            Locale aLocale)
     if (aLocale.getLanguage().compareTo("th") == 0) {
         if (aLocale.getCountry().compareTo("TH") == 0) {
          return new sun.util.BuddhistCalendar(zone, aLocale);
     // else create the default calendar
        return new GregorianCalendar(zone, aLocale);     
SomeObject o = new SomeObject();o is now an instance of SomeObject, isn't it?Yes.

Similar Messages

  • TypeError: Error #1006: getInstance is not a function.

    I having some problems implementing Flex for the first time.
    At the moment I'm getting
    TypeError: Error #1006: getInstance is not a function.
    I suspect that I'm missing a library or something in the
    compile but I don't know how to resolve it.
    When I Run the Application in Flex Builder I get an error
    that the file isn't in the project and that some of the features
    are disabled. This would be consistent with an incomplete compile
    but the file is in a project. I even recreated a new project but I
    get the same errors.
    What am I missing?

    More detail on the error:
    TypeError: Error #1006: getInstance is not a function.
    at mx.core::Singleton$/getInstance()
    at mx.styles::StyleManager$cinit()
    at global$init()
    at mx.containers::Form$cinit()
    at global$init()
    at global$init()
    In debug it was stopping here in Singleton.as
    public static function getInstance(name:String):Object
    var clazz:Class = classMap[name];
    return Object(clazz).getInstance();
    I changed the container from mx:Form to mx:Application so now
    it seems to be working, but I'm not sure why mx:Form was giving me
    this issue.

  • Problem with cipher.getInstance

    hello,
    I am working with JavaCard 2.2.2 on windows with JDK1.5.
    I have this fallowing part of code on my card (in fact I use JCWDE):
    public void initialisation(){
    key = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_DESELECT,KeyBuilder.LENGTH_DES, false);
    // try{
              ecipher = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD,true);
              dcipher = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD,true);
              ecipher.init(key, Cipher.MODE_ENCRYPT);
              dcipher.init(key, Cipher.MODE_DECRYPT);
    //} catch (javacard.security.CryptoException e) {
    When I launch it, I have this error:
    Java Card 2.2.2 Workstation Development Environment, Version 1.3
    Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    jcwde is listening for T=1 Apdu's on TCP/IP port 9 025.
    Exception from the invoked install() method:public static void fr.sogeti.Izy.tes.Test.install(byte[],short,byte) throws javacard.framework.ISOException
    javacard.framework.ISOException
    I dont know why, when i use the debugger mode, this application stop at this line:
    ecipher = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD,true);
    Could you help me?
    Regards
    Alexis

    I try but it doesn't work... (same error)
    if you want I can put my full code?
    my new code:
    private byte[] Crypto = {(byte)0xA0, (byte)0x00,
         (byte)0x00, (byte)0x00, (byte)0x62, (byte)0x03, (byte)0x01, (byte)0x0C,
         (byte)0x0f, (byte)0x01, (byte)0x01};
         public void initialisation(){
    key = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_DESELECT,KeyBuilder.LENGTH_DES, false);
    key.setKey(Crypto, (short)0);
    // try{
              ecipher = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD,false);
              dcipher = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD,false);
              ecipher.init(key, Cipher.MODE_ENCRYPT);
              dcipher.init(key, Cipher.MODE_DECRYPT);
    //} catch (javacard.security.CryptoException e) {
    -----

  • JFreeReportBoot.getInstance().start(); Doesn't work.

    This command ( JFreeReportBoot.getInstance().start(); )
    is required in JFree Reports 0.8.7-9
    Run-time error occurs when executing
    PreviewFrame preview = new PreviewFrame(report);
    Error says: "JFreeReportBoot has not been started. Initialize the system first."
    It works ok in NetBeans but not in Studio Creator. Do I need to do something
    different in Studio Creator?

    What is a minimized start?

  • Unusual use of interface defining static factory class with getInstance

    This question is prompted by a recent New to Java forum question ask about the differences between Interfaces and Abstract classes. Of course one of the standard things mentioned is that interfaces cannot actually implement a method.
    One of my past clients, one of the 500 group, uses interfaces as class factories. The interface defines a pubic static class with a public static method, getInstance, that is called to generate instances of a class that implements the interface.
    This architecture was very object-oriented, made good use of polymorphism and worked very well. But I haven't seen this architecture used anywhere else and it seemed a little convoluted.
    Here is a 'pseudo' version of the basic interface template and use
    -- interface that defines public static factory class and getInstance method
    public interface abc {
        public static class FactoryClass
            public static abc getInstance ()
                return (abc) FactoryGenerator(new abcImpl(), abc.class);
    -- call of interface factory to create an instance
    abc myABC = abc.Factory.getInstance();1. Each main functional area ('abc' in the above) has its own interface factory
    2. Each main functional area has its own implementation class for that interface
    3. There is one generator (FactoryGenerator) that uses the interface class ('abc.class') to determine which implementation class to instantiate and return. The generator class can be configured at startup to control the actual class to return for any given interface.
    I should mention that the people that designed this entire architecture were not novices. They wrote some very sophisticated multi-threaded code that rarely had problems, was high performance and was easy to extend to add new functionality (interfaces and implementing classes) - pretty much plug-n-play with few, if any, side-effects that affected existing modules.
    Is this a best-practices method of designing factory classes and methods? Please provide any comments about the use of an architecture like this.

    Thanks for the feedback.
    >
    I don't see how 'the generator class can be configured at startup to control the actual class to return for any given interface' can possibly be true given this pseudo-code.
    >
    I can see why that isn't clear just from what is posted.
    The way it was explained to me at the time is that the interface uses standard naming conventions and acts like a template to make it easy to clone for new modules: just change 'abc' to 'def' in three places and write a new 'defImpl' class that extends the interface and the new interface and class can just 'plug in' to the framework.
    The new 'defImpl' class established the baseline functionality that must be supported. This line
    return (abc) FactoryGenerator(new abcImpl(), abc.class);uses the initial version of the new class that was defined, 'abcImpl()', when calling the FactoryGenerator and it acted as a 'minimum version supported'. The generator class could use configuration information, if provided, to provide a newer class version that would extend this default class. Their reasoning was that this allowed the framework to use multiple versions of the class as needed when bugs got fixed or new functionality was introduced.
    So the initial objects would be an interface 'abc' and a class 'abcImpl'. Then the next version (bug fixes or enhancements) would be introduced by creating a new class, perhaps 'abcImpl_version2'. A configuration parameter could be passed giving 'abcImpl' as the base class to expect in the FactoryGenerator call and the generator would actually create an instance of 'abcImpl_version2' or any other class that extended 'abcImpl'.
    It certainly go the job done. You could use multiple versions of the class for different environments as you worked new functionality from DEV, TEST, QA and PRODUCTION environments without changing the basic framework.
    I've never seen any Java 'pattern' that looks like that or any pattern where an interface contained a class. It seemed really convoluted to me and seems like the 'versioning' aspect of it could have been accomplished in a more straightforward manner.
    Thanks for the feedback. If you wouldn't mind expanding a bit on one comment you made then I will mark this ANSWERED and put it to rest.
    >
    I don't mind interfaces containing classes per se when necessary
    >
    I have never seen this except at this one site. Would you relate any info about where you have seen or used this or when it might be necessary?

  • Rsa keyfactory.getinstance

    Hi guys could somebody tell me if iaik support keyfactory for rsa?
    Apparently no, infact
    try{
                java.security.KeyFactory fact = java.security.KeyFactory.getInstance ( " RSA" , "IAIK");
    }throw a java.security.NoSuchAlgorithmException: no such algorithm: RSA for provider IAIK.
    Could somebody help me? Suggest?
    thanks in advacne.

    Interesting, I can get this to work(I'm using java 1.4.2 and iaik_jce.jar). Maybe you have bad version of your jar file.
    import iaik.security.provider.IAIK;
    import java.security.KeyFactory;
    import java.security.Security;
    public class temp {
          * @param args
         public static void main(String[] args) {
              Security.addProvider(new IAIK());
              try {
                   KeyFactory kf = KeyFactory.getInstance("RSA", "IAIK");
                   System.out.println(kf.getAlgorithm());
              } catch (Exception e) {
                   e.printStackTrace();
    }

  • Why is ResourceContext.getInstance(anonymous) using UserManagementException

    First of all, I looked at many many disscusions and other places in the internet. I've found no answer
    I have to develop a JEE applicaiton which should read the content of a .properties file in the KM-content of the portal.
    My NWDS is on version 7.3.
    My problem:
    I implemented following code and it doesn't show any errors during developing but ends when deployed and opened on the browser in an 500 Internal Server Error with this error message:
    [EXCEPTION]
    java.lang.NoClassDefFoundError: com/sapportals/portal/security/usermanagement/UserManagementException
    at com.siemens.bt.rolemanager.utils.ConfigurationLoader.getKMContent(ConfigurationLoader.java:89)
    private InputStream getKMContent(String file) throws UMException, ContentException{
         IUser anon = UMFactory.getAnonymousUserFactory().getAnonymousUser();
         IResourceContext resourceContext = ResourceContext.getInstance(anon);
         RID sugg_html = RID.getRID("/documents/" + file);
         com.sapportals.wcm.repository.IResource resource = ResourceFactory.getInstance().getResource(sugg_html,resourceContext);
         return resource.getContent().getInputStream();
    I included these 3 libraries:
    bc.rf.framework_api.jar
    bc.util.public_api.jar
    com.sap.security.api.jar
    prtapi.jar
    I tried it also with including these in addition:
    bc.rf.global.service.urlgenerator_api.jar
    bc.sf.framework_api.jar
    com.sap.portal.usermanagementapi.jar
    km.appl.servlet.webdav_core.jar
    As far as I know. the used methods are all available for version 7.3 but the Exception UserManagementException was replaced by UMException with version 7.1. Why is it showing this message though the method throwing it appears to be a 7.3 method?
    I appreciate fast answer because the application needs to be finished quickly.
    regards
    Daniel

    deploying SAPs libraries with your applcation is always a bad idea. As soon as your AND SAPs Classes land in the same ClassLoader you will gatt all sorts of weired exceptions.
    I was assuming, you develop a Portal Aplication. If you did, you'd have a portalapp.xml File
    Creating Portal Application Projects - Portal - SAP Library
    Creating a Portal Application - Portal - SAP Library
    Now I re-read your original Post -- you have a Java EE Application. The reference techniques are  different here. You would need to add required portal applications using
    <reference reference-type="hard"><reference-target tartget-type="application" provider-name="sap.com>com.sap.km.cm</reference-target></reference>
    BTW, for KM development, I would usually choose a portal application.
    And, unless you are already doing, I'd suggest working with DCs, this way you can resort most buildtime and runtime references using DC-dependancies. Which DCs to use, you can see in the SAP Javadocs, e.g. SAP Javadocs - ResourceContext -- if you scroll to the very bottom, you can see a list of DCs offering that Class

  • Cipher.getInstance("DES") not working in servlet!

    Hi - I'm working on Sun ONE Identity Server 6.1 using Sun ONE Web Server 6.1 using J2SDK 1.4.1_05
    I've modified one of the files to perform DES Encryption prior to getting some data.
    The code works fine when compiled separately - even works fine as a console program - but when I try running it as a servlet - I get a WHOLE bunch of errors when the program hits this line:
    cipher = Cipher.getInstance("DES");Here is the complete code:
    public String encryptPassword(String Password, String AppName)
         Key key;
         Cipher cipher;
         String Data = Password;
         String ApplicationName = AppName;
         String result = new String("hi");
         try
                    ObjectInputStream in = new ObjectInputStream(new FileInputStream("PrivateKey.ser"));
                  key = (Key)in.readObject();
                 in.close();
                 Security.addProvider(new com.sun.crypto.provider.SunJCE());
              cipher = Cipher.getInstance("DES"); // This LINE GIVES THE ERROR
              cipher.init(Cipher.ENCRYPT_MODE, key);
              byte[] stringBytes = Data.getBytes("UTF8");
              byte[] raw = cipher.doFinal(stringBytes);                    
              BASE64Encoder encoder = new BASE64Encoder();
              String result = encoder.encode(raw);
         catch (Exception e)
              // Print some error
    return result;
    }Here is the error log from the webserver:
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Handler method "handleBtnSubmitRequest" threw an exception
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: java.lang.ExceptionInInitializerError
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.a(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.getInstance(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.encryptPassword(UMChangeUserPasswordViewBean.java:244)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.handleBtnSubmitRequest(UMChangeUserPasswordViewBean.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.lang.reflect.Method.invoke(Method.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.command.DefaultRequestHandlingCommand.execute(DefaultRequestHandlingCommand.java:183)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.RequestHandlingViewBase.handleRequest(RequestHandlingViewBase.java:299)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.dispatchInvocation(ViewBeanBase.java:811)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandlerInternal(ViewBeanBase.java:749)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandler(ViewBeanBase.java:596)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:772)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:446)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 27 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.PrivilegedActionException: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.AccessController.doPrivileged(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 28 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.pkcs11.PK11Signature.engineInitVerify(PK11Signature.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.crypto.Signature.initVerify(Signature.java:95) 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.Signature.engineInitVerify(Signature.java:94)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.DSASignature.engineInitVerify(DSASignature.java:70)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.Signature.initVerify(Signature.java:297)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:394)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:363)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.e(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_v.run(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 29 more
    [20/Oct/2003:16:58:01] failure ( 6417):  for host 10.42.7.235 trying to POST /amconsole/user/UMChangeUserPassword, service-j2ee reports: StandardWrapperValve[UMServlet]: WEB2792: Servlet.service() for servlet UMServlet threw exception   com.iplanet.jato.CompleteRequestException   at com.iplanet.am.console.base.ConsoleServletBase.onUncaughtException(ConsoleServletBase.java:331)   at com.iplanet.jato.ApplicationServletBase.fireUncaughtException(ApplicationServletBase.java:1023)   at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:469)   at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)   at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)   at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)    

    Hey.
    Not certain, but I think you need to make sure that your ciphers/certificates are installed on your server. Check the docs on the Sun server, and see what they say about installing certificates.
    Hope this helps.
    Vic

  • [svn:osmf:] 10996: Changing MediaElementLayoutTarget to be constructed via a static ' getInstance' method, instead of by its constructor.

    Revision: 10996
    Author:   [email protected]
    Date:     2009-10-19 07:45:26 -0700 (Mon, 19 Oct 2009)
    Log Message:
    Changing MediaElementLayoutTarget to be constructed via a static 'getInstance' method, instead of by its constructor. This prevents the construction of multiple instances that reference one single media-element. Updating client code accordingly.
    Extending layout unit tests. Adding a custom renderer, checking calculation and layout passes invokation counts.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/osmf/composition/CompositeViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/composition/ParallelViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/composition/SerialViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/gateways/RegionSprite.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/DefaultLayoutRenderer.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/LayoutContextSprite.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/LayoutRendererBase.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/MediaElementLayoutTarget.as
        osmf/trunk/framework/MediaFramework/org/osmf/utils/MediaFrameworkStrings.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/composition/TestParallelViewableTrai t.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/gateways/TestRegionSprite.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestDefaultLayoutRenderer.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestLayoutUtils.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestMediaElementLayoutTarget. as
    Added Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/composition/CustomRenderer.as

    AlexCox, can you clarify that once you get the default model out and save it in the temp var, that your ONLY access to the data is then through temp and never through the JList methods?
    Quick question for everyone: Are any of you using JList.setListData to set you initial dataset? I think that is where the bug lies. When I do not use it and start with an empty list, I am able to add to that list, and then remove from that list using the following line:
    ((DefaultListModel)myList.getModel).remove(###);
    And this cast works everytime.
    But when I start that list out with some data such as:
    myList.setListData(myStringArray);
    and then try to execute the above line, boom! I get the ClassCast exception.
    I think setListData creates a whole new model which is an inner class to JList (which seems stupid when DefaultListModel seems made for this).
    Just my thoughts on where the problem lies. I'll add my data directly to the list and see if that works better.
    PK

  • 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.

  • Why defining Interface for singleton with getInstance() doesnt work?

    Lets say I want to do the following:
    package adapters
        public interface IAdapter
            function init():void         
            function getInstance():IAdapter
    package adapters
        public class DAAdapter extends EventDispatcher implements IAdapter
            private static var _instance:DAAdapter;
            public static function getInstance():IAdapter {
                if(!_instance)
                    _instance = new DAAdapter();
                return _instance;
            function DAAdapter(target:IEventDispatcher=null)
                super(target);
         public function init() {}
    I getting:
    1044: Interface method getInstance in namespace adapters:IAdapter not implemented by class adapters:DAAdapter.
    Why?

    In AS3 you cannot use interface definitions for static methods.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#static

  • Why have getInstance methods?

    Can anyone please explain what is the purpose of a getInstance method.
    If a class is abstract and cannot be instantiated why does the class allow you to make an instance of it by using a getInstance method. I find this concept very confusing.
    Cheers

    To control instantiation. E.g. for singletons, or factories, or like this
    public class RestrictedValue {
      private RestrictedValue(int i) { // can't be called by anybody else
      static RestrictedValue getInstance(int value) {
        if (value > 0 && value < 128) {
          return new RestrictedValue(value);
        } else {
          return null;
    }Not the nicest code, but you get the idea.

  • GetInstance() vs static methods

    Say you want some globally accessible manager type class.
    I can think of two ways to do it.
    1. singleton. i.e. private constructor, static getInstanceMethod(), non-static methods. So you do: Manager.getInstance().doIt();
    2. private constructor, static methods.
    So you do: Manager.doIt();
    What are the benefits of each?
    Any ideas?
    Cheers,
    Jim

    http://www.google.com/search?q=singleton+vs.+static+methods

  • Cipher.getInstance("DES") gives a Servlet Error!

    Hi - I'm working on Sun ONE Identity Server 6.1 using Sun ONE Web Server 6.1 using J2SDK 1.4.1_05
    I've modified one of the files to perform DES Encryption prior to getting some data.
    The code works fine when compiled separately - even works fine as a console program - but when I try running it as a servlet - I get a WHOLE bunch of errors when the program hits this line:
    cipher = Cipher.getInstance("DES");Here is the complete code:
    public String encryptPassword(String Password, String AppName)
         Key key;
         Cipher cipher;
         String Data = Password;
         String ApplicationName = AppName;
         String result = new String("hi");
         try
                    ObjectInputStream in = new ObjectInputStream(new FileInputStream("PrivateKey.ser"));
                  key = (Key)in.readObject();
                 in.close();
                 Security.addProvider(new com.sun.crypto.provider.SunJCE());
              cipher = Cipher.getInstance("DES"); // This LINE GIVES THE ERROR
              cipher.init(Cipher.ENCRYPT_MODE, key);
              byte[] stringBytes = Data.getBytes("UTF8");
              byte[] raw = cipher.doFinal(stringBytes);                    
              BASE64Encoder encoder = new BASE64Encoder();
              String result = encoder.encode(raw);
         catch (Exception e)
              // Print some error
    return result;
    }Here is the error log from the webserver:
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Handler method "handleBtnSubmitRequest" threw an exception
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: java.lang.ExceptionInInitializerError
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.a(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.Cipher.getInstance(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.encryptPassword(UMChangeUserPasswordViewBean.java:244)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.am.console.user.UMChangeUserPasswordViewBean.handleBtnSubmitRequest(UMChangeUserPasswordViewBean.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.lang.reflect.Method.invoke(Method.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.command.DefaultRequestHandlingCommand.execute(DefaultRequestHandlingCommand.java:183)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.RequestHandlingViewBase.handleRequest(RequestHandlingViewBase.java:299)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.dispatchInvocation(ViewBeanBase.java:811)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandlerInternal(ViewBeanBase.java:749)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.view.ViewBeanBase.invokeRequestHandler(ViewBeanBase.java:596)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:772)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:446)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 27 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.PrivilegedActionException: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.AccessController.doPrivileged(Native Method)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 28 more
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: Caused by: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.pkcs11.PK11Signature.engineInitVerify(PK11Signature.java:172)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.crypto.Signature.initVerify(Signature.java:95) 
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.Signature.engineInitVerify(Signature.java:94)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at org.mozilla.jss.provider.DSASignature.engineInitVerify(DSASignature.java:70)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at java.security.Signature.initVerify(Signature.java:297)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:394)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:363)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_b.e(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: at javax.crypto.SunJCE_v.run(DashoA6275)
    [20/Oct/2003:16:58:01] warning ( 6417):  CORE3283: stderr: ... 29 more
    [20/Oct/2003:16:58:01] failure ( 6417):  for host 10.42.7.235 trying to POST /amconsole/user/UMChangeUserPassword, service-j2ee reports: StandardWrapperValve[UMServlet]: WEB2792: Servlet.service() for servlet UMServlet threw exception   com.iplanet.jato.CompleteRequestException   at com.iplanet.am.console.base.ConsoleServletBase.onUncaughtException(ConsoleServletBase.java:331)   at com.iplanet.jato.ApplicationServletBase.fireUncaughtException(ApplicationServletBase.java:1023)   at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:469)   at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:324)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)   at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)   at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)   at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)   at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)   

    Hi - I'm working on Sun ONE Identity Server 6.1 using
    Sun ONE Web Server 6.1 using J2SDK 1.4.1_05
    I've modified one of the files to perform DES
    Encryption prior to getting some data.
    The code works fine when compiled separately - even
    works fine as a console program - but when I try
    running it as a servlet - I get a WHOLE bunch of
    errors when the program hits this line:Actually, I think the errors are telling you the problem - you're just getting tangled up in the stacktraces. Let's get rid of everything except the "causes" lines:Handler method "handleBtnSubmitRequest" threw an exception
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    CORE3283: stderr: at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
    Caused by: java.security.PrivilegedActionException: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key
    at java.security.AccessController.doPrivileged(Native Method)
    Caused by: java.security.InvalidKeyException: publicKey is not a PKCS #11 public key 
    failure ( 6417):  for host 10.42.7.235 trying to POST amconsole/user/UMChangeUserPassword, service-j2eeLooks to me like the ctor for Cipher is unhappy because it's finding a key that isn't a PKCS#11 public key while it's trying to set up.
    What trust-store is your installation using? Have you run keytool -list on it? Possibly there's a bad key/cert in there.
    What do you expect "key" to be, in your code? How certain are you that it's really a DES key? If someone asked me to guess from the filename "PrivateKey.ser", I'd guess it was the private half an RSA keypair, which will NOT work for DES - but that may be just an unfortunate choice of filenames.
    The net is, you need to figure out where the installation is finding the thing that's causing the InvalidKeyException. Haven't used SunONE, so I'm not much help on exactly where to look - you might post on a SunONE list, to get help from admin-mavens...
    Good luck!
    Grant

  • Getting Current time - calendar.getInstance() vs System.getTime...

    Is there a difference between getting a new calendar instance and getting the system time explicitly.
    With regards to getting the current.

    No. Calendar.getInstance() eventually leads to this constructor being called
    (assuming you are not getting the Thai or Japanese Imperial calendar)
        public GregorianCalendar(TimeZone zone, Locale aLocale) {
            super(zone, aLocale);
         gdate = (BaseCalendar.Date) gcal.newCalendarDate(zone);
            setTimeInMillis(System.currentTimeMillis());
        }

  • Problem while using getInstance

    Hi
    I an stuck with a problem for which i need your help.
    I want to pass a DTO to the method as a parameter the code is as below.
    private static void convertList(Collection retVal,Object[] values,Class changetoDTO){
                   System.out.println("method start");
                   int i = 0;
                   for (Iterator itr = retVal.iterator();itr.hasNext();i++) {
                        Object obj = itr.next();
                        if(obj != null && obj instanceof changetoDTO) {
                             changetoDTO = (changetoDTO) obj;
                             values[i] = changetoDTO;
    Here changetoDTO parameter is the name of the DTO class ex: xyzDTO
    The problem is that when i pass the DTO as a Class type to this method. i am getting this error after getInstance keyword.
    changetoDTO cannot be resolved to a type.
    Even if i do a getClasss() here still the problem persists.
    whats the problem with my code.
    Any help from you would be very useful.please let me know this at the earliest as we are stuck herE and cannot proceed.
    Regards
    Vikeng

    The right-hand operand of an instanceof expression must be statically defined. That is, it must be known at compile time. What you're doing cannot be done. Simply compare the result of obj.getClass() to changeToDTO. (I've assumed some code you missed out of your example)
    private static void convertList(Collection retVal,Object[] values,Class changetoDTO){
    System.out.println("method start");
    int i = 0;
    for (Iterator itr = retVal.iterator();itr.hasNext();i++) {
    Object obj = itr.next();
    // works ONLY if the classes are the same
    if(obj.getClass().equals(changetoDTO) ) {
    changetoDTO = (changetoDTO) obj;
    values[i++] = changetoDTO;
    }But if you want to capture subclasses of changetoDTO you need
    private static void convertList(Collection retVal,Object[] values,Class changetoDTO){
    System.out.println("method start");
    int i = 0;
    for (Iterator itr = retVal.iterator();itr.hasNext();i++) {
    Object obj = itr.next();
    // works for subclasses
    if(changetoDTO.isAssignableFrom(obj.getClass() ) {
    changetoDTO = (changetoDTO) obj;
    values[i++] = changetoDTO;
    }But I'd question the wisdom of values being an array. What if the collection isn't the same size?

Maybe you are looking for

  • Do games run better when played using windows xp?

    i was wondering if games run better if you have windows xp on your macbook?

  • Pourquoi mon mac démarre en mode safe boot?

    Sans raison apparente, mon mac s'est mis à démarrer en mode safe boot: un écran gris avec marqué en haut à droite en rouge "Safe Boot" puis le choix entre ma session et une session invité. Si je clique sur une de ces deux options, la session va se me

  • Dynamic text and url...

    Hi, I'm trying to create an url to a word inside a dynamic textbox but I'm not sure how to do that. I'm familiar with TextFormats, etc. but that only apply to the textbox and not to a word or a sentence inside that textbox. Or have I been misguided??

  • Directory configuration could not be completed during instal

    Scenario: 1) New install sles 11 + oes 11 2) Have backup of domain and postoffice from a dead Groupwise 8 server 3) Upgraded to Groupwise 2014 using copies of the Backup of domain and post office copied onto new server. 4) Everything works - or seems

  • Form will not print the typed information?

    My forms will not print the typed information only the form itself as a blank form. I have Acrobate 8 Professional V. 8.3.1 Please advise on how to correct this annoying problem that started with the latest update. Thanks