/** * Initializes a standalone context. */ public static void initContext(String[] configurationResourcePaths, ApplicationContext parent) { // check for overflow initialization for (int i = 5; i < Thread.currentThread().getStackTrace().length; i++) { StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[i]; if (stackTraceElement.getClassName().equals(IntactUpdateContext.class.getName()) && stackTraceElement.getMethodName().equals("initContext")) { throw new IntactInitializationError("Infinite recursive invocation to IntactUpdateContext.initContext(). This" + " may be due to an illegal invocation of IntactUpdateContext.getCurrentInstance() during bean instantiation."); } } // the order of the resources matters when overriding beans, so we add the intact first, // so the user can override the default beans. List<String> resourcesList = new LinkedList<String>(); resourcesList.add("classpath*:/META-INF/update-jpa.spring.xml"); resourcesList.addAll(Arrays.asList(configurationResourcePaths)); configurationResourcePaths = resourcesList.toArray(new String[resourcesList.size()]); if (log.isDebugEnabled()) { log.debug("Loading Spring XML config:"); for (String configurationResourcePath : configurationResourcePaths) { log.debug(" - " + configurationResourcePath); } } // init Spring ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext(configurationResourcePaths, parent); springContext.registerShutdownHook(); instance = (IntactUpdateContext) springContext.getBean("intactUpdateContext"); }
/** * Initializes a standalone context. */ public static void initContext(String[] configurationResourcePaths, ApplicationContext parent) { // check for overflow initialization for (int i = 5; i < Thread.currentThread().getStackTrace().length; i++) { StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[i]; if (stackTraceElement.getClassName().equals(IntactContext.class.getName()) && stackTraceElement.getMethodName().equals("initContext")) { throw new IntactInitializationError("Infinite recursive invocation to IntactContext.initContext(). This" + " may be due to an illegal invocation of IntactContext.getCurrentInstance() during bean instantiation."); } } // the order of the resources matters when overriding beans, so we add the intact first, // so the user can override the default beans. List<String> resourcesList = new LinkedList<String>(); resourcesList.add("classpath*:/META-INF/intact.spring.xml"); resourcesList.addAll(Arrays.asList(configurationResourcePaths)); configurationResourcePaths = resourcesList.toArray(new String[resourcesList.size()]); if (log.isDebugEnabled()) { log.debug("Loading Spring XML config:"); for (String configurationResourcePath : configurationResourcePaths) { log.debug(" - " + configurationResourcePath); } } // init Spring ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext(configurationResourcePaths, parent); springContext.registerShutdownHook(); instance = (IntactContext) springContext.getBean("intactContext"); }
/** * Initializes a standalone context. */ public static void initContext(String[] configurationResourcePaths, ApplicationContext parent) { // check for overflow initialization for (int i = 5; i < Thread.currentThread().getStackTrace().length; i++) { StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[i]; if (stackTraceElement.getClassName().equals(IntactContext.class.getName()) && stackTraceElement.getMethodName().equals("initContext")) { throw new IntactInitializationError("Infinite recursive invocation to IntactContext.initContext(). This" + " may be due to an illegal invocation of IntactContext.getCurrentInstance() during bean instantiation."); } } // the order of the resources matters when overriding beans, so we add the intact first, // so the user can override the default beans. List<String> resourcesList = new LinkedList<String>(); resourcesList.add("classpath*:/META-INF/intact.spring.xml"); resourcesList.addAll(Arrays.asList(configurationResourcePaths)); configurationResourcePaths = resourcesList.toArray(new String[resourcesList.size()]); if (log.isDebugEnabled()) { log.debug("Loading Spring XML config:"); for (String configurationResourcePath : configurationResourcePaths) { log.debug(" - " + configurationResourcePath); } } // init Spring ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext(configurationResourcePaths, parent); springContext.registerShutdownHook(); instance = (IntactContext) springContext.getBean("intactContext"); }
@Transactional(propagation = Propagation.REQUIRES_NEW) public void checkSchemaCompatibility() { if( ! configuration.isSkipSchemaCheck() ) { DbInfo dbInfoSchemaVersion = dbInfoDao.get(DbInfo.SCHEMA_VERSION); SchemaVersion schemaVersion; if (dbInfoSchemaVersion == null ) { if( ! autoPersist ) { throw new IntactInitializationError( "Could not find key "+ DbInfo.SCHEMA_VERSION +" in table IA_DB_INFO, please set IntactInitializer.autoPersist to true so it can be initialized at startup." ); } if ( log.isInfoEnabled() ) log.info( "Schema version does not exist. Will be created: " + requiredSchemaVersion); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredSchemaVersion.toString()); dbInfoDao.persist(dbInfo); } else { try { schemaVersion = SchemaVersion.parse(dbInfoSchemaVersion.getValue()); } catch ( Exception e) { throw new IntactInitializationError("Error parsing schema version", e); } if (!schemaVersion.isCompatibleWith(requiredSchemaVersion)) { throw new IntactInitializationError("Database schema version " + requiredSchemaVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion); } } } }
@Transactional(propagation = Propagation.REQUIRES_NEW) public void checkSchemaCompatibility() { if( ! configuration.isSkipSchemaCheck() ) { DbInfo dbInfoSchemaVersion = dbInfoDao.get(DbInfo.SCHEMA_VERSION); SchemaVersion schemaVersion; if (dbInfoSchemaVersion == null ) { if( ! autoPersist ) { throw new IntactInitializationError( "Could not find key "+ DbInfo.SCHEMA_VERSION +" in table IA_DB_INFO, please set IntactInitializer.autoPersist to true so it can be initialized at startup." ); } if ( log.isInfoEnabled() ) log.info( "Schema version does not exist. Will be created: " + requiredSchemaVersion); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredSchemaVersion.toString()); dbInfoDao.persist(dbInfo); } else { try { schemaVersion = SchemaVersion.parse(dbInfoSchemaVersion.getValue()); } catch ( Exception e) { throw new IntactInitializationError("Error parsing schema version", e); } if (!schemaVersion.isCompatibleWith(requiredSchemaVersion)) { throw new IntactInitializationError("Database schema version " + requiredSchemaVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion); } } } }