private static File getGenerateDir() { File generatedDir = null; String confDir = PROP.get(CLASS_REPOSITORY_STORAGE_DIR_PROP); if (confDir == null || "".equals(confDir)) { generatedDir = new File(System.getProperty("java.io.tmpdir")); } else { generatedDir = new File(confDir); } return generatedDir; }
private Database(String dbProvider, List<String> installDdl, List<String> uninstallDdl) { this.dbProvider = dbProvider; this.installDdl = installDdl; this.uninstallDdl = uninstallDdl; this.username = System.getProperty("user.name"); this.password = System.getProperty("user.name"); this.host = PROPS.get(DB_HOST_TOOLS4J_CONFIG_PROPERTY); this.tablespace = System.getProperty("user.name"); if (DERBY.equals(dbProvider)) { driver = DERBY_DRIVER; forName(driver); url = "jdbc:derby:memory:" + tablespace + ";create=true"; } else if (MYSQL.equals(dbProvider)) { driver = MYSQL_DRIVER; url = "jdbc:mysql://" + host + ":3306/" + tablespace; } else if (POSTGRESQL.equals(dbProvider)) { driver = POSTGRESQL_DRIVER; url = "jdbc:postgresql://" + host + ":5432/" + tablespace; } else { throw new UnsupportedOperationException("DB provider not supported [" + dbProvider + "]"); } }
private List<Bean> readValues() { String dirValue = PROP.get(XML_BEAN_FILE_STORAGE_DIR_PROP); if (dirValue == null || "".equals(dirValue)) { dirValue = System.getProperty("java.io.tmpdir"); } File file = new File(new File(dirValue), XML_BEAN_FILE_NAME); try { if (!file.exists()) { Files.write("<bean-xml></bean-xml>", file, Charset.defaultCharset()); } FileInputStream in = new FileInputStream(file); JAXBContext context = JAXBContext.newInstance(XmlBeans.class); Unmarshaller unmarshaller = context.createUnmarshaller(); XmlBeans beans = (XmlBeans) unmarshaller.unmarshal(in); return beans.getBeans(); } catch (JAXBException e) { throw new RuntimeException(e); } catch (FileNotFoundException e) { throw CFG202_XML_SCHEMA_FILE_MISSING(file); } catch (IOException e) { throw new RuntimeException(e); } }
public static final EntityManagerFactory createFactory(String persistenceUnitName) { Properties p = new Properties(); String filePath = SystemProperties.createDefault().get(JPA_PROPERTIES_FILE); if (filePath == null || "".equals(filePath)) { throw JPA201_PROP_FILEPATH_MISSING(JPA_PROPERTIES_FILE); } FileInputStream in = null; try { in = new FileInputStream(new File(filePath)); p.load(in); } catch (IOException e) { throw new RuntimeException(e); } finally { FileUtils.close(in); } return Persistence.createEntityManagerFactory(persistenceUnitName, p); }
private void writeValues(Map<String, Schema> values) { String dirValue = PROP.get(XML_CONFIG_SCHEMA_FILE_STORAGE_DIR_PROP); if (dirValue == null || "".equals(dirValue)) { dirValue = System.getProperty("java.io.tmpdir");
private Map<String, Schema> readValues() { String dirValue = PROP.get(XML_CONFIG_SCHEMA_FILE_STORAGE_DIR_PROP); if (dirValue == null || "".equals(dirValue)) { dirValue = System.getProperty("java.io.tmpdir"); } File file = new File(new File(dirValue), XML_SCHEMA_FILE_NAME); try { if (!file.exists()) { Files.write("<schema-xml></schema-xml>", file, Charset.defaultCharset()); } FileInputStream in = new FileInputStream(file); JAXBContext context = JAXBContext.newInstance(XmlSchemas.class); Unmarshaller unmarshaller = context.createUnmarshaller(); XmlSchemas schemas = (XmlSchemas) unmarshaller.unmarshal(in); return schemas.getSchemas(); } catch (JAXBException e) { throw new RuntimeException(e); } catch (FileNotFoundException e) { throw CFG202_XML_SCHEMA_FILE_MISSING(file); } catch (IOException e) { throw new RuntimeException(e); } }
private void writeValues(List<Bean> beans) { String dirValue = PROP.get(XML_BEAN_FILE_STORAGE_DIR_PROP); if (dirValue == null || "".equals(dirValue)) { dirValue = System.getProperty("java.io.tmpdir");
public static BeanManager lookupBeanManager() { Collection<BeanManager> beanManagers = Lookup.get().lookupAll(BeanManager.class); if (beanManagers.size() == 1) { return beanManagers.iterator().next(); } /** * If multiple BeanManager are found, allow users to configure usage. */ String preferedBeanManager = SystemProperties.createDefault().get("config.beanmanager"); if (preferedBeanManager == null || "".equals(preferedBeanManager)) { return new XmlBeanManager(); } for (BeanManager beanManager : beanManagers) { if (beanManager.getClass().getName().equals(preferedBeanManager)) { return beanManager; } } /** * return the XmlBeanManager as default, zero-configuration required by users */ return new XmlBeanManager(); }
public static SchemaManager lookupSchemaManager() { Collection<SchemaManager> schemaManagers = Lookup.get().lookupAll(SchemaManager.class); if (schemaManagers.size() == 1) { return schemaManagers.iterator().next(); } /** * If multiple BeanManager are found, allow users to configure usage. */ String preferedSchemaManager = SystemProperties.createDefault().get("config.schemamanager"); if (preferedSchemaManager == null || "".equals(preferedSchemaManager)) { return new XmlSchemaManager(); } for (SchemaManager schemaManager : schemaManagers) { if (schemaManager.getClass().getName().equals(preferedSchemaManager)) { return schemaManager; } } /** * return the XmlSchemaManager as default, zero-configuration required by users */ return new XmlSchemaManager(); }