Package org.apache.openejb

Examples of org.apache.openejb.InterfaceType


                return true;
            }

            String ejbName = deploymentInfo.getEjbName();

            InterfaceType type = deploymentInfo.getInterfaceType(method.getDeclaringClass());

            String name = (type == null) ? null : type.getSpecName();

            Permission permission = new EJBMethodPermission(ejbName, name, method);

            AccessControlContext accessContext = ContextManager.getCurrentContext();
View Full Code Here


    }

    public Object createProxy(Object primaryKey, Class mainInterface) {
        try {

            final InterfaceType objectInterfaceType = this.interfaceType.getCounterpart();
            final BeanType type = getBeanContext().getComponentType();

            final EjbObjectProxyHandler handler = newEjbObjectHandler(getBeanContext(), primaryKey, objectInterfaceType, getInterfaces(), mainInterface);

            // TODO Is it correct for ManagedBean injection via managed bean class?
View Full Code Here

        this.interfaceType = interfaceType;
        this.primaryKey = pk;
        this.setBeanContext(beanContext);

        if (interfaces == null || interfaces.size() == 0) {
            InterfaceType objectInterfaceType = (interfaceType.isHome()) ? interfaceType.getCounterpart() : interfaceType;
            interfaces = new ArrayList<Class>(beanContext.getInterfaces(objectInterfaceType));
        }
       
        if (mainInterface == null && interfaces.size() == 1) {
            mainInterface = interfaces.get(0);
View Full Code Here

        if (interfce == null) throw new IllegalStateException("Interface argument cannot me null.");

        final ThreadContext threadContext = ThreadContext.getThreadContext();
        final BeanContext di = threadContext.getBeanContext();

        final InterfaceType interfaceType = di.getInterfaceType(interfce);
        final BeanType type = di.getComponentType();

        if (interfaceType == null){
            throw new IllegalStateException("Component has no such interface: " + interfce.getName());
        }

        if (!interfaceType.isBusiness()) {
            throw new IllegalStateException("Interface is not a business interface for this bean: " + interfce.getName());
        }

        try {
            EjbObjectProxyHandler handler;
View Full Code Here

    public Class getInvokedBusinessInterface() {
        check(Call.getInvokedBusinessInterface);
        ThreadContext threadContext = ThreadContext.getThreadContext();
        Class invokedInterface = threadContext.getInvokedInterface();
        InterfaceType type = threadContext.getBeanContext().getInterfaceType(invokedInterface);
        if (!type.isBusiness()) throw new IllegalStateException("The EJB spec requires us to cripple the use of this method for anything but business interface proxy.  But FYI, your invoked interface is: "+invokedInterface.getName());

        if (invokedInterface == null){
            throw new IllegalStateException("Business interface not set into ThreadContext.");
        }
        return invokedInterface;
View Full Code Here

    }

    public Object createProxy(Object primaryKey) {
        try {

            InterfaceType objectInterfaceType = this.interfaceType.getCounterpart();

            EjbObjectProxyHandler handler = newEjbObjectHandler(getDeploymentInfo(), primaryKey, objectInterfaceType, this.getInterfaces());

            List<Class> proxyInterfaces = new ArrayList<Class>(handler.getInterfaces().size() + 1);
View Full Code Here

        this.interfaceType = interfaceType;
        this.primaryKey = pk;
        this.setDeploymentInfo((CoreDeploymentInfo) deploymentInfo);

        if (interfaces == null || interfaces.size() == 0) {
            InterfaceType objectInterfaceType = (interfaceType.isHome()) ? interfaceType.getCounterpart() : interfaceType;
            interfaces = new ArrayList<Class>(deploymentInfo.getInterfaces(objectInterfaceType));
        }

        this.setDoIntraVmCopy(!interfaceType.isLocal());
View Full Code Here

            }
        }
    }

    public InterfaceType getInterfaceType(Class clazz) {
        InterfaceType type = interfaces.get(clazz);
        if (type != null) return type;

        if (javax.ejb.EJBLocalHome.class.isAssignableFrom(clazz)) return InterfaceType.EJB_LOCAL_HOME;
        if (javax.ejb.EJBLocalObject.class.isAssignableFrom(clazz)) return InterfaceType.EJB_LOCAL;
        if (javax.ejb.EJBHome.class.isAssignableFrom(clazz)) return InterfaceType.EJB_HOME;
View Full Code Here

        TransactionPolicy txPolicy = createTransactionPolicy(deploymentInfo.getTransactionType(callMethod), callContext);

        Object returnValue = null;
        try {
            InterfaceType type = deploymentInfo.getInterfaceType(callInterface);
            if (type == InterfaceType.SERVICE_ENDPOINT){
                callContext.setCurrentOperation(Operation.BUSINESS_WS);
                returnValue = invokeWebService(args, deploymentInfo, runMethod, instance, returnValue);
            } else {
                List<InterceptorData> interceptors = deploymentInfo.getMethodInterceptors(runMethod);
View Full Code Here

        try {
            // Security check
            checkAuthorization(deploymentInfo, callMethod, callInterface);

            // If a bean managed transaction is active, the bean can not be removed
            InterfaceType interfaceType = deploymentInfo.getInterfaceType(callInterface);
            if (interfaceType.isComponent()) {
                Instance instance = checkedOutInstances.get(primKey);
                if (instance != null && instance.getBeanTransaction() != null) {
                    throw new ApplicationException(new RemoveException("A stateful EJB enrolled in a bean-managed transaction can not be removed"));
                }
            }

            // Start transaction
            TransactionPolicy txPolicy = createTransactionPolicy(callContext.getDeploymentInfo().getTransactionType(callMethod), callContext);

            Object returnValue = null;
            boolean retain = false;
            Instance instance = null;
            Method runMethod = null;
            try {
                // Obtain instance
                instance = obtainInstance(primKey, callContext);
                if (instance == null) throw new ApplicationException(new javax.ejb.NoSuchEJBException());

                // Resume previous Bean transaction if there was one
                if (txPolicy instanceof BeanTransactionPolicy){
                    // Resume previous Bean transaction if there was one
                    SuspendedTransaction suspendedTransaction = instance.getBeanTransaction();
                    if (suspendedTransaction != null) {
                        instance.setBeanTransaction(null);
                        BeanTransactionPolicy beanTxEnv = (BeanTransactionPolicy) txPolicy;
                        beanTxEnv.resumeUserTransaction(suspendedTransaction);
                    }
                }

                // Register the entity managers
                registerEntityManagers(instance, callContext);

                // Register for synchronization callbacks
                registerSessionSynchronization(instance, callContext);

                // Setup for remove invocation
                callContext.setCurrentOperation(Operation.REMOVE);
                callContext.setCurrentAllowedStates(StatefulContext.getStates());
                callContext.setInvokedInterface(callInterface);
                runMethod = deploymentInfo.getMatchingBeanMethod(callMethod);
                callContext.set(Method.class, runMethod);

                // Do not pass arguments on home.remove(remote) calls
                Class<?> declaringClass = callMethod.getDeclaringClass();
                if (declaringClass.equals(EJBHome.class) || declaringClass.equals(EJBLocalHome.class)){
                    args = new Object[]{};
                }
               
                // Initialize interceptor stack
                List<InterceptorData> interceptors = deploymentInfo.getMethodInterceptors(runMethod);
                InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.REMOVE, interceptors, instance.interceptors);

                // Invoke
                if (args == null){
                    returnValue = interceptorStack.invoke();
                } else {
                    returnValue = interceptorStack.invoke(args);
                }
            } catch (Throwable e) {
                if (interfaceType.isBusiness() && deploymentInfo.getExceptionType(e) == SYSTEM) {
                    retain = deploymentInfo.retainIfExeption(runMethod);
                }
                handleException(callContext, txPolicy, e);
            } finally {
                if (!retain) {
View Full Code Here

TOP

Related Classes of org.apache.openejb.InterfaceType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.