PhoneManager phoneManager = null;
PhoneManager phoneManager;
    public void handleForward(IQ iq) {        Element phoneElement = iq.getChildElement();        PhoneManager phoneManager = null;        try {            phoneManager = PhoneManagerFactory.getPhoneManager();            String callSessionID = phoneElement.attributeValue("id");            if(callSessionID == null || "".equals(callSessionID)) {                throw new PhoneException("a call 'id' is a required attribute for type FORWARD");            }            String extension = phoneElement.elementText("extension");            if(extension != null && !"".equals(extension)) {                phoneManager.forward(callSessionID, iq.getFrom().getNode(), extension);            }            // try dialing by jid            else {                String targetJID = phoneElement.elementText("jid");                if(targetJID == null) {                    throw new PhoneException("No extension or jid was specified");                }                iq.getFrom().getNode();                phoneManager.forward(callSessionID, iq.getFrom().getNode(), new JID(targetJID));            }            //send reply            IQ reply = IQ.createResultIQ(iq);            reply.setType(IQ.Type.result);            PhoneAction phoneAction = new PhoneAction(PhoneAction.Type.FORWARD);            reply.setChildElement(phoneAction);            send(reply);        }        catch (PhoneException e) {            Log.debug(e);            IQ reply = IQ.createResultIQ(iq);            reply.setType(IQ.Type.error);            PacketError error = new PacketError(PacketError.Condition.undefined_condition,                    PacketError.Type.cancel,                    e.getMessage());            reply.setError(error);            send(reply);        }        finally {            PhoneManagerFactory.close(phoneManager);        }    }