You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by co...@apache.org on 2003/01/11 08:29:07 UTC
cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant RegistryTask.java
costin 2003/01/10 23:29:07
Modified: modeler/src/java/org/apache/commons/modeler/ant
RegistryTask.java
Log:
Added the ability to save a .ser form of the metadata.
Revision Changes Path
1.4 +32 -11 jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant/RegistryTask.java
Index: RegistryTask.java
===================================================================
RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant/RegistryTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RegistryTask.java 29 Dec 2002 18:01:42 -0000 1.3
+++ RegistryTask.java 11 Jan 2003 07:29:07 -0000 1.4
@@ -62,11 +62,12 @@
import java.io.*;
-import java.net.*;
-import java.lang.reflect.*;
-import java.util.*;
-import org.apache.commons.modeler.BaseRegistry;
+import java.net.URL;
+
import org.apache.commons.modeler.ManagedBean;
+import org.apache.commons.modeler.Registry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.BuildException;
/**
@@ -75,6 +76,7 @@
* @author Costin Manolache
*/
public final class RegistryTask {
+ private static Log log = LogFactory.getLog(RegistryTask.class);
public RegistryTask() {
}
@@ -99,21 +101,40 @@
this.resource=res;
}
+ String outFile;
+
+ public void setOut( String outFile ) {
+ this.outFile=outFile;
+ }
+
public void execute() throws Exception {
- InputStream is=null;
- String id=null;
+ URL url=null;
if( resource != null ) {
- is=this.getClass().getClassLoader().getResourceAsStream(resource);
- id=resource;
+ url=this.getClass().getClassLoader().getResource(resource);
} else if( file != null ) {
- is=new FileInputStream( file );
- id=file;
+ File f=new File(file);
+ url=new URL("file", null, f.getAbsolutePath());
} else {
throw new BuildException( "Resource or file attribute required");
}
- BaseRegistry.getBaseRegistry().loadDescriptors( resource, is, type );
+ Registry.getRegistry().loadDescriptors( type, url);
+
+ if( outFile !=null ) {
+ FileOutputStream fos=new FileOutputStream(outFile);
+ ObjectOutputStream oos=new ObjectOutputStream(fos);
+ Registry reg=Registry.getRegistry();
+ String beans[]=reg.findManagedBeans();
+ ManagedBean mbeans[]=new ManagedBean[beans.length];
+ for( int i=0; i<beans.length; i++ ) {
+ mbeans[i]=reg.findManagedBean(beans[i]);
+ }
+ oos.writeObject( mbeans );
+ oos.flush();
+ oos.close();
+ fos.close();
+ }
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>