[jboss-svn-commits] JBoss Common SVN: r3824 - in invokablecontainer/trunk: core/src/main/java/org/jboss/ejb3/container/core and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 3 22:37:30 EST 2009
Author: ALRubinger
Date: 2009-12-03 22:37:30 -0500 (Thu, 03 Dec 2009)
New Revision: 3824
Removed:
invokablecontainer/trunk/spi/src/main/java/org/jboss/ejb3/container/spi/InvocationContextProvider.java
Modified:
invokablecontainer/trunk/api/src/main/java/org/jboss/ejb3/container/api/InvocationContext.java
invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/InvocationImpl.java
invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/MapBasedInvocationContext.java
invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/DelegatingContainerTestCase.java
invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/InvocationImplTestCase.java
invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/MapBasedInvocationContextTestCase.java
invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/OriginalVersionInvocationImpl.java
Log:
[EJBTHREE-1948] Remove InvocationContextProvider as an SPI construct; add "getKeys" support
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/ejb3/container/api/InvocationContext.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/ejb3/container/api/InvocationContext.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/ejb3/container/api/InvocationContext.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -75,4 +75,17 @@
* @throws IllegalArgumentException If the key or value is not specified
*/
Object setProperty(Object key, Object value) throws IllegalArgumentException;
+
+ /**
+ * Returns an {@link Iterable} view of all keys in this context
+ * @return
+ */
+ Iterable<?> getKeys();
+
+ /**
+ * Determines whether the context properties are empty (ie. none exist)
+ *
+ * @return
+ */
+ boolean isEmpty();
}
Modified: invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/InvocationImpl.java
===================================================================
--- invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/InvocationImpl.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/InvocationImpl.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -34,7 +34,6 @@
import org.jboss.ejb3.container.api.Invocation;
import org.jboss.ejb3.container.api.InvocationContext;
-import org.jboss.ejb3.container.spi.InvocationContextProvider;
/**
* InvocationImpl
@@ -94,7 +93,7 @@
* won't be written during serialization if empty; instead we put a null placeholder
* which will be replaced with a new instance during deserialization
*/
- private transient InvocationContextProvider context;
+ private transient InvocationContext context;
//-------------------------------------------------------------------------------------||
// Constructors -----------------------------------------------------------------------||
@@ -122,7 +121,7 @@
* @param args
* @throws IllegalArgumentException If any of the required arguments are not present
*/
- InvocationImpl(final Method targetMethod, final Object[] args, final InvocationContextProvider context)
+ public InvocationImpl(final Method targetMethod, final Object[] args, final InvocationContext context)
{
// Precondition checks
if (targetMethod == null)
@@ -254,7 +253,7 @@
out.writeObject(paramTypes);
// See if the invocation context is empty
- InvocationContextProvider contextToWrite = this.context;
+ InvocationContext contextToWrite = this.context;
if (context.isEmpty())
{
// Null out; we don't need to send empty properties. On deserialization
@@ -323,7 +322,7 @@
this.setTargetMethod(targetMethod);
// Set the InvocationContext
- InvocationContextProvider context = (InvocationContextProvider) in.readObject();
+ InvocationContext context = (InvocationContext) in.readObject();
// If no context is provided
if (context == null)
{
Modified: invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/MapBasedInvocationContext.java
===================================================================
--- invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/MapBasedInvocationContext.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/main/java/org/jboss/ejb3/container/core/MapBasedInvocationContext.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -20,7 +20,6 @@
import java.util.Map;
import org.jboss.ejb3.container.api.InvocationContext;
-import org.jboss.ejb3.container.spi.InvocationContextProvider;
/**
* MapBasedInvocationContext
@@ -33,7 +32,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-final class MapBasedInvocationContext implements InvocationContextProvider
+final class MapBasedInvocationContext implements InvocationContext
{
//-------------------------------------------------------------------------------------||
@@ -77,6 +76,7 @@
//-------------------------------------------------------------------------------------||
/**
+ * {@inheritDoc}
* @see org.jboss.ejb3.container.api.InvocationContext#getProperty(java.lang.Object)
*/
@Override
@@ -86,6 +86,7 @@
}
/**
+ * {@inheritDoc}
* @see org.jboss.ejb3.container.api.InvocationContext#getProperty(java.lang.Object, java.lang.Class)
*/
@Override
@@ -97,6 +98,7 @@
}
/**
+ * {@inheritDoc}
* @see org.jboss.ejb3.container.api.InvocationContext#setProperty(java.lang.Object, java.lang.Object)
*/
@Override
@@ -106,6 +108,7 @@
}
/**
+ * {@inheritDoc}
* @see org.jboss.ejb3.container.spi.InvocationContextProvider#isEmpty()
*/
@Override
@@ -114,6 +117,16 @@
return this.getMap().isEmpty();
}
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.container.api.InvocationContext#getKeys()
+ */
+ @Override
+ public Iterable<?> getKeys()
+ {
+ return this.getMap().keySet();
+ }
+
//-------------------------------------------------------------------------------------||
// Internal Helper Methods ------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
Modified: invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/DelegatingContainerTestCase.java
===================================================================
--- invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/DelegatingContainerTestCase.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/DelegatingContainerTestCase.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -21,7 +21,6 @@
*/
package org.jboss.ejb3.container.core;
-import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -96,15 +95,6 @@
this.assertInvocationAddingOneTwoThreeSucceeds(calcContainer, 6);
}
- @Test
- public void testSomething()
- {
- log.info("\n\n\n\n\nALR\n\n\n\n\n");
- final Method method = Addable.class.getMethods()[0];
- log.info(method.toString());
- log.info(method.getDeclaringClass().toString());
- }
-
/**
* Tests that an invocation resulting in some exception will
* be wrapped
Modified: invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/InvocationImplTestCase.java
===================================================================
--- invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/InvocationImplTestCase.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/InvocationImplTestCase.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -41,13 +41,10 @@
import org.jboss.ejb3.container.api.Invocation;
import org.jboss.ejb3.container.api.InvocationContext;
-import org.jboss.ejb3.container.spi.InvocationContextProvider;
import org.junit.BeforeClass;
import org.junit.Test;
/**
- * InvocationImplTest
- *
* Tests ensuring the contract of {@link Invocation} holds
* when using the {@link InvocationImpl}.
*
@@ -240,7 +237,7 @@
final Invocation roundtrip = serializeAndDeserialize(invocation);
// Test
- final InvocationContextProvider context = (InvocationContextProvider) roundtrip.getContext();
+ final InvocationContext context = roundtrip.getContext();
TestCase.assertNotNull("Empty invocation context after serialization should not be null", context);
TestCase.assertTrue("Empty invocation context after serialization should still be empty", context.isEmpty());
}
Modified: invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/MapBasedInvocationContextTestCase.java
===================================================================
--- invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/MapBasedInvocationContextTestCase.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/MapBasedInvocationContextTestCase.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -16,6 +16,8 @@
*/
package org.jboss.ejb3.container.core;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.logging.Logger;
@@ -26,8 +28,6 @@
import org.junit.Test;
/**
- * MapBasedInvocationContextTestCase
- *
* Ensures that the contract of {@link InvocationContext}
* holds with the {@link MapBasedInvocationContext} implementation
*
@@ -95,4 +95,59 @@
TestCase.assertEquals("Did not obtain expected value from context under key " + key, value, roundrip);
}
+ /**
+ * Tests that the {@link InvocationContext#isEmpty()}
+ * contract is upheld
+ */
+ @Test
+ public void testIsEmpty()
+ {
+ // Create and ensure empty
+ final InvocationContext context = new MapBasedInvocationContext();
+ TestCase.assertTrue("New invocation context should be empty", context.isEmpty());
+
+ // Put in a property
+ final Object obj = new Object();
+ context.setProperty(obj, obj);
+
+ // Ensure not empty
+ TestCase.assertTrue("Invocation context with property should not be empty", !context.isEmpty());
+ }
+
+ /**
+ * Tests that the {@link InvocationContext#getKeys()}
+ * contract is upheld
+ */
+ @Test
+ public void testGetKeys()
+ {
+ // Create
+ final InvocationContext context = new MapBasedInvocationContext();
+
+ // Put in some properties
+ final Object key1 = new Object();
+ final Object key2 = new Object();
+ final Object value1 = new Object();
+ final Object value2 = new Object();
+ context.setProperty(key1, value1);
+ context.setProperty(key2, value2);
+
+ // Obtain all keys and values present
+ final Collection<Object> keys = new ArrayList<Object>();
+ final Collection<Object> values = new ArrayList<Object>();
+ for (Object key : context.getKeys())
+ {
+ keys.add(key);
+ values.add(context.getProperty(key));
+ }
+
+ // Test
+ TestCase.assertEquals(2, keys.size());
+ TestCase.assertEquals(2, values.size());
+ TestCase.assertTrue(keys.contains(key1));
+ TestCase.assertTrue(keys.contains(key2));
+ TestCase.assertTrue(values.contains(value1));
+ TestCase.assertTrue(values.contains(value2));
+ }
+
}
Modified: invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/OriginalVersionInvocationImpl.java
===================================================================
--- invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/OriginalVersionInvocationImpl.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/core/src/test/java/org/jboss/ejb3/container/core/OriginalVersionInvocationImpl.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -34,7 +34,6 @@
import org.jboss.ejb3.container.api.Invocation;
import org.jboss.ejb3.container.api.InvocationContext;
-import org.jboss.ejb3.container.spi.InvocationContextProvider;
/**
* OriginalVersionInvocationImpl
@@ -84,7 +83,7 @@
* won't be written during serialization if empty; instead we put a null placeholder
* which will be replaced with a new instance during deserialization
*/
- private transient InvocationContextProvider context;
+ private transient InvocationContext context;
//-------------------------------------------------------------------------------------||
// Constructors -----------------------------------------------------------------------||
@@ -112,7 +111,7 @@
* @param args
* @throws IllegalArgumentException If any of the required arguments are not present
*/
- OriginalVersionInvocationImpl(final Method targetMethod, final Object[] args, final InvocationContextProvider context)
+ OriginalVersionInvocationImpl(final Method targetMethod, final Object[] args, final InvocationContext context)
{
// Precondition checks
if (targetMethod == null)
@@ -244,7 +243,7 @@
out.writeObject(paramTypes);
// See if the invocation context is empty
- InvocationContextProvider contextToWrite = this.context;
+ InvocationContext contextToWrite = this.context;
if (context.isEmpty())
{
// Null out; we don't need to send empty properties. On deserialization
@@ -313,7 +312,7 @@
this.setTargetMethod(targetMethod);
// Set the InvocationContext
- InvocationContextProvider context = (InvocationContextProvider) in.readObject();
+ InvocationContext context = (InvocationContext) in.readObject();
// If no context is provided
if (context == null)
{
Deleted: invokablecontainer/trunk/spi/src/main/java/org/jboss/ejb3/container/spi/InvocationContextProvider.java
===================================================================
--- invokablecontainer/trunk/spi/src/main/java/org/jboss/ejb3/container/spi/InvocationContextProvider.java 2009-12-03 18:02:36 UTC (rev 3823)
+++ invokablecontainer/trunk/spi/src/main/java/org/jboss/ejb3/container/spi/InvocationContextProvider.java 2009-12-04 03:37:30 UTC (rev 3824)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.ejb3.container.spi;
-
-import org.jboss.ejb3.container.api.InvocationContext;
-
-/**
- * InvocationContextProvider
- *
- * Contract for implementations of an
- * {@link InvocationContext}
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface InvocationContextProvider extends InvocationContext
-{
-
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Determines whether the context properties are empty (ie. none exist)
- */
- boolean isEmpty();
-}
More information about the jboss-svn-commits
mailing list