All Downloads are FREE. Search and download functionalities are using the official Maven repository.

en-US.Section-Source_Profile.xml Maven / Gradle / Ivy

The newest version!
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "JAIN_SLEE_Example_User_Guide.ent">
%BOOK_ENTITIES;
]>

<section id="source_profile">
	<title>Profile Specification Source</title>
	<para>
	&THIS.EXAMPLE;
		profile specification is not complicated. It is designed only as
		simple service data container.
		It does not perform any other tasks.
	</para>
	<para>Profile
		specification descriptor for &THIS.EXAMPLE;
		declares following values:
	</para>
	<itemizedlist>
		<listitem>
			<para>Profile ID - that is name,vendor and version.</para>
		</listitem>
		<listitem>
			<para>
				profile
				<acronym>CMP</acronym>
				interface
			</para>
		</listitem>
		<listitem>
			<para>
				profile abstract class
			</para>
		</listitem>
	</itemizedlist>

	<section id="descriptor">
		<title>Profile descriptor</title>
		<para>Descriptor look as follows:</para>
		<programlisting language="XML" role="XML"><![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE profile-spec-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE Profile Specification 1.1//EN" "http://java.sun.com/dtd/slee-profile-spec-jar_1_1.dtd">
<profile-spec-jar>
	<profile-spec>
		<description />
		<profile-spec-name>CallControlProfileCMP</profile-spec-name>
		<profile-spec-vendor>org.mobicents</profile-spec-vendor>
		<profile-spec-version>0.1</profile-spec-version>
		
		<profile-classes>
			<profile-cmp-interface>
				<profile-cmp-interface-name>
					org.mobicents.slee.examples.callcontrol.profile.CallControlProfileCMP
				</profile-cmp-interface-name>
				<!-- <profile-index unique="True">userAddress</profile-index>  -->
				<cmp-field>
				<cmp-field-name>userAddress</cmp-field-name>
					<index-hint query-operator="equals"/>
				</cmp-field>
			</profile-cmp-interface>
			<profile-abstract-class>
				<profile-abstract-class-name>
					org.mobicents.slee.examples.callcontrol.profile.CallControlProfileManagementImpl
				</profile-abstract-class-name>
			</profile-abstract-class>
		</profile-classes>
		
	</profile-spec>
</profile-spec-jar>
		]]>
		</programlisting>

	</section>
	<section id="source">
		<title>Profile interface and management</title>
		<para>
			Profile data can be accessed and modified with profile
			<acronym>CMP</acronym>
			interface. It is interface exposed to
			<acronym>JSLEE</acronym>
			components.
			It is defined as follows:
		</para>
		<programlisting role="JAVA" language="Java">
package org.mobicents.slee.examples.callcontrol.profile;

import javax.slee.Address;

public interface CallControlProfileCMP {
	// 'userAddress' CMP field setter
	public abstract void setUserAddress(Address value);
	// 'userAddress' CMP field getter
	public abstract Address getUserAddress();

	// 'blockedAddresses' CMP field setter
	public abstract void setBlockedAddresses(Address[] value);
	// 'blockedAddresses' CMP field getter
	public abstract Address[] getBlockedAddresses();

	// 'backupAddress' CMP field setter
	public abstract void setBackupAddress(Address value);
	// 'backupAddress' CMP field getter
	public abstract Address getBackupAddress();

	// 'voicemailState' CMP field setter
	public abstract void setVoicemailState(boolean value);
	// 'voicemailState' CMP field getter
	public abstract boolean getVoicemailState();
}
		</programlisting>
		<para>
			Profile abstract class implements custom logic to handle profile data
			and
			<acronym>JSLEE</acronym>
			callback methods for management operations. This class becomes part of profile object implementation. It allows to control some aspects of profile and its data.
		</para>
		<para>&THIS.EXAMPLE;
			profile abstract class performs following operations:
		</para>
		<itemizedlist>
			<listitem>
				<para>initialize profile with defailt values</para>
			</listitem>
			<listitem>
				<para>verify data constrains</para>
			</listitem>
		</itemizedlist>
		<para>It is defined as follows:</para>
		<programlisting role="JAVA" language="Java">
import javax.slee.Address;
import javax.slee.AddressPlan;
import javax.slee.CreateException;
import javax.slee.profile.Profile;
import javax.slee.profile.ProfileContext;

import javax.slee.profile.ProfileVerificationException;


public abstract class CallControlProfileManagementImpl implements Profile,
		CallControlProfileCMP {

	private ProfileContext profileCtx;

	/**
	 * Initialize the profile with its default values.
	 */
	public void profileInitialize() {
		setUserAddress(null);
		setBlockedAddresses(null);
		setBackupAddress(null);
		setVoicemailState(false);
	}

	public void profileLoad() {
	}

	public void profileStore() {
	}

	/**
	 * Verify the profile's CMP field settings.
	 * 
	 * @throws ProfileVerificationException
	 *             if any CMP field contains an invalid value
	 */
	public void profileVerify() throws ProfileVerificationException {
		// Verify Called User Address
		Address address = getUserAddress();
		if (address != null)
			verifyAddress(address);
		// Verify Blocked Addresses
		Address[] blockedAddresses = getBlockedAddresses();
		if (blockedAddresses != null) {
			for (int i = 0; i &lt; blockedAddresses.length; i++) {
				if (blockedAddresses[i] != null)
					verifyAddress(blockedAddresses[i]);
			}
		}
		// Verify Backup Address
		Address backupAddress = getBackupAddress();
		if (backupAddress != null)
			verifyAddress(backupAddress);
	}

	public void verifyAddress(Address address)
			throws ProfileVerificationException {
		// Check address plan
		if (address.getAddressPlan() != AddressPlan.SIP)
			throw new ProfileVerificationException("Address \"" + address
					+ "\" is not a SIP address");
		// Check URI scheme - must be sip: or sips:
		String uri = address.getAddressString().toLowerCase();
		if (!(uri.startsWith("sip:") || uri.startsWith("sips:")))
			throw new ProfileVerificationException("Address \"" + address
					+ "\" is not a SIP address");
	}

	public void profileActivate() {


	}

	public void profilePassivate() {


	}

	public void profilePostCreate() throws CreateException {


	}

	public void profileRemove() {

	}

	public void setProfileContext(ProfileContext ctx) {
		this.profileCtx = ctx;
	}

	public void unsetProfileContext() {
		this.profileCtx = null;
	}

}
		</programlisting>
		
	</section>
			
		
</section>	




© 2015 - 2024 Weber Informatics LLC | Privacy Policy