Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated out initialize() (Weld) from instance() and event() (WeldCo…
…ntainer)
- Loading branch information
Showing
8 changed files
with
118 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/org/jboss/weld/environment/se/WeldContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters