openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <...@apache.org>
Subject Re: svn commit: r640685 [1/14] - in /openjpa/trunk: ./ openjpa-all/ openjpa-jdbc-5/ openjpa-jdbc/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/apach
Date Tue, 25 Mar 2008 15:50:57 GMT
BTW, sorry about the line-ending issues. I had to check in from the
command line instead of IntelliJ since I changed the top-level
pom.xml, which is not part of my IntelliJ workspace. Evidently my
command-line svn is not properly configured wrt. line endings.

-Patrick

On Mon, Mar 24, 2008 at 8:38 PM,  <pcl@apache.org> wrote:
> Author: pcl
>  Date: Mon Mar 24 20:37:56 2008
>  New Revision: 640685
>
>  URL: http://svn.apache.org/viewvc?rev=640685&view=rev
>  Log:
>  OPENJPA-544. Get rid of JDK1.4 support, fold the jdk1.5 modules into their siblings, get rid of some ugly reflection that was there for 1.5 support, and move to the java.util.concurrent collections classes. This includes a wrapper around ConcurrentHashMap that allows nulls, since the old OpenJPA concurrent map allowed nulls and we rely on that behavior. The implication is that putIfAbsent() and some of the other special JDK1.5 methods don't obey the same contracts as in the java.util.concurrent package.
>
>  Added:
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBC3SavepointManager.java   (props changed)
>       - copied unchanged from r635113, openjpa/trunk/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/kernel/JDBC3SavepointManager.java
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EnumValueHandler.java   (props changed)
>       - copied unchanged from r635113, openjpa/trunk/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/strats/EnumValueHandler.java
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ClassRedefiner.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCClassFileTransformer.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
>     openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/enhance/TestGetDeclaredMethod.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-kernel-5/src/test/java/org/apache/openjpa/enhance/TestGetDeclaredMethod.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java
>       - copied unchanged from r635113, openjpa/trunk/openjpa-lib-5/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NullSafeConcurrentHashMap.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/SizedConcurrentHashMap.java
>     openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestNullSafeConcurrentHashMap.java
>  Removed:
>     openjpa/trunk/openjpa-jdbc-5/
>     openjpa/trunk/openjpa-kernel-5/
>     openjpa/trunk/openjpa-lib-5/
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractCollection.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractQueue.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractSet.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Arrays.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/ConcurrentHashMap.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/ConcurrentHashSet.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/ConcurrentLinkedQueue.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CondVar.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Condition.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArrayList.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArraySet.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOCondVar.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOWaitQueue.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Lock.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NanoTimer.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Queue.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/ReentrantLock.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/TimeUnit.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Utils.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/WaitQueue.java
>  Modified:
>     openjpa/trunk/openjpa-all/pom.xml
>     openjpa/trunk/openjpa-jdbc/pom.xml
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
>     openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
>     openjpa/trunk/openjpa-kernel/pom.xml
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/QueryCompilationCacheValue.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractQueryCache.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheScheduler.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCRegistry.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/RemoteCommitEventManager.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/SingleJVMRemoteCommitProvider.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/TransactionEventManager.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/CacheMap.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ImplHelper.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
>     openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java
>     openjpa/trunk/openjpa-lib/pom.xml
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryAdapter.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/MultiLogFactory.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/LRUMap.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Localizer.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TimestampHelper.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/AbstractConcurrentEventManager.java
>     openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/ConcurrentReferenceHashSet.java
>     openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
>     openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/TestAbstractEventManager.java
>     openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/util/concurrent/TestConcurrentMap.java
>     openjpa/trunk/openjpa-persistence-jdbc/pom.xml
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestExceptionsFromCallbacks.java
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/AbstractTestCase.java
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/kernel/TestRetainValuesInOptimistic.java
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/relations/TestHandlerToRelationMaps.java
>     openjpa/trunk/openjpa-persistence/pom.xml
>     openjpa/trunk/openjpa-xmlstore/pom.xml
>     openjpa/trunk/pom.xml
>
>  Modified: openjpa/trunk/openjpa-all/pom.xml
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-all/pom.xml?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-all/pom.xml (original)
>  +++ openjpa/trunk/openjpa-all/pom.xml Mon Mar 24 20:37:56 2008
>  @@ -84,15 +84,14 @@
>
>              <!--
>                  create enhancer pre-main attribute
>  -                copied from openjpa-kernel-5/pom.xml
>              -->
>              <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-jar-plugin</artifactId>
>                  <configuration>
>  -                    <archive>
>  -                        <manifest>
>  -                           <mainClass>org.apache.openjpa.conf.OpenJPAVersion</mainClass>
>  +                    <archive>
>  +                        <manifest>
>  +                           <mainClass>org.apache.openjpa.conf.OpenJPAVersion</mainClass>
>                          </manifest>
>                          <manifestEntries>
>                              <Premain-Class>
>  @@ -120,19 +119,7 @@
>          </dependency>
>          <dependency>
>              <groupId>org.apache.openjpa</groupId>
>  -            <artifactId>openjpa-kernel-5</artifactId>
>  -            <version>${pom.version}</version>
>  -            <scope>provided</scope>
>  -        </dependency>
>  -        <dependency>
>  -            <groupId>org.apache.openjpa</groupId>
>              <artifactId>openjpa-jdbc</artifactId>
>  -            <version>${pom.version}</version>
>  -            <scope>provided</scope>
>  -        </dependency>
>  -        <dependency>
>  -            <groupId>org.apache.openjpa</groupId>
>  -            <artifactId>openjpa-jdbc-5</artifactId>
>              <version>${pom.version}</version>
>              <scope>provided</scope>
>          </dependency>
>
>  Modified: openjpa/trunk/openjpa-jdbc/pom.xml
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/pom.xml?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-jdbc/pom.xml (original)
>  +++ openjpa/trunk/openjpa-jdbc/pom.xml Mon Mar 24 20:37:56 2008
>  @@ -32,26 +32,6 @@
>          <artifactId>openjpa-parent</artifactId>
>          <version>1.1.0-SNAPSHOT</version>
>      </parent>
>  -    <profiles>
>  -        <profile>
>  -            <id>java14-validate</id>
>  -            <activation><property><name>java14.jar</name></property></activation>
>  -            <build>
>  -                <pluginManagement>
>  -                    <plugins>
>  -                        <plugin>
>  -                            <artifactId>maven-compiler-plugin</artifactId>
>  -                            <configuration>
>  -                                <compilerArguments>
>  -                                    <bootclasspath>${java14.jar}</bootclasspath>
>  -                                </compilerArguments>
>  -                            </configuration>
>  -                        </plugin>
>  -                    </plugins>
>  -                </pluginManagement>
>  -            </build>
>  -        </profile>
>  -    </profiles>
>      <dependencies>
>          <dependency>
>              <groupId>org.apache.openjpa</groupId>
>  @@ -60,6 +40,10 @@
>              <scope>compile</scope>
>          </dependency>
>          <dependency>
>  +            <groupId>javax.xml.bind</groupId>
>  +            <artifactId>jaxb-api</artifactId>
>  +        </dependency>
>  +        <dependency>
>              <groupId>hsqldb</groupId>
>              <artifactId>hsqldb</artifactId>
>              <scope>compile</scope>
>  @@ -70,8 +54,8 @@
>              <plugin>
>                  <artifactId>maven-compiler-plugin</artifactId>
>                  <configuration>
>  -                    <source>1.4</source>
>  -                    <target>1.4</target>
>  +                    <source>1.5</source>
>  +                    <target>1.5</target>
>                  </configuration>
>              </plugin>
>          </plugins>
>
>  Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBC3SavepointManager.java
>  ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java (original)
>  +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java Mon Mar 24 20:37:56 2008
>  @@ -25,6 +25,7 @@
>
>   import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
>   import org.apache.openjpa.jdbc.meta.strats.UntypedPCValueHandler;
>  +import org.apache.openjpa.jdbc.meta.strats.EnumValueHandler;
>   import org.apache.openjpa.jdbc.schema.Column;
>   import org.apache.openjpa.jdbc.schema.ForeignKey;
>   import org.apache.openjpa.jdbc.schema.Index;
>  @@ -457,10 +458,11 @@
>          if (_stringifyUnmapped && vm.getTypeMapping() != null
>              && !vm.getTypeMapping().isMapped())
>              return UntypedPCValueHandler.getInstance();
>  -        if (_ordinalEnum && !vm.isSerialized()
>  -            && JavaVersions.isEnumeration(type))
>  -            return "org.apache.openjpa.jdbc.meta.strats.EnumValueHandler"
>  -                + "(StoreOrdinal=true)";
>  +        if (type.isEnum() && !vm.isSerialized()) {
>  +            EnumValueHandler enumHandler = new EnumValueHandler();
>  +            enumHandler.setStoreOrdinal(_ordinalEnum);
>  +            return enumHandler;
>  +        }
>          return null;
>      }
>
>
>  Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java (original)
>  +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java Mon Mar 24 20:37:56 2008
>  @@ -102,13 +102,6 @@
>
>      private static final Localizer _loc = Localizer.forPackage
>          (MappingRepository.class);
>  -    private static final Map _handlers = new HashMap();
>  -
>  -    static {
>  -        // register default value handlers
>  -        _handlers.put("java.lang.Enum",
>  -            "org.apache.openjpa.jdbc.meta.strats.EnumValueHandler");
>  -    }
>
>      private transient DBDictionary _dict = null;
>      private transient MappingDefaults _defaults = null;
>  @@ -949,8 +942,6 @@
>              return null;
>
>          Object strat = _defaults.getStrategy(val, type, adapting);
>  -        if (strat == null)
>  -            strat = _handlers.get(type.getName());
>
>          // recurse on superclass so that, for example, a registered handler
>          // for java.lang.Enum will work on all enums
>
>  Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EnumValueHandler.java
>  ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>  Modified: openjpa/trunk/openjpa-kernel/pom.xml
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/pom.xml?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-kernel/pom.xml (original)
>  +++ openjpa/trunk/openjpa-kernel/pom.xml Mon Mar 24 20:37:56 2008
>  @@ -32,26 +32,6 @@
>          <artifactId>openjpa-parent</artifactId>
>          <version>1.1.0-SNAPSHOT</version>
>      </parent>
>  -    <profiles>
>  -        <profile>
>  -            <id>java14-validate</id>
>  -            <activation><property><name>java14.jar</name></property></activation>
>  -            <build>
>  -                <pluginManagement>
>  -                    <plugins>
>  -                        <plugin>
>  -                            <artifactId>maven-compiler-plugin</artifactId>
>  -                            <configuration>
>  -                                <compilerArguments>
>  -                                    <bootclasspath>${java14.jar}</bootclasspath>
>  -                                </compilerArguments>
>  -                            </configuration>
>  -                        </plugin>
>  -                    </plugins>
>  -                </pluginManagement>
>  -            </build>
>  -        </profile>
>  -    </profiles>
>      <dependencies>
>          <dependency>
>              <groupId>org.apache.openjpa</groupId>
>  @@ -80,8 +60,8 @@
>              <plugin>
>                  <artifactId>maven-compiler-plugin</artifactId>
>                  <configuration>
>  -                    <source>1.4</source>
>  -                    <target>1.4</target>
>  +                    <source>1.5</source>
>  +                    <target>1.5</target>
>                  </configuration>
>              </plugin>
>              <plugin>
>
>  Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/QueryCompilationCacheValue.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/QueryCompilationCacheValue.java?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/QueryCompilationCacheValue.java (original)
>  +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/QueryCompilationCacheValue.java Mon Mar 24 20:37:56 2008
>  @@ -25,7 +25,7 @@
>   import org.apache.openjpa.lib.conf.Configuration;
>   import org.apache.openjpa.lib.conf.PluginValue;
>   import org.apache.openjpa.lib.util.concurrent.ConcurrentMap;
>  -import org.apache.openjpa.lib.util.concurrent.ConcurrentHashMap;
>  +import java.util.concurrent.ConcurrentHashMap;
>   import org.apache.openjpa.lib.util.ParseException;
>   import org.apache.openjpa.util.CacheMap;
>
>
>  Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java (original)
>  +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractDataCache.java Mon Mar 24 20:37:56 2008
>  @@ -1,455 +1,455 @@
>  -/*
>  - * Licensed to the Apache Software Foundation (ASF) under one
>  - * or more contributor license agreements.  See the NOTICE file
>  - * distributed with this work for additional information
>  - * regarding copyright ownership.  The ASF 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.apache.openjpa.datacache;
>  -
>  -import java.util.ArrayList;
>  -import java.util.BitSet;
>  -import java.util.Collection;
>  -import java.util.HashMap;
>  -import java.util.Iterator;
>  -import java.util.List;
>  -import java.util.Map;
>  -
>  -import org.apache.openjpa.conf.OpenJPAConfiguration;
>  -import org.apache.openjpa.event.RemoteCommitEvent;
>  -import org.apache.openjpa.event.RemoteCommitListener;
>  -import org.apache.openjpa.lib.conf.Configurable;
>  -import org.apache.openjpa.lib.conf.Configuration;
>  -import org.apache.openjpa.lib.log.Log;
>  -import org.apache.openjpa.lib.util.Localizer;
>  -import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
>  -
>  -/**
>  - * Abstract {@link DataCache} implementation that provides various
>  - * statistics, logging, and timeout functionality common across cache
>  - * implementations.
>  - *
>  - * @author Patrick Linskey
>  - * @author Abe White
>  - */
>  -public abstract class AbstractDataCache
>  -    extends AbstractConcurrentEventManager
>  -    implements DataCache, Configurable {
>  -
>  -    private static final BitSet EMPTY_BITSET = new BitSet(0);
>  -
>  -    private static final Localizer s_loc =
>  -        Localizer.forPackage(AbstractDataCache.class);
>  -
>  -    /**
>  -     * The configuration set by the system.
>  -     */
>  -    protected OpenJPAConfiguration conf;
>  -
>  -    /**
>  -     * The log to use.
>  -     */
>  -    protected Log log;
>  -
>  -    private String _name = null;
>  -    private boolean _closed = false;
>  -    private String _schedule = null;
>  -
>  -    public String getName() {
>  -        return _name;
>  -    }
>  -
>  -    public void setName(String name) {
>  -        _name = name;
>  -    }
>  -
>  -    public String getEvictionSchedule() {
>  -        return _schedule;
>  -    }
>  -
>  -    public void setEvictionSchedule(String s) {
>  -        _schedule = s;
>  -    }
>  -
>  -    public void initialize(DataCacheManager manager) {
>  -        if (_schedule != null && !"".equals(_schedule)) {
>  -            DataCacheScheduler scheduler = manager.getDataCacheScheduler();
>  -            if (scheduler != null)
>  -                scheduler.scheduleEviction(this, _schedule);
>  -        }
>  -    }
>  -
>  -    public void commit(Collection additions, Collection newUpdates,
>  -        Collection existingUpdates, Collection deletes) {
>  -        // remove all objects in deletes list
>  -        removeAllInternal(deletes);
>  -
>  -        // next, add all the new additions
>  -        putAllInternal(additions);
>  -        putAllInternal(newUpdates);
>  -
>  -        // possibly add the existing updates, depending on the
>  -        // semantics of the cache, as dictated by recacheUpdates()
>  -        if (recacheUpdates())
>  -            putAllInternal(existingUpdates);
>  -
>  -        if (log.isTraceEnabled()) {
>  -            Collection addIds = new ArrayList(additions.size());
>  -            Collection upIds = new ArrayList(newUpdates.size());
>  -            Collection exIds = new ArrayList(existingUpdates.size());
>  -
>  -            for (Iterator iter = additions.iterator(); iter.hasNext();)
>  -                addIds.add(((DataCachePCData) iter.next()).getId());
>  -            for (Iterator iter = newUpdates.iterator(); iter.hasNext();)
>  -                upIds.add(((DataCachePCData) iter.next()).getId());
>  -            for (Iterator iter = existingUpdates.iterator(); iter.hasNext();)
>  -                exIds.add(((DataCachePCData) iter.next()).getId());
>  -
>  -            log.trace(s_loc.get("cache-commit",
>  -                new Object[]{ addIds, upIds, exIds, deletes }));
>  -        }
>  -    }
>  -
>  -    public boolean contains(Object key) {
>  -        DataCachePCData o = getInternal(key);
>  -        if (o != null && o.isTimedOut()) {
>  -            o = null;
>  -            removeInternal(key);
>  -            if (log.isTraceEnabled())
>  -                log.trace(s_loc.get("cache-timeout", key));
>  -        }
>  -        return o != null;
>  -    }
>  -
>  -    public BitSet containsAll(Collection keys) {
>  -        if (keys.isEmpty())
>  -            return EMPTY_BITSET;
>  -
>  -        BitSet set = new BitSet(keys.size());
>  -        int i = 0;
>  -        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  -            if (contains(iter.next()))
>  -                set.set(i);
>  -        return set;
>  -    }
>  -
>  -    public DataCachePCData get(Object key) {
>  -        DataCachePCData o = getInternal(key);
>  -        if (o != null && o.isTimedOut()) {
>  -            o = null;
>  -            removeInternal(key);
>  -            if (log.isTraceEnabled())
>  -                log.trace(s_loc.get("cache-timeout", key));
>  -        }
>  -
>  -        if (log.isTraceEnabled()) {
>  -            if (o == null)
>  -                log.trace(s_loc.get("cache-miss", key));
>  -            else
>  -                log.trace(s_loc.get("cache-hit", key));
>  -        }
>  -
>  -        return o;
>  -    }
>  -
>  -    public DataCachePCData put(DataCachePCData data) {
>  -        DataCachePCData o = putInternal(data.getId(), data);
>  -        if (log.isTraceEnabled())
>  -            log.trace(s_loc.get("cache-put", data.getId()));
>  -        return (o == null || o.isTimedOut()) ? null : o;
>  -    }
>  -
>  -    public void update(DataCachePCData data) {
>  -        if (recacheUpdates())
>  -            putInternal(data.getId(), data);
>  -    }
>  -
>  -    public DataCachePCData remove(Object key) {
>  -        DataCachePCData o = removeInternal(key);
>  -        if (o != null && o.isTimedOut())
>  -            o = null;
>  -        if (log.isTraceEnabled()) {
>  -            if (o == null)
>  -                log.trace(s_loc.get("cache-remove-miss", key));
>  -            else
>  -                log.trace(s_loc.get("cache-remove-hit", key));
>  -        }
>  -        return o;
>  -    }
>  -
>  -    public BitSet removeAll(Collection keys) {
>  -        if (keys.isEmpty())
>  -            return EMPTY_BITSET;
>  -
>  -        BitSet set = new BitSet(keys.size());
>  -        int i = 0;
>  -        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  -            if (remove(iter.next()) != null)
>  -                set.set(i);
>  -        return set;
>  -    }
>  -
>  -    /**
>  -     * Remove the objects of the given class from the cache.
>  -     */
>  -    public void removeAll(Class cls, boolean subClasses) {
>  -        removeAllInternal(cls, subClasses);
>  -    }
>  -
>  -    public boolean pin(Object key) {
>  -        boolean bool = pinInternal(key);
>  -        if (log.isTraceEnabled()) {
>  -            if (bool)
>  -                log.trace(s_loc.get("cache-pin-hit", key));
>  -            else
>  -                log.trace(s_loc.get("cache-pin-miss", key));
>  -        }
>  -        return bool;
>  -    }
>  -
>  -    public BitSet pinAll(Collection keys) {
>  -        if (keys.isEmpty())
>  -            return EMPTY_BITSET;
>  -
>  -        BitSet set = new BitSet(keys.size());
>  -        int i = 0;
>  -        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  -            if (pin(iter.next()))
>  -                set.set(i);
>  -        return set;
>  -    }
>  -
>  -    public void pinAll(Class cls, boolean subs) {
>  -        if (log.isWarnEnabled())
>  -            log.warn(s_loc.get("cache-class-pin", getName()));
>  -    }
>  -
>  -    public boolean unpin(Object key) {
>  -        boolean bool = unpinInternal(key);
>  -        if (log.isTraceEnabled()) {
>  -            if (bool)
>  -                log.trace(s_loc.get("cache-unpin-hit", key));
>  -            else
>  -                log.trace(s_loc.get("cache-unpin-miss", key));
>  -        }
>  -        return bool;
>  -    }
>  -
>  -    public BitSet unpinAll(Collection keys) {
>  -        if (keys.isEmpty())
>  -            return EMPTY_BITSET;
>  -
>  -        BitSet set = new BitSet(keys.size());
>  -        int i = 0;
>  -        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  -            if (unpin(iter.next()))
>  -                set.set(i);
>  -        return set;
>  -    }
>  -
>  -    public void unpinAll(Class cls, boolean subs) {
>  -        if (log.isWarnEnabled())
>  -            log.warn(s_loc.get("cache-class-unpin", getName()));
>  -    }
>  -
>  -    public void clear() {
>  -        clearInternal();
>  -        if (log.isTraceEnabled())
>  -            log.trace(s_loc.get("cache-clear", getName()));
>  -    }
>  -
>  -    public void close() {
>  -        close(true);
>  -    }
>  -
>  -    protected void close(boolean clear) {
>  -        if (!_closed) {
>  -            if (clear)
>  -                clearInternal();
>  -            _closed = true;
>  -        }
>  -    }
>  -
>  -    public boolean isClosed() {
>  -        return _closed;
>  -    }
>  -
>  -    public void addExpirationListener(ExpirationListener listen) {
>  -        addListener(listen);
>  -    }
>  -
>  -    public boolean removeExpirationListener(ExpirationListener listen) {
>  -        return removeListener(listen);
>  -    }
>  -
>  -    public String toString() {
>  -        return "[" + super.toString() + ":" + _name + "]";
>  -    }
>  -
>  -    /**
>  -     * This method is part of the {@link RemoteCommitListener} interface. If
>  -     * your cache subclass relies on OpenJPA for clustering support, make it
>  -     * implement <code>RemoteCommitListener</code>. This method will take
>  -     * care of invalidating entries from remote commits.
>  -     */
>  -    public void afterCommit(RemoteCommitEvent event) {
>  -        if (_closed)
>  -            return;
>  -
>  -        if (event.getPayloadType() == RemoteCommitEvent.PAYLOAD_EXTENTS) {
>  -            removeAllTypeNamesInternal(event.getUpdatedTypeNames());
>  -            removeAllTypeNamesInternal(event.getDeletedTypeNames());
>  -        } else {
>  -            // drop all the committed OIDs, excepting brand
>  -            // new OIDs. brand new OIDs either won't be in
>  -            // the cache, or if they are, will be more up to date
>  -            removeAllInternal(event.getUpdatedObjectIds());
>  -            removeAllInternal(event.getDeletedObjectIds());
>  -        }
>  -    }
>  -
>  -    /**
>  -     * Invoke when a key is removed from this cache. Propagates the
>  -     * expiration event on to all expiration listeners registered
>  -     * with this class.
>  -     */
>  -    protected void keyRemoved(Object key, boolean expired) {
>  -        // Notify any expiration listeners of the expiration.
>  -        if (hasListeners())
>  -            fireEvent(new ExpirationEvent(this, key, expired));
>  -
>  -        if (expired && log.isTraceEnabled())
>  -            log.trace(s_loc.get("cache-expired", key));
>  -    }
>  -
>  -    /**
>  -     * Return <code>true</code> if updates to data already in the
>  -     * cache (either in {@link #commit} or the {@link #update})
>  -     * should be put back into the cache. Returns false by default.
>  -     */
>  -    protected boolean recacheUpdates() {
>  -        return false;
>  -    }
>  -
>  -    /**
>  -     * Return the object for the given oid.
>  -     */
>  -    protected abstract DataCachePCData getInternal(Object oid);
>  -
>  -    /**
>  -     * Add the given object to the cache, returning the old object under the
>  -     * given oid.
>  -     */
>  -    protected abstract DataCachePCData putInternal(Object oid,
>  -        DataCachePCData pc);
>  -
>  -    /**
>  -     * All all of the given objects to the cache.
>  -     */
>  -    protected void putAllInternal(Collection pcs) {
>  -        DataCachePCData pc;
>  -        for (Iterator iter = pcs.iterator(); iter.hasNext();) {
>  -            pc = (DataCachePCData) iter.next();
>  -            putInternal(pc.getId(), pc);
>  -        }
>  -    }
>  -
>  -    /**
>  -     * Remove the object under the given oid from the cache.
>  -     */
>  -    protected abstract DataCachePCData removeInternal(Object oid);
>  -
>  -    /**
>  -     * Evict objects in cache by class.
>  -     */
>  -    protected abstract void removeAllInternal(Class cls, boolean subclasses);
>  -
>  -    /**
>  -     * Remove all objects under the given oids from the cache.
>  -     */
>  -    protected void removeAllInternal(Collection oids) {
>  -        for (Iterator iter = oids.iterator(); iter.hasNext();)
>  -            removeInternal(iter.next());
>  -    }
>  -
>  -    /**
>  -     * Remove all objects of the given class names from the cache.
>  -     */
>  -    protected void removeAllTypeNamesInternal(Collection classNames) {
>  -        Collection classes = Caches.addTypesByName(conf, classNames, null);
>  -        if (classes == null)
>  -            return;
>  -
>  -        Class cls;
>  -        for (Iterator iter = classes.iterator(); iter.hasNext();) {
>  -            cls = (Class) iter.next();
>  -            if (log.isTraceEnabled())
>  -                log.trace(s_loc.get("cache-removeclass", cls.getName()));
>  -            removeAllInternal(cls, false);
>  -        }
>  -    }
>  -
>  -    /**
>  -     * Clear the cache.
>  -     */
>  -    protected abstract void clearInternal();
>  -
>  -    /**
>  -     * Pin an object to the cache.
>  -     */
>  -    protected abstract boolean pinInternal(Object oid);
>  -
>  -    /**
>  -     * Unpin an object from the cache.
>  -     */
>  -    protected abstract boolean unpinInternal(Object oid);
>  -
>  -    // ---------- Configurable implementation ----------
>  -
>  -    public void setConfiguration(Configuration conf) {
>  -        this.conf = (OpenJPAConfiguration) conf;
>  -        this.log = conf.getLog(OpenJPAConfiguration.LOG_DATACACHE);
>  -    }
>  -
>  -    public void startConfiguration() {
>  -    }
>  -
>  -    public void endConfiguration() {
>  -        if (_name == null)
>  -            setName(NAME_DEFAULT);
>  -    }
>  -
>  -    // ---------- AbstractEventManager implementation ----------
>  -
>  -    protected void fireEvent(Object event, Object listener) {
>  -        ExpirationListener listen = (ExpirationListener) listener;
>  -        ExpirationEvent ev = (ExpirationEvent) event;
>  -        try {
>  -            listen.onExpire(ev);
>  -        } catch (Exception e) {
>  -            if (log.isWarnEnabled())
>  -                log.warn(s_loc.get("exp-listener-ex"), e);
>  -               }
>  -       }
>  -
>  -    /**
>  -     * Returns the objects for the given key List.
>  -     */
>  -    public Map getAll(List keys) {
>  -        Map resultMap = new HashMap(keys.size());
>  -        for(int i=0; i<keys.size(); i++)
>  -            resultMap.put(keys.get(i), get(keys.get(i)));
>  -        return resultMap;
>  -    }
>  -}
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF 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.apache.openjpa.datacache;
>  +
>  +import java.util.ArrayList;
>  +import java.util.BitSet;
>  +import java.util.Collection;
>  +import java.util.HashMap;
>  +import java.util.Iterator;
>  +import java.util.List;
>  +import java.util.Map;
>  +
>  +import org.apache.openjpa.conf.OpenJPAConfiguration;
>  +import org.apache.openjpa.event.RemoteCommitEvent;
>  +import org.apache.openjpa.event.RemoteCommitListener;
>  +import org.apache.openjpa.lib.conf.Configurable;
>  +import org.apache.openjpa.lib.conf.Configuration;
>  +import org.apache.openjpa.lib.log.Log;
>  +import org.apache.openjpa.lib.util.Localizer;
>  +import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
>  +
>  +/**
>  + * Abstract {@link DataCache} implementation that provides various
>  + * statistics, logging, and timeout functionality common across cache
>  + * implementations.
>  + *
>  + * @author Patrick Linskey
>  + * @author Abe White
>  + */
>  +public abstract class AbstractDataCache
>  +    extends AbstractConcurrentEventManager
>  +    implements DataCache, Configurable {
>  +
>  +    private static final BitSet EMPTY_BITSET = new BitSet(0);
>  +
>  +    private static final Localizer s_loc =
>  +        Localizer.forPackage(AbstractDataCache.class);
>  +
>  +    /**
>  +     * The configuration set by the system.
>  +     */
>  +    protected OpenJPAConfiguration conf;
>  +
>  +    /**
>  +     * The log to use.
>  +     */
>  +    protected Log log;
>  +
>  +    private String _name = null;
>  +    private boolean _closed = false;
>  +    private String _schedule = null;
>  +
>  +    public String getName() {
>  +        return _name;
>  +    }
>  +
>  +    public void setName(String name) {
>  +        _name = name;
>  +    }
>  +
>  +    public String getEvictionSchedule() {
>  +        return _schedule;
>  +    }
>  +
>  +    public void setEvictionSchedule(String s) {
>  +        _schedule = s;
>  +    }
>  +
>  +    public void initialize(DataCacheManager manager) {
>  +        if (_schedule != null && !"".equals(_schedule)) {
>  +            DataCacheScheduler scheduler = manager.getDataCacheScheduler();
>  +            if (scheduler != null)
>  +                scheduler.scheduleEviction(this, _schedule);
>  +        }
>  +    }
>  +
>  +    public void commit(Collection additions, Collection newUpdates,
>  +        Collection existingUpdates, Collection deletes) {
>  +        // remove all objects in deletes list
>  +        removeAllInternal(deletes);
>  +
>  +        // next, add all the new additions
>  +        putAllInternal(additions);
>  +        putAllInternal(newUpdates);
>  +
>  +        // possibly add the existing updates, depending on the
>  +        // semantics of the cache, as dictated by recacheUpdates()
>  +        if (recacheUpdates())
>  +            putAllInternal(existingUpdates);
>  +
>  +        if (log.isTraceEnabled()) {
>  +            Collection addIds = new ArrayList(additions.size());
>  +            Collection upIds = new ArrayList(newUpdates.size());
>  +            Collection exIds = new ArrayList(existingUpdates.size());
>  +
>  +            for (Iterator iter = additions.iterator(); iter.hasNext();)
>  +                addIds.add(((DataCachePCData) iter.next()).getId());
>  +            for (Iterator iter = newUpdates.iterator(); iter.hasNext();)
>  +                upIds.add(((DataCachePCData) iter.next()).getId());
>  +            for (Iterator iter = existingUpdates.iterator(); iter.hasNext();)
>  +                exIds.add(((DataCachePCData) iter.next()).getId());
>  +
>  +            log.trace(s_loc.get("cache-commit",
>  +                new Object[]{ addIds, upIds, exIds, deletes }));
>  +        }
>  +    }
>  +
>  +    public boolean contains(Object key) {
>  +        DataCachePCData o = getInternal(key);
>  +        if (o != null && o.isTimedOut()) {
>  +            o = null;
>  +            removeInternal(key);
>  +            if (log.isTraceEnabled())
>  +                log.trace(s_loc.get("cache-timeout", key));
>  +        }
>  +        return o != null;
>  +    }
>  +
>  +    public BitSet containsAll(Collection keys) {
>  +        if (keys.isEmpty())
>  +            return EMPTY_BITSET;
>  +
>  +        BitSet set = new BitSet(keys.size());
>  +        int i = 0;
>  +        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  +            if (contains(iter.next()))
>  +                set.set(i);
>  +        return set;
>  +    }
>  +
>  +    public DataCachePCData get(Object key) {
>  +        DataCachePCData o = getInternal(key);
>  +        if (o != null && o.isTimedOut()) {
>  +            o = null;
>  +            removeInternal(key);
>  +            if (log.isTraceEnabled())
>  +                log.trace(s_loc.get("cache-timeout", key));
>  +        }
>  +
>  +        if (log.isTraceEnabled()) {
>  +            if (o == null)
>  +                log.trace(s_loc.get("cache-miss", key));
>  +            else
>  +                log.trace(s_loc.get("cache-hit", key));
>  +        }
>  +
>  +        return o;
>  +    }
>  +
>  +    public DataCachePCData put(DataCachePCData data) {
>  +        DataCachePCData o = putInternal(data.getId(), data);
>  +        if (log.isTraceEnabled())
>  +            log.trace(s_loc.get("cache-put", data.getId()));
>  +        return (o == null || o.isTimedOut()) ? null : o;
>  +    }
>  +
>  +    public void update(DataCachePCData data) {
>  +        if (recacheUpdates())
>  +            putInternal(data.getId(), data);
>  +    }
>  +
>  +    public DataCachePCData remove(Object key) {
>  +        DataCachePCData o = removeInternal(key);
>  +        if (o != null && o.isTimedOut())
>  +            o = null;
>  +        if (log.isTraceEnabled()) {
>  +            if (o == null)
>  +                log.trace(s_loc.get("cache-remove-miss", key));
>  +            else
>  +                log.trace(s_loc.get("cache-remove-hit", key));
>  +        }
>  +        return o;
>  +    }
>  +
>  +    public BitSet removeAll(Collection keys) {
>  +        if (keys.isEmpty())
>  +            return EMPTY_BITSET;
>  +
>  +        BitSet set = new BitSet(keys.size());
>  +        int i = 0;
>  +        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  +            if (remove(iter.next()) != null)
>  +                set.set(i);
>  +        return set;
>  +    }
>  +
>  +    /**
>  +     * Remove the objects of the given class from the cache.
>  +     */
>  +    public void removeAll(Class cls, boolean subClasses) {
>  +        removeAllInternal(cls, subClasses);
>  +    }
>  +
>  +    public boolean pin(Object key) {
>  +        boolean bool = pinInternal(key);
>  +        if (log.isTraceEnabled()) {
>  +            if (bool)
>  +                log.trace(s_loc.get("cache-pin-hit", key));
>  +            else
>  +                log.trace(s_loc.get("cache-pin-miss", key));
>  +        }
>  +        return bool;
>  +    }
>  +
>  +    public BitSet pinAll(Collection keys) {
>  +        if (keys.isEmpty())
>  +            return EMPTY_BITSET;
>  +
>  +        BitSet set = new BitSet(keys.size());
>  +        int i = 0;
>  +        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  +            if (pin(iter.next()))
>  +                set.set(i);
>  +        return set;
>  +    }
>  +
>  +    public void pinAll(Class cls, boolean subs) {
>  +        if (log.isWarnEnabled())
>  +            log.warn(s_loc.get("cache-class-pin", getName()));
>  +    }
>  +
>  +    public boolean unpin(Object key) {
>  +        boolean bool = unpinInternal(key);
>  +        if (log.isTraceEnabled()) {
>  +            if (bool)
>  +                log.trace(s_loc.get("cache-unpin-hit", key));
>  +            else
>  +                log.trace(s_loc.get("cache-unpin-miss", key));
>  +        }
>  +        return bool;
>  +    }
>  +
>  +    public BitSet unpinAll(Collection keys) {
>  +        if (keys.isEmpty())
>  +            return EMPTY_BITSET;
>  +
>  +        BitSet set = new BitSet(keys.size());
>  +        int i = 0;
>  +        for (Iterator iter = keys.iterator(); iter.hasNext(); i++)
>  +            if (unpin(iter.next()))
>  +                set.set(i);
>  +        return set;
>  +    }
>  +
>  +    public void unpinAll(Class cls, boolean subs) {
>  +        if (log.isWarnEnabled())
>  +            log.warn(s_loc.get("cache-class-unpin", getName()));
>  +    }
>  +
>  +    public void clear() {
>  +        clearInternal();
>  +        if (log.isTraceEnabled())
>  +            log.trace(s_loc.get("cache-clear", getName()));
>  +    }
>  +
>  +    public void close() {
>  +        close(true);
>  +    }
>  +
>  +    protected void close(boolean clear) {
>  +        if (!_closed) {
>  +            if (clear)
>  +                clearInternal();
>  +            _closed = true;
>  +        }
>  +    }
>  +
>  +    public boolean isClosed() {
>  +        return _closed;
>  +    }
>  +
>  +    public void addExpirationListener(ExpirationListener listen) {
>  +        addListener(listen);
>  +    }
>  +
>  +    public boolean removeExpirationListener(ExpirationListener listen) {
>  +        return removeListener(listen);
>  +    }
>  +
>  +    public String toString() {
>  +        return "[" + super.toString() + ":" + _name + "]";
>  +    }
>  +
>  +    /**
>  +     * This method is part of the {@link RemoteCommitListener} interface. If
>  +     * your cache subclass relies on OpenJPA for clustering support, make it
>  +     * implement <code>RemoteCommitListener</code>. This method will take
>  +     * care of invalidating entries from remote commits.
>  +     */
>  +    public void afterCommit(RemoteCommitEvent event) {
>  +        if (_closed)
>  +            return;
>  +
>  +        if (event.getPayloadType() == RemoteCommitEvent.PAYLOAD_EXTENTS) {
>  +            removeAllTypeNamesInternal(event.getUpdatedTypeNames());
>  +            removeAllTypeNamesInternal(event.getDeletedTypeNames());
>  +        } else {
>  +            // drop all the committed OIDs, excepting brand
>  +            // new OIDs. brand new OIDs either won't be in
>  +            // the cache, or if they are, will be more up to date
>  +            removeAllInternal(event.getUpdatedObjectIds());
>  +            removeAllInternal(event.getDeletedObjectIds());
>  +        }
>  +    }
>  +
>  +    /**
>  +     * Invoke when a key is removed from this cache. Propagates the
>  +     * expiration event on to all expiration listeners registered
>  +     * with this class.
>  +     */
>  +    protected void keyRemoved(Object key, boolean expired) {
>  +        // Notify any expiration listeners of the expiration.
>  +        if (hasListeners())
>  +            fireEvent(new ExpirationEvent(this, key, expired));
>  +
>  +        if (expired && log.isTraceEnabled())
>  +            log.trace(s_loc.get("cache-expired", key));
>  +    }
>  +
>  +    /**
>  +     * Return <code>true</code> if updates to data already in the
>  +     * cache (either in {@link #commit} or the {@link #update})
>  +     * should be put back into the cache. Returns false by default.
>  +     */
>  +    protected boolean recacheUpdates() {
>  +        return false;
>  +    }
>  +
>  +    /**
>  +     * Return the object for the given oid.
>  +     */
>  +    protected abstract DataCachePCData getInternal(Object oid);
>  +
>  +    /**
>  +     * Add the given object to the cache, returning the old object under the
>  +     * given oid.
>  +     */
>  +    protected abstract DataCachePCData putInternal(Object oid,
>  +        DataCachePCData pc);
>  +
>  +    /**
>  +     * All all of the given objects to the cache.
>  +     */
>  +    protected void putAllInternal(Collection pcs) {
>  +        DataCachePCData pc;
>  +        for (Iterator iter = pcs.iterator(); iter.hasNext();) {
>  +            pc = (DataCachePCData) iter.next();
>  +            putInternal(pc.getId(), pc);
>  +        }
>  +    }
>  +
>  +    /**
>  +     * Remove the object under the given oid from the cache.
>  +     */
>  +    protected abstract DataCachePCData removeInternal(Object oid);
>  +
>  +    /**
>  +     * Evict objects in cache by class.
>  +     */
>  +    protected abstract void removeAllInternal(Class cls, boolean subclasses);
>  +
>  +    /**
>  +     * Remove all objects under the given oids from the cache.
>  +     */
>  +    protected void removeAllInternal(Collection oids) {
>  +        for (Iterator iter = oids.iterator(); iter.hasNext();)
>  +            removeInternal(iter.next());
>  +    }
>  +
>  +    /**
>  +     * Remove all objects of the given class names from the cache.
>  +     */
>  +    protected void removeAllTypeNamesInternal(Collection classNames) {
>  +        Collection classes = Caches.addTypesByName(conf, classNames, null);
>  +        if (classes == null)
>  +            return;
>  +
>  +        Class cls;
>  +        for (Iterator iter = classes.iterator(); iter.hasNext();) {
>  +            cls = (Class) iter.next();
>  +            if (log.isTraceEnabled())
>  +                log.trace(s_loc.get("cache-removeclass", cls.getName()));
>  +            removeAllInternal(cls, false);
>  +        }
>  +    }
>  +
>  +    /**
>  +     * Clear the cache.
>  +     */
>  +    protected abstract void clearInternal();
>  +
>  +    /**
>  +     * Pin an object to the cache.
>  +     */
>  +    protected abstract boolean pinInternal(Object oid);
>  +
>  +    /**
>  +     * Unpin an object from the cache.
>  +     */
>  +    protected abstract boolean unpinInternal(Object oid);
>  +
>  +    // ---------- Configurable implementation ----------
>  +
>  +    public void setConfiguration(Configuration conf) {
>  +        this.conf = (OpenJPAConfiguration) conf;
>  +        this.log = conf.getLog(OpenJPAConfiguration.LOG_DATACACHE);
>  +    }
>  +
>  +    public void startConfiguration() {
>  +    }
>  +
>  +    public void endConfiguration() {
>  +        if (_name == null)
>  +            setName(NAME_DEFAULT);
>  +    }
>  +
>  +    // ---------- AbstractEventManager implementation ----------
>  +
>  +    protected void fireEvent(Object event, Object listener) {
>  +        ExpirationListener listen = (ExpirationListener) listener;
>  +        ExpirationEvent ev = (ExpirationEvent) event;
>  +        try {
>  +            listen.onExpire(ev);
>  +        } catch (Exception e) {
>  +            if (log.isWarnEnabled())
>  +                log.warn(s_loc.get("exp-listener-ex"), e);
>  +               }
>  +       }
>  +
>  +    /**
>  +     * Returns the objects for the given key List.
>  +     */
>  +    public Map getAll(List keys) {
>  +        Map resultMap = new HashMap(keys.size());
>  +        for(int i=0; i<keys.size(); i++)
>  +            resultMap.put(keys.get(i), get(keys.get(i)));
>  +        return resultMap;
>  +    }
>  +}
>
>  Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractQueryCache.java
>  URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractQueryCache.java?rev=640685&r1=640684&r2=640685&view=diff
>  ==============================================================================
>  --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractQueryCache.java (original)
>  +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/AbstractQueryCache.java Mon Mar 24 20:37:56 2008
>  @@ -1,322 +1,322 @@
>  -/*
>  - * Licensed to the Apache Software Foundation (ASF) under one
>  - * or more contributor license agreements.  See the NOTICE file
>  - * distributed with this work for additional information
>  - * regarding copyright ownership.  The ASF 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.apache.openjpa.datacache;
>  -
>  -import java.util.ArrayList;
>  -import java.util.Collection;
>  -import java.util.HashSet;
>  -import java.util.Iterator;
>  -import java.util.List;
>  -import java.util.Set;
>  -
>  -import org.apache.openjpa.conf.OpenJPAConfiguration;
>  -import org.apache.openjpa.event.RemoteCommitEvent;
>  -import org.apache.openjpa.event.RemoteCommitListener;
>  -import org.apache.openjpa.lib.conf.Configurable;
>  -import org.apache.openjpa.lib.conf.Configuration;
>  -import org.apache.openjpa.lib.log.Log;
>  -import org.apache.openjpa.lib.util.Localizer;
>  -import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
>  -import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
>  -import org.apache.openjpa.meta.ClassMetaData;
>  -import org.apache.openjpa.meta.MetaDataRepository;
>  -import org.apache.openjpa.util.Id;
>  -
>  -/**
>  - * Abstract {@link QueryCache} implementation that provides various
>  - * statistics, logging, and timeout functionality common across cache
>  - * implementations.
>  - *
>  - * @author Patrick Linskey
>  - * @author Abe White
>  - */
>  -public abstract class AbstractQueryCache
>  -    extends AbstractConcurrentEventManager
>  -    implements QueryCache, Configurable {
>  -
>  -    private static final Localizer s_loc =
>  -        Localizer.forPackage(AbstractQueryCache.class);
>  -
>  -    /**
>  -     * The configuration set by the system.
>  -     */
>  -    protected OpenJPAConfiguration conf;
>  -
>  -    /**
>  -     * The log to use.
>  -     */
>  -    protected Log log;
>  -
>  -    private boolean _closed = false;
>  -
>  -    public void initialize(DataCacheManager manager) {
>  -    }
>  -
>  -    public void onTypesChanged(TypesChangedEvent ev) {
>  -        writeLock();
>  -        Collection keys = null;
>  -        try {
>  -            if (hasListeners())
>  -                fireEvent(ev);
>  -            keys = keySet();
>  -        } finally {
>  -            writeUnlock();
>  -        }
>  -
>  -        QueryKey qk;
>  -        List removes = null;
>  -        for (Iterator iter = keys.iterator(); iter.hasNext();) {
>  -            qk = (QueryKey) iter.next();
>  -            if (qk.changeInvalidatesQuery(ev.getTypes())) {
>  -                if (removes == null)
>  -                    removes = new ArrayList();
>  -                removes.add(qk);
>  -            }
>  -        }
>  -        if (removes != null)
>  -            removeAllInternal(removes);
>  -    }
>  -
>  -    public QueryResult get(QueryKey key) {
>  -        QueryResult o = getInternal(key);
>  -        if (o != null && o.isTimedOut()) {
>  -            o = null;
>  -            removeInternal(key);
>  -            if (log.isTraceEnabled())
>  -                log.trace(s_loc.get("cache-timeout", key));
>  -        }
>  -
>  -        if (log.isTraceEnabled()) {
>  -            if (o == null)
>  -                log.trace(s_loc.get("cache-miss", key));
>  -            else
>  -                log.trace(s_loc.get("cache-hit", key));
>  -        }
>  -        return o;
>  -    }
>  -
>  -    public QueryResult put(QueryKey qk, QueryResult oids) {
>  -        QueryResult o = putInternal(qk, oids);
>  -        if (log.isTraceEnabled())
>  -            log.trace(s_loc.get("cache-put", qk));
>  -        return (o == null || o.isTimedOut()) ? null : o;
>  -    }
>  -
>  -    public QueryResult remove(QueryKey key) {
>  -        QueryResult o = removeInternal(key);
>  -        if (o != null && o.isTimedOut())
>  -            o = null;
>  -        if (log.isTraceEnabled()) {
>  -            if (o == null)
>  -                log.trace(s_loc.get("cache-remove-miss", key));
>  -            else
>  -                log.trace(s_loc.get("cache-remove-hit", key));
>  -        }
>  -        return o;
>  -    }
>  -
>  -    public boolean pin(QueryKey key) {
>  -        boolean bool = pinInternal(key);
>  -        if (log.isTraceEnabled()) {
>  -            if (bool)
>  -                log.trace(s_loc.get("cache-pin-hit", key));
>  -            else
>  -                log.trace(s_loc.get("cache-pin-miss", key));
>  -        }
>  -        return bool;
>  -    }
>  -
>  -    public boolean unpin(QueryKey key) {
>  -        boolean bool = unpinInternal(key);
>  -        if (log.isTraceEnabled()) {
>  -            if (bool)
>  -                log.trace(s_loc.get("cache-unpin-hit", key));
>  -            else
>  -                log.trace(s_loc.get("cache-unpin-miss", key));
>  -        }
>  -        return bool;
>  -    }
>  -
>  -    public void clear() {
>  -        clearInternal();
>  -        if (log.isTraceEnabled())
>  -            log.trace(s_loc.get("cache-clear", "<query-cache>"));
>  -    }
>  -
>  -    public void close() {
>  -        close(true);
>  -    }
>  -
>  -    protected void close(boolean clear) {
>  -        if (!_closed) {
>  -            if (clear)
>  -                clearInternal();
>  -            _closed = true;
>  -        }
>  -    }
>  -
>  -    public boolean isClosed() {
>  -        return _closed;
>  -    }
>  -
>  -    public void addTypesChangedListener(TypesChangedListener listen) {
>  -        addListener(listen);
>  -    }
>  -
>  -    public boolean removeTypesChangedListener(TypesChangedListener listen) {
>  -        return removeListener(listen);
>  -    }
>  -
>  -    /**
>  -     * This method is part of the {@link RemoteCommitListener} interface. If
>  -     * your cache subclass relies on OpenJPA for clustering support, make it
>  -     * implement <code>RemoteCommitListener</code>. This method will take
>  -     * care of invalidating entries from remote commits, by delegating to
>  -     * {@link #onTypesChanged}.
>  -     */
>  -    public void afterCommit(RemoteCommitEvent event) {
>  -        if (_closed)
>  -            return;
>  -
>  -        // drop all committed classes
>  -        Set classes = Caches.addTypesByName(conf,
>  -            event.getPersistedTypeNames(), null);
>  -        if (event.getPayloadType() == RemoteCommitEvent.PAYLOAD_EXTENTS) {
>  -            classes = Caches.addTypesByName(conf, event.getUpdatedTypeNames(),
>  -                classes);
>  -            classes = Caches.addTypesByName(conf, event.getDeletedTypeNames(),
>  -                classes);
>  -        } else {
>  -            classes = addTypes(event.getUpdatedObjectIds(), classes);
>  -            classes = addTypes(event.getDeletedObjectIds(), classes);
>  -        }
>  -        if (classes != null)
>  -            onTypesChanged(new TypesChangedEvent(this, classes));
>  -    }
>  -
>  -    /**
>  -     * Build up a set of classes for the given oids.
>  -     */
>  -    private Set addTypes(Collection oids, Set classes) {
>  -        if (oids.isEmpty())
>  -            return classes;
>  -        if (classes == null)
>  -            classes = new HashSet();
>  -
>  -        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
>  -        ClassMetaData meta;
>  -        Object oid;
>  -        for (Iterator itr = oids.iterator(); itr.hasNext();) {
>  -            oid = itr.next();
>  -            if (oid instanceof Id)
>  -                classes.add(((Id) oid).getType());
>  -            else {
>  -                // ok if no metadata for oid; that just means the pc type
>  -                // probably hasn't been loaded into this JVM yet, and therefore
>  -                // there's no chance that it's in the cache anyway
>  -                meta = repos.getMetaData(oid, null, false);
>  -                if (meta != null)
>  -                    classes.add(meta.getDescribedType());
>  -            }
>  -        }
>  -        return classes;
>  -    }
>  -
>  -    /**
>  -     * Return a threadsafe view of the keys in this cache. This collection
>  -     * must be iterable without risk of concurrent modification exceptions.
>  -     * It does not have to implement contains() efficiently or use set
>  -     * semantics.
>  -     */
>  -    protected abstract Collection keySet();
>  -
>  -    /**
>  -     * Return the list for the given key.
>  -     */
>  -    protected abstract QueryResult getInternal(QueryKey qk);
>  -
>  -    /**
>  -     * Add the given result to the cache, returning the old result under the
>  -     * given key.
>  -     */
>  -    protected abstract QueryResult putInternal(QueryKey qk, QueryResult oids);
>  -
>  -    /**
>  -     * Remove the result under the given key from the cache.
>  -     */
>  -    protected abstract QueryResult removeInternal(QueryKey qk);
>  -
>  -    /**
>  -     * Remove all results under the given keys from the cache.
>  -     */
>  -    protected void removeAllInternal(Collection qks) {
>  -        for (Iterator iter = qks.iterator(); iter.hasNext();)
>  -            removeInternal((QueryKey) iter.next());
>  -    }
>  -
>  -    /**
>  -     * Clear the cache.
>  -     */
>  -    protected abstract void clearInternal();
>  -
>  -    /**
>  -     * Pin an object to the cache.
>  -     */
>  -    protected abstract boolean pinInternal(QueryKey qk);
>  -
>  -    /**
>  -     * Unpin an object from the cache.
>  -     */
>  -    protected abstract boolean unpinInternal(QueryKey qk);
>  -
>  -    // ---------- Configurable implementation ----------
>  -
>  -    public void setConfiguration(Configuration conf) {
>  -        this.conf = (OpenJPAConfiguration) conf;
>  -        this.log = conf.getLog(OpenJPAConfiguration.LOG_DATACACHE);
>  -    }
>  -
>  -    public void startConfiguration() {
>  -    }
>  -
>  -    public void endConfiguration() {
>  -    }
>  -
>  -    // ---------- AbstractEventManager implementation ----------
>  -
>  -    protected void fireEvent(Object event, Object listener) {
>  -        TypesChangedListener listen = (TypesChangedListener) listener;
>  -        TypesChangedEvent ev = (TypesChangedEvent) event;
>  -        try {
>  -            listen.onTypesChanged(ev);
>  -        } catch (Exception e) {
>  -            if (log.isWarnEnabled())
>  -                log.warn(s_loc.get("exp-listener-ex"), e);
>  -        }
>  -    }
>  -
>  -    /**
>  -     * Individual query results will be registered as types changed
>  -     * listeners. We want such query results to be gc'd once
>  -     * the only reference is held by the list of expiration listeners.
>  -     */
>  -    protected Collection newListenerCollection() {
>  -        return new ConcurrentReferenceHashSet (ConcurrentReferenceHashSet.WEAK);
>  -       }
>  -}
>  +/*
>  + * Licensed to the Apache Software Foundation (ASF) under one
>  + * or more contributor license agreements.  See the NOTICE file
>  + * distributed with this work for additional information
>  + * regarding copyright ownership.  The ASF 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.apache.openjpa.datacache;
>  +
>  +import java.util.ArrayList;
>  +import java.util.Collection;
>  +import java.util.HashSet;
>  +import java.util.Iterator;
>  +import java.util.List;
>  +import java.util.Set;
>  +
>  +import org.apache.openjpa.conf.OpenJPAConfiguration;
>  +import org.apache.openjpa.event.RemoteCommitEvent;
>  +import org.apache.openjpa.event.RemoteCommitListener;
>  +import org.apache.openjpa.lib.conf.Configurable;
>  +import org.apache.openjpa.lib.conf.Configuration;
>  +import org.apache.openjpa.lib.log.Log;
>  +import org.apache.openjpa.lib.util.Localizer;
>  +import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
>  +import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet;
>  +import org.apache.openjpa.meta.ClassMetaData;
>  +import org.apache.openjpa.meta.MetaDataRepository;
>  +import org.apache.openjpa.util.Id;
>  +
>  +/**
>  + * Abstract {@link QueryCache} implementation that provides various
>  + * statistics, logging, and timeout functionality common across cache
>  + * implementations.
>  + *
>  + * @author Patrick Linskey
>  + * @author Abe White
>  + */
>  +public abstract class AbstractQueryCache
>  +    extends AbstractConcurrentEventManager
>  +    implements QueryCache, Configurable {
>  +
>  +    private static final Localizer s_loc =
>  +        Localizer.forPackage(AbstractQueryCache.class);
>  +
>  +    /**
>  +     * The configuration set by the system.
>  +     */
>  +    protected OpenJPAConfiguration conf;
>  +
>  +    /**
>  +     * The log to use.
>  +     */
>  +    protected Log log;
>  +
>  +    private boolean _closed = false;
>  +
>  +    public void initialize(DataCacheManager manager) {
>  +    }
>  +
>  +    public void onTypesChanged(TypesChangedEvent ev) {
>  +        writeLock();
>  +        Collection keys = null;
>  +        try {
>  +            if (hasListeners())
>  +                fireEvent(ev);
>  +            keys = keySet();
>  +        } finally {
>  +            writeUnlock();
>  +        }
>  +
>  +        QueryKey qk;
>  +        List removes = null;
>  +        for (Iterator iter = keys.iterator(); iter.hasNext();) {
>  +            qk = (QueryKey) iter.next();
>  +            if (qk.changeInvalidatesQuery(ev.getTypes())) {
>  +                if (removes == null)
>  +                    removes = new ArrayList();
>  +                removes.add(qk);
>  +            }
>  +        }
>  +        if (removes != null)
>  +            removeAllInternal(removes);
>  +    }
>  +
>  +    public QueryResult get(QueryKey key) {
>  +        QueryResult o = getInternal(key);
>  +        if (o != null && o.isTimedOut()) {
>  +            o = null;
>  +            removeInternal(key);
>  +            if (log.isTraceEnabled())
>  +                log.trace(s_loc.get("cache-timeout", key));
>  +        }
>  +
>  +        if (log.isTraceEnabled()) {
>  +            if (o == null)
>  +                log.trace(s_loc.get("cache-miss", key));
>  +            else
>  +                log.trace(s_loc.get("cache-hit", key));
>  +        }
>  +        return o;
>  +    }
>  +
>  +    public QueryResult put(QueryKey qk, QueryResult oids) {
>  +        QueryResult o = putInternal(qk, oids);
>  +        if (log.isTraceEnabled())
>  +            log.trace(s_loc.get("cache-put", qk));
>  +        return (o == null || o.isTimedOut()) ? null : o;
>  +    }
>  +
>  +    public QueryResult remove(QueryKey key) {
>  +        QueryResult o = removeInternal(key);
>  +        if (o != null && o.isTimedOut())
>  +            o = null;
>  +        if (log.isTraceEnabled()) {
>  +            if (o == null)
>  +                log.trace(s_loc.get("cache-remove-miss", key));
>  +            else
>  +                log.trace(s_loc.get("cache-remove-hit", key));
>  +        }
>  +        return o;
>  +    }
>  +
>  +    public boolean pin(QueryKey key) {
>  +        boolean bool = pinInternal(key);
>  +        if (log.isTraceEnabled()) {
>  +            if (bool)
>  +                log.trace(s_loc.get("cache-pin-hit", key));
>  +            else
>  +                log.trace(s_loc.get("cache-pin-miss", key));
>  +        }
>  +        return bool;
>  +    }
>  +
>  +    public boolean unpin(QueryKey key) {
>  +        boolean bool = unpinInternal(key);
>  +        if (log.isTraceEnabled()) {
>  +            if (bool)
>  +                log.trace(s_loc.get("cache-unpin-hit", key));
>  +            else
>  +                log.trace(s_loc.get("cache-unpin-miss", key));
>  +        }
>  +        return bool;
>  +    }
>  +
>  +    public void clear() {
>  +        clearInternal();
>  +        if (log.isTraceEnabled())
>  +            log.trace(s_loc.get("cache-clear", "<query-cache>"));
>  +    }
>  +
>  +    public void close() {
>  +        close(true);
>  +    }
>  +
>  +    protected void close(boolean clear) {
>  +        if (!_closed) {
>  +            if (clear)
>  +                clearInternal();
>  +            _closed = true;
>  +        }
>  +    }
>  +
>  +    public boolean isClosed() {
>  +        return _closed;
>  +    }
>  +
>  +    public void addTypesChangedListener(TypesChangedListener listen) {
>  +        addListener(listen);
>  +    }
>  +
>  +    public boolean removeTypesChangedListener(TypesChangedListener listen) {
>  +        return removeListener(listen);
>  +    }
>  +
>  +    /**
>  +     * This method is part of the {@link RemoteCommitListener} interface. If
>  +     * your cache subclass relies on OpenJPA for clustering support, make it
>  +     * implement <code>RemoteCommitListener</code>. This method will take
>  +     * care of invalidating entries from remote commits, by delegating to
>  +     * {@link #onTypesChanged}.
>  +     */
>  +    public void afterCommit(RemoteCommitEvent event) {
>  +        if (_closed)
>  +            return;
>  +
>  +        // drop all committed classes
>  +        Set classes = Caches.addTypesByName(conf,
>  +            event.getPersistedTypeNames(), null);
>  +        if (event.getPayloadType() == RemoteCommitEvent.PAYLOAD_EXTENTS) {
>  +            classes = Caches.addTypesByName(conf, event.getUpdatedTypeNames(),
>  +                classes);
>  +            classes = Caches.addTypesByName(conf, event.getDeletedTypeNames(),
>  +                classes);
>  +        } else {
>  +            classes = addTypes(event.getUpdatedObjectIds(), classes);
>  +            classes = addTypes(event.getDeletedObjectIds(), classes);
>  +        }
>  +        if (classes != null)
>  +            onTypesChanged(new TypesChangedEvent(this, classes));
>  +    }
>  +
>  +    /**
>  +     * Build up a set of classes for the given oids.
>  +     */
>  +    private Set addTypes(Collection oids, Set classes) {
>  +        if (oids.isEmpty())
>  +            return classes;
>  +        if (classes == null)
>  +            classes = new HashSet();
>  +
>  +        MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
>  +        ClassMetaData meta;
>  +        Object oid;
>  +        for (Iterator itr = oids.iterator(); itr.hasNext();) {
>  +            oid = itr.next();
>  +            if (oid instanceof Id)
>  +                classes.add(((Id) oid).getType());
>  +            else {
>  +                // ok if no metadata for oid; that just means the pc type
>  +                // probably hasn't been loaded into this JVM yet, and therefore
>  +                // there's no chance that it's in the cache anyway
>  +                meta = repos.getMetaData(oid, null, false);
>  +                if (meta != null)
>  +                    classes.add(meta.getDescribedType());
>  +            }
>  +        }
>  +        return classes;
>  +    }
>  +
>  +    /**
>  +     * Return a threadsafe view of the keys in this cache. This collection
>  +     * must be iterable without risk of concurrent modification exceptions.
>  +     * It does not have to implement contains() efficiently or use set
>  +     * semantics.
>  +     */
>  +    protected abstract Collection keySet();
>  +
>  +    /**
>  +     * Return the list for the given key.
>  +     */
>  +    protected abstract QueryResult getInternal(QueryKey qk);
>  +
>  +    /**
>  +     * Add the given result to the cache, returning the old result under the
>  +     * given key.
>  +     */
>  +    protected abstract QueryResult putInternal(QueryKey qk, QueryResult oids);
>  +
>  +    /**
>  +     * Remove the result under the given key from the cache.
>  +     */
>  +    protected abstract QueryResult removeInternal(QueryKey qk);
>  +
>  +    /**
>  +     * Remove all results under the given keys from the cache.
>  +     */
>  +    protected void removeAllInternal(Collection qks) {
>  +        for (Iterator iter = qks.iterator(); iter.hasNext();)
>  +            removeInternal((QueryKey) iter.next());
>  +    }
>  +
>  +    /**
>  +     * Clear the cache.
>  +     */
>  +    protected abstract void clearInternal();
>  +
>  +    /**
>  +     * Pin an object to the cache.
>  +     */
>  +    protected abstract boolean pinInternal(QueryKey qk);
>  +
>  +    /**
>  +     * Unpin an object from the cache.
>  +     */
>  +    protected abstract boolean unpinInternal(QueryKey qk);
>  +
>  +    // ---------- Configurable implementation ----------
>  +
>  +    public void setConfiguration(Configuration conf) {
>  +        this.conf = (OpenJPAConfiguration) conf;
>  +        this.log = conf.getLog(OpenJPAConfiguration.LOG_DATACACHE);
>  +    }
>  +
>  +    public void startConfiguration() {
>  +    }
>  +
>  +    public void endConfiguration() {
>  +    }
>  +
>  +    // ---------- AbstractEventManager implementation ----------
>  +
>  +    protected void fireEvent(Object event, Object listener) {
>  +        TypesChangedListener listen = (TypesChangedListener) listener;
>  +        TypesChangedEvent ev = (TypesChangedEvent) event;
>  +        try {
>  +            listen.onTypesChanged(ev);
>  +        } catch (Exception e) {
>  +            if (log.isWarnEnabled())
>  +                log.warn(s_loc.get("exp-listener-ex"), e);
>  +        }
>  +    }
>  +
>  +    /**
>  +     * Individual query results will be registered as types changed
>  +     * listeners. We want such query results to be gc'd once
>  +     * the only reference is held by the list of expiration listeners.
>  +     */
>  +    protected Collection newListenerCollection() {
>  +        return new ConcurrentReferenceHashSet (ConcurrentReferenceHashSet.WEAK);
>  +       }
>  +}
>
>
>



-- 
Patrick Linskey
202 669 5907

Mime
View raw message