atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apoorvn...@apache.org
Subject [11/12] incubator-atlas git commit: ATLAS-1198: Spring Framework (v4 with Spring security) over Guice
Date Tue, 23 May 2017 22:07:09 GMT
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/GraphTransaction.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/GraphTransaction.java b/repository/src/main/java/org/apache/atlas/GraphTransaction.java
deleted file mode 100644
index b73f4ed..0000000
--- a/repository/src/main/java/org/apache/atlas/GraphTransaction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface GraphTransaction {
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/GraphTransactionAdvisor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/GraphTransactionAdvisor.java b/repository/src/main/java/org/apache/atlas/GraphTransactionAdvisor.java
new file mode 100644
index 0000000..9751a87
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/GraphTransactionAdvisor.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas;
+
+import org.aopalliance.aop.Advice;
+import org.apache.atlas.annotation.GraphTransaction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.aop.Pointcut;
+import org.springframework.aop.support.AbstractPointcutAdvisor;
+import org.springframework.aop.support.StaticMethodMatcherPointcut;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.lang.reflect.Method;
+
+@Component
+public class GraphTransactionAdvisor extends AbstractPointcutAdvisor {
+    private static final Logger LOG = LoggerFactory.getLogger(GraphTransactionAdvisor.class);
+
+    private final StaticMethodMatcherPointcut pointcut = new StaticMethodMatcherPointcut() {
+        @Override
+        public boolean matches(Method method, Class<?> targetClass) {
+            boolean annotationPresent = method.isAnnotationPresent(GraphTransaction.class);
+            if (annotationPresent) {
+                LOG.info("GraphTransaction intercept for {}.{}", targetClass.getName(), method.getName());
+            }
+            return annotationPresent;
+        }
+    };
+
+    private final GraphTransactionInterceptor interceptor;
+
+    @Inject
+    public GraphTransactionAdvisor(GraphTransactionInterceptor interceptor) {
+        this.interceptor = interceptor;
+    }
+
+    @Override
+    public Pointcut getPointcut() {
+        return pointcut;
+    }
+
+    @Override
+    public Advice getAdvice() {
+        return interceptor;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java b/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java
index 0f85b61..7d3bdf7 100644
--- a/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java
+++ b/repository/src/main/java/org/apache/atlas/GraphTransactionInterceptor.java
@@ -20,30 +20,32 @@ package org.apache.atlas;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.typesystem.exception.NotFoundException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
 import javax.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.List;
 
+@Component
 public class GraphTransactionInterceptor implements MethodInterceptor {
     private static final Logger LOG = LoggerFactory.getLogger(GraphTransactionInterceptor.class);
 
     private static final ThreadLocal<List<PostTransactionHook>> postTransactionHooks = new ThreadLocal<>();
 
-    private AtlasGraph graph;
+    private final AtlasGraph graph;
+
+    @Inject
+    public GraphTransactionInterceptor(AtlasGraph graph) {
+        this.graph = graph;
+    }
 
     @Override
     public Object invoke(MethodInvocation invocation) throws Throwable {
-        
-        if (graph == null) {
-            graph = AtlasGraphProvider.getGraphInstance();
-        }
-
         boolean isSuccess = false;
 
         try {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java b/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java
deleted file mode 100755
index 6c175ae..0000000
--- a/repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas;
-
-import com.google.inject.Binder;
-import com.google.inject.Singleton;
-import com.google.inject.matcher.Matchers;
-import com.google.inject.multibindings.Multibinder;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.apache.atlas.discovery.AtlasDiscoveryService;
-import org.apache.atlas.discovery.AtlasLineageService;
-import org.apache.atlas.discovery.DataSetLineageService;
-import org.apache.atlas.discovery.DiscoveryService;
-import org.apache.atlas.discovery.EntityDiscoveryService;
-import org.apache.atlas.discovery.EntityLineageService;
-import org.apache.atlas.discovery.LineageService;
-import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService;
-import org.apache.atlas.listener.EntityChangeListener;
-import org.apache.atlas.listener.TypeDefChangeListener;
-import org.apache.atlas.listener.TypesChangeListener;
-import org.apache.atlas.repository.MetadataRepository;
-import org.apache.atlas.repository.audit.EntityAuditListener;
-import org.apache.atlas.repository.audit.EntityAuditRepository;
-import org.apache.atlas.repository.graph.DeleteHandler;
-import org.apache.atlas.repository.graph.GraphBackedMetadataRepository;
-import org.apache.atlas.repository.graph.GraphBackedSearchIndexer;
-import org.apache.atlas.repository.store.graph.AtlasEntityDefStore;
-import org.apache.atlas.repository.store.graph.AtlasEntityStore;
-import org.apache.atlas.repository.store.graph.v1.AtlasEntityDefStoreV1;
-import org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1;
-import org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1;
-import org.apache.atlas.repository.store.graph.v1.DeleteHandlerV1;
-import org.apache.atlas.repository.store.graph.v1.EntityGraphMapper;
-import org.apache.atlas.repository.typestore.GraphBackedTypeStore;
-import org.apache.atlas.repository.typestore.ITypeStore;
-import org.apache.atlas.service.Service;
-import org.apache.atlas.services.DefaultMetadataService;
-import org.apache.atlas.services.MetadataService;
-import org.apache.atlas.store.AtlasTypeDefStore;
-import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.typesystem.types.TypeSystem;
-import org.apache.atlas.typesystem.types.TypeSystemProvider;
-import org.apache.atlas.typesystem.types.cache.TypeCache;
-import org.apache.atlas.util.AtlasRepositoryConfiguration;
-import org.apache.commons.configuration.Configuration;
-
-/**
- * Guice module for Repository module.
- */
-public class RepositoryMetadataModule extends com.google.inject.AbstractModule {
-
-    @Override
-    protected void configure() {
-
-        // allow for dynamic binding of the metadata repo & graph service
-        // bind the MetadataRepositoryService interface to an implementation
-        bind(MetadataRepository.class).to(GraphBackedMetadataRepository.class).asEagerSingleton();
-
-        bind(TypeSystem.class).toProvider(TypeSystemProvider.class).in(Singleton.class);
-
-        // bind the ITypeStore interface to an implementation
-        bind(ITypeStore.class).to(GraphBackedTypeStore.class).asEagerSingleton();
-        bind(AtlasTypeDefStore.class).to(AtlasTypeDefGraphStoreV1.class).asEagerSingleton();
-
-        //For testing
-        bind(AtlasEntityDefStore.class).to(AtlasEntityDefStoreV1.class).asEagerSingleton();
-        bind(AtlasTypeRegistry.class).asEagerSingleton();
-
-        //GraphBackedSearchIndexer must be an eager singleton to force the search index creation to happen before
-        //we try to restore the type system (otherwise we'll end up running queries
-        //before we have any indices during the initial graph setup)
-        Multibinder<TypesChangeListener> typesChangeListenerBinder =
-                Multibinder.newSetBinder(binder(), TypesChangeListener.class);
-        typesChangeListenerBinder.addBinding().to(GraphBackedSearchIndexer.class).asEagerSingleton();
-
-        // New typesdef/instance change listener should also be bound to the corresponding implementation
-        Multibinder<TypeDefChangeListener> typeDefChangeListenerMultibinder =
-                Multibinder.newSetBinder(binder(), TypeDefChangeListener.class);
-        typeDefChangeListenerMultibinder.addBinding().to(DefaultMetadataService.class);
-        typeDefChangeListenerMultibinder.addBinding().to(GraphBackedSearchIndexer.class).asEagerSingleton();
-
-        bind(AtlasEntityStore.class).to(AtlasEntityStoreV1.class);
-
-        // bind the MetadataService interface to an implementation
-        bind(MetadataService.class).to(DefaultMetadataService.class).asEagerSingleton();
-
-        // bind the DiscoveryService interface to an implementation
-        bind(DiscoveryService.class).to(GraphBackedDiscoveryService.class).asEagerSingleton();
-        bind(AtlasDiscoveryService.class).to(EntityDiscoveryService.class).asEagerSingleton();
-
-        bind(LineageService.class).to(DataSetLineageService.class).asEagerSingleton();
-        bind(AtlasLineageService.class).to(EntityLineageService.class).asEagerSingleton();
-
-        Configuration configuration = getConfiguration();
-        bindAuditRepository(binder(), configuration);
-
-        bind(DeleteHandler.class).to(AtlasRepositoryConfiguration.getDeleteHandlerImpl()).asEagerSingleton();
-
-        bind(DeleteHandlerV1.class).to(AtlasRepositoryConfiguration.getDeleteHandlerV1Impl()).asEagerSingleton();
-
-        bind(TypeCache.class).to(AtlasRepositoryConfiguration.getTypeCache()).asEagerSingleton();
-
-        bind(EntityGraphMapper.class);
-
-        //Add EntityAuditListener as EntityChangeListener
-        Multibinder<EntityChangeListener> entityChangeListenerBinder =
-                Multibinder.newSetBinder(binder(), EntityChangeListener.class);
-        entityChangeListenerBinder.addBinding().to(EntityAuditListener.class);
-
-        MethodInterceptor interceptor = new GraphTransactionInterceptor();
-        requestInjection(interceptor);
-        bindInterceptor(Matchers.any(), Matchers.annotatedWith(GraphTransaction.class), interceptor);
-    }
-
-    protected Configuration getConfiguration() {
-        try {
-            return ApplicationProperties.get();
-        } catch (AtlasException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    protected void bindAuditRepository(Binder binder, Configuration configuration) {
-
-        Class<? extends EntityAuditRepository> auditRepoImpl = AtlasRepositoryConfiguration.getAuditRepositoryImpl();
-
-        //Map EntityAuditRepository interface to configured implementation
-        binder.bind(EntityAuditRepository.class).to(auditRepoImpl).asEagerSingleton();
-
-        if(Service.class.isAssignableFrom(auditRepoImpl)) {
-            Class<? extends Service> auditRepoService = (Class<? extends Service>)auditRepoImpl;
-            //if it's a service, make sure that it gets properly closed at shutdown
-            Multibinder<Service> serviceBinder = Multibinder.newSetBinder(binder, Service.class);
-            serviceBinder.addBinding().to(auditRepoService);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/discovery/DataSetLineageService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/DataSetLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/DataSetLineageService.java
index b65b67d..af7f1b4 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/DataSetLineageService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/DataSetLineageService.java
@@ -18,17 +18,11 @@
 
 package org.apache.atlas.discovery;
 
-import java.util.Arrays;
-import java.util.Iterator;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasConfiguration;
 import org.apache.atlas.AtlasException;
-import org.apache.atlas.GraphTransaction;
+import org.apache.atlas.annotation.GraphTransaction;
 import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy;
 import org.apache.atlas.discovery.graph.GraphBackedDiscoveryService;
 import org.apache.atlas.query.GremlinQueryResult;
@@ -37,7 +31,6 @@ import org.apache.atlas.query.OutputLineageClosureQuery;
 import org.apache.atlas.query.QueryParams;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.MetadataRepository;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
@@ -49,16 +42,22 @@ import org.apache.atlas.utils.ParamChecker;
 import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+import org.springframework.stereotype.Component;
 import scala.Option;
 import scala.Some;
 import scala.collection.JavaConversions;
 import scala.collection.immutable.List;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.Arrays;
+import java.util.Iterator;
+
 /**
  * Hive implementation of Lineage service interface.
  */
 @Singleton
+@Component
 public class DataSetLineageService implements LineageService {
 
     private static final Logger LOG = LoggerFactory.getLogger(DataSetLineageService.class);
@@ -91,8 +90,9 @@ public class DataSetLineageService implements LineageService {
 
     @Inject
     DataSetLineageService(MetadataRepository metadataRepository,
-                          GraphBackedDiscoveryService discoveryService) throws DiscoveryException {
-        this.graph = AtlasGraphProvider.getGraphInstance();
+                          GraphBackedDiscoveryService discoveryService,
+                          AtlasGraph atlasGraph) throws DiscoveryException {
+        this.graph = atlasGraph;
         this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository);
         this.discoveryService = discoveryService;
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index 1b4583a..128cdbf 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -20,7 +20,6 @@ package org.apache.atlas.discovery;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasConfiguration;
 import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.discovery.AtlasSearchResult;
@@ -28,6 +27,7 @@ import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult;
 import org.apache.atlas.model.discovery.AtlasSearchResult.AtlasQueryType;
 import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
 import org.apache.atlas.model.instance.AtlasEntity.Status;
+import org.apache.atlas.AtlasException;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.query.Expressions.AliasExpression;
 import org.apache.atlas.query.Expressions.Expression;
@@ -40,7 +40,6 @@ import org.apache.atlas.query.QueryProcessor;
 import org.apache.atlas.query.SelectExpressionHelper;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.MetadataRepository;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
@@ -58,6 +57,7 @@ import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 import scala.Option;
 import scala.util.Either;
 import scala.util.parsing.combinator.Parsers.NoSuccess;
@@ -73,10 +73,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import static org.apache.atlas.AtlasErrorCode.CLASSIFICATION_NOT_FOUND;
 import static org.apache.atlas.AtlasErrorCode.DISCOVERY_QUERY_FAILED;
 import static org.apache.atlas.AtlasErrorCode.UNKNOWN_TYPENAME;
-import static org.apache.atlas.AtlasErrorCode.CLASSIFICATION_NOT_FOUND;
 
+@Component
 public class EntityDiscoveryService implements AtlasDiscoveryService {
     private static final Logger LOG = LoggerFactory.getLogger(EntityDiscoveryService.class);
 
@@ -90,8 +91,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
     private final int                             maxTagsCountInIdxQuery;
 
     @Inject
-    EntityDiscoveryService(MetadataRepository metadataRepository, AtlasTypeRegistry typeRegistry) throws AtlasException {
-        this.graph                    = AtlasGraphProvider.getGraphInstance();
+    EntityDiscoveryService(MetadataRepository metadataRepository, AtlasTypeRegistry typeRegistry, AtlasGraph graph) throws AtlasException {
+        this.graph                    = graph;
         this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository);
         this.entityRetriever          = new EntityGraphRetriever(typeRegistry);
         this.gremlinQueryProvider     = AtlasGremlinQueryProvider.INSTANCE;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
index d6aca89..b07091a 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
@@ -24,10 +24,9 @@ import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.lineage.AtlasLineageInfo;
-import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation;
 import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
+import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation;
 import org.apache.atlas.repository.Constants;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
@@ -36,9 +35,9 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.util.AtlasGremlinQueryProvider;
 import org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery;
 import org.apache.commons.collections.CollectionUtils;
+import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
-import javax.script.ScriptException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -46,6 +45,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+@Service
 public class EntityLineageService implements AtlasLineageService {
     private static final String INPUT_PROCESS_EDGE      =  "__Process.inputs";
     private static final String OUTPUT_PROCESS_EDGE     =  "__Process.outputs";
@@ -55,8 +55,8 @@ public class EntityLineageService implements AtlasLineageService {
     private final EntityGraphRetriever      entityRetriever;
 
     @Inject
-    EntityLineageService(AtlasTypeRegistry typeRegistry) throws DiscoveryException {
-        this.graph                = AtlasGraphProvider.getGraphInstance();
+    EntityLineageService(AtlasTypeRegistry typeRegistry, AtlasGraph atlasGraph) throws DiscoveryException {
+        this.graph                = atlasGraph;
         this.gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE;
         this.entityRetriever      = new EntityGraphRetriever(typeRegistry);
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
index 23e4531..083c34d 100755
--- a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java
@@ -18,18 +18,8 @@
 
 package org.apache.atlas.discovery.graph;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
 import org.apache.atlas.AtlasClient;
-import org.apache.atlas.GraphTransaction;
+import org.apache.atlas.annotation.GraphTransaction;
 import org.apache.atlas.discovery.DiscoveryException;
 import org.apache.atlas.discovery.DiscoveryService;
 import org.apache.atlas.exception.AtlasBaseException;
@@ -43,7 +33,6 @@ import org.apache.atlas.query.QueryParser;
 import org.apache.atlas.query.QueryProcessor;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.MetadataRepository;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasEdge;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
@@ -56,14 +45,24 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+import org.springframework.stereotype.Component;
 import scala.util.Either;
 import scala.util.parsing.combinator.Parsers;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Graph backed implementation of Search.
  */
 @Singleton
+@Component
 public class GraphBackedDiscoveryService implements DiscoveryService {
 
     private static final Logger LOG = LoggerFactory.getLogger(GraphBackedDiscoveryService.class);
@@ -74,9 +73,9 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
     public final static String SCORE = "score";
 
     @Inject
-    GraphBackedDiscoveryService(MetadataRepository metadataRepository)
+    GraphBackedDiscoveryService(MetadataRepository metadataRepository, AtlasGraph atlasGraph)
     throws DiscoveryException {
-        this.graph = AtlasGraphProvider.getGraphInstance();
+        this.graph = atlasGraph;
         this.graphPersistenceStrategy = new DefaultGraphPersistenceStrategy(metadataRepository);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java b/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
index 9a873b3..b72ee7d 100644
--- a/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
+++ b/repository/src/main/java/org/apache/atlas/repository/MetadataRepository.java
@@ -18,9 +18,9 @@
 
 package org.apache.atlas.repository;
 
-import org.apache.atlas.AtlasClient;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.CreateUpdateEntitiesResult;
+import org.apache.atlas.model.legacy.EntityResult;
 import org.apache.atlas.typesystem.ITypedReferenceableInstance;
 import org.apache.atlas.typesystem.ITypedStruct;
 import org.apache.atlas.typesystem.exception.EntityExistsException;
@@ -135,7 +135,7 @@ public interface MetadataRepository {
      * @return guids of deleted entities
      * @throws RepositoryException
      */
-    AtlasClient.EntityResult deleteEntities(List<String> guids) throws RepositoryException;
+    EntityResult deleteEntities(List<String> guids) throws RepositoryException;
     
     
     // Trait management functions

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java b/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
new file mode 100644
index 0000000..261a6d0
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/repository/RepositoryConfiguration.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.repository;
+
+import org.apache.atlas.repository.graphdb.GraphDatabase;
+import org.apache.atlas.typesystem.types.TypeSystem;
+import org.apache.atlas.util.AtlasRepositoryConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RepositoryConfiguration {
+    @Bean
+    public GraphDatabase getGraphDatabase() throws IllegalAccessException, InstantiationException {
+        return AtlasRepositoryConfiguration.getGraphDatabaseImpl().newInstance();
+    }
+
+    @Bean
+    public TypeSystem getTypeSystem() {
+        return TypeSystem.getInstance();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
index eab86c4..2a1881b 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java
@@ -32,6 +32,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.nio.charset.StandardCharsets;
@@ -44,6 +45,7 @@ import java.util.Map;
 /**
  * Listener on entity create/update/delete, tag add/delete. Adds the corresponding audit event to the audit repository.
  */
+@Component
 public class EntityAuditListener implements EntityChangeListener {
     private static final Logger LOG = LoggerFactory.getLogger(EntityAuditListener.class);
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java b/repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
index 9de2110..89ca748 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/HBaseBasedAuditRepository.java
@@ -19,10 +19,10 @@
 package org.apache.atlas.repository.audit;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Singleton;
 import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.EntityAuditEvent;
+import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
 import org.apache.atlas.ha.HAConfiguration;
 import org.apache.atlas.listener.ActiveStateChangeHandler;
 import org.apache.atlas.service.Service;
@@ -47,7 +47,9 @@ import org.apache.hadoop.hbase.regionserver.BloomType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Singleton;
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -70,6 +72,8 @@ import java.util.Map;
  * But if there are more than one atlas servers, we should use server id in the key
  */
 @Singleton
+@Component
+@ConditionalOnAtlasProperty(property = "atlas.EntityAuditRepository.impl")
 public class HBaseBasedAuditRepository implements Service, EntityAuditRepository, ActiveStateChangeHandler {
     private static final Logger LOG = LoggerFactory.getLogger(HBaseBasedAuditRepository.class);
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java b/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
index 86f1af7..22d2a81 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/InMemoryEntityAuditRepository.java
@@ -18,21 +18,24 @@
 
 package org.apache.atlas.repository.audit;
 
+import org.apache.atlas.AtlasException;
+import org.apache.atlas.EntityAuditEvent;
+import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Singleton;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.EntityAuditEvent;
-
-import com.google.inject.Singleton;
-
 /**
  * Entity audit repository where audit events are stored in-memory. Used only for integration tests
  */
 @Singleton
+@Component
+@ConditionalOnAtlasProperty(property = "atlas.EntityAuditRepository.impl")
 public class InMemoryEntityAuditRepository implements EntityAuditRepository {
     private TreeMap<String, EntityAuditEvent> auditEvents = new TreeMap<>();
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java b/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
index d4d3c20..7c39ce9 100644
--- a/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
+++ b/repository/src/main/java/org/apache/atlas/repository/audit/NoopEntityAuditRepository.java
@@ -18,18 +18,21 @@
 
 package org.apache.atlas.repository.audit;
 
-import java.util.Collections;
-import java.util.List;
-
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.EntityAuditEvent;
+import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
+import org.springframework.stereotype.Component;
 
-import com.google.inject.Singleton;
+import javax.inject.Singleton;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * Implementation that completely disables the audit repository.
  */
 @Singleton
+@Component
+@ConditionalOnAtlasProperty(property = "atlas.EntityAuditRepository.impl", isDefault = true)
 public class NoopEntityAuditRepository implements EntityAuditRepository {
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasAbstractFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasAbstractFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasAbstractFormatConverter.java
index a36618c..ab0d1fc 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasAbstractFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasAbstractFormatConverter.java
@@ -21,8 +21,8 @@ package org.apache.atlas.repository.converters;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.type.AtlasTypeRegistry;
 
-
 public abstract class AtlasAbstractFormatConverter implements AtlasFormatConverter {
+
     protected final AtlasFormatConverters converterRegistry;
     protected final AtlasTypeRegistry     typeRegistry;
     protected final TypeCategory          typeCategory;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
index d71d543..734bd0c 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasEnumFormatConverter.java
@@ -28,8 +28,8 @@ import org.apache.atlas.typesystem.types.EnumValue;
 
 import java.util.Map;
 
-
 public class AtlasEnumFormatConverter extends AtlasAbstractFormatConverter {
+
     public AtlasEnumFormatConverter(AtlasFormatConverters registry, AtlasTypeRegistry typeRegistry) {
         super(registry, typeRegistry, TypeCategory.ENUM);
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasFormatConverters.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasFormatConverters.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasFormatConverters.java
index 3a164c8..d519806 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasFormatConverters.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasFormatConverters.java
@@ -17,17 +17,19 @@
  */
 package org.apache.atlas.repository.converters;
 
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.type.AtlasTypeRegistry;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import java.util.HashMap;
 import java.util.Map;
 
 @Singleton
+@Component
 public class AtlasFormatConverters {
 
     private final Map<TypeCategory, AtlasFormatConverter> registry = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
index 6e0766d..3426ae5 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java
@@ -17,10 +17,7 @@
  */
 package org.apache.atlas.repository.converters;
 
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.apache.atlas.AtlasClient;
-import org.apache.atlas.AtlasClient.EntityResult;
+import org.apache.atlas.model.legacy.EntityResult;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.CreateUpdateEntitiesResult;
@@ -55,7 +52,10 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -64,19 +64,24 @@ import java.util.List;
 import java.util.Map;
 
 @Singleton
+@Component
 public class AtlasInstanceConverter {
 
     private static final Logger LOG = LoggerFactory.getLogger(AtlasInstanceConverter.class);
 
-    @Inject
     private AtlasTypeRegistry typeRegistry;
 
-    @Inject
     private AtlasFormatConverters instanceFormatters;
 
-    @Inject
     private MetadataService metadataService;
 
+    @Inject
+    public AtlasInstanceConverter(AtlasTypeRegistry typeRegistry, AtlasFormatConverters instanceFormatters, MetadataService metadataService) {
+        this.typeRegistry = typeRegistry;
+        this.instanceFormatters = instanceFormatters;
+        this.metadataService = metadataService;
+    }
+
     public ITypedReferenceableInstance[] getITypedReferenceables(Collection<AtlasEntity> entities) throws AtlasBaseException {
         ITypedReferenceableInstance[] entitiesInOldFormat = new ITypedReferenceableInstance[entities.size()];
 
@@ -166,7 +171,7 @@ public class AtlasInstanceConverter {
         return ctx.getEntities();
     }
 
-    public static EntityMutationResponse toEntityMutationResponse(AtlasClient.EntityResult entityResult) {
+    public static EntityMutationResponse toEntityMutationResponse(EntityResult entityResult) {
 
         CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
         result.setEntityResult(entityResult);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
index f8fa4d5..f946b9c 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasObjectIdConverter.java
@@ -36,8 +36,7 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.util.Map;
 
-public class
-AtlasObjectIdConverter extends  AtlasAbstractFormatConverter {
+public class AtlasObjectIdConverter extends  AtlasAbstractFormatConverter {
 
     public AtlasObjectIdConverter(AtlasFormatConverters registry, AtlasTypeRegistry typeRegistry) {
         this(registry, typeRegistry, TypeCategory.OBJECT_ID_TYPE);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/converters/AtlasPrimitiveFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasPrimitiveFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasPrimitiveFormatConverter.java
index d0e63eb..dc29689 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasPrimitiveFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasPrimitiveFormatConverter.java
@@ -23,8 +23,8 @@ import org.apache.atlas.model.TypeCategory;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
 
-
 public class AtlasPrimitiveFormatConverter extends AtlasAbstractFormatConverter {
+
     public AtlasPrimitiveFormatConverter(AtlasFormatConverters registry, AtlasTypeRegistry typeRegistry) {
         super(registry, typeRegistry, TypeCategory.PRIMITIVE);
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java b/repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java
index 0c5cac6..323af40 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java
@@ -18,17 +18,19 @@
 
 package org.apache.atlas.repository.graph;
 
+import com.google.common.annotations.VisibleForTesting;
 import org.apache.atlas.repository.RepositoryException;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.GraphDatabase;
 import org.apache.atlas.util.AtlasRepositoryConfiguration;
-
-import com.google.common.annotations.VisibleForTesting;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
 
 /**
  * Provides access to the AtlasGraph
  *
  */
+@Configuration
 public class AtlasGraphProvider implements IAtlasGraphProvider {
 
     private static volatile GraphDatabase<?,?> graphDb_;    
@@ -64,6 +66,7 @@ public class AtlasGraphProvider implements IAtlasGraphProvider {
     }
 
     @Override
+    @Bean
     public AtlasGraph get() throws RepositoryException {
         return getGraphInstance();
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java b/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
index a60ef9e..1ed12bc 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/FullTextMapperV2.java
@@ -17,8 +17,6 @@
  */
 package org.apache.atlas.repository.graph;
 
-import com.google.inject.Singleton;
-import org.apache.atlas.ApplicationProperties;
 import org.apache.atlas.RequestContext;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.instance.AtlasClassification;
@@ -34,6 +32,7 @@ import org.apache.commons.collections.MapUtils;
 import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.util.HashSet;
@@ -42,7 +41,7 @@ import java.util.Map;
 import java.util.Set;
 
 
-@Singleton
+@Component
 public class FullTextMapperV2 {
     private static final Logger LOG = LoggerFactory.getLogger(FullTextMapperV2.class);
 
@@ -53,20 +52,9 @@ public class FullTextMapperV2 {
     private final boolean              followReferences;
 
     @Inject
-    public FullTextMapperV2(AtlasTypeRegistry typeRegistry) {
+    public FullTextMapperV2(AtlasTypeRegistry typeRegistry, Configuration configuration) {
         entityGraphRetriever = new EntityGraphRetriever(typeRegistry);
-
-        Configuration configuration = null;
-
-        try {
-            configuration = ApplicationProperties.get();
-        } catch (Throwable e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("AtlasApplication properties couldn't be loaded", e);
-            }
-        } finally {
-            followReferences = configuration != null && configuration.getBoolean(FULL_TEXT_FOLLOW_REFERENCES, false);
-        }
+        followReferences = configuration != null && configuration.getBoolean(FULL_TEXT_FOLLOW_REFERENCES, false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
index d1e8cb7..5bec8fa 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
@@ -18,23 +18,13 @@
 
 package org.apache.atlas.repository.graph;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.atlas.AtlasClient;
+import com.google.common.base.Preconditions;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.CreateUpdateEntitiesResult;
-import org.apache.atlas.GraphTransaction;
 import org.apache.atlas.RequestContext;
+import org.apache.atlas.annotation.GraphTransaction;
 import org.apache.atlas.model.instance.GuidMapping;
+import org.apache.atlas.model.legacy.EntityResult;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.MetadataRepository;
 import org.apache.atlas.repository.RepositoryException;
@@ -55,16 +45,18 @@ import org.apache.atlas.typesystem.types.IDataType;
 import org.apache.atlas.typesystem.types.TypeSystem;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.*;
 
 /**
  * An implementation backed by a Graph database provided
  * as a Graph Service.
  */
 @Singleton
+@Component
 @Deprecated
 public class GraphBackedMetadataRepository implements MetadataRepository {
 
@@ -76,24 +68,16 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
 
     private DeleteHandler deleteHandler;
 
-    private final IAtlasGraphProvider graphProvider;
+    private final AtlasGraph atlasGraph;
     private final GraphToTypedInstanceMapper graphToInstanceMapper;
 
     @Inject
-    public GraphBackedMetadataRepository(DeleteHandler deleteHandler) {
-        this.graphProvider = new AtlasGraphProvider();
-        this.graphToInstanceMapper = new GraphToTypedInstanceMapper(graphProvider);
+    public GraphBackedMetadataRepository(DeleteHandler deleteHandler, AtlasGraph atlasGraph) {
+        this.atlasGraph = atlasGraph;
+        this.graphToInstanceMapper = new GraphToTypedInstanceMapper(atlasGraph);
         this.deleteHandler = deleteHandler;
     }
 
-    //for testing only
-    public GraphBackedMetadataRepository(IAtlasGraphProvider graphProvider, DeleteHandler deleteHandler) {
-        this.graphProvider = graphProvider;
-        this.graphToInstanceMapper = new GraphToTypedInstanceMapper(graphProvider);
-        this.deleteHandler = deleteHandler;
-    }
-
-
     public GraphToTypedInstanceMapper getGraphToInstanceMapper() {
         return graphToInstanceMapper;
     }
@@ -161,7 +145,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
             instanceToGraphMapper.mapTypedInstanceToGraph(TypedInstanceToGraphMapper.Operation.CREATE, entities);
             List<String> createdGuids = RequestContext.get().getCreatedEntityIds();
             CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
-            AtlasClient.EntityResult entityResult = new AtlasClient.EntityResult(createdGuids, null,  null);
+            EntityResult entityResult = new EntityResult(createdGuids, null,  null);
             GuidMapping mapping = instanceToGraphMapper.createGuidMapping();
             result.setEntityResult(entityResult);
             result.setGuidMapping(mapping);
@@ -174,6 +158,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
     }
 
     @Override
+    @GraphTransaction
     public ITypedReferenceableInstance getEntityDefinition(String guid) throws RepositoryException, EntityNotFoundException {
         return getEntityDefinitions(guid).get(0);
     }
@@ -469,7 +454,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
 
     @Override
     @GraphTransaction
-    public AtlasClient.EntityResult deleteEntities(List<String> guids) throws RepositoryException {
+    public EntityResult deleteEntities(List<String> guids) throws RepositoryException {
 
         if (guids == null || guids.size() == 0) {
             throw new IllegalArgumentException("guids must be non-null and non-empty");
@@ -491,7 +476,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
 
         if (deletionCandidates.isEmpty()) {
             LOG.info("No deletion candidate entities were found for guids %s", guids);
-            return new AtlasClient.EntityResult(Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList());
+            return new EntityResult(Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList());
         }
 
         try {
@@ -505,14 +490,14 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
         return createEntityResultFromContext(requestContext);
     }
 
-    private AtlasClient.EntityResult createEntityResultFromContext(RequestContext requestContext) {
-        return new AtlasClient.EntityResult(
+    private EntityResult createEntityResultFromContext(RequestContext requestContext) {
+        return new EntityResult(
                 requestContext.getCreatedEntityIds(),
                 requestContext.getUpdatedEntityIds(),
                 requestContext.getDeletedEntityIds());
     }
 
     public AtlasGraph getGraph() throws RepositoryException {
-        return graphProvider.get();
+        return atlasGraph;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
index 9b921f9..35dbf6c 100755
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
@@ -60,6 +60,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.math.BigDecimal;
@@ -76,6 +77,7 @@ import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.*;
 /**
  * Adds index for properties of a given type when its added before any instances are added.
  */
+@Component
 public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChangeHandler,
         TypeDefChangeListener {
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/GraphSchemaInitializer.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphSchemaInitializer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphSchemaInitializer.java
index 8b03b6a..e877680 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphSchemaInitializer.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphSchemaInitializer.java
@@ -22,6 +22,7 @@ import org.apache.atlas.setup.SetupException;
 import org.apache.atlas.setup.SetupStep;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 /**
  * A {@link SetupStep} that initializes the Graph backend for Atlas.
@@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory;
  * This class will initialize the specific backend implementation specified in
  * the Atlas configuration for the key atlas.graph.storage.backend.
  */
+@Component
 public class GraphSchemaInitializer implements SetupStep {
 
     private static final Logger LOG = LoggerFactory.getLogger(GraphSchemaInitializer.class);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
index 3a54e3e..bbacb14 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
@@ -17,20 +17,10 @@
  */
 package org.apache.atlas.repository.graph;
 
-import static org.apache.atlas.repository.graph.GraphHelper.string;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.RequestContext;
-import org.apache.atlas.repository.RepositoryException;
 import org.apache.atlas.repository.Constants;
+import org.apache.atlas.repository.RepositoryException;
 import org.apache.atlas.repository.graphdb.AtlasEdge;
 import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
@@ -50,10 +40,20 @@ import org.apache.atlas.typesystem.types.TraitType;
 import org.apache.atlas.typesystem.types.TypeSystem;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
-import com.google.inject.Singleton;
+import static org.apache.atlas.repository.graph.GraphHelper.string;
 
-@Singleton
+@Component
 @Deprecated
 public final class GraphToTypedInstanceMapper {
 
@@ -61,10 +61,11 @@ public final class GraphToTypedInstanceMapper {
     private static TypeSystem typeSystem = TypeSystem.getInstance();
     private static final GraphHelper graphHelper = GraphHelper.getInstance();
 
-    private final IAtlasGraphProvider graphProvider;
+    private final AtlasGraph atlasGraph;
 
-    public GraphToTypedInstanceMapper(IAtlasGraphProvider graphProvider) {
-        this.graphProvider = graphProvider;
+    @Inject
+    public GraphToTypedInstanceMapper(AtlasGraph atlasGraph) {
+        this.atlasGraph = atlasGraph;
     }
 
     public ITypedReferenceableInstance mapGraphToTypedInstance(String guid, AtlasVertex instanceVertex)
@@ -448,7 +449,7 @@ public final class GraphToTypedInstanceMapper {
     }
 
     private AtlasGraph getGraph() throws RepositoryException {
-        return graphProvider.get();
+        return atlasGraph;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/HardDeleteHandler.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/HardDeleteHandler.java b/repository/src/main/java/org/apache/atlas/repository/graph/HardDeleteHandler.java
index 78cf946..e00ef96 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/HardDeleteHandler.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/HardDeleteHandler.java
@@ -18,12 +18,17 @@
 
 package org.apache.atlas.repository.graph;
 
-import com.google.inject.Inject;
+import org.apache.atlas.AtlasException;
+import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
 import org.apache.atlas.repository.graphdb.AtlasEdge;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
-import org.apache.atlas.AtlasException;
 import org.apache.atlas.typesystem.types.TypeSystem;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
 
+@Component
+@ConditionalOnAtlasProperty(property = "atlas.DeleteHandler.impl")
 public class HardDeleteHandler extends DeleteHandler {
 
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/SoftDeleteHandler.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/SoftDeleteHandler.java b/repository/src/main/java/org/apache/atlas/repository/graph/SoftDeleteHandler.java
index dc21291..b37fe75 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/SoftDeleteHandler.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/SoftDeleteHandler.java
@@ -18,19 +18,25 @@
 
 package org.apache.atlas.repository.graph;
 
-import com.google.inject.Inject;
-import org.apache.atlas.repository.graphdb.AtlasEdge;
-import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.RequestContext;
+import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
+import org.apache.atlas.repository.graphdb.AtlasEdge;
+import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.typesystem.persistence.Id;
 import org.apache.atlas.typesystem.types.TypeSystem;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
 
 import static org.apache.atlas.repository.Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY;
 import static org.apache.atlas.repository.Constants.MODIFIED_BY_KEY;
 import static org.apache.atlas.repository.Constants.STATE_PROPERTY_KEY;
 
+@Component
+@ConditionalOnAtlasProperty(property = "atlas.DeleteHandler.impl", isDefault = true)
 public class SoftDeleteHandler extends DeleteHandler {
+
     @Inject
     public SoftDeleteHandler(TypeSystem typeSystem) {
         super(typeSystem, false, true);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
index c3e25bd..4dac293 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
@@ -17,19 +17,8 @@
  */
 package org.apache.atlas.repository.graph;
 
-import static org.apache.atlas.repository.graph.GraphHelper.string;
-
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.RequestContext;
 import org.apache.atlas.model.instance.GuidMapping;
@@ -46,27 +35,30 @@ import org.apache.atlas.typesystem.exception.EntityExistsException;
 import org.apache.atlas.typesystem.exception.EntityNotFoundException;
 import org.apache.atlas.typesystem.persistence.Id;
 import org.apache.atlas.typesystem.persistence.ReferenceableInstance;
-import org.apache.atlas.typesystem.types.AttributeInfo;
-import org.apache.atlas.typesystem.types.ClassType;
-import org.apache.atlas.typesystem.types.DataTypes;
+import org.apache.atlas.typesystem.types.*;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
-import org.apache.atlas.typesystem.types.EnumValue;
-import org.apache.atlas.typesystem.types.IDataType;
-import org.apache.atlas.typesystem.types.Multiplicity;
-import org.apache.atlas.typesystem.types.ObjectGraphWalker;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.TypeSystem;
-import org.apache.atlas.typesystem.types.TypeUtils;
 import org.apache.atlas.typesystem.types.utils.TypesUtil;
 import org.apache.atlas.util.AtlasRepositoryConfiguration;
 import org.apache.atlas.utils.MD5Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
+import javax.inject.Inject;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.atlas.repository.graph.GraphHelper.string;
 
+@Component
 @Deprecated
 public final class TypedInstanceToGraphMapper {
 
@@ -473,8 +465,8 @@ public final class TypedInstanceToGraphMapper {
                                              IDataType entryType, AttributeInfo attributeInfo) throws AtlasException {
         if (currentEntries != null && !currentEntries.isEmpty()) {
             LOG.debug("Removing unused entries from the old collection");
-            if (entryType.getTypeCategory() == DataTypes.TypeCategory.STRUCT
-                    || entryType.getTypeCategory() == DataTypes.TypeCategory.CLASS) {
+            if (entryType.getTypeCategory() == TypeCategory.STRUCT
+                    || entryType.getTypeCategory() == TypeCategory.CLASS) {
 
                 //Remove the edges for (current edges - new edges)
                 List<AtlasEdge> cloneElements = new ArrayList<>(currentEntries);
@@ -840,7 +832,7 @@ public final class TypedInstanceToGraphMapper {
             if (dateVal != null) {
                 propertyValue = dateVal.getTime();
             }
-        } else if (attributeInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.ENUM) {
+        } else if (attributeInfo.dataType().getTypeCategory() == TypeCategory.ENUM) {
             if (attrValue != null) {
                 propertyValue = ((EnumValue) attrValue).value;
             }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
index 2f298ba..7744c78 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
@@ -35,7 +35,6 @@ import org.apache.atlas.model.typedef.AtlasEnumDef;
 import org.apache.atlas.model.typedef.AtlasStructDef;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
 import org.apache.atlas.model.typedef.AtlasTypesDef;
-import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever;
 import org.apache.atlas.type.AtlasArrayType;
@@ -55,7 +54,9 @@ import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
 import javax.script.ScriptEngine;
 import javax.script.ScriptException;
 import java.util.ArrayList;
@@ -68,6 +69,7 @@ import java.util.Set;
 
 import static org.apache.atlas.model.impexp.AtlasExportRequest.*;
 
+@Component
 public class ExportService {
     private static final Logger LOG = LoggerFactory.getLogger(ExportService.class);
 
@@ -76,10 +78,11 @@ public class ExportService {
     private final EntityGraphRetriever      entityGraphRetriever;
     private final AtlasGremlinQueryProvider gremlinQueryProvider;
 
-    public ExportService(final AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
+    @Inject
+    public ExportService(final AtlasTypeRegistry typeRegistry, AtlasGraph atlasGraph) throws AtlasBaseException {
         this.typeRegistry         = typeRegistry;
         this.entityGraphRetriever = new EntityGraphRetriever(this.typeRegistry);
-        this.atlasGraph           = AtlasGraphProvider.getGraphInstance();
+        this.atlasGraph           = atlasGraph;
         this.gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java b/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
index 245c1d8..4530f51 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
@@ -33,12 +33,16 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.codehaus.jackson.annotate.JsonAutoDetect;
 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -57,10 +61,28 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
 /**
  * Class that handles initial loading of models and patches into typedef store
  */
+@Service
 public class AtlasTypeDefStoreInitializer {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefStoreInitializer.class);
 
-    public void initializeStore(AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry, String typesDirName) {
+    private final AtlasTypeDefStore atlasTypeDefStore;
+    private final AtlasTypeRegistry atlasTypeRegistry;
+
+    @Inject
+    public AtlasTypeDefStoreInitializer(AtlasTypeDefStore atlasTypeDefStore, AtlasTypeRegistry atlasTypeRegistry) {
+        this.atlasTypeDefStore = atlasTypeDefStore;
+        this.atlasTypeRegistry = atlasTypeRegistry;
+    }
+
+    @PostConstruct
+    public void init() {
+        String atlasHomeDir = System.getProperty("atlas.home");
+        String typesDirName = (StringUtils.isEmpty(atlasHomeDir) ? "." : atlasHomeDir) + File.separator + "models";
+
+        initializeStore(typesDirName);
+    }
+
+    private void initializeStore(String typesDirName) {
         File   typesDir     = new File(typesDirName);
         File[] typeDefFiles = typesDir.exists() ? typesDir.listFiles() : null;
 
@@ -88,11 +110,11 @@ public class AtlasTypeDefStoreInitializer {
                     continue;
                 }
 
-                AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, typeRegistry);
-                AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, typeRegistry);
+                AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, atlasTypeRegistry);
+                AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry);
 
                 if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) {
-                    typeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate);
+                    atlasTypeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate);
 
                     LOG.info("Created/Updated types defined in file {}", typeDefFile.getAbsolutePath());
                 } else {
@@ -104,7 +126,7 @@ public class AtlasTypeDefStoreInitializer {
             }
         }
 
-        applyTypePatches(typeDefStore, typeRegistry, typesDirName);
+        applyTypePatches(typesDirName);
     }
 
     public static AtlasTypesDef getTypesToCreate(AtlasTypesDef typesDef, AtlasTypeRegistry typeRegistry) {
@@ -239,7 +261,7 @@ public class AtlasTypeDefStoreInitializer {
         return ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
     }
 
-    private void applyTypePatches(AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry, String typesDirName) {
+    private void applyTypePatches(String typesDirName) {
         String typePatchesDirName = typesDirName + File.separator + "patches";
         File   typePatchesDir     = new File(typePatchesDirName);
         File[] typePatchFiles     = typePatchesDir.exists() ? typePatchesDir.listFiles() : null;
@@ -254,9 +276,9 @@ public class AtlasTypeDefStoreInitializer {
         Arrays.sort(typePatchFiles);
 
         PatchHandler[] patchHandlers = new PatchHandler[] {
-                new AddAttributePatchHandler(typeDefStore, typeRegistry),
-                new UpdateTypeDefOptionsPatchHandler(typeDefStore, typeRegistry),
-                new UpdateAttributePatchHandler(typeDefStore, typeRegistry)
+                new AddAttributePatchHandler(atlasTypeDefStore, atlasTypeRegistry),
+                new UpdateTypeDefOptionsPatchHandler(atlasTypeDefStore, atlasTypeRegistry),
+                new UpdateAttributePatchHandler(atlasTypeDefStore, atlasTypeRegistry)
         };
 
         Map<String, PatchHandler> patchHandlerRegistry = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
index e873e91..a4163f2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
@@ -17,12 +17,9 @@
  */
 package org.apache.atlas.repository.store.graph;
 
-
-import org.apache.atlas.GraphTransaction;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.impexp.AtlasImportResult;
 import org.apache.atlas.model.instance.AtlasClassification;
-import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.EntityMutationResponse;
@@ -132,7 +129,6 @@ public interface AtlasEntityStore {
      */
     void updateClassifications(String guid, List<AtlasClassification> classifications) throws AtlasBaseException;
 
-    @GraphTransaction
     void addClassification(List<String> guids, AtlasClassification classification) throws AtlasBaseException;
 
     /**
@@ -140,9 +136,7 @@ public interface AtlasEntityStore {
      */
     void deleteClassifications(String guid, List<String> classificationNames) throws AtlasBaseException;
 
-    @GraphTransaction
     List<AtlasClassification> getClassifications(String guid) throws AtlasBaseException;
 
-    @GraphTransaction
     AtlasClassification getClassification(String guid, String classificationName) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 4a8e1de..17b7e17 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -19,8 +19,8 @@ package org.apache.atlas.repository.store.graph;
 
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
-import org.apache.atlas.GraphTransaction;
 import org.apache.atlas.GraphTransactionInterceptor;
+import org.apache.atlas.annotation.GraphTransaction;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.listener.ActiveStateChangeHandler;
 import org.apache.atlas.listener.ChangedTypeDefs;
@@ -34,7 +34,6 @@ import org.apache.atlas.model.typedef.AtlasStructDef;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
 import org.apache.atlas.model.typedef.AtlasTypesDef;
-import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
 import org.apache.atlas.repository.util.FilterUtil;
 import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.type.AtlasClassificationType;
@@ -52,7 +51,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -108,8 +106,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
         } finally {
             typeRegistry.releaseTypeRegistryForUpdate(ttr, commitUpdates);
         }
-
-        bootstrapTypes();
     }
 
     @Override
@@ -571,15 +567,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
         LOG.info("Not reacting to a Passive state change");
     }
 
-    private void bootstrapTypes() {
-        AtlasTypeDefStoreInitializer storeInitializer = new AtlasTypeDefStoreInitializer();
-
-        String atlasHomeDir = System.getProperty("atlas.home");
-        String typesDirName = (StringUtils.isEmpty(atlasHomeDir) ? "." : atlasHomeDir) + File.separator + "models";
-
-        storeInitializer.initializeStore(this, typeRegistry, typesDirName);
-    }
-
     private AtlasBaseTypeDef getTypeDefFromType(AtlasType type) throws AtlasBaseException {
         AtlasBaseTypeDef ret;
         switch (type.getTypeCategory()) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
index d9bc924..6423aea 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java
@@ -18,8 +18,6 @@
 package org.apache.atlas.repository.store.graph.v1;
 
 
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.exception.AtlasBaseException;
@@ -30,7 +28,8 @@ import org.apache.atlas.model.instance.EntityMutationResponse;
 import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.converters.AtlasInstanceConverter;
-import org.apache.atlas.repository.graph.*;
+import org.apache.atlas.repository.graph.FullTextMapperV2;
+import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.typesystem.ITypedReferenceableInstance;
 import org.apache.atlas.typesystem.ITypedStruct;
@@ -39,14 +38,16 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
+import javax.inject.Inject;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
 
-@Singleton
+@Component
 public class AtlasEntityChangeNotifier {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityChangeNotifier.class);
 
@@ -101,7 +102,7 @@ public class AtlasEntityChangeNotifier {
             try {
                 listener.onTraitsAdded(entity, traits);
             } catch (AtlasException e) {
-                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e);
+                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitAdd");
             }
         }
     }
@@ -120,7 +121,7 @@ public class AtlasEntityChangeNotifier {
             try {
                 listener.onTraitsDeleted(entity, traitNames);
             } catch (AtlasException e) {
-                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e);
+                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitDelete");
             }
         }
     }
@@ -140,11 +141,15 @@ public class AtlasEntityChangeNotifier {
             try {
                 listener.onTraitsUpdated(entity, traits);
             } catch (AtlasException e) {
-                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e);
+                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitUpdate");
             }
         }
     }
 
+    private String getListenerName(EntityChangeListener listener) {
+        return listener.getClass().getSimpleName();
+    }
+
     private void notifyListeners(List<AtlasEntityHeader> entityHeaders, EntityOperation operation, boolean isImport) throws AtlasBaseException {
         if (CollectionUtils.isEmpty(entityHeaders)) {
             return;
@@ -167,7 +172,7 @@ public class AtlasEntityChangeNotifier {
                         break;
                 }
             } catch (AtlasException e) {
-                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, operation.toString());
+                throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), operation.toString());
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/35e5828f/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
index 1bfe3b9..8046234 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
@@ -17,7 +17,6 @@
  */
 package org.apache.atlas.repository.store.graph.v1;
 
-import com.google.inject.Inject;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
@@ -32,6 +31,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.inject.Inject;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;


Mime
View raw message