You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by hc...@apache.org on 2005/02/02 12:22:26 UTC
cvs commit: jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/core CacheChangeSupport.java ICacheChangeHandler.java ICacheChangeListener.java
hchar 2005/02/02 03:22:26
Added: sandbox/yajcache/src/org/apache/jcs/yajcache/beans
CacheChangeEvent.java CacheChangeEventType.java
CacheChangeSupport.java CacheClearEvent.java
CachePutBeanCloneEvent.java
CachePutBeanCopyEvent.java CachePutCopyEvent.java
CachePutEvent.java CacheRemoveEvent.java
ICacheChangeHandler.java ICacheChangeListener.java
Removed: sandbox/yajcache/src/org/apache/jcs/yajcache/event
CacheChangeEvent.java CacheChangeEventType.java
CacheClearEvent.java CachePutBeanCloneEvent.java
CachePutBeanCopyEvent.java CachePutCopyEvent.java
CachePutEvent.java CacheRemoveEvent.java
sandbox/yajcache/src/org/apache/jcs/yajcache/core
CacheChangeSupport.java ICacheChangeHandler.java
ICacheChangeListener.java
Log:
move to package o.a.j.y.beans
Revision Changes Path
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CacheChangeEvent.java
Index: CacheChangeEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public abstract class CacheChangeEvent<V> extends java.util.EventObject {
/** Creates a new instance of CacheEvent */
protected CacheChangeEvent(@NonNullable ICache<V> cache) {
super(cache);
}
/** Returns the cache which is the source of the events. */
protected @NonNullable ICache<V> getCache() {
return (ICache<V>)super.getSource();
}
/**
* Dispatches the beans handling to the specific method invokation of the
* given handler.
*/
public abstract boolean dispatch(@NonNullable ICacheChangeHandler<V> handler);
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CacheChangeEventType.java
Index: CacheChangeEventType.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
* @author Hanson Char
*/
// @CopyRightApache
// http://www.netbeans.org/issues/show_bug.cgi?id=53704
@TODO("Remove this class: no longer needed")
public enum CacheChangeEventType {
CLEAR_CACHE,
PUT,
PUT_BEAN_CLONE,
PUT_BEAN_COPY,
PUT_COPY,
REMOVE
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CacheChangeSupport.java
Index: CacheChangeSupport.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.beans.CacheChangeEvent;
import org.apache.jcs.yajcache.beans.CacheClearEvent;
import org.apache.jcs.yajcache.beans.CachePutEvent;
import org.apache.jcs.yajcache.beans.CacheRemoveEvent;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CacheChangeSupport<V> {
private final @NonNullable List<ICacheChangeListener<V>> listeners
= new CopyOnWriteArrayList<ICacheChangeListener<V>>();
private ICache<V> cache;
public CacheChangeSupport(@NonNullable ICache<V> cache) {
this.cache = cache;
}
public void addCacheChangeListener(@NonNullable ICacheChangeListener<V> listener)
{
listeners.add(listener);
}
public void removeCacheChangeListener(@NonNullable ICacheChangeListener<V> listener)
{
listeners.remove(listener);
}
public @NonNullable Iterable<ICacheChangeListener<V>> getCacheChangeListeners()
{
return listeners;
}
public void fireCacheChange(@NonNullable CacheChangeEvent<V> evt)
{
for (ICacheChangeListener<V> listener : this.listeners) {
listener.cacheChange(evt);
}
}
public void fireCachePut(@NonNullable String key, @NonNullable V value)
{
this.fireCacheChange(new CachePutEvent<V>(this.cache, key, value));
}
public void fireCacheRemove(@NonNullable String key)
{
this.fireCacheChange(new CacheRemoveEvent<V>(this.cache, key));
}
public void fireCacheClear()
{
this.fireCacheChange(new CacheClearEvent<V>(this.cache));
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CacheClearEvent.java
Index: CacheClearEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CacheClearEvent<V> extends CacheChangeEvent<V> {
public CacheClearEvent(@NonNullable ICache<V> cache)
{
super(cache);
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handleClear(super.getCache().getName());
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CachePutBeanCloneEvent.java
Index: CachePutBeanCloneEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CachePutBeanCloneEvent<V> extends CachePutEvent<V> {
protected CachePutBeanCloneEvent(@NonNullable ICache<V> cache,
@NonNullable String key, @NonNullable V val)
{
super(cache, key, val);
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handlePutBeanClone(
super.getCache().getName(), super.getKey(), super.getValue());
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CachePutBeanCopyEvent.java
Index: CachePutBeanCopyEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CachePutBeanCopyEvent<V> extends CachePutEvent<V> {
public CachePutBeanCopyEvent(@NonNullable ICache<V> cache,
@NonNullable String key, @NonNullable V val)
{
super(cache, key, val);
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handlePutBeanCopy(
super.getCache().getName(), super.getKey(), super.getValue());
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CachePutCopyEvent.java
Index: CachePutCopyEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CachePutCopyEvent<V> extends CachePutEvent<V> {
public CachePutCopyEvent(@NonNullable ICache<V> cache,
@NonNullable String key, @NonNullable V val)
{
super(cache, key, val);
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handlePutCopy(
super.getCache().getName(), super.getKey(), super.getValue());
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CachePutEvent.java
Index: CachePutEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CachePutEvent<V> extends CacheChangeEvent<V> {
private final @NonNullable String key;
private final @NonNullable V value;
public CachePutEvent(@NonNullable ICache<V> cache,
@NonNullable String key, @NonNullable V value)
{
super(cache);
this.key = key;
this.value = value;
}
public @NonNullable String getKey() {
return key;
}
public @NonNullable V getValue() {
return value;
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handlePut(
super.getCache().getName(), this.key, this.value);
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/CacheRemoveEvent.java
Index: CacheRemoveEvent.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
import org.apache.jcs.yajcache.core.ICache;
/**
*
* @author Hanson Char
*/
@CopyRightApache
public class CacheRemoveEvent<V> extends CacheChangeEvent<V> {
private final @NonNullable String key;
public CacheRemoveEvent(@NonNullable ICache<V> cache,
@NonNullable String key)
{
super(cache);
this.key = key;
}
public @NonNullable String getKey() {
return key;
}
@Override
public boolean dispatch(@NonNullable ICacheChangeHandler<V> handler) {
return handler.handleRemove(super.getCache().getName(), this.key);
}
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/ICacheChangeHandler.java
Index: ICacheChangeHandler.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
* Cache change beans listener/handler.
*
* @author Hanson CHar
*/
@CopyRightApache
public interface ICacheChangeHandler<V> {
public boolean handlePut(@NonNullable String cacheName,
@NonNullable String key, @NonNullable V value);
public boolean handlePutCopy(@NonNullable String cacheName,
@NonNullable String key, @NonNullable V value);
public boolean handlePutBeanCopy(@NonNullable String cacheName,
@NonNullable String key, @NonNullable V value);
public boolean handlePutBeanClone(@NonNullable String cacheName,
@NonNullable String key, @NonNullable V value);
public boolean handleRemove(
@NonNullable String cacheName, @NonNullable String key);
public boolean handleClear(@NonNullable String cacheName);
}
1.1 jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/beans/ICacheChangeListener.java
Index: ICacheChangeListener.java
===================================================================
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed 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.jcs.yajcache.beans;
import org.apache.jcs.yajcache.beans.CacheChangeEvent;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
* Cache change beans listener/handler.
*
* @author Hanson CHar
*/
@CopyRightApache
public interface ICacheChangeListener<V> extends java.util.EventListener {
public void cacheChange(@NonNullable CacheChangeEvent<V> evt);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org