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.job.common;
018
019import com.echothree.control.user.job.server.JobLocal;
020import com.echothree.util.common.control.InitialContextUtils;
021import javax.naming.NamingException;
022
023public class JobUtil {
024    
025    private static JobLocal cachedLocal = null;
026    private static JobRemote cachedRemote = null;
027
028    @SuppressWarnings("BanJNDI")
029    public static JobLocal getLocalHome()
030            throws NamingException {
031        if(cachedLocal == null) {
032            var ctx = InitialContextUtils.getInstance().getInitialContext();
033
034            cachedLocal = (JobLocal)ctx.lookup("ejb:echothree/echothree-server/JobBean!com.echothree.control.user.job.server.JobLocal");
035        }
036        
037        return cachedLocal;
038    }
039
040    @SuppressWarnings("BanJNDI")
041    public static JobRemote getHome()
042            throws NamingException {
043        if(cachedRemote == null) {
044            var ctx = InitialContextUtils.getInstance().getInitialContext();
045
046            cachedRemote = (JobRemote)ctx.lookup("ejb:echothree/echothree-server/JobBean!com.echothree.control.user.job.common.JobRemote");
047        }
048        
049        return cachedRemote;
050    }
051    
052}