[jboss-cvs] JBossAS SVN: r83557 - in projects/ejb3/trunk: timerservice-as5 and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 28 10:20:03 EST 2009


Author: wolfc
Date: 2009-01-28 10:20:03 -0500 (Wed, 28 Jan 2009)
New Revision: 83557

Added:
   projects/ejb3/trunk/timerservice-as5/
   projects/ejb3/trunk/timerservice-as5/.classpath
   projects/ejb3/trunk/timerservice-as5/.project
   projects/ejb3/trunk/timerservice-as5/.settings/
   projects/ejb3/trunk/timerservice-as5/.settings/org.eclipse.jdt.core.prefs
   projects/ejb3/trunk/timerservice-as5/.settings/org.maven.ide.eclipse.prefs
   projects/ejb3/trunk/timerservice-as5/pom.xml
   projects/ejb3/trunk/timerservice-as5/src/
   projects/ejb3/trunk/timerservice-as5/src/main/
   projects/ejb3/trunk/timerservice-as5/src/main/java/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/JBossTimerServiceFactory.java
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimedObjectInvokerBridge.java
   projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimerServiceFacade.java
   projects/ejb3/trunk/timerservice-as5/src/main/resources/
   projects/ejb3/trunk/timerservice-as5/src/main/resources/META-INF/
   projects/ejb3/trunk/timerservice-as5/src/main/resources/META-INF/jboss-beans.xml
Log:
EJBTHREE-1697: timerservice-as5 for backwards compatibility with AS 5.0.1


Property changes on: projects/ejb3/trunk/timerservice-as5
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Added: projects/ejb3/trunk/timerservice-as5/.classpath
===================================================================
--- projects/ejb3/trunk/timerservice-as5/.classpath	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/.classpath	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,7 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="eclipse-target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+</classpath>
\ No newline at end of file

Added: projects/ejb3/trunk/timerservice-as5/.project
===================================================================
--- projects/ejb3/trunk/timerservice-as5/.project	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/.project	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,18 @@
+<projectDescription>
+  <name>jboss-ejb3-timerservice-as5</name>
+  <comment>An implementation of an EJB TimerService that falls back to the TimerService
+    implementation in JBoss Application Server.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/ejb3/trunk/timerservice-as5/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/timerservice-as5/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/.settings/org.eclipse.jdt.core.prefs	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,5 @@
+#Wed Jan 28 12:02:41 CET 2009
+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/timerservice-as5/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/ejb3/trunk/timerservice-as5/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/.settings/org.maven.ide.eclipse.prefs	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,8 @@
+#Wed Jan 28 12:07:38 CET 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1

Added: projects/ejb3/trunk/timerservice-as5/pom.xml
===================================================================
--- projects/ejb3/trunk/timerservice-as5/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/pom.xml	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  vi:ts=2:sw=2:expandtab:
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-build</artifactId>
+    <version>1.0.0</version>
+    <relativePath>../build/pom.xml</relativePath>
+  </parent>
+
+  <!-- Maven POM Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Information -->
+  <artifactId>jboss-ejb3-timerservice-as5</artifactId>
+  <packaging>jar</packaging>
+  <version>0.1.0-SNAPSHOT</version>
+  <name>JBoss EJB 3.x TimerService AS 5</name>
+  <description>
+    An implementation of an EJB TimerService that falls back to the TimerService
+    implementation in JBoss Application Server.
+  </description>
+  <url>http://labs.jboss.com/jbossejb3/</url>
+
+  <properties>
+    <version.org.jboss.jboss-as>5.0.0.GA</version.org.jboss.jboss-as>
+  </properties>
+  
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-timerservice-spi</artifactId>
+      <version>[0,)</version>
+    </dependency>
+    
+    <!-- this needs to be removed - EJBTHREE-1343 -->
+    <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-server</artifactId>
+      <version>${version.org.jboss.jboss-as}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-remoting</artifactId>
+        </exclusion>        
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-metadata</artifactId>
+        </exclusion>        
+        <exclusion>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-as-security</artifactId>
+        </exclusion>        
+        <!-- Conflicts with org.jboss.security:jbosssx -->
+        <exclusion>
+          <groupId>org.jboss.security</groupId>
+          <artifactId>jbosssx-client</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.ws.native</groupId>
+          <artifactId>jbossws-native-jaxws</artifactId>
+        </exclusion>
+      </exclusions>      
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Copied: projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/JBossTimerServiceFactory.java (from rev 83543, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/timerservice/jboss/JBossTimerServiceFactory.java)
===================================================================
--- projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/JBossTimerServiceFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/JBossTimerServiceFactory.java	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.timerservice.as5;
+
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
+import org.jboss.ejb3.timerservice.spi.TimerServiceFactory;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * Factory to create timer services which use the JBoss EJB Timer Service.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossTimerServiceFactory implements TimerServiceFactory
+{
+   private static Logger log = Logger.getLogger(JBossTimerServiceFactory.class);
+   
+   public TimerService createTimerService(TimedObjectInvoker invoker)
+   {
+      TimerService timerService = null;
+      try
+      {
+         EJBTimerService service = getEJBTimerService();
+         ObjectName objectName = new ObjectName(invoker.getTimedObjectId());
+         org.jboss.ejb.txtimer.TimedObjectInvoker bridge = new TimedObjectInvokerBridge(invoker);
+         TimerService delegate = service.createTimerService(objectName, null, bridge);
+         timerService = new TimerServiceFacade(objectName, delegate);
+      }
+      catch (Exception e)
+      {
+         //throw new EJBException("Could not create timer service", e);
+         if (log.isTraceEnabled())
+         {
+            log.trace("Unable to initialize timer service", e);
+         }
+         else
+         {
+            log.trace("Unable to initialize timer service");
+         }
+      }
+      return timerService;
+   }
+
+   protected EJBTimerService getEJBTimerService()
+   {
+      return (EJBTimerService) MBeanProxyExt.create(EJBTimerService.class, EJBTimerService.OBJECT_NAME, MBeanServerLocator.locateJBoss());
+   }
+   
+   public void removeTimerService(TimerService timerService)
+   {
+      removeTimerService(((TimerServiceFacade) timerService).getContainerId());
+   }
+
+   protected void removeTimerService(ObjectName containerId)
+   {
+      try
+      {
+         EJBTimerService service = getEJBTimerService();
+         service.removeTimerService(containerId, true);
+      }
+      catch (Exception e)
+      {
+         //throw new EJBException("Could not remove timer service", e);
+         if (log.isTraceEnabled())
+         {
+            log.trace("Unable to initialize timer service", e);
+         }
+         else
+         {
+            log.trace("Unable to initialize timer service");
+         }
+      }
+   }
+   
+   public void restoreTimerService(TimerService aTimerService)
+   {
+      if (aTimerService == null)
+      {
+         log.warn("TIMER SERVICE IS NOT INSTALLED");
+         return;
+      }
+      TimerServiceFacade timerService = (TimerServiceFacade) aTimerService;
+      ClassLoader loader = null;
+      
+      // FIXME: A hack to circumvent the check in TimerServiceFacade
+      // In AS itself (/EJB2) the container has an unsecured timer service association
+      // see org.jboss.ejb.Container.getTimerService(Object pKey)
+      AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_BUSINESS_METHOD);
+      try
+      {
+         getEJBTimerService().restoreTimers(timerService.getContainerId(), loader);
+      }
+      finally
+      {
+         AllowedOperationsAssociation.popInMethodFlag();
+      }
+   }
+   
+   public void suspendTimerService(TimerService timerService)
+   {
+      removeTimerService(timerService);
+   }
+}

