commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: Chain Configuration
Date Sun, 13 Oct 2013 19:34:23 GMT
Hi Jagan,

I really don't know, it may be a problem if some other code also calls
getInstance and then changes the CatalogFactory... But if you only
initialize it once, it should work.

Benedikt


2013/10/12 Jagan Ranganathan <jagan@zohocorp.com>

> Hi,
>
> Instead of invoking CatalogFactory.getInstance everytime, thought we can
> invoke the getInstance as soon as we parse and keep the instance as static
> in the parser/init class. But it defeats the purpose of ClassLoader usage
> in the getInstance.
>
>
> Hope there won't be any issues with such usage.
>
>
> Regards,
> Jagan
>
> ---- On Sat, 12 Oct 2013 14:48:37 +0530 Benedikt Ritter &
> lt;britter@apache.org&gt; wrote ----
>
>
> Hi Jagan,
>
> sorry I don't understand what you mean by "retained CatalogFactory instance
> in our backend code". Can you explain?
>
> Benedikt
>
>
> 2013/10/12 Jagan Ranganathan &lt;jagan@zohocorp.com&gt;
>
> &gt; Hi,
> &gt;
> &gt; Thanks for your response. We retained CatalogFactory instance in our
> &gt; backend code where we parsed the chain config xml. You see any issues
> with
> &gt; this?
> &gt;
> &gt;
> &gt; Regards,
> &gt; Jagan
> &gt;
> &gt; ---- On Fri, 11 Oct 2013 14:52:25 +0530 Benedikt
> &gt; Ritter&amp;lt;britter@apache.org&amp;gt; wrote ----
> &gt;
> &gt;
> &gt; Hi Jagan,
> &gt;
> &gt; as far as I know, no there isn't... We know this is a flaw in chain
> and we
> &gt; intended to fix it for chain2 (which is in the current trunk of
> chain). But
> &gt; currently there is nobody who really has the time make chain2 ready
> for a
> &gt; release. Simone Tripodi was working on it and he intended to
> implement the
> &gt; configuration module using modello [1]. But that seems to be blocked
> until
> &gt; a new modello release hits the road...
> &gt;
> &gt; Benedikt
> &gt;
> &gt; [1] http://modello.codehaus.org
> &gt;
> &gt;
> &gt; 2013/10/11 Jagan Ranganathan &amp;lt;jagan@zohocorp.com&amp;gt;
> &gt;
> &gt; &amp;gt; Hi,
> &gt; &amp;gt;
> &gt; &amp;gt; We are trying to use Chain Of Responsibility pattern in the
> server
> &gt; side.
> &gt; &amp;gt; We have defined our chain+commands in an xml and are parsing
> it via
> &gt; &amp;gt; ConfigParser.
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; But we face a problem with getting Catalog via
> &gt; &amp;gt; CatalogFactoryBase.getInstance().getCatalog(catalogName)
> call.Looks
> &gt; like it
> &gt; &amp;gt; has got some ClassLoader specific loading. So if we have
> initialized
> &gt; in
> &gt; &amp;gt; some web context, the Catalog is not present in other
> context -
> &gt; different
> &gt; &amp;gt; ClassLoader.
> &gt; &amp;gt; Is there anyway we can remove this ClassLoader level
> dependency or is
> &gt; &amp;gt; there any other way of loading the chain configuration for
> server side
> &gt; &amp;gt; usage?
> &gt; &amp;gt; /** * &amp;amp;lt;p&amp;amp;gt;Return the singleton {@link
> CatalogFactory}
> &gt; instance
> &gt; &amp;gt; * for the relevant
> &gt; &amp;amp;lt;code&amp;amp;gt;ClassLoader&amp;amp;lt;/code&amp;amp;gt;.
> For
> &gt; &amp;gt; applications
> &gt; &amp;gt; * that use a thread context class loader (such as web
> applications
> &gt; &amp;gt; * running inside a servet container), this will return a
> separate
> &gt; &amp;gt; * instance for each application, even if this class is
> loaded from
> &gt; &amp;gt; * a shared parent class loader.&amp;amp;lt;/p&amp;amp;gt;
> &gt; &amp;gt; *
> &gt; &amp;gt; * @return the per-application singleton instance of {@link
> &gt; &amp;gt; CatalogFactory}
> &gt; &amp;gt; */
> &gt; &amp;gt; public static CatalogFactory getInstance() {
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; CatalogFactory factory = null;
> &gt; &amp;gt; ClassLoader cl = getClassLoader();
> &gt; &amp;gt; synchronized (factories) {
> &gt; &amp;gt; factory = (CatalogFactory) factories.get(cl);
> &gt; &amp;gt; if (factory == null) {
> &gt; &amp;gt; factory = new CatalogFactoryBase();
> &gt; &amp;gt; factories.put(cl, factory);
> &gt; &amp;gt; }
> &gt; &amp;gt; }
> &gt; &amp;gt; return factory;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; }
> &gt; &amp;gt;
> &gt; &amp;gt; Regards,
> &gt; &amp;gt; Jagan
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt;
> &gt;
> &gt; --
> &gt; http://people.apache.org/~britter/
> &gt; http://www.systemoutprintln.de/
> &gt; http://twitter.com/BenediktRitter
> &gt; http://github.com/britter
> &gt;
> &gt;
> &gt;
> &gt;
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>
>
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message