Package com.sun.enterprise.deployment

Examples of com.sun.enterprise.deployment.ResourceReferenceDescriptor


        if(!(resRef.isEmpty()))
        {
            Iterator it = resRef.iterator();
            while (it.hasNext())
            {
                ResourceReferenceDescriptor resDesc = ((ResourceReferenceDescriptor)it.next());
                String refName = resDesc.getName();
                if(refName == null || refName.length()==0)
                    {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName()+".failed",
                            "FAILED [AS-EJB resource-ref] : resource-ref has empty res-ref-name"));
View Full Code Here


        if(!(resRef.isEmpty()))
        {
            Iterator it = resRef.iterator();
            while (it.hasNext())
            {
                ResourceReferenceDescriptor resDesc = (ResourceReferenceDescriptor)it.next();
                String refName = resDesc.getName();
               
             try
                    {
                        descriptor.getResourceReferenceByName(refName);
                        addGoodDetails(result, compName);
View Full Code Here

    {
        validatePool();
        PoolManager poolmgr = Switch.getSwitch().getPoolManager();
  boolean resourceShareable = true;

  ResourceReferenceDescriptor ref =  poolmgr.getResourceReference(jndiNameToUse);
  if (ref != null) {
      String shareableStr = ref.getSharingScope();

      // MQ resource adapter doesnt support connection sharing. Disabling it
      // for the moment.
            if (shareableStr.equals(ref.RESOURCE_UNSHAREABLE)) {
                resourceShareable = false;
            }
        }

        if (ref == null) {
            _logger.log(Level.FINE,"poolmgr.no_resource_reference",jndiNameToUse);
            return internalGetConnection(mcf, defaultPrin, cxRequestInfo,
                resourceShareable, jndiNameToUse, conn, true);
        }
        String auth = ref.getAuthorization();
 
        if (auth.equals(ref.APPLICATION_AUTHORIZATION) ) {
      if (cxRequestInfo == null ) {
                StringManager localStrings =
                    StringManager.getManager(ConnectionManagerImpl.class);
          String msg = localStrings.getString(
        "con_mgr.null_userpass");
          throw new ResourceException( msg );
      }
            ConnectorRuntime.getRuntime().switchOnMatching(rarName, poolName);
            return internalGetConnection(mcf, null, cxRequestInfo,
                resourceShareable, jndiNameToUse, conn, false );
        } else {
            ResourcePrincipal prin =null;
            Set principalSet =null;
            Principal callerPrincipal = null;
            SecurityContext securityContext = null;
            ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
            if(connectorRuntime.isServer() &&
             (securityContext = SecurityContext.getCurrent()) != null &&
       (callerPrincipal = securityContext.getCallerPrincipal()) != null &&
       (principalSet = securityContext.getPrincipalSet()) != null) {
                AuthenticationService authService =
                    connectorRuntime.getAuthenticationService(rarName,poolName);
                if(authService != null) {
                    prin = (ResourcePrincipal)authService.mapPrincipal(
                            callerPrincipal, principalSet);
                }
            }

            if (prin == null) {
                prin = ref.getResourcePrincipal();
                if (prin == null) {
                    _logger.log(Level.FINE,"default-resource-principal not" +
                    "specified for " + jndiNameToUse + ". Defaulting to" +
        " user/password specified in the pool");
View Full Code Here

        return valid;
    }

    boolean validJndiName(String refJndiName, String refName,WebBundleDescriptor descriptor){
        boolean valid =true;
        ResourceReferenceDescriptor resDesc;

        if(refJndiName !=null && refJndiName.length()!=0) {
          //descriptor.getResourceReferenceByName(name);
          resDesc = descriptor.getResourceReferenceByName(refName);
                        String type = resDesc.getType();
                        if(type.indexOf("javax.jms")>-1) //jms resource
                        {
                            if(!refJndiName.startsWith("jms/"))
                              valid=false;
View Full Code Here

  Result result = getInitializedResult();
  ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

        try{
            EjbBundleDescriptor ejbBundleDesc = descriptor.getEjbBundleDescriptor();
            ResourceReferenceDescriptor cmpResource = ejbBundleDesc.getCMPResourceReference();
           
            if(cmpResource!=null){
//                String jndiName = cmpResource.getJndiName();
                String jndiName = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/jndi-name");
                if(jndiName == null || jndiName.length()==0){
                    oneFailed=true;//4698046
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString(getClass().getName()+".failed",
                        "FAILED [AS-EJB cmp-resource] : jndi-name cannot be an empty string"));
                }else{
                    if(jndiName.startsWith("jdbc/")|| jndiName.startsWith("jdo/")) {
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName()+".passed",
                            "PASSED [AS-EJB cmp-resource] : jndi-name is {0}",new Object[]{jndiName}));
                    }else{
                        oneWarning=true;//4698046
                        addWarningDetails(result, compName);
                        result.warning(smh.getLocalString(getClass().getName()+".warning",
                            "WARNING [AS-EJB cmp-resource] : The jndi-name  is {0}, the preferred jndi-name should start with  jdbc/ or jdo/"
                            , new Object[]{jndiName}));
                    }
                }

                ResourcePrincipal defPrincipal = cmpResource.getResourcePrincipal();
                if(defPrincipal!=null){
//                    String name = defPrincipal.getName();
                    String name = getXPathValue("sun-ejb-jar/enterprise-beans/cmp-resource/default-resource-principal/name");
                    if( name == null || name.length()==0){
                        oneFailed=true; //4698046
View Full Code Here

     * @return <code>Result</code> the results for this assertion
     */
    public Result check(WebBundleDescriptor descriptor) {

        Set resourceRefs;
        ResourceReferenceDescriptor resrefDes;
        Iterator itr;
        String resrefName;
  Result result = getInitializedResult();
  ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        //boolean foundIt = false;
        boolean oneFailed = false;
        boolean notApp = false;
       
  if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
           
      // get the Resource Reference Descriptors set
      resourceRefs = descriptor.getResourceReferenceDescriptors();
      itr = resourceRefs.iterator();
      // test the Resource Reference Descriptor
      while (itr.hasNext()) {
    resrefDes = (ResourceReferenceDescriptor)itr.next();
    resrefName = resrefDes.getName();
                if (resrefName.length() != 0) {
                    //                 foundIt  = true;
        result.addGoodDetails(smh.getLocalString
               ("tests.componentNameConstructor",
          "For [ {0} ]",
View Full Code Here

     * @return <code>Result</code> the results for this assertion
     */
    public Result check(WebBundleDescriptor descriptor) {

        Set resourceRefs;
        ResourceReferenceDescriptor resrefDes;
        Iterator itr;
        String resAuth;
  Result result = getInitializedResult();
  ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        boolean oneFailed = false;
       
  if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
           
      // get the Resource Reference Descriptors set
      resourceRefs = descriptor.getResourceReferenceDescriptors();
      itr = resourceRefs.iterator();
      // test the Resource Reference Descriptor
      while (itr.hasNext()) {
    resrefDes = (ResourceReferenceDescriptor)itr.next();
    resAuth = resrefDes.getAuthorization();
                if (resAuth.equals("Application") || resAuth.equals("Container")) {
        result.addGoodDetails(smh.getLocalString
               ("tests.componentNameConstructor",
          "For [ {0} ]",
          new Object[] {compName.toString()}));
View Full Code Here

   private void processAppBundle(EjbBundleDescriptor bundle) {
           if (!bundle.containsCMPEntity()) {
                return;
            }

            ResourceReferenceDescriptor cmpResource =
                    bundle.getCMPResourceReference();

            // If this bundle's beans are not created by Java2DB, then skip to
            // next bundle.
            if (!DeploymentHelper.isJavaToDatabase(
                    cmpResource.getSchemaGeneratorProperties())) {
                return;
            }
     
            boolean createTables = getCreateTablesValue(cmpResource) ;                  
            boolean dropTables = getDropTablesValue(cmpResource);

            if (debug) {               
                logger.fine("ejb.CMPProcessor.createanddroptables", //NOI18N
                    new Object[] {new Boolean(createTables), new Boolean(dropTables)});
            }

            if (!createTables && !dropTables) {
                // Nothing to do.
                return;
            }
       
            // At this point of time we are sure that we would need to create
            // the sql/jdbc files required to create or drop objects from the
            // database. Hence setup the required directories from the info object.
            setApplicationLocation();
            setGeneratedLocation();
           
            constructJdbcFileNames(bundle);
            if (debug) {
                logger.fine("ejb.CMPProcessor.createanddropfilenames",
                    createJdbcFileName, dropJdbcFileName); //NOI18N           
            }           

            String resourceName = cmpResource.getJndiName();
            if (dropTables) {
                executeStatements(dropJdbcFileName, resourceName);
            } else {
                // else can only be createTables as otherwise we'll not reach here
                executeStatements(createJdbcFileName, resourceName);
View Full Code Here

            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(
                ejbcContext, 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) {
                    DeploymentStatus status =
                        ejbcContext.getDeploymentRequest()
                        .getCurrentDeploymentStatus();
                    status.setStageStatus(DeploymentStatus.WARNING);
                    String msg = status.getStageStatusMessage();
                    msg = (msg == null) ? warning : (msg + "\n" + warning); // NOI18N
                    status.setStageStatusMessage(msg);
                }
            }
              
            // 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

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.