[jboss-cvs] JBossAS SVN: r104203 - in projects/demos/microcontainer/trunk/infinispan: src/main/java/org/jboss/demos and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 23 12:08:24 EDT 2010
Author: alesj
Date: 2010-04-23 12:08:23 -0400 (Fri, 23 Apr 2010)
New Revision: 104203
Added:
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/infinispan/
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/infinispan/InfinispanMain.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerBeanDeployer.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerParsingDeployer.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSBeanDeployer.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSFactory.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSMetaData.java
projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSParsingDeployer.java
Modified:
projects/demos/microcontainer/trunk/infinispan/pom.xml
Log:
Infinispan integration.
Modified: projects/demos/microcontainer/trunk/infinispan/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/pom.xml 2010-04-23 15:54:03 UTC (rev 104202)
+++ projects/demos/microcontainer/trunk/infinispan/pom.xml 2010-04-23 16:08:23 UTC (rev 104203)
@@ -13,6 +13,10 @@
<description>JBoss MC Demos</description>
<dependencies>
+ <dependency>
+ <groupId>org.jboss.demos</groupId>
+ <artifactId>jboss-demos-bootstrap</artifactId>
+ </dependency>
<!-- Compile (global dependencies) -->
<dependency>
<groupId>org.jboss</groupId>
@@ -22,6 +26,42 @@
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-structure-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-jmx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/infinispan/InfinispanMain.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/infinispan/InfinispanMain.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/bootstrap/infinispan/InfinispanMain.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,30 @@
+/*
+ * 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.bootstrap.infinispan;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class InfinispanMain
+{
+}
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerBeanDeployer.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerBeanDeployer.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerBeanDeployer.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,60 @@
+/*
+ * 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.infinispan.deployers;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+import org.infinispan.manager.CacheManager;
+
+/**
+ * Deploy cache manager as MC bean.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CacheManagerBeanDeployer extends AbstractSimpleRealDeployer<CacheManager>
+{
+ public CacheManagerBeanDeployer()
+ {
+ super(CacheManager.class);
+ setStage(DeploymentStages.PRE_REAL);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, CacheManager cm) throws DeploymentException
+ {
+ String name = getCacheManagerName(unit);
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, CacheManager.class.getName());
+ builder.setConstructorValue(cm);
+ unit.addAttachment(name + "_" + BeanMetaData.class.getName(), builder.getBeanMetaData(), BeanMetaData.class);
+ }
+
+ static String getCacheManagerName(DeploymentUnit unit)
+ {
+ return CacheManager.class.getSimpleName() + "-" + unit.getSimpleName();
+ }
+}
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerParsingDeployer.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerParsingDeployer.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/CacheManagerParsingDeployer.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,60 @@
+/*
+ * 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.infinispan.deployers;
+
+import java.io.InputStream;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.vfs.VirtualFile;
+
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+
+/**
+ * Deploy cache manager from config file.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CacheManagerParsingDeployer extends AbstractVFSParsingDeployer<CacheManager>
+{
+ public CacheManagerParsingDeployer()
+ {
+ super(CacheManager.class);
+ setName("jboss-infinispan.xml");
+ }
+
+ @Override
+ protected CacheManager parse(VFSDeploymentUnit unit, VirtualFile file, CacheManager root) throws Exception
+ {
+ InputStream is = file.openStream();
+ try
+ {
+ return new DefaultCacheManager(is, false);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+}
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSBeanDeployer.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSBeanDeployer.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSBeanDeployer.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,67 @@
+/*
+ * 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.infinispan.deployers;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+import org.infinispan.io.GridFilesystem;
+import org.infinispan.manager.CacheManager;
+
+/**
+ * Deploy cache manager as MC bean.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GFSBeanDeployer extends AbstractSimpleRealDeployer<CacheManager>
+{
+ public GFSBeanDeployer()
+ {
+ super(CacheManager.class);
+ setStage(DeploymentStages.PRE_REAL);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, CacheManager cm) throws DeploymentException
+ {
+ GFSMetaData gfs = unit.getAttachment(GFSMetaData.class);
+ if (gfs == null)
+ gfs = GFSMetaData.DEFAULT;
+
+ String name = GridFilesystem.class.getSimpleName() + "#" + unit.getSimpleName();
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, GridFilesystem.class.getName());
+ builder.setFactoryClass(GFSFactory.class.getName());
+ builder.setFactoryMethod("create");
+ // let's go over injection, so we know CM is already fully installed
+ ValueMetaData cmInjection = builder.createInject(CacheManagerBeanDeployer.getCacheManagerName(unit));
+ builder.addConstructorParameter(CacheManager.class.getName(), cmInjection);
+ builder.addConstructorParameter(GFSMetaData.class.getName(), gfs);
+
+ unit.addAttachment(name + "_" + BeanMetaData.class.getName(), builder.getBeanMetaData());
+ }
+}
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSFactory.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSFactory.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSFactory.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,58 @@
+/*
+ * 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.infinispan.deployers;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+import org.infinispan.Cache;
+import org.infinispan.io.GridFile;
+import org.infinispan.io.GridFilesystem;
+import org.infinispan.manager.CacheManager;
+
+/**
+ * Deploy cache manager as MC bean.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GFSFactory
+{
+ /**
+ * Create grid file system.
+ *
+ * @param cm the cache manager
+ * @param gfsmd the gfs metadata
+ * @return new grid file system
+ */
+ public static GridFilesystem create(CacheManager cm, GFSMetaData gfsmd)
+ {
+ Cache<String,byte[]> data = cm.getCache(gfsmd.getData());
+ Cache<String, GridFile.Metadata> metadata = cm.getCache(gfsmd.getMetadata());
+ data.start();
+ metadata.start();
+ return new GridFilesystem(data, metadata);
+ }
+}
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSMetaData.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSMetaData.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSMetaData.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,59 @@
+/*
+ * 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.infinispan.deployers;
+
+import java.io.Serializable;
+
+/**
+ * Deploy cache manager from config file.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GFSMetaData implements Serializable
+{
+ private static final long serialVersionUID = 1l;
+ public static final GFSMetaData DEFAULT = new GFSMetaData();
+
+ private String data = "data";
+ private String metadata = "metadata";
+
+ private GFSMetaData()
+ {
+ }
+
+ public GFSMetaData(String data, String metadata)
+ {
+ this.data = data;
+ this.metadata = metadata;
+ }
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public String getMetadata()
+ {
+ return metadata;
+ }
+}
\ No newline at end of file
Added: projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSParsingDeployer.java
===================================================================
--- projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSParsingDeployer.java (rev 0)
+++ projects/demos/microcontainer/trunk/infinispan/src/main/java/org/jboss/demos/infinispan/deployers/GFSParsingDeployer.java 2010-04-23 16:08:23 UTC (rev 104203)
@@ -0,0 +1,64 @@
+/*
+ * 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.infinispan.deployers;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Grid file system metadata.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class GFSParsingDeployer extends AbstractVFSParsingDeployer<GFSMetaData>
+{
+ public GFSParsingDeployer()
+ {
+ super(GFSMetaData.class);
+ setName("gfs.txt");
+ }
+
+ @Override
+ protected GFSMetaData parse(VFSDeploymentUnit unit, VirtualFile file, GFSMetaData root) throws Exception
+ {
+ InputStream is = file.openStream();
+ try
+ {
+ Properties props = new Properties();
+ props.load(is);
+
+ String data = props.getProperty("data", GFSMetaData.DEFAULT.getData());
+ String metadata = props.getProperty("metadata", GFSMetaData.DEFAULT.getMetadata());
+
+ return new GFSMetaData(data, metadata);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list