Package org.jboss.fresh.ctx

Source Code of org.jboss.fresh.ctx.JNDICtx

package org.jboss.fresh.ctx;

import org.jboss.fresh.registry.RegistryContext;
import java.util.Iterator;
import java.util.Map;

import org.apache.log4j.Logger;


public class JNDICtx implements Context {

  private static final Logger log = Logger.getLogger(JNDICtx.class);
    private Map map;


    public void put(Object key, Object value) {
        throw new RuntimeException("Not implemented: void put(Object, Object)");
    }


    public void setMappings(Map m) {
        map = m;
    }

    public Object get(Object key) {

        // find it in map first:
        try {

            Object o = map.get(key);
            if (o == null) return null;

            RegistryContext ctx = new RegistryContext();
            return ctx.lookup((String) o);

        } catch (Exception ex) {
            throw new RuntimeException(ex.toString(), ex);
        }
    }

    public Object remove(Object key) {
        throw new RuntimeException("Not implemented: Object remove(Object)");
    }

    public Map loadMappings(Map m) {

        Iterator it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry ent = (Map.Entry) it.next();
            try {
              m.put(ent.getKey(), get(ent.getKey()));
            } catch(Exception ex) {
              log.warn("Exception while looking up key: " + ent.getKey(), ex);
            }
        }

        return m;
    }

    public void registerDelegate(Context ctx) {
        throw new RuntimeException("Not implemented: void registerDelegate(Context)");
    }

    public boolean unregisterDelegate(Context ctx) {
        throw new RuntimeException("Not implemented: boolean unregisterDelegate(Context)");
    }

}
TOP

Related Classes of org.jboss.fresh.ctx.JNDICtx

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.