Xml - Bean 构造函数

Xml - Bean constructor

我正在使用 apache camel,我想在 blueprint.xml

中实例化 java class

这是class的构造函数:

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>