List of usage examples for java.lang System getSecurityManager
public static SecurityManager getSecurityManager()
From source file:org.apache.catalina.core.ApplicationContextFacade.java
public void log(String msg) { if (System.getSecurityManager() != null) { doPrivileged("log", new Object[] { msg }); } else {//w ww. ja v a 2 s. c o m context.log(msg); } }
From source file:org.apache.catalina.core.ApplicationFilterConfig.java
/** * Release the Filter instance associated with this FilterConfig, * if there is one./*from w w w. j ava 2 s . c o m*/ */ void release() { if (this.filter != null) { if (System.getSecurityManager() != null) { try { SecurityUtil.doAsPrivilege("destroy", filter); SecurityUtil.remove(filter); } catch (java.lang.Exception ex) { log.error("ApplicationFilterConfig.doAsPrivilege", ex); } } else { filter.destroy(); } } this.filter = null; }
From source file:org.apache.jasper.runtime.PageContextImpl.java
public Object getAttribute(final String name) { if (name == null) { throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name")); }//from www . ja va 2s.com if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return doGetAttribute(name); } }); } else { return doGetAttribute(name); } }
From source file:org.apache.catalina.core.ApplicationContextFacade.java
public void log(Exception exception, String msg) { if (System.getSecurityManager() != null) { doPrivileged("log", new Class[] { Exception.class, String.class }, new Object[] { exception, msg }); } else {//from ww w . ja v a2s. c o m context.log(exception, msg); } }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param application//from w w w. jav a2s.co m * * @throws SshToolsApplicationException */ public void init(SshToolsApplication application) throws SshToolsApplicationException { super.init(application); // Additional connection tabs additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() }; // Printing page format try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } try { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { throw new IOException("Could not get print page format."); } pageFormat = job.defaultPage(); if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) { pageFormat.setOrientation( PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE)); Paper paper = new Paper(); paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0)); paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0)); pageFormat.setPaper(paper); } } catch (Exception e) { showExceptionMessage("Error", e.getMessage()); } } catch (AccessControlException ace) { ace.printStackTrace(); } enableEvents(VDU_EVENTS); // Set up the actions initActions(); // Create the status bar statusBar = new StatusBar(); dataListener = new DataNotificationListener(statusBar); // Create our terminal emulation object try { emulation = createEmulation(); } catch (IOException ioe) { throw new SshToolsApplicationException(ioe); } emulation.addTerminalListener(this); // Set a scrollbar for the terminal - doesn't seem to be as simple as this scrollBar = new JScrollBar(JScrollBar.VERTICAL); emulation.setBufferSize(1000); // Create our swing terminal and add it to the main frame terminal = new TerminalPanel(emulation) { public void processEvent(AWTEvent evt) { /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */ if (evt instanceof MouseEvent && evt.getID() == 507) { try { Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {}); SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue() + (SshTermSessionPanel.this.scrollBar.getUnitIncrement() * ((Integer) m.invoke(evt, new Object[] {})).intValue() * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1))); } catch (Throwable t) { } } else { super.processEvent(evt); } } public void copyNotify() { copyAction.actionPerformed(null); } }; terminal.requestFocus(); terminal.setScrollbar(scrollBar); terminal.addMouseMotionListener(this); //terminal.addMouseWheelListener(this); // Center panel with terminal and scrollbar JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.red); center.add(terminal, BorderLayout.CENTER); center.add(scrollBar, BorderLayout.EAST); // Show the context menu on mouse button 3 (right click) terminal.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) { getContextMenu().setLabel(getApplication().getApplicationName()); getContextMenu().show(terminal, evt.getX(), evt.getY()); } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) { pasteAction.actionPerformed(null); } } }); // // JPanel top = new JPanel(new BorderLayout()); // top.add(getJMenuBar(), BorderLayout.NORTH); // top.add(north, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(center, BorderLayout.CENTER); // add(top, BorderLayout.NORTH); // Make sure that the swing terminal has focus terminal.requestFocus(); }
From source file:com.cisco.dvbu.ps.deploytool.dao.wsapi.ArchiveWSDAOImpl.java
public void takeArchiveAction(String actionName, ArchiveType archive, String serverId, String pathToServersXML, String prefix, String propertyFile) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug(/*from w ww . ja v a 2s .c o m*/ "ArchiveWSDAOImpl.takeArchiveAction(actionName, archive, serverId, pathToServersXML, prefix, propertyFile). actionName=" + actionName + " archive object=" + archive.toString() + " serverId=" + serverId + " pathToServersXML=" + pathToServersXML + " prefix=" + prefix + " propertyFile=" + propertyFile); } // Set the debug options setDebug(); // Read target server properties from xml and build target server object based on target server name CompositeServer targetServer = WsApiHelperObjects.getServerLogger(serverId, pathToServersXML, "ArchiveWSDAOImpl.takeArchiveAction(" + actionName + ")", logger); // // DA@20120610 Comment unnecessary ping - if server is down the backup/restore command will fail as fast as ping // Ping the Server to make sure it is alive and the values are correct. // WsApiHelperObjects.pingServer(targetServer, true); // Get the offset location of the java.policy file [offset from PDTool home]. String javaPolicyOffset = CommonConstants.javaPolicy; String javaPolicyLocation = CommonUtils.extractVariable(prefix, CommonUtils.getFileOrSystemPropertyValue(propertyFile, "PROJECT_HOME_PHYSICAL"), propertyFile, true) + javaPolicyOffset; String identifier = "ArchiveWSDAOImpl.takeArchiveAction"; // some unique identifier that characterizes this invocation. try { if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput(":: executing action: " + actionName, prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: executing action: "+actionName); } List<String> argsList = getCommonArchiveParameters(archive, targetServer); if (actionName.equalsIgnoreCase(ArchiveDAO.action.IMPORT.name())) { // pkg_import boolean archiveISNULL = false; if (archive == null) archiveISNULL = true; if (logger.isDebugEnabled() || debug3) { CommonUtils .writeOutput( identifier + ":: " + ArchiveDAO.action.IMPORT.name().toString() + " archiveISNULL=[" + archiveISNULL + "]", prefix, "-debug3", logger, debug1, debug2, debug3); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. // If so then force a no operation to happen by performing a -printcontents for pkg_import if (!CommonUtils.isExecOperation() || (archive.isPrintcontents() != null && !archive.isPrintcontents())) archive.setPrintcontents(true); // Construct the variable input for pacakged import List<String> parms = getPackageImportParameters(archive); argsList.addAll(parms); String[] args = argsList.toArray(new String[0]); String maskedArgList = CommonUtils.getArgumentListMasked(argsList); if (logger.isDebugEnabled() || debug3) { CommonUtils .writeOutput( identifier + ":: " + ArchiveDAO.action.IMPORT.name().toString() + " argument list=[" + maskedArgList + "]", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: "+ArchiveDAO.action.IMPORT.name().toString()+" argument list=[" + maskedArgList+"]" ); } /* * 2014-02-14 (mtinius): Removed the PDTool Archive capability */ // ImportCommand.startCommand(".", ".", args); /* * 2014-02-14 (mtinius): Added security manager around the Composite native Archive code because * it has System.out.println and System.exit commands. Need to trap both. */ // Get the existing security manager SecurityManager sm = System.getSecurityManager(); PrintStream originalOut = System.out; PrintStream originalErr = System.err; String command = "ImportCommand.startCommand"; try { // Set the java security policy System.getProperties().setProperty("java.security.policy", javaPolicyLocation); // Create a new System.out Logger Logger importLogger = Logger.getLogger(ImportCommand.class); System.setOut(new PrintStream(new LogOutputStream(importLogger, Level.INFO))); System.setErr(new PrintStream(new LogOutputStream(importLogger, Level.ERROR))); // Create a new security manager System.setSecurityManager(new NoExitSecurityManager()); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Invoking ImportCommand.startCommand(\".\", \".\", args)."); } // Invoke the Composite native import command. ImportCommand.startCommand(".", ".", args); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Successfully imported."); } } catch (NoExitSecurityExceptionStatusNonZero nesesnz) { String error = identifier + ":: Exited with exception from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")"; logger.error(error); throw new CompositeException(error); } catch (NoExitSecurityExceptionStatusZero nesezero) { if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput( identifier + ":: Exited successfully from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: Exited successfully from System.exit(): "+command+"(\".\", \".\", "+maskedArgList+")"); } } finally { System.setSecurityManager(sm); System.setOut(originalOut); System.setErr(originalErr); } } else if (actionName.equalsIgnoreCase(ArchiveDAO.action.RESTORE.name())) { // backup_import // Construct the variable input for backup import List<String> parms = getBackupImportParameters(archive); argsList.addAll(parms); String[] args = argsList.toArray(new String[0]); String maskedArgList = CommonUtils.getArgumentListMasked(argsList); if (logger.isDebugEnabled() || debug3) { CommonUtils .writeOutput( identifier + ":: " + ArchiveDAO.action.RESTORE.name().toString() + " argument list=[" + maskedArgList + "]", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: "+ArchiveDAO.action.RESTORE.name().toString()+" argument list=[" + maskedArgList+"]" ); } /* * 2014-02-14 (mtinius): Removed the PDTool Archive capability */ // RestoreCommand.startCommand(".", ".", args) ; /* * 2014-02-14 (mtinius): Added security manager around the Composite native Archive code because * it has System.out.println and System.exit commands. Need to trap both. */ // Get the existing security manager SecurityManager sm = System.getSecurityManager(); PrintStream originalOut = System.out; PrintStream originalErr = System.err; String command = "RestoreCommand.startCommand"; try { // Set the java security policy System.getProperties().setProperty("java.security.policy", javaPolicyLocation); // Create a new System.out Logger Logger restoreLogger = Logger.getLogger(RestoreCommand.class); System.setOut(new PrintStream(new LogOutputStream(restoreLogger, Level.INFO))); System.setErr(new PrintStream(new LogOutputStream(restoreLogger, Level.ERROR))); // Create a new security manager System.setSecurityManager(new NoExitSecurityManager()); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Invoking RestoreCommand.startCommand(\".\", \".\", args)."); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { // Invoke the Composite native restore command. RestoreCommand.startCommand(".", ".", args); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Successfully restored."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } catch (NoExitSecurityExceptionStatusNonZero nesesnz) { String error = identifier + ":: Exited with exception from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")"; logger.error(error); throw new CompositeException(error); } catch (NoExitSecurityExceptionStatusZero nesezero) { if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput( identifier + ":: Exited successfully from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: Exited successfully from System.exit(): "+command+"(\".\", \".\", "+maskedArgList+")"); } } finally { System.setSecurityManager(sm); System.setOut(originalOut); System.setErr(originalErr); } } else if (actionName.equalsIgnoreCase(ArchiveDAO.action.EXPORT.name())) { // pkg_export List<String> parms = getPackageExportParameters(archive); argsList.addAll(parms); String[] args = argsList.toArray(new String[0]); String maskedArgList = CommonUtils.getArgumentListMasked(argsList); if (logger.isDebugEnabled() || debug3) { CommonUtils .writeOutput( identifier + ":: " + ArchiveDAO.action.EXPORT.name().toString() + " argument list=[" + maskedArgList + "]", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: "+ArchiveDAO.action.EXPORT.name().toString()+" argument list=[" + maskedArgList+"]" ); } /* * 2014-02-14 (mtinius): Removed the PDTool Archive capability */ // ExportCommand.startCommand(".", ".", args); /* * 2014-02-14 (mtinius): Added security manager around the Composite native Archive code because * it has System.out.println and System.exit commands. Need to trap both. */ // Get the existing security manager SecurityManager sm = System.getSecurityManager(); PrintStream originalOut = System.out; PrintStream originalErr = System.err; String command = "ExportCommand.startCommand"; try { // Set the java security policy System.getProperties().setProperty("java.security.policy", javaPolicyLocation); // Create a new System.out Logger Logger exportLogger = Logger.getLogger(ExportCommand.class); System.setOut(new PrintStream(new LogOutputStream(exportLogger, Level.INFO))); System.setErr(new PrintStream(new LogOutputStream(exportLogger, Level.ERROR))); // Create a new security manager System.setSecurityManager(new NoExitSecurityManager()); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Invoking ExportCommand.startCommand(\".\", \".\", args)."); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { // Invoke the Composite native export command. ExportCommand.startCommand(".", ".", args); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Successfully exported."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } catch (NoExitSecurityExceptionStatusNonZero nesesnz) { String error = identifier + ":: Exited with exception from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")"; logger.error(error); throw new CompositeException(error); } catch (NoExitSecurityExceptionStatusZero nesezero) { if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput( identifier + ":: Exited successfully from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: Exited successfully from System.exit(): "+command+"(\".\", \".\", "+maskedArgList+")"); } } finally { System.setSecurityManager(sm); System.setOut(originalOut); System.setErr(originalErr); } } else if (actionName.equalsIgnoreCase(ArchiveDAO.action.BACKUP.name())) { // backup_export List<String> parms = getBackupExportParameters(archive); argsList.addAll(parms); String[] args = argsList.toArray(new String[0]); String maskedArgList = CommonUtils.getArgumentListMasked(argsList); if (logger.isDebugEnabled() || debug3) { CommonUtils .writeOutput( identifier + ":: " + ArchiveDAO.action.BACKUP.name().toString() + " argument list=[" + maskedArgList + "]", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: "+ArchiveDAO.action.BACKUP.name().toString()+" argument list=[" + maskedArgList+"]" ); } /* * 2014-02-14 (mtinius): Removed the PDTool Archive capability */ // BackupCommand.startCommand(".", ".", args); /* * 2014-02-14 (mtinius): Added security manager around the Composite native Archive code because * it has System.out.println and System.exit commands. Need to trap both. */ // Get the existing security manager SecurityManager sm = System.getSecurityManager(); PrintStream originalOut = System.out; PrintStream originalErr = System.err; String command = "BackupCommand.startCommand"; try { // Set the java security policy System.getProperties().setProperty("java.security.policy", javaPolicyLocation); // Create a new System.out Logger Logger backupLogger = Logger.getLogger(BackupCommand.class); System.setOut(new PrintStream(new LogOutputStream(backupLogger, Level.INFO))); System.setErr(new PrintStream(new LogOutputStream(backupLogger, Level.ERROR))); // Create a new security manager System.setSecurityManager(new NoExitSecurityManager()); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Invoking BackupCommand.startCommand(\".\", \".\", args)."); } // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation. if (CommonUtils.isExecOperation()) { // Invoke the Composite native backup command. BackupCommand.startCommand(".", ".", args); if (logger.isDebugEnabled()) { logger.debug(identifier + "(). Successfully backed up."); } } else { logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName + "] WAS NOT PERFORMED.\n"); } } catch (NoExitSecurityExceptionStatusNonZero nesesnz) { String error = identifier + ":: Exited with exception from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")"; logger.error(error); throw new CompositeException(error); } catch (NoExitSecurityExceptionStatusZero nesezero) { if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput( identifier + ":: Exited successfully from System.exit(): " + command + "(\".\", \".\", " + maskedArgList + ")", prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: Exited successfully from System.exit(): "+command+"(\".\", \".\", "+maskedArgList+")"); } } finally { System.setSecurityManager(sm); System.setOut(originalOut); System.setErr(originalErr); } } if (logger.isDebugEnabled() || debug3) { CommonUtils.writeOutput(identifier + ":: completed " + actionName, prefix, "-debug3", logger, debug1, debug2, debug3); //logger.debug(identifier+":: completed " + actionName ); } } // TO DO: Implement specific catch clauses based on implementation catch (Exception e) { // TODO: Be more specific about error messages being returned // TODO: null - this is where soap-faults get passed - modify if you return a soap-fault (e.g. e.getFaultInfo()) if (e.getCause() != null && e.getCause() instanceof WebapiException) { // CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), actionName, "Archive", identifier, targetServer),e.getCause()); CompositeLogger.logException(e.getCause(), DeployUtil.constructMessage( DeployUtil.MessageType.ERROR.name(), actionName, "Archive", identifier, targetServer)); } else { CompositeLogger.logException(e, DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), actionName, "Archive", identifier, targetServer)); } throw new ApplicationException(e.getMessage(), e); } }
From source file:org.apache.catalina.core.ApplicationContextFacade.java
public void log(String message, Throwable throwable) { if (System.getSecurityManager() != null) { doPrivileged("log", new Class[] { String.class, Throwable.class }, new Object[] { message, throwable }); } else {/*from w w w.j a v a 2s . co m*/ context.log(message, throwable); } }
From source file:org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver.java
/** * Special classpath method. Will try to detect the imported bundles (which are part of the classpath) and look for * resources in all of them. This implementation will try to determine the bundles that compose the current bundle * classpath and then it will inspect the bundle space of each of them individually. * //from w ww .j a v a2s .c o m * <p/> Since the bundle space is considered, runtime classpath entries such as dynamic imports are not supported * (yet). * * @param locationPattern * @param type * @return classpath resources */ @SuppressWarnings("unchecked") private Resource[] findClassPathMatchingResources(String locationPattern, int type) throws IOException { if (resolver == null) throw new IllegalArgumentException( "PackageAdmin service/a started bundle is required for classpath matching"); final ImportedBundle[] importedBundles = resolver.getImportedBundles(bundle); // eliminate classpath path final String path = OsgiResourceUtils.stripPrefix(locationPattern); final Collection<String> foundPaths = new LinkedHashSet<String>(); // 1. search the imported packages // find folder path matching final String rootDirPath = determineFolderPattern(path); if (System.getSecurityManager() != null) { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws IOException { for (int i = 0; i < importedBundles.length; i++) { final ImportedBundle importedBundle = importedBundles[i]; if (!bundle.equals(importedBundle.getBundle())) { findImportedBundleMatchingResource(importedBundle, rootDirPath, path, foundPaths); } } return null; } }); } catch (PrivilegedActionException pe) { throw (IOException) pe.getException(); } } else { for (int i = 0; i < importedBundles.length; i++) { final ImportedBundle importedBundle = importedBundles[i]; if (!bundle.equals(importedBundle.getBundle())) { findImportedBundleMatchingResource(importedBundle, rootDirPath, path, foundPaths); } } } // 2. search the target bundle findSyntheticClassPathMatchingResource(bundle, path, foundPaths); // 3. resolve the entries using the official class-path method (as some of them might be hidden) List<Resource> resources = new ArrayList<Resource>(foundPaths.size()); for (String resourcePath : foundPaths) { // classpath*: -> getResources() if (OsgiResourceUtils.PREFIX_TYPE_CLASS_ALL_SPACE == type) { CollectionUtils.mergeArrayIntoCollection( convertURLEnumerationToResourceArray(bundle.getResources(resourcePath), resourcePath), resources); } // classpath -> getResource() else { URL url = bundle.getResource(resourcePath); if (url != null) resources.add(new UrlContextResource(url, resourcePath)); } } if (logger.isTraceEnabled()) { logger.trace("Fitered " + foundPaths + " to " + resources); } return (Resource[]) resources.toArray(new Resource[resources.size()]); }
From source file:org.apache.jasper.runtime.PageContextImpl.java
public Object getAttribute(final String name, final int scope) { if (name == null) { throw new NullPointerException(Localizer.getMessage("jsp.error.attribute.null_name")); }// w w w .jav a 2s. co m if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return doGetAttribute(name, scope); } }); } else { return doGetAttribute(name, scope); } }
From source file:org.pepstock.jem.ant.tasks.StepListener.java
/** * Called by ANT engine when a step is started.<br> * Notifies to JEM the current step in execution to save inside of JEM job * instance./*from w w w. ja va 2s. c o m*/ * * @param event ANT event */ @Override public void targetStarted(BuildEvent event) { // checks if is the first step // if yes, does many activities: // - loading all targets and task // - prepares for resources locking if (isFirst) { // sets locking scope setLockingScope(event.getProject()); event.getProject().log(AntMessage.JEMA033I.toMessage().getFormattedMessage(lockingScope)); // if Job scope is set, loads all items to lock resources if (isJobLockingScope()) { loadForLock(event.getProject()); // check procedure checkProcedure(); try { locker.lock(); } catch (AntException e) { throw new BuildException(e); } } isFirst = false; } // if step locking is set, then locks resources // loading tasks info if (isStepLockingScope()) { loadForLock(event.getTarget()); checkProcedure(); try { locker.lock(); } catch (AntException e) { throw new BuildException(e); } } AntBatchSecurityManager batchSM = (AntBatchSecurityManager) System.getSecurityManager(); batchSM.setInternalAction(true); // checks if the target name is empty. if yes, does nothing if (!"".equals(event.getTarget().getName())) { try { // creates object to send to JEM Step step = new Step(); // sets step name and description step.setName(event.getTarget().getName()); step.setDescription(event.getTarget().getDescription()); // send to JEM by RMI door.setStepStarted(JobId.VALUE, step); } catch (RemoteException e) { throw new BuildException(e.getMessage(), e); } finally { batchSM.setInternalAction(false); } } batchSM.setInternalAction(false); }