org.nuxeo.common.Environment.getDefault()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.nuxeo.common.Environment.getDefault()方法的一些代码示例,展示了Environment.getDefault()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getDefault()方法的具体详情如下:
包路径:org.nuxeo.common.Environment
类名称:Environment
方法名:getDefault

Environment.getDefault介绍

暂无

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

  1. } else {
  2. File home = Environment.getDefault().getData();
  3. base = new File(home, path);

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test

  1. public File resolveAndCreate(File aFile) {
  2. File temp = Environment.getDefault().getTemp();
  3. File actual = temp.toPath().resolve(aFile.toPath()).toFile();
  4. try {
  5. actual.createNewFile();
  6. } catch (IOException e) {
  7. throw new RuntimeException("Cannot create temp file " + actual);
  8. }
  9. created.add(actual);
  10. return actual;
  11. }
  12. }

代码示例来源:origin: org.nuxeo.ecm.webengine/nuxeo-webengine-gwt

  1. private static File locateRoot() {
  2. File dir = new File(Environment.getDefault().getWeb(), "root.war/gwt");
  3. dir.mkdirs();
  4. return dir;
  5. }

代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core

  1. protected boolean isTargetDirectoryForbidden() {
  2. File nuxeoHome = Environment.getDefault().getServerHome().getAbsoluteFile();
  3. return Paths.get(directory)
  4. .toAbsolutePath()
  5. .normalize()
  6. .startsWith(nuxeoHome.toPath().toAbsolutePath().normalize());
  7. }

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-content-template-manager

  1. @Override
  2. public File getFile(String path) {
  3. File nxDdataFolder = Environment.getDefault().getData();
  4. return new File(nxDdataFolder, path);
  5. }
  6. },

代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core

  1. /**
  2. * @since 8.4
  3. */
  4. public String getHomePath() {
  5. if (homePath == null) {
  6. // Since ES 2.X we need to set a home path for embedded node, but it is not used by the bundle
  7. File dir = new File(Environment.getDefault().getTemp(), "elasticsearch");
  8. homePath = dir.getPath();
  9. }
  10. return homePath;
  11. }