Added: projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimedObjectInvokerBridge.java
===================================================================
--- projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimedObjectInvokerBridge.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimedObjectInvokerBridge.java	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb3.timerservice.as5;
+
+import javax.ejb.Timer;
+
+import org.jboss.ejb.txtimer.TimedObjectInvoker;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TimedObjectInvokerBridge implements TimedObjectInvoker
+{
+   private org.jboss.ejb3.timerservice.spi.TimedObjectInvoker delegate;
+
+   protected TimedObjectInvokerBridge(org.jboss.ejb3.timerservice.spi.TimedObjectInvoker delegate)
+   {
+      assert delegate != null : "delegate is null";
+      this.delegate = delegate;
+   }
+   
+   public void callTimeout(Timer timer) throws Exception
+   {
+      delegate.callTimeout(timer);
+   }
+}

Copied: projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimerServiceFacade.java (from rev 83543, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/timerservice/jboss/TimerServiceFacade.java)
===================================================================
--- projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimerServiceFacade.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/src/main/java/org/jboss/ejb3/timerservice/as5/TimerServiceFacade.java	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.timerservice.as5;
+
+import static org.jboss.ejb.AllowedOperationsFlags.IN_BUSINESS_METHOD;
+import static org.jboss.ejb.AllowedOperationsFlags.IN_EJB_TIMEOUT;
+import static org.jboss.ejb.AllowedOperationsFlags.IN_SERVICE_ENDPOINT_METHOD;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+
+import org.jboss.ejb.AllowedOperationsAssociation;
+
+/**
+ * Holds the association with the container, without exposing it.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TimerServiceFacade implements TimerService
+{
+   private ObjectName objectName;
+   private TimerService delegate;
+   
+   protected TimerServiceFacade(ObjectName objectName, TimerService delegate)
+   {
+      this.objectName = objectName;
+      this.delegate = delegate;
+   }
+
+   private void assertAllowedIn(String timerMethod)
+   {
+      // TODO: This isn't handled by the AS timer service itself
+      AllowedOperationsAssociation.assertAllowedIn(timerMethod, IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD);
+   }
+   
+   public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(initialExpiration, intervalDuration, info);
+   }
+
+   public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(expiration, info);
+   }
+
+   public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(initialDuration, intervalDuration, info);
+   }
+
+   public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.createTimer");
+      return delegate.createTimer(duration, info);
+   }
+
+//   protected EJBContainer getContainer()
+//   {
+//      return (EJBContainer) container;
+//   }
+   
+   protected ObjectName getContainerId()
+   {
+      return objectName;
+   }
+   
+   public Collection<?> getTimers() throws IllegalStateException, EJBException
+   {
+      assertAllowedIn("TimerService.getTimers");
+      return delegate.getTimers();
+   }
+}

Added: projects/ejb3/trunk/timerservice-as5/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/timerservice-as5/src/main/resources/META-INF/jboss-beans.xml	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-as5/src/main/resources/META-INF/jboss-beans.xml	2009-01-28 15:20:03 UTC (rev 83557)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="JBossTimerServiceFactory" class="org.jboss.ejb3.timerservice.as5.JBossTimerServiceFactory">
+      <depends>jboss.ejb:service=EJBTimerService</depends>
+   </bean>
+</deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list