[jboss-cvs] JBossAS SVN: r105968 - in projects/ejb3/trunk: timerservice-naming and 19 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 11 11:19:23 EDT 2010


Author: jaikiran
Date: 2010-06-11 11:19:22 -0400 (Fri, 11 Jun 2010)
New Revision: 105968

Added:
   projects/ejb3/trunk/timerservice-naming/
   projects/ejb3/trunk/timerservice-naming/pom.xml
   projects/ejb3/trunk/timerservice-naming/src/
   projects/ejb3/trunk/timerservice-naming/src/main/
   projects/ejb3/trunk/timerservice-naming/src/main/java/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceBinder.java
   projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceObjectFactory.java
   projects/ejb3/trunk/timerservice-naming/src/main/resources/
   projects/ejb3/trunk/timerservice-naming/src/test/
   projects/ejb3/trunk/timerservice-naming/src/test/java/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyEJBContext.java
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyInvocationContext.java
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyTimerService.java
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/unit/
   projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/unit/TimerServiceBinderTestCase.java
   projects/ejb3/trunk/timerservice-naming/src/test/resources/
   projects/ejb3/trunk/timerservice-naming/src/test/resources/jndi.properties
Log:
Initial commit of timerservice-naming

Added: projects/ejb3/trunk/timerservice-naming/pom.xml
===================================================================
--- projects/ejb3/trunk/timerservice-naming/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/pom.xml	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,109 @@
+<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">
+
+
+	<!-- Maven POM Model Version -->
+	<modelVersion>4.0.0</modelVersion>
+
+	<!-- Artifact Information -->
+	<groupId>org.jboss.ejb3</groupId>
+	<artifactId>jboss-ejb3-timerservice-naming</artifactId>
+	<version>1.0.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>JBoss EJB3 TimerService naming</name>
+	<description>
+		Responsible for setting up TimerService in ENC of EJB3 containers
+	</description>
+	<url>http://labs.jboss.com/jbossejb3/</url>
+
+	<properties>
+		<version.junit>4.7</version.junit>
+		<version.jboss.logging>2.1.1.GA</version.jboss.logging>
+		<version.jboss.common.core>2.2.14.GA</version.jboss.common.core>
+		<version.jboss.ejb3.context>0.1.1</version.jboss.ejb3.context>
+	</properties>
+
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<artifactId>maven-enforcer-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>enforce-jdk6</id>
+						<goals>
+							<goal>enforce</goal>
+						</goals>
+						<configuration>
+							<rules>
+								<requireJavaVersion>
+									<version>[1.6,)</version>
+								</requireJavaVersion>
+							</rules>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+
+		</plugins>
+	</build>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>org.jboss.spec.javax.ejb</groupId>
+			<artifactId>jboss-ejb-api_3.1_spec</artifactId>
+			<version>1.0.0.Beta2</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.jboss.spec.javax.interceptor</groupId>
+			<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+			<version>1.0.0.Beta1</version>
+		</dependency>
+		
+		
+		<dependency>
+			<groupId>org.jboss.logging</groupId>
+			<artifactId>jboss-logging-spi</artifactId>
+			<version>${version.jboss.logging}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.jboss.ejb3.context</groupId>
+			<artifactId>jboss-ejb3-context-base</artifactId>
+			<version>${version.jboss.ejb3.context}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.jboss</groupId>
+			<artifactId>jboss-common-core</artifactId>
+			<version>${version.jboss.common.core}</version>
+		</dependency>
+
+		<!--  Test dependencies -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+			<version>${version.junit}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.jboss.naming</groupId>
+			<artifactId>jnpserver</artifactId>
+			<version>5.0.5.Final</version>
+			<scope>test</scope>
+		</dependency>
+
+	</dependencies>
+
+</project>

