Package org.apache.openejb

Examples of org.apache.openejb.BeanContext


            } else {
                interfaces.add(ejb.getRemoteInterfaceClass());
            }

            final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
            final BeanContext beanContext = containerSystem.getBeanContext(ejb.getDeploymentID());

            return EjbHomeProxyHandler.createHomeProxy(beanContext, interfaceType, interfaces, ejb.getMainInterface());
        } catch (Exception e) {
            Logger.getInstance(LogCategory.OPENEJB_SERVER_REMOTE, "org.apache.openejb.server.util.resources")
                .error("ServerSideResolver.resolve() failed, falling back to ClientSideResolver: " +
View Full Code Here


            } else {
                interfaces.add(ejb.getRemoteInterfaceClass());
            }

            final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
            final BeanContext beanContext = containerSystem.getBeanContext(ejb.getDeploymentID());

            return EjbObjectProxyHandler.createProxy(beanContext, handler.getPrimaryKey(), interfaceType, interfaces, ejb.getMainInterface());
        } catch (Exception e) {
            Logger.getInstance(LogCategory.OPENEJB_SERVER_REMOTE, "org.apache.openejb.server.util.resources")
                .error("ServerSideResolver.resolve() failed, falling back to ClientSideResolver: " +
View Full Code Here

        }
    }

    public BeanContext getDeployment(final EJBRequest req) throws RemoteException {

        final BeanContext info;

        final int deploymentCode = req.getDeploymentCode();
        if (deploymentCode > 0 && deploymentCode < deployments.length) {
            info = deployments[deploymentCode];
            req.setDeploymentId((String) info.getDeploymentID());
            return info;
        }

        if (req.getDeploymentId() == null) {
            throw new RemoteException(messages.format("invalidDeploymentIdAndCode", req.getDeploymentId(), req.getDeploymentCode()));
View Full Code Here

        }
    }

    protected BeanContext getDeployment(final EJBRequest req) throws RemoteException {
        final String deploymentId = req.getDeploymentId();
        final BeanContext beanContext = containerSystem.getBeanContext(deploymentId);
        if (beanContext == null) {
            throw new RemoteException("No deployment: " + deploymentId);
        }
        return beanContext;
    }
View Full Code Here

        return deployment.get(deploymentInfo);
    }


    public void contextEntered(ThreadContext oldContext, ThreadContext newContext) {
        BeanContext deploymentInfo = newContext.getBeanContext();
        if (deploymentInfo == null) return;

        EjbDeployment ejbDeployment = getEjbDeployment(deploymentInfo);

        if (ejbDeployment == null) return;

        // Geronimo call context is used to track old state that must be restored
        GeronimoCallContext geronimoCallContext = new GeronimoCallContext();

        // Demarcate component boundaries for connection tracking if we have a tracker
        TrackedConnectionAssociator trackedConnectionAssociator = ejbDeployment.getTrackedConnectionAssociator();
        if (trackedConnectionAssociator != null) {
            // create the connector context... this only works with a TrackedConnectionAssociator using lazy association
            ConnectorInstanceContext connectorContext = new ConnectorInstanceContextImpl(ejbDeployment.getUnshareableResources(),
                    ejbDeployment.getApplicationManagedSecurityResources());

            // Set connector context
            try {
                geronimoCallContext.oldConnectorContext = trackedConnectionAssociator.enter(connectorContext);
            } catch (ResourceException e) {
                log.error("Error while entering TrackedConnectionAssociator");
                return;
            }
        }

        // Get the jndi context
        Context jndiContext = deploymentInfo.getJndiEnc();
        geronimoCallContext.oldJndiContext = RootContext.getComponentContext();
        // Set the jndi context into Geronimo's root context
        RootContext.setComponentContext(jndiContext);

        // set the policy (security) context id
View Full Code Here

        newContext.set(GeronimoCallContext.class, geronimoCallContext);
    }

    public void contextExited(ThreadContext exitedContext, ThreadContext reenteredContext) {
        BeanContext deploymentInfo = exitedContext.getBeanContext();
        if (deploymentInfo == null) return;

        EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class);
        if (ejbDeployment == null) return;

        // Geronimo call context is used to track old state that must be restored
        GeronimoCallContext geronimoCallContext = exitedContext.get(GeronimoCallContext.class);
        if (geronimoCallContext == null) return;
View Full Code Here

    public boolean isCallerAuthorized(Method method, InterfaceType typee) {
        ThreadContext threadContext = ThreadContext.getThreadContext();

        try {
            BeanContext deploymentInfo = threadContext.getBeanContext();

            // if security is not enabled we are autorized
            EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class);
            if (ejbDeployment == null || !ejbDeployment.isSecurityEnabled()) {
                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);
View Full Code Here

    public boolean isCallerInRole(String role) {
        if (role == null) throw new IllegalArgumentException("Role must not be null");

        ThreadContext threadContext = ThreadContext.getThreadContext();

        BeanContext deploymentInfo = threadContext.getBeanContext();

        // if security is not enabled we are not in that role
        EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class);
        if (ejbDeployment == null || !ejbDeployment.isSecurityEnabled()) {
            return false;
        }

        String EJBName = deploymentInfo.getEjbName();
        if (EJBName == null) throw new IllegalArgumentException("EJBName must not be null");
        try {
            AccessControlContext context = ContextManager.getCurrentContext();
            context.checkPermission(new EJBRoleRefPermission(EJBName, role));
        } catch (AccessControlException e) {
View Full Code Here

    }

    public Principal getCallerPrincipal() {
        // if security is not enabled, we don't have a principal
        ThreadContext threadContext = ThreadContext.getThreadContext();
        BeanContext deploymentInfo = threadContext.getBeanContext();
        EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class);
        if (ejbDeployment == null || !ejbDeployment.isSecurityEnabled()) {
            return null;
        }

        Subject callerSubject = ContextManager.getCurrentCaller();
View Full Code Here

            throw new IllegalStateException("Unable to complete EjbDeployment initialization", e);
        }
    }

    protected void destroy() {
        BeanContext info = deploymentInfo.getAndSet(null);
        if (info != null) {
            info.set(EjbDeployment.class, null);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.BeanContext

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.