// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
// 
//     WRITE,
//     READ_FAST,
//     READ_COMMITTED;
// }


import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import pl.setblack.airomem.direct.OperationType;
/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
 *  http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.direct.impl;


/**
 *
 */
@ApplicationScoped
public class ClassContextRegistry {

    private final Map<Class, ClassContext> cache;

    @Inject
    private TransactionAnalyzer transactionAnalyzer;

    public ClassContextRegistry() {
        this.cache = new HashMap<>();
    }

    public synchronized ClassContext getContext(final Object object) {
        final Class clz = object.getClass();
        final ClassContext ctx = this.cache.get(clz);
        if (ctx == null) {
            return createAndStoreNewContext(clz);
        }
        return ctx;
    }

    private ClassContext createAndStoreNewContext(Class clz) {
        final ClassContext ctx = new ClassContext(clz);
        this.cache.put(clz, ctx);
        return ctx;
    }

// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
// 
//     WRITE,
//     READ_FAST,
//     READ_COMMITTED;
// }


// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/impl/ClassContextRegistry.java
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import pl.setblack.airomem.direct.OperationType;

/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
 *  http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.direct.impl;


/**
 *
 */
@ApplicationScoped
public class ClassContextRegistry {

    private final Map<Class, ClassContext> cache;

    @Inject
    private TransactionAnalyzer transactionAnalyzer;

    public ClassContextRegistry() {
        this.cache = new HashMap<>();
    }

    public synchronized ClassContext getContext(final Object object) {
        final Class clz = object.getClass();
        final ClassContext ctx = this.cache.get(clz);
        if (ctx == null) {
            return createAndStoreNewContext(clz);
        }
        return ctx;
    }

    private ClassContext createAndStoreNewContext(Class clz) {
        final ClassContext ctx = new ClassContext(clz);
        this.cache.put(clz, ctx);
        return ctx;
    }

    public OperationType sayTypeOfMethod(final Method method) {