Author: nickarls
Date: 2008-12-26 16:12:54 -0500 (Fri, 26 Dec 2008)
New Revision: 735
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/SimpleBeanProxyMethodHandler.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapContext.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/LocalGoodDoggie.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/Naming.java
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoadingException.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/PropertiesBasedBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/BasicContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/resources/DefaultNaming.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletContextResourceLoader.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ConcurrentCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/DeploymentProperties.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanLifecycleTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/GoodDoggie.java
Log:
* WBRI-84, splitting into AbstractContext and AbstractBeanMapContext.
* JavaDocs/header blocks/comments
* AbstractBeanMapAdaptor -> AbstractBeanMap
* Stub for enterprise client proxy, under construction but doesn't break any tests
;-)
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-26
18:28:04 UTC (rev 734)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -73,6 +73,8 @@
@Standard
public class ManagerImpl implements Manager, Serializable
{
+ private static final long serialVersionUID = 1L;
+
// The JNDI key to place the manager under
public static final String JNDI_KEY = "java:comp/Manager";
@@ -88,12 +90,13 @@
private ProxyPool proxyPool;
// The registered beans
private List<Bean<?>> beans;
+ // The registered beans, mapped by implementation class
private Map<Class<?>, Bean<?>> beanMap;
// The registered decorators
private Set<Decorator> decorators;
// The registered interceptors
private Set<Interceptor> interceptors;
-
+
private EjbDescriptorCache ejbDescriptorCache;
// The Naming (JNDI) access
@@ -103,7 +106,7 @@
* Constructor
*
* @param enabledDeploymentTypes any enabled deployment types, an empty set
- * if none are specified
+ * if none are specified
*/
public ManagerImpl()
{
@@ -116,7 +119,7 @@
this.contextMap = new ContextMap();
this.eventManager = new EventManager();
this.ejbDescriptorCache = new EjbDescriptorCache();
-
+
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new
ArrayList<Class<? extends Annotation>>();
defaultEnabledDeploymentTypes.add(0, Standard.class);
defaultEnabledDeploymentTypes.add(1, Production.class);
@@ -158,7 +161,8 @@
}
/**
- * Resolve the disposal method for the given producer method. For internal use.
+ * Resolve the disposal method for the given producer method. For internal
+ * use.
*
* @param apiType The API type to match
* @param bindingTypes The binding types to match
@@ -193,9 +197,10 @@
{
return Collections.unmodifiableList(enabledDeploymentTypes);
}
-
+
/**
* Set the enabled deployment types
+ *
* @param enabledDeploymentTypes
*/
public void setEnabledDeploymentTypes(List<Class<? extends Annotation>>
enabledDeploymentTypes)
@@ -272,7 +277,8 @@
/**
* Wraps a collection of beans into a thread safe list. Since this overwrites
* any existing list of beans in the manager, this should only be done on
- * startup and other controlled situations. For internal use.
+ * startup and other controlled situations. Also maps the beans by
+ * implementation class. For internal use.
*
* @param beans The set of beans to add
* @return A reference to the manager
@@ -289,7 +295,12 @@
resolver.clear();
}
}
-
+
+ /**
+ * Gets the class-mapped beans. For internal use.
+ *
+ * @return The bean map
+ */
public Map<Class<?>, Bean<?>> getBeanMap()
{
return beanMap;
@@ -658,7 +669,7 @@
{
return resolver;
}
-
+
public EjbDescriptorCache getEjbDescriptorCache()
{
return ejbDescriptorCache;
@@ -670,7 +681,8 @@
* @return A string representation
*/
@Override
- public String toString() {
+ public String toString()
+ {
StringBuilder buffer = new StringBuilder();
buffer.append("Manager\n");
buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes()
+ "\n");
@@ -680,7 +692,7 @@
buffer.append("Registered interceptors: " + interceptors.size() +
"\n");
return buffer.toString();
}
-
+
public String toDetailedString()
{
StringBuilder buffer = new StringBuilder();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-26
18:28:04 UTC (rev 734)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -47,6 +47,7 @@
*/
public class Resolver implements Serializable
{
+ private static final long serialVersionUID = 1L;
/**
* Extension of an element which bases equality not only on type, but also on
@@ -54,6 +55,7 @@
*/
private abstract class ResolvableAnnotatedItem<T, S> extends
ForwardingAnnotatedItem<T, S> implements Serializable
{
+ private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object other)
@@ -170,6 +172,7 @@
{
registerInjectionPoint(new ResolvableAnnotatedItem<Object, Object>()
{
+ private static final long serialVersionUID = 1L;
@Override
public AnnotatedItem<Object, Object> delegate()
@@ -193,6 +196,7 @@
final ResolvableAnnotatedItem<T, S> element = new
ResolvableAnnotatedItem<T, S>()
{
+ private static final long serialVersionUID = 1L;
@Override
public AnnotatedItem<T, S> delegate()
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -252,7 +252,6 @@
* @return The instance
*/
@Override
- @SuppressWarnings("unchecked")
public T create()
{
try
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.bean.proxy;
+
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Method handler for enterprise bean client proxies
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class EnterpriseBeanProxyMethodHandler implements MethodHandler
+{
+ // The log provider
+ private LogProvider log =
Logging.getLogProvider(EnterpriseBeanProxyMethodHandler.class);
+ // The container provided proxy that implements all interfaces
+ private Object proxy;
+
+ /**
+ * Constructor
+ *
+ * @param proxy The generic proxy
+ */
+ public EnterpriseBeanProxyMethodHandler(Object proxy)
+ {
+ this.proxy = proxy;
+ log.trace("Created enterprise bean proxy method handler for " + proxy);
+ }
+
+ /**
+ * The method proxy
+ *
+ * Executes the corresponding method on the proxy
+ *
+ * @param self A reference to the proxy
+ * @param method The method to execute
+ * @param process The next method to proceed to
+ * @param args The method calling arguments
+ */
+ @Override
+ public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
+ {
+ Method proxiedMethod = Reflections.lookupMethod(method, proxy);
+ Object returnValue = Reflections.invokeAndWrap(proxiedMethod, proxy, args);
+ log.trace("Executed " + method + " on " + proxy + " with
parameters " + args + " and got return value " + returnValue);
+ return returnValue;
+ }
+
+}
Deleted:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.webbeans.bean.proxy;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import javassist.util.proxy.MethodHandler;
-
-import javax.webbeans.manager.Bean;
-import javax.webbeans.manager.Context;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.util.Reflections;
-
-/**
- * A Javassist MethodHandler that delegates method calls to a proxied bean. If
- * the transient bean has become null, it is looked up from the manager bean
- * list before the invocation.
- *
- * @author Nicklas Karlsson
- *
- * @see org.jboss.webbeans.bean.proxy.ProxyPool
- */
-public class ProxyMethodHandler implements MethodHandler, Serializable
-{
- private static final long serialVersionUID = -5391564935097267888L;
- // The bean
- private transient Bean<?> bean;
- // The bean index in the manager
- private int beanIndex;
-
- /**
- * Constructor
- *
- * @param bean The bean to proxy
- * @param beanIndex The index to the bean in the manager bean list
- */
- public ProxyMethodHandler(Bean<?> bean, int beanIndex)
- {
- this.bean = bean;
- this.beanIndex = beanIndex;
- }
-
- /**
- * The method proxy
- *
- * Uses reflection to look up the corresponding method on the proxy and
- * executes that method with the same parameters.
- *
- * @param self A reference to the proxy
- * @param method The method to execute
- * @param process The next method to proceed to
- * @param args The method calling arguments
- */
- public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
- {
- //TODO account for child managers
- if (bean == null)
- {
- bean = CurrentManager.rootManager().getBeans().get(beanIndex);
- }
- Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
- Object proxiedInstance = context.get(bean, true);
- Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
- return proxiedMethod.invoke(proxiedInstance, args);
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- String beanInfo = bean == null ? "null bean" : bean.toString();
- buffer.append("Proxy method handler for " + beanInfo + " with index
" + beanIndex);
- return buffer.toString();
- }
-
-}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -41,14 +41,18 @@
*/
public class ProxyPool implements Serializable
{
+ private static final long serialVersionUID = 1L;
+
/**
* A container/cache for previously created proxies
*
* @author Nicklas Karlsson
*/
-
private ConcurrentCache<Bean<? extends Object>, Object> pool;
+ /**
+ * Constructor
+ */
public ProxyPool()
{
this.pool = new ConcurrentCache<Bean<? extends Object>, Object>();
@@ -130,7 +134,7 @@
{
throw new RuntimeException("Could not access bean correctly when creating
client proxy for " + bean, e);
}
- ProxyMethodHandler proxyMethodHandler = new ProxyMethodHandler(bean, beanIndex);
+ SimpleBeanProxyMethodHandler proxyMethodHandler = new
SimpleBeanProxyMethodHandler(bean, beanIndex);
((ProxyObject) clientProxy).setHandler(proxyMethodHandler);
return clientProxy;
}
Copied:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/SimpleBeanProxyMethodHandler.java
(from rev 659,
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java)
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/SimpleBeanProxyMethodHandler.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/SimpleBeanProxyMethodHandler.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.bean.proxy;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.MethodHandler;
+
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Context;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * A Javassist MethodHandler that delegates method calls to a proxied bean. If
+ * the transient bean has become null, it is looked up from the manager bean
+ * list before the invocation.
+ *
+ * @author Nicklas Karlsson
+ *
+ * @see org.jboss.webbeans.bean.proxy.ProxyPool
+ */
+public class SimpleBeanProxyMethodHandler implements MethodHandler, Serializable
+{
+ private static final long serialVersionUID = -5391564935097267888L;
+ // The log provider
+ private LogProvider log = Logging.getLogProvider(SimpleBeanProxyMethodHandler.class);
+ // The bean
+ private transient Bean<?> bean;
+ // The bean index in the manager
+ private int beanIndex;
+
+ /**
+ * Constructor
+ *
+ * @param bean The bean to proxy
+ * @param beanIndex The index to the bean in the manager bean list
+ */
+ public SimpleBeanProxyMethodHandler(Bean<?> bean, int beanIndex)
+ {
+ this.bean = bean;
+ this.beanIndex = beanIndex;
+ log.trace("Created method handler for bean " + bean + " indexed as
" + beanIndex);
+ }
+
+ /**
+ * The method proxy
+ *
+ * Uses reflection to look up the corresponding method on the proxy and
+ * executes that method with the same parameters.
+ *
+ * @param self A reference to the proxy
+ * @param method The method to execute
+ * @param process The next method to proceed to
+ * @param args The method calling arguments
+ */
+ public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
+ {
+ // TODO account for child managers
+ if (bean == null)
+ {
+ bean = CurrentManager.rootManager().getBeans().get(beanIndex);
+ }
+ Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
+ Object proxiedInstance = context.get(bean, true);
+ Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
+ Object returnValue = proxiedMethod.invoke(proxiedInstance, args);
+ log.trace("Executed method " + proxiedMethod + " on " +
proxiedInstance + " with parameters " + args + " and got return value
" + returnValue);
+ return returnValue;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ String beanInfo = bean == null ? "null bean" : bean.toString();
+ buffer.append("Proxy method handler for " + beanInfo + " with index
" + beanIndex);
+ return buffer.toString();
+ }
+
+}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/PropertiesBasedBootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/PropertiesBasedBootstrap.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/PropertiesBasedBootstrap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.bootstrap;
import java.lang.reflect.Constructor;
@@ -23,7 +40,7 @@
*/
public abstract class PropertiesBasedBootstrap extends WebBeansBootstrap
{
-
+ // The log provider
private static final LogProvider log =
Logging.getLogProvider(ServletBootstrap.class);
/**
@@ -52,6 +69,13 @@
return null;
}
+ /**
+ * Creates an instance of the type
+ *
+ * @param constructor The constructor to use
+ * @param parameters The parameters to pass to the contstructor
+ * @return An instance of the type
+ */
protected static <T> T newInstance(Constructor<T> constructor, Object...
parameters)
{
try
@@ -77,6 +101,8 @@
}
/**
+ * Initializes the naming provider
+ *
* Only safe to call once resourceloader and deployment properties are set
*/
protected void initProperties()
@@ -93,7 +119,13 @@
}
-
+ /**
+ * Gets the deployment properties
+ *
+ * @return The deployment properties
+ *
+ * @see org.jboss.webbeans.util.DeploymentProperties
+ */
protected abstract DeploymentProperties getDeploymentProperties();
}
\ No newline at end of file
Copied:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMap.java (from
rev 734,
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMap.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.contexts;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.webbeans.manager.Contextual;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.servlet.ApplicationBeanMap;
+
+public abstract class AbstractBeanMap implements BeanMap
+{
+ // The log provider
+ private static LogProvider log = Logging.getLogProvider(ApplicationBeanMap.class);
+
+ /**
+ * Gets a bean from the map
+ *
+ * @param bean The bean to get
+ * @return The instance
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T get(Contextual<? extends T> bean)
+ {
+ String key = getBeanKey(bean);
+ T instance = (T) getAttribute(key);
+ log.trace("Looked for " + key + " and got " + instance);
+ return instance;
+ }
+
+ /**
+ * Removes an instance from the map
+ *
+ * @param bean The bean of the instance to remove
+ * @return The removed instance
+ */
+ public <T> T remove(Contextual<? extends T> bean)
+ {
+ T instance = get(bean);
+ String key = getBeanKey(bean);
+ removeAttribute(key);
+ log.trace("Removed bean under key " + key);
+ return instance;
+ }
+
+ /**
+ * Clears the bean map
+ */
+ @SuppressWarnings("unchecked")
+ public void clear()
+ {
+ Enumeration names = getAttributeNames();
+ while (names.hasMoreElements())
+ {
+ String name = (String) names.nextElement();
+ removeAttribute(name);
+ log.trace("Cleared " + name);
+ }
+ log.trace("Bean Map cleared");
+ }
+
+ /**
+ * Returns the beans present in the map
+ *
+ * @return The beans
+ */
+ @SuppressWarnings("unchecked")
+ public Iterable<Contextual<? extends Object>> keySet()
+ {
+ List<Contextual<?>> beans = new
ArrayList<Contextual<?>>();
+ Enumeration names = getAttributeNames();
+ while (names.hasMoreElements())
+ {
+ String name = (String) names.nextElement();
+ if (name.startsWith(getKeyPrefix()))
+ {
+ String id = name.substring(getKeyPrefix().length() + 1);
+ Contextual<?> bean =
CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
+ beans.add(bean);
+ }
+ }
+ return beans;
+ }
+
+ /**
+ * Puts an instance of a bean in the map
+ *
+ * @param bean The key bean
+ * @param instance The instance
+ * @return The instance added
+ */
+ public <T> void put(Contextual<? extends T> bean, T instance)
+ {
+ String key = getBeanKey(bean);
+ setAttribute(key, instance);
+ log.trace("Added bean " + bean + " under key " + key);
+ }
+
+ /**
+ * Gets an attribute from the underlying storage
+ *
+ * @param key The key of the attribute
+ * @return The data
+ */
+ protected abstract Object getAttribute(String key);
+
+ /**
+ * Removes an attribute from the underlying storage
+ *
+ * @param key The attribute to remove
+ */
+ protected abstract void removeAttribute(String key);
+
+ /**
+ * Gets an enumeration of the beans present in the underlying storage
+ *
+ * @return The current beans
+ */
+ protected abstract Enumeration<String> getAttributeNames();
+
+ /**
+ * Sets an instance under a key in the underlying storage
+ *
+ * @param key The key
+ * @param instance The instance
+ */
+ protected abstract void setAttribute(String key, Object instance);
+
+ /**
+ * Gets a key prefix that should be prefixed to names
+ *
+ * @return The prefix
+ */
+ protected abstract String getKeyPrefix();
+
+ /**
+ * Returns a map key to a bean. Uses a known prefix and appends the index of
+ * the Bean in the Manager bean list.
+ *
+ * @param bean The bean to generate a key for.
+ * @return A unique key;
+ */
+ protected String getBeanKey(Contextual<?> bean)
+ {
+ return getKeyPrefix() + "#" +
CurrentManager.rootManager().getBeans().indexOf(bean);
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
Deleted:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapAdaptor.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,168 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.webbeans.contexts;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.webbeans.manager.Contextual;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.servlet.ApplicationBeanMap;
-
-public abstract class AbstractBeanMapAdaptor implements BeanMap
-{
- // The log provider
- private static LogProvider log = Logging.getLogProvider(ApplicationBeanMap.class);
-
- /**
- * Gets a bean from the map
- *
- * @param bean The bean to get
- * @return The instance
- */
- @SuppressWarnings("unchecked")
- public <T> T get(Contextual<? extends T> bean)
- {
- String key = getBeanKey(bean);
- T instance = (T) getAttribute(key);
- log.trace("Looked for " + key + " and got " + instance);
- return instance;
- }
-
- /**
- * Removes an instance from the map
- *
- * @param bean The bean of the instance to remove
- * @return The removed instance
- */
- public <T> T remove(Contextual<? extends T> bean)
- {
- T instance = get(bean);
- String key = getBeanKey(bean);
- removeAttribute(key);
- log.trace("Removed bean under key " + key);
- return instance;
- }
-
- /**
- * Clears the bean map
- */
- @SuppressWarnings("unchecked")
- public void clear()
- {
- Enumeration names = getAttributeNames();
- while (names.hasMoreElements())
- {
- String name = (String) names.nextElement();
- removeAttribute(name);
- log.trace("Cleared " + name);
- }
- log.trace("Bean Map cleared");
- }
-
- /**
- * Returns the beans present in the map
- *
- * @return The beans
- */
- @SuppressWarnings("unchecked")
- public Iterable<Contextual<? extends Object>> keySet()
- {
- List<Contextual<?>> beans = new
ArrayList<Contextual<?>>();
- Enumeration names = getAttributeNames();
- while (names.hasMoreElements())
- {
- String name = (String) names.nextElement();
- if (name.startsWith(getKeyPrefix()))
- {
- String id = name.substring(getKeyPrefix().length() + 1);
- Contextual<?> bean =
CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
- beans.add(bean);
- }
- }
- return beans;
- }
-
- /**
- * Puts an instance of a bean in the map
- *
- * @param bean The key bean
- * @param instance The instance
- * @return The instance added
- */
- public <T> void put(Contextual<? extends T> bean, T instance)
- {
- String key = getBeanKey(bean);
- setAttribute(key, instance);
- log.trace("Added bean " + bean + " under key " + key);
- }
-
- /**
- * Gets an attribute from the underlying storage
- *
- * @param key The key of the attribute
- * @return The data
- */
- protected abstract Object getAttribute(String key);
-
- /**
- * Removes an attribute from the underlying storage
- *
- * @param key The attribute to remove
- */
- protected abstract void removeAttribute(String key);
-
- /**
- * Gets an enumeration of the beans present in the underlying storage
- *
- * @return The current beans
- */
- protected abstract Enumeration<String> getAttributeNames();
-
- /**
- * Sets an instance under a key in the underlying storage
- *
- * @param key The key
- * @param instance The instance
- */
- protected abstract void setAttribute(String key, Object instance);
-
- /**
- * Gets a key prefix that should be prefixed to names
- *
- * @return The prefix
- */
- protected abstract String getKeyPrefix();
-
- /**
- * Returns a map key to a bean. Uses a known prefix and appends the index of
- * the Bean in the Manager bean list.
- *
- * @param bean The bean to generate a key for.
- * @return A unique key;
- */
- protected String getBeanKey(Contextual<?> bean)
- {
- return getKeyPrefix() + "#" +
CurrentManager.rootManager().getBeans().indexOf(bean);
- }
-
-}
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapContext.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractBeanMapContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.contexts;
+
+import java.lang.annotation.Annotation;
+
+import javax.webbeans.ContextNotActiveException;
+import javax.webbeans.manager.Bean;
+import javax.webbeans.manager.Contextual;
+
+/**
+ * Base for the Context implementations. Delegates calls to the abstract
+ * getBeanMap and getActive to allow for different implementations (storage
+ * types and ThreadLocal vs. shared)
+ *
+ * @author Nicklas Karlsson
+ * @author Pete Muir
+ *
+ * @see org.jboss.webbeans.contexts.SharedContext
+ * @see org.jboss.webbeans.contexts.BasicContext
+ */
+public abstract class AbstractBeanMapContext extends AbstractContext
+{
+ /**
+ * Constructor
+ *
+ * @param scopeType The scope type
+ */
+ public AbstractBeanMapContext(Class<? extends Annotation> scopeType)
+ {
+ super(scopeType);
+ }
+
+ /**
+ * Get the bean if it exists in the contexts.
+ *
+ * @param create If true, a new instance of the bean will be created if none
+ * exists
+ * @return An instance of the bean
+ * @throws ContextNotActiveException if the context is not active
+ *
+ * @see javax.webbeans.manager.Context#get(Bean, boolean)
+ */
+ public <T> T get(Contextual<T> bean, boolean create)
+ {
+ if (!isActive())
+ {
+ throw new ContextNotActiveException();
+ }
+ T instance = getBeanMap().get(bean);
+ if (instance != null)
+ {
+ return instance;
+ }
+ if (!create)
+ {
+ return null;
+ }
+ instance = bean.create();
+ getBeanMap().put(bean, instance);
+ return instance;
+ }
+
+ /**
+ * Destroys a bean
+ *
+ * @param <T> The type of the bean
+ * @param bean The bean to destroy
+ */
+ private <T> void destroy(Contextual<T> bean)
+ {
+ bean.destroy(getBeanMap().get(bean));
+ }
+
+ /**
+ * Destroys the context
+ */
+ public void destroy()
+ {
+ for (Contextual<? extends Object> bean : getBeanMap().keySet())
+ {
+ destroy(bean);
+ }
+ getBeanMap().clear();
+ }
+
+ /**
+ * A method that should return the actual bean map implementation
+ *
+ * @return The actual bean map
+ */
+ protected abstract BeanMap getBeanMap();
+
+}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/AbstractContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -19,26 +19,13 @@
import java.lang.annotation.Annotation;
-import javax.webbeans.ContextNotActiveException;
-import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
-import javax.webbeans.manager.Contextual;
-/**
- * Base for the Context implementations. Delegates calls to the abstract
- * getBeanMap and getActive to allow for different implementations (storage
- * types and ThreadLocal vs. shared)
- *
- * @author Nicklas Karlsson
- * @author Pete Muir
- *
- * @see org.jboss.webbeans.contexts.SharedContext
- * @see org.jboss.webbeans.contexts.BasicContext
- */
public abstract class AbstractContext implements Context
{
// The scope type
private Class<? extends Annotation> scopeType;
+ // The active state of the context
private ThreadLocal<Boolean> active;
/**
@@ -60,36 +47,6 @@
}
/**
- * Get the bean if it exists in the contexts.
- *
- * @param create If true, a new instance of the bean will be created if none
- * exists
- * @return An instance of the bean
- * @throws ContextNotActiveException if the context is not active
- *
- * @see javax.webbeans.manager.Context#get(Bean, boolean)
- */
- public <T> T get(Contextual<T> bean, boolean create)
- {
- if (!isActive())
- {
- throw new ContextNotActiveException();
- }
- T instance = getBeanMap().get(bean);
- if (instance != null)
- {
- return instance;
- }
- if (!create)
- {
- return null;
- }
- instance = bean.create();
- getBeanMap().put(bean, instance);
- return instance;
- }
-
- /**
* Get the scope the context is for
*
* @return The scope type
@@ -124,36 +81,6 @@
}
/**
- * Destroys a bean
- *
- * @param <T> The type of the bean
- * @param bean The bean to destroy
- */
- private <T> void destroy(Contextual<T> bean)
- {
- bean.destroy(getBeanMap().get(bean));
- }
-
- /**
- * Destroys the context
- */
- public void destroy()
- {
- for (Contextual<? extends Object> bean : getBeanMap().keySet())
- {
- destroy(bean);
- }
- getBeanMap().clear();
- }
-
- /**
- * A method that should return the actual bean map implementation
- *
- * @return The actual bean map
- */
- protected abstract BeanMap getBeanMap();
-
- /**
* Delegates to a ThreadLocal instance
*/
protected Boolean getActive()
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ApplicationContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -30,7 +30,7 @@
*
* @see org.jboss.webbeans.contexts.ApplicationContext
*/
-public class ApplicationContext extends AbstractContext
+public class ApplicationContext extends AbstractBeanMapContext
{
public static ApplicationContext INSTANCE = new ApplicationContext();
@@ -97,7 +97,7 @@
{
String active = isActive() ? "Active " : "Inactive ";
String count = getBeanMap() == null ? "" : "holding " +
Names.count(getBeanMap().keySet()) + " instances ";
- String prefix = getBeanMap() == null ? "" : "with key prefix "
+ ((AbstractBeanMapAdaptor) getBeanMap()).getKeyPrefix();
+ String prefix = getBeanMap() == null ? "" : "with key prefix "
+ ((AbstractBeanMap) getBeanMap()).getKeyPrefix();
return active + "application context " + count + prefix;
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/BasicContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/BasicContext.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/BasicContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -32,7 +32,7 @@
* @see org.jboss.webbeans.contexts.ConversationContext
* @see org.jboss.webbeans.contexts.SessionContext
*/
-public abstract class BasicContext extends AbstractContext
+public abstract class BasicContext extends AbstractBeanMapContext
{
// The beans
protected ThreadLocal<BeanMap> beans;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -38,6 +38,7 @@
*/
public class ContextMap extends ConcurrentCache<Class<? extends Annotation>,
List<Context>>
{
+ private static final long serialVersionUID = 1L;
/**
* Gets the dependent context
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/DependentContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -23,14 +23,12 @@
import javax.webbeans.Dependent;
import javax.webbeans.manager.Contextual;
-import org.jboss.webbeans.util.Names;
-
/**
* The dependent context
*
* @author Nicklas Karlsson
*/
-public class DependentContext extends BasicContext
+public class DependentContext extends AbstractContext
{
public static final DependentContext INSTANCE = new DependentContext();
@@ -75,8 +73,7 @@
public String toString()
{
String active = isActive() ? "Active " : "Inactive ";
- String count = getBeanMap() == null ? "" : "holding " +
Names.count(getBeanMap().keySet()) + " instances ";
- return active + "dependent context " + count;
+ return active + "dependent context";
}
@Override
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -28,7 +28,7 @@
*
* @author Nicklas Karlsson
*/
-public class SessionContext extends AbstractContext
+public class SessionContext extends AbstractBeanMapContext
{
private static LogProvider log = Logging.getLogProvider(SessionContext.class);
@@ -74,7 +74,7 @@
{
String active = isActive() ? "Active " : "Inactive ";
String count = getBeanMap() == null ? "" : "holding " +
Names.count(getBeanMap().keySet()) + " instances ";
- String prefix = getBeanMap() == null ? "" : "with key prefix "
+ ((AbstractBeanMapAdaptor) getBeanMap()).getKeyPrefix();
+ String prefix = getBeanMap() == null ? "" : "with key prefix "
+ ((AbstractBeanMap) getBeanMap()).getKeyPrefix();
return active + "session context " + count + prefix;
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -33,6 +33,7 @@
*/
public class EjbDescriptorCache implements Serializable
{
+ private static final long serialVersionUID = 1L;
// EJB name -> EJB descriptor map
private ConcurrentMap<String, EjbDescriptor<?>> ejbsByName;
@@ -118,17 +119,20 @@
add(ejbDescriptor);
}
}
-
+
+ /**
+ * Clears both maps
+ */
public void clear()
{
ejbsByBeanClass.clear();
ejbsByName.clear();
}
-
+
@Override
public String toString()
{
- return ejbsByBeanClass + "\n" + ejbsByName;
+ return "EJB Descriptor cache has indexed " + ejbsByBeanClass.size() +
" EJBs by class and " + ejbsByName + " by name";
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.ejb;
import javax.annotation.PostConstruct;
@@ -8,9 +25,18 @@
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bean.EnterpriseBean;
+/**
+ * Interceptor for handling EJB post-construct tasks
+ *
+ * @author Pete Muir
+ */
public class SessionBeanInterceptor
{
-
+ /**
+ * Gets the underlying target and calls the post-construct method
+ *
+ * @param invocationContext The invocation context
+ */
@PostConstruct
public void postConstruct(InvocationContext invocationContext)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -42,11 +42,14 @@
*/
public class EventManager implements Serializable
{
- /**
+ private static final long serialVersionUID = 1L;
+
+ /**
* An event type -> observer list map
*/
private class RegisteredObserversMap extends ForwardingMap<Class<?>,
List<EventObserver<?>>> implements Serializable
{
+ private static final long serialVersionUID = 1L;
// The map delegate
private ConcurrentHashMap<Class<?>, List<EventObserver<?>>>
delegate;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/JSFApiAbstraction.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -29,7 +29,6 @@
public class JSFApiAbstraction extends ApiAbstraction
{
-
// An UI component
public final Class<?> UICOMPONENT_CLASS;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/resources/DefaultNaming.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/resources/DefaultNaming.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/resources/DefaultNaming.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.resources;
import javax.naming.InitialContext;
@@ -6,30 +23,48 @@
import org.jboss.webbeans.resources.spi.Naming;
+/**
+ * The default naming provider
+ *
+ * @author Pete Muir
+ */
public class DefaultNaming implements Naming
{
-
+ private static final long serialVersionUID = 1L;
+ // The initial lookup context
private transient InitialContext initialContext;
-
+
+ /**
+ * Constructor
+ */
public DefaultNaming()
{
- try
+ try
{
this.initialContext = new InitialContext();
}
- catch (NamingException e)
+ catch (NamingException e)
{
- throw new ExecutionException("Could not obtain InitialContext", e);
+ throw new ExecutionException("Could not obtain InitialContext", e);
}
}
-
-
+ /**
+ * Gets the initial context
+ *
+ * @return The initial context
+ */
public InitialContext getInitialContext()
{
return initialContext;
}
-
+
+ /**
+ * Binds in item to JNDI
+ *
+ * @param key The key to bind under
+ * @param value The value to bind
+ */
public void bind(String key, Object value)
{
try
@@ -41,7 +76,15 @@
throw new ExecutionException("Cannot bind " + value + " to "
+ key, e);
}
}
-
+
+ /**
+ * Lookup an item from JNDI
+ *
+ * @param name The key
+ * @param expectedType The expected return type
+ * @return The found item
+ */
+ @SuppressWarnings("unchecked")
public <T> T lookup(String name, Class<? extends T> expectedType)
{
Object instance;
@@ -57,10 +100,10 @@
{
return (T) instance;
}
- catch (ClassCastException e)
+ catch (ClassCastException e)
{
throw new ExecutionException(instance + " not of expected type " +
expectedType, e);
}
}
-
+
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanMap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -21,7 +21,7 @@
import javax.servlet.ServletContext;
-import org.jboss.webbeans.contexts.AbstractBeanMapAdaptor;
+import org.jboss.webbeans.contexts.AbstractBeanMap;
import org.jboss.webbeans.contexts.ApplicationContext;
/**
@@ -31,7 +31,7 @@
*
* @see org.jboss.webbeans.contexts.ApplicationContext
*/
-public class ApplicationBeanMap extends AbstractBeanMapAdaptor
+public class ApplicationBeanMap extends AbstractBeanMap
{
// The servlet context to use as backing map
private ServletContext context;
@@ -48,7 +48,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getKeyPrefix()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getKeyPrefix()
*/
@Override
protected String getKeyPrefix()
@@ -57,7 +57,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getAttribute()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getAttribute()
*/
@Override
protected Object getAttribute(String key)
@@ -66,7 +66,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getAttributeNames()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getAttributeNames()
*/
@SuppressWarnings("unchecked")
@Override
@@ -76,7 +76,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#removeAttributes()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#removeAttributes()
*/
@Override
protected void removeAttribute(String key)
@@ -85,7 +85,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#setAttribute()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#setAttribute()
*/
@Override
protected void setAttribute(String key, Object instance)
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.servlet;
import org.jboss.webbeans.resources.spi.ResourceLoader;
@@ -3,4 +20,9 @@
import org.jboss.webbeans.util.ApiAbstraction;
+/**
+ * Abstraction for classes in the Servlet API
+ *
+ * @author Pete Muir
+ */
public class ServletApiAbstraction extends ApiAbstraction
{
@@ -11,7 +33,12 @@
public final Class<?> SERVLET_CONTEXT_LISTENER_CLASS;
public final Class<?> HTTP_SESSION_LISTENER_CLASS;
public final Class<?> SERVLET_REQUEST_LISTENER_CLASS;
-
+
+ /**
+ * Constructor
+ *
+ * @param resourceLoader The root resource loader
+ */
public ServletApiAbstraction(ResourceLoader resourceLoader)
{
super(resourceLoader);
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletBootstrap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,6 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.servlet;
-
import java.lang.reflect.Constructor;
import javax.servlet.ServletContext;
@@ -15,12 +31,20 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.util.DeploymentProperties;
+/**
+ * Bootstrapper for usage within servlet environments
+ *
+ * @author Pete Muir
+ */
public class ServletBootstrap extends PropertiesBasedBootstrap
{
-
+ // The Web Beans manager
private ManagerImpl manager;
+ // The resource loader
private ResourceLoader resourceLoader;
+ // The discover implementation
private WebBeanDiscovery webBeanDiscovery;
+ // The deployment properties
private DeploymentProperties deploymentProperties;
public ServletBootstrap(ServletContext servletContext)
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletContextResourceLoader.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletContextResourceLoader.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletContextResourceLoader.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.servlet;
import java.io.IOException;
@@ -9,16 +26,35 @@
import org.jboss.webbeans.resources.spi.ResourceLoadingException;
import org.jboss.webbeans.util.EnumerationIterable;
+/**
+ * A resource loader based on a servlet context
+ *
+ * @author Pete Muir
+ *
+ */
public class ServletContextResourceLoader implements ResourceLoader
{
-
+ // The servlet context
private final ServletContext servletContext;
+ /**
+ * Constructor
+ *
+ * @param servletContext The servlet context
+ */
public ServletContextResourceLoader(ServletContext servletContext)
{
this.servletContext = servletContext;
}
+ /**
+ * Creates a class with a given name from the servlet contexts classloader
+ *
+ * @param The FQCN of the class
+ * @return The class
+ *
+ * @see org.jboss.webbeans.resources.spi.ResourceLoader#classForName(String)
+ */
public Class<?> classForName(String name)
{
try
@@ -34,18 +70,27 @@
throw new ResourceLoadingException(e);
}
}
-
+
+ /**
+ * @see org.jboss.webbeans.resources.spi.ResourceLoader#getResource(String)
+ */
public URL getResource(String name)
{
URL resource = getResourceFromServletContext(name);
if (resource == null)
{
String stripped = name.startsWith("/") ? name.substring(1) : name;
- resource = servletContext.getClass().getClassLoader().getResource(name);
+ resource = servletContext.getClass().getClassLoader().getResource(stripped);
}
return resource;
}
+ /**
+ * Gets an resource from the classloader of the servlet context
+ *
+ * @param name The name of the resource
+ * @return An URL to the resource
+ */
private URL getResourceFromServletContext(String name)
{
try
@@ -58,6 +103,9 @@
}
}
+ /**
+ * @see org.jboss.webbeans.resources.spi.ResourceLoader#getResource(String)
+ */
public Iterable<URL> getResources(String name)
{
try
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -21,7 +21,7 @@
import javax.servlet.http.HttpSession;
-import org.jboss.webbeans.contexts.AbstractBeanMapAdaptor;
+import org.jboss.webbeans.contexts.AbstractBeanMap;
import org.jboss.webbeans.contexts.ApplicationContext;
/**
@@ -31,7 +31,7 @@
*
* @see org.jboss.webbeans.contexts.ApplicationContext
*/
-public class SessionBeanMap extends AbstractBeanMapAdaptor
+public class SessionBeanMap extends AbstractBeanMap
{
// The HTTP session context to use as backing map
private HttpSession session;
@@ -48,7 +48,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getKeyPrefix()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getKeyPrefix()
*/
@Override
protected String getKeyPrefix()
@@ -57,7 +57,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getAttribute()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getAttribute()
*/
@Override
protected Object getAttribute(String key)
@@ -66,7 +66,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#getAttributeNames()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#getAttributeNames()
*/
@SuppressWarnings("unchecked")
@Override
@@ -76,7 +76,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#removeAttributes()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#removeAttributes()
*/
@Override
protected void removeAttribute(String key)
@@ -85,7 +85,7 @@
}
/**
- * @see org.jboss.webbeans.contexts.AbstractBeanMapAdaptor#setAttribute()
+ * @see org.jboss.webbeans.contexts.AbstractBeanMap#setAttribute()
*/
@Override
protected void setAttribute(String key, Object instance)
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ApiAbstraction.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -46,8 +46,12 @@
{
}
-
+ /**
+ * Constructor
+ *
+ * @param resourceLoader The root resource loaderS
+ */
public ApiAbstraction(ResourceLoader resourceLoader)
{
this.resourceLoader = resourceLoader;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ConcurrentCache.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ConcurrentCache.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ConcurrentCache.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -34,6 +34,7 @@
*/
public class ConcurrentCache<K, V> extends ForwardingMap<K, Future<V>>
implements Serializable
{
+ private static final long serialVersionUID = 1L;
// The backing map with the value wrapped in a Future instance
private ConcurrentHashMap<K, Future<V>> map;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/DeploymentProperties.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/DeploymentProperties.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/DeploymentProperties.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -154,6 +154,7 @@
* @param propertyName The name of the property to load
* @return A set of classes specified
*/
+ @SuppressWarnings("unchecked")
public static <T> Set<Class<? extends T>>
getClasses(DeploymentProperties deploymentProperties, ResourceLoader resourceLoader,
String propertyName, Class<T> expectedType)
{
Set<Class<? extends T>> classes = new HashSet<Class<? extends
T>>();
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/AbstractTest.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -14,10 +14,11 @@
public class AbstractTest
{
-
protected MockManagerImpl manager;
protected MockBootstrap webBeansBootstrap;
-
+
+ public static boolean visited = false;
+
@BeforeMethod
public final void before()
{
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-26
18:28:04 UTC (rev 734)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ManagerTest.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -6,7 +6,7 @@
import javax.webbeans.RequestScoped;
import javax.webbeans.manager.Context;
-import org.jboss.webbeans.contexts.AbstractContext;
+import org.jboss.webbeans.contexts.AbstractBeanMapContext;
import org.jboss.webbeans.contexts.RequestContext;
import org.jboss.webbeans.test.beans.FishFarmOffice;
import org.testng.annotations.Test;
@@ -26,7 +26,7 @@
public void testGetContextWithNoActiveContextsFails()
{
Context requestContext = new RequestContext() {};
- ((AbstractContext)requestContext).setActive(false);
+ ((AbstractBeanMapContext)requestContext).setActive(false);
manager.addContext(requestContext);
manager.getContext(RequestScoped.class);
}
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanLifecycleTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanLifecycleTest.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanLifecycleTest.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -2,9 +2,15 @@
import javax.webbeans.UnremovedException;
+import org.jboss.webbeans.bean.BeanFactory;
+import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.test.AbstractTest;
import org.jboss.webbeans.test.SpecAssertion;
import org.jboss.webbeans.test.SpecVersion;
+import org.jboss.webbeans.test.ejb.valid.GoodDoggie;
+import org.jboss.webbeans.test.ejb.valid.LocalGoodDoggie;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -22,8 +28,17 @@
@SpecVersion("20081206")
public class EnterpriseBeanLifecycleTest extends AbstractTest
{
-
/**
+ * Initializes the EJB descriptors for the EJBs about to be used
+ */
+ @BeforeMethod
+ public void setupEjbDescriptors()
+ {
+ addToEjbCache(GoodDoggie.class);
+ addToEjbCache(LocalGoodDoggie.class);
+ }
+
+ /**
* When the create() method is called, the Web Bean manager creates and
* returns an enterprise bean proxy
*/
@@ -38,11 +53,17 @@
* When the destroy() method is called, the Web Bean manager calls the Web
* Bean remove method upon the proxy
*/
- @Test(groups = { "enterpriseBeans", "clientProxy",
"lifecycle", "stub" })
+ @Test(groups = { "enterpriseBeans", "clientProxy",
"lifecycle", "stub"})
@SpecAssertion(section = "6.4")
public void testRemoveMethodCalled()
{
- assert false;
+ visited = false;
+ DependentContext.INSTANCE.setActive(true);
+ EnterpriseBean<GoodDoggie> bean =
BeanFactory.createEnterpriseBean(GoodDoggie.class, manager);
+ manager.addBean(bean);
+ GoodDoggie doggie = manager.getInstance(bean);
+ bean.destroy(doggie);
+ assert visited = true;
}
/**
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -18,6 +18,7 @@
import org.jboss.webbeans.test.ejb.invalid.RussellTerrier;
import org.jboss.webbeans.test.ejb.invalid.Saluki;
import org.jboss.webbeans.test.ejb.invalid.Spitz;
+import org.jboss.webbeans.test.ejb.valid.GoodDoggie;
import org.jboss.webbeans.test.ejb.valid.Koirus;
import org.jboss.webbeans.test.ejb.valid.Toller;
import org.jboss.webbeans.test.ejb.valid.WelshCorgie;
@@ -27,18 +28,20 @@
/**
* Sections
*
- * 3.3.5. Web Bean remove methods
- * 3.3.5.1. Declaring a Web Bean remove method using annotations.
- * 3.3.5.2. Declaring a Web Bean remove method using XML
+ * 3.3.5. Web Bean remove methods 3.3.5.1. Declaring a Web Bean remove method
+ * using annotations. 3.3.5.2. Declaring a Web Bean remove method using XML
* 3.3.5.3. Remove method parameters
- *
+ *
* @author Nicklas Karlsson
*/
@SpecVersion("20081206")
@SuppressWarnings("unused")
public class EnterpriseBeanRemoveMethodTest extends AbstractTest
{
-
+
+ /**
+ * Initializes the EJB descriptors for the EJBs about to be used
+ */
@BeforeMethod
public void setupEjbDescriptors()
{
@@ -52,9 +55,8 @@
addToEjbCache(Toller.class);
addToEjbCache(WelshCorgie.class);
addToEjbCache(Koirus.class);
+ addToEjbCache(GoodDoggie.class);
}
-
- public static boolean visited = false;
/**
* EJB spec
@@ -99,7 +101,6 @@
* DefinitionException is thrown by the Web Bean manager at initialization
* time
*/
- // TODO: sentenced duplicated in previous paragraph in specs
@Test(groups = { "enterpriseBeans", "removeMethod" },
expectedExceptions = DefinitionException.class)
@SpecAssertion(section = "3.3.5")
public void testStatefulEnterpriseBeanWithoutRemoveMethodMustBeDependentScoped()
@@ -113,7 +114,6 @@
* DefinitionException is thrown by the Web Bean manager at initialization
* time
*/
- // TODO: sentenced duplicated in previous paragraph in specs
@Test(groups = { "enterpriseBeans", "removeMethod" })
@SpecAssertion(section = "3.3.5")
public void testStatefulEnterpriseBeanWithoutRemoveMethodMustBeDependentScoped2()
@@ -127,7 +127,6 @@
* the application before the Web Bean manager attempts to destroy the
* instance, an UnremovedException is thrown by the Web Bean manager
*/
- // TODO: sentenced duplicated in previous paragraph in specs
@Test(groups = { "enterpriseBeans", "removeMethod",
"stub" }, expectedExceptions = UnremovedException.class)
@SpecAssertion(section = "3.3.5")
public void
testStatefulEnterpriseBeanWithoutRemoveMethodMustBeRemovedByApplicationBeforeManager()
@@ -165,9 +164,8 @@
/**
* If the application directly calls an EJB remove method of an instance of
* an enterprise Web Bean that is a stateful session bean and has scope
- *
* @Dependent, the Web Bean manager ignores the instance when instead of
- * destroying it
+ * destroying it
*/
@Test(groups = { "enterpriseBeans", "removeMethod",
"lifecycle", "stub" })
@SpecAssertion(section = "3.3.5")
@@ -241,6 +239,13 @@
EnterpriseBean<RussellTerrier> bean =
BeanFactory.createEnterpriseBean(RussellTerrier.class, manager);
}
+ @Test(groups = { "enterpriseBeans", "removeMethod" })
+ @SpecAssertion(section = { "3.3.5.1" })
+ public void testDestructorAnnotatedSingleRemoveMethod()
+ {
+ EnterpriseBean<GoodDoggie> bean =
BeanFactory.createEnterpriseBean(GoodDoggie.class, manager);
+ }
+
/**
* If a Web Bean remove method is annotated @Initializer or @Produces, has a
* parameter annotated @Disposes, or has a parameter annotated @Observes, a
@@ -293,16 +298,6 @@
EnterpriseBean<JackRussellTerrier> bean =
BeanFactory.createEnterpriseBean(JackRussellTerrier.class, manager);
}
- // TODO: where did this come from?
- // @Test(groups = { "enterpriseBeans", "removeMethod" },
expectedExceptions =
- // DefinitionException.class)
- // @SpecAssertion(section = { "3.3.5.1", "3.3.5.2" })
- // public void testMultipleRemoveAnnotationsButNoDestructorFails()
- // {
- // EnterpriseBean<Poodle> bean =
- // BeanFactory.createEnterpriseBean(Poodle.class);
- // }
-
/**
* If an enterprise Web Bean defined using XML does not explicitly declare a
* Web Bean remove method using XML, and exactly one remove method that
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/GoodDoggie.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/GoodDoggie.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/GoodDoggie.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -4,11 +4,14 @@
import javax.ejb.Stateful;
import javax.webbeans.Destructor;
+import org.jboss.webbeans.test.ejb.EnterpriseBeanRemoveMethodTest;
+
@Stateful
-public class GoodDoggie
+public class GoodDoggie implements LocalGoodDoggie
{
@Destructor @Remove
public void bye() {
+ EnterpriseBeanRemoveMethodTest.visited = true;
}
}
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/LocalGoodDoggie.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/LocalGoodDoggie.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/LocalGoodDoggie.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.ejb.valid;
+
+import javax.ejb.Local;
+import javax.ejb.Remove;
+
+@Local
+public interface LocalGoodDoggie
+{
+ @Remove
+ public void bye();
+}
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -28,7 +28,6 @@
*/
public interface WebBeanDiscovery
{
-
public static final String PROPERTY_NAME = WebBeanDiscovery.class.getName();
/**
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/Naming.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/Naming.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/Naming.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.resources.spi;
import java.io.Serializable;
@@ -13,12 +30,17 @@
*
* @param <T> The type
* @param name The JNDI name
- * @param expectedType The excpected type
+ * @param expectedType The expected type
* @return The object
*/
- @SuppressWarnings("unchecked")
public <T> T lookup(String name, Class<? extends T> expectedType);
+ /**
+ * Binds an item to JNDI
+ *
+ * @param key The key to bind under
+ * @param value The item to bind
+ */
public void bind(String key, Object value);
}
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.webbeans.resources.spi;
import java.net.URL;
@@ -2,12 +19,35 @@
-
+/**
+ * Resource loading/class creation abstraction
+ *
+ * @author Pete Muir
+ *
+ */
public interface ResourceLoader
{
-
+ // Name of the resource loader
public static final String PROPERTY_NAME = ResourceLoader.class.getName();
+ /**
+ * Creates a class from a given FQCN
+ *
+ * @param name The name of the clsas
+ * @return The class
+ */
public Class<?> classForName(String name);
+ /**
+ * Gets a resource as a URL by name
+ *
+ * @param name The name of the resource
+ * @return An URL to the resource
+ */
public URL getResource(String name);
+ /**
+ * Gets resources as URLs by name
+ *
+ * @param name The name of the resource
+ * @return An iterable reference to the URLS
+ */
public Iterable<URL> getResources(String name);
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoadingException.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoadingException.java 2008-12-26
18:28:04 UTC (rev 734)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoadingException.java 2008-12-26
21:12:54 UTC (rev 735)
@@ -5,24 +5,50 @@
import javax.webbeans.ExecutionException;
+/**
+ * Exception thrown when errors occur while loading resource
+ *
+ * @author Pete Muir
+ *
+ */
public class ResourceLoadingException extends ExecutionException
{
+ private static final long serialVersionUID = 1L;
+ /**
+ * Constructor
+ */
public ResourceLoadingException()
{
super();
}
+ /**
+ * Constructor
+ *
+ * @param message The message
+ * @param throwable The exception
+ */
public ResourceLoadingException(String message, Throwable throwable)
{
super(message, throwable);
}
+ /**
+ * Constructor
+ *
+ * @param message The message
+ */
public ResourceLoadingException(String message)
{
super(message);
}
+ /**
+ * Constructor
+ *
+ * @param throwable The exception
+ */
public ResourceLoadingException(Throwable throwable)
{
super(throwable);