You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lance Java <la...@googlemail.com> on 2012/06/21 11:24:17 UTC

MultiMapConfiguration

Hi, I'm aware that there is an OrderedConfiguration and a MappedConfiguration
but I would like a MultiMapConfiguration where I can contribute to a
Multimap (guava's implementation here
http://guava-libraries.googlecode.com/svn/tags/release03/javadoc/com/google/common/collect/Multimap.html)

Has anyone managed to implement this somehow?
Ideally I would like for contributions to specify an ordering in the
multimap.

eg:
AppModule.java
   public static void contibuteAuthorizers(MultiMapConfiguration<String,
Authorizer> config) {
      config.add("topic1", "auth1", new Authorizer1());
      config.add("topic1", "auth2", new Authorizer2(), "before:auth1");
      config.add("topic2", "auth3", new Authorizer3());
      config.add("topic2", "auth4", new Authorizer4(), "before:auth3");
   }

--
View this message in context: http://tapestry.1045711.n5.nabble.com/MultiMapConfiguration-tp5714003.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: MultiMapConfiguration

Posted by Lance Java <la...@googlemail.com>.
I have found a (slightly hacky) solution be using an OrderedConfiruration and
adding a getTopic() to my Authorizer interface.

public interface Authorizer {
   public String getTopic();
   public boolean authorize(Context context);
}

public void contributeAuthorizers(OrderedConfiguration<Authorizer> config) {
   config.add("auth1", new Authorizer1("topic1"));
   config.add("auth2", new Authorizer1("topic1"), "before:auth1");
   config.add("auth3", new Authorizer1("topic2"));
   config.add("auth4", new Authorizer1("topic2"), "before:auth3");
}

public void buildAuthorizers(List<Authorizer> authorizers) {
   MultiMap multimap = new HashMultiMap<String, Authorizer>();
   for (Authorizer auth : authorizers) {
      multimap.put(auth.getTopic(), auth);
   }
   return new AuthorizersImpl(multimap);
}


--
View this message in context: http://tapestry.1045711.n5.nabble.com/MultiMapConfiguration-tp5714003p5714004.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org