You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Chetan Mehrotra <ch...@gmail.com> on 2014/03/27 09:54:14 UTC

Remove SynchronizedDocumentStoreWrapper

I see two similar classes

- org.apache.jackrabbit.oak.plugins.document.rdb.SynchronizedDocumentStoreWrapper
- org.apache.jackrabbit.oak.plugins.document.util.SynchronizingDocumentStoreWrapper

And these are not being used anywhere. Further I am not sure what
purpose it would serve. Should they be removed.

Further can we implement other wrapper via proxies as it increases
work if new methods are to be added to DocumentStore

Chetan Mehrotra

Re: Remove SynchronizedDocumentStoreWrapper

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

I think proxies are a bit problematic. I would prefer the non-proxy
version.

Regards,
Thomas


On 27/03/14 10:41, "Chetan Mehrotra" <ch...@gmail.com> wrote:

>On Thu, Mar 27, 2014 at 2:30 PM, Julian Reschke <ju...@gmx.de>
>wrote:
>> I created the first one, and use it occasionally for debugging. (it's
>> similar to the Logging*Wrapper. Please do not remove.
>
>Okie but there already one preset in Util. Are they different? If not
>we should keep only one
>
>> Example?
>
>Something like
>public class SynchronizedDocumentStoreWrapper2 {
>
>    public static DocumentStore create(DocumentStore documentStore){
>        return (DocumentStore) Proxy.newProxyInstance(
>                SynchronizedDocumentStoreWrapper2.class.getClassLoader(),
>                new Class[] {DocumentStore.class},
>                new DocumentStoreProxy(documentStore));
>    }
>
>    private static class DocumentStoreProxy implements InvocationHandler {
>        private final DocumentStore delegate;
>        private final Object lock = new Object();
>
>        private DocumentStoreProxy(DocumentStore delegate) {
>            this.delegate = delegate;
>        }
>
>        @Override
>        public Object invoke(Object proxy, Method method, Object[]
>args) throws Throwable {
>            synchronized (lock){
>                return method.invoke(delegate, args);
>            }
>        }
>    }
>}
>
>Chetan Mehrotra


Re: Remove SynchronizedDocumentStoreWrapper

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Thu, Mar 27, 2014 at 4:00 PM, Julian Reschke <ju...@gmx.de> wrote:
> We can kill the one in rdb (I didn't see the other one when I added it).

Would do

Chetan Mehrotra

Re: Remove SynchronizedDocumentStoreWrapper

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-03-27 10:41, Chetan Mehrotra wrote:
> On Thu, Mar 27, 2014 at 2:30 PM, Julian Reschke <ju...@gmx.de> wrote:
>> I created the first one, and use it occasionally for debugging. (it's
>> similar to the Logging*Wrapper. Please do not remove.
>
> Okie but there already one preset in Util. Are they different? If not
> we should keep only one

We can kill the one in rdb (I didn't see the other one when I added it).

> ...

Best regards, Julian


Re: Remove SynchronizedDocumentStoreWrapper

Posted by Chetan Mehrotra <ch...@gmail.com>.
On Thu, Mar 27, 2014 at 2:30 PM, Julian Reschke <ju...@gmx.de> wrote:
> I created the first one, and use it occasionally for debugging. (it's
> similar to the Logging*Wrapper. Please do not remove.

Okie but there already one preset in Util. Are they different? If not
we should keep only one

> Example?

Something like
public class SynchronizedDocumentStoreWrapper2 {

    public static DocumentStore create(DocumentStore documentStore){
        return (DocumentStore) Proxy.newProxyInstance(
                SynchronizedDocumentStoreWrapper2.class.getClassLoader(),
                new Class[] {DocumentStore.class},
                new DocumentStoreProxy(documentStore));
    }

    private static class DocumentStoreProxy implements InvocationHandler {
        private final DocumentStore delegate;
        private final Object lock = new Object();

        private DocumentStoreProxy(DocumentStore delegate) {
            this.delegate = delegate;
        }

        @Override
        public Object invoke(Object proxy, Method method, Object[]
args) throws Throwable {
            synchronized (lock){
                return method.invoke(delegate, args);
            }
        }
    }
}

Chetan Mehrotra

Re: Remove SynchronizedDocumentStoreWrapper

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-03-27 09:54, Chetan Mehrotra wrote:
> I see two similar classes
>
> - org.apache.jackrabbit.oak.plugins.document.rdb.SynchronizedDocumentStoreWrapper
> - org.apache.jackrabbit.oak.plugins.document.util.SynchronizingDocumentStoreWrapper
>
> And these are not being used anywhere. Further I am not sure what
> purpose it would serve. Should they be removed.

I created the first one, and use it occasionally for debugging. (it's 
similar to the Logging*Wrapper. Please do not remove.

> Further can we implement other wrapper via proxies as it increases
> work if new methods are to be added to DocumentStore

Example?

Best regards, Julian