[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/notification ...
Jason Thomas Greene
jgreene at jboss.com
Sun Apr 22 22:53:22 EDT 2007
User: jgreene
Date: 07/04/22 22:53:22
Added: src/org/jboss/cache/pojo/notification
AttachNotification.java DetachNotification.java
FieldModifyNotification.java
ListModifyNotification.java
MapModifyNotification.java Notification.java
NotificationContext.java SetModifyNotification.java
Log:
Introduce new notification API
Remove mixin approach
Revision Changes Path
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/AttachNotification.java
Index: AttachNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
/**
* A notification that indicates an object was attached to the cache instance.
*
* @author Jason T. Greene
*/
public final class AttachNotification extends Notification
{
public AttachNotification(NotificationContext context, Object source, Phase phase, boolean local)
{
super(context, source, phase, local);
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/DetachNotification.java
Index: DetachNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
/**
* A notification that indicates an object was detached from the cache instance.
*
* @author Jason T. Greene
*/
public final class DetachNotification extends Notification
{
public DetachNotification(NotificationContext context, Object source, Phase phase, boolean local)
{
super(context, source, phase, local);
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/FieldModifyNotification.java
Index: FieldModifyNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import java.lang.reflect.Field;
/**
* A notification that indicates a field was changed on an attached object.
*
* @author Jason T. Greene.
*/
public final class FieldModifyNotification extends Notification
{
private final Field field;
private final Object value;
public FieldModifyNotification(NotificationContext context, Object source, Field field, Object value, Phase phase, boolean local)
{
super(context, source, phase, local);
this.field = field;
this.value = value;
}
/**
* Gets the field that was or is being modified (depending on the notification phase).
*
* @return the modified field
*/
public Field getField()
{
return field;
}
/**
* Gets the new value that this field is being set to.
*
* @return the new value
*/
public Object getValue()
{
return value;
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/ListModifyNotification.java
Index: ListModifyNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import java.util.List;
/**
* A notification that indicates an attached List was modified.
*
* @author Jason T. Greene
*/
public final class ListModifyNotification extends Notification
{
public enum Operation {ADD, SET, REMOVE}
private final Operation operation;
private final int index;
private final Object value;
public ListModifyNotification(NotificationContext context, List source, Operation operation, int index, Object value, Phase phase, boolean local)
{
super(context, source, phase, local);
this.operation = operation;
this.index = index;
this.value = value;
}
/**
* Gets the index of the change. For an add operation this may be equal to the current size (append).
*
* @return the index of this change
*/
public Object getIndex()
{
return index;
}
/**
* Gets the new value for this change. Returns null on a remove operation.
*
* @return the new value, or null if remove
*/
public Object getValue()
{
return value;
}
/**
* Gets the operation of this change.
*
* @return the operation.
*/
public Operation getOperation()
{
return operation;
}
@Override
public List getSource()
{
return (List) super.getSource();
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/MapModifyNotification.java
Index: MapModifyNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import java.util.Map;
/**
* A notification that indicates an attached Map was modified.
*
* @author Jason T. Greene
*/
public final class MapModifyNotification extends Notification
{
public enum Operation {PUT, REMOVE}
private final Operation operation;
private final Object key;
private final Object value;
public MapModifyNotification(NotificationContext context, Map source, Operation operation, Object key, Object value, Phase phase, boolean local)
{
super(context, source, phase, local);
this.operation = operation;
this.key = key;
this.value = value;
}
/**
* Gets the operation of this change.
*
* @return the operation.
*/
public Operation getOperation()
{
return operation;
}
/**
* Gets the new value for this change. Returns null on a remove operation.
*
* @return the new value, or null if remove
*/
public Object getValue()
{
return value;
}
/**
* Gets the key for the modified entry.
*
* @return the key
*/
public Object getKey()
{
return value;
}
@Override
public Map getSource()
{
return (Map) super.getSource();
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/Notification.java
Index: Notification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import java.util.EventObject;
/**
* Base class for all POJO Cache notifications.
*
* @author Jason T. Greene
*/
public abstract class Notification extends EventObject
{
public enum Phase {PRE, POST};
private final NotificationContext context;
private final Phase phase;
private final boolean local;
public Notification(NotificationContext context, Object source, Phase phase, boolean local)
{
super(source);
this.context = context;
this.phase = phase;
this.local = local;
}
/**
* Get the phase of this notification. The "PRE" phase occurs before the
* event this notification represents; likewise, the "POST" phase occurs after
* the event represented by this notification.
*
* @return the phase this notification represents.
*/
public Phase getPhase()
{
return phase;
}
/**
* Determines if this event originated locally.
*
* @return true if this event originated locally, otherwise false.
*/
public boolean isLocal()
{
return local;
}
/**
* Obtain the context associated with this notification.
*
* @return the notification context
*/
public NotificationContext getContext()
{
return context;
}
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/NotificationContext.java
Index: NotificationContext.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import org.jboss.cache.pojo.PojoCache;
/**
* The context currently associated with a Notification.
*
* @author Jason T. Greene
*/
public interface NotificationContext
{
/**
* Obtains the cache instance that triggered this notification.
*
* @return a pojo cache instance.
*/
public PojoCache getPojoCache();
}
1.1 date: 2007/04/23 02:53:22; author: jgreene; state: Exp;JBossCache/src/org/jboss/cache/pojo/notification/SetModifyNotification.java
Index: SetModifyNotification.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.notification;
import java.util.Set;
/**
* A notification that indicates an attached Set was modified.
*
* @author Jason T. Greene
*/
public final class SetModifyNotification extends Notification
{
public enum Operation {ADD, REMOVE}
private final Operation operation;
private final Object value;
public SetModifyNotification(NotificationContext context, Set source, Operation operation, Object value, Phase phase, boolean local)
{
super(context, source, phase, local);
this.operation = operation;
this.value = value;
}
/**
* Gets the operation of this change.
*
* @return the operation.
*/
public Operation getOperation()
{
return operation;
}
/**
* Gets the new value for this change. Returns null on a remove operation.
*
* @return the new value, or null if remove
*/
public Object getValue()
{
return value;
}
@Override
public Set getSource()
{
return (Set) super.getSource();
}
}
More information about the jboss-cvs-commits
mailing list