Xml-Bean构造函数



我使用的是apachecamel,我想在blueprint.xml 中实例化java类

这是类的构造函数:

public class ShiroSecurityPolicy implements AuthorizationPolicy {
          private static final Logger LOG = LoggerFactory.getLogger(ShiroSecurityPolicy.class);
        private final byte[] bits128 = {
            (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B,
            (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
            (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
            (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17};
        private CipherService cipherService;
        private byte[] passPhrase;
        private SecurityManager securityManager;
        private List<Permission> permissionsList;
        private boolean alwaysReauthenticate;
        private boolean base64;
    public ShiroSecurityPolicy(String iniResourcePath, byte[] passPhrase, boolean alwaysReauthenticate, List<Permission> permissionsList)
               {
                     this(iniResourcePath, passPhrase, alwaysReauthenticate); 
                     this.setPermissionsList(permissionsList);
               }
                  ........

如何在blueprint.xml中实例化它?

这就是我所做的:

<bean id="shiroPolicy" class="org.apache.camel.component.shiro.security.ShiroSecurityPolicy">
       <argument value="shiro.ini"/>
           ...
</bean>

但是我为passPhrase(一个数组)和permissionsList(一个列表)参数放了什么?

列表:

    <argument>
        <list>
            <value>item1</value>
            <value>item2</value>
            <value>item3</value>
        </list>
    </argument>

阵列:

    <argument>
        <array>
            <value>item1</value>
            <value>item2</value>
            <value>item3</value>
        </array>
    </argument>

您可以使用构造函数public ShiroSecurityPolicy(String iniResourcePath),并像bean的属性一样注入passPhrase和permissionsList。

如果我没有错的话,可以在ini文件中指定permissionsList:http://shiro.apache.org/configuration.html

更新:

尝试设置权限列表如下:

   <argument>
       <list>
           <bean class="org.apache.shiro.authz.permission.WildcardPermission">
               <argument value="zone1"/>
           </bean>
       </list>
   </argument>

最新更新