代码示例来源:origin: org.nuxeo.template.rendering/nuxeo-template-rendering-core

  1. protected File getWorkingDir() {
  2. File workingDir = new File(Environment.getDefault().getTemp(), "NXTemplateProcessor"
  3. + System.currentTimeMillis());
  4. if (workingDir.exists()) {
  5. FileUtils.deleteQuietly(workingDir);
  6. }
  7. workingDir.mkdirs();
  8. Framework.trackFile(workingDir, workingDir);
  9. return workingDir;
  10. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-convert

  1. protected String getDefaultCachingDirectory() {
  2. File cache = new File(Environment.getDefault().getData(), DEFAULT_CACHING_DIRECTORY);
  3. return cache.getAbsolutePath();
  4. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-reload

  1. protected static File getAppDir() {
  2. return Environment.getDefault().getConfig().getParentFile();
  3. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-connect-standalone

  1. public PackagePersistence(PackageUpdateService pus) throws IOException {
  2. Environment env = Environment.getDefault();
  3. root = env.getPath(Environment.NUXEO_MP_DIR, Environment.DEFAULT_MP_DIR);
  4. if (!root.isAbsolute()) {
  5. throw new RuntimeException();
  6. }
  7. root.mkdirs();
  8. store = new File(root, "store");
  9. store.mkdirs();
  10. temp = new File(root, "tmp");
  11. temp.mkdirs();
  12. service = pus;
  13. states = loadStates();
  14. }

代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core

  1. protected InputStream getResourceStream(String filename) {
  2. // First check if the resource is available on the config directory
  3. File file = new File(Environment.getDefault().getConfig(), filename);
  4. if (file.exists()) {
  5. try {
  6. return new FileInputStream(file);
  7. } catch (FileNotFoundException e) {
  8. // try another way
  9. }
  10. }
  11. // getResourceAsStream is needed getResource will not work when called from another module
  12. InputStream ret = this.getClass().getClassLoader().getResourceAsStream(filename);
  13. if (ret == null) {
  14. // Then try to get it from jar
  15. ret = this.getClass().getClassLoader().getResourceAsStream(filename);
  16. }
  17. if (ret == null) {
  18. throw new IllegalArgumentException(
  19. String.format("Resource file cannot be found: %s or %s", file.getAbsolutePath(), filename));
  20. }
  21. return ret;
  22. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test

  1. @Override
  2. public void beforeMethodRun(FeaturesRunner runner, FrameworkMethod method, Object test) throws Exception {
  3. File temp = Environment.getDefault().getTemp();
  4. tempPath = temp.toPath();
  5. tracked.clear();
  6. created.clear();
  7. listener.install();
  8. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-cache

  1. private File getDataDir(TransientStoreConfig config) {
  2. String dataDirPath = config.getDataDir();
  3. if (StringUtils.isBlank(dataDirPath)) {
  4. File transienStoreHome = new File(Environment.getDefault().getData(), "transientstores");
  5. return new File(transienStoreHome, config.getName());
  6. } else {
  7. return new File(dataDirPath);
  8. }
  9. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-schema

  1. public SchemaManagerImpl() {
  2. recomputeCallbacks = new ArrayList<>();
  3. schemaDir = new File(Environment.getDefault().getTemp(), SCHEMAS_DIR_NAME);
  4. schemaDir.mkdirs();
  5. clearSchemaDir();
  6. registerBuiltinTypes();
  7. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-osgi

  1. /**
  2. * @since 5.5
  3. * @return Environment summary
  4. */
  5. protected static StringBuilder getStartMessage() {
  6. String newline = System.getProperty("line.separator");
  7. Environment env = Environment.getDefault();
  8. String hr = "======================================================================";
  9. StringBuilder msg = new StringBuilder(newline);
  10. msg.append(hr).append(newline);
  11. msg.append("= Starting Nuxeo Framework").append(newline);
  12. msg.append(hr).append(newline);
  13. msg.append(" * Server home = ").append(env.getServerHome()).append(newline);
  14. msg.append(" * Runtime home = ").append(env.getRuntimeHome()).append(newline);
  15. msg.append(" * Data Directory = ").append(env.getData()).append(newline);
  16. msg.append(" * Log Directory = ").append(env.getLog()).append(newline);
  17. msg.append(" * Configuration Directory = ").append(env.getConfig()).append(newline);
  18. msg.append(" * Temp Directory = ").append(env.getTemp()).append(newline);
  19. msg.append(hr);
  20. return msg;
  21. }
  22. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-test

  1. @Override
  2. public void beforeSetup(FeaturesRunner runner) throws Exception {
  3. server = SimpleSmtpServer.start(SERVER_PORT);
  4. if (Framework.isInitialized()) {
  5. File file = new File(Environment.getDefault().getConfig(), "mail.properties");
  6. List<String> mailProperties = new ArrayList<>();
  7. mailProperties.add(String.format("mail.smtp.host = %s", SERVER_HOST));
  8. mailProperties.add(String.format("mail.smtp.port = %s", SERVER_PORT));
  9. FileUtils.writeLines(file, mailProperties);
  10. Framework.getProperties().put("mail.transport.host", SERVER_HOST);
  11. Framework.getProperties().put("mail.transport.port", String.valueOf(SERVER_PORT));
  12. }
  13. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-reload

  1. @Override
  2. public void runDeploymentPreprocessor() throws IOException {
  3. log.info("Start running deployment preprocessor");
  4. String rootPath = Environment.getDefault().getRuntimeHome().getAbsolutePath();
  5. File root = new File(rootPath);
  6. DeploymentPreprocessor processor = new DeploymentPreprocessor(root);
  7. // initialize
  8. processor.init();
  9. // and predeploy
  10. processor.predeploy();
  11. log.info("Deployment preprocessing done");
  12. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test

  1. @Override
  2. public void start(BundleContext context) {
  3. log.info("Starting Runtime Activator");
  4. // create the runtime
  5. runtime = new OSGiRuntimeService(context);
  6. String tempDir = Environment.getDefault().getTemp().getAbsolutePath();
  7. System.setProperty("java.io.tmpdir", tempDir);
  8. System.setProperty(Environment.NUXEO_TMP_DIR, tempDir);
  9. // load main config file if any
  10. URL config = context.getBundle().getResource("/OSGI-INF/nuxeo.properties");
  11. if (config != null) {
  12. System.setProperty(OSGiRuntimeService.PROP_CONFIG_DIR, config.toExternalForm());
  13. }
  14. initialize(runtime);
  15. // start it
  16. Framework.initialize(runtime);
  17. // register bundle component loader
  18. componentLoader = new OSGiComponentLoader(runtime);
  19. // TODO register osgi services
  20. }

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-web-common

  1. /**
  2. * @deprecated since 9.1. It was defined for ClipboardActionsBean but it seems not to be used anymore.
  3. */
  4. @Deprecated
  5. protected void handleDownloadTemporaryZip(HttpServletRequest req, HttpServletResponse resp, String filePath)
  6. throws IOException {
  7. String[] pathParts = filePath.split("/");
  8. String tmpFileName = pathParts[0];
  9. File tmpZip = new File(Environment.getDefault().getTemp(), tmpFileName);
  10. try {
  11. Blob zipBlob = Blobs.createBlob(tmpZip);
  12. DownloadService downloadService = Framework.getService(DownloadService.class);
  13. downloadService.downloadBlob(req, resp, null, null, zipBlob, "clipboard.zip", "clipboardZip");
  14. } finally {
  15. tmpZip.delete();
  16. }
  17. }

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-server

  1. @Override
  2. public void addWepApp(WebApplication descriptor) {
  3. String contextPath = normalizeContextPath(descriptor.getContextPath());
  4. File home = Environment.getDefault().getHome();
  5. File docBase = new File(home, descriptor.getWebRoot());
  6. docBase.mkdirs(); // make sure the WAR root exists
  7. Context context = tomcat.addWebapp(contextPath, docBase.getAbsolutePath());
  8. StandardJarScanner jarScanner = (StandardJarScanner) context.getJarScanner();
  9. // avoid costly scanning, we register everything explicitly
  10. jarScanner.setScanManifest(false); // many MANIFEST.MF files have incorrect Class-Path
  11. jarScanner.setScanAllDirectories(false);
  12. jarScanner.setScanAllFiles(false);
  13. jarScanner.setScanBootstrapClassPath(false);
  14. jarScanner.setScanClassPath(false);
  15. }

相关文章