在一致性中找不到AbstractProcessor

时间:2018-10-24 11:46:28

标签: java caching java-ee cache-control oracle-coherence

我有一个Java Web应用程序,并且正在使用一致性来在两个weblogic节点中获得方法执行的摘要编号。这是pof.xml配置:

<user-type>
        <type-id>1040</type-id>
        <class-name>     com.process.UserMethodKeyUpdateProcessor</class-name>
        <serializer>
            <class-name>com.process.UserMethodKeyUpdateProcessor$Serializer</class-name>
        </serializer>
</user-type>

它是一致性配置文件:

<coherence-application
        xmlns="http://xmlns.oracle.com/coherence/coherence-application">

   <cache-configuration-ref>META-INF/coherence-cache-config.xml</cache-configuration-ref>
   <pof-configuration-ref>META-INF/pof-config.xml</pof-configuration-ref>

</coherence-application>

下面是缓存映射:

<cache-mapping>
            <cache-name>perDayCountCache</cache-name>
            <scheme-name>perDayCountCache-gar</scheme-name>
        </cache-mapping>

这是我的处理器类,它扩展了AbstractProcessor:

public class UserMethodKeyUpdateProcessor extends AbstractProcessor  {
    private UserMethodKey userMethodKey;
    private Integer count;


    public UserMethodKeyUpdateProcessor(UserMethodKey userMethodKey, Integer count) {
        this.userMethodKey = userMethodKey;
        this.count = count;
    }

    @Override
    public Object process(InvocableMap.Entry entry) {

        System.err.println("##UserMetUpdateProcessor process: "+entry);
        UserMethodKey userMethodKey  = (UserMethodKey) entry.getKey();
        System.out.println("#UserMetUpdateProcessor  cache: " + userMethodKey);
        int countCacheRead = (int) entry.getValue();
        System.out.println("## countCacheRead : "+ countCacheRead);
        System.out.println("#UserMetUpdateProcessor ID cache: " + userMethodKey);
        countCacheRead = countCacheRead +1;

        entry.setValue(countCacheRead);
        return "";
    }

    public static class Serializer implements PofSerializer {
        private final int USER_METHOD_KEY= 0;
        private final int COUNT= 1;


        @Override
        public void serialize(PofWriter writer, Object o) throws IOException {
            UserMethodKeyUpdateProcessor processor = (UserMethodKeyUpdateProcessor) o;
            writer.writeObject(USER_METHOD_KEY,processor.userMethodKey);
            writer.writeInt(COUNT,processor.count);

            writer.writeRemainder(null);//important
        }

        @Override
        public Object deserialize(PofReader reader) throws IOException {
            UserMethodKeyUpdateProcessor processor = new UserMethodKeyUpdateProcessor(
                    reader.readObject(USER_METHOD_KEY),
                    reader.readInt(COUNT)
            );

            reader.readRemainder();//important
            return processor;
        }
    }
}

您在我的项目中看到了此缓存的用法:

 AllowedPerDay allowed = info.getResourceMethod().getAnnotation(AllowedPerDay.class);
        if (allowed.value() > counter) {
            System.out.println("counter before update is : "+ counter);
//            cache.put(userMethodKey, counter + 1);
            System.out.println("counter after update is : "+ counter);
            System.out.println("counter after update is : "+ counter);
            UserMethodKeyUpdateProcessor processor=new UserMethodKeyUpdateProcessor(userMethodKey,counter);// todo process
            cacheUserCount.size();
            cacheUserCount.invoke(userMethodKey, processor);
            return true;
        }

一旦我编译项目,就会发生此错误:

Error:(134, 27) java: cannot access com.tangosol.util.processor.AbstractProcessor
  class file for com.tangosol.util.processor.AbstractProcessor not found

我不知道为什么它找不到处理器类。确切地说,正如我将这一行添加到我的方法中一样,发生此错误: cacheUserCount.invoke(userMethodKey,处理器); 此外,当我删除此行时,缓存可以正常工作(正确打印其大小)。

0 个答案:

没有答案