
org.apache.webbeans.el10.EL10Resolver Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.apache.webbeans.el10;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import java.util.Set;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.el.ELContextStore;
public class EL10Resolver extends ELResolver
{
private WebBeansContext webBeansContext;
public EL10Resolver()
{
webBeansContext = WebBeansContext.getInstance();
}
@Override
public Class> getCommonPropertyType(ELContext arg0, Object arg1)
{
return null;
}
@Override
public Iterator getFeatureDescriptors(ELContext arg0, Object arg1)
{
return null;
}
@Override
public Class> getType(ELContext arg0, Object arg1, Object arg2) throws NullPointerException, PropertyNotFoundException, ELException
{
return null;
}
@Override
@SuppressWarnings({"unchecked","deprecation"})
public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
{
// Check if the OWB actually got used in this application
if (!webBeansContext.getBeanManagerImpl().isInUse())
{
return null;
}
//Bean instance
Object contextualInstance = null;
if (obj == null)
{
//Name of the bean
String name = (String) property;
//Local store, create if not exist
ELContextStore elContextStore = ELContextStore.getInstance(true);
contextualInstance = elContextStore.findBeanByName(name);
if(contextualInstance != null)
{
context.setPropertyResolved(true);
return contextualInstance;
}
//Manager instance
BeanManagerImpl manager = elContextStore.getBeanManager();
//Get beans
Set> beans = manager.getBeans(name);
//Found?
if(beans != null && !beans.isEmpty())
{
//Managed bean
Bean
© 2015 - 2025 Weber Informatics LLC | Privacy Policy