You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Tak Yoshida (JIRA)" <ib...@incubator.apache.org> on 2005/03/06 05:30:52 UTC

[jira] Created: (IBATIS-84) Enhancement proposal: plug in external bean

Enhancement proposal: plug in external bean
-------------------------------------------

         Key: IBATIS-84
         URL: http://issues.apache.org/jira/browse/IBATIS-84
     Project: iBatis for Java
        Type: New Feature
  Components: SQL Maps  
    Versions: 2.0.9b    
    Reporter: Tak Yoshida


Hello SQLMap development team,

I would like to post this idea again,
which was submitted to sourceforge forum last year.

I believe this is not only for my case in real world, 
and makes SQLMap more flexible. 
 
I have already done on 2.0.9b, and it works pretty well on my project.
If you would reflect my proposal in the future SQLMap, that would be great. 

thanks,
Tak Yoshida

-------- Here is the post on Oct 30th for 2.0.7 --------
I found one thing I should ask,
that is external service bean plug in feature for the complex object query. 
 
In my project, I need to use Oracle Object Cache Service for disributed  
application environment. 
and this cache will be managed outside of SQLMap framework, 
which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages 
cache object itself.
 
So I would like to have SQLMap call external service for complex object's sub 
query. 
 
Here is my proposal:
Summary: 
Inject ServiceLocator to make SQLMap be able to call the service managed  
outside of SQLMap. 
 
1: To make use of external object, SqlMapClient has UserServiceBeanLocator 
object property. 
 
public interface SqlMapClient extends SqlMapExecutor,  
SqlMapTransactionManager { 
public void setUserServiceBeanLocator(UserServiceBeanLocator 
serviceBeanLocator); 
public UserServiceBeanLocator getUserServiceBeanLocator(); 
.... 
} 
And SqlMapClientImpl has this imlementation. 
 
public interface UserServiceBeanLocator { 
// locator method 
public Object getUserServiceBean(String name) throws SqlMapException; 
} 
 
 
2: Extends resultMap's "result" tag attribute to specify the external bean 
and the method name. 
 
<result property="shipMode" column="SMODE" javaType="string" 
bean="shipModeDao" method="getShipModeById"/> 
instead of 
<result property="shipMode" column="SMODE" 
select="shipModeSqlMap.getShipModeById"/> 
 
3: To support 2, DTD must be enhanced for new two attributes, and  
XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
 
4: And to hold these external bean info in mapping object created by 
XmlSqlMapClientBuilder, 
I introduce UserServiceBeanInfo. 
public class UserServiceBeanInfo { 
private String beanName; 
private String methodName; 
private Method method; 
... 
} 
 
5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry 
for the complex property by calling external service. 
 
Here is a snippet of the codes 
} else if (mapping.getUserServiceBeanInfo() != null) { 
// get key for complex property 
Object rawValue = getPrimitiveResultMappingValue(rs, mapping); 
// get complex property via external service 
UserServiceBeanLocator serviceBeanLocator =  
request.getSession().getSqlMapClient().getUserServiceBeanLocator(); 
UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo(); 
try { 
Object service = 
serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName()); 
Method method = serviceBeanInfo.getMethod(); // check cacheed one. 
if (method == null) { 
method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new 
Class[] {mapping.getJavaType()}); 
serviceBeanInfo.setMethod(method); // cache it. 
} 
columnValues[i] = method.invoke(service, new Object[] {rawValue}); 
... exception handling... 
} else { 
 
6: Application is fully responsible to set this up at startup time. 
I am injecting spring ApplicationContext object to SqlMapClient via 
ApplicationListener, 
-------------------------------


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-84) Enhancement proposal: plug in external bean

Posted by "Tak Yoshida (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-84?page=comments#action_60304 ]
     
Tak Yoshida commented on IBATIS-84:
-----------------------------------

Clinton,

Thanks for your time. I really appreciate it.

