[Yanel-dev] policy viewer refactoring (inside "policymanager" resource-type)

Guillaume Déflache guillaume.deflache at wyona.com
Tue Mar 23 15:35:08 CET 2010


Michael Wechner schrieb:
> Guillaume Déflache wrote:
>> Michael Wechner schrieb:
>>> Guillaume Déflache wrote:
>>>> Hi!
>>>>
>>>> For a project I need to implement some specific behaviour for the 
>>>> policy viewer.
>>>> So as to also reuse existing Yanel code for other unchanged things 
>>>> I'd need to be able to reuse parts of the existing Yanel 
>>>> implementation.
>>>>
>>>>
>>>> ATM alas the policy viewer is implemented by calling the sole static 
>>>> method PolicyViewer#getXHTMLView(PolicyManager pm, GroupManager gm, 
>>>> String path, String contentItemId, [other view options' parameters]) 
>>>> which does not allow any kind of overriding.
>>>>
>>>>
>>>> I'd like to introduce the following method in 
>>>> org.wyona.yanel.impl.resources.policymanager.PolicyManagerResource:
>>>>
>>>>     protected PolicyViewer getPolicyViewer(PolicyManager pm, 
>>>> GroupManager gm, [other view options' parameters]);
>>>>
>>>> with the visible API of PolicyViewer being:
>>>>
>>>>     InputStream getXHTMLInputStream(String path, String 
>>>> contentItemId) throws Exception
>>>>
>>>> Then I would be able to just change the used resource-type in 
>>>> $MY_SPECIFIC_REALM_DIR/src/webapp/global-resource-configs/policy-manager_yanel-rc.xml 
>>>> to one using my own PolicyViewer-based Java class!
>>>>
>>>> WDYT?
>>>
>>> What exactly would you like to do?
>>
>> The 1st thing I would like to do is to able to use the existing 
>> PolicyManagerResource as it is now, except I'd like to replace the 
>> PolicyViewer by another project-specific class, possibly reusing some 
>> parts of Yanel's original PolicyViewer implementation at a later stage.
>>
>>
>>> The reason I am asking is because I think "overriding/inheritance" is 
>>> not always a good thing and maybe it's better to introduce
>>> appropriate interfaces.
>>
>> I do suggest introducing an API when I write "the visible API of 
>> PolicyViewer", even if in this 1st step it would not be a Java 
>> interface per se.
>> But indeed we should introduce a PolicyViewerV1 Java interface at some 
>> point, except for now I am not 100% sure if what I suggest is 
>> sufficient even for my own needs and if I would not need a 
>> finer-grained one later
> 
> what is your suggestion re an API right now?

in src/core/java:

package org.wyona.yanel.core[.security].api;

interface PolicyViewerV1 {

     InputStream getXHTMLInputStream(String path, String contentItemId) 
throws Exception;

}

But as I tried to explain for this interface to be really usable and get 
used ATM we need to change 
org.wyona.yanel.impl.resources.policymanager.PolicyManagerResource as 
follows:

replace the call:
PolicyViewer.getXHTMLView(getRealm().getPolicyManager(), 
getRealm().getIdentityManager().getGroupManager(), getPath(), 
contentItemID, [other parameters for view options like sort order])
by:
PolicyViewer pv = 
policyViewerFactory.getPolicyViewer(getRealm().getPolicyManager(), 
getRealm().getIdentityManager().getGroupManager(), [other parameters for 
view options like sort order]);
pv..getXHTMLInputStream(getPath(), contentItemID)

...where policyViewerFactory may be any class implementing the following 
interface:

     PolicyViewer getPolicyViewer(PolicyManager pm, GroupManager gm, 
other parameters for view options like sort order])

...including PolicyManagerResource itself: my point was that I think we 
do not need a separate factory for now.

If we want to use a separate factory, then we need a way to configure 
the actual factory class used: I guess we should do it the same as for 
example PolicyManagerFactory?


>> So I'd rather use a class than an interface at this point to avoid 
>> setting it in stone too early.
> 
> this is why we use versioned interfaces ...
> 
> Don't be afraid of suggestion an interface.

I am just unsure at the moment how wide all this should be exposed, 
given that it is the 1st usecase we have.


>>
>>
>> Hope this clears things a bit.
> 
> not really, because I still don't know how you would actually like to 
> use it.

Is that better?


Cheers,
    Guillaume


More information about the Yanel-development mailing list