Added: projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceBinder.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceBinder.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceBinder.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,168 @@
+/*
+ * 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.naming;
+
+import javax.ejb.TimerService;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+
+import org.jboss.util.naming.Util;
+
+/**
+ * Responsible for binding {@link TimerService} into JNDI at a internal JNDI name.
+ * 
+ * <p>
+ *  The internal JNDI name is meant to be used by EJB3 internal implementation and isn't
+ *  meant to be used by user deployments. User deployments are expected to use the 
+ *  java:comp/TimerService JNDI name, as dictated by EJB3 spec. For further details of 
+ *  accessing TimerService in user deployments, refer the EJB3.0/EJB3.1 spec 
+ * </p>
+ * <p>
+ *  The default JNDI name to which the {@link TimerService} is bound is java:internal/TimerService.
+ *  This can be overriden by using the {@link #TimerServiceBinder(String, Context)}
+ * </p>
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class TimerServiceBinder
+{
+   /**
+    * Naming context
+    */
+   private Context context;
+
+   /**
+    * The default internal JNDI name to which the {@link TimerService} will be bound
+    */
+   private String jndiName = "java:internal/TimerService";
+
+   /**
+    * Constructs {@link TimerServiceBinder} 
+    * <p>
+    *   Instantiates a new {@link InitialContext} to bind the {@link TimerService}  
+    * </p>
+    */
+   public TimerServiceBinder()
+   {
+      try
+      {
+         this.context = new InitialContext();
+      }
+      catch (NamingException ne)
+      {
+         throw new RuntimeException(ne);
+      }
+   }
+
+   /**
+    * Constructs a {@link TimerServiceBinder}
+    * 
+    * @param jndiName The jndi name to which the {@link TimerService} should be bound
+    * @param ctx The naming context to which the {@link TimerService} should be bound
+    * 
+    * @throws IllegalArgumentException If either of <code>jndiName</code> or <code>ctx</code> is null
+    */
+   public TimerServiceBinder(String jndiName, Context ctx)
+   {
+      if (jndiName == null)
+      {
+         throw new IllegalArgumentException("JNDI name for timerservice cannot be null");
+      }
+      if (ctx == null)
+      {
+         throw new IllegalArgumentException("Context for timerservice binding cannot be null");
+      }
+
+      this.jndiName = jndiName;
+      this.context = ctx;
+   }
+
+   /**
+    * Constructs a {@link TimerServiceBinder}
+    * 
+    * @param jndiName The jndi name to which the {@link TimerService} is to be bound
+    */
+   public TimerServiceBinder(String jndiName)
+   {
+      this();
+      if (jndiName == null)
+      {
+         throw new IllegalArgumentException("JNDI name for timerservice cannot be null");
+      }
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * Constructs a {@link TimerServiceBinder}
+    * 
+    * @param ctx The naming context to which the {@link TimerService} has to be bound
+    */
+   public TimerServiceBinder(Context ctx)
+   {
+      if (ctx == null)
+      {
+         throw new IllegalArgumentException("Context for timerservice binding cannot be null");
+      }
+      this.context = ctx;
+   }
+
+   /**
+    * Returns the {@link Context} to which the {@link TimerService} is bound
+    * @return
+    */
+   public Context getContext()
+   {
+      return this.context;
+   }
+
+   /**
+    * Returns the jndi name to which the {@link TimerService} will be bound
+    * by this {@link TimerServiceBinder}
+    * @return
+    */
+   public String getTimerServiceJNDIName()
+   {
+      return this.jndiName;
+   }
+
+   /**
+    * Binds the {@link TimerService} to {@link #jndiName} under {@link #context}
+    * 
+    * @throws NamingException If there is any exception during the bind operation
+    */
+   public void start() throws NamingException
+   {
+      Reference ref = new Reference(TimerService.class.getName(), TimerServiceObjectFactory.class.getName(), null);
+      Util.bind(this.context, jndiName, ref);
+   }
+
+   /**
+    * Unbinds {@link TimerService} from {@link #jndiName} under {@link #context}
+    * @throws NamingException If there is any exception during the bind operation 
+    */
+   public void stop() throws NamingException
+   {
+      Util.unbind(this.context, jndiName);
+   }
+}

Added: projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceObjectFactory.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceObjectFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/main/java/org/jboss/ejb3/timerservice/naming/TimerServiceObjectFactory.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,58 @@
+/*
+ * 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.naming;
+
+import java.util.Hashtable;
+
+import javax.ejb.EJBContext;
+import javax.ejb.TimerService;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import org.jboss.ejb3.context.CurrentInvocationContext;
+
+
+/**
+ * An implementation of {@link ObjectFactory} which is responsible for returing
+ * a {@link TimerService} for the current {@link EJBContext}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class TimerServiceObjectFactory implements ObjectFactory
+{
+
+   /**
+    * Returns {@link TimerService} for the current {@link EJBContext}
+    */
+   @Override
+   public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
+         throws Exception
+   {
+      // get hold of EJBContext
+      EJBContext currentEJBContext = CurrentInvocationContext.get().getEJBContext();
+      // and return the timerservice of that context
+      return currentEJBContext.getTimerService();
+   }
+
+}

