Weld SVN: r5182 - in core/trunk/impl/src/main: java/org/jboss/weld/xml and 1 other directories.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2009-12-01 08:24:19 -0500 (Tue, 01 Dec 2009)
New Revision: 5182
Added:
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/XmlMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/xml/WeldXmlException.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/xml_en.properties
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
Log:
Exception conversion for XML parser to support localization
Added: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/XmlMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/XmlMessage.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/XmlMessage.java 2009-12-01 13:24:19 UTC (rev 5182)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld.logging.messages;
+
+import org.jboss.weld.logging.MessageId;
+
+import ch.qos.cal10n.BaseName;
+import ch.qos.cal10n.Locale;
+import ch.qos.cal10n.LocaleData;
+
+@BaseName("org.jboss.weld.messages.xml")
+@LocaleData({
+ @Locale("en")
+})
+/**
+ * Error messages relating to XML parser
+ *
+ * Message ids: 001200 - 001299
+ */
+public enum XmlMessage
+{
+ @MessageId("001200") CONFIGURATION_ERROR,
+ @MessageId("001201") LOAD_ERROR,
+ @MessageId("001202") PARSING_ERROR,
+ @MessageId("001203") MULTIPLE_ALTERNATIVES,
+ @MessageId("001204") MULTIPLE_DECORATORS,
+ @MessageId("001205") MULTIPLE_INTERCEPTORS,
+ @MessageId("001206") CANNOT_LOAD_CLASS;
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/XmlMessage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-12-01 10:00:30 UTC (rev 5181)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-12-01 13:24:19 UTC (rev 5182)
@@ -16,19 +16,24 @@
*/
package org.jboss.weld.xml;
+import static org.jboss.weld.logging.messages.XmlMessage.CANNOT_LOAD_CLASS;
+import static org.jboss.weld.logging.messages.XmlMessage.CONFIGURATION_ERROR;
+import static org.jboss.weld.logging.messages.XmlMessage.LOAD_ERROR;
+import static org.jboss.weld.logging.messages.XmlMessage.MULTIPLE_ALTERNATIVES;
+import static org.jboss.weld.logging.messages.XmlMessage.MULTIPLE_DECORATORS;
+import static org.jboss.weld.logging.messages.XmlMessage.MULTIPLE_INTERCEPTORS;
+import static org.jboss.weld.logging.messages.XmlMessage.PARSING_ERROR;
+
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import javax.enterprise.inject.InjectionException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.interceptor.Interceptor;
import org.jboss.weld.DeploymentException;
import org.jboss.weld.resources.spi.ResourceLoader;
@@ -122,7 +127,7 @@
}
catch (ParserConfigurationException e)
{
- throw new InjectionException("Error configuring XML parser", e);
+ throw new WeldXmlException(CONFIGURATION_ERROR, e);
}
List<XmlElement> policiesElements = new ArrayList<XmlElement>();
List<XmlElement> decoratorsElements = new ArrayList<XmlElement>();
@@ -138,7 +143,7 @@
}
catch (IOException e)
{
- throw new InjectionException("Error loading beans.xml " + url.toString(), e);
+ throw new WeldXmlException(LOAD_ERROR, e, url.toString());
}
if (fileHasContents)
{
@@ -150,11 +155,11 @@
}
catch (SAXException e)
{
- throw new DeploymentException("Error parsing beans.xml " + url.toString(), e);
+ throw new DeploymentException(PARSING_ERROR, e, url.toString());
}
catch (IOException e)
{
- throw new DeploymentException("Error loading beans.xml " + url.toString(), e);
+ throw new DeploymentException(LOAD_ERROR, e, url.toString());
}
Element beans = document.getDocumentElement();
for (Node child : new NodeListIterable(beans.getChildNodes()))
@@ -178,7 +183,7 @@
if (policiesElements.size() > 1)
{
- throw new DeploymentException("<alternatives> can only be specified once, but it is specified muliple times " + policiesElements);
+ throw new DeploymentException(MULTIPLE_ALTERNATIVES, policiesElements);
}
else if (policiesElements.size() == 1)
{
@@ -189,7 +194,7 @@
if (decoratorsElements.size() > 1)
{
- throw new DeploymentException("<decorator> can only be specified once, but it is specified muliple times " + decoratorsElements);
+ throw new DeploymentException(MULTIPLE_DECORATORS, decoratorsElements);
}
else if (decoratorsElements.size() == 1)
{
@@ -199,7 +204,7 @@
if (interceptorsElements.size() > 1)
{
- throw new DeploymentException("<interceptor> can only be specified once, but it is specified muliple times " + interceptorsElements);
+ throw new DeploymentException(MULTIPLE_INTERCEPTORS, interceptorsElements);
}
else if (interceptorsElements.size() == 1)
{
@@ -230,7 +235,7 @@
}
catch (ResourceLoadingException e)
{
- throw new DeploymentException("Cannot load class " + className + " defined in " + element.getFile().toString());
+ throw new DeploymentException(CANNOT_LOAD_CLASS, className, element.getFile());
}
}
}
@@ -263,7 +268,7 @@
}
catch (ResourceLoadingException e)
{
- throw new DeploymentException("Cannot load class " + className + " defined in " + element.getFile().toString());
+ throw new DeploymentException(CANNOT_LOAD_CLASS, className, element.getFile());
}
}
}
@@ -287,7 +292,7 @@
}
catch (ResourceLoadingException e)
{
- throw new DeploymentException("Cannot load class " + className + " defined in " + element.getFile().toString());
+ throw new DeploymentException(CANNOT_LOAD_CLASS, className, element.getFile());
}
}
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/xml/WeldXmlException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/WeldXmlException.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/WeldXmlException.java 2009-12-01 13:24:19 UTC (rev 5182)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld.xml;
+
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+
+import javax.enterprise.inject.InjectionException;
+
+import ch.qos.cal10n.IMessageConveyor;
+
+/**
+ * Used for exceptions from the Weld XML parser and provides localization
+ * support.
+ *
+ * @author David Allen
+ *
+ */
+public class WeldXmlException extends InjectionException
+{
+
+ private static final long serialVersionUID = -6716110761385845182L;
+
+ // Exception messages
+ private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
+
+ public WeldXmlException(Throwable throwable)
+ {
+ super(throwable.getLocalizedMessage(), throwable);
+ }
+
+ public <E extends Enum<?>> WeldXmlException(E key, Object... args)
+ {
+ super(messageConveyer.getMessage(key, args));
+ }
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/xml/WeldXmlException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/trunk/impl/src/main/resources/org/jboss/weld/messages/xml_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/xml_en.properties (rev 0)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/xml_en.properties 2009-12-01 13:24:19 UTC (rev 5182)
@@ -0,0 +1,6 @@
+CONFIGURATION_ERROR=Error configuring XML parser
+LOAD_ERROR=Error loading {0}
+PARSING_ERROR=Error parsing {0}
+MULTIPLE_ALTERNATIVES=<alternatives> can only be specified once, but appears multiple times\: {0}
+MULTIPLE_DECORATORS=<decorator> can only be specified once, but is specified multiple times\: {0}
+MULTIPLE_INTERCEPTORS=<interceptor> can only be specified once, but it is specified multiple times\: {0}
Property changes on: core/trunk/impl/src/main/resources/org/jboss/weld/messages/xml_en.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 12 months
Weld SVN: r5181 - in java-se/trunk/src: main/java/org/jboss/weld/environment/se/beans and 1 other directories.
by weld-commits@lists.jboss.org
Author: peteroyle
Date: 2009-12-01 05:00:30 -0500 (Tue, 01 Dec 2009)
New Revision: 5181
Added:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/StartMain.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java
Log:
Separated out initialize() (Weld) from instance() and event() (WeldContainer)
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/StartMain.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/StartMain.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/StartMain.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -16,13 +16,12 @@
*/
package org.jboss.weld.environment.se;
-import javax.enterprise.inject.spi.BeanManager;
import org.jboss.weld.environment.se.events.ContainerInitialized;
/**
* This is the main class that should always be called from the command line for
- * a Weld SE app. Something like: <code>
+ * a WeldContainer SE app. Something like: <code>
* java -jar MyApp.jar org.jboss.weld.environment.se.StarMain arguments
* </code>
*
@@ -39,12 +38,11 @@
PARAMETERS = commandLineArgs;
}
- public BeanManager go()
+ public WeldContainer go()
{
- Weld weld = new Weld().initialize();
-
- weld.getBeanManager().fireEvent(new ContainerInitialized());
- return weld.getBeanManager();
+ WeldContainer weld = new Weld().initialize();
+ weld.event().select(ContainerInitialized.class).fire(new ContainerInitialized());
+ return weld;
}
/**
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -16,9 +16,6 @@
*/
package org.jboss.weld.environment.se;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.spi.BeanManager;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environments;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
@@ -31,13 +28,13 @@
import org.jboss.weld.manager.api.WeldManager;
/**
- * An alternative means of booting Weld form an arbitrary main method within an
+ * An alternative means of booting WeldContainer form an arbitrary main method within an
* SE application, <em>without</em> using the built-in ContainerInitialized event.
- * Typical usage of the API looks like this:
+ * Typical usage of this API looks like this:
* <code>
- * Weld weld = new Weld().initialize();
+ * WeldContainer weld = new Weld().initialize();
* weld.instance().select(Foo.class).get();
- * weld.event().select(Bar.class).fire( new Bar() );
+ * weld.event().select(Bar.class).fire(new Bar());
* weld.shutdown();
* </code>
*
@@ -50,7 +47,6 @@
private final Bootstrap bootstrap;
private final BeanStore applicationBeanStore;
private WeldManager manager;
- private InstanceManager instanceManager;
public Weld()
{
@@ -64,7 +60,11 @@
this.applicationBeanStore = new ConcurrentHashMapBeanStore();
}
- public Weld initialize()
+ /**
+ * Boots Weld and creates and returns a WeldContainer instance, through which
+ * beans and events can be accesed.
+ */
+ public WeldContainer initialize()
{
SEWeldDeployment deployment = new SEWeldDeployment()
@@ -79,30 +79,17 @@
bootstrap.validateBeans();
bootstrap.endInitialization();
- instanceManager = WeldManagerUtils.getInstanceByType(manager, InstanceManager.class);
+ InstanceManager instanceManager = WeldManagerUtils.getInstanceByType(manager, InstanceManager.class);
- return this;
- }
+ return new WeldContainer(instanceManager, manager);
- public Instance<Object> instance()
- {
- return instanceManager.getInstances();
}
- public Event<Object> event()
- {
- return instanceManager.getEvents();
- }
-
- public BeanManager getBeanManager()
- {
- return manager;
- }
-
/**
* Convenience method for shutting down the container.
*/
- public void shutdown() {
+ public void shutdown()
+ {
WeldManagerUtils.getInstanceByType(manager, ShutdownManager.class).shutdown();
}
}
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java (from rev 5175, java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -0,0 +1,74 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.weld.environment.se;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import org.jboss.weld.environment.se.beans.InstanceManager;
+
+/**
+ * Provides convenient access to beans and events, particularly helpful when
+ * bootstrapping an application in Java SE.
+ * <p>
+ * An instance of this class can be obtained using the Weld class by calling:
+ * <code>
+ * WeldContainer weld = new Weld().initialize();
+ * </code>
+ * @see Weld
+ *
+ * @author Peter Royle
+ */
+public class WeldContainer
+{
+
+ private final InstanceManager instanceManager;
+ private final BeanManager beanManager;
+
+ protected WeldContainer(InstanceManager instanceManager, BeanManager beanManager)
+ {
+ this.instanceManager = instanceManager;
+ this.beanManager = beanManager;
+ }
+
+ /**
+ * Provides access to all beans within the application. For example:
+ * <code>
+ * Foo foo = weld.instance().select(Foo.class).get();
+ * </code>
+ */
+ public Instance<Object> instance()
+ {
+ return instanceManager.getInstances();
+ }
+
+ /**
+ * Provides access to all events within the application. For example:
+ * <code>
+ * weld.event().select(Bar.class).fire(new Bar());
+ * </code>
+ */
+ public Event<Object> event()
+ {
+ return instanceManager.getEvents();
+ }
+
+ public BeanManager getBeanManager()
+ {
+ return beanManager;
+ }
+}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -19,14 +19,14 @@
import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
-import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
/**
* A managed bean which holds all of the injected instances of managed beans and
- * events. It is primarily used as a delegate for the Weld class's instance()
+ * events. It is primarily used as a delegate for the WeldContainer class's instance()
* and event() methods.
*
- * @see Weld
+ * @see WeldContainer
* @author Peter Royle
*/
public class InstanceManager
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -19,7 +19,8 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;
-import org.jboss.weld.environment.se.StartMain;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.decorators.CarDoor;
import org.jboss.weld.environment.se.test.decorators.Door;
@@ -36,19 +37,16 @@
public class DecoratorsTest
{
- public static String[] ARGS_EMPTY = new String[]
- {
- };
-
/**
* Test that decorators work as expected in SE.
*/
@Test
public void testDecorators()
{
- String[] args = ARGS_EMPTY;
- BeanManager manager = new StartMain(args).go();
+ WeldContainer weld = new Weld().initialize();
+ BeanManager manager = weld.getBeanManager();
+
CarDoor carDoor = WeldManagerUtils.getInstanceByType(manager, CarDoor.class);
Assert.assertNotNull(carDoor);
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -19,7 +19,8 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;
-import org.jboss.weld.environment.se.StartMain;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.InterceptorTestBean;
import org.jboss.weld.environment.se.test.interceptors.AggregatingInterceptor;
@@ -35,18 +36,14 @@
public class InterceptorsTest
{
- public static String[] ARGS_EMPTY = new String[]
- {
- };
-
/**
* Test that interceptors work as expected in SE.
*/
@Test
public void testInterceptors()
{
- String[] args = ARGS_EMPTY;
- BeanManager manager = new StartMain(args).go();
+ WeldContainer weld = new Weld().initialize();
+ BeanManager manager = weld.getBeanManager();
InterceptorTestBean intTestBean = WeldManagerUtils.getInstanceByType(manager, InterceptorTestBean.class);
Assert.assertNotNull(intTestBean);
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -20,6 +20,7 @@
import javax.enterprise.util.AnnotationLiteral;
import org.jboss.weld.environment.se.StartMain;
+import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.CustomEvent;
import org.jboss.weld.environment.se.test.beans.InitObserverTestBean;
@@ -49,8 +50,10 @@
public void testMain()
{
String[] args = ARGS;
- BeanManager manager = new StartMain(args).go();
+ WeldContainer weld = new StartMain(args).go();
+ BeanManager manager = weld.getBeanManager();
+
MainTestBean mainTestBean = WeldManagerUtils.getInstanceByType(manager, MainTestBean.class);
Assert.assertNotNull(mainTestBean);
@@ -74,7 +77,8 @@
@Test
public void testMainEmptyArgs()
{
- BeanManager manager = new StartMain(ARGS_EMPTY).go();
+ WeldContainer weld = new StartMain(ARGS_EMPTY).go();
+ BeanManager manager = weld.getBeanManager();
MainTestBean mainTestBean = WeldManagerUtils.getInstanceByType(manager, MainTestBean.class);
Assert.assertNotNull(mainTestBean);
@@ -92,7 +96,8 @@
InitObserverTestBean.reset();
ObserverTestBean.reset();
- BeanManager manager = new StartMain(ARGS_EMPTY).go();
+ WeldContainer weld = new StartMain(ARGS_EMPTY).go();
+ BeanManager manager = weld.getBeanManager();
manager.fireEvent(new CustomEvent());
Assert.assertTrue(ObserverTestBean.isBuiltInObserved());
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java 2009-11-30 20:26:04 UTC (rev 5180)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java 2009-12-01 10:00:30 UTC (rev 5181)
@@ -20,6 +20,7 @@
import javax.enterprise.util.AnnotationLiteral;
import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.CustomEvent;
import org.jboss.weld.environment.se.test.beans.InitObserverTestBean;
@@ -37,13 +38,13 @@
{
/**
- * Test the alternate API for boting Weld from an SE app.
+ * Test the alternate API for boting WeldContainer from an SE app.
*/
@Test
public void testInitialize()
{
- Weld weld = new Weld().initialize();
+ WeldContainer weld = new Weld().initialize();
MainTestBean mainTestBean = weld.instance().select(MainTestBean.class).get();
Assert.assertNotNull(mainTestBean);
@@ -56,7 +57,7 @@
}
/**
- * Test the firing of observers using the alternate API for boting Weld from an SE app.
+ * Test the firing of observers using the alternate API for boting WeldContainer from an SE app.
*/
@Test
public void testObservers()
@@ -64,7 +65,8 @@
InitObserverTestBean.reset();
ObserverTestBean.reset();
- Weld weld = new Weld().initialize();
+
+ WeldContainer weld = new Weld().initialize();
weld.event().select(CustomEvent.class).fire(new CustomEvent());
Assert.assertTrue(ObserverTestBean.isBuiltInObserved());
14 years, 12 months