Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.ConnectorBase


        assert moduleFile != null : "moduleFile is null";
        assert targetPath != null : "targetPath is null";
        assert !targetPath.endsWith("/") : "targetPath must not end with a '/'";

        String specDD = null;
        ConnectorBase connector = null;
        try {
            if (specDDUrl == null) {
                specDDUrl = JarUtils.createJarURL(moduleFile, "META-INF/ra.xml");
            }

            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
            // on the J2ee management object
            specDD = JarUtils.readAll(specDDUrl);
        } catch (Exception e) {
            if (!moduleFile.getName().endsWith(".rar")) {
                //no ra.xml, not a .rar file, not for us.
                return null;
            }
        }
        //we found ra.xml, if it won't parse it's an error.
        // parse it
        if (specDD != null) {
//            XmlObject xmlObject;
//            try {
//                xmlObject = XmlBeansUtil.parse(specDD);
//                xmlObject = convertToConnectorSchema(xmlObject);
//            } catch (XmlException e) {
//                throw new DeploymentException("Could not read or convert ra.xml with xmlbeans: "  + specDDUrl.toExternalForm(), e);
//            }
//            InputStream in = xmlObject.newInputStream();
            try {
                InputStream in = specDDUrl.openStream();
                try {
                    connector = (ConnectorBase) JaxbJavaee.unmarshal(Connector.class, in);
                } catch (JAXBException e) {
                    in.close();
                    in = specDDUrl.openStream();
                    connector = (ConnectorBase) JaxbJavaee.unmarshal(Connector10.class, in);
                } finally {
                    in.close();
                }
            } catch (SAXException e) {
                throw new DeploymentException("Cannot parse the ra.xml file: " + specDDUrl.toExternalForm(), e);
            } catch (JAXBException e) {
                throw new DeploymentException("Cannot unmarshall the ra.xml file: " + specDDUrl.toExternalForm(), e);
//            } catch (IOException e) {
//                throw new DeploymentException("Cannot read the ra.xml file: " + specDDUrl.toExternalForm(), e);
            } catch (Exception e) {
                throw new DeploymentException("Encountered unknown error parsing the ra.xml file: " + specDDUrl.toExternalForm(), e);
            }
        }
        GerConnectorType gerConnector = null;
        try {
            // load the geronimo connector plan from either the supplied plan or from the earFile
            try {
                if (plan instanceof XmlObject) {
                    gerConnector = (GerConnectorType) SchemaConversionUtils.getNestedObjectAsType((XmlObject) plan,
                            CONNECTOR_QNAME,
                            GerConnectorType.type);
                } else {
                    GerConnectorDocument gerConnectorDoc;
                    ArrayList errors = new ArrayList();
                    if (plan != null) {
                        gerConnectorDoc = GerConnectorDocument.Factory.parse((File) plan, XmlBeansUtil.createXmlOptions(errors));
                    } else {
                        URL path = JarUtils.createJarURL(moduleFile, "META-INF/geronimo-ra.xml");
                        gerConnectorDoc = GerConnectorDocument.Factory.parse(path, XmlBeansUtil.createXmlOptions(errors));
                    }
                    if (errors.size() > 0) {
                        throw new DeploymentException("Could not parse connector doc: " + errors);
                    }
                    if (gerConnectorDoc != null) {
                        gerConnector = gerConnectorDoc.getConnector();
                    }
                }
            } catch (IOException e) {
                //do nothing
            }

            // if we got one extract the validate it otherwise create a default one
            if (gerConnector == null) {
                throw new DeploymentException("A connector module must be deployed using a Geronimo deployment plan" +
                        " (either META-INF/geronimo-ra.xml in the RAR file or a standalone deployment plan passed to the deployer).");
            }
            ConnectorPlanRectifier.rectifyPlan(gerConnector);
            XmlCursor cursor = gerConnector.newCursor();
            try {
                SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            } finally {
                cursor.dispose();
            }

            XmlBeansUtil.validateDD(gerConnector);
        } catch (XmlException e) {
            throw new DeploymentException("Could not parse module descriptor", e);
        }

        EnvironmentType environmentType = gerConnector.getEnvironment();
        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
        if (earEnvironment != null) {
            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
            environment = earEnvironment;
            if (!environment.getConfigId().isResolved()) {
                throw new IllegalStateException("Connector module ID should be fully resolved (not " + environment.getConfigId() + ")");
            }
        } else {
            idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "car");
        }

        AbstractName moduleName;
        if (earName == null) {
            earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
            moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.RESOURCE_ADAPTER_MODULE);
        } else {
            moduleName = naming.createChildName(earName, targetPath, NameFactory.RESOURCE_ADAPTER_MODULE);
        }

        boolean standAlone = earEnvironment == null;
        AnnotatedApp annotatedApp = null;
       
        String name = null;
        if (connector != null && connector.getModuleName() != null) {
            name = connector.getModuleName();
        } else if (standAlone) {
            name = FileUtils.removeExtension(new File(moduleFile.getName()).getName(), ".rar");
        } else {
            name = FileUtils.removeExtension(targetPath, ".rar");
        }
