Package org.jboss.fresh.deployer

Source Code of org.jboss.fresh.deployer.JNDICtxBinder

package org.jboss.fresh.deployer;


import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.jboss.fresh.ctx.FlatContext;
import org.jboss.fresh.ctx.JNDICtx;

public class JNDICtxBinder extends RegistryNamingBinder implements JNDICtxBinderMBean {

    private String mappings;
    private Map map = new HashMap();

    public String getName() {
        return "JNDICtxBinder";
    }

    public void setMappings(String str) {
        try {
            this.mappings = str;

            InputStream in = new ByteArrayInputStream(str.getBytes());
            Properties p = new Properties();
            p.load(in);

            Enumeration enom = p.propertyNames();
            while (enom.hasMoreElements()) {
                String key = (String) enom.nextElement();
                map.put(key, p.getProperty(key));
            }
        } catch (Exception ex) {
            throw new RuntimeException("Error configuring mappings: " + ex.toString());
        }
    }

    public String getMappings() {
        return mappings;
    }

    protected String getBindClass() {
        return "com.parsek.ctx.Context";
    }

    protected Object classToInstance(Class c) {

        // create it
        // set mappings
        // return

        FlatContext ctx = new FlatContext();

        JNDICtx jctx = new JNDICtx();
        jctx.setMappings(map);
        ctx.registerDelegate(jctx);
       
        setServiceObject(ctx);
        return ctx;

    }

    protected boolean bindByReference() {
  return true;
    }

}
TOP

Related Classes of org.jboss.fresh.deployer.JNDICtxBinder

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.