Added: projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyEJBContext.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyEJBContext.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyEJBContext.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,149 @@
+/*
+ * 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.naming.test.binder;
+
+import java.security.Identity;
+import java.security.Principal;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+
+import org.jboss.ejb3.context.spi.BeanManager;
+
+/**
+ * DummyEJBContext
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DummyEJBContext implements org.jboss.ejb3.context.spi.EJBContext
+{
+
+   @Override
+   public Identity getCallerIdentity()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Principal getCallerPrincipal()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Map<String, Object> getContextData()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public EJBHome getEJBHome()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public EJBLocalHome getEJBLocalHome()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Properties getEnvironment()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public boolean getRollbackOnly() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public TimerService getTimerService() throws IllegalStateException
+   {
+      return new DummyTimerService();
+   }
+
+   @Override
+   public UserTransaction getUserTransaction() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public boolean isCallerInRole(Identity role)
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public boolean isCallerInRole(String roleName)
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public Object lookup(String name) throws IllegalArgumentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public void setRollbackOnly() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   @Override
+   public BeanManager getManager()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Object getTarget()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+}

Added: projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyInvocationContext.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyInvocationContext.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyInvocationContext.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,216 @@
+/*
+ * 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.naming.test.binder;
+
+import java.lang.reflect.Method;
+import java.security.Identity;
+import java.security.Principal;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+
+import org.jboss.ejb3.context.spi.BeanManager;
+import org.jboss.ejb3.context.spi.EJBContext;
+
+/**
+ * DummyInvocationContext
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DummyInvocationContext implements org.jboss.ejb3.context.spi.InvocationContext
+{
+
+   @Override
+   public Map<String, Object> getContextData()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Method getMethod()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Object[] getParameters()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Object getTarget()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+
+   @Override
+   public Object proceed() throws Exception
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public void setParameters(Object[] params)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   @Override
+   public EJBContext getEJBContext()
+   {
+      return new DummyEJBContext();
+   }
+
+   @Override
+   public void setCallerPrincipal(Principal callerPrincipal)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   @Override
+   public void setEJBContext(EJBContext instance)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   @Override
+   public void setTimer(Timer timer)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   @Override
+   public BeanManager getManager()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Identity getCallerIdentity()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Principal getCallerPrincipal()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public EJBHome getEJBHome()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public EJBLocalHome getEJBLocalHome()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Properties getEnvironment()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public boolean getRollbackOnly() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public TimerService getTimerService() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public UserTransaction getUserTransaction() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public boolean isCallerInRole(Identity role)
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public boolean isCallerInRole(String roleName)
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public Object lookup(String name) throws IllegalArgumentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public void setRollbackOnly() throws IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   @Override
+   public Timer getTimer()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+}

Added: projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyTimerService.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyTimerService.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/DummyTimerService.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,131 @@
+/*
+ * 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.naming.test.binder;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.ejb.EJBException;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.Timer;
+import javax.ejb.TimerConfig;
+import javax.ejb.TimerService;
+
+/**
+ * DummyTimerService
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DummyTimerService implements TimerService
+{
+
+   @Override
+   public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException,
+         IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig)
+         throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig)
+         throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig)
+         throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException,
+         IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException,
+         IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException,
+         IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException,
+         IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createTimer(long initialDuration, long intervalDuration, Serializable info)
+         throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info)
+         throws IllegalArgumentException, IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Collection<Timer> getTimers() throws IllegalStateException, EJBException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+}
+

Added: projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/unit/TimerServiceBinderTestCase.java
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/unit/TimerServiceBinderTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/test/java/org/jboss/ejb3/timerservice/naming/test/binder/unit/TimerServiceBinderTestCase.java	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,101 @@
+/*
+ * 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.naming.test.binder.unit;
+
+import javax.ejb.TimerService;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.context.CurrentInvocationContext;
+import org.jboss.ejb3.timerservice.naming.TimerServiceBinder;
+import org.jboss.ejb3.timerservice.naming.test.binder.DummyInvocationContext;
+import org.jnp.server.SingletonNamingServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests {@link TimerServiceBinder}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class TimerServiceBinderTestCase
+{
+
+   private static SingletonNamingServer namingServer;
+
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      // start the naming server
+      namingServer = new SingletonNamingServer();
+   }
+
+   @AfterClass
+   public static void afterClass()
+   {
+      if (namingServer != null)
+      {
+         // stop the server
+         namingServer.destroy();
+      }
+   }
+
+   /**
+    * Test that the {@link TimerServiceBinder} binds to the default internal jndi name
+    * 
+    * @throws Exception
+    */
+   @Test
+   public void testTimerServiceBinding() throws Exception
+   {
+      Context ctx = new InitialContext();
+      TimerServiceBinder timerServiceBinder = new TimerServiceBinder(ctx);
+
+      // bind 
+      timerServiceBinder.start();
+      // push an invocation context
+      CurrentInvocationContext.push(new DummyInvocationContext());
+      try
+      {
+         // get the jndi name to which the timer service is bound
+         String timerServiceJNDIName = timerServiceBinder.getTimerServiceJNDIName();
+         Assert.assertNotNull("Timerservice jndiname was null", timerServiceJNDIName);
+   
+         // lookup the timerservice
+         Object timerService = ctx.lookup(timerServiceJNDIName);
+   
+         Assert.assertNotNull("Object retrieved from JNDI was null", timerService);
+         Assert.assertTrue("Unexpected object type retrieved from JNDI: " + timerService.getClass().getName(),
+               (timerService instanceof TimerService));
+      }
+      finally
+      {
+         CurrentInvocationContext.pop();
+      }
+
+   }
+
+}

Added: projects/ejb3/trunk/timerservice-naming/src/test/resources/jndi.properties
===================================================================
--- projects/ejb3/trunk/timerservice-naming/src/test/resources/jndi.properties	                        (rev 0)
+++ projects/ejb3/trunk/timerservice-naming/src/test/resources/jndi.properties	2010-06-11 15:19:22 UTC (rev 105968)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces



More information about the jboss-cvs-commits mailing list