Skip to content

Commit

Permalink
New configuration param because of: spring-projects/spring-data-neo4j…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Hardt committed Mar 20, 2014
1 parent 90049c9 commit 6234929
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/main/java/neo4jplugin/EmbbededNeo4jConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
public class EmbbededNeo4jConfig extends Neo4JBaseConfiguration
{

private static String embeddedDBPath = "neo4j.embeddedDB";
/**
* Config key which defines where the embedded database path is.
*/
private static String EMBEDDED_DB_CFG_KEY = "neo4j.embeddedDB";


@Bean
public GraphDatabaseService graphDatabaseService() {
String embeddedDB = ConfigFactory.load().getString(embeddedDBPath);
String embeddedDB = ConfigFactory.load().getString(EMBEDDED_DB_CFG_KEY);
if (StringUtils.isEmpty(embeddedDB) == true) {
throw new RuntimeException("Could not find config for embedded DB: " + embeddedDBPath);
throw new RuntimeException("Could not find config for embedded DB: " + EMBEDDED_DB_CFG_KEY);
}
GraphDatabaseFactory graphDatabaseFactory = new GraphDatabaseFactory();

Expand Down
23 changes: 21 additions & 2 deletions src/main/java/neo4jplugin/Neo4JBaseConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
package neo4jplugin;


import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.data.auditing.IsNewAwareAuditingHandler;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.lifecycle.AuditingEventListener;
import play.Logger;

public class Neo4JBaseConfiguration extends Neo4jConfiguration {

public Neo4JBaseConfiguration() {
/**
* Config key which defines where the base packages are located.
*/
private static String BASE_PACKAGES_CFG = "neo4j.basepackage";


public Neo4JBaseConfiguration() {
super();
setBasePackage("neo4j");

// check if baspackes is defined in the configuration if not fall back to neo4j
String basePackages;
try {
basePackages = ConfigFactory.load().getString(BASE_PACKAGES_CFG);
} catch(ConfigException cfge) {
Logger.warn("Could not find configuration: "+BASE_PACKAGES_CFG+" falling back to: neo4j as basepackage.");
basePackages = "neo4j";
}

setBasePackage(basePackages);
}

@Bean
Expand Down

0 comments on commit 6234929

Please sign in to comment.