List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:net.unicon.sakora.impl.csv.CsvSyncServiceImpl.java
public void setCleanupData(String cleanupDataString) { this.cleanupData = Boolean.getBoolean(cleanupDataString); }
From source file:org.openconcerto.sql.model.graph.DatabaseGraph.java
private void map(final DBRoot r, final String tableName, final Set<String> tableNames) throws SQLException { // either we refresh the whole root and we must know which tables to use // or we refresh only one table and tableNames is useless assert tableName == null ^ tableNames == null; final SetMap<String, String> metadataFKs = new SetMap<String, String>(); @SuppressWarnings("unchecked") final List<Object[]> importedKeys = this.base.getDataSource() .useConnection(new ConnectionHandlerNoSetup<List, SQLException>() { @Override/* w w w.ja va 2s .c o m*/ public List handle(final SQLDataSource ds) throws SQLException { final DatabaseMetaData metaData = ds.getConnection().getMetaData(); return (List) SQLDataSource.ARRAY_LIST_HANDLER.handle(metaData .getImportedKeys(r.getBase().getMDName(), r.getSchema().getName(), tableName)); } }); // accumulators for multi-field foreign key final List<SQLField> from = new ArrayList<SQLField>(); final List<SQLField> to = new ArrayList<SQLField>(); final SQLSystem sys = this.base.getServer().getSQLSystem(); Rule updateRule = null; Rule deleteRule = null; String name = null; // Follow the JDBC to the letter and order by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, // KEY_SEQ : thus ignoring FK_NAME if (sys == SQLSystem.MSSQL) { Collections.sort(importedKeys, IMPORTED_KEYS_COMP); } final Iterator<Object[]> ikIter = importedKeys.iterator(); while (ikIter.hasNext()) { final Object[] m = ikIter.next(); // FKTABLE_SCHEM assert CompareUtils.equals(m[5], r.getSchema().getName()); // FKTABLE_NAME final String fkTableName = (String) m[6]; assert tableName == null || tableName.equals(fkTableName); if (tableNames != null && !tableNames.contains(fkTableName)) continue; // not by name, postgresql returns lowercase // "FKCOLUMN_NAME" final String keyName = (String) m[7]; // "KEY_SEQ" final short seq = ((Number) m[8]).shortValue(); // "PKCOLUMN_NAME" final String foreignTableColName = (String) m[3]; // "FK_NAME" final String foreignKeyName = (String) m[11]; final SQLField key = r.getTable(fkTableName).getField(keyName); final SQLTable foreignTable; try { foreignTable = getTableFromJDBCMetaData(r.getBase(), (String) m[0], (String) m[1], (String) m[2]); } catch (Exception e) { throw new IllegalStateException("Could not find what " + key.getSQLName() + " references", e); } metadataFKs.add(fkTableName, keyName); if (seq == 1) { // if we start a new link add the current one if (from.size() > 0) addLink(from, to, name, updateRule, deleteRule); from.clear(); to.clear(); } from.add(key); assert seq == 1 || from.get(from.size() - 2).getTable() == from.get(from.size() - 1).getTable(); to.add(foreignTable.getField(foreignTableColName)); assert seq == 1 || to.get(to.size() - 2).getTable() == to.get(to.size() - 1).getTable(); final Rule prevUpdateRule = updateRule; final Rule prevDeleteRule = deleteRule; // "UPDATE_RULE" updateRule = getRule((Number) m[9], sys); // "DELETE_RULE" deleteRule = getRule((Number) m[10], sys); if (seq > 1) { if (prevUpdateRule != updateRule) throw new IllegalStateException( "Incoherent update rules " + prevUpdateRule + " != " + updateRule); if (prevDeleteRule != deleteRule) throw new IllegalStateException( "Incoherent delete rules " + prevDeleteRule + " != " + deleteRule); } name = foreignKeyName; // MAYBE DEFERRABILITY } if (from.size() > 0) addLink(from, to, name, updateRule, deleteRule); if (Boolean.getBoolean(INFER_FK)) { final Set<String> tables = tableName != null ? Collections.singleton(tableName) : tableNames; for (final String tableToInfer : tables) { final SQLTable table = r.getTable(tableToInfer); final Set<String> lexicalFKs = SQLKey.foreignKeys(table); // already done lexicalFKs.removeAll(metadataFKs.getNonNull(table.getName())); // MAYBE option to print out foreign keys w/o constraint for (final String keyName : lexicalFKs) { final SQLField key = table.getField(keyName); addLink(singletonList(key), singletonList(SQLKey.keyToTable(key).getKey()), null, null, null); } } } }
From source file:com.wavemaker.tools.data.ImportDB.java
private void checkGenerateOldStyleOps() { String s = this.properties.getProperty(GENERATE_OLD_STYLE_OPRS_PROPERTY); if (s != null) { setUseIndividualCRUDOperations(Boolean.getBoolean(GENERATE_OLD_STYLE_OPRS_PROPERTY)); }//from w w w. j a v a 2 s . c o m }
From source file:org.openconcerto.sql.model.SQLTable.java
private int findMinID(SQLField pk) { final String debugUndef = "fwk_sql.debug.undefined_id"; if (System.getProperty(debugUndef) != null) Log.get().warning("The system property '" + debugUndef + "' is deprecated, use the '" + UNDEFINED_ID_POLICY + "' metadata"); final String policy = getSchema().getFwkMetadata(UNDEFINED_ID_POLICY); if (Boolean.getBoolean(debugUndef) || "min".equals(policy)) { final SQLSelect sel = new SQLSelect(true).addSelect(pk, "min"); final Number undef = (Number) this.getBase().getDataSource().executeScalar(sel.asString()); if (undef == null) { // empty table throw new IllegalStateException(this + " is empty, can not infer UNDEFINED_ID"); } else {//from w ww. j a v a2 s. com final String update = "INSERT into " + new SQLName(this.getDBRoot().getName(), undefTable) + " VALUES('" + this.getName() + "', " + undef + ");"; Log.get().config("the first row (which should be the undefined):\n" + update); return undef.intValue(); } } else if ("inDB".equals(policy)) { throw new IllegalStateException( "Not in " + new SQLName(this.getDBRoot().getName(), undefTable) + " : " + this.getName()); } else if (policy != null && !"nonexistant".equals(policy)) { final int res = Integer.parseInt(policy); if (res < SQLRow.MIN_VALID_ID) throw new IllegalStateException("ID is not valid : " + res); return res; } else { // by default assume NULL is used return SQLRow.NONEXISTANT_ID; } }
From source file:org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.java
@Override public CompletableFuture<CompletionItem> resolveCompletionItem(CompletionItem unresolved) { logInfo(">> document/resolveCompletionItem"); CompletionResolveHandler handler = new CompletionResolveHandler(preferenceManager); final IProgressMonitor[] monitors = new IProgressMonitor[1]; CompletableFuture<CompletionItem> result = computeAsync((monitor) -> { monitors[0] = monitor;//from ww w . ja va 2s .c o m if ((Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION))) { waitForLifecycleJobs(monitor); } return handler.resolve(unresolved, monitor); }); result.join(); if (monitors[0].isCanceled()) { result.cancel(true); } return result; }
From source file:org.codice.ddf.itests.common.AbstractIntegrationTest.java
protected Option[] configureSystemSettings() { return options( when(Boolean.getBoolean("isDebugEnabled")) .useOptions(vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")), when(Boolean.getBoolean("acdebuggerEnabled") && !Boolean.getBoolean("isDebugEnabled")) .useOptions(KarafDistributionOption .debugConfiguration(System.getProperty("acdebuggerPort", "5505"), true)), when(System.getProperty(MVN_LOCAL_REPO) != null).useOptions( systemProperty(PAX_URL_MVN_LOCAL_REPO).value(System.getProperty(MVN_LOCAL_REPO, ""))), editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "org.codice.ddf.system.version", MavenUtils.getArtifactVersion(DDF_ITESTS_GROUP_ID, "test-itests-common")), editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "ddf.version", MavenUtils.getArtifactVersion(DDF_ITESTS_GROUP_ID, "test-itests-common")), editConfigurationFilePut(SYSTEM_PROPERTIES_REL_PATH, "artemis.diskusage", "100")); }
From source file:statechum.analysis.learning.Visualiser.java
public void construct(Graph g, LayoutOptions options) { if (!globalConfig.isAssertEnabled() && Boolean.getBoolean(globalConfig.getProperty(G_PROPERTIES.ASSERT_ENABLED))) { System.err.println("Pass the -ea argument to JVM to enable assertions"); }// w w w.java2 s . c om // if (Boolean.valueOf(GlobalConfiguration.getConfiguration() .getProperty(GlobalConfiguration.G_PROPERTIES.CLOSE_TERMINATE))) this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); else if (Boolean.valueOf( GlobalConfiguration.getConfiguration().getProperty(GlobalConfiguration.G_PROPERTIES.ESC_TERMINATE))) this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); else this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.addWindowListener(new WindowEventHandler()); /* this.addComponentListener(new ComponentListener() { @Override public void componentShown(@SuppressWarnings("unused") ComponentEvent e) {} @Override public void componentResized(@SuppressWarnings("unused") ComponentEvent e) { if (viewer != null) viewer.getModel().getGraphLayout().resize(getSize()); } @Override public void componentMoved(@SuppressWarnings("unused") ComponentEvent e) {} @Override public void componentHidden(@SuppressWarnings("unused") ComponentEvent e) {} });*/ this.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { Action act = keyToActionMap.get(arg0.getKeyCode()); if (act != null) { act.actionPerformed(null); } } @Override public void keyReleased(@SuppressWarnings("unused") KeyEvent arg0) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method. } @Override public void keyTyped(@SuppressWarnings("unused") KeyEvent key) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method. } }); popupMenu = new JPopupMenu(); // Icon loading is from http://www.javaworld.com/javaworld/javaqa/2000-06/03-qa-0616-icon.html Image icon = Toolkit.getDefaultToolkit() .getImage(GlobalConfiguration.getConfiguration().getProperty(G_PROPERTIES.RESOURCES) + File.separator + "icon.jpg"); if (icon != null) { setIconImage(icon); } setVisualiserKeyBindings(); setStateChumKeyBindings(this, propName, keyToActionMap); updatePopupMenu(popupMenu, keyToActionMap); //getContentPane().removeAll(); WindowPosition framePosition = globalConfig.loadFrame(propName); viewer = new VisualizationViewer( new DefaultVisualizationModel( new XMLPersistingLayout(propName >= 0 ? new FRLayout(g) : new KKLayout(g))), constructRenderer(g, options)); viewer.setBackground(Color.WHITE); final DefaultModalGraphMouse graphMouse = new XMLModalGraphMouse(); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); graphMouse.add(new PickingGraphMousePlugin()); viewer.setGraphMouse(graphMouse); viewer.setPickSupport(new ShapePickSupport()); viewer.addMouseListener(this); final GraphZoomScrollPane panel = new GraphZoomScrollPane(viewer); getContentPane().add(panel); pack(); viewer.setPreferredSize(getSize()); //viewer.getModel().getGraphLayout().initialize(getSize()); restoreLayout(true, currentGraph); setBounds(framePosition.getRect()); framesVisible.add(this);// register as an active frame. setVisible(true); }
From source file:org.apache.cassandra.db.commitlog.CommitLogReplayer.java
static void handleReplayError(boolean permissible, String message, Object... messageArgs) throws IOException { String msg = String.format(message, messageArgs); IOException e = new CommitLogReplayException(msg); if (permissible) logger.error("Ignoring commit log replay error likely due to incomplete flush to disk", e); else if (Boolean.getBoolean(IGNORE_REPLAY_ERRORS_PROPERTY)) logger.error("Ignoring commit log replay error", e); else if (!CommitLog.handleCommitError("Failed commit log replay", e)) { logger.error(/* w w w . jav a 2s. co m*/ "Replay stopped. If you wish to override this error and continue starting the node ignoring " + "commit log replay problems, specify -D" + IGNORE_REPLAY_ERRORS_PROPERTY + "=true " + "on the command line"); throw e; } }
From source file:org.openspaces.pu.container.servicegrid.PUServiceBeanImpl.java
private void startPU(String springXml) throws IOException, ClassNotFoundException { if (logger.isDebugEnabled()) { logger.debug(logMessage("Starting PU with [" + springXml + "]")); }/*from w w w. j av a 2s. c o m*/ String puName = (String) context.getInitParameter("puName"); String puPath = (String) context.getInitParameter("puPath"); String codeserver = context.getExportCodebase(); org.openspaces.pu.sla.SLA sla = getSLA(getServiceBeanContext()); Integer instanceId = this.instanceId; Integer backupId = this.backupId; // Derive instanceId and backupId if not explicitly set if (instanceId == null) { boolean hasBackups = sla.getNumberOfBackups() > 0; if (hasBackups) { instanceId = clusterGroup; //the first instance is primary so no backupid if (context.getServiceBeanConfig().getInstanceID().intValue() > 1) { backupId = (context.getServiceBeanConfig().getInstanceID().intValue() - 1); } } else { instanceId = context.getServiceBeanConfig().getInstanceID().intValue(); } } //set cluster info clusterInfo = new ClusterInfo(); String clusterSchema = sla.getClusterSchema(); if (clusterSchema != null) { clusterInfo.setSchema(clusterSchema); int slaMax = getSLAMax(context); int numberOfInstances = Math.max(slaMax, sla.getNumberOfInstances()); clusterInfo.setNumberOfInstances(numberOfInstances); } else { clusterInfo.setNumberOfInstances(sla.getNumberOfInstances()); } clusterInfo.setNumberOfBackups(sla.getNumberOfBackups()); clusterInfo.setInstanceId(instanceId); clusterInfo.setBackupId(backupId); clusterInfo.setName(puName); ClusterInfoParser.guessSchema(clusterInfo); logger.info(logMessage("ClusterInfo [" + clusterInfo + "]")); MarshalledObject beanLevelPropertiesMarshObj = (MarshalledObject) getServiceBeanContext() .getInitParameter("beanLevelProperties"); BeanLevelProperties beanLevelProperties; if (beanLevelPropertiesMarshObj != null) { beanLevelProperties = (BeanLevelProperties) beanLevelPropertiesMarshObj.get(); logger.info(logMessage("BeanLevelProperties " + beanLevelProperties)); } else { beanLevelProperties = new BeanLevelProperties(); } beanLevelProperties.getContextProperties() .putAll(ClusterInfoPropertyPlaceholderConfigurer.createProperties(clusterInfo)); // set a generic work location that can be used by container providers File workLocation = new File(SystemInfo.singleton().locations().work()); workLocation.mkdirs(); beanLevelProperties.getContextProperties().setProperty("com.gs.work", workLocation.getAbsolutePath()); boolean downloadPU = false; //create PU Container ProcessingUnitContainerProvider factory; // identify if this is a web app final InputStream webXml = openUrlStream(codeserver + puPath + "/WEB-INF/web.xml"); // identify if this is a .NET one final InputStream puConfig = openUrlStream(codeserver + puPath + "/pu.config"); // identify if this is a .NET interop one final InputStream puInteropConfig = openUrlStream(codeserver + puPath + "/pu.interop.config"); String processingUnitContainerProviderClass; if (webXml != null) { webXml.close(); downloadPU = true; String jeeContainer = JeeProcessingUnitContainerProvider.getJeeContainer(beanLevelProperties); String[] classesToLoad = null; if ("jetty".equals(jeeContainer)) { // pre load the jetty server class so the static shutdown thread will be loaded under it classesToLoad = new String[] { "org.eclipse.jetty.server.Server" }; } // setup class loaders correcly try { Thread.currentThread().setContextClassLoader(CommonClassLoader.getInstance()); ((ServiceClassLoader) contextClassLoader).addURLs(BootUtil.toURLs( new String[] { JeeProcessingUnitContainerProvider.getJeeContainerJarPath(jeeContainer) })); ((ServiceClassLoader) contextClassLoader) .setParentClassLoader(SharedServiceData.getJeeClassLoader(jeeContainer, classesToLoad)); } catch (Exception e) { throw new CannotCreateContainerException("Failed to configure JEE class loader", e); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } String className = StringUtils.capitalize(jeeContainer) + "JeeProcessingUnitContainerProvider"; processingUnitContainerProviderClass = "org.openspaces.pu.container.jee." + jeeContainer + "." + className; } else if (puConfig != null) { puConfig.close(); downloadPU = true; processingUnitContainerProviderClass = DotnetProcessingUnitContainerProvider.class.getName(); } else if (puInteropConfig != null) { puInteropConfig.close(); downloadPU = true; processingUnitContainerProviderClass = IntegratedProcessingUnitContainerProvider.class.getName(); } else { processingUnitContainerProviderClass = IntegratedProcessingUnitContainerProvider.class.getName(); if (beanLevelProperties.getContextProperties().getProperty("pu.download", "true") .equalsIgnoreCase("true")) { downloadPU = true; } } if (beanLevelProperties != null) { processingUnitContainerProviderClass = beanLevelProperties.getContextProperties().getProperty( ProcessingUnitContainerProvider.CONTAINER_CLASS_PROP, processingUnitContainerProviderClass); } if (downloadPU) { String deployName = puName + "_" + clusterInfo.getRunningNumberOffset1(); String deployedProcessingUnitsLocation = workLocation.getAbsolutePath() + "/processing-units"; int uuid = Math.abs(new Random().nextInt()); deployPath = new File( deployedProcessingUnitsLocation + "/" + deployName.replace('.', '_') + "_" + uuid); FileSystemUtils.deleteRecursively(deployPath); deployPath.mkdirs(); // backward compatible beanLevelProperties.getContextProperties().setProperty("jee.deployPath", deployPath.getAbsolutePath()); beanLevelProperties.getContextProperties().setProperty("dotnet.deployPath", deployPath.getAbsolutePath()); beanLevelProperties.getContextProperties().setProperty( ProcessingUnitContainerProvider.CONTEXT_PROPERTY_DEPLOY_PATH, deployPath.getAbsolutePath()); try { if (isOnGsmHost()) { copyPu(puPath, deployPath); } else { long size = downloadAndExtractPU(puName, puPath, codeserver, deployPath, new File(deployedProcessingUnitsLocation)); logDownloadSize(size); } } catch (MalformedURLException mle) { logger.warn("Could not determine if GSC and GSM are on the same host", mle); // fallback to download long size = downloadAndExtractPU(puName, puPath, codeserver, deployPath, new File(deployedProcessingUnitsLocation)); logDownloadSize(size); } catch (UnknownHostException unhe) { logger.warn("Could not determine if GSC and GSM are on the same host", unhe); // fallback to download long size = downloadAndExtractPU(puName, puPath, codeserver, deployPath, new File(deployedProcessingUnitsLocation)); logDownloadSize(size); } catch (RemoteException re) { logger.warn("Could not determine if GSC and GSM are on the same host", re); // fallback to download long size = downloadAndExtractPU(puName, puPath, codeserver, deployPath, new File(deployedProcessingUnitsLocation)); logDownloadSize(size); } // go over listed files that needs to be resolved with properties for (Map.Entry entry : beanLevelProperties.getContextProperties().entrySet()) { String key = (String) entry.getKey(); if (key.startsWith("com.gs.resolvePlaceholder")) { String path = (String) entry.getValue(); File input = new File(deployPath, path); if (logger.isDebugEnabled()) { logger.debug("Resolving placeholder for file [" + input.getAbsolutePath() + "]"); } BeanLevelPropertiesUtils.resolvePlaceholders(beanLevelProperties, input); } } } boolean sharedLibEnabled; if (beanLevelProperties.getContextProperties().containsKey("pu.shared-lib.enable")) { sharedLibEnabled = beanLevelProperties.getContextProperties().getProperty("pu.shared-lib") .equals("true"); } else { sharedLibEnabled = System.getProperty("com.gs.pu.shared-lib.enable", "false").equals("true"); } final boolean disableManifestClassPathJars = Boolean.getBoolean("com.gs.pu.manifest.classpath.disable"); final boolean disableManifestClassPathCommonPuJars = Boolean .getBoolean("com.gs.pu.manifest.classpath.common.disable"); // this is used to inject the manifest jars to the webapp classloader (if exists) List<URL> manifestClassPathJars = new ArrayList<URL>(); CommonClassLoader commonClassLoader = CommonClassLoader.getInstance(); // handles class loader libraries if (downloadPU) { List<URL> libUrls = new ArrayList<URL>(); File libDir = new File(deployPath, "lib"); if (libDir.exists()) { File[] libFiles = BootIOUtils.listFiles(libDir); for (File libFile : libFiles) { libUrls.add(libFile.toURI().toURL()); } } if (!disableManifestClassPathJars) { File manifestFile = new File(deployPath, JarFile.MANIFEST_NAME); if (manifestFile.isFile()) { try { InputStream manifestStream = new FileInputStream(manifestFile); manifestClassPathJars = getManifestClassPathJars(puName, manifestStream); libUrls.addAll(manifestClassPathJars); } catch (IOException e) { if (logger.isWarnEnabled()) { logger.warn(failedReadingManifest(puName), e); } } } } // add to common class loader List<URL> sharedlibUrls = new ArrayList<URL>(); File sharedlibDir = new File(deployPath, "shared-lib"); if (sharedlibDir.exists()) { File[] sharedlibFiles = BootIOUtils.listFiles(sharedlibDir); for (File sharedlibFile : sharedlibFiles) { sharedlibUrls.add(sharedlibFile.toURI().toURL()); } } sharedlibDir = new File(deployPath, "WEB-INF/shared-lib"); if (sharedlibDir.exists()) { File[] sharedlibFiles = BootIOUtils.listFiles(sharedlibDir); for (File sharedlibFile : sharedlibFiles) { sharedlibUrls.add(sharedlibFile.toURI().toURL()); } } if (sharedLibEnabled) { ((ServiceClassLoader) contextClassLoader).setSlashPath(deployPath.toURI().toURL()); ((ServiceClassLoader) contextClassLoader).setLibPath(libUrls.toArray(new URL[libUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Service Class Loader " + Arrays.toString(((ServiceClassLoader) contextClassLoader).getURLs()))); } commonClassLoader.addComponent(puName, sharedlibUrls.toArray(new URL[sharedlibUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Common Class Loader " + sharedlibUrls)); } } else { if (sharedlibUrls.size() > 0) { logger.warn("Using old 'shared-lib' directory, will add jars under it as if it was 'lib'"); } libUrls.addAll(sharedlibUrls); // add pu-common jar files String gsLibOpt = Locator.getLibOptional(); String gsPuCommon = System.getProperty("com.gs.pu-common", gsLibOpt + "pu-common"); final String gsLibOptSecurity = Locator.getLibOptionalSecurity(); libUrls.addAll(Arrays.asList(BootUtil.toURLs(new String[] { gsPuCommon, gsLibOptSecurity }))); if (ScalaIdentifier.isScalaLibInClassPath()) { String gsLibPlatform = Locator.getLibPlatform(); // note that we assume BootUtil.toURLs does not work recursively here // i.e, only gs-openspaces-scala.jar will be added and not all the files under /lib String gsLibPlatformScala = gsLibPlatform + "scala"; libUrls.addAll(Arrays.asList(BootUtil.toURLs(new String[] { gsLibPlatformScala }))); } if (!disableManifestClassPathJars && !disableManifestClassPathCommonPuJars) { URLClassLoader urlClassLoader = new URLClassLoader(BootUtil.toURLs(new String[] { gsPuCommon }), null /* parent */); InputStream puCommonManifestMF = urlClassLoader.getResourceAsStream(JarFile.MANIFEST_NAME); if (puCommonManifestMF != null) { List<URL> manifestClassPathComonPuJars = getManifestClassPathJars(puName, puCommonManifestMF); manifestClassPathJars.addAll(manifestClassPathComonPuJars); libUrls.addAll(manifestClassPathComonPuJars); } } ((ServiceClassLoader) contextClassLoader).setSlashPath(deployPath.toURI().toURL()); ((ServiceClassLoader) contextClassLoader).setLibPath(libUrls.toArray(new URL[libUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Service Class Loader " + Arrays.toString(((ServiceClassLoader) contextClassLoader).getURLs()))); } } try { prepareWebApplication(deployPath, clusterInfo, beanLevelProperties); } catch (Exception e) { throw new CannotCreateContainerException("Failed to bootstrap web application", e); } } else { // add to service class loader List<URL> libUrls = new ArrayList<URL>(); WebsterFile libDir = new WebsterFile(new URL(codeserver + puPath + "/lib")); File[] libFiles = libDir.listFiles(); for (int i = 0; i < libFiles.length; i++) { libUrls.add(new URL(codeserver + puPath + "/lib/" + libFiles[i].getName())); } if (!disableManifestClassPathJars) { InputStream manifestStream = readManifestFromCodeServer(puName, puPath, codeserver, workLocation); if (manifestStream != null) { manifestClassPathJars = getManifestClassPathJars(puName, manifestStream); libUrls.addAll(manifestClassPathJars); } } // add to common class loader WebsterFile sharedlibDir = new WebsterFile(new URL(codeserver + puPath + "/shared-lib")); File[] sharedlibFiles = sharedlibDir.listFiles(); List<URL> sharedlibUrls = new ArrayList<URL>(); for (File sharedlibFile : sharedlibFiles) { sharedlibUrls.add(new URL(codeserver + puPath + "/shared-lib/" + sharedlibFile.getName())); } sharedlibDir = new WebsterFile(new URL(codeserver + puPath + "/WEB-INF/shared-lib")); sharedlibFiles = sharedlibDir.listFiles(); for (File sharedlibFile : sharedlibFiles) { sharedlibUrls.add(new URL(codeserver + puPath + "/WEB-INF/shared-lib/" + sharedlibFile.getName())); } if (sharedLibEnabled) { ((ServiceClassLoader) contextClassLoader).setSlashPath(new URL(codeserver + puPath + "/")); ((ServiceClassLoader) contextClassLoader).setLibPath(libUrls.toArray(new URL[libUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Service Class Loader " + Arrays.toString(((ServiceClassLoader) contextClassLoader).getURLs()))); } commonClassLoader.addComponent(puName, sharedlibUrls.toArray(new URL[sharedlibUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Common Class Loader " + sharedlibUrls)); } } else { if (sharedlibUrls.size() > 0) { logger.warn("Using old 'shared-lib' directory, will add jars under it as if it was 'lib'"); } libUrls.addAll(sharedlibUrls); ((ServiceClassLoader) contextClassLoader).setSlashPath(new URL(codeserver + puPath + "/")); ((ServiceClassLoader) contextClassLoader).setLibPath(libUrls.toArray(new URL[libUrls.size()])); if (logger.isDebugEnabled()) { logger.debug(logMessage("Service Class Loader " + Arrays.toString(((ServiceClassLoader) contextClassLoader).getURLs()))); } } } // handle mule os if there is one class loader try { contextClassLoader.loadClass("org.mule.api.MuleContext"); ((ServiceClassLoader) contextClassLoader).addURLs(BootUtil.toURLs(new String[] { SystemInfo.singleton().locations().lib() + "/optional/openspaces/mule-os.jar" })); } catch (Throwable e) { // no mule } //apply the following only if the pu has the rest element if (springXml.contains("<os-core:rest")) { String jeeContainer = JeeProcessingUnitContainerProvider.getJeeContainer(beanLevelProperties); // pre load the jetty server class so the static shutdown thread will be loaded under it String[] classesToLoad = new String[] { "org.eclipse.jetty.server.Server" }; String jettyJars = System.getProperty("com.gigaspaces.rest.jetty", JeeProcessingUnitContainerProvider.getJeeContainerJarPath(jeeContainer)); // setup class loaders correctly try { Thread.currentThread().setContextClassLoader(CommonClassLoader.getInstance()); ((ServiceClassLoader) contextClassLoader).addURLs(BootUtil.toURLs(new String[] { jettyJars, SystemInfo.singleton().locations().lib() + "/platform/jetty/org.apache.jasper.glassfish-2.2.2.v201112011158.jar", SystemInfo.singleton().locations().lib() + "/optional/spring/spring-web-4.1.1.RELEASE.jar", SystemInfo.singleton().locations().lib() + "/optional/spring/spring-webmvc-4.1.1.RELEASE.jar", SystemInfo.singleton().locations().lib() + "/optional/jackson/jackson-core-2.3.0.jar", SystemInfo.singleton().locations().lib() + "/optional/jackson/jackson-databind-2.3.0.jar", SystemInfo.singleton().locations().lib() + "/optional/jackson/jackson-annotations-2.3.0.jar", SystemInfo.singleton().locations().lib() + "/platform/rest/xap-rest.jar" })); ((ServiceClassLoader) contextClassLoader) .setParentClassLoader(SharedServiceData.getJeeClassLoader(jeeContainer, classesToLoad)); } catch (Exception e) { throw new CannotCreateContainerException("Failed to configure class loader", e); } finally { //TODO check if we need this Thread.currentThread().setContextClassLoader(contextClassLoader); } } //apply the following only if the pu has the mapdb-blob-store element if (springXml.contains("<blob-store:mapdb-blob-store")) { String mapdbJar = System.getProperty("com.gigaspaces.blobstore.mapdb", SystemInfo.singleton().locations().lib() + "/optional/blobstore/mapdb-blobstore.jar"); Thread.currentThread().setContextClassLoader(CommonClassLoader.getInstance()); ((ServiceClassLoader) contextClassLoader).addURLs(BootUtil.toURLs(new String[] { mapdbJar })); Thread.currentThread().setContextClassLoader(contextClassLoader); } //apply the following only if the pu has the rocksdb-blob-store element if (springXml.contains("<blob-store:rocksdb-blob-store") || springXml.contains("class=\"com.gigaspaces.blobstore.rocksdb.RocksDBBlobStoreHandler\"")) { String rocksdbJar = System.getProperty("com.gigaspaces.blobstore.rocksdb", SystemInfo.singleton().locations().lib() + "/optional/blobstore/rocksdb-blobstore.jar"); Thread.currentThread().setContextClassLoader(CommonClassLoader.getInstance()); ((ServiceClassLoader) contextClassLoader).addURLs(BootUtil.toURLs(new String[] { rocksdbJar })); Thread.currentThread().setContextClassLoader(contextClassLoader); } final Map<String, String> puTags = buildPuTags(clusterInfo); MetricRegistrator puMetricRegistrator = metricManager.createRegistrator("pu", puTags); this.metricRegistrators = metricManager.registerProcessMetrics(puTags); this.metricRegistrators.add(puMetricRegistrator); for (Map.Entry<String, String> entry : puTags.entrySet()) beanLevelProperties.getContextProperties().setProperty("metrics." + entry.getKey(), entry.getValue()); //inject quiesce state changed event in order let space know to be initialized in quiesced mode if (quiesceDetails != null && quiesceDetails.getStatus() == QuiesceState.QUIESCED) { beanLevelProperties.getContextProperties().setProperty("quiesce.token", quiesceDetails.getToken().toString()); beanLevelProperties.getContextProperties().setProperty("quiesce.description", quiesceDetails.getDescription()); } factory = createContainerProvider(processingUnitContainerProviderClass); factory.setDeployPath(deployPath); factory.setClassLoader(contextClassLoader); factory.setManifestUrls(manifestClassPathJars); // only load the spring xml file if it is not a web application (if it is a web application, we will load it with the Bootstrap servlet context loader) if (webXml == null && factory instanceof ApplicationContextProcessingUnitContainerProvider) { if (StringUtils.hasText(springXml)) { // GS-9350: if this is a processing unit with gateway declarations, always try to // re-load the pu.xml to support "hot-deploy" (refresh) if (springXml.contains("os-gateway:")) { String deployPath = beanLevelProperties.getContextProperties().getProperty("deployPath"); if (StringUtils.hasText(deployPath)) { String newSpringXml = readFile(deployPath + "/META-INF/spring/pu.xml"); if (StringUtils.hasText(newSpringXml)) { springXml = newSpringXml; //override with new one } } } Resource resource = new ByteArrayResource(springXml.getBytes()); ((ApplicationContextProcessingUnitContainerProvider) factory).addConfigLocation(resource); } } factory.setClusterInfo(clusterInfo); factory.setBeanLevelProperties(beanLevelProperties); factory.setMetricRegistrator(puMetricRegistrator); container = factory.createContainer(); // set the context class loader to the web app class loader if there is one // this menas that from now on, and the exported service, will use the context class loader ClassLoader webAppClassLoader = SharedServiceData.removeWebAppClassLoader(clusterInfo.getUniqueName()); if (webAppClassLoader != null) { contextClassLoader = webAppClassLoader; } Thread.currentThread().setContextClassLoader(contextClassLoader); buildMembersAliveIndicators(); buildUndeployingEventListeners(); buildDumpProcessors(); ArrayList<Object> serviceDetails = buildServiceDetails(); buildServiceMonitors(); buildInvocableServices(); this.puDetails = new PUDetails(context.getParentServiceID(), clusterInfo, beanLevelProperties, serviceDetails.toArray(new Object[serviceDetails.size()])); if (container instanceof ApplicationContextProcessingUnitContainer) { ApplicationContext applicationContext = ((ApplicationContextProcessingUnitContainer) container) .getApplicationContext(); // inject the application context to all the monitors and schedule them // currently use the number of threads in relation to the number of monitors int numberOfThreads = watchTasks.size() / 5; if (numberOfThreads == 0) { numberOfThreads = 1; } executorService = Executors.newScheduledThreadPool(numberOfThreads); for (WatchTask watchTask : watchTasks) { if (watchTask.getMonitor() instanceof ApplicationContextMonitor) { ((ApplicationContextMonitor) watchTask.getMonitor()).setApplicationContext(applicationContext); } executorService.scheduleAtFixedRate(watchTask, watchTask.getMonitor().getPeriod(), watchTask.getMonitor().getPeriod(), TimeUnit.MILLISECONDS); } } }