001/** 002 * 003 * Copyright 2003-2006 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smackx.jingleold.nat; 018 019import java.util.logging.Level; 020import java.util.logging.Logger; 021 022import org.jivesoftware.smackx.jingleold.JingleSession; 023 024/** 025 * A Jingle Transport Manager implementation to be used on NAT networks with STUN Service NOT Blocked. 026 * 027 * @author Thiago Camargo 028 */ 029public class STUNTransportManager extends JingleTransportManager { 030 private static final Logger LOGGER = Logger.getLogger(STUNTransportManager.class.getName()); 031 032 STUNResolver stunResolver = null; 033 034 public STUNTransportManager() { 035 stunResolver = new STUNResolver() { 036 }; 037 try { 038 stunResolver.initializeAndWait(); 039 } catch (Exception e) { 040 LOGGER.log(Level.WARNING, "exception", e); 041 } 042 } 043 044 @Override 045 protected TransportResolver createResolver(JingleSession session) { 046 try { 047 stunResolver.resolve(session); 048 } catch (Exception e) { 049 LOGGER.log(Level.WARNING, "exception", e); 050 } 051 return stunResolver; 052 } 053}