Obtain CallerPrincipal in a utility class

Hi,
I'd like to obtain the caller principal of a ejb from a utility class. I know I can easily get the EJBContext inside the ejb itself using the callback from the container to the setSeccionCoontect method, but what if I need to knwo the caller principal in a utility class called by a business method of my ejb?
By the way, I'm using EJB2.1 in Weblogic 8.1 and I'm talking about SessionBeans. I know I could obtain the caller principal inside my ejb and simply pass it as a parameter to my utility class, but I dont liek to idea of adding a user parameter to my utility clases method.
I'm aware that I could do a InitialContext.lookup("java:/comp/EJBContext") if I was using a EJB3 container, but I cant find the equivalent with EJB2.
Thanks!

Every thread has a stack of its own and its own copies of local variables, if a static method uses only locals it doesn't have to be synchronized.
Using lazy initialization with the singleton pattern is a good example of side effects. Examine this code:class Singleton {
    static Singleton instance;
    static Singleton getInstance() {
        if (instance == null) instance = new Singleton();
        return instance;
    // don't allow other classes to create an instance
    private Singleton() {}
}Now what happens if two threads simultaneously enter the getInstance method and both find the value of the "instance" variable null in the if-condition? You end up creating an instance of the class twice, which is not what you want. This can be solved by writing the method declaration as "synchronized static Singleton getInstance()" so no two threads can enter the method simultaneously.

Similar Messages

  • Obtaining pooled connection in utility class.

    Hello,
    For our ADF application,
    There is a utility class obtaining DB connection. Presently it is directly using JDBC to obtain the same. We need to change it to use connection from the Weblogic connection pool, that gets built at the start of server.
    Please can you suggest a specific link that I can refer?
    Regards,
    Amar

    Well create a datasource in weblogic and then in your AM - Configurations - Double click on Local - Application Module Tab - Connection Type section - Select JDBC DataSource - and in the datasource name give the name of datasource you created in weblogic

  • How does the JVM handle private class parameters in a utility class?

    If I have a class that is public and not labeled as static, but it's constructor is private so that it cannot be instantiated, and all of its parameters and methods are both private and static. The methods modify the private parameters. In this case, the code explicitly is avoiding a singleton pattern, so there isn't even a class being instantiated, so this is a true utility class.
    However, the static methods are accessible from multiple objects, and as far as I can tell, the JVM is persisting the parameters in memory beyond the specific thread that called the static method to begin with.
    The question I have is how the JVM handles this? Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. I am working with byte code injection, and the assumption is that a direct reference to a static parameter is much faster to call than having to go through an object reference. Of course, from a programmer point of view, I much prefer the singleton pattern since I am so used to hang my hat on a class reference.
    Thanks.

    entguru wrote:
    However, the static methods are accessible from multiple objects...Not if the methods are private, as you seemed to indicate ("all of its parameters and methods are both private and static").
    Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. There is a class reference. It refers to the class, and is obtainable via the class literal; e.g., MyClass.class.
    ~

  • RE: [iPlanet-JATO] Re: Use Of models in utility classes

    Hi all,
    if you add the following to your spider2jato.xml
    It will automatically map your CSpDataObject.executeImmediate to use
    ExecuteImmediateUtil.executeImmediateSelect with the arguments mapped as
    well.
    Kostas
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpDataObject[.\s]*executeImmediate[\s]*\(([^,]*),([^)]*)\)]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpDataObject[.\s]*executeImmediate[\s]*\(([^,]*),([^)]*)\)]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[ExecuteImmediateUtil.executeImmediateSelect($1,$2,
    getRequestContext())]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    -----Original Message-----
    From: Matthew Stevens
    Cc: vnamboori@y...
    Sent: 11/29/01 11:23 AM
    Subject: RE: [iPlanet-JATO] Re: Use Of models in utility classes
    Namburi,
    I have included an example in the file ExecuteImmediateUtil.java
    The Yahoo Group will not handle the attached file we will put it in the
    Files section shortly.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Thursday, November 29, 2001 12:29 PM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes
    Matt,
    For CSpSelect.executeImmediate() I have an example of custom helpermethod as a replacement which uses JDBC results instead of
    CSpDBResult.
    Can you send me this example.
    Thanks
    Namburi
    --- In iPlanet-JATO@y..., "Matthew Stevens" <matthew.stevens@E...>
    wrote:
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities.Essentially, you
    either need to convert these utilities to Models themselves or keepthe
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helpermethod
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the
    manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive.Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    [Non-text portions of this message have been removed]
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    [Non-text portions of this message have been removed]

    Hi all,
    if you add the following to your spider2jato.xml
    It will automatically map your CSpDataObject.executeImmediate to use
    ExecuteImmediateUtil.executeImmediateSelect with the arguments mapped as
    well.
    Kostas
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpDataObject[.\s]*executeImmediate[\s]*\(([^,]*),([^)]*)\)]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpDataObject[.\s]*executeImmediate[\s]*\(([^,]*),([^)]*)\)]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[ExecuteImmediateUtil.executeImmediateSelect($1,$2,
    getRequestContext())]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    -----Original Message-----
    From: Matthew Stevens
    Cc: vnamboori@y...
    Sent: 11/29/01 11:23 AM
    Subject: RE: [iPlanet-JATO] Re: Use Of models in utility classes
    Namburi,
    I have included an example in the file ExecuteImmediateUtil.java
    The Yahoo Group will not handle the attached file we will put it in the
    Files section shortly.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Thursday, November 29, 2001 12:29 PM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes
    Matt,
    For CSpSelect.executeImmediate() I have an example of custom helpermethod as a replacement which uses JDBC results instead of
    CSpDBResult.
    Can you send me this example.
    Thanks
    Namburi
    --- In iPlanet-JATO@y..., "Matthew Stevens" <matthew.stevens@E...>
    wrote:
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities.Essentially, you
    either need to convert these utilities to Models themselves or keepthe
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helpermethod
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the
    manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive.Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    [Non-text portions of this message have been removed]
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    [Non-text portions of this message have been removed]

  • Re: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't forget about the regular expression potential

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

  • Re: [iPlanet-JATO] Use Of models in utility classes

    Hi Matt,
    Sounds like some of the stuff we need to migrate has a lot in common with
    Namburi's project.
    I would be very keen to get hold of a copy of the 'tactic' document you
    mention below, as well as the sample code you mention to replace CspDBResult
    stuff with JDBC results.
    Thanks in advance,
    Phil
    ----- Original Message -----
    From: Matthew Stevens <matthew.stevens@E...>
    Sent: Wednesday, August 08, 2001 7:56 AM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities. Essentially, you
    either need to convert these utilities to Models themselves or keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helper method
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]

    Hi Matt,
    Sounds like some of the stuff we need to migrate has a lot in common with
    Namburi's project.
    I would be very keen to get hold of a copy of the 'tactic' document you
    mention below, as well as the sample code you mention to replace CspDBResult
    stuff with JDBC results.
    Thanks in advance,
    Phil
    ----- Original Message -----
    From: Matthew Stevens <matthew.stevens@E...>
    Sent: Wednesday, August 08, 2001 7:56 AM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has thedetails
    on various tactics of migrating these type of utilities. Essentially, you
    either need to convert these utilities to Models themselves or keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of custom helper method
    as a replacement whicch uses JDBC results instead of CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100253094145066046167121181">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes. These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do the manipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion for these
    utilities we have to do manually.
    My question is Can we access the the models in the post migration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObject intensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]

  • Is there a Java utility class to help with data management in a desktop UI?

    Is there a Java utility class to help with data management in a desktop UI?
    I am writing a UI to configure a network device that will be connected to the serial port of the computer while it is being configured. There is no web server or database for my application. The UI has a large number of fields (50+) spread across 16 tabs. I will write the UI in Java FX. It should run inside the browser when launched, and issue commands to the network device through the serial port. A UI has several input fields spread across tabs and one single Submit button. If a field is edited, and the submit button clicked, it issues a command and sends the new datum to the device, retrieves current value and any errors. so if input field has bad data, it is indicated for example, the field has a red border.
    Is there a standard design pattern or Java utility class to accomplish the frequently encountered, 'generic' parts of this scenario? lazy loading, submitting only what fields changed, displaying what fields have errors etc. (I dont want to reinvent the wheel if it is already there). Otherwise I can write such a class and share it back here if it is useful.
    someone recommended JGoodies Bindings for Swing - will this work well and in FX?

    Many thanks for the reply.
    In the servlet create an Arraylist and in th efor
    loop put the insances of the csqabean in this
    ArrayList. Exit the for loop and then add the
    ArrayList as an attribute to the session.I am making the use of Vector and did the same thing as u mentioned.I am using scriplets...
    >
    In the jsp retrieve the array list from the session
    and in a for loop step through the ArrayList
    retrieving each CourseSectionQABean and displaying.
    You can do this in a scriptlet but should also check
    out the jstl tags.I am able to remove this problem.Thanks again for the suggestion.
    AS

  • ClassNotFoundException on utility class in JTA Transaction

    When using user defined transactions, I am finding I get odd
              ClassNotFoundExceptions. I've tested this primarily on NT/2000, but did
              also confirm it on Solaris. Can anyone explain it?
              The exception only seems to occur if it becomes necessary to throw an
              exception from the EJB. If I am not inside a user defined transaction,
              there are no problems. (Even if the method is marked as Transacation
              Required). Similarly, if no exception is thrown, there is also no problem
              (even though I use plenty of other utility classes)
              The classes (including the utility class) are all in my deployed jar file
              (which is deployed as part of an ear file).
              The error message is below:
              java.lang.ClassNotFoundException:
              com.iknowledge.inext.exception.STInvalidNameException
              at
              weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.
              java:178)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:195)
              at
              weblogic.j2ee.ApplicationManager.loadFromNetwork(ApplicationManager.java:248
              at
              weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:175)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInputStream.
              java:211)
              at
              weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputStream.re
              adClassDescriptor(ChunkedObjectInputStream.java:290)
              at
              java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:906)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
              at
              java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
              at
              java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2263)
              at
              java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:519)
              at
              java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1412)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
              putStream.java:107)
              at
              weblogic.transaction.internal.PropagationContext.readExternal(PropagationCon
              text.java:304)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
              putStream.java:97)
              at
              weblogic.common.internal.ChunkedObjectInputStream.readObjectWL(ChunkedObject
              InputStream.java:123)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readTxContext(MsgAbbrevInputStream.java:1
              66)
              at
              weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
              ava:156)
              at
              weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:581)
              at
              weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
              at
              weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java:638)
              at
              weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

    You closed your Main class with a bracket, so your getConnection() method isn't in a class
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
        public static void main(String[] args) {
            Connection con = getConnection();
            System.out.println("The connection is: " +con );
    }That is your entire Main class. Anything below it isn't in the class.

  • Accessing utility classes from ebj

    I have a session bean trying to access a utility class in the lib directory (same
    directory as weblogic.jar). I have packaged it into a jar file and set the classpath
    pointing to the file in the startWeblogic.cmd file. I compiled and depolyed the session
    bean and it runs fine until it starts to access the class. I got NoClassFoundException.
    I have tried to shut down and restart the server without any success. Anyone can
    help me this this?
    I know I can package the utility into the same jar as my ejb. But I don't want to
    do it because it is going to be everywhere. What is the right way of doing it?
    Thanks in advance.
    L.W.Xu

    Rob,
    You are right.
    Thanks a lot.
    L.W.X.
    Rob Woollen <[email protected]> wrote:
    >
    >
    If it's in the server classpath, the ejb will have no problem finding it.
    Either you have a typo and the class is not in the classpath. You can prove
    this by running
    javap on the class using the same classpath as your startWebLogic script.
    Or, as I suggested in the last response, it's not really standalone. The
    jar probably has a
    dependence on some classes in the ejb.jar.
    -- Rob
    "L. W. Xu" wrote:
    Rob,
    It is a standalone generic jar which has some classes in it. The ejb justcan't find
    it.
    I have a simple java program which uses it and it runs fine.
    Thanks.
    L. W. Xu
    Rob Woollen <[email protected]> wrote:
    If your utility.jar is standalone, then your approach is fine. However,
    it sounds like it
    is referencing a class that's only
    available in your ejb.jar. That won't work.
    -- Rob
    "L. W. Xu" wrote:
    I have a session bean trying to access a utility class in the lib directory(same
    directory as weblogic.jar). I have packaged it into a jar file and
    set
    the classpath
    pointing to the file in the startWeblogic.cmd file. I compiled and
    depolyed
    the session
    bean and it runs fine until it starts to access the class. I got NoClassFoundException.
    I have tried to shut down and restart the server without any success.Anyone can
    help me this this?
    I know I can package the utility into the same jar as my ejb. But I
    don't
    want to
    do it because it is going to be everywhere. What is the right way of
    doing
    it?
    Thanks in advance.
    L.W.Xu--
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    If your utility.jar is standalone, then your approach is fine. However,
    it sounds like it is referencing a class that's only
    <br>available in your ejb.jar. That won't work.
    <p>-- Rob
    <p>"L. W. Xu" wrote:
    <blockquote TYPE=CITE>I have a session bean trying to access a utility
    class in the lib directory (same
    <br>directory as weblogic.jar). I have packaged it into a jar file and
    set the classpath
    <br>pointing to the file in the startWeblogic.cmd file. I compiled and
    depolyed the session
    <br>bean and it runs fine until it starts to access the class. I gotNoClassFoundException.
    <br>I have tried to shut down and restart the server without any success.
    Anyone can
    <br>help me this this?
    <p>I know I can package the utility into the same jar as my ejb. ButI
    don't want to
    <br>do it because it is going to be everywhere. What is the right wayof
    doing it?
    <p>Thanks in advance.
    <p>L.W.Xu</blockquote>
    <pre>--
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com</pre>
    </html>
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    If it's in the server classpath, the ejb will have no problem finding it.
    <p>Either you have a typo and the class is not in the classpath. 
    You can prove this by running javap on the class using the same classpath
    as your startWebLogic script.
    <p>Or, as I suggested in the last response, it's not really standalone.  
    The jar probably has a dependence on some classes in the ejb.jar.
    <p>-- Rob
    <br> 
    <p>"L. W. Xu" wrote:
    <blockquote TYPE=CITE>Rob,
    <p>It is a standalone generic jar which has some classes in it. The ejb
    just can't find
    <br>it.
    <p>I have a simple java program which uses it and it runs fine.
    <p>Thanks.
    <p>L. W. Xu
    <p>Rob Woollen <[email protected]> wrote:
    <br>>
    <br>>
    <br>>If your utility.jar is standalone, then your approach is fine. 
    However,
    <br>>it sounds like it
    <br>>is referencing a class that's only
    <br>>available in your ejb.jar.  That won't work.
    <br>>
    <br>>-- Rob
    <br>>
    <br>>"L. W. Xu" wrote:
    <br>>
    <br>>> I have a session bean trying to access a utility class in the lib
    directory
    <br>>(same
    <br>>> directory as weblogic.jar). I have packaged it into a jar file and
    set
    <br>>the classpath
    <br>>> pointing to the file in the startWeblogic.cmd file. I compiled and
    depolyed
    <br>>the session
    <br>>> bean and it runs fine until it starts to access the class. I got
    NoClassFoundException.
    <br>>> I have tried to shut down and restart the server without any success.
    <br>>Anyone can
    <br>>> help me this this?
    <br>>>
    <br>>> I know I can package the utility into the same jar as my ejb. But
    I don't
    <br>>want to
    <br>>> do it because it is going to be everywhere. What is the right way
    of doing
    <br>>it?
    <br>>>
    <br>>> Thanks in advance.
    <br>>>
    <br>>> L.W.Xu
    <br>>
    <br>>--
    <br>>
    <br>>----------------------------------------------------------------------
    <br>>
    <br>>AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    <br>>
    <br>>by Michael Girdley, Rob Woollen, and Sandra Emerson
    <br>>
    <br>>http://learnWebLogic.com
    <br>>
    <br>>
    <br>>
    <br>>
    <br>><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <br>><html>
    <br>>If your utility.jar is standalone, then your approach is fine. 
    However,
    <br>>it sounds like it is referencing a class that's only
    <br>><br>available in your ejb.jar.  That won't work.
    <br>><p>-- Rob
    <br>><p>"L. W. Xu" wrote:
    <br>><blockquote TYPE=CITE>I have a session bean trying to access a
    utility
    <br>>class in the lib directory (same
    <br>><br>directory as weblogic.jar). I have packaged it into a jar file
    and
    <br>>set the classpath
    <br>><br>pointing to the file in the startWeblogic.cmd file. I compiled
    and
    <br>>depolyed the session
    <br>><br>bean and it runs fine until it starts to access the class.
    I got NoClassFoundException.
    <br>><br>I have tried to shut down and restart the server without any
    success.
    <br>>Anyone can
    <br>><br>help me this this?
    <br>><p>I know I can package the utility into the same jar as my ejb.
    But I
    <br>>don't want to
    <br>><br>do it because it is going to be everywhere. What is the right
    way of
    <br>>doing it?
    <br>><p>Thanks in advance.
    <br>><p>L.W.Xu</blockquote>
    <br>>
    <br>><pre>--
    <br>>
    <br>>----------------------------------------------------------------------
    <br>>
    <br>>AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    <br>>
    <br>>by Michael Girdley, Rob Woollen, and Sandra Emerson
    <br>>
    <br>>http://learnWebLogic.com"><a
    href="http://learnWebLogic.com">http://learnWebLogic.com</a></A></pre>
    <br>> </html>
    <br>>
    <br>></blockquote>
    <pre>-- 
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    <A HREF="http://learnWebLogic.com">http://learnWebLogic.com</A></pre>
     </html>

  • Can I create a JTA EntityManagerFactory in a utility class in a .jar file?

    I have utility classes in a .jar file inside of a .war file deployed in Glassfish 3.1. One of these utility classes, CredentialsUtil, needs to access a database. I can't inject an EntityManager into CredentialsUtil since it is not an EJB. (For security reasons I don't want to make CredentialsUtil an EJB. I want it to be a POJO.)
    In CredentialsUtil I need an EntityManagerFactory that is connected to a datasource defined in Glassfish. Here is the line from CredentialsUtil.java and from the persistence.xml both of which will be in the util.jar file:
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("Credpu");
    <persistence-unit name="Credpu" transaction-type="JTA">
    I can't use RESOURCE_LOCAL since any changes to the datasource configuration must be done in Glassfish rather than changing persistence.xml.
    (The transaction context is not important in CredentialsUtil. It will be called by a WS-Security handler which may not have a transaction context.)
    Can I put the persistence.xml and the CredentialsUtil class that creates the EntityManagerFactory from it inside of the util.jar file (which will be in a .war), or do I have to move the class and a copy of the persistence.xml file out to the .war file? (I'll have to leave persistence.xml in the .jar file too since there are some @Entity in the .jar file. I don't know why but there are @Entity pojos in the .jar file.)
    I'd like to use the existing persistence.xml, but if I can't is there is a way to create an EntityManagerFactory (or EntityManager) that gets its datasource directly from Glassfish, ignoring persistence.xml?
    Thanks.

    Styles in Pages are saved in the documents (or templates). There is no easy method for adding a style to a built-in template (and it is strongly recommended that you do not tamper with them). You can open a built- in template, add your style and save it as a user template so that your new style will be standard in documents created from that template.

  • Using Async calls in a Util class

    I have a Utility class that I want to put code in that I'm reusing over and over again.  This includes Async.handleEvent calls.  If I call an instance of the Util class from a [Test(async)] method, can I use the Async call in that other event?
    When I tried this in my code, it said that it "Cannot add asynchronous functionality to methods defined by Test,Before or After that are not marked async" but my [Test] is marked as async. And when I was in the same class, I was able to have non-Test methods make Async calls.
    Thanks for the help!
    Mocked up Example (please note these are two separate files):
    // Test.as
    package
        import TimerUtil;
        public class Test
            [Test(async)]
            public function waitForTimer():void
                TimerUtil.newTimer();
    // TimerUtil.as
    package
        import flash.events.TimerEvent;
        import flash.utils.Timer;
        import org.flexunit.async.Async;
        public class TimerUtil
            private static var instance:TimerUtil;
            private var timer:Timer;
            private static const TIME_OUT:int = 1000;
            public static function newTimer() : void
                if (!instance) instance = new TimerUtil();
                instance.timer = new Timer(1000, 5);
                instance.timer.start();
                instance.waitForFifthTick();
            private function waitForFifthTick() : void
                Async.handleEvent(this, instance.timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);
            private function handleTimerTick ( evt:TimerEvent, eventObject:Object) : void
                if ( timer.currentCount == 5 )
                    // We are at the Fifth click, move on.
                else
                    Async.handleEvent(this, instance.timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);
    Message was edited by: zyellowman2
    I missed a comma.  And a few "instance"s

    Yes, you can put async calls in utility classes or wherever you want. That isn't the issue here though.
    In your test you call TimerUtil.newTimer()
    That code creates a timer and then returns. Then your test returns. At that moment, FlexUnit sees that your test has finished and that there are no outstanding registered asynchronous events so it declares the test a success. Then, a second later, your other method executes and tries to register an async call. FlexUnit has no idea what test this pertains to, or why this call is being made as it is no longer in the context of the original test, hence the message you are receiving that you can only using Async calls inside of a method marked with a Async... as, in FlexUnit's opion, the method that is executing this code no longer has anything to do with a test with an async param.
    The best way to think about this is a chain that cannot be broken. As soon as a method finishes executing with, FlexUnit will declare it a success unless we are waiting on something else (an async event of some sort) That is what the Async syntax really does, it tells the framework not to declare this method a success just yet, and that there is something else we need to account for to make that decision.
    So, right now, in your newTimer() you don't let the framework know that you will be waiting for an async event. Therefore, when that method and the test method is over, so is the test.
    Mike

  • Issue: Using utility class instance

    Hi,
    I need to use OIM APIs.
    I am using Eclipse IDE and have made the settings accordingly.
    I am able to connect successfully and also able to get the instance of factory class.
    Also then I am able to fetch the instance of utility class, tcUserOperationsIntf.
    But next when I am trying to call any method of this utility class using the instance, I am getting null pointer exception.
    Kindly help.

    public class oimtest {
         public tcUtilityFactory getUtilFacObject()throws Exception
              try
                   ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
                   final Hashtable env = config.getAllSettings();
                   tcUtilityFactory ioUtilityFactory;
                   System.out.println("1");
                   tcSignatureMessage mysign = tcCryptoUtil.sign("xelsysadm", "PrivateKey");
                   System.out.println("2");
                   ioUtilityFactory = new tcUtilityFactory(env,mysign);
                   System.out.println("3");
                   return ioUtilityFactory;
              catch(Exception e)
                   System.out.println("Exception in establishing connection is: "+e);
                   return null;
         public void mymethod()throws IOException, ServletException
    String orgid = "Xellerate Users";
    HashMap uidmap = new HashMap();
    uidmap.put("Organizations.Organization Name",orgid);
    int a=4;
    Long userkey=new Long(a);
         try
    tcUtilityFactory ioUtilityFactory = this.getUtilFacObject();
    System.out.println("4");
         tcUserOperationsIntf userIntf=(tcUserOperationsIntf)ioUtilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
              System.out.println("6");
              String s=userIntf.toString();
              System.out.println("It is"+s);
              userIntf.disableUser(userkey);
    tcResultSet urset=userIntf.findUsers(uidmap);
    System.out.println("7");
    if(!urset.isEmpty())
    int len =urset.getTotalRowCount();
         System.out.println("length:"+ len);
    catch(Exception ex){
         System.out.println("Exception is: "+ex.getMessage());
         System.out.println("Exception is: "+ex);
    I am getting the following output when calling mymethod() from the main class-
    1
    2
    3
    4
    log4j:WARN No appenders could be found for logger (XELLERATE.ACCOUNTMANAGEMENT).
    log4j:WARN Please initialize the log4j system properly.
    6
    It isThor.API.Operations.tcUserOperationsClient@2f4b20
    Exception is: null
    Exception is: java.lang.NullPointerException

  • Need info on Date Utility Classes

    Hi Experts,
    Can someone please suggest me some re-usable date utility classes which I can re-use in my application(preferably date utility classes provided by basis so I dont need to bother about package ) ? What I want to do is pretty simple: Read current date/current month/Year and do basic date calculations.
    Best Regards,
    Viqar Ali.

    Vijay,
    I got a few classes(mostly BSP utility classes), but I could not use them due to package dependancy problems. Can somebody please suggest some date utility classes which I can use in my Web-Dynpro applications ?
    Best Regards,
    Viqar Ali.

  • Referencing utility classes from a war file

    How do you reference a utility class from a war file? I tried adding the class to the deployment plan descriptor, however I still get a ClassNotFoundException.
    Thanks,
    Will

    To use the utility classes from a war you have to place them under the web-inf/classes directory.
    webApplication(WAR directory)--->WEB-INF--> classes (put your utility classes in this directory)

  • JavaDocError: Utility classes should not have a public or default construct

    Hello all,
    I am trying to comply with some check style errors that i am getting and i cannot seem to figure out what is going on. I have set all non-data members to private, except for call point public static void main(string[] args) and i am still getting this error. "Utility classes should not have a public or default constructor." I cannot figure out what is going on, any help would be greatly welcomed. My code is posted below.
    public final class Main
         * Constant Data Member: RECTANGLE
         * Purpose: contains the constant string representing a rectangle.
         * @deprecated RECTANGLE Representitive string value for a rectangle.
        public static final String RECTANGLE = "rectangle";
         * Constant Data Member: TRIANGLE
         * Purpose: contains the constant string representing a triangle.
         * @deprecated TRIANGLE Representitive string value for a triangle.
        public static final String TRIANGLE = "triangle";
         * Constant Data Member: REGEX_NUMBER_TEST
         * Purpose: contains the constant for numerical test within regex method.
         * @deprecated REGEX_NUMBER_TEST regex string for digit comparison.
        public static final String REGEX_NUMBER_TEST = "^[0-9]+$";
         * Constant Data Member: MAX_ARGUMENTS_RECTANGLE
         * Purpose: contains the constant for the maximum number of allowed
         *          arguments coming in from the command line.
         * @deprecated MAX_ARGUMENTS_RECTANGLE constant for rectangle argument.
         *                                      limit.
        public static final int MAX_ARGUMENTS_RECTANGLE = 3;
         * Constant Data Member: MAX_ARGUMENTS_TRIANGLE
         * Purpose: contains the constant for the maximum number of allowed
         *          arguments coming in from the command line, in the case of a
         *          triangle object.
         * @deprecated MAX_ARGUMENTS_TRIANGLE constant for triangle argument limit.
        public static final int MAX_ARGUMENTS_TRIANGLE = 2;
         * Method: main
         * Purpose: Is the execution point for the program. It is in charge of
         *          initiating validation and the creation and application of
         *          objects and their related draw methods.
         * @param args input from the user.
        public static void main(final String[] args)
            String objectType = null;
            int width = 0;
            int height = 0;
            if(args.length > MAX_ARGUMENTS_RECTANGLE || args.length <
                MAX_ARGUMENTS_TRIANGLE || (args.length == MAX_ARGUMENTS_TRIANGLE &&
                !isTriangle(args[0])))
                 // fails
                outputErrorMessage();
            else
                if ((isTriangle(args[0]) && args.length > MAX_ARGUMENTS_TRIANGLE) ||
                    (!isTriangle(args[0]) && args.length > MAX_ARGUMENTS_RECTANGLE))
                    // fails becuase triangle should only have one argument
                    outputErrorMessage();
                else
                    // passes and proceed
                    objectType = args[0];
                    if (validNumber(args[1]))
                        width = Integer.parseInt(args[1]);
                        if(width == 0)
                            outputErrorMessage();
                        else
    ....

    Add a private constructor.
    private Main() {  }
    ...This way it will be not possible to create an instance because it is not needed to use its static members or methods.
    ref : [http://www.javapractices.com/topic/TopicAction.do?Id=40]
    Bye.

Maybe you are looking for

  • Dynamic file names in outbound file adapter

    I have to configure a flow in XI system wich takes an input file from one machine and after mapping process leaves the output file in target machine with the same name of input file. Name of input file won't be always the same (*.dat) so i cannot har

  • 4gb not showing up in Arch64

    Hi all. I finally installed Arch64 to take advantage of my 4gb of RAM and my Core 2 Duo. But I am having some problems. I don't think Arch sees all of it. It should not be a hardware problem because my BIOS correctly displays 4 gb. I left my 32-bit A

  • Valuation control in material master and special stock differs

    Hello expert. SAP is showing  the attach error when a key user is trying to making a usage decision What can be the problem?  And how can i resolve? Check the attach file. thank

  • Sql Loader - Parallel Direct Path Loading

    Hi, I want to load a few million records into a table. I read from OTN site that we can make use of Parallel Direct Loading Option. As given in the site, I split my source file into two and tried loading the file from two different sqlldr sessions si

  • Lightroom Slideshow behave strangely when changing star rating.

    Hi there, I am having issues with Lightroom Slideshow when in Manual Mode and filter is on. When I try and do a manual slideshow and I have filters on "Rating" = ** and I try and change an image to a "*" or a "***" then the slildeshow starts acting w