You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Zoerner <st...@labeo.de> on 2007/11/05 22:05:30 UTC

[ApacheDS] Stored Procedures: One language id per StoredProcEngineConfig and StoredProcEngine, Stateful vs. Stateless

Hi all!

The current interface StoredProcEngineConfig from 
org.apache.directory.server.core.sp

basically looks like this:

---

interface StoredProcEngineConfig
{
     /**
      * Returns the type of the associated {@link StoredProcEngine}.
      */
     Class<? extends StoredProcEngine> getStoredProcEngineType();


     /**
      * Returns the unique language identifier of the {@link 
StoredProcEngine}.
      */
     String getStoredProcLangId();
}

---

The interface StoredProcEngine has only one SPLangId, as well.

This makes it hard to provide a StoredProcEngine implementation for more 
than one language. I have started a BsfStoredProcEngine, and ran into 
two problems:

* My StoredProcEngine should be able to support several scripting 
languages, but I can only return one of them as SPLangId
* The only way to create my class currently is the default constructor. 
Thus I am not able to use Spring to configure my StoredProcEngine

I would like to modify the interfaces in order to support 
StoredProcEngines with more than one language, and to configure them 
with properties.

Before I can propose concrete changed, I have a question (probably to Ersin)

The StoredProcEngine life cycle seems to presume that there is an 
instance for each stored procedure. How often are the methods
* setSPUnitEntry
* invokeProcedure
presumed to be called?

Currently, the implementation within StoredProcExecutionManager looks 
like a new StoredProcEngine is created for each call. The methods will 
be called one after the other. Is a StoredProcEngine supposed to be 
stateful or stateless?

Thanks in advance,
     Stefan



Re: [ApacheDS] Stored Procedures: One language id per StoredProcEngineConfig and StoredProcEngine, Stateful vs. Stateless

Posted by Stefan Zoerner <st...@labeo.de>.
Hi Chris and Ersin!

Chris Custine wrote:
> I vaguely remember running into these issues a while back as well.  I 
> think the problem is differentiating which scripting language the script 
> is written in so that the BSF Scripting Manager can retrieve the correct 
> script engine internally (by extension, name, or mime type).  Is that 
> the same issue you are having Stefan?

I thought I have. But due to the sample implementation for Java 6 
Scripting, Ersin provided in his sandbox, I learned an alternative. 
Thank you Ersin for the link!

Ersin stores the concrete scripting language in the attributes of the SP 
entry. So the engine has a chance to determine the correct scripting 
language, because it knows this attribute (provided via setSPUnitEntry).

In this case, storedProcLangId has a generic value "JavaxScript". This 
would solve my problem of how to determine the right language, but I 
think the name storedProcLangId is somehow misleading then. Basically, 
you store both the engine and the language within the entry. I would 
prefer to store only the language, and leave the selection of the engine 
up to the StoredProcExecutionManager.

I think I will try to complete my BSF implementation with the solution 
Ersin provided first, in order to have more knowledge to discuss.

Thanks for your insights,
     Stefan


Re: [ApacheDS] Stored Procedures: One language id per StoredProcEngineConfig and StoredProcEngine, Stateful vs. Stateless

Posted by Alex Karasulu <ak...@apache.org>.
On 11/5/07, Chris Custine <cc...@apache.org> wrote:

...

Another thing to mention in case you guys aren't aware of this:  BSF 3.0 is
> adding a JSR-223 javax.script implementation that will work with Java 1.5as well so I have been following that development so that we can deliver
> script support for Java 1.5.  I think they are releasing beta versions now
> so this is something to watch.
>

That's great news.  I was going to even suggest we move to 1.6 but now with
this there's no need.

Alex

Re: [ApacheDS] Stored Procedures: One language id per StoredProcEngineConfig and StoredProcEngine, Stateful vs. Stateless

Posted by Chris Custine <cc...@apache.org>.
On 11/5/07, Ersin Er <er...@gmail.com> wrote:
>
>
>
> On 11/5/07, Stefan Zoerner <st...@labeo.de> wrote:
> >
> > Hi all!
>
>
> Hi Stefan,
>
> The current interface StoredProcEngineConfig from
> > org.apache.directory.server.core.sp
> >
> > basically looks like this:
> >
> > ---
> >
> > interface StoredProcEngineConfig
> > {
> >      /**
> >       * Returns the type of the associated {@link StoredProcEngine}.
> >       */
> >      Class<? extends StoredProcEngine> getStoredProcEngineType();
> >
> >
> >      /**
> >       * Returns the unique language identifier of the {@link
> > StoredProcEngine}.
> >       */
> >      String getStoredProcLangId();
> > }
> >
> > ---
> >
> > The interface StoredProcEngine has only one SPLangId, as well.
> >
> > This makes it hard to provide a StoredProcEngine implementation for more
> > than one language. I have started a BsfStoredProcEngine, and ran into
> > two problems:
> >
> > * My StoredProcEngine should be able to support several scripting
> > languages, but I can only return one of them as SPLangId
> >
>
> I am not sure that you need to specify each language supported by BSF with
> a distinct Id. I think only an Id such as "BSF" is enough. Because from the
> point of view of the ExecutionEngine it won't matter which specific language
> is being used as the BSF provider. All of those providers can support Java
> objects passed as parameters. The BSF abstraction provides other useful
> tools to handle all the languages with a single API, as far as I remember.
>

