Search in sources :

Example 6 with IllegalStateException

use of java.lang.IllegalStateException in project karaf by apache.

the class JmsServiceImpl method delete.

@Override
public void delete(String name) throws Exception {
    Path connectionFactoryFile = getConnectionFactoryFile(name);
    if (!Files.isRegularFile(connectionFactoryFile)) {
        throw new IllegalStateException("The JMS connection factory file " + connectionFactoryFile + " doesn't exist");
    }
    Files.delete(connectionFactoryFile);
}
Also used : Path(java.nio.file.Path) IllegalStateException(java.lang.IllegalStateException)

Example 7 with IllegalStateException

use of java.lang.IllegalStateException in project karaf by apache.

the class JmsServiceImpl method create.

@Override
public void create(String name, String type, String url, String username, String password) throws Exception {
    if (!type.equalsIgnoreCase("activemq") && !type.equalsIgnoreCase("artemis") && !type.equalsIgnoreCase("webspheremq")) {
        throw new IllegalArgumentException("JMS connection factory type not known");
    }
    Path outFile = getConnectionFactoryFile(name);
    String template;
    HashMap<String, String> properties = new HashMap<>();
    properties.put("name", name);
    if (type.equalsIgnoreCase("activemq")) {
        // activemq
        properties.put("url", url);
        properties.put("username", username);
        properties.put("password", password);
        template = "connectionfactory-activemq.xml";
    } else if (type.equalsIgnoreCase("artemis")) {
        // artemis
        properties.put("url", url);
        properties.put("username", username);
        properties.put("password", password);
        template = "connectionfactory-artemis.xml";
    } else {
        // webspheremq
        String[] splitted = url.split("/");
        if (splitted.length != 4) {
            throw new IllegalStateException("WebsphereMQ URI should be in the following format: host/port/queuemanager/channel");
        }
        properties.put("host", splitted[0]);
        properties.put("port", splitted[1]);
        properties.put("queuemanager", splitted[2]);
        properties.put("channel", splitted[3]);
        template = "connectionfactory-webspheremq.xml";
    }
    InputStream is = this.getClass().getResourceAsStream(template);
    if (is == null) {
        throw new IllegalArgumentException("Template resource " + template + " doesn't exist");
    }
    TemplateUtils.createFromTemplate(outFile.toFile(), is, properties);
}
Also used : Path(java.nio.file.Path) IllegalStateException(java.lang.IllegalStateException)

Example 8 with IllegalStateException

use of java.lang.IllegalStateException in project OpenAM by OpenRock.

the class TokenBlobUtils method getBlobAsString.

/**
     * Retrieve the blob data of the Token in String format.
     *
     * @param token Non null.
     * @return maybe null if the Token has not binary data assigned.
     * @throws IllegalStateException If there was a problem decoding the string.
     */
public String getBlobAsString(Token token) {
    Reject.ifNull(token);
    byte[] blob = token.getBlob();
    if (blob == null) {
        return null;
    }
    try {
        return toUTF8(blob);
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException("Failed to decode blob to " + ENCODING, e);
    }
}
Also used : IllegalStateException(java.lang.IllegalStateException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 9 with IllegalStateException

use of java.lang.IllegalStateException in project XobotOS by xamarin.

the class AudioTrack method play.

//---------------------------------------------------------
// Transport control methods
//--------------------
/**
     * Starts playing an AudioTrack.
     *
     * @throws IllegalStateException
     */
public void play() throws IllegalStateException {
    if (mState != STATE_INITIALIZED) {
        throw (new IllegalStateException("play() called on uninitialized AudioTrack."));
    }
    synchronized (mPlayStateLock) {
        native_start();
        mPlayState = PLAYSTATE_PLAYING;
    }
}
Also used : IllegalStateException(java.lang.IllegalStateException)

Example 10 with IllegalStateException

use of java.lang.IllegalStateException in project XobotOS by xamarin.

the class AudioTrack method pause.

/**
     * Pauses the playback of the audio data. Data that has not been played
     * back will not be discarded. Subsequent calls to {@link #play} will play
     * this data back.
     *
     * @throws IllegalStateException
     */
public void pause() throws IllegalStateException {
    if (mState != STATE_INITIALIZED) {
        throw (new IllegalStateException("pause() called on uninitialized AudioTrack."));
    }
    // pause playback
    synchronized (mPlayStateLock) {
        native_pause();
        mPlayState = PLAYSTATE_PAUSED;
    }
}
Also used : IllegalStateException(java.lang.IllegalStateException)

Aggregations

IllegalStateException (java.lang.IllegalStateException)11 RemoteException (android.os.RemoteException)3 SparseArray (android.util.SparseArray)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1