Package org.ow2.easybeans.examples.maven.jpa2.entity

Examples of org.ow2.easybeans.examples.maven.jpa2.entity.Address


        if (auditComponent != null) {
            auditComponent.registerJ2EEManagedObject(this);
        }

        // Dispatch life cycle event.
        this.dispatcher.dispatch(new EventLifeCycleStarting(this.j2eeManagedObjectId));

        // Gets URL of the archive
        final URL url;
        try {
            url = getArchive().getURL();
View Full Code Here


     */
    public static void main(final String[] args) throws Exception {

        // Lookup the Remote Bean interface through JNDI
        Context initialContext = getInitialContext();
        BusinessInterface facadeBean = (BusinessInterface) initialContext.lookup("JPA2Bean");

        // Init (if not done)
        System.out.println("Initializing the database with some employees...");
        facadeBean.init();

        // Search Florent Employee
        System.out.println("Finding data about Florent...");
        Employee florent = facadeBean.findEmployeeWithItsGivenName("Florent");
        printEmployee(florent);

        System.out.println("Listing all employees...");
        for (Employee employee : facadeBean.findEmployees()) {
            printEmployee(employee);
        }

    }
View Full Code Here

        florent.getLevelRights().add(EmployeeLevelType.ADMIN);
        florent.getLevelRights().add(EmployeeLevelType.SUPER_ADMIN);

        // Create addresses
        Address florentWorkAddress = new Address();
        florentWorkAddress.setTitle("work");
        florentWorkAddress.setCity("Grenoble");
        this.entityManager.persist(florentWorkAddress);

        Address florentHomeAddress = new Address();
        florentHomeAddress.setTitle("home");
        florentHomeAddress.setCity("Grenoble");
        this.entityManager.persist(florentHomeAddress);

        florent.getAddresses().add(florentHomeAddress);
        florent.getAddresses().add(florentWorkAddress);

        Date now = new Date();
        Calendar calendar = new GregorianCalendar();
        calendar.set(2010, 11, 25);
        Date christmas = calendar.getTime();

        florent.getHistoryEvents().put(now, "Date of init");
        florent.getHistoryEvents().put(christmas, "XMas Day");

        this.entityManager.persist(florent);

        // Another employee
        Employee bean = new Employee();
        bean.setName("EasyBeans");
        bean.addNickName("The easy bean");
        bean.addNickName("OW2 EasyBeans");

        bean.getLevelRights().add(EmployeeLevelType.TRAINEE);

        // Create addresses
        Address beanFirstAddress = new Address();
        beanFirstAddress.setTitle("work");
        beanFirstAddress.setCity("Grenoble");

        Address beanSecondAddress = new Address();
        beanSecondAddress.setTitle("cofee");
        beanSecondAddress.setCity("Java");

        bean.getAddresses().add(beanFirstAddress);
        bean.getAddresses().add(beanSecondAddress);

        Calendar calendarRelease = new GregorianCalendar();
View Full Code Here

        System.out.println("Initializing the database with some employees...");
        facadeBean.init();

        // Search Florent Employee
        System.out.println("Finding data about Florent...");
        Employee florent = facadeBean.findEmployeeWithItsGivenName("Florent");
        printEmployee(florent);

        System.out.println("Listing all employees...");
        for (Employee employee : facadeBean.findEmployees()) {
            printEmployee(employee);
View Full Code Here

     * Initialize the Database with new entities.
     */
    public void init() {

        // Do nothing if already defined
        Employee test = findEmployeeWithItsGivenName("Florent");
        if (test != null) {
            return;
        }

        // The first employee
        Employee florent = new Employee();
        florent.setName("Florent");
        florent.addNickName("flo");
        florent.addNickName("FB");

        florent.getLevelRights().add(EmployeeLevelType.ADMIN);
        florent.getLevelRights().add(EmployeeLevelType.SUPER_ADMIN);

        // Create addresses
        Address florentWorkAddress = new Address();
        florentWorkAddress.setTitle("work");
        florentWorkAddress.setCity("Grenoble");
        this.entityManager.persist(florentWorkAddress);

        Address florentHomeAddress = new Address();
        florentHomeAddress.setTitle("home");
        florentHomeAddress.setCity("Grenoble");
        this.entityManager.persist(florentHomeAddress);

        florent.getAddresses().add(florentHomeAddress);
        florent.getAddresses().add(florentWorkAddress);

        Date now = new Date();
        Calendar calendar = new GregorianCalendar();
        calendar.set(2010, 11, 25);
        Date christmas = calendar.getTime();

        florent.getHistoryEvents().put(now, "Date of init");
        florent.getHistoryEvents().put(christmas, "XMas Day");

        this.entityManager.persist(florent);

        // Another employee
        Employee bean = new Employee();
        bean.setName("EasyBeans");
        bean.addNickName("The easy bean");
        bean.addNickName("OW2 EasyBeans");

        bean.getLevelRights().add(EmployeeLevelType.TRAINEE);

        // Create addresses
        Address beanFirstAddress = new Address();
        beanFirstAddress.setTitle("work");
        beanFirstAddress.setCity("Grenoble");

        Address beanSecondAddress = new Address();
        beanSecondAddress.setTitle("cofee");
        beanSecondAddress.setCity("Java");

        bean.getAddresses().add(beanFirstAddress);
        bean.getAddresses().add(beanSecondAddress);

        Calendar calendarRelease = new GregorianCalendar();
        calendarRelease.set(2010, 01, 01);
        Date release = calendarRelease.getTime();

        bean.getHistoryEvents().put(release, "Date of the release");

        this.entityManager.persist(bean);

    }
View Full Code Here

        // Get Deployable
        IDeployable<?> deployable = null;
        try {
            deployable = DeployableHelper.getDeployable(this.archive);
        } catch (DeployableHelperException e) {
            throw new ArchiveInjectionException("Unable to get a deployable on archive '" + this.archive + "'.", e);
        }

        // Client Archive ?
        if (CARDeployable.class.isInstance(deployable)) {
            // Create metadata
            ICarDeployableMetadata carDeployableMetadata = null;
            try {
                carDeployableMetadata = new CarDeployableMetadataFactory().createDeployableMetadata(CARDeployable.class
                        .cast(deployable), classLoader);
            } catch (DeployableMetadataException e) {
                throw new ArchiveInjectionException("Unable to get metadata on archive '" + this.archive + "'.", e);
            }

            // Use only common part
            this.metadataCollection = carDeployableMetadata.getCarClassMetadataCollection();
        } else {
View Full Code Here

        for (ICommonMethodMetadata<?, ?, ?> postConstructMethodMetadata : postConstructMethods) {
            Method postConstructMethod = null;
            try {
                postConstructMethod = clazz.getDeclaredMethod(postConstructMethodMetadata.getJMethod().getName());
            } catch (NoSuchMethodException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            }

            boolean accessible = postConstructMethod.isAccessible();
            try {
                postConstructMethod.setAccessible(true);
                postConstructMethod.invoke(instance);
            } catch (IllegalAccessException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            } catch (InvocationTargetException e) {
                throw new ArchiveInjectionException("Cannot invoke postconstruct method", e);
            } finally {
                postConstructMethod.setAccessible(accessible);
            }
        }
View Full Code Here

            // OK, now that JNDI name is here, get value
            try {
                value = new InitialContext().lookup(jndiName);
            } catch (NamingException e) {
                throw new ArchiveInjectionException("Cannot get object with JNDI Name '" + jndiName + "' for ejb '" + ejb
                        + "'.", e);
            }
        }

        // Set value
View Full Code Here

        // No value, needs to find it
        if (value == null) {
            try {
                value = new InitialContext().lookup(name);
            } catch (NamingException e) {
                throw new ArchiveInjectionException("Cannot get object with JNDI Name '" + name + "' for Resource '"
                        + jJavaxPersistenceUnit + "'.", e);
            }
        }

        // Set value
View Full Code Here

            // OK, now that JNDI name is here, get value
            try {
                value = new InitialContext().lookup(mappedName);
            } catch (NamingException e) {
                throw new ArchiveInjectionException("Cannot get object with JNDI Name '" + mappedName + "' for Resource '"
                        + jAnnotationResource + "'.", e);
            }
        }

        // Set value
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.examples.maven.jpa2.entity.Address

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.