001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.control.user.scale.common;
018
019import com.echothree.control.user.scale.server.ScaleLocal;
020import com.echothree.util.common.control.InitialContextUtils;
021import javax.naming.NamingException;
022
023public class ScaleUtil {
024    
025    private static ScaleLocal cachedLocal = null;
026    private static ScaleRemote cachedRemote = null;
027
028    @SuppressWarnings("BanJNDI")
029    public static ScaleLocal getLocalHome()
030            throws NamingException {
031        if(cachedLocal == null) {
032            var ctx = InitialContextUtils.getInstance().getInitialContext();
033
034            cachedLocal = (ScaleLocal)ctx.lookup("ejb:echothree/echothree-server/ScaleBean!com.echothree.control.user.scale.server.ScaleLocal");
035        }
036        
037        return cachedLocal;
038    }
039
040    @SuppressWarnings("BanJNDI")
041    public static ScaleRemote getHome()
042            throws NamingException {
043        if(cachedRemote == null) {
044            var ctx = InitialContextUtils.getInstance().getInitialContext();
045            
046            cachedRemote = (ScaleRemote)ctx.lookup("ejb:echothree/echothree-server/ScaleBean!com.echothree.control.user.scale.common.ScaleRemote");
047        }
048        
049        return cachedRemote;
050    }
051    
052}