⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myjndicustomfactory.java

📁 一个java写的加密算法
💻 JAVA
字号:
/* * Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved. * Use is subject to license terms. *//***  Custom JNDI Factory*  @author amurillo*/  		package samples.jndi.custom.share;import java.util.Enumeration;import java.util.Hashtable;import javax.naming.Context;import javax.naming.Name;import javax.naming.NamingException;import javax.naming.RefAddr;import javax.naming.Reference;import javax.naming.spi.ObjectFactory;public class MyJndiCustomFactory implements ObjectFactory {    public Object getObjectInstance(Object    obj,                                     Name      name,                                     Context   nameCtx,                                     Hashtable environment)        throws NamingException    {        // Acquire an instance of the custom bean class        CustomBean bean = new CustomBean();        // Customize the bean properties from  provided attributes        Reference ref = (Reference) obj;        Enumeration addrs = ref.getAll();                while (addrs.hasMoreElements())         {            RefAddr addr = (RefAddr) addrs.nextElement();            String  propertyName = addr.getType();            String value = (String) addr.getContent();            if (propertyName.equals("propertyOne"))             {                bean.setPropertyOne(value);            } else if (propertyName.equals("propertyTwo")) {                try                 {                    bean.setPropertyTwo(Integer.parseInt(value));                } catch (NumberFormatException e) {                    throw new NamingException("Invalid 'propertyTwo' value " + value);                }            }        }      // Return the customized instance      return (bean);    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -