AbstractHandler.java
Go to the documentation of this file.
00001 /* \file AbstractHandler.java
00002  * \brief Abstract handler
00003  *
00004  * The abstract handler provides the management of API keys/Connection objects
00005  * for handler implementations.
00006  * 
00007  * This file is part of the RoboEarth ROS re_comm_core package.
00008  * 
00009  * It was originally created for <a href="http://www.roboearth.org/">RoboEarth</a>.
00010  * The research leading to these results has received funding from the 
00011  * European Union Seventh Framework Programme FP7/2007-2013 
00012  * under grant agreement no248942 RoboEarth.
00013  *
00014  * Copyright (C) 2010 by 
00015  * <a href=" mailto:perzylo@cs.tum.edu">Alexander Perzylo</a>
00016  * Technische Universitaet Muenchen
00017  * 
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions are met:
00020  * 
00021  *    <UL>
00022  *     <LI> Redistributions of source code must retain the above copyright
00023  *       notice, this list of conditions and the following disclaimer.
00024  *     <LI> Redistributions in binary form must reproduce the above copyright
00025  *       notice, this list of conditions and the following disclaimer in the
00026  *       documentation and/or other materials provided with the distribution.
00027  *     <LI> Neither the name of Willow Garage, Inc. nor the names of its
00028  *       contributors may be used to endorse or promote products derived from
00029  *       this software without specific prior written permission.
00030  *    </UL>
00031  * 
00032  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00033  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00034  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00035  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00036  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00037  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00038  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00039  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00040  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00041  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00042  * POSSIBILITY OF SUCH DAMAGE.
00043  *
00044  * \author Alexander Perzylo
00045  * \version 1.0
00046  * \date 2010
00047  * \image html http://www.roboearth.org/sites/default/files/RoboEarth.org_logo.gif
00048  * \image latex http://www.roboearth.org/sites/default/files/RoboEarth.org_logo.gif
00049  */
00050 package roboearth.wp5.module;
00051 
00052 import java.util.TreeMap;
00053 
00054 import roboearth.wp5.conn.REConnectionHadoop;
00055 import roboearth.wp5.conn.REInterface;
00056 import ros.NodeHandle;
00057 import ros.Ros;
00058 import ros.RosException;
00059 
00060 public abstract class AbstractHandler {
00061 
00065         protected Ros ros;
00066 
00070         protected NodeHandle n;
00071 
00075         public final static String guestInterfaceKey = "re_guest";
00076 
00080         private static TreeMap<String, REInterface> conns = new TreeMap<String, REInterface>();
00081         static{
00082                 conns.put(guestInterfaceKey, new REConnectionHadoop(null));
00083         }
00084 
00091         public AbstractHandler(Ros ros, NodeHandle n) throws RosException {
00092 
00093                 this.ros = ros;
00094                 this.n = n;
00095 
00096         }
00097 
00105         public static REInterface getREConnection(String apiKey) {
00106 
00107                 REInterface con = conns.get(apiKey);
00108                 if (con == null) {
00109                         con = new REConnectionHadoop(apiKey);
00110                         conns.put(apiKey, con);
00111                 }
00112                 return con;
00113 
00114         }
00115 
00116 }


re_comm_core
Author(s): Alexander Perzylo
autogenerated on Sun Jan 5 2014 11:29:33