>Looking into this a bit further, I wonder if you could manage this using either:
>1) A custom cache model implementation (preferred).
>My recommendation is to write a custom cache model.  If there is a hook that you need (such as more 
>specific manual flush capability), then let's look at that.
Sure, I see your point. 
If I use this, no futher complexity will be introduced, and it follows the SQLMap design policy.
I will definitely take a look custom cache model again first.
Unfortunately, our project will be in final testing phase very soon.
so I will do this as a enhancement project for my app.

One simple concern is that all our service objects, e.g. our cache service, are managed by Spring,
and how my own custom cache model can work with these services,
in other words, how to get the cache service object. 
Well, I'll see.

>or
>2) A custom type handler.
I haven't think about CTH for my case.
But if I can inject my own DAO instance into it,
I can do the same thing as I am doing via external service.
Is there any way to work with Factory (such as Spring) to instantiate SQLMap object?
Oops, back to the same discussion, again. please forget about this until I study cache model.

Later,
Tak

> Enhancement proposal: plug in external bean
> -------------------------------------------
>
>          Key: IBATIS-84
>          URL: http://issues.apache.org/jira/browse/IBATIS-84
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Versions: 2.0.9b
>     Reporter: Tak Yoshida

>
> Hello SQLMap development team,
> I would like to post this idea again,
> which was submitted to sourceforge forum last year.
> I believe this is not only for my case in real world, 
> and makes SQLMap more flexible. 
>  
> I have already done on 2.0.9b, and it works pretty well on my project.
> If you would reflect my proposal in the future SQLMap, that would be great. 
> thanks,
> Tak Yoshida
> -------- Here is the post on Oct 30th for 2.0.7 --------
> I found one thing I should ask,
> that is external service bean plug in feature for the complex object query. 
>  
> In my project, I need to use Oracle Object Cache Service for disributed  
> application environment. 
> and this cache will be managed outside of SQLMap framework, 
> which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages 
> cache object itself.
>  
> So I would like to have SQLMap call external service for complex object's sub 
> query. 
>  
> Here is my proposal:
> Summary: 
> Inject ServiceLocator to make SQLMap be able to call the service managed  
> outside of SQLMap. 
>  
> 1: To make use of external object, SqlMapClient has UserServiceBeanLocator 
> object property. 
>  
> public interface SqlMapClient extends SqlMapExecutor,  
> SqlMapTransactionManager { 
> public void setUserServiceBeanLocator(UserServiceBeanLocator 
> serviceBeanLocator); 
> public UserServiceBeanLocator getUserServiceBeanLocator(); 
> .... 
> } 
> And SqlMapClientImpl has this imlementation. 
>  
> public interface UserServiceBeanLocator { 
> // locator method 
> public Object getUserServiceBean(String name) throws SqlMapException; 
> } 
>  
>  
> 2: Extends resultMap's "result" tag attribute to specify the external bean 
> and the method name. 
>  
> <result property="shipMode" column="SMODE" javaType="string" 
> bean="shipModeDao" method="getShipModeById"/> 
> instead of 
> <result property="shipMode" column="SMODE" 
> select="shipModeSqlMap.getShipModeById"/> 
>  
> 3: To support 2, DTD must be enhanced for new two attributes, and  
> XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
>  
> 4: And to hold these external bean info in mapping object created by 
> XmlSqlMapClientBuilder, 
> I introduce UserServiceBeanInfo. 
> public class UserServiceBeanInfo { 
> private String beanName; 
> private String methodName; 
> private Method method; 
> ... 
> } 
>  
> 5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry 
> for the complex property by calling external service. 
>  
> Here is a snippet of the codes 
> } else if (mapping.getUserServiceBeanInfo() != null) { 
> // get key for complex property 
> Object rawValue = getPrimitiveResultMappingValue(rs, mapping); 
> // get complex property via external service 
> UserServiceBeanLocator serviceBeanLocator =  
> request.getSession().getSqlMapClient().getUserServiceBeanLocator(); 
> UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo(); 
> try { 
> Object service = 
> serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName()); 
> Method method = serviceBeanInfo.getMethod(); // check cacheed one. 
> if (method == null) { 
> method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new 
> Class[] {mapping.getJavaType()}); 
> serviceBeanInfo.setMethod(method); // cache it. 
> } 
> columnValues[i] = method.invoke(service, new Object[] {rawValue}); 
> ... exception handling... 
> } else { 
>  
> 6: Application is fully responsible to set this up at startup time. 
> I am injecting spring ApplicationContext object to SqlMapClient via 
> ApplicationListener, 
> -------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-84) Enhancement proposal: plug in external bean

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-84?page=comments#action_60285 ]
     
