Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.ResourceReferenceDescriptor


     * Return the resource object corresponding to the supplied name or throw an illegal argument exception.
     */
    @Override
    public ResourceReferenceDescriptor getResourceReferenceByName(String name) {
        for (Iterator itr = getResourceReferenceDescriptors().iterator(); itr.hasNext();) {
            ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) itr.next();
            if (next.getName().equals(name)) {
                return next;
            }
        }
        throw new IllegalArgumentException("no resource ref of name " + name);
    }
View Full Code Here


     * Create and execute the files.
     */
    public void process() {
     
        EjbBundleDescriptor bundle = ctx.getModuleMetaData(EjbBundleDescriptor.class);
        ResourceReferenceDescriptor cmpResource = bundle.getCMPResourceReference();

        // If this bundle's beans are not created by Java2DB, there is nothing to do.
        if (!DeploymentHelper.isJavaToDatabase(
                cmpResource.getSchemaGeneratorProperties())) {
            return;
        }

        helper = new Java2DBProcessorHelper(ctx);
        helper.init();

        String resourceName = cmpResource.getJndiName();
        helper.setProcessorType("CMP", bundle.getName()); // NOI18N
        helper.setJndiName(resourceName, bundle.getName());

        // If CLI options are not set, use value from the create-tables-at-deploy
        // or drop-tables-at-undeploy elements of the sun-ejb-jar.xml
        boolean userCreateTables = cmpResource.isCreateTablesAtDeploy();
        boolean createTables = helper.getCreateTables(userCreateTables);

        boolean userDropTables = cmpResource.isDropTablesAtUndeploy();

        if (logger.isLoggable(logger.FINE)) {               
            logger.fine("ejb.CMPProcessor.createanddroptables", //NOI18N
                new Object[] {new Boolean(createTables), new Boolean(userDropTables)});
        }
View Full Code Here

        if (ctx == null)
            isVerifyFlag = true;
        File cmpMappingFile = getSunCmpMappingFile(inputFilesPath);
        boolean mappedBeans = !ignoreSunDeploymentDescriptors
                && cmpMappingFile.exists();
        ResourceReferenceDescriptor cmpResource = checkOrCreateCMPResource(
                mappedBeans);

        // Remember whether or not this mapping was created by Java2DB.
        isJavaToDatabaseFlag = DeploymentHelper.isJavaToDatabase(
                cmpResource.getSchemaGeneratorProperties());

        // We *must* get a vendor name if either the beans are not mapped, or
        // they are mapped and the javaToDatabase flag is set.
        boolean mustHaveDBVendorName =
            !mappedBeans || (mappedBeans && isJavaToDatabaseFlag);
       
        // Read deployment settings from the deployment descriptor
        // and CLI options.
        Results deploymentArguments = getDeploymentArguments(
                ctx, cmpResource, mustHaveDBVendorName);
        dbVendorName = deploymentArguments.getDatabaseVendorName();
        if (mappedBeans) {
            // If sun-cmp-mappings.xml exists and we are doing a deployment,
            // validate some arguments and make sure we have dbschema.
            // If it is from verify, skip deployment arguments check.
            if (!isVerifyFlag) {
                String warning = null; // Warning for user, if required.

                if (isJavaToDatabaseFlag) {
                    // If beans were already mapped, we will generate tables, but
                    // they will be as per the existing mapping.  So if the user
                    // gave --uniquetablenames, warn them that we will not take
                    // that flag into account.  I.e., the tables will be generated
                    // as per the mapping.
                    if (deploymentArguments.hasUniqueTableNames()) {
                        warning =
                            I18NHelper.getMessage(
                                messages,
                                "EXC_DisallowJava2DBUniqueTableNames", //NOI18N
                                bundle.getApplication().getRegistrationName(),
                                JDOCodeGeneratorHelper.getModuleName(bundle));
                        logger.warning(warning);
                    }
                } else if (deploymentArguments.hasJavaToDatabaseArgs()) {

                    // If beans are already mapped but the user gave any Java2DB
                    // command line arguments, warn the user that these args
                    // should not be used when module is already mapped.
                    warning =
                        I18NHelper.getMessage(
                            messages,
                            "EXC_DisallowJava2DBCLIOverrides", //NOI18N
                            bundle.getApplication().getRegistrationName(),
                            JDOCodeGeneratorHelper.getModuleName(bundle));
                    logger.warning(warning);
                }

                if (warning != null) {
                    ActionReport subActionReport = ctx.getActionReport().addSubActionsReport();
                    // Propagte warning to client side so that the deployer can see the warning.
                    Java2DBProcessorHelper.warnUser(subActionReport, warning);
                }
            }
            // Sun-cmp-mapping.xml exists, use normal MappingClass loading
            SunCmpMappings sunCmpMappings = getSunCmpMappings(cmpMappingFile);

            // Ensure that there is a dbschema for each element of
            // sunCmpMappings.
            ensureDBSchemaExistence(cmpResource, sunCmpMappings, inputFilesPath,
                classout);

            // load real mapping model and jdo model in memory
            Map mappingClasses = loadMappingClasses(sunCmpMappings, getClassLoader());

            // Get schema from one of the mapping classes.
            // The mapping class element may be null if there is inconsistency
            // in sun-cmp-mappings.xml and ejb-jar.xml. For example,
            // the bean has mapping information in sun-cmp-mappings.xml but
            // no definition in the ejb-jar.xml.
            // So iterate over the mappings until the 1st non-null is found.
            MappingClassElement mc = null;
            Iterator iter = mappingClasses.values().iterator();
            while (iter.hasNext()) {
                mc = (MappingClassElement)iter.next();
                if (mc != null) {
                    schema = SchemaElement.forName(mc.getDatabaseRoot());
                    break;
                }
            }

            if (logger.isLoggable(Logger.FINE)){
                logger.fine("Loaded mapped beans for " // NOI18N
                            + cmpResource.getJndiName()
                            + ", isJavaToDatabase=" + isJavaToDatabaseFlag); // NOI18N
            }
        }
        else {
            // Generate mapping file and dbschema, since either
View Full Code Here

     * specified.
     */
    private ResourceReferenceDescriptor checkOrCreateCMPResource(
            boolean mappedBeans)
            throws GeneratorException {
        ResourceReferenceDescriptor cmpResource =
                bundle.getCMPResourceReference();
        if (mappedBeans) {
            if (cmpResource == null) {
                // If mapping exists, the cmpResource must specify a
                // database or a PMF JNDI name.
                throw JDOCodeGeneratorHelper.createGeneratorException(
                        "EXC_MissingCMPResource", bundle); //NOI18N
            }
        } else {
            if (cmpResource == null) {

                // In JavaToDB case we can deploy to the default jdbc-resource.
                cmpResource = new ResourceReferenceDescriptor();
                cmpResource.setJndiName("jdbc/__default");
                cmpResource.setDatabaseVendorName(DBVendorTypeHelper.DERBY);
                cmpResource.setCreateTablesAtDeploy(true);
                cmpResource.setDropTablesAtUndeploy(true);
                bundle.setCMPResourceReference(cmpResource);
            }
        }
        return cmpResource;
    }
View Full Code Here

        // pm-descriptors?
  PMDescriptorsNode pmsNode = new PMDescriptorsNode();
  pmsNode.writeDescriptor(ejbs, RuntimeTagNames.PM_DESCRIPTORS, bundleDescriptor);
       
        // cmpresource?
        ResourceReferenceDescriptor rrd = bundleDescriptor.getCMPResourceReference();
        if ( rrd != null ) {
            CmpResourceNode crn = new CmpResourceNode();
            crn.writeDescriptor(ejbs, RuntimeTagNames.CMP_RESOURCE, rrd);
        }
       
View Full Code Here

            }
        } else if (newDescriptor instanceof ResourceRef) {
            ResourceRef resourceRef = (ResourceRef)newDescriptor;
            descriptor.getSunDescriptor().addResourceRef(resourceRef);
            try {
                ResourceReferenceDescriptor rrd = descriptor.getResourceReferenceByName(resourceRef.getResRefName());
                rrd.setJndiName(resourceRef.getJndiName());
            } catch (IllegalArgumentException iae) {
                DOLUtils.getDefaultLogger().warning(iae.getMessage());
            }
        } else if (newDescriptor instanceof ResourceEnvRef) {
            ResourceEnvRef resourceEnvRef = (ResourceEnvRef)newDescriptor;
            descriptor.getSunDescriptor().addResourceEnvRef(resourceEnvRef);
            try {
                JmsDestinationReferenceDescriptor rrd = descriptor.getJmsDestinationReferenceByName(resourceEnvRef.getResourceEnvRefName());
                rrd.setJndiName(resourceEnvRef.getJndiName());
            } catch (IllegalArgumentException iae) {
                DOLUtils.getDefaultLogger().warning(iae.getMessage());
            }
        } else if (newDescriptor instanceof EjbRef) {
            EjbRef ejbRef = (EjbRef) newDescriptor;
View Full Code Here

            // that has to be used
            WebServiceContextImpl wsc = null;
            WebBundleDescriptor bundle = (WebBundleDescriptor)endpoint.getBundleDescriptor();
            Iterator<ResourceReferenceDescriptor> it = bundle.getResourceReferenceDescriptors().iterator();
            while(it.hasNext()) {
                ResourceReferenceDescriptor r = it.next();
                if(r.isWebServiceContext()) {
                    Iterator<InjectionTarget> iter = r.getInjectionTargets().iterator();
                    boolean matchingClassFound = false;
                    while(iter.hasNext()) {
                        InjectionTarget target = iter.next();
                        if(endpoint.getServletImplClass().equals(target.getClassName())) {
                            matchingClassFound = true;
                            break;
                        }
                    }
                    if(!matchingClassFound) {
                        continue;
                    }
                    try {
                        javax.naming.InitialContext ic = new javax.naming.InitialContext();
                        wsc = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
                    } catch (Throwable t) {
                        // Do something here
                        logger.fine(rb.getString("exception.thrown") + t);
                    }
                    if(wsc != null) {
View Full Code Here

     * Return the resource object corresponding to the supplied name or throw an illegal argument exception.
     */
    @Override
    public ResourceReferenceDescriptor getResourceReferenceByName(String name) {
        for (Iterator itr = getResourceReferenceDescriptors().iterator(); itr.hasNext();) {
            ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) itr.next();
            if (next.getName().equals(name)) {
                return next;
            }
        }
        throw new IllegalArgumentException("no resource ref of name " + name);
    }
View Full Code Here

    @Override
    public void addResourceReferenceDescriptor(
                            ResourceReferenceDescriptor resourceReference) {

        try {
            ResourceReferenceDescriptor existing =
                getResourceReferenceByName(resourceReference.getName());
            for(InjectionTarget next : resourceReference.getInjectionTargets() ) {
                existing.addInjectionTarget(next);
            }

        } catch(IllegalArgumentException e) {
            if (env != null)
                env.addResourceReferenceDescriptor(resourceReference);
View Full Code Here

            getResourceReferenceDescriptors(boolean resolved) {
        Set<ResourceReferenceDescriptor> toReturn =
            new HashSet<ResourceReferenceDescriptor>();
        for (Iterator itr = getResourceReferenceDescriptors().iterator();
                itr.hasNext();) {
            ResourceReferenceDescriptor next =
                (ResourceReferenceDescriptor) itr.next();
            if (next.isResolved() == resolved) {
                toReturn.add(next);
            }
        }
        return toReturn;
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.ResourceReferenceDescriptor

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.