Skip to content

Commit

Permalink
Part II
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@737 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Dec 26, 2008
1 parent f8959ef commit 8a28219
Show file tree
Hide file tree
Showing 38 changed files with 276 additions and 240 deletions.
Expand Up @@ -51,7 +51,7 @@

import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
import org.jboss.webbeans.contexts.ContextMap;
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.introspector.AnnotatedItem;
Expand Down
Expand Up @@ -38,7 +38,7 @@
import javax.webbeans.manager.Bean;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bindings.CurrentBinding;
import org.jboss.webbeans.binding.CurrentBinding;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem.AnnotationMap;
import org.jboss.webbeans.log.LogProvider;
Expand Down
Expand Up @@ -37,7 +37,7 @@

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
Expand Down
Expand Up @@ -24,7 +24,7 @@
import javax.webbeans.Event;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.event.EventImpl;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
Expand Down
Expand Up @@ -22,7 +22,7 @@

import org.jboss.webbeans.InstanceImpl;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedItem;

/**
Expand Down
Expand Up @@ -20,7 +20,7 @@
import java.lang.reflect.Field;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.jlr.AnnotatedFieldImpl;
import org.jboss.webbeans.util.Names;
Expand Down
Expand Up @@ -27,7 +27,7 @@
import javax.webbeans.Observes;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
Expand Down
Expand Up @@ -28,7 +28,7 @@
import javax.webbeans.manager.Manager;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
Expand Down
@@ -0,0 +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.binding;

import javax.webbeans.AnnotationLiteral;
import javax.webbeans.Current;

/**
* Annotation literal for @Current
*
* @author Pete Muir
*/
public class CurrentBinding extends AnnotationLiteral<Current> implements Current {}
@@ -0,0 +1,9 @@
package org.jboss.webbeans.binding;

import javax.webbeans.AnnotationLiteral;
import javax.webbeans.manager.Initialized;

public class InitializedBinding extends AnnotationLiteral<Initialized> implements Initialized
{

}
Expand Up @@ -24,7 +24,7 @@

import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.resources.DefaultNaming;
import org.jboss.webbeans.resource.DefaultNaming;
import org.jboss.webbeans.resources.spi.Naming;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.ServletBootstrap;
Expand Down Expand Up @@ -73,7 +73,7 @@ protected static <T> Constructor<? extends T> getClassConstructor(DeploymentProp
* Creates an instance of the type
*
* @param constructor The constructor to use
* @param parameters The parameters to pass to the contstructor
* @param parameters The parameters to pass to the constructor
* @return An instance of the type
*/
protected static <T> T newInstance(Constructor<T> constructor, Object... parameters)
Expand Down
Expand Up @@ -50,7 +50,7 @@
import org.jboss.webbeans.bean.ProducerFieldBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.bindings.InitializedBinding;
import org.jboss.webbeans.binding.InitializedBinding;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.event.ObserverImpl;
Expand All @@ -73,8 +73,7 @@
* @author Pete Muir
*/
public abstract class WebBeansBootstrap
{

{
// The log provider
private static LogProvider log = Logging.getLogProvider(WebBeansBootstrap.class);

Expand Down
Expand Up @@ -46,7 +46,12 @@ public void postConstruct(InvocationContext invocationContext)
enterpriseBean.postConstruct(invocationContext.getTarget());
}
}


/**
* Gets the underlying target and calls the pre-destroy method
*
* @param invocationContext The invocation context
*/
@PreDestroy
public void preDestroy(InvocationContext invocationContext)
{
Expand All @@ -56,7 +61,13 @@ public void preDestroy(InvocationContext invocationContext)
enterpriseBean.preDestroy(invocationContext.getTarget());
}
}


/**
* Gets a bean based on the target in the invocation context
*
* @param invocationContext The invocation context
* @return The found bean or null if the bean was not an enterprise bean
*/
@SuppressWarnings("unchecked")
private static EnterpriseBean<Object> getBean(InvocationContext invocationContext)
{
Expand All @@ -71,5 +82,5 @@ private static EnterpriseBean<Object> getBean(InvocationContext invocationContex
return null;
}
}

}
Expand Up @@ -24,7 +24,7 @@
import javax.el.ELResolver;

import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;

public class WebBeansELResolver extends ELResolver
{
Expand Down
Expand Up @@ -28,7 +28,7 @@

import javax.webbeans.Observer;

import org.jboss.webbeans.contexts.DependentContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;

Expand Down
@@ -0,0 +1,70 @@
/*
* 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.exception;

import javax.webbeans.DefinitionException;

/**
* Exception for incorrect scope usage
*
* @author Pete Muir
*/
public class NotAScopeException extends DefinitionException
{
private static final long serialVersionUID = 1L;

/**
* Constructor
*/
public NotAScopeException()
{
super();
}

/**
* Constructor
*
* @param message The exception message
* @param throwable The root exception
*/
public NotAScopeException(String message, Throwable throwable)
{
super(message, throwable);
}

/**
* Constructor
*
* @param message The exception message
*/
public NotAScopeException(String message)
{
super(message);
}

/**
* Constructor
*
* @param throwable The root exception
*/
public NotAScopeException(Throwable throwable)
{
super(throwable);
}

}
Expand Up @@ -32,7 +32,7 @@
import javax.webbeans.BindingType;
import javax.webbeans.manager.Manager;

import org.jboss.webbeans.bindings.CurrentBinding;
import org.jboss.webbeans.binding.CurrentBinding;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.util.Reflections;
Expand Down
@@ -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.resource;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.webbeans.ExecutionException;

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
{
this.initialContext = new InitialContext();
}
catch (NamingException 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
{
initialContext.bind(key, value);
}
catch (NamingException e)
{
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;
try
{
instance = initialContext.lookup(name);
}
catch (NamingException e)
{
throw new ExecutionException("Cannot lookup " + name, e);
}
try
{
return (T) instance;
}
catch (ClassCastException e)
{
throw new ExecutionException(instance + " not of expected type " + expectedType, e);
}
}

}

0 comments on commit 8a28219

Please sign in to comment.