Hi,
As fas as I now you need to close the Connection btw I did this by implementing the Composable interface like so :
public class myAction extends AbstractAction implements Composable {private DataSourceComponent datasource;
public void compose(ComponentManager manager) throws ComponentException {
ComponentSelector dbselector =
(ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector");
datasource = (DataSourceComponent) dbselector.select("<replace-by-name-in-cocoon.xconf>"); }
public Map act(........
Connection conn = datasource.getConnection();
conn.close();
Cheers, Gertjan
Bart Molenkamp wrote:
public class TestAction extends ServiceableAction {
/* (non-Javadoc)
* @see ...
*/
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
{
ServiceSelector dbselector = (ServiceSelector)this.manager.lookup(DataSourceComponent.ROLE + "Selector");
DataSourceComponent ds = (DataSourceComponent) dbselector.select("personnel");
Connection con = ds.getConnection();
//...
// your code here.
dbselector.release(ds);
this.manager.release(dbselector);
return objectModel;
}
Now I'm only wondering if you need to close the connection, or if this is handled by Cocoon. You should check the documentation for that.
HTH, Bart.
it-----Original Message----- From: Jonny Pony [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 2:51 PM To: [EMAIL PROTECTED] Subject: RE: Action (accessing jdbc-pooll) using Avalon components
Hi,
thaks for the answers.
Or extend org.apache.cocoon.acting.ServiceableAction
Where should I place this since my java knowledge is lousy?
Thanks
From: "Bart Molenkamp" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: <[EMAIL PROTECTED]> Subject: RE: Action (accessing jdbc-pooll) using Avalon components Date: Tue, 19 Oct 2004 14:04:22 +0200
Or extend org.apache.cocoon.acting.ServiceableAction
-----Original Message----- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jorg Heymans Sent: Tuesday, October 19, 2004 1:33 PM To: [EMAIL PROTECTED] Subject: Re: Action (accessing jdbc-pooll) using Avalon components
in service() set the manager to an instance variable, then access
Serviceable{in
cocoon.xconf.act() - or did i completely miss your point?
Jonny Pony wrote:
Hi,
I want my action to access the jdbc-pool configured in the
My try so far:
package foo.bar.acting;
import java.sql.*; import org.apache.avalon.framework.service.*; ...
public class PoolTest extends AbstractAction implements
resolver,public Map act(Redirector redirector, SourceResolver
actionMap objectModel, String source, Parameters params) {
...
/*
I want to use the service method below in this
moreServiceExceptionBut how?? */ }
public void service(ServiceManager manager) throws
{
ServiceManager serviceManager = null; ServiceSelector selector = (ServiceSelector) serviceManager.lookup(DataSourceComponent.ROLE + "Selector");
DataSourceComponent ds = (DataSourceComponent) selector.select("mysql-test"); Connection con = null; ...
try { con = ds.getConnection(); ... } catch (Exception e) { } finally { try { con.close(); } catch (Exception e) { } if (selector != null) selector.release(ds); if (serviceManager != null) serviceManager.release(selector); } } }
My question is how to use the service method in this action. Or
_________________________________________________________________precise, how to access it? Do I pass an empty ServiceManager?
Jonny
---------------------------------------------------------------------Anti-Virus.Tun Sie Ihrem Rechner 'was Gutes. MSN Hotmail mit McAfee(r)
http://www.msn.de/email/antivirus/ Jetzt kostenlos anmelden!
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________ MSN Toolbar - kostenloser Pop-Up Blocker - Jetzt herunterladen http://toolbar.msn.de Jetzt kostenlos downloaden!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
