[jboss-cvs] JBossAS SVN: r59011 - in projects/ejb3/trunk/injection: . .settings src/test src/test/java/org/jboss/injection/test src/test/java/org/jboss/injection/test/simple src/test/java/org/jboss/injection/test/simple/unit src/test/resources src/test/resources/simple

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 13 06:15:34 EST 2006


Author: wolfc
Date: 2006-12-13 06:15:26 -0500 (Wed, 13 Dec 2006)
New Revision: 59011

Added:
   projects/ejb3/trunk/injection/.settings/
   projects/ejb3/trunk/injection/.settings/org.eclipse.jdt.core.prefs
   projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/
   projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/Counter.java
   projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/InjectedBean.java
   projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/unit/
   projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/unit/SimpleTestCase.java
   projects/ejb3/trunk/injection/src/test/resources/
   projects/ejb3/trunk/injection/src/test/resources/simple/
   projects/ejb3/trunk/injection/src/test/resources/simple/jboss-aop.xml
Log:
First prototype

Added: projects/ejb3/trunk/injection/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/injection/.settings/org.eclipse.jdt.core.prefs	2006-12-13 11:12:42 UTC (rev 59010)
+++ projects/ejb3/trunk/injection/.settings/org.eclipse.jdt.core.prefs	2006-12-13 11:15:26 UTC (rev 59011)
@@ -0,0 +1,5 @@
+#Mon Dec 11 11:33:01 CET 2006
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/Counter.java
===================================================================
--- projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/Counter.java	2006-12-13 11:12:42 UTC (rev 59010)
+++ projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/Counter.java	2006-12-13 11:15:26 UTC (rev 59011)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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.injection.test.simple;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Counter
+{
+   public static int postConstructs;
+   public static int preDestroys;
+   
+   public static void reset()
+   {
+      postConstructs = 0;
+      preDestroys = 0;
+   }
+}

Added: projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/InjectedBean.java
===================================================================
--- projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/InjectedBean.java	2006-12-13 11:12:42 UTC (rev 59010)
+++ projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/InjectedBean.java	2006-12-13 11:15:26 UTC (rev 59011)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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.injection.test.simple;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InjectedBean
+{
+   private String value;
+   
+   public InjectedBean()
+   {
+      if(value != null)
+         throw new IllegalStateException("value must be null");
+   }
+   
+   public void check()
+   {
+      if(value == null)
+         throw new IllegalStateException("value must not be null");
+   }
+   
+   public void postConstruct()
+   {
+      if(value == null)
+         throw new IllegalStateException("value must not be null");
+      Counter.postConstructs++;
+   }
+   
+   public void preDestroy()
+   {
+      Counter.preDestroys++;
+   }
+}

Added: projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/unit/SimpleTestCase.java
===================================================================
--- projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/unit/SimpleTestCase.java	2006-12-13 11:12:42 UTC (rev 59010)
+++ projects/ejb3/trunk/injection/src/test/java/org/jboss/injection/test/simple/unit/SimpleTestCase.java	2006-12-13 11:15:26 UTC (rev 59011)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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.injection.test.simple.unit;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.injection.test.simple.Counter;
+import org.jboss.injection.test.simple.InjectedBean;
+
+/**
+ * Run with: -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleTestCase extends TestCase
+{
+   public void test1() throws Exception
+   {
+      Counter.reset();
+      
+//      Class cls = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.injection.test.simple.InjectedBean");
+      
+//      Object bean1 = cls.newInstance();
+      
+      InjectedBean bean = new InjectedBean();
+      
+      bean.check();
+      
+      assertEquals(1, Counter.postConstructs);
+      
+      bean = null;
+      
+      Runtime.getRuntime().gc();
+      Runtime.getRuntime().runFinalization();
+      
+      assertEquals(1, Counter.preDestroys);
+   }
+   
+   public static Test suite() throws Exception
+   {
+//      AspectManager.verbose = true;
+      
+//      AspectManager.debugClasses = true;
+//      AspectManager.classicOrder = true;
+      
+//      System.err.println(Thread.currentThread().getContextClassLoader());
+//      URLClassLoader ucl = (URLClassLoader) Thread.currentThread().getContextClassLoader();
+//      for(URL url : ucl.getURLs())
+//         System.err.println(" - " + url);
+//      
+//      List<URL> urls = new ArrayList<URL>();
+//      for(int i = 0; i < ucl.getURLs().length; i++)
+//      {
+//         System.err.println(ucl.getURLs()[i]);
+//         urls.add(ucl.getURLs()[i]);
+//      }
+      
+      //ClassLoader parent = URLClassLoader.newInstance(urls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader().getParent());
+//      ClassLoader parent = URLClassLoader.newInstance(urls.toArray(new URL[0]), null);
+//      SystemClassLoader cl = new SystemClassLoader(parent);
+//      //AspectManager.instance().registerClassLoader(cl);
+//      Thread.currentThread().setContextClassLoader(cl);
+      
+      URL url = Thread.currentThread().getContextClassLoader().getResource("simple/jboss-aop.xml");
+      System.out.println(url);
+      AspectXmlLoader.deployXML(url);
+      
+//      AspectManager.instance().registerClassLoader(cl);
+//      System.err.println(AspectManager.getRegisteredCLs());
+      
+      return new TestSuite(SimpleTestCase.class);
+   }
+}

Added: projects/ejb3/trunk/injection/src/test/resources/simple/jboss-aop.xml
===================================================================
--- projects/ejb3/trunk/injection/src/test/resources/simple/jboss-aop.xml	2006-12-13 11:12:42 UTC (rev 59010)
+++ projects/ejb3/trunk/injection/src/test/resources/simple/jboss-aop.xml	2006-12-13 11:15:26 UTC (rev 59011)
@@ -0,0 +1,7 @@
+<aop>
+	<interceptor name="ConstructorInterceptor" class="org.jboss.injection.aop.ConstructorInterceptor" scope="PER_VM"/>
+	
+	<bind pointcut="construction(org.jboss.injection.test.*->new(..))">
+		<interceptor-ref name="ConstructorInterceptor"/>
+	</bind>
+</aop>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list