I vaguely remember running into these issues a while back as well.  I think
the problem is differentiating which scripting language the script is
written in so that the BSF Scripting Manager can retrieve the correct script
engine internally (by extension, name, or mime type).  Is that the same
issue you are having Stefan?

Another thing to mention in case you guys aren't aware of this:  BSF 3.0 is
adding a JSR-223 javax.script implementation that will work with Java 1.5 as
well so I have been following that development so that we can deliver script
support for Java 1.5.  I think they are releasing beta versions now so this
is something to watch.

Chris

I had developed a prototype implementation for Javax Scripting API languages
> here:
>
> http://svn.apache.org/viewvc/directory/sandbox/ersiner
>
> It's really not tested well but it may give some idea.
>
> * The only way to create my class currently is the default constructor.
> > Thus I am not able to use Spring to configure my StoredProcEngine
> >
> > I would like to modify the interfaces in order to support
> > StoredProcEngines with more than one language, and to configure them
> > with properties.
>
>
> As I said before feel free to modify any part of the SP subsystem. I did
> not make it very flexible because when I refactored the code the server
> configuration system was being refactored extensively. So I had left DI out
> temporarily.
>
> Before I can propose concrete changed, I have a question (probably to
> > Ersin)
> >
> > The StoredProcEngine life cycle seems to presume that there is an
> > instance for each stored procedure. How often are the methods
> > * setSPUnitEntry
> > * invokeProcedure
> > presumed to be called?
> >
>
> They are invoked upon each SP call.
>
> Currently, the implementation within StoredProcExecutionManager looks
> > like a new StoredProcEngine is created for each call. The methods will
> > be called one after the other. Is a StoredProcEngine supposed to be
> > stateful or stateless?
>
>
> And they are stateful.
>
> BTW I had faced also some other restrictions to be able to support SPs
> from both over the wire and from the core. So some of the difficulties about
> extending the system can be caused by such limitations.
>
>
> Thanks in advance,
> >      Stefan
>
>
>
> Thanks for working on this and sharing your thoughts Stefan.
>
>
> --
> Ersin

Re: [ApacheDS] Stored Procedures: One language id per StoredProcEngineConfig and StoredProcEngine, Stateful vs. Stateless

Posted by Ersin Er <er...@gmail.com>.
On 11/5/07, Stefan Zoerner <st...@labeo.de> wrote:
>
> Hi all!


Hi Stefan,

The current interface StoredProcEngineConfig from
> org.apache.directory.server.core.sp
>
> basically looks like this:
>
> ---
>
> interface StoredProcEngineConfig
> {
>      /**
>       * Returns the type of the associated {@link StoredProcEngine}.
>       */
>      Class<? extends StoredProcEngine> getStoredProcEngineType();
>
>
>      /**
>       * Returns the unique language identifier of the {@link
> StoredProcEngine}.
>       */
>      String getStoredProcLangId();
> }
>
> ---
>
> The interface StoredProcEngine has only one SPLangId, as well.
>
> This makes it hard to provide a StoredProcEngine implementation for more
> than one language. I have started a BsfStoredProcEngine, and ran into
> two problems:
>
> * My StoredProcEngine should be able to support several scripting
> languages, but I can only return one of them as SPLangId
>

I am not sure that you need to specify each language supported by BSF with a
distinct Id. I think only an Id such as "BSF" is enough. Because from the
point of view of the ExecutionEngine it won't matter which specific language
is being used as the BSF provider. All of those providers can support Java
objects passed as parameters. The BSF abstraction provides other useful
tools to handle all the languages with a single API, as far as I remember.

I had developed a prototype implementation for Javax Scripting API languages
here:

http://svn.apache.org/viewvc/directory/sandbox/ersiner

It's really not tested well but it may give some idea.

* The only way to create my class currently is the default constructor.
> Thus I am not able to use Spring to configure my StoredProcEngine
>
> I would like to modify the interfaces in order to support
> StoredProcEngines with more than one language, and to configure them
> with properties.


As I said before feel free to modify any part of the SP subsystem. I did not
make it very flexible because when I refactored the code the server
configuration system was being refactored extensively. So I had left DI out
temporarily.

Before I can propose concrete changed, I have a question (probably to Ersin)
>
> The StoredProcEngine life cycle seems to presume that there is an
> instance for each stored procedure. How often are the methods
> * setSPUnitEntry
> * invokeProcedure
> presumed to be called?
>

They are invoked upon each SP call.

Currently, the implementation within StoredProcExecutionManager looks
> like a new StoredProcEngine is created for each call. The methods will
> be called one after the other. Is a StoredProcEngine supposed to be
> stateful or stateless?


And they are stateful.

BTW I had faced also some other restrictions to be able to support SPs from
both over the wire and from the core. So some of the difficulties about
extending the system can be caused by such limitations.


Thanks in advance,
>      Stefan



Thanks for working on this and sharing your thoughts Stefan.


-- 
Ersin