[jboss-cvs] JBossAS SVN: r104308 - in projects/demos/microcontainer/trunk/gfs/src/main: resources/META-INF and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 29 08:58:17 EDT 2010
Author: alesj
Date: 2010-04-29 08:58:16 -0400 (Thu, 29 Apr 2010)
New Revision: 104308
Added:
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Reader.java
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Writer.java
Removed:
projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java
Modified:
projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml
Log:
Split between writer and reader.
Added: projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Reader.java
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Reader.java (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Reader.java 2010-04-29 12:58:16 UTC (rev 104308)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.demos.gfs;
+
+import java.io.InputStream;
+
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+import org.infinispan.io.GridFilesystem;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class Reader
+{
+ private GridFilesystem gfs;
+
+ public Reader(GridFilesystem gfs)
+ {
+ if (gfs == null)
+ throw new IllegalArgumentException("Null GFS");
+ this.gfs = gfs;
+ }
+
+ public void start() throws Exception
+ {
+ VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode());
+ VirtualFile file = grid.getChild("movies/bond.iso");
+ InputStream is = file.openStream();
+ try
+ {
+ int ch;
+ while((ch = is.read()) != -1)
+ System.out.print((char)ch);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java 2010-04-29 12:46:46 UTC (rev 104307)
+++ projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Test.java 2010-04-29 12:58:16 UTC (rev 104308)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.demos.gfs;
-
-import java.io.*;
-
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.VirtualFile;
-
-import org.infinispan.io.GridFilesystem;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class Test
-{
- private GridFilesystem gfs;
-
- public Test(GridFilesystem gfs)
- {
- if (gfs == null)
- throw new IllegalArgumentException("Null GFS");
- this.gfs = gfs;
- }
-
- public void create(String path) throws Exception
- {
- File file = new File(path);
- if (file.exists() == false)
- throw new IllegalArgumentException("File doesn't exist: " + file);
-
- File movies = gfs.getFile("movies");
- if (movies.mkdir() == false)
- throw new IllegalArgumentException("Failed to create movies dir.");
-
- InputStream in = new FileInputStream(file);
- OutputStream out = gfs.getOutput("movies/bond.iso");
- byte[] buffer = new byte[20000];
- int len;
- while ((len = in.read(buffer, 0, buffer.length)) != -1)
- {
- out.write(buffer, 0, len);
- }
- in.close();
- out.close();
- }
-
- public void start() throws Exception
- {
- VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode());
- VirtualFile file = grid.getChild("movies/bond.iso");
- InputStream is = file.openStream();
- try
- {
- int ch;
- while((ch = is.read()) != -1)
- System.out.print((char)ch);
- }
- finally
- {
- is.close();
- }
- }
-
- public void stop() throws Exception
- {
- VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode());
- VirtualFile file = grid.getChild("movies/bond.iso");
- file.delete();
- }
-
- public void destroy() throws Exception
- {
- VirtualFile grid = VFS.getChild("GFS-" + gfs.hashCode());
- VirtualFile file = grid.getChild("movies/bond.iso");
- if (file.exists())
- throw new IllegalArgumentException("Didn't delete grid file: " + file);
-
- gfs.remove("movies", true);
- }
-}
Added: projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Writer.java
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Writer.java (rev 0)
+++ projects/demos/microcontainer/trunk/gfs/src/main/java/org/jboss/demos/gfs/Writer.java 2010-04-29 12:58:16 UTC (rev 104308)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.demos.gfs;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.infinispan.io.GridFilesystem;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class Writer
+{
+ private GridFilesystem gfs;
+
+ public Writer(GridFilesystem gfs)
+ {
+ if (gfs == null)
+ throw new IllegalArgumentException("Null GFS");
+ this.gfs = gfs;
+ }
+
+ public void start(String path) throws Exception
+ {
+ File file = new File(path);
+ if (file.exists() == false)
+ throw new IllegalArgumentException("File doesn't exist: " + file);
+
+ File movies = gfs.getFile("movies");
+ if (movies.mkdir() == false)
+ throw new IllegalArgumentException("Failed to create movies dir.");
+
+ InputStream in = new FileInputStream(file);
+ OutputStream out = gfs.getOutput("movies/bond.iso");
+ byte[] buffer = new byte[20000];
+ int len;
+ while ((len = in.read(buffer, 0, buffer.length)) != -1)
+ {
+ out.write(buffer, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ public void stop()
+ {
+ gfs.remove("movies/bond.iso", true);
+ gfs.remove("movies", true);
+ }
+}
\ No newline at end of file
Modified: projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml 2010-04-29 12:46:46 UTC (rev 104307)
+++ projects/demos/microcontainer/trunk/gfs/src/main/resources/META-INF/gfs-beans.xml 2010-04-29 12:58:16 UTC (rev 104308)
@@ -1,12 +1,19 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="Test" class="org.jboss.demos.gfs.Test">
+ <bean name="Writer" class="org.jboss.demos.gfs.Writer">
<constructor>
<parameter><inject/></parameter>
</constructor>
- <create>
+ <start>
<parameter>${demos.home}/gfs/bond.iso</parameter>
- </create>
+ </start>
</bean>
+ <bean name="Reader" class="org.jboss.demos.gfs.Reader">
+ <constructor>
+ <parameter><inject/></parameter>
+ </constructor>
+ <depends>Writer</depends>
+ </bean>
+
</deployment>
More information about the jboss-cvs-commits
mailing list