Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Austrian Association for Software Tool Integration (AASTI) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The AASTI licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.openengsb.core.persistence.internal;
 
 import java.io.File;
 import java.util.List;
 
 
 
 public class DefaultPersistenceIndex implements PersistenceIndex {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPersistenceIndex.class);
     private static final String INDEX_FILE_NAME = "index.ser";
 
     private File indexFile;
     private ArrayList<ObjectInfoindex = Lists.newArrayList();
 
     public DefaultPersistenceIndex(File indexDirectoryObjectPersistenceBackend persistenceBackend) {
         this. = persistenceBackend;
          = new File(indexDirectory + "/" + );
         if (!.exists()) {
             writeIndex();
         } else {
             loadIndex();
         }
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public void indexObject(Class<?> beanFile beanLocation) {
         ObjectInfo objectInfo = new ObjectInfo(bean.getName(), beanLocation.toString());
         List<Class<?>> allInterfaces = ClassUtils.getAllInterfaces(bean);
         for (Class<?> class1 : allInterfaces) {
             objectInfo.addType(class1);
         }
         List<Class<?>> allSuperClasses = ClassUtils.getAllSuperclasses(bean);
         for (Class<?> class1 : allSuperClasses) {
             if (isObjectClassToIgnore(class1)) {
                 continue;
             }
             objectInfo.addType(class1);
         }
         objectInfo.addType(bean);
         synchronized () {
             .add(objectInfo);
         }
         .debug("Adding to index {}: {}".toString(), objectInfo.toString());
     }
 
     @Override
     public void removeIndexObject(ObjectInfo info) {
         synchronized () {
             .remove(info);
         }
     }
 
     @Override
     public void updateIndex() throws ObjectDbNotSerializableException {
         writeIndex();
     }
 
     @Override
     public List<ObjectInfofindIndexObject(Class<?> beanClass) {
         .trace("Looking for bean class {} in index {}"beanClass.getName(), .toString());
         List<ObjectInforetVal = Lists.newArrayList();
         synchronized () {
             for (ObjectInfo info : ) {
                 if (info.containsClass(beanClass)) {
                     retVal.add(info);
                     .debug("Looking for {} in index {} and found " + info.toString(), beanClass.getName(),
                         .toString());
                 }
             }
         }
         .debug("Found {} objects of type bean class {} in index: " + .toString(), retVal.size(),
             beanClass.getName());
         return retVal;
    }
    private boolean isObjectClassToIgnore(Class<?> class1) {
        return class1.getName().equals(Object.class.getName());
    }
    private void writeIndex() {
    }
    @SuppressWarnings("unchecked")
    private void loadIndex() {
    }
New to GrepCode? Check out our FAQ X