View Full Code Here


            classFinder = new BundleAnnotationFinder(packageAdmin, bundle);
        } catch (Exception e) {
            throw new DeploymentException("could not create class finder for rar bundle " + bundle, e);
        }

        ConnectorBase connector = resourceModule.getSpecDD();
        connector = mergeMetadata(bundle, classFinder, connector);

        addExportPackages(connector, module.getEnvironment(), bundle);

        /*
        The chain of idiotic jsr-77 meaningless objects is:
        ResourceAdapterModule (1)  >
        ResourceAdapter (n, but there can only be 1 resource adapter in a rar, so we use 1) >
        JCAResource (1) >
        JCAConnectionFactory (n) >
        JCAManagedConnectionFactory (1)
        We also include:
        JCAResourceAdapter (n)  (from JCAResource) (actual instance of ResourceAdapter)
        TODO include admin objects (n) from JCAResource presumably
        */
        AbstractName resourceAdapterModuleName = resourceModule.getModuleName();

        AbstractName resourceAdapterjsr77Name = earContext.getNaming().createChildName(resourceAdapterModuleName, module.getName(), NameFactory.RESOURCE_ADAPTER);
        AbstractName jcaResourcejsr77Name = earContext.getNaming().createChildName(resourceAdapterjsr77Name, module.getName(), NameFactory.JCA_RESOURCE);

        //set up the metadata for the ResourceAdapterModule
        GBeanData resourceAdapterModuleData = new GBeanData(resourceAdapterModuleName, ResourceAdapterModuleImplGBean.GBEAN_INFO);
        // initalize the GBean
        if (earContext.getServerName() != null) {
            //app clients don't have a Server gbean
            resourceAdapterModuleData.setReferencePattern(NameFactory.J2EE_SERVER, earContext.getServerName());
            //app clients don't have an application name either
            if (!earContext.getModuleName().equals(resourceAdapterModuleName)) {
                resourceAdapterModuleData.setReferencePattern(NameFactory.J2EE_APPLICATION, earContext.getModuleName());
            }
        }
        resourceAdapterModuleData.setReferencePattern("ResourceAdapter", resourceAdapterjsr77Name);

        resourceAdapterModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
        resourceAdapterModuleData.setAttribute("displayName", connector.getDisplayName());
        resourceAdapterModuleData.setAttribute("description", connector.getDescription());
        resourceAdapterModuleData.setAttribute("vendorName", connector.getVendorName());
        resourceAdapterModuleData.setAttribute("EISType", connector.getEisType());
        resourceAdapterModuleData.setAttribute("resourceAdapterVersion", connector.getResourceAdapterVersion());

        ResourceAdapterBase resourceAdapter = connector.getResourceAdapter();
        // Create the resource adapter gbean
        if (resourceAdapter.getResourceAdapterClass() != null) {
            GBeanInfoBuilder resourceAdapterInfoBuilder = new GBeanInfoBuilder(ResourceAdapterWrapperGBean.class, new MultiGBeanInfoFactory().getGBeanInfo(ResourceAdapterWrapperGBean.class));
            String resourceAdapterClassName = resourceAdapter.getResourceAdapterClass();
            GBeanData resourceAdapterGBeanData = setUpDynamicGBeanWithProperties(resourceAdapterClassName, resourceAdapterInfoBuilder, resourceAdapter.getConfigProperty(), bundle, Collections.<String>emptySet());
View Full Code Here

            List<Class> resourceAdapterClasses = classFinder.findAnnotatedClasses(javax.resource.spi.Connector.class);
            if (resourceAdapterClasses.size() != 1) {
                throw new DeploymentException("Not exactly one resource adapter: " + resourceAdapterClasses);
            }
            raClass = resourceAdapterClasses.get(0);
            connector = new ConnectorBase();
//          connector.setDescriptions(ra.description());
            connector.setMetadataComplete(false);
            connector.setVersion("1.6");
            ResourceAdapterBase resourceAdapter = new ResourceAdapterBase();
            connector.setResourceAdapter(resourceAdapter);
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.ConnectorBase

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.