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
Similar Messages
-
Tuxedo Client using async calls... hangs sometimes!
Hello, I've noticed a fancy behaviour on Tuxedo Client applications...
I wrote an application which receives multiple connections on a socket and dispatches messages to a server with asynchronous calls, then receives asynchronous notifications. Of course it can send multiple async requests before getting a notification.
It seems that when I send an async request, and then I send another async request without getting the reply to the previous one first, the system hangs...
The call stack is quite clear... and I can see on the unix message queue an outstanding message..
I've used the TPU_DIP method, because none of the other unsolicited flavours works:
TPU_SIG: Hangs because malloc can be interrupted by a signal, and within the unsol handrel a tpalloc (which in turn calls malloc) is called, and a kernel spinlock is locked
TPU_THREAD: Hangs exactly in the same way ad TPU_DIP, but on a different thread...
Does anyone knows how to solve this HUGE issue? Thanks in advance!
Marco Romagnuolo
0 0x3000403abc8 in _tmmsgrcv(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so#1 0x3000405e650 in _tmrcvunsol(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so
#2 0x3000405d2f8 in tpchkunsol(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so
#3 0x3000405e480 in _tmchk4unsol(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so
#4 0x30004036ee4 in _tmatmienter(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so
#5 0x30004022944 in tpallocinternal(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.so
#6 0x300040226f0 in tpalloc(...) in /usr/tuxedo/bea/tuxedo8.1/lib/libtux.soI need asynchronous notifications for their particular behaviour: they are notified as soon as they arrive through signals ot through a thread handled by Tuxedo itself.
Now I've changed the policy of the process to use tpgetrply, but I have to poll in order to make it work, and it is UGLY.... anyway... anything else doesn't seem to work -
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] -
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 -
Design Advice Request - Using JDBC in a utility class
I have a utility class that I would like to use from any client code, regardless of whether that code is executing in a transaction or not.
This seems to greatly complicate the JDBC access from within the utility class. I appreciate any advice.
The utility class may both read from and write to the database. It currently attempts to detect whether it is in a transaction (it tests whether TransactionHelper.getTransactionHelper().getTransaction() is null to do this -- please point out if there is a better way.)
If in a transaction, the utility uses a data source which is linked to an XA connection pool, since it must assume other database activity may be occurring on the tx. If not in a transaction, however, it uses a data source linked to a non-XA connection pool, since the XA connection pool will not work outside of a transaction.
It seems like there should be an easier way -- are we overlooking some simpler solution?
The database is Oracle 9i and we are using the Oracle thin drivers.
Thanks in advance,
Ken ClarkKen Clark wrote:
> I am not sure what you mean by this:
>
> "do all your JDBC work in the
> scope of a top-level method (or methods)
> with *all* jdbc variables method-level
> variables,"
I saw the code you sent me, and that is what it does, so no worries here.
>
> I originally built this with a non-XA DataSource, but found that when the utility was called from within a transaction, I would get errors that there was already a connection in use and that I therefore needed to use an XA connection.
>
> Switching to XA DataSource fixed that problem, but then in other cases when not in a transaction, I would get errors saying that an XA Connection could not be used outside a transaction.
>
> Since my utility has no control over the callers state, I came up with the solution stated previously, where I determine if in a Tx and then use the corresponding DataSource.
>
> Is there just a matter of configuration such that I can use a non-XA DS in all cases?
I am saying a non transactional DataSource, not a non XA data source. Ie, a datasource that
is unaware of whether there is a UserTransaction underway. A transactional data source can
be either XA or not. In the former case, multiple XA connections can and will be entrained
in any ongoing transactino, and non-XA (but transactional) datasources can and will be
used in a tx, but only one per tx because they have no 2-phase commit capability.
Ie; In the config file, you will see TxDataSource for a transactional datasource
to a pool (whether XA or not), and you will see DataSource for a non-transactional
data source.
Joe -
Do Utility classes also have a delegate to call them?
My application is a J2EE application�.and we are using delegates to call the Business objects which in turn call the DAO�s. (Struts framework)
This is the pattern for business calls.
Now my question is�. If we have some common utility classes� then is there any pattern for using those classes also?
Like should we be creating a business delegate for the common utility classes like logging or so?
These classes are placed in the common util folder of our application.You don't use patterns because they exist - you use them because you need the functionality.
If you think that swapping out logging is likely to happen then you need to wrap it. Jakarta commons already has a layer for that.
If you don't think that is likely to happen then don't wrap it. -
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] 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] -
Revision: 3672
Author: [email protected]
Date: 2008-10-15 16:54:51 -0700 (Wed, 15 Oct 2008)
Log Message:
Removing the commonly used getUnqualifiedClassName out of the less commonly used utility class to reduce SWF size for the general case.
Reviewer: Gordon
QE: No
Modified Paths:
flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/graphicsClasses/TextGraphicEleme nt.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UITextField.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/Effect.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/EffectInstance.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/managers/SystemManager.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/NameUtil.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/ObjectUtil.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/OrderedObject.asIn general theory, one now has the Edit button for their posts, until someone/anyone Replies to it. I've had Edit available for weeks, as opposed to the old forum's ~ 30 mins.
That, however, is in theory. I've posted, and immediately seen something that needed editing, only to find NO Replies, yet the Edit button is no longer available, only seconds later. Still, in that same thread, I'd have the Edit button from older posts, to which there had also been no Replies even after several days/weeks. Found one that had to be over a month old, and Edit was still there.
Do not know the why/how of this behavior. At first, I thought that maybe there WAS a Reply, that "ate" my Edit button, but had not Refreshed on my screen. Refresh still showed no Replies, just no Edit either. In those cases, I just Reply and mention the [Edit].
Also, it seems that the buttons get very scrambled at times, and Refresh does not always clear that up. I end up clicking where I "think" the right button should be and hope for the best. Seems that when the buttons do bunch up they can appear at random around the page, often three atop one another, and maybe one way the heck out in left-field.
While I'm on a role, it would be nice to be able to switch between Flattened and Threaded Views on the fly. Each has a use, and having to go to Options and then come back down to the thread is a very slow process. Jive is probably incapable of this, but I can dream.
Hunt -
Simple cylinder by using the Cylinder utility class
I compiled the example of a Cylinder from the following internet-page:
[This creates a simple cylinder by using the Cylinder utility class|http://www.java2s.com/Code/Java/3D/ThiscreatesasimplecylinderbyusingtheCylinderutilityclass.htm]
I could compile it, but when I started it, I got this error:
exception in thread "main" java.lang.NullPointerException: Canvas3D: null GraphicsConfiguration
Is there an error in the code?try to replace the line: protected Canvas3D myCanvas3D = new Canvas3D(null);
with
protected Canvas3D myCanvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration(); -
Hi folks,
I need a utility class in my J2EE application. Both the JSPs and the EJBs will need to use it.
But I don't know where this class should be located so that it can be easily accessed. Can anyone give me a hand?If it a utility class then all the method will be static. Put it anywhere. Lots of copies. Most SD companies have a core library that is included in every application - maybe even put on the classpath of their dedicated servers/apps.
-
hi, In an Async call, there is a ICallBack interface, which is having a init(ODIInformationObj),
handleCallBack(long pElapsedTime)
handleFaultCallback(long pElapsedTime,Exception pException).
can u pls help me how to invoke the handleCallBack() method, or else
it will be invoked internally through the Thread call.
pls suggest me to post the Message via(DirectConnection) and get back the operation information to an ODIService.
Note:
I have this code:
Message xmlMessage = XMLMessageFactory.getInstance().createMessage(payload1);
payload1="<ns1:ODIInvokerServiceResponse " + " xmlns:ns1=\"http://xmlns.oracle.com/ODIService\">\n" +
"<ns1:odiPlan> " + pOdiPlanName + "</ns1:odiPlan>\n" +
"<ns1:elapsedTime> " + pElapsedTime +
" </ns1:elapsedTime>\n" +
" </ns1:ODIInvokerServiceResponse>";
getting Direct connection using:
DirectConnection directconnection =
loc.createDirectConnection(compositeDN,
"MasterBPELProcessDirect");
Sending Message like:
directConnection.post(pOperation, pNm);You Might Try tapping the Home button and see what that does, Do it on a Test call with one of your Relative or Friend's so they know that when you tap the button and if it happens to end the call they won't be concerned because it was a test Call..
Hope that helps b33 -
Using Async to wait for a specific event
I've simplified the creation and deletion calls and used a generic item. In my before method, I call Async.handleEvent to wait for PropertyChangeEvents, but this only waits for the first one. My problem lies in the fact that ItemManager is an IEventDispatcher that sends multiple property change events, but I need to wait for the specific event with the property "item". However, when I call Async inside the handler, it does not keep the Test method from running, Before assumes that it's Async responsibilities have been fulfilled and launches the next stage of tests. How can I keep Before from moving on until an event with a specific property has been received?
public class Test
private static const TIME_OUT:int = 3000;
[Before(async)]
public function runBeforeEveryTest() : void
// Create a new item
item.create(); // This is an asynchronous creation that sends many Property Change events
//Wait for the item to be created before continuing tests.
Async.handleEvent( this, ItemManager.instance, PropertyChangeEvent.PROPERTY_CHANGE, handlePropertyChangeForItem, TIME_OUT);
[After]
public function runAfterEveryTest() : void
// Delete the Item
item.delete();
[Test(async)]
public function itemExists() : void
Assert.assertTrue( item.exists() );
private function handlePropertyChangeForItem(evt:PropertyChangeEvent, eventObject:Object) : void
if (evt.property == "item")
// Now that the item has been created, we can start the tests.
return;
else
// Keep waiting.
Async.handleEvent( this, ItemManager.instance, PropertyChangeEvent.PROPERTY_CHANGE, handlePropertyChangeForItem, TIME_OUT);
Thanks in advance, it's greatly appreciated!I can't reproduce this issue. All seems to be working fine with multiple deferred Async calls. I am pasting my code in. Since I did not have your manager, I tried to repiicate this with a timer. If you could look at my code and see if it differs from yours in a significant way, I can take another shot, but it seems to be working as expected.
package
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.events.PropertyChangeEvent;
import org.flexunit.Assert;
import org.flexunit.async.Async;
public class NestedAsync {
private static const TIME_OUT:int = 3000;
private var timer:Timer;
Before(async)]
public function runBeforeEveryTest() : void { timer =
new Timer( 1000, 5 );
Async.handleEvent(this, timer, TimerEvent.TIMER, handleTimerTick, TIME_OUT);timer.start();}
[After]
public function runAfterEveryTest() : void { timer.stop();
timer =
null;}
Test(async)]
public function itemExists() : void {Assert.assertTrue(
true );}
private function handleTimerTick(evt:TimerEvent, eventObject:Object) : void {
if ( timer.currentCount == 5 ) {
// Now that the item has been created, we can start the tests.
return; }
else {
// Keep waiting. Async.handleEvent(
this, timer, TimerEvent.TIMER, handlePropertyChangeForItem, TIME_OUT);
suite.cases { -
Calling Custom XSLT java class from BPEL in SOA Suite 11g
Hi All,
Morning...need some help with this issue...we are currently on SOA Suite 11g (11.1.1.4) version.
Earlier while we were on SOA Suite version 10g (10.1.3.3) we were calling the custom java classes from the xsl mapping for complex transformation and for this we were placing the .class file as .jar file at the location mentioned here $OC4J_HOME/j2ee/home/applib directory and then mentioning the namespace as http://www.oracle.com/XSL/Transform/java/{$classname$} in the XSLT mapping file.
Now in SOA Suite 11g if we need to retain similar functionality for external custom java calls could someone please help us where do we need to put the .jar file now ..
exactly at which directory location/path and on which instance/server (application server instance or middle tier instance ) we need to put this .jar file
Currently we are stuck and need some help with this.
With thanks & RegardsHi Eric & Anuj,
Thanks for replying , sorry for checking on this now...
here at this path /opt101/app/oracle/SOAD/SOA11gR1/fmw/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1
we got the ora.soa.ext.jar file and extracted it to get the MANIFEST.mf file ..have mentioned below.
Now if we need to link our custom .jar file named customfunctions.jar so we need to mention it as below is this correct :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 17.0-b17 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle
Implementation-Title: Oracle SOA EXT
Implementation-Version: 11.1.1
Product-Name: Oracle SOA EXT
Product-Version: 11.1.1.4.0
Specification-Version: 11.1.1
Extension-Name: oracle.soa.ext
Class-Path: classes/
Class-Path:customfunctions.jar classes/ -- is this the way to mention (means we need to add this additional line or we need to add to the existing line at Class-Path: classes/)
2.
Eric the Alternative method mentioned in your update :
Open a command prompt and change the current directory to the oracle.soa.ext_11.1.1 directory ,
then execute the build.xml file in the oracle.soa.ext_11.1.1 folder using Ant
Now could someone please guide us regards this ANT means how does it work and its relation to the build.xml file and how do we check whether we have ANT utility available or not..
not much conversant with this ANT hence asking here..would lookout for your reply
thank you -
Calling a object of class from other class's function with in a package
Hello Sir,
I have a package.package have two classes.I want to use object of one class in function of another class of this same package.
Like that:
one.java
package co;
public class one
private String aa="Vijay"; //something like
}main.java:
package co;
import java.util.Stack;
public class main extends Stack
public void show(one obj)
push(obj);
public static void main(String args[])
main oo=new main();
}when I compile main class, Its not compile.
Its give error.can not resolve symbol:
symbol: class one
location: class co.main
public void show(one obj)
^Please help How that compile "Calling a object of class from other class's function with in a package" beacuse I want to use this funda in an applicationkumar.vijaydahiya wrote:
.It is set in environment variable.path=C:\bea\jdk141_02\bin;.,C:\oraclexe\app\oracle\product\10.2.0\server\bin;. command is:
c:\Core\co\javac one.javaIts compiled already.
c:\Core\co\javac main.javaBut it give error.
Both java classes in co package.Okay, open a command prompt and execute these two commands:
// to compile both classes:
javac -cp c:\Core c:\Core\co\*.java
// to run your main-class:
java -cp c:\Core co.main
Maybe you are looking for
-
Insert pages from a single document multiple times
I'm trying to create a simple program that I can use to display PDF files that I can use to play at the piano. I perform often, and need to create "play lists" from which I can pull all, or part of, a PDF file containing music and display it. I have
-
Albums vs. artists, where to submit feedback/complaints?
Is there a place to send Apple design feedback? When viewing albums, why does it split the albums up into separate artists? It's incredibly annoying when it's a compilation album. There's a tab for that, it's called ARTISTS, I'm supposed to be viewin
-
Movies in mobilme gallery won't play in safari on the ipad
The movies I have put on my MobilMe Gallery won't play in Safari on the iPad. The photo gallery works fine, but the movies gallery does not. I created the movies directly from within Quicktime (Share-> MobilMe gallery). Using Safari on my Mac everyth
-
iPhone 4, just over a month old, about 2 weeks into use has been playing up since.... I'm certain the problem is the same, but it manifests in different ways, usually daily. If unused for a period (as in an hour or two), the iPhone (when pressing the
-
Installing latest Flash 10.1 in Firefox 3.0.19 on XP/32-bit
After uninstalling the previous version of Flash I found that the new Flash plugin would not install. I could download a file gp.xpi, but clicking it gave a message like "application unknown". I found that I had to manually select Firefox as the a