Package org.ow2.easybeans.component.mail.factory

Examples of org.ow2.easybeans.component.mail.factory.AbsJavaMailRef


            if (this.clusterViewManager != null) {
                try {
                    this.clusterViewManager.stop();
                } catch (Exception e) {
                    this.logger.error("Cannot stop the server-side manager", e);
                    throw new EZBComponentException("Cannot stop the server-side manager", e);
                }
            }
        }
        this.logger.info("CMI extension stopped.");
View Full Code Here


    public void start() throws EZBComponentException {

        // Create and bind factories
        for (MailItf factory : getAllFactories()) {

            AbsJavaMailRef javaMailRef = null;
            String jndiName = factory.getJNDIName();

            // Create object and bind it
            if (factory instanceof Session) {
                JavaMailSessionRef javamailSession = new JavaMailSessionRef();
                javaMailRef = javamailSession;
            } else if (factory instanceof MimePart) {
                JavaMailMimePartDataSourceRef mimePartDataSourceRef = new JavaMailMimePartDataSourceRef();
                javaMailRef = mimePartDataSourceRef;

                // Set properties of this factory.
                MimePart mimePart = (MimePart) factory;

                // Set subject
                mimePartDataSourceRef.setSubject(mimePart.getSubject());

                // Define addresses
                List<Address> toAddresses = new ArrayList<Address>();
                List<Address> ccAddresses = new ArrayList<Address>();
                List<Address> bccAddresses = new ArrayList<Address>();

                // Get value
                for (MailAddress mail : mimePart.getMailAddresses()) {

                    // Build address object from the string
                    Address address = null;
                    try {
                        address = new InternetAddress(mail.getName());
                    } catch (AddressException e) {
                        throw new EZBComponentException("Cannot build an internet address with given value '" + mail.getName()
                                + "'.", e);
                    }

                    // Add address in the correct list
                    if ("CC".equalsIgnoreCase(mail.getType())) {
                        ccAddresses.add(address);
                    } else if ("BCC".equalsIgnoreCase(mail.getType())) {
                        bccAddresses.add(address);
                    } else {
                        // Default is TO
                        toAddresses.add(address);
                    }
                }

                // Set recipients
                mimePartDataSourceRef.setToRecipients(toAddresses.toArray(new Address[toAddresses.size()]));
                mimePartDataSourceRef.setCcRecipients(ccAddresses.toArray(new Address[ccAddresses.size()]));
                mimePartDataSourceRef.setBccRecipients(bccAddresses.toArray(new Address[bccAddresses.size()]));

            } else {
                throw new EZBComponentException("Unknown factory '" + factory + "'.");
            }

            // Set common values
            javaMailRef.setName(factory.getName());
            javaMailRef.setJNDIName(jndiName);
            javaMailRef.setProperties(factory.getMailSessionProperties());

            // Auth set for the factory ?
            Auth auth = factory.getAuth();

            // No, try to see for default auth ?
            if (auth == null) {
                auth = getAuth();
            }

            // There is authentication, set it
            if (auth != null) {
                javaMailRef.setAuthName(auth.getUsername());
                javaMailRef.setAuthName(auth.getPassword());
            }

            // Bind object
            try {
                new InitialContext().bind(jndiName, javaMailRef);
                logger.info("Binding {0} Mail factory with JNDI name {1}", javaMailRef.getType(), jndiName);
            } catch (NamingException e) {
                throw new EZBComponentException(
                        "Unable to bind the factory '" + factory + "' with JNDI name '" + jndiName + "'.", e);
            }
View Full Code Here

        } else {
            throw new EZBContainerException("unknown session type for: " + sessionBean);
        }

        // Build runtime information
        SessionBeanInfo sessionBeanInfo = new SessionBeanInfo();
        sessionBeanInfo.setTransactionManagementType(sessionBean.getTransactionManagementType());
        sessionBeanInfo.setApplicationExceptions(sessionBean.getEjbJarDeployableMetadata().getApplicationExceptions());
        // Only for singleton
        if (sessionBean.isSingleton()) {
            sessionBeanInfo.setStartup(sessionBean.isStartup());
        }

        sessionFactory.setSessionBeanInfo(sessionBeanInfo);

        // Build WS deploy/time info
        if (sessionBean.getWebServiceMarker() != null) {
            // Bean is annotated with @WebService or @WebServiceprovider
            IWebServiceInfo info = createWebServiceInfo(sessionBean, factoryName);
            sessionBeanInfo.setWebServiceInfo(info);
        } // else this bean is not webservices annotated

        // get interfaces of bean
        IJLocal localItfs = sessionBean.getLocalInterfaces();
        IJRemote remoteItfs = sessionBean.getRemoteInterfaces();

        if (localItfs != null) {
            sessionBeanInfo.setLocalInterfaces(localItfs.getInterfaces());
            for (String itf : localItfs.getInterfaces()) {
                this.bindingReferences.add(createLocalItfRef(itf,
                                                             getEmbedded().getID(),
                                                             getId(),
                                                             factoryName,
                                                             sessionBean,
                                                             sessionFactory));
            }
        }
        if (remoteItfs != null) {
            sessionBeanInfo.setRemoteInterfaces(remoteItfs.getInterfaces());
            for (String itf : remoteItfs.getInterfaces()) {
                this.bindingReferences.add(createRemoteItfRef(itf,
                                                              getId(),
                                                              factoryName,
                                                              sessionBean,
View Full Code Here

                    }
                }
            }

            // Fill the Info structure
            WebServiceInfo info = new WebServiceInfo();

            // Read name
            info.setPortComponentName(name);

            if (portComponent != null) {

                // Read wsdl-location from the webservice-description parent element
                info.setWsdlLocation(portComponent.getParent().getWsdlFile());

                // Read service QName
                info.setServiceName(portComponent.getWsdlService());

                // Read port QName
                info.setPortName(portComponent.getWsdlPort());

                // Read protocol-binding
                info.setProtocolBinding(portComponent.getProtocolBinding());

                // Read enable-mtom
                info.setMTOMEnabled(portComponent.isMTOMEnabled());

                // Read service-endpoint-interface
                if  (!marker.isWebServiceProvider()) {
                    info.setServiceEndpointInterface(portComponent.getServiceEndpointInterface());
                }

                // Read HandlerChains
                info.setHandlerChains(portComponent.getHandlerChains());

            }

            // EasyBeans specific values ....
            // ---------------------------------------------------
            // manage endpoint-address
            info.setEndpointAddress(sessionBean.getWebServiceEndpointAddress());

            // manage context-root
            info.setContextRoot(sessionBean.getWebServiceContextRoot());

            // manage realm-name
            info.setRealmName(sessionBean.getWebServiceRealmName());

            // manage transport-guarantee
            info.setTransportGuarantee(sessionBean.getWebServiceTransportGuarantee());

            // manage auth-method
            info.setAuthMethod(sessionBean.getWebServiceAuthMethod());

            // manage http-methods
            info.setHttpMethods(sessionBean.getWebServiceHttpMethods());

            // manage wsdl-publication-directory
            if (endpoint != null) {
                info.setWsdlPublicationDirectory(endpoint.getWsdlPublicationDirectory());
            }

            return info;
        }
View Full Code Here

        // Get JMS Component
        JMSComponent jmsComponent = null;
        jmsComponent = getEmbedded().getComponent(JMSComponent.class);

        // Create factory
        MDBMessageEndPointFactory mdbMessageEndPointFactory = null;
        try {
            mdbMessageEndPointFactory = new MDBMessageEndPointFactory(className, this, activationSpec, resourceAdapter,
                    jmsComponent);
        } catch (FactoryException e) {
            throw new EZBContainerException("Cannot build the MDB MessageEndPoint factory", e);
        }

        // build runtime information
        MessageDrivenInfo messageDrivenInfo = new MessageDrivenInfo();
        messageDrivenInfo.setApplicationExceptions(messageDrivenBean.getEjbJarDeployableMetadata().getApplicationExceptions());
        messageDrivenInfo.setTransactionManagementType(messageDrivenBean.getTransactionManagementType());
        messageDrivenInfo.setMessageListenerInterface(messageDrivenBean.getJMessageDriven()
                .getMessageListenerInterface());
        messageDrivenInfo.setMessageDestinationLink(messageDrivenBean.getJMessageDriven()
                .getMessageDestinationLink());

        // MappedName ? use it as destination
        String mappedName = messageDrivenBean.getJCommonBean().getMappedName();
        if (mappedName != null && !"".equals(mappedName)) {
            messageDrivenBean.getJMessageDriven().getActivationConfigProperties().add(
                    new JActivationConfigProperty("destination", mappedName));
        }

        messageDrivenInfo.setActivationConfigProperties(messageDrivenBean.getJMessageDriven()
                .getActivationConfigProperties());
        mdbMessageEndPointFactory.setMessageDrivenInfo(messageDrivenInfo);



        return mdbMessageEndPointFactory;
View Full Code Here

            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateful factory", fe);
            }
        } else if (sessionBean.isSingleton()) {
            try {
                sessionFactory = new SingletonSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateful factory", fe);
            }
        } else {
            throw new EZBContainerException("unknown session type for: " + sessionBean);
View Full Code Here

            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateless factory", fe);
            }
        } else if (sessionBean.isStateful()) {
            try {
                sessionFactory = new StatefulSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateful factory", fe);
            }
        } else if (sessionBean.isSingleton()) {
            try {
View Full Code Here

        SessionFactory<?> sessionFactory = null;

        if (sessionBean.isStateless()) {
            try {
                sessionFactory = new StatelessSessionFactory(className, this);
            } catch (FactoryException fe) {
                throw new EZBContainerException("Cannot build the stateless factory", fe);
            }
        } else if (sessionBean.isStateful()) {
            try {
View Full Code Here

        // stateless ? (using id = stateful)
        boolean isStateless = !isUsingID();

        // build the metadata
        EasyBeansMetaData metadata = new EasyBeansMetaData(ejbHome, homeInterfaceClass, remoteInterfaceClass, isStateless);

        // return it
        return metadata;
    }
View Full Code Here

        if (this.available) {
            throw new IllegalStateException("Cannot change the EZBContainer configuration after start().");
        }
        this.configuration = config;
        this.id = String.valueOf(System.identityHashCode(this));
        this.deployment = new Deployment(this.configuration);
        this.factories = new HashMap<String, Factory<?, ?>>();
    }
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.component.mail.factory.AbsJavaMailRef

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.