mx4j/src/core/mx4j/persist FilePersister.java,1.7,1.8 MBeanPersister.java,1.5,1.6 Persister.java,1.3,1.4 PersisterMBean.java,1.4,1.5
Simone Bordet <[email protected]> Sat, 04 Sep 2004 15:44:11 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/persist
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13665/src/core/mx4j/persist
Modified Files:
FilePersister.java MBeanPersister.java Persister.java
PersisterMBean.java
Log Message:
Updated copyright notice to be:
Copyright (C) The MX4J Contributors
Index: MBeanPersister.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/persist/MBeanPersister.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MBeanPersister.java 20 Jan 2003 19:46:30 -0000 1.5
--- MBeanPersister.java 4 Sep 2004 15:44:09 -0000 1.6
***************
*** 1,4 ****
/*
! * Copyright (C) MX4J.
* All rights reserved.
*
--- 1,4 ----
/*
! * Copyright (C) The MX4J Contributors.
* All rights reserved.
*
***************
*** 24,50 ****
public class MBeanPersister extends Persister
{
! private MBeanServer m_server;
! private ObjectName m_name;
! private PersisterMBean m_proxy;
! /**
! * Creates a new MBeanPersister that delegates persistence to a persister MBean
! * registered in the specified MBeanServer with the specified ObjectName.
! */
! public MBeanPersister(MBeanServer server, ObjectName name)
! {
! m_server = server;
! m_name = name;
! m_proxy = (PersisterMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, PersisterMBean.class, false);
! }
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! return m_proxy.load();
! }
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! m_proxy.store(data);
! }
}
--- 24,50 ----
public class MBeanPersister extends Persister
{
! private MBeanServer m_server;
! private ObjectName m_name;
! private PersisterMBean m_proxy;
! /**
! * Creates a new MBeanPersister that delegates persistence to a persister MBean
! * registered in the specified MBeanServer with the specified ObjectName.
! */
! public MBeanPersister(MBeanServer server, ObjectName name)
! {
! m_server = server;
! m_name = name;
! m_proxy = (PersisterMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, PersisterMBean.class, false);
! }
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! return m_proxy.load();
! }
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! m_proxy.store(data);
! }
}
Index: PersisterMBean.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/persist/PersisterMBean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PersisterMBean.java 7 Sep 2002 19:57:01 -0000 1.4
--- PersisterMBean.java 4 Sep 2004 15:44:09 -0000 1.5
***************
*** 1,4 ****
/*
! * Copyright (C) MX4J.
* All rights reserved.
*
--- 1,4 ----
/*
! * Copyright (C) The MX4J Contributors.
* All rights reserved.
*
***************
*** 9,15 ****
package mx4j.persist;
import javax.management.MBeanException;
import javax.management.RuntimeOperationsException;
- import javax.management.InstanceNotFoundException;
/**
--- 9,15 ----
package mx4j.persist;
+ import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.RuntimeOperationsException;
/**
***************
*** 21,34 ****
public interface PersisterMBean
{
! /**
! * Loads the information persisted on the storage media.
! * @see #store
! */
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException;
! /**
! * Store the given information to the storage media.
! * @see #load
! */
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException;
}
--- 21,36 ----
public interface PersisterMBean
{
! /**
! * Loads the information persisted on the storage media.
! *
! * @see #store
! */
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException;
! /**
! * Store the given information to the storage media.
! *
! * @see #load
! */
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException;
}
Index: FilePersister.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/persist/FilePersister.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** FilePersister.java 24 Dec 2002 13:41:07 -0000 1.7
--- FilePersister.java 4 Sep 2004 15:44:09 -0000 1.8
***************
*** 1,4 ****
/*
! * Copyright (C) MX4J.
* All rights reserved.
*
--- 1,4 ----
/*
! * Copyright (C) The MX4J Contributors.
* All rights reserved.
*
***************
*** 9,27 ****
package mx4j.persist;
- import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
! import java.io.ObjectOutputStream;
! import java.io.FileInputStream;
! import java.io.ObjectInputStream;
import java.io.NotSerializableException;
import java.io.Serializable;
!
! import mx4j.loading.ClassLoaderObjectInputStream;
!
import javax.management.MBeanException;
import javax.management.RuntimeOperationsException;
! import javax.management.InstanceNotFoundException;
/**
--- 9,26 ----
package mx4j.persist;
import java.io.File;
+ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
! import java.io.IOException;
import java.io.NotSerializableException;
+ import java.io.ObjectInputStream;
+ import java.io.ObjectOutputStream;
import java.io.Serializable;
! import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.RuntimeOperationsException;
!
! import mx4j.loading.ClassLoaderObjectInputStream;
/**
***************
*** 34,94 ****
public class FilePersister extends Persister
{
! private File m_store;
! /**
! * Creates a new FilePersister.
! * @param location the directory where the file will be written (must already exist);
! * if null the name is used as a location
! * @param name the file name used to store information
! */
! public FilePersister(String location, String name) throws MBeanException
! {
! if (name == null) {throw new MBeanException(new IllegalArgumentException("Persist name cannot be null"));}
! if (location != null)
! {
! File dir = new File(location);
! if (!dir.exists()) {throw new MBeanException(new FileNotFoundException(location));}
! m_store = new File(dir, name);
! }
! else
! {
! m_store = new File(name);
! }
! }
! /**
! * Returns the path where the information is stored.
! */
! public String getFileName() {return m_store.getAbsolutePath();}
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! FileInputStream fin = null;
! ObjectInputStream clois = null;
! Object result = null;
! synchronized(this)
! {
! try
! {
! // Create the inputStream
! fin = new FileInputStream(m_store);
! // Use the ClassLoaderObjectInputStream
! clois = new ClassLoaderObjectInputStream(fin, Thread.currentThread().getContextClassLoader());
! try
! {
! // Try load the object using the ContextClassLoader
! result = clois.readObject();
! }
! catch(ClassNotFoundException ex)
! {
! // Close previous streams, FileInputStream does not support reset(),
! // so I have to create a new one
! try {clois.close();}
! catch (IOException ignored) {}
! throw new MBeanException(ex);
/*
// Try using the DefaultLoaderRepository
--- 33,108 ----
public class FilePersister extends Persister
{
! private File m_store;
! /**
! * Creates a new FilePersister.
! *
! * @param location the directory where the file will be written (must already exist);
! * if null the name is used as a location
! * @param name the file name used to store information
! */
! public FilePersister(String location, String name) throws MBeanException
! {
! if (name == null)
! {
! throw new MBeanException(new IllegalArgumentException("Persist name cannot be null"));
! }
! if (location != null)
! {
! File dir = new File(location);
! if (!dir.exists())
! {
! throw new MBeanException(new FileNotFoundException(location));
! }
! m_store = new File(dir, name);
! }
! else
! {
! m_store = new File(name);
! }
! }
! /**
! * Returns the path where the information is stored.
! */
! public String getFileName()
! {
! return m_store.getAbsolutePath();
! }
! public Object load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! FileInputStream fin = null;
! ObjectInputStream clois = null;
! Object result = null;
! synchronized (this)
! {
! try
! {
! // Create the inputStream
! fin = new FileInputStream(m_store);
! // Use the ClassLoaderObjectInputStream
! clois = new ClassLoaderObjectInputStream(fin, Thread.currentThread().getContextClassLoader());
! try
! {
! // Try load the object using the ContextClassLoader
! result = clois.readObject();
! }
! catch (ClassNotFoundException ex)
! {
! // Close previous streams, FileInputStream does not support reset(),
! // so I have to create a new one
! try
! {
! clois.close();
! }
! catch (IOException ignored)
! {
! }
! throw new MBeanException(ex);
/*
// Try using the DefaultLoaderRepository
***************
*** 104,151 ****
}
*/
! }
! }
! catch (IOException ex)
! {
! throw new MBeanException(ex);
! }
! finally
! {
! try {clois.close();}
! catch (IOException ignored) {}
! }
! }
! return result;
! }
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! if(data == null) throw new RuntimeOperationsException(new IllegalArgumentException("Cannot store a null object."));
! if(!(data instanceof Serializable)) throw new MBeanException(new NotSerializableException(data.getClass().getName() + " must implement java.io.Serializable"));
! FileOutputStream fos = null;
! ObjectOutputStream oos = null;
! synchronized(this)
! {
! try
! {
! fos = new FileOutputStream(m_store);
! oos = new ObjectOutputStream(fos);
! }
! catch(IOException ex) {throw new MBeanException(ex); }
! try
! {
! //write out the data
! oos.writeObject(data);
! // flush the stream
! oos.flush();
! }
! catch(IOException ex) {throw new MBeanException(ex); }
! finally
! {
! try {oos.close();}
! catch(IOException ex){/* unable to close the stream nothing to do*/}
! }
! }
! }
}
--- 118,181 ----
}
*/
! }
! }
! catch (IOException ex)
! {
! throw new MBeanException(ex);
! }
! finally
! {
! try
! {
! clois.close();
! }
! catch (IOException ignored)
! {
! }
! }
! }
! return result;
! }
! public void store(Object data) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
! {
! if (data == null) throw new RuntimeOperationsException(new IllegalArgumentException("Cannot store a null object."));
! if (!(data instanceof Serializable)) throw new MBeanException(new NotSerializableException(data.getClass().getName() + " must implement java.io.Serializable"));
! FileOutputStream fos = null;
! ObjectOutputStream oos = null;
! synchronized (this)
! {
! try
! {
! fos = new FileOutputStream(m_store);
! oos = new ObjectOutputStream(fos);
! }
! catch (IOException ex)
! {
! throw new MBeanException(ex);
! }
! try
! {
! //write out the data
! oos.writeObject(data);
! // flush the stream
! oos.flush();
! }
! catch (IOException ex)
! {
! throw new MBeanException(ex);
! }
! finally
! {
! try
! {
! oos.close();
! }
! catch (IOException ex)
! {/* unable to close the stream nothing to do*/
! }
! }
! }
! }
}
Index: Persister.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/persist/Persister.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Persister.java 8 Jun 2002 12:59:25 -0000 1.3
--- Persister.java 4 Sep 2004 15:44:09 -0000 1.4
***************
*** 1,4 ****
/*
! * Copyright (C) MX4J.
* All rights reserved.
*
--- 1,4 ----
/*
! * Copyright (C) The MX4J Contributors.
* All rights reserved.
*
***************
*** 9,13 ****
package mx4j.persist;
- import mx4j.persist.PersisterMBean;
/**
--- 9,12 ----
***************
*** 17,19 ****
* @version $Revision$
*/
! public abstract class Persister implements PersisterMBean {}
--- 16,20 ----
* @version $Revision$
*/
! public abstract class Persister implements PersisterMBean
! {
! }
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click