Clinton Begin commented on IBATIS-84:
-------------------------------------


Tak, you know I respect you and I appreciate your needs.  But I'm going to be completely honest.  I am not a big fan of this idea.  It potentially adds a great deal of complexity to result mappings, possibly that are outside of the scope of iBATIS.  

I also have concerns about the naming conventions, as they aren't portable to the .NET implementation (i.e. "bean" is not a valid .NET term).

A similar request has been made before, with regard to allowing factories to create object instances.  

I'm not entirely opposed to such ideas, but I would like to ensure that if we do implement something along these lines that it is:

1) VERY simple.  That is, it should not require more than one additional attribute on the result mapping (if any at all), and it should not introduce too many new interfaces or methods.  

2) Portable to the .NET implementation.  iBATIS has a family now, and we have to respect it.  Let's be careful to avoid such terms like "Bean".  I'm also not a fan of naming classes after patterns, especially not more than one.  "ServiceLocatorBean" has at least 3 patterns in the name, and as a new user I'd wonder what the heck it does.  What is it really?

3) Not redundant.  Before we do anything further, I'd like to see some exploration of ways this can be achieved WITHOUT modifications to iBATIS.  If there is no way, then we'll look into it.  But I would like to see some effort applied here first.

Hopefully the others who were interested in the result object factories are watching the list and will see this, so they can contribute too.

Cheers,
Clinton

> Enhancement proposal: plug in external bean
> -------------------------------------------
>
>          Key: IBATIS-84
>          URL: http://issues.apache.org/jira/browse/IBATIS-84
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Versions: 2.0.9b
>     Reporter: Tak Yoshida

>
> Hello SQLMap development team,
> I would like to post this idea again,
> which was submitted to sourceforge forum last year.
> I believe this is not only for my case in real world, 
> and makes SQLMap more flexible. 
>  
> I have already done on 2.0.9b, and it works pretty well on my project.
> If you would reflect my proposal in the future SQLMap, that would be great. 
> thanks,
> Tak Yoshida
> -------- Here is the post on Oct 30th for 2.0.7 --------
> I found one thing I should ask,
> that is external service bean plug in feature for the complex object query. 
>  
> In my project, I need to use Oracle Object Cache Service for disributed  
> application environment. 
> and this cache will be managed outside of SQLMap framework, 
> which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages 
> cache object itself.
>  
> So I would like to have SQLMap call external service for complex object's sub 
> query. 
>  
> Here is my proposal:
> Summary: 
> Inject ServiceLocator to make SQLMap be able to call the service managed  
> outside of SQLMap. 
>  
> 1: To make use of external object, SqlMapClient has UserServiceBeanLocator 
> object property. 
>  
> public interface SqlMapClient extends SqlMapExecutor,  
> SqlMapTransactionManager { 
> public void setUserServiceBeanLocator(UserServiceBeanLocator 
> serviceBeanLocator); 
> public UserServiceBeanLocator getUserServiceBeanLocator(); 
> .... 
> } 
> And SqlMapClientImpl has this imlementation. 
>  
> public interface UserServiceBeanLocator { 
> // locator method 
> public Object getUserServiceBean(String name) throws SqlMapException; 
> } 
>  
>  
> 2: Extends resultMap's "result" tag attribute to specify the external bean 
> and the method name. 
>  
> <result property="shipMode" column="SMODE" javaType="string" 
> bean="shipModeDao" method="getShipModeById"/> 
> instead of 
> <result property="shipMode" column="SMODE" 
> select="shipModeSqlMap.getShipModeById"/> 
>  
> 3: To support 2, DTD must be enhanced for new two attributes, and  
> XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
>  
> 4: And to hold these external bean info in mapping object created by 
> XmlSqlMapClientBuilder, 
> I introduce UserServiceBeanInfo. 
> public class UserServiceBeanInfo { 
> private String beanName; 
> private String methodName; 
> private Method method; 
> ... 
> } 
>  
> 5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry 
> for the complex property by calling external service. 
>  
> Here is a snippet of the codes 
> } else if (mapping.getUserServiceBeanInfo() != null) { 
> // get key for complex property 
> Object rawValue = getPrimitiveResultMappingValue(rs, mapping); 
> // get complex property via external service 
> UserServiceBeanLocator serviceBeanLocator =  
> request.getSession().getSqlMapClient().getUserServiceBeanLocator(); 
> UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo(); 
> try { 
> Object service = 
> serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName()); 
> Method method = serviceBeanInfo.getMethod(); // check cacheed one. 
> if (method == null) { 
> method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new 
> Class[] {mapping.getJavaType()}); 
> serviceBeanInfo.setMethod(method); // cache it. 
> } 
> columnValues[i] = method.invoke(service, new Object[] {rawValue}); 
> ... exception handling... 
> } else { 
>  
> 6: Application is fully responsible to set this up at startup time. 
> I am injecting spring ApplicationContext object to SqlMapClient via 
> ApplicationListener, 
> -------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-84) Enhancement proposal: plug in external bean

