Examples of EJBComponent


Examples of org.jboss.as.ejb3.component.EJBComponent

    public synchronized void start(final StartContext context) throws StartException {

        if (logger.isDebugEnabled()) {
            logger.debug("Starting timerservice for timedObjectId: " + getInvoker().getTimedObjectId());
        }
        final EJBComponent component = ejbComponentInjectedValue.getValue();
        this.transactionManager = component.getTransactionManager();
        this.tsr = component.getTransactionSynchronizationRegistry();
        final TimedObjectInvoker invoker = timedObjectInvoker.getValue();
        if (invoker == null) {
            throw EjbLogger.ROOT_LOGGER.invokerIsNull();
        }
        final List<ScheduleTimer> timers = new ArrayList<ScheduleTimer>();
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

        final String viewClassOfInvokedMethod = componentView.getViewClass().getName();
        // shouldn't really happen if the interceptor was setup correctly. But let's be safe and do a check
        if (!this.viewClassName.equals(viewClassOfInvokedMethod) || !this.viewMethod.equals(invokedMethod)) {
            throw EjbLogger.ROOT_LOGGER.failProcessInvocation(this.getClass().getName(), invokedMethod, viewClassOfInvokedMethod, viewMethod, viewClassName);
        }
        final EJBComponent ejbComponent = (EJBComponent) component;
        final ServerSecurityManager securityManager = ejbComponent.getSecurityManager();
        final MethodInterfaceType methodIntfType = this.getMethodInterfaceType(componentView.getPrivateData(MethodIntf.class));

        // set the JACC contextID before calling the security manager.
        final String previousContextID = setContextID(this.contextID);
        try {
            if(WildFlySecurityManager.isChecking()) {
                try {
                    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                        @Override
                        public ProtectionDomain run() {

                            if (!securityManager.authorize(ejbComponent.getComponentName(), componentView.getProxyClass().getProtectionDomain().getCodeSource(),
                                    methodIntfType.name(), AuthorizationInterceptor.this.viewMethod, AuthorizationInterceptor.this.getMethodRolesAsPrincipals(), AuthorizationInterceptor.this.contextID)) {
                                throw EjbLogger.ROOT_LOGGER.invocationOfMethodNotAllowed(invokedMethod,ejbComponent.getComponentName());
                            }
                            return null;
                        }
                    });
                } catch (PrivilegedActionException e) {
                    throw e.getException();
                }
            } else {
                if (!securityManager.authorize(ejbComponent.getComponentName(), componentView.getProxyClass().getProtectionDomain().getCodeSource(),
                        methodIntfType.name(), this.viewMethod, this.getMethodRolesAsPrincipals(), this.contextID)) {
                    throw EjbLogger.ROOT_LOGGER.invocationOfMethodNotAllowed(invokedMethod,ejbComponent.getComponentName());
                }
            }
            // successful authorization, let the invocation proceed
            return context.proceed();
        }
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

        throw (Exception) t;
    }

    public Object processInvocation(InterceptorContext invocation) throws Exception {
        final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);
        final TransactionManager tm = component.getTransactionManager();
        final int oldTimeout = getCurrentTransactionTimeout(component);
        try {
            final MethodIntf methodIntf = MethodIntfHelper.of(invocation);
            final TransactionAttributeType attr = component.getTransactionAttributeType(methodIntf, invocation.getMethod());
            final int timeoutInSeconds = component.getTransactionTimeout(methodIntf, invocation.getMethod());
            switch (attr) {
                case MANDATORY:
                    return mandatory(invocation, component);
                case NEVER:
                    return never(invocation, component);
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

    }


    @Override
    public Object processInvocation(InterceptorContext invocation) throws Exception {
        final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);

        switch (transactionAttributeType) {
            case MANDATORY:
                return mandatory(invocation, component);
            case NEVER:
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

            this.treatRequiredAsRequiresNew = treatRequiredAsRequiresNew;
        }

        @Override
        protected Interceptor create(Component component, InterceptorFactoryContext context) {
            final EJBComponent ejb = (EJBComponent) component;
            TransactionAttributeType txAttr;
            if (methodIdentifier == null) {
                if(treatRequiredAsRequiresNew) {
                    txAttr = TransactionAttributeType.REQUIRED;
                } else {
                    //for stateful beans we default to NOT_SUPPORTED
                    txAttr = TransactionAttributeType.NOT_SUPPORTED;
                }
            } else {
                txAttr = ejb.getTransactionAttributeType(MethodIntf.BEAN, methodIdentifier, treatRequiredAsRequiresNew ? TransactionAttributeType.REQUIRES_NEW : TransactionAttributeType.NOT_SUPPORTED);
            }
            final int txTimeout;
            if(methodIdentifier == null) {
                txTimeout = -1;
            } else {
                txTimeout = ejb.getTransactionTimeout(MethodIntf.BEAN, methodIdentifier);
            }
            if (treatRequiredAsRequiresNew && txAttr == TransactionAttributeType.REQUIRED) {
                txAttr = TransactionAttributeType.REQUIRES_NEW;
            }
            if(!treatRequiredAsRequiresNew ) {
                if(txAttr != TransactionAttributeType.NOT_SUPPORTED &&
                        txAttr != TransactionAttributeType.REQUIRES_NEW) {
                    EjbLogger.ROOT_LOGGER.invalidTransactionTypeForSfsbLifecycleMethod(txAttr, methodIdentifier, ejb.getComponentClass());
                    txAttr = TransactionAttributeType.NOT_SUPPORTED;
                }
            }
            final LifecycleCMTTxInterceptor interceptor = new LifecycleCMTTxInterceptor(txAttr, txTimeout);
            return interceptor;
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

        @Override
        public Object getInstance() {
            // get the current invocation context and the EJBComponent out of it
            final InterceptorContext currentInvocationContext = CurrentInvocationContext.get();
            final EJBComponent ejbComponent = (EJBComponent) currentInvocationContext.getPrivateData(Component.class);
            if (ejbComponent == null) {
                throw EjbLogger.ROOT_LOGGER.failToGetEjbComponent(currentInvocationContext);
            }
            return ejbComponent.getTimerService();
        }
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

    @Override
    public Object processInvocation(final InterceptorContext invocation) throws Exception {
        // Do we have a foreign transaction context?
        Transaction tx = TxServerInterceptor.getCurrentTransaction();
        if (tx instanceof ForeignTransaction) {
            final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);

            //for timer invocations there is no view, so the methodInf is attached directly
            //to the context. Otherwise we retrieve it from the invoked view
            MethodIntf methodIntf = invocation.getPrivateData(MethodIntf.class);
            if (methodIntf == null) {
                final ComponentView componentView = invocation.getPrivateData(ComponentView.class);
                if (componentView != null) {
                    methodIntf = componentView.getPrivateData(MethodIntf.class);
                } else {
                    methodIntf = MethodIntf.BEAN;
                }
            }

            final TransactionAttributeType attr = component.getTransactionAttributeType(methodIntf, invocation.getMethod());
            if (attr != TransactionAttributeType.NOT_SUPPORTED && attr != TransactionAttributeType.REQUIRES_NEW) {
                throw EjbLogger.ROOT_LOGGER.transactionPropagationNotSupported();
            }
        }
        return invocation.proceed();
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

            // Should create a CORBA interface repository?
            final boolean interfaceRepositorySupported = false;

            // Build binding name of the bean.
            final EJBComponent component = ejbComponentInjectedValue.getValue();
            final String earApplicationName = component.getEarApplicationName();
            if (iiopMetaData != null && iiopMetaData.getBindingName() != null) {
                name = iiopMetaData.getBindingName();
            } else if (useQualifiedName) {
                if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) {
                    name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                    name = name + component.getModuleName() + "/" + component.getComponentName();
                } else {
                    name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                    name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName();
                }
            } else {
                name = component.getComponentName();
            }
            name = name.replace(".", "_");

            final ORB orb = this.orb.getValue();
            if (interfaceRepositorySupported) {
                // Create a CORBA interface repository for the enterprise bean
                iri = new InterfaceRepository(orb, irPoa.getValue(), name);
                // Add bean interface info to the interface repository
                iri.mapClass(remoteView.getValue().getViewClass());
                iri.mapClass(homeView.getValue().getViewClass());
                iri.finishBuild();
                EjbLogger.ROOT_LOGGER.cobraInterfaceRepository(name, orb.object_to_string(iri.getReference()));
            }

            IORSecurityConfigMetaData iorSecurityConfigMetaData = this.iorSecConfigMetaData.getOptionalValue();
            if (this.iiopMetaData != null && this.iiopMetaData.getIorSecurityConfigMetaData() != null)
                iorSecurityConfigMetaData = this.iiopMetaData.getIorSecurityConfigMetaData();

            // Create security policies if security metadata has been provided.
            List<Policy> policyList = new ArrayList<Policy>();
            if (iorSecurityConfigMetaData != null) {

                // Create csiv2Policy for both home and remote containing IorSecurityConfigMetadata.
                final Any secPolicy = orb.create_any();
                secPolicy.insert_Value(iorSecurityConfigMetaData);
                Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
                policyList.add(csiv2Policy);

                // Create SSLPolicy (SSL_REQUIRED ensures home and remote IORs will have port 0 in the primary address).
                boolean sslRequired = false;
                if (iorSecurityConfigMetaData != null) {
                    IORTransportConfigMetaData tc = iorSecurityConfigMetaData.getTransportConfig();
                    sslRequired = IORTransportConfigMetaData.INTEGRITY_REQUIRED.equals(tc.getIntegrity())
                            || IORTransportConfigMetaData.CONFIDENTIALITY_REQUIRED.equals(tc.getConfidentiality())
                            || IORTransportConfigMetaData.ESTABLISH_TRUST_IN_CLIENT_REQUIRED.equals(tc.getEstablishTrustInClient());
                }
                final Any sslPolicyValue = orb.create_any();
                SSLPolicyValueHelper.insert(sslPolicyValue, (sslRequired) ? SSLPolicyValue.SSL_REQUIRED : SSLPolicyValue.SSL_NOT_REQUIRED);
                Policy sslPolicy = orb.create_policy(SSL_POLICY_TYPE.value, sslPolicyValue);
                policyList.add(sslPolicy);

                EjbLogger.ROOT_LOGGER.debug("container's SSL policy: " + sslPolicy);
            }

            String securityDomain = "CORBA_REMOTE"; //TODO: what should this default to
            if (component.getSecurityMetaData() != null) {
                securityDomain = component.getSecurityMetaData().getSecurityDomain();
            }

            Policy[] policies = policyList.toArray(new Policy[policyList.size()]);

            // If there is an interface repository, then get the homeInterfaceDef from the IR
            InterfaceDef homeInterfaceDef = null;
            if (iri != null) {
                Repository ir = iri.getReference();
                homeInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(homeRepositoryIds[0]));
            }

            // Get the POACurrent object
            Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));

            // Instantiate home servant, bind it to the servant registry, and create CORBA reference to the EJBHome.
            final EjbCorbaServant homeServant = new EjbCorbaServant(poaCurrent, homeMethodMap, homeRepositoryIds, homeInterfaceDef,
                    orb, homeView.getValue(), factory, configuration, component.getTransactionManager(), module.getClassLoader(), true, securityDomain);

            homeServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
            ReferenceFactory homeReferenceFactory = homeServantRegistry.bind(homeServantName(name), homeServant, policies);

            final org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);

            //we do this twice to force eager dynamic stub creation
            ejbHome = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);

            final HomeHandleImplIIOP homeHandle = new HomeHandleImplIIOP(orb.object_to_string(corbaRef));
            homeServant.setHomeHandle(homeHandle);

            // Initialize beanPOA and create metadata depending on the kind of bean
            if (component instanceof EntityBeanComponent) {

                // This is an entity bean (lifespan: persistent)
                beanServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
                final EntityBeanComponent entityBeanComponent = (EntityBeanComponent) component;
                final Class pkClass = entityBeanComponent.getPrimaryKeyClass();
                ejbMetaData = new EJBMetaDataImplIIOP(entityBeanComponent.getRemoteClass(), entityBeanComponent.getHomeClass(), pkClass, false, false, homeHandle);
            } else {
                // This is a session bean (lifespan: transient)
                beanServantRegistry = poaRegistry.getValue().getRegistryWithTransientPOAPerServant();
                if (component instanceof StatelessSessionComponent) {
                    // Stateless session bean
                    ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, true, homeHandle);
                } else {
                    // Stateful session bean
                    ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, false, homeHandle);
                }
            }
            homeServant.setEjbMetaData(ejbMetaData);

            // If there is an interface repository, then get the beanInterfaceDef from the IR
            InterfaceDef beanInterfaceDef = null;
            if (iri != null) {
                final Repository ir = iri.getReference();
                beanInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
            }

            // Instantiate the ejb object servant and bind it to the servant registry.
            final EjbCorbaServant beanServant = new EjbCorbaServant(poaCurrent, beanMethodMap, beanRepositoryIds,
                    beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, component.getTransactionManager(),
                    module.getClassLoader(), false, securityDomain);
            beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies);

            // Register bean home in local CORBA naming context
            rebind(corbaNamingContext.getValue(), name, corbaRef);
            EjbLogger.ROOT_LOGGER.debug("Home IOR for " + component.getComponentName() + " bound to " + this.name + " in CORBA naming service");

            //now eagerly force stub creation, so de-serialization of stubs will work correctly
            final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
            try {
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

     *
     * @param locator The locator
     * @return The corba reference
     */
    public org.omg.CORBA.Object referenceForLocator(final EJBLocator<?> locator) {
        final EJBComponent ejbComponent = ejbComponentInjectedValue.getValue();
        try {
            final String earApplicationName = ejbComponent.getEarApplicationName() == null ? "" : ejbComponent.getEarApplicationName();
            if (locator.getBeanName().equals(ejbComponent.getComponentName()) &&
                    locator.getAppName().equals(earApplicationName) &&
                    locator.getModuleName().equals(ejbComponent.getModuleName()) &&
                    locator.getDistinctName().equals(ejbComponent.getDistinctName())) {
                if (locator instanceof EJBHomeLocator) {
                    return (org.omg.CORBA.Object) ejbHome;
                } else if (locator instanceof StatelessEJBLocator) {
                    return beanReferenceFactory.createReference(beanRepositoryIds[0]);
                } else if (locator instanceof StatefulEJBLocator) {
                    final Marshaller marshaller = factory.createMarshaller(configuration);
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((StatefulEJBLocator) locator).getSessionId());
                    marshaller.finish();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                } else if (locator instanceof EntityEJBLocator) {
                    final Marshaller marshaller = factory.createMarshaller(configuration);
                    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    marshaller.start(new OutputStreamByteOutput(stream));
                    marshaller.writeObject(((EntityEJBLocator) locator).getPrimaryKey());
                    marshaller.finish();
                    return beanReferenceFactory.createReferenceWithId(stream.toByteArray(), beanRepositoryIds[0]);
                }
                throw EjbLogger.ROOT_LOGGER.unknownEJBLocatorType(locator);
            } else {
                throw EjbLogger.ROOT_LOGGER.incorrectEJBLocatorForBean(locator, ejbComponent.getComponentName());
            }
        } catch (Exception e) {
            throw EjbLogger.ROOT_LOGGER.couldNotCreateCorbaObject(e, locator);
        }
    }
View Full Code Here

Examples of org.jboss.as.ejb3.component.EJBComponent

    public Object processInvocation(InterceptorContext context) throws Exception {
        InvocationType invocation = context.getPrivateData(InvocationType.class);
        if (invocation != InvocationType.REMOTE && invocation != InvocationType.MESSAGE_DELIVERY) {
            return context.proceed();
        }
        EJBComponent component = getComponent(context, EJBComponent.class);
        ControlPoint entryPoint = component.getControlPoint();
        RunResult result = entryPoint.beginRequest();
        if (result == RunResult.REJECTED) {
            throw EjbLogger.ROOT_LOGGER.containerSuspended();
        }
        try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.