List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.gcaldaemon.core.Configurator.java
public Configurator(String configPath, Properties properties, boolean userHome, byte mode) throws Exception { this.mode = mode; int i;//from w ww . j a v a 2 s . c o m File programRootDir = null; if (mode == MODE_EMBEDDED) { // Embedded mode standaloneMode = false; config = properties; String workPath = getConfigProperty(WORK_DIR, null); workDirectory = new File(workPath); } else { // Load config if (configPath != null) { configFile = new File(configPath); } InputStream in = null; boolean configInClassPath = false; if (configFile == null || !configFile.isFile()) { try { in = Configurator.class.getResourceAsStream("/gcal-daemon.cfg"); configInClassPath = in != null; } catch (Exception ignored) { in = null; } if (in == null) { System.out.println("INFO | Searching main configuration file..."); String path = (new File("x")).getAbsolutePath().replace('\\', '/'); i = path.lastIndexOf('/'); if (i > 1) { i = path.lastIndexOf('/', i - 1); if (i > 1) { configFile = new File(path.substring(0, i), "conf/gcal-daemon.cfg"); } } if (configFile == null || !configFile.isFile()) { configFile = new File("/usr/local/sbin/GCALDaemon/conf/gcal-daemon.cfg"); } if (configFile == null || !configFile.isFile()) { configFile = new File("/GCALDaemon/conf/gcal-daemon.cfg"); } if (configFile == null || !configFile.isFile()) { File root = new File("/"); String[] dirs = root.list(); if (dirs != null) { for (i = 0; i < dirs.length; i++) { configFile = new File('/' + dirs[i] + "/GCALDaemon/conf/gcal-daemon.cfg"); if (configFile.isFile()) { break; } } } } if (configFile == null || !configFile.isFile()) { throw new FileNotFoundException("Missing main configuration file: " + configPath); } if (!userHome) { // Open global config file in = new FileInputStream(configFile); } } } else { if (!userHome) { // Open global config file in = new FileInputStream(configFile); } } standaloneMode = !configInClassPath; if (in != null) { // Load global config file config.load(new BufferedInputStream(in)); in.close(); } // Loading config from classpath if (configFile == null) { try { URL url = Configurator.class.getResource("/gcal-daemon.cfg"); configFile = new File(url.getFile()); } catch (Exception ignored) { } } programRootDir = configFile.getParentFile().getParentFile(); System.setProperty("gcaldaemon.program.dir", programRootDir.getAbsolutePath()); String workPath = getConfigProperty(WORK_DIR, null); File directory; if (workPath == null) { directory = new File(programRootDir, "work"); } else { directory = new File(workPath); } if (!directory.isDirectory()) { if (!directory.mkdirs()) { directory = new File("work"); directory.mkdirs(); } } workDirectory = directory; // User-specific config file handler if (userHome) { boolean useGlobal = true; try { String home = System.getProperty("user.home", null); if (home != null) { File userConfig = new File(home, ".gcaldaemon/gcal-daemon.cfg"); if (!userConfig.isFile()) { // Create new user-specific config File userDir = new File(home, ".gcaldaemon"); userDir.mkdirs(); copyFile(configFile, userConfig); if (!userConfig.isFile()) { userConfig.delete(); userDir.delete(); } } if (userConfig.isFile()) { // Load user-specific config configFile = userConfig; in = new FileInputStream(configFile); config.load(new BufferedInputStream(in)); in.close(); useGlobal = false; } } } catch (Exception ignored) { } if (useGlobal) { // Load global config file config.load(new BufferedInputStream(in)); in.close(); } } } // Init logger ProgressMonitor monitor = null; if (standaloneMode && mode != MODE_CONFIGEDITOR) { // Compute log config path String logConfig = getConfigProperty(LOG_CONFIG, "logger-config.cfg"); logConfig = logConfig.replace('\\', '/'); File logConfigFile; if (logConfig.indexOf('/') == -1) { logConfigFile = new File(programRootDir, "conf/" + logConfig); } else { logConfigFile = new File(logConfig); } if (logConfigFile.isFile()) { String logConfigPath = logConfigFile.getAbsolutePath(); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger"); System.setProperty("log4j.defaultInitOverride", "false"); System.setProperty("log4j.configuration", logConfigPath); try { PropertyConfigurator.configure(logConfigPath); } catch (Throwable ignored) { } } } if (mode == MODE_CONFIGEDITOR) { // Show monitor try { monitor = new ProgressMonitor(); monitor.setVisible(true); Thread.sleep(400); } catch (Exception ignored) { } // Init simple logger try { System.setProperty("log4j.defaultInitOverride", "false"); Logger root = Logger.getRootLogger(); root.removeAllAppenders(); root.addAppender(new ConsoleAppender(new SimpleLayout())); root.setLevel(Level.INFO); } catch (Throwable ingored) { } } // Disable unnecessary INFO messages of the GData API try { java.util.logging.Logger logger = java.util.logging.Logger.getLogger("com.google"); logger.setLevel(java.util.logging.Level.WARNING); } catch (Throwable ingored) { } Log log = LogFactory.getLog(Configurator.class); log.info(VERSION + " starting..."); if (configFile != null && log.isDebugEnabled()) { log.debug("Config loaded successfully (" + configFile + ")."); } // Check Java version double jvmVersion = 1.5; try { jvmVersion = Float.valueOf(System.getProperty("java.version", "1.5").substring(0, 3)).floatValue(); } catch (Exception ignored) { } if (jvmVersion < 1.5) { log.fatal("GCALDaemon requires at least Java 1.5! Current version: " + System.getProperty("java.version")); throw new Exception("Invalid JVM version!"); } // Check permission if (workDirectory.isDirectory() && !workDirectory.canWrite()) { if (System.getProperty("os.name", "unknown").toLowerCase().indexOf("windows") == -1) { String path = workDirectory.getCanonicalPath(); if (programRootDir != null) { path = programRootDir.getCanonicalPath(); } log.warn("Please check the file permissions on the '" + workDirectory.getCanonicalPath() + "' folder!\r\n" + "Hint: [sudo] chmod -R 777 " + path); } } // Disable all ICS file syntax validators CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_OUTLOOK_COMPATIBILITY, true); CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_NOTES_COMPATIBILITY, true); // Disable SSL validation try { // Create a trust manager that does not validate certificate chains javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[] { new javax.net.ssl.X509TrustManager() { public final java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public final void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } public final void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; // Install the all-trusting trust manager javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Throwable ignored) { } // Replace hostname verifier try { javax.net.ssl.HostnameVerifier hv[] = new javax.net.ssl.HostnameVerifier[] { new javax.net.ssl.HostnameVerifier() { public final boolean verify(String hostName, javax.net.ssl.SSLSession session) { return true; } } }; javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(hv[0]); } catch (Throwable ignored) { } // Setup proxy String proxyHost = getConfigProperty(PROXY_HOST, null); if (proxyHost != null) { String proxyPort = getConfigProperty(PROXY_PORT, null); if (proxyPort == null) { log.warn("Missing 'proxy.port' configuration property!"); } else { // HTTP proxy server properties System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); System.setProperty("http.proxySet", "true"); // HTTPS proxy server properties System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); System.setProperty("https.proxySet", "true"); // Setup proxy credentials String username = getConfigProperty(PROXY_USERNAME, null); String encodedPassword = getConfigProperty(PROXY_PASSWORD, null); if (username != null) { if (encodedPassword == null) { log.warn("Missing 'proxy.password' configuration property!"); } else { String password = StringUtils.decodePassword(encodedPassword); // HTTP auth credentials System.setProperty("http.proxyUser", username); System.setProperty("http.proxyUserName", username); System.setProperty("http.proxyPassword", password); // HTTPS auth credentials System.setProperty("https.proxyUser", username); System.setProperty("https.proxyUserName", username); System.setProperty("https.proxyPassword", password); } } } } // Get iCal cache timeout long timeout = getConfigProperty(CACHE_TIMEOUT, 180000L); if (timeout < 60000L) { log.warn("The enabled minimal cache timeout is '1 min'!"); timeout = 60000L; } calendarCacheTimeout = timeout; // Get backup file timeout timeout = getConfigProperty(ICAL_BACKUP_TIMEOUT, 604800000L); if (timeout < 86400000L && timeout != 0) { log.warn("The enabled minimal backup timeout is '1 day'!"); timeout = 86400000L; } backupTimeout = timeout; // Get extended syncronization mode (alarms, url, category, etc) boolean enable = getConfigProperty(EXTENDED_SYNC_ENABLED, false); System.setProperty("gcaldaemon.extended.sync", Boolean.toString(enable)); if (enable) { log.info("Extended synchronization enabled."); } // Google send an email to the attendees to invite them to attend enable = getConfigProperty(SEND_INVITATIONS, false); System.setProperty("gcaldaemon.send.invitations", Boolean.toString(enable)); // Enabled alarm types in the Google Calendar (e.g. 'sms,popup,email') System.setProperty("gcaldaemon.remote.alarms", getConfigProperty(REMOTE_ALARM_TYPES, "email,sms,popup")); // Get parameters of the feed to iCal converter feedEnabled = getConfigProperty(FEED_ENABLED, true); feedEventLength = getConfigProperty(FEED_EVENT_LENGTH, 2700000L); timeout = getConfigProperty(FEED_CACHE_TIMEOUT, 3600000L); if (timeout < 60000L) { log.warn("The enabled minimal feed timeout is '1 min'!"); timeout = 60000L; } feedCacheTimeout = timeout; if (feedEnabled) { log.info("RSS/ATOM feed converter enabled."); } else { log.info("RSS/ATOM feed converter disabled."); } // Get feed event duplication ratio String percent = getConfigProperty(FEED_DUPLICATION_FILTER, "70").trim(); if (percent.endsWith("%")) { percent = percent.substring(0, percent.length() - 1).trim(); } double ratio = Double.parseDouble(percent) / 100; if (ratio < 0.4) { ratio = 0.4; log.warn("The smallest enabled filter percent is '40%'!"); } else { if (ratio > 1) { log.warn("The largest filter percent is '100%'!"); ratio = 1; } } duplicationRatio = ratio; if (feedEnabled) { if (duplicationRatio == 1) { log.debug("Duplication filter disabled."); } else { log.debug("Sensibility of the duplication filter is " + percent + "%."); } } // Delete backup files if (backupTimeout == 0) { File backupDirectory = new File(workDirectory, "backup"); if (backupDirectory.isDirectory()) { File[] backups = backupDirectory.listFiles(); if (backups != null && backups.length != 0) { for (i = 0; i < backups.length; i++) { backups[i].delete(); } } } } // Displays time zone log.info("Local time zone is " + TimeZone.getDefault().getDisplayName() + "."); // Get main thread group ThreadGroup mainGroup = Thread.currentThread().getThreadGroup(); while (mainGroup.getParent() != null) { mainGroup = mainGroup.getParent(); } // Configurator mode - launch ConfigTool's window if (mode == MODE_CONFIGEDITOR) { synchronizer = new Synchronizer(mainGroup, this); gmailPool = startService(log, mainGroup, "org.gcaldaemon.core.GmailPool"); new ConfigEditor(this, monitor); return; } // Init synchronizer boolean enableHTTP = getConfigProperty(HTTP_ENABLED, true); boolean enableFile = getConfigProperty(FILE_ENABLED, false); if (enableHTTP || enableFile || !standaloneMode) { synchronizer = new Synchronizer(mainGroup, this); if (mode == MODE_EMBEDDED) { return; } } // On demand mode - run once then quit if (mode == MODE_RUNONCE) { fileListener = startService(log, mainGroup, "org.gcaldaemon.core.file.OfflineFileListener"); return; } // Init Gmail pool boolean enableLDAP = getConfigProperty(LDAP_ENABLED, false); boolean enableSendMail = getConfigProperty(SENDMAIL_ENABLED, false); boolean enableMailTerm = getConfigProperty(MAILTERM_ENABLED, false); if (enableLDAP || enableSendMail || enableMailTerm) { gmailPool = startService(log, mainGroup, "org.gcaldaemon.core.GmailPool"); } if (standaloneMode) { // Init HTTP listener if (enableHTTP) { httpListener = startService(log, mainGroup, "org.gcaldaemon.core.http.HTTPListener"); } else { log.info("HTTP server disabled."); } } else { // Init J2EE servlet listener servletListener = startService(log, mainGroup, "org.gcaldaemon.core.servlet.ServletListener"); } // Init file listener if (enableFile) { if (getConfigProperty(FILE_OFFLINE_ENABLED, true)) { fileListener = startService(log, mainGroup, "org.gcaldaemon.core.file.OfflineFileListener"); } else { fileListener = startService(log, mainGroup, "org.gcaldaemon.core.file.OnlineFileListener"); } } else { if (standaloneMode) { log.info("File listener disabled."); } } // Init LDAP listener if (enableLDAP) { contactLoader = startService(log, mainGroup, "org.gcaldaemon.core.ldap.ContactLoader"); } else { if (standaloneMode) { log.info("LDAP server disabled."); } } // Init Gmail notifier if (getConfigProperty(NOTIFIER_ENABLED, false)) { if (GraphicsEnvironment.isHeadless()) { log.warn("Unable to use Gmail notifier in headless mode!"); } else { mailNotifier = startService(log, mainGroup, "org.gcaldaemon.core.notifier.GmailNotifier"); } } else { if (standaloneMode) { log.info("Gmail notifier disabled."); } } // Init sendmail service if (enableSendMail) { sendMail = startService(log, mainGroup, "org.gcaldaemon.core.sendmail.SendMail"); } else { if (standaloneMode) { log.info("Sendmail service disabled."); } } // Init mailterm service if (enableMailTerm) { mailTerm = startService(log, mainGroup, "org.gcaldaemon.core.mailterm.MailTerminal"); } else { if (standaloneMode) { log.info("Mail terminal disabled."); } } // Clear configuration holder config.clear(); }
From source file:org.gldapdaemon.core.Configurator.java
public Configurator(String configPath, Properties properties, boolean userHome, byte mode) throws Exception { this.mode = mode; int i;/*from w w w . j a v a2s.co m*/ File programRootDir = null; if (mode == MODE_EMBEDDED) { // Embedded mode standaloneMode = false; config = properties; String workPath = getConfigProperty(WORK_DIR, null); workDirectory = new File(workPath); } else { // Load config if (configPath != null) { configFile = new File(configPath); } InputStream in = null; boolean configInClassPath = false; if (configFile == null || !configFile.isFile()) { try { in = Configurator.class.getResourceAsStream("/gcal-daemon.cfg"); configInClassPath = in != null; } catch (Exception ignored) { in = null; } if (in == null) { System.out.println("INFO | Searching main configuration file..."); String path = (new File("x")).getAbsolutePath().replace('\\', '/'); i = path.lastIndexOf('/'); if (i > 1) { i = path.lastIndexOf('/', i - 1); if (i > 1) { configFile = new File(path.substring(0, i), "conf/gcal-daemon.cfg"); } } if (configFile == null || !configFile.isFile()) { configFile = new File("/usr/local/sbin/GCALDaemon/conf/gcal-daemon.cfg"); } if (configFile == null || !configFile.isFile()) { configFile = new File("/GCALDaemon/conf/gcal-daemon.cfg"); } if (configFile == null || !configFile.isFile()) { File root = new File("/"); String[] dirs = root.list(); if (dirs != null) { for (i = 0; i < dirs.length; i++) { configFile = new File('/' + dirs[i] + "/GCALDaemon/conf/gcal-daemon.cfg"); if (configFile.isFile()) { break; } } } } if (configFile == null || !configFile.isFile()) { throw new FileNotFoundException("Missing main configuration file: " + configPath); } if (!userHome) { // Open global config file in = new FileInputStream(configFile); } } } else { if (!userHome) { // Open global config file in = new FileInputStream(configFile); } } standaloneMode = !configInClassPath; if (in != null) { // Load global config file config.load(new BufferedInputStream(in)); in.close(); } // Loading config from classpath if (configFile == null) { try { URL url = Configurator.class.getResource("/gcal-daemon.cfg"); configFile = new File(url.getFile()); } catch (Exception ignored) { } } programRootDir = configFile.getParentFile().getParentFile(); System.setProperty("gldapdaemon.program.dir", programRootDir.getAbsolutePath()); String workPath = getConfigProperty(WORK_DIR, null); File directory; if (workPath == null) { directory = new File(programRootDir, "work"); } else { directory = new File(workPath); } if (!directory.isDirectory()) { if (!directory.mkdirs()) { directory = new File("work"); directory.mkdirs(); } } workDirectory = directory; // User-specific config file handler if (userHome) { boolean useGlobal = true; try { String home = System.getProperty("user.home", null); if (home != null) { File userConfig = new File(home, ".gcaldaemon/gcal-daemon.cfg"); if (!userConfig.isFile()) { // Create new user-specific config File userDir = new File(home, ".gcaldaemon"); userDir.mkdirs(); copyFile(configFile, userConfig); if (!userConfig.isFile()) { userConfig.delete(); userDir.delete(); } } if (userConfig.isFile()) { // Load user-specific config configFile = userConfig; in = new FileInputStream(configFile); config.load(new BufferedInputStream(in)); in.close(); useGlobal = false; } } } catch (Exception ignored) { } if (useGlobal) { // Load global config file config.load(new BufferedInputStream(in)); in.close(); } } } // Init logger ProgressMonitor monitor = null; if (standaloneMode && mode != MODE_CONFIGEDITOR) { // Compute log config path String logConfig = getConfigProperty(LOG_CONFIG, "logger-config.cfg"); logConfig = logConfig.replace('\\', '/'); File logConfigFile; if (logConfig.indexOf('/') == -1) { logConfigFile = new File(programRootDir, "conf/" + logConfig); } else { logConfigFile = new File(logConfig); } if (logConfigFile.isFile()) { String logConfigPath = logConfigFile.getAbsolutePath(); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger"); System.setProperty("log4j.defaultInitOverride", "false"); System.setProperty("log4j.configuration", logConfigPath); try { PropertyConfigurator.configure(logConfigPath); } catch (Throwable ignored) { ignored.printStackTrace(); } } } if (mode == MODE_CONFIGEDITOR) { // Show monitor try { monitor = new ProgressMonitor(); monitor.setVisible(true); Thread.sleep(400); } catch (Exception ignored) { } // Init simple logger try { System.setProperty("log4j.defaultInitOverride", "false"); Logger root = Logger.getRootLogger(); root.removeAllAppenders(); root.addAppender(new ConsoleAppender(new SimpleLayout())); root.setLevel(Level.INFO); } catch (Throwable ingored) { } } // Disable unnecessary INFO messages of the GData API try { java.util.logging.Logger logger = java.util.logging.Logger.getLogger("com.google"); logger.setLevel(java.util.logging.Level.WARNING); } catch (Throwable ingored) { } Log log = LogFactory.getLog(Configurator.class); log.info(VERSION + " starting..."); if (configFile != null && log.isDebugEnabled()) { log.debug("Config loaded successfully (" + configFile + ")."); } // Check Java version double jvmVersion = 1.5; try { jvmVersion = Float.valueOf(System.getProperty("java.version", "1.5").substring(0, 3)).floatValue(); } catch (Exception ignored) { } if (jvmVersion < 1.5) { log.fatal("GCALDaemon requires at least Java 1.5! Current version: " + System.getProperty("java.version")); throw new Exception("Invalid JVM version!"); } // Check permission if (workDirectory.isDirectory() && !workDirectory.canWrite()) { if (System.getProperty("os.name", "unknown").toLowerCase().indexOf("windows") == -1) { String path = workDirectory.getCanonicalPath(); if (programRootDir != null) { path = programRootDir.getCanonicalPath(); } log.warn("Please check the file permissions on the '" + workDirectory.getCanonicalPath() + "' folder!\r\n" + "Hint: [sudo] chmod -R 777 " + path); } } // Disable SSL validation try { // Create a trust manager that does not validate certificate chains javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[] { new javax.net.ssl.X509TrustManager() { public final java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public final void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } public final void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; // Install the all-trusting trust manager javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Throwable ignored) { } // Replace hostname verifier try { javax.net.ssl.HostnameVerifier hv[] = new javax.net.ssl.HostnameVerifier[] { new javax.net.ssl.HostnameVerifier() { public final boolean verify(String hostName, javax.net.ssl.SSLSession session) { return true; } } }; javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(hv[0]); } catch (Throwable ignored) { } // Setup proxy String proxyHost = getConfigProperty(PROXY_HOST, null); if (proxyHost != null) { String proxyPort = getConfigProperty(PROXY_PORT, null); if (proxyPort == null) { log.warn("Missing 'proxy.port' configuration property!"); } else { // HTTP proxy server properties System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); System.setProperty("http.proxySet", "true"); // HTTPS proxy server properties System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", proxyPort); System.setProperty("https.proxySet", "true"); // Setup proxy credentials String username = getConfigProperty(PROXY_USERNAME, null); String encodedPassword = getConfigProperty(PROXY_PASSWORD, null); if (username != null) { if (encodedPassword == null) { log.warn("Missing 'proxy.password' configuration property!"); } else { String password = StringUtils.decodePassword(encodedPassword); // HTTP auth credentials System.setProperty("http.proxyUser", username); System.setProperty("http.proxyUserName", username); System.setProperty("http.proxyPassword", password); // HTTPS auth credentials System.setProperty("https.proxyUser", username); System.setProperty("https.proxyUserName", username); System.setProperty("https.proxyPassword", password); } } } } // Get feed event duplication ratio String percent = getConfigProperty(FEED_DUPLICATION_FILTER, "70").trim(); if (percent.endsWith("%")) { percent = percent.substring(0, percent.length() - 1).trim(); } double ratio = Double.parseDouble(percent) / 100; if (ratio < 0.4) { ratio = 0.4; log.warn("The smallest enabled filter percent is '40%'!"); } else { if (ratio > 1) { log.warn("The largest filter percent is '100%'!"); ratio = 1; } } duplicationRatio = ratio; // Displays time zone log.info("Local time zone is " + TimeZone.getDefault().getDisplayName() + "."); // Get main thread group ThreadGroup mainGroup = Thread.currentThread().getThreadGroup(); while (mainGroup.getParent() != null) { mainGroup = mainGroup.getParent(); } // Init Gmail pool boolean enableLDAP = getConfigProperty(LDAP_ENABLED, false); if (enableLDAP) { gmailPool = startService(log, mainGroup, "org.gldapdaemon.core.GmailPool"); } // Init LDAP listener if (enableLDAP) { contactLoader = startService(log, mainGroup, "org.gldapdaemon.core.ldap.ContactLoader"); } else { if (standaloneMode) { log.info("LDAP server disabled."); } } // Clear configuration holder config.clear(); }
From source file:org.globus.workspace.service.binding.vm.VirtualMachine.java
private void _adjustRootUnpropTarget(String path, String suffix, Log logger) throws ManageException { if (this.partitions == null || this.partitions.length == 0) { throw new ManageException("partitions do not exist"); }//from w w w. ja v a 2 s .com boolean found = false; for (int i = 0; i < this.partitions.length; i++) { if (this.partitions[i].isRootdisk()) { final String old = this.partitions[i].getAlternateUnpropTarget(); if (logger != null && old != null) { logger.info(Lager.ev(this.id) + "Overriding previously " + "set alternate unpropagate target: '" + old + "'"); } else if (logger != null) { logger.info(Lager.ev(this.id) + "Setting " + "alternate unpropagate target: '" + path + "'"); } if (path != null) { if (suffix != null) { final String newpath = path + suffix; this.partitions[i].setAlternateUnpropTarget(newpath); } else { this.partitions[i].setAlternateUnpropTarget(path); } } else if (old != null && suffix != null) { final String newpath = old + suffix; this.partitions[i].setAlternateUnpropTarget(newpath); } found = true; break; } } if (!found) { throw new ManageException("could not find root disk to override its target"); } }
From source file:org.globus.wsrf.tools.wsdl.GenerateBinding.java
public void execute() throws Exception { Log log = LogFactory.getLog(getClass()); if (this.portTypeFile == null || this.portTypeFile.length() == 0) { throw new Exception("Input file not specified"); }/* w ww. jav a 2s .c o m*/ if (this.fileRoot == null || this.fileRoot.length() == 0) { throw new Exception("File root not specified"); } Definition portTypeDefinition; Definition bindingDefinition; Definition serviceDefinition; FileOutputStream bindingDefinitionOutput = null; FileOutputStream serviceDefinitionOutput = null; FileInputStream portTypeInput = null; try { portTypeFile = new File(this.portTypeFile).getCanonicalPath(); portTypeInput = new FileInputStream(portTypeFile); WSDLFactory factory = WSDLFactory.newInstance(); WSDLReader reader = factory.newWSDLReader(); WSDLWriter writer = factory.newWSDLWriter(); reader.setFeature("javax.wsdl.verbose", false); reader.setFeature("javax.wsdl.importDocuments", true); portTypeDefinition = reader.readWSDL(null, portTypeFile); bindingDefinition = factory.newDefinition(); serviceDefinition = factory.newDefinition(); QName name = portTypeDefinition.getQName(); if (name == null) { String baseName = (new File(portTypeFile)).getName(); int pos = baseName.indexOf('.'); name = new QName(portTypeDefinition.getTargetNamespace(), (pos == -1) ? baseName : baseName.substring(0, pos)); } bindingDefinition.setQName(new QName(name.getLocalPart())); serviceDefinition.setQName(new QName(name.getLocalPart())); bindingDefinition.setTargetNamespace(portTypeDefinition.getTargetNamespace() + "/bindings"); bindingDefinition.setExtensionRegistry(new PopulatedExtensionRegistry()); bindingDefinition.addNamespace("soap", SOAP_NS); bindingDefinition.addNamespace("porttype", portTypeDefinition.getTargetNamespace()); String bindingFile = this.fileRoot + "_bindings.wsdl"; bindingFile = new File(bindingFile).getCanonicalPath(); bindingDefinitionOutput = new FileOutputStream(bindingFile); String relativePortTypeFile = RelativePathUtil.getRelativeFileName(new File(portTypeFile), new File(bindingFile)); Import portTypeImport = bindingDefinition.createImport(); portTypeImport.setLocationURI(relativePortTypeFile); portTypeImport.setNamespaceURI(portTypeDefinition.getTargetNamespace()); bindingDefinition.addImport(portTypeImport); serviceDefinition.setTargetNamespace(portTypeDefinition.getTargetNamespace() + "/service"); serviceDefinition.setExtensionRegistry(new PopulatedExtensionRegistry()); serviceDefinition.addNamespace("soap", SOAP_NS); serviceDefinition.addNamespace("binding", bindingDefinition.getTargetNamespace()); String serviceFile = this.fileRoot + "_service.wsdl"; serviceFile = new File(serviceFile).getCanonicalPath(); serviceDefinitionOutput = new FileOutputStream(serviceFile); String relativeBindingFile = RelativePathUtil.getRelativeFileName(new File(bindingFile), new File(serviceFile)); Import bindingImport = serviceDefinition.createImport(); bindingImport.setLocationURI(relativeBindingFile); bindingImport.setNamespaceURI(bindingDefinition.getTargetNamespace()); serviceDefinition.addImport(bindingImport); Service service = serviceDefinition.createService(); if (serviceDefinition.getQName().getLocalPart().endsWith("Service")) { service.setQName(serviceDefinition.getQName()); } else { service.setQName(new QName(serviceDefinition.getQName().getLocalPart() + "Service")); } Iterator portTypeIterator = portTypeDefinition.getPortTypes().values().iterator(); Binding binding; PortType portType; while (portTypeIterator.hasNext()) { portType = (PortType) portTypeIterator.next(); binding = processPortType(bindingDefinition, portType); bindingDefinition.addBinding(binding); service.addPort(createPort(serviceDefinition, portType, binding)); } writer.writeWSDL(bindingDefinition, bindingDefinitionOutput); serviceDefinition.addService(service); writer.writeWSDL(serviceDefinition, serviceDefinitionOutput); if (!this.quiet) { log.info("Generated " + bindingFile); log.info("Generated " + serviceFile); } } finally { if (portTypeInput != null) { try { portTypeInput.close(); } catch (Exception io) { } } if (bindingDefinitionOutput != null) { try { bindingDefinitionOutput.close(); } catch (Exception io) { } } if (serviceDefinitionOutput != null) { try { serviceDefinitionOutput.close(); } catch (Exception io) { } } } }
From source file:org.grouter.common.jndi.JNDIUtils.java
/** * Print out all JNDI variables for provided Context. * * @param ctx Context//from ww w . ja v a2s. co m * @param alogger if null it will usethis class logger */ public static void printJNDI(Context ctx, final Log alogger) { Hashtable table; try { table = ctx.getEnvironment(); Set set = table.keySet(); Iterator it = set.iterator(); alogger.info("Context contains key value pairs:"); while (it.hasNext()) { String key = (String) it.next(); alogger.info("(key,value) = (" + key + "," + (table.get(key)) + ")"); } } catch (NamingException ex) { logger.error("Retrieving the environment in effect for this context failed."); } }
From source file:org.hibernate.eclipse.HibernatePlugin.java
public void start(BundleContext context) throws Exception { super.start(context); configureLog4jHooks();// w w w. j a v a 2 s. c o m Log log = LogFactory.getLog(HibernatePlugin.class); log.info("HibernatePlugin Started"); //$NON-NLS-1$ }
From source file:org.holodeckb2b.ebms3.util.SOAPEnvelopeLogger.java
@Override protected InvocationResponse doProcessing(MessageContext mc) throws Exception { // We use a specific log for the SOAP headers so it can easily be enabled or disabled Log soapEnvLog = LogFactory.getLog("org.holodeckb2b.msgproc.soapenvlog." + (isInFlow(IN_FLOW) || isInFlow(IN_FAULT_FLOW) ? "IN" : "OUT")); // Only do something when logging is enabled if (soapEnvLog.isInfoEnabled()) { soapEnvLog.info(mc.getEnvelope().cloneOMElement().toStringWithConsume() + "\n"); }// w w w .j a v a 2 s. co m return InvocationResponse.CONTINUE; }
From source file:org.hyperic.hq.context.IntegrationTestContextLoader.java
public static final void configureSigar(final ApplicationContext context, final Log externalLogger) { final Log log = (externalLogger == null ? logger : externalLogger); try {/*from www .j av a 2s . c o m*/ overrideProperties(log); //Find the sigar libs on the test classpath final File sigarBin = new File( context.getResource("/libsigar-sparc64-solaris.so").getFile().getParent()); log.info("Setting sigar path to : " + sigarBin.getAbsolutePath()); System.setProperty("org.hyperic.sigar.path", sigarBin.getAbsolutePath()); //ensure that the Sigar native libraries are loaded and remain in the classloader's context sigar = new Sigar(); Sigar.load(); } catch (Throwable t) { log.error("Unable to initiailize sigar path", t); throw new SystemException(t); } //EO catch block }
From source file:org.hyperic.hq.context.IntegrationTestContextLoader.java
private static final void overrideProperties(final Log log) { if (initializedSysProps) return;// www. j a v a2 s . c o m final String OVERRIDE_PREFIX = "override."; final int OVERRIDE_PREFIX_LENGTH = OVERRIDE_PREFIX.length(); final Properties sysProps = System.getProperties(); final Map<String, String> newProps = new HashMap<String, String>(); String origSysPropName, overrideSysPropName, origSyspropVal, overrideVal; int indexOfPrefix; for (Entry<Object, Object> syspropEntry : sysProps.entrySet()) { overrideSysPropName = (String) syspropEntry.getKey(); if ((indexOfPrefix = overrideSysPropName.indexOf(OVERRIDE_PREFIX)) == -1) continue; //first search for an explicitly defined corresponding original sys prop //and found skip the override. origSysPropName = overrideSysPropName.substring(OVERRIDE_PREFIX_LENGTH); origSyspropVal = System.getProperty(origSysPropName); if (origSyspropVal != null) continue; //else create a new orig sys prop with the override value overrideVal = (String) syspropEntry.getValue(); newProps.put(origSysPropName, overrideVal); log.info("An " + overrideSysPropName + " property value was provided : " + overrideVal + " setting in the " + origSysPropName + " system property"); } //EO while there are more system properties for (Map.Entry<String, String> newPropEntry : newProps.entrySet()) { System.setProperty(newPropEntry.getKey(), newPropEntry.getValue()); } //EO while there are more new properties initializedSysProps = true; }
From source file:org.hyperic.hq.context.IntegrationTestContextLoader.java
private final void overrideProperties(final String[][] properties, final Log log) { final int length = properties.length; String sysPropName, overrideSysPropName, syspropOrigVal, overrideVal; for (int i = 0; i < length; i++) { sysPropName = properties[i][0];/*from w w w . ja v a 2 s .co m*/ syspropOrigVal = System.getProperty(sysPropName); //if the org system property already exists then it was explicitly defined and should //not be overriden if (syspropOrigVal != null) continue; //else attempt to looukup the overrding property value and if found, define //a new system proeprty with the orig name and the overriding value overrideSysPropName = properties[i][1]; overrideVal = System.getProperty(overrideSysPropName); if (overrideVal == null) continue; //else there is an override value and not explicitly defined orig value so override log.info("An " + overrideSysPropName + " property value was provided : " + overrideVal + " setting in the " + sysPropName + " system property"); } //EO while there are more properties to potentially override }