Posted by "Tak Yoshida (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-84?page=comments#action_60292 ]
     
Tak Yoshida commented on IBATIS-84:
-----------------------------------

Clinton,

Thanks for your quick reply,
and giving me iBATIS design and naming policy.

>Tak, you know I respect you and I appreciate your needs.  But I'm going to be 
>completely honest.  I am not a big fan of this idea.  It potentially adds a 
>great deal of complexity to result mappings, possibly that are outside of the 
You don't have to say this, I really appreciate your honest feedback always!
If this could introduce a great deal of complexity, I cannot disagree with it.
With my limited knowledge of SQLMap, what I did on result mapping is not complex.
Could you please explain your concern for "potential" case?

>A similar request has been made before, with regard to allowing factories to 
>create object instances.  

>I'm not entirely opposed to such ideas, but I would like to ensure that if we 
>do implement something along these lines that it is:
It's good to know that you're not entirely against that idea.
Apology, I would use "bean" untill I know the proper name in iBATIS.
My concern is AOP, I am novis though.
Let's say, if I would like to use a bean for a result, and that bean is enhanced by AOP,
such as overriding getter method for lazy loading, or new properties are introduced.
We need some pluggable bean Factory facility, don't we?

>1) VERY simple.  That is, it should not require more than one additional 
>attribute on the result mapping (if any at all), and it should not introduce 
>too many new interfaces or methods.  
I'm sorry I'm not following this.
I guess this policy means, if we need to add something on result mapping,
we can introduce only one new attribute,
which implicitly means we need to encapslate that new feature to a single class, correct?

>2) Portable to the .NET implementation.  iBATIS has a family now, and we have 
>to respect it.  Let's be careful to avoid such terms like "Bean".  I'm also 
I completely agree that naming is very importamt to make code redable and maintainable.
I just didn't consider about .NET at all. This is tough for me though.
So please let me know what the name equivalent to "bean" in iBATIS for .NET?

>not a fan of naming classes after patterns, especially not more than one.  
>"ServiceLocatorBean" has at least 3 patterns in the name, and as a new user 
Now I understood "Bean" makes a confusion for .NET user.
But "ServiceLocator" is a class name in class diagram in "ServiceLocator" pattern.
I think using the same name as in known class diagram is more easy to understand the design behind it,
and using different name for the pattern would result more confusion for the development team.
Does iBATIS hava its own naming convention for patternized implementation?

>3) Not redundant.  Before we do anything further, I'd like to see some 
>exploration of ways this can be achieved WITHOUT modifications to iBATIS.  If 
>there is no way, then we'll look into it.  But I would like to see some 
>effort applied here first.
I totally agree with you, and please do so, because
my limited knowledge of SQLMap could initiate this enhancement for my requirement.
So let me explain again, why I need this in my project.
1: I need to use external cache (I could use OSCache for this now, we can ignore this)
2: The application need to know the key for the each cache entry,
so that it can be invalidated, when the backend processes update corresponding information in DB.
3: There is no mechanism to invalidate cache entries by key respectively in SQLMap.

