Skip to content

Commit

Permalink
Bug fix with component views
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Mar 15, 2011
1 parent d586f7d commit 7a7ba43
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,42 @@
*
* @author Stuart Douglas
*/
public class SessionObjectReferenceImpl implements SessionObjectReference{
public class SessionObjectReferenceImpl implements SessionObjectReference {

private final EjbDescriptorImpl<?> descriptor;
private final ServiceRegistry serviceRegistry;
private volatile Serializable sessionId;
private volatile boolean removed = false;
private volatile Component component;
private volatile ComponentView view;

public SessionObjectReferenceImpl(EjbDescriptorImpl<?> descriptor, ServiceRegistry serviceRegistry) {
public SessionObjectReferenceImpl(EjbDescriptorImpl<?> descriptor, ServiceRegistry serviceRegistry) {
this.descriptor = descriptor;
this.serviceRegistry = serviceRegistry;
}


@Override
public <S> S getBusinessObject(Class<S> businessInterfaceType) {
if(component == null) {
if (component == null) {
synchronized (this) {
if(component == null) {
if (component == null) {
final ServiceName createServiceName = descriptor.getCreateServiceName();
final ServiceController<?> controller = serviceRegistry.getRequiredService(createServiceName);
component = (Component) controller.getValue();
final ServiceName viewServiceName = component.getViewServices().get(businessInterfaceType);
if(viewServiceName == null) {
throw new RuntimeException("Could not find view for " + businessInterfaceType);
}
final ServiceController<?> viewController = serviceRegistry.getRequiredService(viewServiceName);
view = (ComponentView) viewController.getValue();
}
}
}
if(descriptor.isStateful()) {
StatefulSessionComponent sfsb = (StatefulSessionComponent)component;
if(sessionId == null ) {
final ServiceName viewServiceName = component.getViewServices().get(businessInterfaceType);
if (viewServiceName == null) {
throw new RuntimeException("Could not find view for " + businessInterfaceType);
}
final ServiceController<?> viewController = serviceRegistry.getRequiredService(viewServiceName);
ComponentView view = (ComponentView) viewController.getValue();
if (descriptor.isStateful()) {
StatefulSessionComponent sfsb = (StatefulSessionComponent) component;
if (sessionId == null) {
synchronized (this) {
if(sessionId == null) {
if (sessionId == null) {
sessionId = sfsb.createSession();
}
}
Expand All @@ -84,7 +83,7 @@ public <S> S getBusinessObject(Class<S> businessInterfaceType) {

@Override
public void remove() {
if(descriptor.isStateful()) {
if (descriptor.isStateful()) {
//TODO: destroy the EJB's
}
removed = true;
Expand Down

0 comments on commit 7a7ba43

Please sign in to comment.