Jared Bunting (JIRA | 22 May 05:41 2012
Picon

[jira] [Created] (SHIRO-364) Add "bean listener" feature to Ini factories

Jared Bunting created SHIRO-364:
-----------------------------------

             Summary: Add "bean listener" feature to Ini factories
                 Key: SHIRO-364
                 URL: https://issues.apache.org/jira/browse/SHIRO-364
             Project: Shiro
          Issue Type: New Feature
            Reporter: Jared Bunting
            Assignee: Jared Bunting
             Fix For: 1.3.0

The ini factory/configuration  has been described as a poor man's dependency injection.  Even though other
DI mechanisms are often used when more power and configurability is required, the ini factory is still
quite popular.  Adding the ability to register "bean listeners" that are notified of the beans that get
created would allow us to add some more complex functionality to shiro, decouple it from our core classes,
and support it in all of our supported DI solutions.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

Jared Bunting (JIRA | 22 May 05:43 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280696#comment-13280696
] 

Jared Bunting commented on SHIRO-364:
-------------------------------------

The idea here is a "IniBeanListener" with a "notify(String name, Object bean)" that will be called once for
every bean that is a part of the factory.  

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
> The ini factory/configuration  has been described as a poor man's dependency injection.  Even though
other DI mechanisms are often used when more power and configurability is required, the ini factory is
still quite popular.  Adding the ability to register "bean listeners" that are notified of the beans that
get created would allow us to add some more complex functionality to shiro, decouple it from our core
classes, and support it in all of our supported DI solutions.

--
(Continue reading)

Les Hazlewood (JIRA | 23 May 19:09 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281728#comment-13281728
] 

Les Hazlewood commented on SHIRO-364:
-------------------------------------

In thinking about this a bit, I think we might want to take this a bit further and have methods like:

beanInstantiated = new instance
beanPropertySet = foo.bar = $whatever
beanPropertiesSet = after all properties have been set

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
> The ini factory/configuration  has been described as a poor man's dependency injection.  Even though
other DI mechanisms are often used when more power and configurability is required, the ini factory is
still quite popular.  Adding the ability to register "bean listeners" that are notified of the beans that
get created would allow us to add some more complex functionality to shiro, decouple it from our core
(Continue reading)

Jared Bunting (JIRA | 23 May 19:58 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281759#comment-13281759
] 

Jared Bunting commented on SHIRO-364:
-------------------------------------

So right now, my interface looks something like this:

public interface IniBeanListener {
    void notifyCreated(String name, Object bean);

    void notifyDestroyed(String name, Object bean);
}

Are you proposing that I add:

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
(Continue reading)

Jared Bunting (JIRA | 23 May 20:00 2012
Picon

[jira] [Comment Edited] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281759#comment-13281759
] 

Jared Bunting edited comment on SHIRO-364 at 5/23/12 5:59 PM:
--------------------------------------------------------------

So right now, my interface looks something like this:

public interface IniBeanListener {
    void notifyCreated(String name, Object bean);

    void notifyDestroyed(String name, Object bean);
}

Are you proposing that I also include:

void notifyPropertySet(String name, Object bean, String propertyName, String propertyValue)
and
void notifyPropertiesSet(String name, Object bean)

?

      was (Author: deraj123):
    So right now, my interface looks something like this:

public interface IniBeanListener {
    void notifyCreated(String name, Object bean);

(Continue reading)

Jared Bunting (JIRA | 23 May 20:00 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281760#comment-13281760
] 

Jared Bunting commented on SHIRO-364:
-------------------------------------

Also, I should note that I had planned on calling notifyCreated after properties were set, but if I were to
add these new methods it would make more sense to add it before.

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
> The ini factory/configuration  has been described as a poor man's dependency injection.  Even though
other DI mechanisms are often used when more power and configurability is required, the ini factory is
still quite popular.  Adding the ability to register "bean listeners" that are notified of the beans that
get created would allow us to add some more complex functionality to shiro, decouple it from our core
classes, and support it in all of our supported DI solutions.

--
(Continue reading)

Les Hazlewood (JIRA | 23 May 20:14 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281771#comment-13281771
] 

Les Hazlewood commented on SHIRO-364:
-------------------------------------

'created' can be interpreted in a number of ways (e.g. after all of its properties have been set, only then is
it finished being created).

My vote would be:

- notifyInstantiated(InstantiatedBeanEvent event);
- notifyPropertySet(PropertySetBeanEvent event);   The event's propertyValue could be an Object
(resolved reference) or a String (primitive value yet to be converted).  If the bean has a getter for that
property, they can get the converted value by calling bean.getWhateverProperty().
- notifyPropertiesSet(ConfiguredBeanEvent event);
- notifyDestroyed(DestroyedBeanEvent event);

The reason for the event instead of multiple arguments is for compatibility over time:  Coarse-grained
arguments (an object) allow us to add properties to it later.  Changing method signatures however would
break backwards compatibility.

The event could also have other useful information, for example, a reference back to the overall bean map in
case the event listener wanted to inspect other beans if necessary.

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
(Continue reading)

Les Hazlewood | 23 May 20:19 2012
Picon

Re: [jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories

(Moving design discussion here, as Jira tends to be too noisy for this)

Actually, even better, for the same compatibility reasons, have a
single event listener method:

IniBeanListener {
    void onBeanEvent(BeanEvent event);
}

This way adding new event types in the future (if ever necessary)
won't break existing implementations (assuming they ignore events they
don't want to process).

--
Les Hazlewood
CTO, Stormpath | http://stormpath.com | 888.391.5282
twitter:  <at> lhazlewood | http://twitter.com/lhazlewood
blog: http://leshazlewood.com
stormpath blog: http://www.stormpath.com/blog

On Wed, May 23, 2012 at 11:14 AM, Les Hazlewood (JIRA) <jira@...> wrote:
>
>    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281771#comment-13281771 ]
>
> Les Hazlewood commented on SHIRO-364:
> -------------------------------------
>
> 'created' can be interpreted in a number of ways (e.g. after all of its properties have been set, only then
is it finished being created).
(Continue reading)

Les Hazlewood | 23 May 20:20 2012
Picon

Re: [jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories

I'd also probably leave off the 'Ini' in the BeanListener name as well
- perhaps this could be used with other config too (like YAML or
Groovy config, or whatever).

On Wed, May 23, 2012 at 11:19 AM, Les Hazlewood <lhazlewood@...> wrote:
> (Moving design discussion here, as Jira tends to be too noisy for this)
>
> Actually, even better, for the same compatibility reasons, have a
> single event listener method:
>
> IniBeanListener {
>    void onBeanEvent(BeanEvent event);
> }
>
> This way adding new event types in the future (if ever necessary)
> won't break existing implementations (assuming they ignore events they
> don't want to process).
>
> --
> Les Hazlewood
> CTO, Stormpath | http://stormpath.com | 888.391.5282
> twitter:  <at> lhazlewood | http://twitter.com/lhazlewood
> blog: http://leshazlewood.com
> stormpath blog: http://www.stormpath.com/blog
>
>
> On Wed, May 23, 2012 at 11:14 AM, Les Hazlewood (JIRA)
<jira@...> wrote:
>>
>>    [
(Continue reading)

Luke Biddell (JIRA | 28 May 14:52 2012
Picon

[jira] [Commented] (SHIRO-170) Force New Session ID on Authentication


    [
https://issues.apache.org/jira/browse/SHIRO-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284391#comment-13284391
] 

Luke Biddell commented on SHIRO-170:
------------------------------------

+1 voting for this in the next release.

In the meantime I have hacked up the suggested fix by Les. I already have my own AuthenticationFilter so I've
rather cheekily overriden executeLogin and done this...

  <at> Override
    protected boolean executeLogin(final ServletRequest request, final ServletResponse response)
throws Exception {
        final AuthenticationToken token = createToken(request, response);
        if (token == null) {
            String msg = "createToken method implementation returned null. A valid non-null AuthenticationToken "
                    + "must be created in order to execute a login attempt.";
            throw new IllegalStateException(msg);
        }
        try {
            // Stop session fixation issues.
            // https://issues.apache.org/jira/browse/SHIRO-170
            final Subject subject = getSubject(request, response);
            Session session = subject.getSession();
            // Store the attributes so we can copy them to the new session after auth.
            final LinkedHashMap<Object, Object> attributes = new LinkedHashMap<Object, Object>();
            final Collection<Object> keys = session.getAttributeKeys();
(Continue reading)

Jared Bunting (JIRA | 20 Jun 06:04 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397240#comment-13397240
] 

Jared Bunting commented on SHIRO-364:
-------------------------------------

So far, I have implemented the majority of this and am committing what I have.  One thing to note is that I send
an instantiation notification for every bean in the map, including those passed in as "defaults" (if they
are not overridden).  Same for "notifyPropertiesSet", it is invoked on every bean in the map, whether it
specifically had any properties set or not.

I have not implemented "notifyPropertySet" simply because I'm not sure how to keep it consistent with the
behavior that I just described.

Anyways, comments welcome.

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
(Continue reading)

Les Hazlewood (JIRA | 17 Nov 09:19 2012
Picon

[jira] [Commented] (SHIRO-364) Add "bean listener" feature to Ini factories


    [
https://issues.apache.org/jira/browse/SHIRO-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499374#comment-13499374
] 

Les Hazlewood commented on SHIRO-364:
-------------------------------------

Hi Jared,

I just implemented SHIRO-395 - I'm assuming this BeanEvent stuff could leverage this as well.  If you get a
chance, please review - I'm curious to know what you think.

Cheers,

Les

> Add "bean listener" feature to Ini factories
> --------------------------------------------
>
>                 Key: SHIRO-364
>                 URL: https://issues.apache.org/jira/browse/SHIRO-364
>             Project: Shiro
>          Issue Type: New Feature
>            Reporter: Jared Bunting
>            Assignee: Jared Bunting
>             Fix For: 1.3.0
>
>
> The ini factory/configuration  has been described as a poor man's dependency injection.  Even though
(Continue reading)


Gmane