Tak

> Enhancement proposal: plug in external bean
> -------------------------------------------
>
>          Key: IBATIS-84
>          URL: http://issues.apache.org/jira/browse/IBATIS-84
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Versions: 2.0.9b
>     Reporter: Tak Yoshida

>
> Hello SQLMap development team,
> I would like to post this idea again,
> which was submitted to sourceforge forum last year.
> I believe this is not only for my case in real world, 
> and makes SQLMap more flexible. 
>  
> I have already done on 2.0.9b, and it works pretty well on my project.
> If you would reflect my proposal in the future SQLMap, that would be great. 
> thanks,
> Tak Yoshida
> -------- Here is the post on Oct 30th for 2.0.7 --------
> I found one thing I should ask,
> that is external service bean plug in feature for the complex object query. 
>  
> In my project, I need to use Oracle Object Cache Service for disributed  
> application environment. 
> and this cache will be managed outside of SQLMap framework, 
> which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages 
> cache object itself.
>  
> So I would like to have SQLMap call external service for complex object's sub 
> query. 
>  
> Here is my proposal:
> Summary: 
> Inject ServiceLocator to make SQLMap be able to call the service managed  
> outside of SQLMap. 
>  
> 1: To make use of external object, SqlMapClient has UserServiceBeanLocator 
> object property. 
>  
> public interface SqlMapClient extends SqlMapExecutor,  
> SqlMapTransactionManager { 
> public void setUserServiceBeanLocator(UserServiceBeanLocator 
> serviceBeanLocator); 
> public UserServiceBeanLocator getUserServiceBeanLocator(); 
> .... 
> } 
> And SqlMapClientImpl has this imlementation. 
>  
> public interface UserServiceBeanLocator { 
> // locator method 
> public Object getUserServiceBean(String name) throws SqlMapException; 
> } 
>  
>  
> 2: Extends resultMap's "result" tag attribute to specify the external bean 
> and the method name. 
>  
> <result property="shipMode" column="SMODE" javaType="string" 
> bean="shipModeDao" method="getShipModeById"/> 
> instead of 
> <result property="shipMode" column="SMODE" 
> select="shipModeSqlMap.getShipModeById"/> 
>  
> 3: To support 2, DTD must be enhanced for new two attributes, and  
> XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
>  
> 4: And to hold these external bean info in mapping object created by 
> XmlSqlMapClientBuilder, 
> I introduce UserServiceBeanInfo. 
> public class UserServiceBeanInfo { 
> private String beanName; 
> private String methodName; 
> private Method method; 
> ... 
> } 
>  
> 5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry 
> for the complex property by calling external service. 
>  
> Here is a snippet of the codes 
> } else if (mapping.getUserServiceBeanInfo() != null) { 
> // get key for complex property 
> Object rawValue = getPrimitiveResultMappingValue(rs, mapping); 
> // get complex property via external service 
> UserServiceBeanLocator serviceBeanLocator =  
> request.getSession().getSqlMapClient().getUserServiceBeanLocator(); 
> UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo(); 
> try { 
> Object service = 
> serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName()); 
> Method method = serviceBeanInfo.getMethod(); // check cacheed one. 
> if (method == null) { 
> method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new 
> Class[] {mapping.getJavaType()}); 
> serviceBeanInfo.setMethod(method); // cache it. 
> } 
> columnValues[i] = method.invoke(service, new Object[] {rawValue}); 
> ... exception handling... 
> } else { 
>  
> 6: Application is fully responsible to set this up at startup time. 
> I am injecting spring ApplicationContext object to SqlMapClient via 
> ApplicationListener, 
> -------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-84) Enhancement proposal: plug in external bean

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-84?page=comments#action_60293 ]
     
Clinton Begin commented on IBATIS-84:
-------------------------------------


Hi Tak, 

Looking into this a bit further, I wonder if you could manage this using either:

1) A custom cache model implementation (preferred).

or

2) A custom type handler.

