[jboss-cvs] JBossAS SVN: r79973 - in projects/demos/microcontainer/trunk/ioc/src/main: java/org/jboss/demos/ioc/builder and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 23 08:23:03 EDT 2008


Author: alesj
Date: 2008-10-23 08:23:03 -0400 (Thu, 23 Oct 2008)
New Revision: 79973

Added:
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExample.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExampleHolder.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderUtil.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/AdvancedTMSupplyer.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/MockTransactionManager.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/SimpleTMSupplyer.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/TMDemander.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RegistryChecker.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RepositoryManager.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/SimpleEntry.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/FullLifecycleBean.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/LifecycleChecker.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortBindingManager.java
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortsConfig.java
   projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/builder-util-beans.xml
Modified:
   projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/factory/EnhancedBeanFactory.java
   projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/demand-supply-beans.xml
   projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/install-beans.xml
   projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/lifecycle-beans.xml
   projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/value-factory-beans.xml
Log:
Add more ioc examples.

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExample.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExample.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExample.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.builder;
+
+import org.jboss.kernel.Kernel;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BuilderExample
+{
+   private Kernel kernel;
+
+   public void start(Kernel kernel)
+   {
+      this.kernel = kernel;
+   }
+
+   public Kernel getKernel()
+   {
+      return kernel;
+   }
+}
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExampleHolder.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExampleHolder.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderExampleHolder.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.builder;
+
+import org.jboss.kernel.Kernel;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BuilderExampleHolder
+{
+   private BuilderExample example;
+
+   public BuilderExampleHolder(BuilderExample example)
+   {
+      this.example = example;
+      Kernel kernel = example.getKernel();
+      if (kernel == null)
+         throw new IllegalArgumentException("Kernel should be setup in BuilderExample: " + example);
+   }
+
+   public BuilderExample getExample()
+   {
+      return example;
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderUtil.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderUtil.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/builder/BuilderUtil.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.builder;
+
+import org.jboss.beans.metadata.api.annotations.Constructor;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.kernel.spi.dependency.KernelController;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BuilderUtil
+{
+   private KernelController controller;
+
+   @Constructor
+   public BuilderUtil(@Inject(bean = KernelConstants.KERNEL_CONTROLLER_NAME) KernelController controller)
+   {
+      this.controller = controller;
+   }
+
+   public void create() throws Throwable
+   {
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("BUExample", BuilderExample.class.getName());
+      builder.addStartParameter(Kernel.class.getName(), KernelConstants.KERNEL_NAME);
+      controller.install(builder.getBeanMetaData());
+   }
+
+   public void destroy()
+   {
+      controller.uninstall("BUExample");
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/AdvancedTMSupplyer.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/AdvancedTMSupplyer.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/AdvancedTMSupplyer.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.demandsupply;
+
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AdvancedTMSupplyer
+{
+   public void start(Properties properties)
+   {
+      MockTransactionManager.setup(properties);
+   }
+}
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/MockTransactionManager.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/MockTransactionManager.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/MockTransactionManager.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.demandsupply;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MockTransactionManager
+{
+   private static MockTransactionManager singleton;
+   private Map<Object, Object> properties = new HashMap<Object, Object>();
+
+   private MockTransactionManager()
+   {
+   }
+
+   public synchronized static void setup(Map<Object, Object> properties)
+   {
+      System.out.println("Properties: " + properties);
+      if (singleton == null)
+         singleton = new MockTransactionManager();
+      if (properties != null)
+         singleton.properties.putAll(properties);
+   }
+
+   public static MockTransactionManager getInstance()
+   {
+      return singleton;
+   }
+
+   public Map<Object, Object> getProperties()
+   {
+      return properties;
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/SimpleTMSupplyer.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/SimpleTMSupplyer.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/SimpleTMSupplyer.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.demandsupply;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleTMSupplyer
+{
+   public void start()
+   {
+      MockTransactionManager.setup(System.getProperties());
+   }
+}
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/TMDemander.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/TMDemander.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/demandsupply/TMDemander.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.demandsupply;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TMDemander
+{
+   public void create()
+   {
+      MockTransactionManager tm = MockTransactionManager.getInstance();
+      if (tm == null)
+         throw new IllegalArgumentException("Demanding TM - should be setup!");
+   }
+}

Modified: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/factory/EnhancedBeanFactory.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/factory/EnhancedBeanFactory.java	2008-10-23 11:54:36 UTC (rev 79972)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/factory/EnhancedBeanFactory.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -37,7 +37,7 @@
    public Object createBean() throws Throwable
    {
       Object bean = super.createBean();
-      // enhance bean - using javassist
+      // TODO enhance bean - using javassist
       return bean;
    }
 }
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RegistryChecker.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RegistryChecker.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RegistryChecker.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.install;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RegistryChecker
+{
+   private RepositoryManager manager;
+   private int size;
+
+   public RegistryChecker(RepositoryManager manager)
+   {
+      this.manager = manager;
+   }
+
+   public void setSize(int size)
+   {
+      this.size = size;
+   }
+
+   public void start()
+   {
+      if (manager == null)
+         throw new IllegalArgumentException("Null manager!");
+      Map<String,Object> repository = manager.getRepository();
+      if (repository == null)
+         throw new IllegalArgumentException("Null repository");
+      if (size != repository.size())
+         throw new IllegalArgumentException("Illegal repository size: " + repository);
+   }
+}
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RepositoryManager.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RepositoryManager.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/RepositoryManager.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.install;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RepositoryManager
+{
+   private Map<String, Object> repository = new HashMap<String, Object>();
+
+   public void addEntry(String name, Object instance)
+   {
+      repository.put(name, instance);
+   }
+
+   public Map<String, Object> getRepository()
+   {
+      return repository;
+   }
+
+   public void removeEntry(String name)
+   {
+      repository.remove(name);
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/SimpleEntry.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/SimpleEntry.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/install/SimpleEntry.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.install;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleEntry
+{
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/FullLifecycleBean.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/FullLifecycleBean.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/FullLifecycleBean.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.lifecycle;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FullLifecycleBean
+{
+   private int state;
+
+   public void create()
+   {
+      state += 1;
+   }
+
+   public void start()
+   {
+      state += 2;
+   }
+
+   public int getState()
+   {
+      return state;
+   }
+
+   public void stop()
+   {
+      state -= 2;
+   }
+
+   public void destroy()
+   {
+      state -= 1;
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/LifecycleChecker.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/LifecycleChecker.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/lifecycle/LifecycleChecker.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.lifecycle;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleChecker
+{
+   private KernelController controller;
+
+   @Inject(bean = KernelConstants.KERNEL_CONTROLLER_NAME)
+   public void setController(KernelController controller)
+   {
+      this.controller = controller;
+   }
+
+   @Start
+   public void checkLifecycle()
+   {
+      Set<KernelControllerContext> contexts = controller.getInstantiatedContexts(FullLifecycleBean.class);
+      if (contexts != null && contexts.isEmpty() == false)
+      {
+         for (KernelControllerContext context : contexts)
+         {
+            String name = context.getName().toString();
+            int state = Integer.parseInt(name.split("-")[1]);
+            FullLifecycleBean bean = (FullLifecycleBean)context.getTarget();
+            if (state != bean.getState())
+               throw new IllegalArgumentException("Wrong state: " + context);
+         }
+      }
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortBindingManager.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortBindingManager.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortBindingManager.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.vf;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PortBindingManager
+{
+   private Map<String, Integer> bindings;
+
+   public PortBindingManager(Map<String, Integer> bindings)
+   {
+      this.bindings = bindings;
+   }
+
+   public Integer getPort(String key)
+   {
+      return getPort(key, null);
+   }
+
+   public Integer getPort(String key, Integer defaultValue)
+   {
+      if (bindings == null)
+         return defaultValue;
+
+      Integer value = bindings.get(key);
+      if (value != null)
+         return value;
+
+      if (defaultValue != null)
+         bindings.put(key, defaultValue);
+
+      return defaultValue;
+   }
+}

Added: projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortsConfig.java
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortsConfig.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/java/org/jboss/demos/ioc/vf/PortsConfig.java	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.demos.ioc.vf;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PortsConfig
+{
+   private Integer http;
+   private Integer ftp;
+   private Integer mail;
+   private Integer ssh;
+
+   public void setHttp(Integer http)
+   {
+      this.http = http;
+   }
+
+   public void setFtp(Integer ftp)
+   {
+      this.ftp = ftp;
+   }
+
+   public void setMail(Integer mail)
+   {
+      this.mail = mail;
+   }
+
+   public void setSsh(Integer ssh)
+   {
+      this.ssh = ssh;
+   }
+
+   public void start()
+   {
+      check(http, 80);
+      check(ftp, 21);      
+      check(mail, 25);
+      check(ssh, 22);
+   }
+
+   protected void check(Integer value, Integer expected)
+   {
+      if (expected.equals(value) == false)
+         throw new IllegalArgumentException("Illegal value: " + value + ", expecting: " + expected);
+   }
+}

Copied: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/builder-util-beans.xml (from rev 79091, projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/value-factory-beans.xml)
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/builder-util-beans.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/builder-util-beans.xml	2008-10-23 12:23:03 UTC (rev 79973)
@@ -0,0 +1,11 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="BuilderUtil" class="org.jboss.demos.ioc.builder.BuilderUtil"/>
+
+  <bean name="BuilderExampleHolder" class="org.jboss.demos.ioc.builder.BuilderExampleHolder">
+    <constructor>
+      <parameter><inject bean="BUExample"/></parameter>
+    </constructor>
+  </bean>
+
+</deployment>

Modified: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/demand-supply-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/demand-supply-beans.xml	2008-10-23 11:54:36 UTC (rev 79972)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/demand-supply-beans.xml	2008-10-23 12:23:03 UTC (rev 79973)
@@ -1,5 +1,16 @@
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- TODO -->
+  <bean name="TMDemand" class="org.jboss.demos.ioc.demandsupply.TMDemander">
+    <demand>TM</demand>
+  </bean>
 
+  <bean name="SimpleTMSupply" class="org.jboss.demos.ioc.demandsupply.SimpleTMSupplyer">
+    <supply>TM</supply>
+  </bean>
+
+  <bean name="AdvancedTMSupply" class="org.jboss.demos.ioc.demandsupply.AdvancedTMSupplyer">
+    <start><parameter><null/></parameter></start>
+    <supply>TM</supply>
+  </bean>
+
 </deployment>

Modified: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/install-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/install-beans.xml	2008-10-23 11:54:36 UTC (rev 79972)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/install-beans.xml	2008-10-23 12:23:03 UTC (rev 79973)
@@ -1,5 +1,30 @@
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- TODO -->
+  <bean name="RepositoryManager" class="org.jboss.demos.ioc.install.RepositoryManager">
+    <install method="addEntry">
+      <parameter><inject fromContext="name"/></parameter>
+      <parameter><this/></parameter>
+    </install>
+    <uninstall method="removeEntry">
+      <parameter><inject fromContext="name"/></parameter>
+    </uninstall>
+  </bean>
 
+  <bean name="Entry" class="org.jboss.demos.ioc.install.SimpleEntry">
+    <install bean="RepositoryManager" method="addEntry" state="Instantiated">
+      <parameter><inject fromContext="name"/></parameter>
+      <parameter><this/></parameter>
+    </install>
+    <uninstall bean="RepositoryManager" method="removeEntry" state="Configured">
+      <parameter><inject fromContext="name"/></parameter>
+    </uninstall>
+  </bean>
+
+  <bean name="RC" class="org.jboss.demos.ioc.install.RegistryChecker">
+    <constructor>
+      <parameter><inject/></parameter>
+    </constructor>
+    <property name="size">2</property>
+  </bean>
+
 </deployment>

Modified: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/lifecycle-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/lifecycle-beans.xml	2008-10-23 11:54:36 UTC (rev 79972)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/lifecycle-beans.xml	2008-10-23 12:23:03 UTC (rev 79973)
@@ -1,5 +1,15 @@
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- TODO -->
+  <bean name="FullLifecycleBean-3" class="org.jboss.demos.ioc.lifecycle.FullLifecycleBean"/>
 
+  <bean name="FullLifecycleBean-2" class="org.jboss.demos.ioc.lifecycle.FullLifecycleBean">
+    <create ignore="true"/>
+  </bean>
+
+  <bean name="FullLifecycleBean-1" class="org.jboss.demos.ioc.lifecycle.FullLifecycleBean">
+    <start ignore="true"/>
+  </bean>
+
+  <bean name="LifecycleChecker" class="org.jboss.demos.ioc.lifecycle.LifecycleChecker"/>  
+
 </deployment>

Modified: projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/value-factory-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/value-factory-beans.xml	2008-10-23 11:54:36 UTC (rev 79972)
+++ projects/demos/microcontainer/trunk/ioc/src/main/resources/META-INF/value-factory-beans.xml	2008-10-23 12:23:03 UTC (rev 79973)
@@ -1,5 +1,37 @@
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-  <!-- TODO -->
+  <bean name="Binding" class="org.jboss.demos.ioc.vf.PortBindingManager">
+    <constructor>
+      <parameter>
+        <map keyClass="java.lang.String" valueClass="java.lang.Integer">
+          <entry>
+            <key>http</key>
+            <value>80</value>
+          </entry>
+          <entry>
+            <key>ssh</key>
+            <value>22</value>
+          </entry>
+        </map>
+      </parameter>
+    </constructor>
+  </bean>
 
+  <bean name="PortsConfig" class="org.jboss.demos.ioc.vf.PortsConfig">
+    <property name="http"><value-factory bean="Binding" parameter="http"/></property>
+    <property name="ssh"><value-factory bean="Binding" parameter="ssh"/></property>
+    <property name="ftp">
+      <value-factory bean="Binding">
+        <parameter>ftp</parameter>
+        <parameter>21</parameter>
+      </value-factory>
+    </property>
+    <property name="mail">
+      <value-factory bean="Binding">
+        <parameter>mail</parameter>
+        <parameter>25</parameter>
+      </value-factory>
+    </property>
+  </bean>
+
 </deployment>




More information about the jboss-cvs-commits mailing list