org.asteriskjava.pbx.PBXFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of asterisk-java Show documentation
Show all versions of asterisk-java Show documentation
The free Java library for Asterisk PBX integration.
The newest version!
package org.asteriskjava.pbx;
import org.asteriskjava.pbx.internal.core.AsteriskPBX;
import java.util.concurrent.atomic.AtomicReference;
public class PBXFactory {
public static PBX getActivePBX() {
return AsteriskPBX.SELF;
}
final static AtomicReference profile = new AtomicReference<>();
public static void init(AsteriskSettings newProfile) {
profile.set(newProfile);
getActivePBX().performPostCreationTasks();
}
public static AsteriskSettings getActiveProfile() {
AsteriskSettings activeProfile = profile.get();
if (activeProfile == null) {
throw new RuntimeException(
"you must call setAsteriskSettings() before getActiveProfile() is called the first time");
}
return activeProfile;
}
}