001: /*
002: * Portions Copyright 2000-2007 Sun Microsystems, Inc. All Rights
003: * Reserved. Use is subject to license terms.
004: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License version
008: * 2 only, as published by the Free Software Foundation.
009: *
010: * This program is distributed in the hope that it will be useful, but
011: * WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * General Public License version 2 for more details (a copy is
014: * included at /legal/license.txt).
015: *
016: * You should have received a copy of the GNU General Public License
017: * version 2 along with this work; if not, write to the Free Software
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022: * Clara, CA 95054 or visit www.sun.com if you need additional
023: * information or have any questions.
024: */
025: package gov.nist.siplite;
026:
027: import gov.nist.siplite.address.*;
028: import gov.nist.siplite.header.*;
029: import gov.nist.siplite.message.*;
030: import com.sun.midp.security.SecurityToken;
031:
032: /**
033: * Main SIP factory for instance classes.
034: */
035: public class SipFactory {
036: /** Main SIP factory. */
037: private static SipFactory myFactory;
038: /** Address factory. */
039: private static AddressFactory addressFactory;
040: /** Messgae factory. */
041: private static MessageFactory msgFactory;
042: /** Header factoey. */
043: private static HeaderFactory headerFactory;
044:
045: /** Default private constructor (singleton). */
046: private SipFactory() {
047: // Dont let outsiders call me!
048: }
049:
050: /**
051: * Gets a handle the the SIP factory handler.
052: * @return handle to the SIP factory singelton
053: */
054: public static SipFactory getInstance() {
055: if (myFactory == null)
056: myFactory = new SipFactory();
057: return myFactory;
058: }
059:
060: /**
061: * Creates a SIP Stack based on requested properties.
062: * @param properties configuration of current SIP STack
063: * @param classSecurityToken SecurityToken object for saving
064: * @return SIP Stack context
065: */
066: public SipStack createSipStack(ConfigurationProperties properties,
067: SecurityToken classSecurityToken)
068: throws PeerUnavailableException {
069: return new SipStack(properties, classSecurityToken);
070: }
071:
072: /**
073: * Creates a mesage factory.
074: * @return handle to message factory handler
075: */
076: public MessageFactory createMessageFactory() {
077: if (msgFactory != null)
078: return msgFactory;
079: msgFactory = new MessageFactory();
080: return msgFactory;
081: }
082:
083: /**
084: * Creates a header factory.
085: * @return handle to header factory handler
086: */
087: public HeaderFactory createHeaderFactory() {
088: if (headerFactory != null)
089: return headerFactory;
090: headerFactory = new HeaderFactory();
091: return headerFactory;
092: }
093:
094: /**
095: * Creates a address factory.
096: * @return handle to address factory handler
097: */
098: public AddressFactory createAddressFactory() {
099: if (addressFactory != null)
100: return addressFactory;
101: addressFactory = new AddressFactory();
102: return addressFactory;
103: }
104:
105: }
|