As for the name, ServiceLocatorBean for me does not describe what it does.  To me, a Bean is primarily a data centric construct, whereas this is mostly function and no state.  ServiceLocator implies that a service is being looked up, but to my eyes it seems that it's actually looking up data.  If it is synonymous with a cache, then maybe we should call it a cache.

My recommendation is to write a custom cache model.  If there is a hook that you need (such as more specific manual flush capability), then let's look at that.

If the cache model doesn't work, then a Custom Type Handler might.  A CTH is not unlike what you've suggested.

Cheers,
Clinton

> Enhancement proposal: plug in external bean
> -------------------------------------------
>
>          Key: IBATIS-84
>          URL: http://issues.apache.org/jira/browse/IBATIS-84
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Versions: 2.0.9b
>     Reporter: Tak Yoshida

>
> Hello SQLMap development team,
> I would like to post this idea again,
> which was submitted to sourceforge forum last year.
> I believe this is not only for my case in real world, 
> and makes SQLMap more flexible. 
>  
> I have already done on 2.0.9b, and it works pretty well on my project.
> If you would reflect my proposal in the future SQLMap, that would be great. 
> thanks,
> Tak Yoshida
> -------- Here is the post on Oct 30th for 2.0.7 --------
> I found one thing I should ask,
> that is external service bean plug in feature for the complex object query. 
>  
> In my project, I need to use Oracle Object Cache Service for disributed  
> application environment. 
> and this cache will be managed outside of SQLMap framework, 
> which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages 
> cache object itself.
>  
> So I would like to have SQLMap call external service for complex object's sub 
> query. 
>  
> Here is my proposal:
> Summary: 
> Inject ServiceLocator to make SQLMap be able to call the service managed  
> outside of SQLMap. 
>  
> 1: To make use of external object, SqlMapClient has UserServiceBeanLocator 
> object property. 
>  
> public interface SqlMapClient extends SqlMapExecutor,  
> SqlMapTransactionManager { 
> public void setUserServiceBeanLocator(UserServiceBeanLocator 
> serviceBeanLocator); 
> public UserServiceBeanLocator getUserServiceBeanLocator(); 
> .... 
> } 
> And SqlMapClientImpl has this imlementation. 
>  
> public interface UserServiceBeanLocator { 
> // locator method 
> public Object getUserServiceBean(String name) throws SqlMapException; 
> } 
>  
>  
> 2: Extends resultMap's "result" tag attribute to specify the external bean 
> and the method name. 
>  
> <result property="shipMode" column="SMODE" javaType="string" 
> bean="shipModeDao" method="getShipModeById"/> 
> instead of 
> <result property="shipMode" column="SMODE" 
> select="shipModeSqlMap.getShipModeById"/> 
>  
> 3: To support 2, DTD must be enhanced for new two attributes, and  
> XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
>  
> 4: And to hold these external bean info in mapping object created by 
> XmlSqlMapClientBuilder, 
> I introduce UserServiceBeanInfo. 
> public class UserServiceBeanInfo { 
> private String beanName; 
> private String methodName; 
> private Method method; 
> ... 
> } 
>  
> 5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry 
> for the complex property by calling external service. 
>  
> Here is a snippet of the codes 
> } else if (mapping.getUserServiceBeanInfo() != null) { 
> // get key for complex property 
> Object rawValue = getPrimitiveResultMappingValue(rs, mapping); 
> // get complex property via external service 
> UserServiceBeanLocator serviceBeanLocator =  
> request.getSession().getSqlMapClient().getUserServiceBeanLocator(); 
> UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo(); 
> try { 
> Object service = 
> serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName()); 
> Method method = serviceBeanInfo.getMethod(); // check cacheed one. 
> if (method == null) { 
> method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new 
> Class[] {mapping.getJavaType()}); 
> serviceBeanInfo.setMethod(method); // cache it. 
> } 
> columnValues[i] = method.invoke(service, new Object[] {rawValue}); 
> ... exception handling... 
> } else { 
>  
> 6: Application is fully responsible to set this up at startup time. 
> I am injecting spring ApplicationContext object to SqlMapClient via 
> ApplicationListener, 
> -------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira