/*
 * 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.test.tck;

import java.lang.reflect.Method;
import java.util.List;

import javax.inject.manager.Bean;


import org.apache.webbeans.component.AbstractComponent;
import org.apache.webbeans.component.ComponentImpl;
import org.apache.webbeans.component.WebBeansType;
import org.apache.webbeans.config.SimpleWebBeansConfigurator;
import org.apache.webbeans.decorator.DecoratorUtil;
import org.apache.webbeans.test.mock.MockManager;
import org.jboss.jsr299.tck.spi.Beans;

public class BeansImpl implements Beans
{

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    public <T> Bean<T> createProducerMethodBean(Method method, Bean<?> declaringBean)
    {
        //X TODO plz review! If the declaringBean has been already parsed, then the producer must be also.
        MockManager manager = MockManager.getInstance();
        List<AbstractComponent<?>> components = manager.getComponents();
        
        for (AbstractComponent<?> component : components)
        {
            if (component.getClass().equals(method.getReturnType())) 
            {
                //X TODO plz review the cast!
                return (Bean<T>) component;
            }
        }
        
        return null;
    }

    /** {@inheritDoc} */
    public <T> Bean<T> createSimpleBean(Class<T> clazz)
    {
        ComponentImpl<T> bean = null;

        SimpleWebBeansConfigurator.checkSimpleWebBeanCondition(clazz);
        bean = SimpleWebBeansConfigurator.define(clazz, WebBeansType.SIMPLE);

        if (bean != null)
        {
            DecoratorUtil.checkSimpleWebBeanDecoratorConditions(bean);
            // DefinitionUtil.defineSimpleWebBeanInterceptorStack(bean);

            MockManager manager = MockManager.getInstance();
            manager.getComponents().add((AbstractComponent<?>) bean);
            manager.addBean(bean);
        }

        return bean;
    }

    public boolean isEnterpriseBean( Class<?> clazz ) {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean isEntityBean( Class<?> clazz ) {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean isProxy( Object instance ) {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean isStatefulBean( Class<?> clazz ) {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean isStatelessBean( Class<?> clazz ) {
        // TODO Auto-generated method stub
        return false;
    }

}

@@ -1185,16 +1185,56 @@
 orUtil;%0A
+import org.apache.webbeans.ejb.EJBUtil;%0A
 import o
@@ -2789,63 +2789,89 @@
     
-// TODO Auto-generated method stub%0A        return false
+return EJBUtil.isEJBMessageDrivenClass(clazz) %7C%7C EJBUtil.isEJBSessionClass(clazz)
 ;%0A  
@@ -2939,63 +2939,45 @@
     
-// TODO Auto-generated method stub%0A        return false
+return EJBUtil.isEJBEntityBean(clazz)
 ;%0A  
@@ -3041,63 +3041,59 @@
     
-// TODO Auto-generated method stub%0A        return false
+return instance.getClass().getName().contains(%22$$%22)
 ;%0A  
@@ -3163,63 +3163,55 @@
     
-// TODO Auto-generated method stub%0A        return false
+return EJBUtil.isEJBSessionStatefulClass(clazz)
 ;%0A  
@@ -3282,63 +3282,51 @@
     
-// TODO Auto-generated method stub%0A        return false
+return EJBUtil.isEJBSessionStateless(clazz)
 ;%0A  

adding some unimplemented methods.