Author: nickarls
Date: 2008-11-29 16:17:54 -0500 (Sat, 29 Nov 2008)
New Revision: 381
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java
Log:
javadocs/comments
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ApplicationScopedAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.ApplicationScoped;
+/**
+ * Annotation literal for @ApplicationScoped
+ *
+ * @author Pete Muir
+ */
public class ApplicationScopedAnnotationLiteral extends
AnnotationLiteral<ApplicationScoped> implements ApplicationScoped
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ConversationScopedAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.ConversationScoped;
+/**
+ * Annotation literal for @ConversationScoped
+ *
+ * @author Pete Muir
+ */
public class ConversationScopedAnnotationLiteral extends
AnnotationLiteral<ConversationScoped> implements ConversationScoped
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/CurrentAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,3 +20,8 @@
import javax.webbeans.Current;
+/**
+ * Annotation literal for @Current
+ *
+ * @author Pete Muir
+ */
public class CurrentAnnotationLiteral extends AnnotationLiteral<Current> implements
Current {}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/DependentAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Dependent;
+/**
+ * Annotation literal for @Dependent
+ *
+ * @author Pete Muir
+ */
public class DependentAnnotationLiteral extends AnnotationLiteral<Dependent>
implements Dependent
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/NamedAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,3 +20,10 @@
import javax.webbeans.Named;
-public abstract class NamedAnnotationLiteral extends AnnotationLiteral<Named>
implements Named {}
\ No newline at end of file
+/**
+ * Annotation literal for @Named
+ *
+ * @author Pete Muir
+ */
+public abstract class NamedAnnotationLiteral extends AnnotationLiteral<Named>
implements Named
+{
+}
\ No newline at end of file
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/ProductionAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Production;
+/**
+ * Annotation literal for @Production
+ *
+ * @author Pete Muir
+ */
public class ProductionAnnotationLiteral extends AnnotationLiteral<Production>
implements Production
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/RequestScopedAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.RequestScoped;
+/**
+ * Annotation literal for @RequestScoped
+ *
+ * @author Pete Muir
+ */
public class RequestScopedAnnotationLiteral extends
AnnotationLiteral<RequestScoped> implements RequestScoped
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bindings/StandardAnnotationLiteral.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.bindings;
import javax.webbeans.AnnotationLiteral;
@@ -3,4 +20,9 @@
import javax.webbeans.Standard;
+/**
+ * Annotation literal for @Standard
+ *
+ * @author Pete Muir
+ */
public class StandardAnnotationLiteral extends AnnotationLiteral<Standard>
implements Standard
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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 static org.jboss.webbeans.util.BeanFactory.createEnterpriseBean;
@@ -17,49 +34,89 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+/**
+ * Bootstrapping functionality that is run at application startup and detects
+ * and register beans
+ *
+ * @author Pete Muir
+ */
public class Bootstrap
{
-
+ // The property name of the discovery class
public static String WEB_BEAN_DISCOVERY_PROPERTY_NAME =
"org.jboss.webbeans.bootstrap.webBeanDiscovery";
-
+
private static LogProvider log = Logging.getLogProvider(Bootstrap.class);
-
+
+ // The Web Beans manager
private ManagerImpl manager;
-
+
+ /**
+ * Constructor
+ *
+ * Starts up with a fresh manager
+ */
public Bootstrap()
{
this(new ManagerImpl());
}
-
+
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ */
protected Bootstrap(ManagerImpl manager)
{
this.manager = manager;
}
-
+
/**
* Register any beans defined by the provided classes with the manager
+ *
+ * @param classes The classes to register
*/
- public void registerBeans(Class<?>...classes)
+ public void registerBeans(Class<?>... classes)
{
registerBeans(new HashSet<Class<?>>(Arrays.asList(classes)));
}
-
+
+ /**
+ * Register the bean with the manager
+ *
+ * Creates the beans first and then sets them in the manager
+ *
+ * @param classes The classes to register as Web Beans
+ */
public void registerBeans(Iterable<Class<?>> classes)
{
Set<AbstractBean<?, ?>> beans = createBeans(classes);
manager.setBeans(beans);
}
-
+
/**
* Discover any beans defined by the provided classes
*
* Beans discovered are not registered with the manager
+ *
+ * @param classes The classes to create Web Beans from
+ * @return A set of Web Beans that represents the classes
*/
public Set<AbstractBean<?, ?>> createBeans(Class<?>... classes)
{
return createBeans(new HashSet<Class<?>>(Arrays.asList(classes)));
}
-
+
+ /**
+ * Creates Web Beans from a set of classes
+ *
+ * Iterates over the classes and creates a Web Bean of the corresponding
+ * type. Also register the beans injection points with the resolver. If the
+ * bean has producer methods, producer beans are created for these and those
+ * injection points are also registered.
+ *
+ * @param classes The classes to adapt
+ * @return A set of adapted Web Beans
+ */
public Set<AbstractBean<?, ?>> createBeans(Iterable<Class<?>>
classes)
{
Set<AbstractBean<?, ?>> beans = new HashSet<AbstractBean<?,
?>>();
@@ -87,6 +144,14 @@
return beans;
}
+ /**
+ * Starts the boot process.
+ *
+ * Discovers the beans and registers them with the manager. Also resolves the
+ * injection points.
+ *
+ * @param webBeanDiscovery The discovery implementation
+ */
public void boot(WebBeanDiscovery webBeanDiscovery)
{
log.info("Starting Web Beans RI " + getVersion());
@@ -98,35 +163,47 @@
log.info("Validing Web Bean injection points");
manager.getResolver().resolveInjectionPoints();
}
-
+
+ /**
+ * Gets version information
+ *
+ * @return The implementation version from the Bootstrap class package.
+ */
public static String getVersion()
{
Package pkg = Bootstrap.class.getPackage();
- return pkg != null ? pkg.getImplementationVersion() : null;
+ return pkg != null ? pkg.getImplementationVersion() : null;
}
-
-
+
+ /**
+ * Gets the available discovery implementations
+ *
+ * Parses the web-beans-ri.properties file and for each row describing a
+ * discover class, instantiate that class and add it to the set
+ *
+ * @return A set of discovery implementations
+ * @see org.jboss.webbeans.bootstrap.DeploymentProperties
+ */
+ @SuppressWarnings("unchecked")
public static Set<Class<? extends WebBeanDiscovery>>
getWebBeanDiscoveryClasses()
{
Set<Class<? extends WebBeanDiscovery>> webBeanDiscoveryClasses = new
HashSet<Class<? extends WebBeanDiscovery>>();
for (String className : new
DeploymentProperties(Thread.currentThread().getContextClassLoader()).getPropertyValues(WEB_BEAN_DISCOVERY_PROPERTY_NAME))
{
- Class<WebBeanDiscovery> webBeanDiscoveryClass = null;
try
{
webBeanDiscoveryClasses.add((Class<WebBeanDiscovery>)
Class.forName(className));
}
- catch (ClassNotFoundException e)
+ catch (ClassNotFoundException e)
{
log.debug("Unable to load WebBeanDiscovery provider " + className,
e);
}
- catch (NoClassDefFoundError e) {
+ catch (NoClassDefFoundError e)
+ {
log.warn("Unable to load WebBeanDiscovery provider " + className +
" due classDependencyProblem", e);
}
}
return webBeanDiscoveryClasses;
}
-
-
-
+
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/DeploymentProperties.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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 static org.jboss.webbeans.util.Strings.split;
@@ -10,52 +27,74 @@
import java.util.List;
import java.util.Properties;
-/*
+/**
* Utility class to load deployment properties
+ *
+ * @author Pete Muir
*/
public class DeploymentProperties
{
-
+ // The resource bundle used to control Web Beans RI deployment
+ public static final String RESOURCE_BUNDLE =
"META-INF/web-beans-ri.properties";
+
+ // The class to work from
private ClassLoader classLoader;
+ // An enumeration of URLs to work on
private Enumeration<URL> urlEnum;
-
+
+ /**
+ * Constructor
+ *
+ * @param classLoader The classloader to work on
+ */
public DeploymentProperties(ClassLoader classLoader)
{
this.classLoader = classLoader;
}
/**
- * The resource bundle used to control Web Beans RI deployment
- */
- public static final String RESOURCE_BUNDLE =
"META-INF/web-beans-ri.properties";
-
- /**
* Get a list of possible values for a given key.
*
* First, System properties are tried, followed by the specified resource
* bundle (first in classpath only).
*
- * Colon (:) deliminated lists are split out.
+ * Colon (:) deliminated lists are split out. (gotta love Petes choice of
+ * ASCII art for that one ;-)
*
+ * @param key The key to search for
+ * @return A list of possible values. An empty list is returned if there are
+ * no matches.
*/
public List<String> getPropertyValues(String key)
{
- List<String>values = new ArrayList<String>();
+ List<String> values = new ArrayList<String>();
addPropertiesFromSystem(key, values);
addPropertiesFromResourceBundle(key, values);
return values;
}
-
+
+ /**
+ * Adds matches from system properties
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
private void addPropertiesFromSystem(String key, List<String> values)
{
addProperty(key, System.getProperty(key), values);
}
-
+
+ /**
+ * Adds matches from detected resource bundles
+ *
+ * @param key The key to match
+ * @param values The currently found values
+ */
private void addPropertiesFromResourceBundle(String key, List<String> values)
{
try
- {
- while ( getResources().hasMoreElements() )
+ {
+ while (getResources().hasMoreElements())
{
URL url = getResources().nextElement();
Properties properties = new Properties();
@@ -74,14 +113,21 @@
}
}
}
- catch (IOException e)
+ catch (IOException e)
{
// No - op, file is optional
+ // TODO: Isn't this more of a open/read/close error? If the file wasn't
+ // there in the first place you wouldn't be in the loop?
}
}
-
- /*
- * Add the property to the set of properties only if it hasn't already been added
+
+ /**
+ * Add the property to the set of properties only if it hasn't already been
+ * added
+ *
+ * @param key The key searched for
+ * @param value The value of the property
+ * @param values The currently found values
*/
private void addProperty(String key, String value, List<String> values)
{
@@ -92,18 +138,24 @@
{
values.add(property);
}
-
+
}
}
-
+
+ /**
+ * Gets all Web Beans property files relative to the provided classloader
+ *
+ * @return An enumeration of URLs to the property files
+ * @throws IOException If the resource files could not be loaded
+ */
private Enumeration<URL> getResources() throws IOException
{
-
+
if (urlEnum == null)
{
urlEnum = classLoader.getResources(RESOURCE_BUNDLE);
}
return urlEnum;
}
-
+
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.spi;
import java.lang.reflect.Method;
@@ -3,23 +20,38 @@
import java.util.Iterator;
+/**
+ * EJB metadata from the EJB descriptor
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public interface EjbDescriptor<T>
{
/**
+ * Gets the EJB type
+ *
* @return The EJB Bean class
*/
public Class<T> getType();
/**
- * @return The JNDI name under which the EJB is registered
+ * Gets the JNDI name under which the EJB is registered
+ *
+ * @return The JNDI name
*/
public String getJndiName();
/**
- * @return The local interfaces of the EJB
+ * Gets the local interfaces of the EJB
+ *
+ * @return An iterator to the local interfaces
*/
public Iterator<Class<?>> getLocalInterfaces();
/**
- * @return The remove methods of the EJB
+ * Get the remove methods of the EJB
+ *
+ * @return An iterator the remove methods
*/
public Iterator<Method> getRemoveMethods();
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.spi;
import java.net.URL;
@@ -13,17 +30,23 @@
public interface WebBeanDiscovery
{
/**
- * @return A list of all classes in classpath archives with web-beans.xml files
+ * Gets list of all classes in classpath archives with web-beans.xml files
+ *
+ * @return An iterable over the classes
*/
public Iterable<Class<?>> discoverWebBeanClasses();
/**
- * @return A list of all web-beans.xml files in the app classpath
+ * Gets a list of all web-beans.xml files in the app classpath
+ *
+ * @return An iterable over the web-beans.xml files
*/
public Iterable<URL> discoverWebBeansXml();
/**
- * @return A Map of EJB descriptors, keyed by the EJB bean class
+ * Gets a Map of EJB descriptors, keyed by the EJB bean class
+ *
+ * @return The bean class to descriptor map
*/
public Map<Class<?>, EjbDescriptor<?>> discoverEjbs();
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -1,44 +1,121 @@
+/*
+ * 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 java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import javax.webbeans.CreationException;
import javax.webbeans.Standard;
import javax.webbeans.manager.EnterpriseBeanLookup;
import org.jboss.webbeans.util.JNDI;
+import org.jboss.webbeans.util.Strings;
+import com.google.common.collect.ForwardingMap;
+
+/**
+ * Provides lookup and metadata registration services for EJBs
+ *
+ * @author Pete Muir
+ * @see java.webbeans.manager.EnterpriseBeanLookup
+ */
@Standard
public class DefaultEnterpriseBeanLookup implements EnterpriseBeanLookup
{
- private Map<String, EjbMetaData<?>> ejbMetaDataMap = new
HashMap<String, EjbMetaData<?>>();
-
+ /**
+ * An EJB name -> metadata map
+ */
+ private class EjbMetaDataMap extends ForwardingMap<String,
EjbMetaData<?>>
+ {
+ private Map<String, EjbMetaData<?>> delegate;
+
+ public EjbMetaDataMap()
+ {
+ delegate = new ConcurrentHashMap<String, EjbMetaData<?>>();
+ }
+
+ @Override
+ protected Map<String, EjbMetaData<?>> delegate()
+ {
+ return delegate;
+ }
+
+ @Override
+ public String toString()
+ {
+ return Strings.mapToString("EjbMetaDataMap (EJB name -> metadata):
", delegate);
+ }
+ }
+
+ // A map from EJB name to EJB metadata
+ private EjbMetaDataMap ejbMetaDataMap = new EjbMetaDataMap();
+
+ /**
+ * Looks up and EJB based on the name
+ *
+ * Gets the EJB metadata and calls helper method
+ *
+ * @param ejbName The EJB name
+ * @return The EJB local home interface
+ * @see javax.webbeans.manager.EnterpriseBeanLookup#lookup(String)
+ */
public Object lookup(String ejbName)
{
- return lookup( ejbMetaDataMap.get(ejbName) );
+ return lookup(ejbMetaDataMap.get(ejbName));
}
-
- public static <T> T lookup(EjbMetaData<T> ejb)
+
+ /**
+ * Looks up an EJB
+ *
+ * First tried the EJB link JNDI name, if available, then the default JNDI
+ * name. Throws an CreationException if it isn't found.
+ *
+ * @param <T> The type of the EJB
+ * @param ejbMetaData The EJB metadata
+ * @return The EJB local interface
+ */
+ public static <T> T lookup(EjbMetaData<T> ejbMetaData)
{
- if (ejb.getEjbLinkJndiName() != null)
- {
- return JNDI.lookup(ejb.getEjbLinkJndiName(), ejb.getType());
- }
try
{
- return JNDI.lookup(ejb.getDefaultJndiName(), ejb.getType());
+ if (ejbMetaData.getEjbLinkJndiName() != null)
+ {
+ return JNDI.lookup(ejbMetaData.getEjbLinkJndiName(), ejbMetaData.getType());
+ }
+ return JNDI.lookup(ejbMetaData.getDefaultJndiName(), ejbMetaData.getType());
}
- catch (Exception e)
+ catch (Exception e)
{
throw new CreationException("could not find the EJB in JNDI", e);
}
}
-
- //TODO: this method needs to get called at startup
+
+ // TODO: this method needs to get called at startup
+ /**
+ * Creates and registers EJB metadata for a class
+ *
+ * @param clazz The EJB class
+ * @return the EJB metadata
+ */
public <T> EjbMetaData<T> registerEjbMetaData(Class<T> clazz)
{
- EjbMetaData<T> ejbMetaData = new EjbMetaData<T>(clazz);
+ EjbMetaData<T> ejbMetaData = new EjbMetaData<T>(clazz);
ejbMetaDataMap.put(ejbMetaData.getEjbName(), ejbMetaData);
return ejbMetaData;
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-11-28 11:26:26
UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EJB.java 2008-11-29 21:17:54
UTC (rev 381)
@@ -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 java.lang.annotation.Annotation;
@@ -4,29 +21,46 @@
import org.jboss.webbeans.util.Reflections;
-
+/**
+ * Utility class for EJB annotations etc
+ *
+ * @author Pete Muir
+ */
public class EJB
{
-
- public @interface Dummy {}
-
+
+ public @interface Dummy
+ {
+ }
+
+ // Annotation instances
public static final Class<? extends Annotation> STATELESS_ANNOTATION;
public static final Class<? extends Annotation> STATEFUL_ANNOTATION;
public static final Class<? extends Annotation> MESSAGE_DRIVEN_ANNOTATION;
public static final Class<? extends Annotation> SINGLETON_ANNOTATION;
public static final Class<? extends Annotation> REMOVE_ANNOTATION;
-
- static
+
+ /**
+ * Static initialization block
+ */
+ static
{
STATELESS_ANNOTATION = classForName("javax.ejb.Stateless");
STATEFUL_ANNOTATION = classForName("javax.ejb.Stateful");
MESSAGE_DRIVEN_ANNOTATION = classForName("javax.ejb.MessageDriven");
-// FIXME Faking singleton
+ // FIXME Faking singleton
SINGLETON_ANNOTATION =
classForName("org.jboss.webbeans.test.annotations.Singleton");
-// SINGLETON_ANNOTATION = classForName("javax.ejb.Singleton");
+ // SINGLETON_ANNOTATION = classForName("javax.ejb.Singleton");
REMOVE_ANNOTATION = classForName("javax.ejb.Remove");
}
-
+
+ /**
+ * Initializes an annotation class
+ *
+ * @param name The name of the annotation class
+ * @return The instance of the annotation. Returns a dummy if the class was
+ * not found
+ */
@SuppressWarnings("unchecked")
private static Class<? extends Annotation> classForName(String name)
{
@@ -39,5 +73,5 @@
return Dummy.class;
}
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-11-28
11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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 static org.jboss.webbeans.ejb.EJB.MESSAGE_DRIVEN_ANNOTATION;
@@ -20,35 +37,65 @@
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+/**
+ * EJB metadata
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
public class EjbMetaData<T>
{
-
+ // The known EJB types
public enum EjbType
{
STATELESS, STATEFUL, SINGLETON, MESSAGE_DRIVEN;
}
+ // The type of the EJB
private EjbType ejbType;
+ // The remove methods
private List<AnnotatedMethod<Object>> removeMethods = new
ArrayList<AnnotatedMethod<Object>>();
+ // The destructor methods
private List<AnnotatedMethod<Object>> destructorMethods = new
ArrayList<AnnotatedMethod<Object>>();
+ // The remove methods with no arguments
private List<AnnotatedMethod<Object>> noArgsRemoveMethods = new
ArrayList<AnnotatedMethod<Object>>();
// TODO Populate this from web.xml
+ // The EJB link jndi name
private String ejbLinkJndiName;
// TODO Initialize this based on the EJB 3.1 spec
+ // The default JNDI name
private String defaultJndiName;
// TODO Initialize the ejb name
+ // The EJB name
private String ejbName;
+ // The abstracted type
private AnnotatedClass<T> type;
+ /**
+ * Constrcutor
+ *
+ * Creates a new abstracted class and delegates to another constructor
+ *
+ * @param type The type
+ */
public EjbMetaData(Class<T> type)
{
this(new AnnotatedClassImpl<T>(type));
}
+ /**
+ * Constructor
+ *
+ * Initializes the class based on information from the abstracted class.
+ * Detects the EJB type and remove/destructor methods
+ *
+ * @param type The abstracted class
+ */
public EjbMetaData(AnnotatedClass<T> type)
{
// TODO Merge in ejb-jar.xml
@@ -89,46 +136,82 @@
}
}
+ /**
+ * Indicates if the EJB is a stateless one
+ *
+ * @return True if stateless, false otherwise
+ */
public boolean isStateless()
{
return STATELESS.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a stateful one
+ *
+ * @return True if stateful, false otherwise
+ */
public boolean isStateful()
{
return STATEFUL.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a MDB
+ *
+ * @return True if MDB, false otherwise
+ */
public boolean isMessageDriven()
{
return MESSAGE_DRIVEN.equals(ejbType);
}
+ /**
+ * Indicates if the EJB is a singleton
+ *
+ * @return True if singleton, false otherwise
+ */
public boolean isSingleton()
{
return SINGLETON.equals(ejbType);
}
+ /**
+ * Indicates if class really is of a know EJB type
+ *
+ * @return True if EJB, false otherwise
+ */
+
public boolean isEjb()
{
return ejbType != null;
}
- public List<AnnotatedMethod<Object>> getRemoveMethods()
- {
- return removeMethods;
- }
-
+ /**
+ * Gets the EJB link JNDI name
+ *
+ * @return The name
+ */
public String getEjbLinkJndiName()
{
return ejbLinkJndiName;
}
+ /**
+ * Gets the default JNDI name
+ *
+ * @return The name
+ */
public String getDefaultJndiName()
{
return defaultJndiName;
}
+ /**
+ * Gets the EJB name
+ *
+ * @return The name
+ */
public String getEjbName()
{
return ejbName;
@@ -139,11 +222,34 @@
return type.getType();
}
+ /**
+ * Gets the list of remove method abstractions
+ *
+ * @return The list of remove methods. An empty list is returned if there are
+ * none.
+ */
+ public List<AnnotatedMethod<Object>> getRemoveMethods()
+ {
+ return removeMethods;
+ }
+
+ /**
+ * Gets a list of destructor method abstractions
+ *
+ * @return The list of destructor methods. An empty list is returned if there
+ * are none.
+ */
public List<AnnotatedMethod<Object>> getDestructorMethods()
{
return destructorMethods;
}
+ /**
+ * Gets the list of remove method abstractions that take no arguments
+ *
+ * @return The list of remove methods without arguments. An empty list is
+ * returned if there are none.
+ */
public List<AnnotatedMethod<Object>> getNoArgsRemoveMethods()
{
return noArgsRemoveMethods;
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.el;
import java.beans.FeatureDescriptor;
@@ -9,6 +26,9 @@
public class WebBeansELResolver extends ELResolver
{
+ /**
+ * @see javax.el.ELResolver#getCommonPropertyType(ELContext, Object)
+ */
@Override
public Class<?> getCommonPropertyType(ELContext context, Object base)
{
@@ -16,6 +36,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getFeatureDescriptors(ELContext, Object)
+ */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base)
{
@@ -23,6 +46,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getType(ELContext, Object, Object)
+ */
@Override
public Class<?> getType(ELContext context, Object base, Object property)
{
@@ -30,6 +56,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#getValue(ELContext, Object, Object)
+ */
@Override
public Object getValue(ELContext context, Object base, Object property)
{
@@ -37,6 +66,9 @@
return null;
}
+ /**
+ * @see javax.el.ELResolver#isReadOnly(ELContext, Object, Object)
+ */
@Override
public boolean isReadOnly(ELContext context, Object base, Object property)
{
@@ -44,6 +76,9 @@
return false;
}
+ /**
+ * @see javax.el.ELResolver#setValue(ELContext, Object, Object, Object)
+ */
@Override
public void setValue(ELContext context, Object base, Object property, Object value)
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.event;
import javax.transaction.Status;
@@ -9,11 +26,13 @@
* the JTA transaction currently in effect is committed.
*
* @author David Allen
- *
+ * @see javax.transaction.Synchronization
*/
public class DeferredEventNotification<T> implements Synchronization
{
+ // The observer
private ObserverImpl<T> observer;
+ // The event object
private T event;
/**
@@ -30,6 +49,8 @@
}
/**
+ * Gets the observer
+ *
* @return the observer
*/
public final Observer<T> getObserver()
@@ -37,6 +58,15 @@
return observer;
}
+ /**
+ * Called after completion of a transaction
+ *
+ * Checks if the observer is interested in this particular transaction phase
+ * and if so, notifies the observer.
+ *
+ * @param status The status of the transaction
+ * @see javax.transaction.Status
+ */
public void afterCompletion(int status)
{
if
(observer.isInterestedInTransactionPhase(TransactionObservationPhase.AFTER_COMPLETION))
@@ -60,6 +90,12 @@
}
}
+ /**
+ * Called before completion of a transaction
+ *
+ * Checks if the observer is interested in this particular transaction phase
+ * and if so, notifies the observer.
+ */
public void beforeCompletion()
{
if
(observer.isInterestedInTransactionPhase(TransactionObservationPhase.BEFORE_COMPLETION))
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-11-28
11:26:26 UTC (rev 380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.event;
import java.lang.annotation.Annotation;
@@ -28,7 +45,7 @@
public class EventImpl<T> implements Event<T>
{
private Collection<? extends Annotation> eventBindings;
- private Class<T> eventType;
+ private Class<T> eventType;
// The current WB manager
@Current
@@ -38,8 +55,7 @@
* Used to set the event bindings for this type of event after it is
* constructed with the default constructor.
*
- * @param eventBindings
- * Annotations that are bindings for the event
+ * @param eventBindings Annotations that are bindings for the event
*/
public void setEventBindings(Annotation... eventBindings)
{
@@ -66,14 +82,13 @@
addAnnotationBindings(eventBindings, bindings);
// Invoke the container method to fire the event per 7.2
- webBeansManager
- .fireEvent(event, eventBindings.toArray(new Annotation[0]));
+ webBeansManager.fireEvent(event, eventBindings.toArray(new Annotation[0]));
}
public void observe(Observer<T> observer, Annotation... bindings)
{
// Register the observer with the web beans manager
-
+
Set<Annotation> eventBindings = new HashSet<Annotation>();
eventBindings.addAll(this.getBindingTypes());
addAnnotationBindings(eventBindings, bindings);
@@ -85,35 +100,32 @@
* already exists in the set, a {@link DuplicateBindingTypeException} is
* thrown.
*
- * @param bindingsSet
- * The set of annotation binding objects
- * @param bindings
- * An array of annotation bindings to add to the set
- * @throws DuplicateBindingTypeException
- * if any of bindings are duplicates
- * @throws IllegalArgumentException
- * if any annotation is not a binding type
+ * @param bindingsSet The set of annotation binding objects
+ * @param bindings An array of annotation bindings to add to the set
+ * @throws DuplicateBindingTypeException if any of bindings are duplicates
+ * @throws IllegalArgumentException if any annotation is not a binding type
*/
- private void addAnnotationBindings(Set<Annotation> bindingsSet,
- Annotation[] bindings)
+ private void addAnnotationBindings(Set<Annotation> bindingsSet, Annotation[]
bindings)
{
if (bindings != null)
{
Set<Class<? extends Annotation>> bindingTypes = new
HashSet<Class<? extends Annotation>>();
- // Add the bindings types that are already in the set being added to. This
will
- // provide detection of duplicates across construction and later invocations.
+ // Add the bindings types that are already in the set being added to.
+ // This will
+ // provide detection of duplicates across construction and later
+ // invocations.
for (Annotation annotation : bindingsSet)
{
bindingTypes.add(annotation.annotationType());
}
-
- // Now go through the new annotations being added to make sure these are
binding
+
+ // Now go through the new annotations being added to make sure these
+ // are binding
// types and are not duplicates
for (Annotation annotation : bindings)
{
// Check that the binding type is indeed a binding type
- Annotation[] bindingAnnotations = annotation.annotationType()
- .getAnnotations();
+ Annotation[] bindingAnnotations =
annotation.annotationType().getAnnotations();
boolean isBindingType = false;
for (Annotation bindingAnnotation : bindingAnnotations)
{
@@ -123,15 +135,15 @@
}
}
if (!isBindingType)
- throw new IllegalArgumentException("Annotation " + annotation
- + " is not a binding type");
+ throw new IllegalArgumentException("Annotation " + annotation +
" is not a binding type");
// Check that no binding type was specified more than once in the
// annotations
if (bindingTypes.contains(annotation.annotationType()))
{
throw new DuplicateBindingTypeException();
- } else
+ }
+ else
{
bindingTypes.add(annotation.annotationType());
}
@@ -152,7 +164,7 @@
{
this.webBeansManager = manager;
}
-
+
// TODO Use constructor injection
public void setEventType(Class<T> eventType)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventObserver.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.event;
import java.lang.annotation.Annotation;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -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.event;
import java.lang.annotation.Annotation;
@@ -123,7 +140,7 @@
* Uses the container to retrieve the most specialized instance of this
* observer.
*
- * @param conditional
+ * @param conditional T
*
* @return the most specialized instance
*/
@@ -133,16 +150,32 @@
return manager.getInstanceByType(eventBean.getType(),
eventBean.getBindingTypes().toArray(new Annotation[0]));
}
+ /**
+ * Indicates if the observer is transactional
+ *
+ * @return True if transactional, false otherwise
+ */
public boolean isTransactional()
{
return !TransactionObservationPhase.NONE.equals(transactionObservationPhase);
}
+ /**
+ * Indicates if the observer is conditional
+ *
+ * @return True if conditional, false otherwise
+ */
public boolean isConditional()
{
return conditional;
}
+ /**
+ * Checks if the observer is interested in a particular transactional phase
+ *
+ * @param currentPhase The phase to check
+ * @return True if interested, false otherwise
+ */
public boolean isInterestedInTransactionPhase(TransactionObservationPhase
currentPhase)
{
return transactionObservationPhase.equals(currentPhase);
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java 2008-11-28
11:26:26 UTC (rev 380)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/TransactionObservationPhase.java 2008-11-29
21:17:54 UTC (rev 381)
@@ -1,5 +1,28 @@
+/*
+ * 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.event;
+/**
+ * The known transactional phases a transactional event observer can be
+ * interested in
+ *
+ * @author Nicklas Karlsson
+ */
public enum TransactionObservationPhase
{
NONE, BEFORE_COMPLETION, AFTER_COMPLETION, AFTER_FAILURE, AFTER_SUCCESS