Example usage for javax.jms MapMessage setBooleanProperty

List of usage examples for javax.jms MapMessage setBooleanProperty

Introduction

In this page you can find the example usage for javax.jms MapMessage setBooleanProperty.

Prototype


void setBooleanProperty(String name, boolean value) throws JMSException;

Source Link

Document

Sets a boolean property value with the specified name into the message.

Usage

From source file:org.jwebsocket.plugins.scripting.ScriptingPlugIn.java

/**
 * Reload a deployed script application.
 *
 * @param aConnector//from w w w.  j  a va 2 s.  c  o m
 * @param aToken
 * @throws Exception
 */
public void reloadAppAction(WebSocketConnector aConnector, Token aToken) throws Exception {
    String lAppName = aToken.getString("app");
    boolean lHotReload = aToken.getBoolean("hotReload", true);

    Assert.notNull(lAppName, "The 'app' argument cannot be null!");
    Assert.isTrue(mSettings.getApps().containsKey(lAppName),
            "The target application '" + lAppName + "' does not exists!");

    if (!hasAuthority(aConnector, NS + ".reloadApp.*")
            && !hasAuthority(aConnector, NS + ".reloadApp." + lAppName)) {
        sendToken(aConnector, createAccessDenied(aToken));
        return;
    }

    // loading the app
    String lAppPath = mSettings.getApps().get(lAppName);
    execAppBeforeLoadChecks(lAppName, lAppPath);
    loadApp(lAppName, lAppPath, lHotReload);

    // broadcasting event to other ScriptingPlugIn nodes
    MapMessage lMessage = getServer().getJMSManager().buildMessage(NS, ClusterMessageTypes.LOAD_APP.name());
    lMessage.setStringProperty("appName", lAppName);
    lMessage.setBooleanProperty("hotLoad", lHotReload);
    lMessage.setStringProperty(Attributes.NODE_ID, JWebSocketConfig.getConfig().getNodeId());

    // sending the message
    getServer().getJMSManager().send(lMessage);

    sendToken(aConnector, createResponse(aToken));
}

From source file:org.jwebsocket.plugins.scripting.ScriptingPlugIn.java

/**
 * Deploy an application/*from  w w  w.j  av a  2  s.co  m*/
 *
 * @param aConnector
 * @param aToken
 * @throws Exception
 */
public void deployAction(WebSocketConnector aConnector, Token aToken) throws Exception {
    // getting calling arguments
    String lAppFile = aToken.getString("appFile");
    boolean lDeleteAfterDeploy = aToken.getBoolean("deleteAfterDeploy", false);
    boolean lHotDeploy = aToken.getBoolean("hotDeploy", false);

    // getting the FSP instance
    TokenPlugIn lFSP = (TokenPlugIn) getPlugInChain().getPlugIn("jws.filesystem");
    Assert.notNull(lFSP, "FileSystem plug-in is not running!");

    // creating invoke request for FSP
    Token lCommand = TokenFactory.createToken(JWebSocketServerConstants.NS_BASE + ".plugins.filesystem",
            "getAliasPath");
    lCommand.setString("alias", "privateDir");
    Token lResult = lFSP.invoke(aConnector, lCommand);
    Assert.notNull(lResult,
            "Unable to communicate with the FileSystem plug-in " + "to retrieve the client private directory!");

    // locating the app zip file
    File lAppZipFile = new File(lResult.getString("aliasPath") + File.separator + lAppFile);
    Assert.isTrue(lAppZipFile.exists(), "The target application file '" + lAppFile + "' does not exists"
            + " on the user file-system scope!");

    // validating MIME type
    String lFileType = new MimetypesFileTypeMap().getContentType(lAppZipFile);
    Assert.isTrue("application/zip, application/octet-stream".contains(lFileType),
            "The file format is not valid! Expecting a ZIP compressed directory.");

    // umcompressing in TEMP unique folder
    File lTempDir = new File(FileUtils.getTempDirectory().getCanonicalPath() + File.separator
            + UUID.randomUUID().toString() + File.separator);

    try {
        Tools.unzip(lAppZipFile, lTempDir);
        if (lDeleteAfterDeploy) {
            lAppZipFile.delete();
        }
    } catch (IOException lEx) {
        throw new Exception("Unable to uncompress zip file: " + lEx.getMessage());
    }

    // validating structure
    File[] lTempAppDirContent = lTempDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
    Assert.isTrue(1 == lTempAppDirContent.length && lTempAppDirContent[0].isDirectory(),
            "Compressed application has invalid directory structure! " + "Expecting a single root folder.");

    // executing before-load checks
    execAppBeforeLoadChecks(lTempAppDirContent[0].getName(), lTempAppDirContent[0].getPath());

    // copying application content to apps directory
    File lAppDir = new File(mSettings.getAppsDirectory() + File.separator + lTempAppDirContent[0].getName());

    FileUtils.copyDirectory(lTempAppDirContent[0], lAppDir);
    FileUtils.deleteDirectory(lTempDir);

    // getting the application name
    String lAppName = lAppDir.getName();

    // checking security
    if (!hasAuthority(aConnector, NS + ".deploy.*") && !hasAuthority(aConnector, NS + ".deploy." + lAppName)) {
        sendToken(aConnector, createAccessDenied(aToken));
        return;
    }

    // loading the script app
    loadApp(lAppName, lAppDir.getAbsolutePath(), lHotDeploy);

    // broadcasting event to other ScriptingPlugIn nodes
    MapMessage lMessage = getServer().getJMSManager().buildMessage(NS, ClusterMessageTypes.LOAD_APP.name());
    lMessage.setStringProperty("appName", lAppName);
    lMessage.setBooleanProperty("hotLoad", lHotDeploy);
    lMessage.setStringProperty(Attributes.NODE_ID, JWebSocketConfig.getConfig().getNodeId());

    // sending the message
    getServer().getJMSManager().send(lMessage);

    // finally send acknowledge response
    sendToken(aConnector, createResponse(aToken));
}

From source file:org.jwebsocket.plugins.system.SystemPlugIn.java

void notifySessionStopped(WebSocketSession aSession) {
    try {//  w w  w.  ja v  a2s  .com
        // getting the message hub
        JMSManager lMessageHub = getServer().getJMSManager();

        // creating the event message to be sent
        MapMessage lMsg = lMessageHub.buildMessage(getNamespace(), "sessionStopped");
        lMsg.setStringProperty("username", aSession.getUsername());
        lMsg.setStringProperty("uuid", aSession.getUUID());
        lMsg.setBooleanProperty("authenticated", aSession.isAuthenticated());
        lMsg.setStringProperty("authorities", (String) aSession.getStorage().get(SystemPlugIn.AUTHORITIES));

        // sending event
        lMessageHub.send(lMsg);
    } catch (Exception lEx) {
        mLog.error(Logging.getSimpleExceptionMessage(lEx,
                "notifying 'sessionStopped' " + "event through the MessageHub"), lEx);
    }
}