Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.Connector


        }
        return definition;
    }

    public static Connector readConnector(URL url) throws OpenEJBException {
        Connector connector;
        try {
            connector = (Connector) JaxbJavaee.unmarshalJavaee(Connector.class, IO.read(url));
        } catch (JAXBException e) {
            try {
                Connector10 connector10 = (Connector10) JaxbJavaee.unmarshalJavaee(Connector10.class, IO.read(url));
View Full Code Here


            // DEVELOPERS NOTE:  if you change the id generation code here, you must change
            // the id generation code in ConfigurationFactory.configureApplication(AppModule appModule)
            //

            for (ConnectorModule connectorModule : appModule.getConnectorModules()) {
                Connector connector = connectorModule.getConnector();

                ResourceAdapter resourceAdapter = connector.getResourceAdapter();
                if (resourceAdapter.getResourceAdapterClass() != null) {
                    String resourceAdapterId;
                    if (resourceAdapter.getId() != null) {
                        resourceAdapterId = resourceAdapter.getId();
                    } else {
View Full Code Here

                    application = (Application) obj;
                    setId(application, method);

                } else if (obj instanceof Connector) {

                    final Connector connector = (Connector) obj;
                    setId(connector, method);
                    appModule.getConnectorModules().add(new ConnectorModule(connector));

                } else if (obj instanceof Persistence) {
View Full Code Here

                        application = (Application) modules;

                    } else if (modules instanceof Connector) {

                        final Connector connector = (Connector) modules;
                        appModule.getConnectorModules().add(new ConnectorModule(connector));

                    } else if (modules instanceof Persistence) {

                        final Persistence persistence = (Persistence) modules;
View Full Code Here

            // DEVELOPERS NOTE:  if you change the id generation code here, you must change
            // the id generation code in ConfigurationFactory.configureApplication(AppModule appModule)
            //

            for (ConnectorModule connectorModule : appModule.getResourceModules()) {
                Connector connector = connectorModule.getConnector();

                ResourceAdapter resourceAdapter = connector.getResourceAdapter();
                if (resourceAdapter.getResourceAdapterClass() != null) {
                    String resourceAdapterId;
                    if (resourceAdapter.getId() != null) {
                        resourceAdapterId = resourceAdapter.getId();
                    } else {
View Full Code Here

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

        String specDD = null;
        Connector 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) {
            try {
                InputStream in = specDDUrl.openStream();
                try {
                    connector = (Connector) JaxbJavaee.unmarshalJavaee(Connector.class, in);
                } catch (JAXBException e) {
                    in.close();
                    in = specDDUrl.openStream();
                    Connector10 connector10 = (Connector10) JaxbJavaee.unmarshalJavaee(Connector10.class, in);
                    connector = Connector.newConnector(connector10);
                } 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 (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 (parentModule == null) {
            AbstractName 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(parentModule.getModuleName(), targetPath, NameFactory.RESOURCE_ADAPTER_MODULE);
        }

        boolean standAlone = earEnvironment == null;

        String name;
        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);
        }

        Connector 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());

        org.apache.openejb.jee.ResourceAdapter 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).asSubclass(ResourceAdapter.class);
            connector = new Connector();
//          connector.setDescriptions(ra.description());
            connector.setMetadataComplete(false);
            connector.setVersion("1.6");
            org.apache.openejb.jee.ResourceAdapter resourceAdapter = new org.apache.openejb.jee.ResourceAdapter();
            connector.setResourceAdapter(resourceAdapter);
View Full Code Here

        rarFile = unpack(rarFile);
        baseUrl = getFileUrl(rarFile);

        // read the ra.xml file
        Map<String, URL> descriptors = getDescriptors(baseUrl);
        Connector connector = null;
        URL rarXmlUrl = descriptors.get("ra.xml");
        if (rarXmlUrl != null){
            connector = ReadDescriptors.readConnector(rarXmlUrl);
        }
View Full Code Here

        Object data = connectorModule.getAltDDs().get("ra.xml");
        if (data instanceof Connector) {
            connectorModule.setConnector((Connector) data);
        } else if (data instanceof URL) {
            URL url = (URL) data;
            Connector connector = readConnector(url);
            connectorModule.setConnector(connector);
        } else {
            DeploymentLoader.logger.debug("No ra.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + connectorModule.getModuleId());
            connectorModule.setConnector(new Connector());
        }
    }
View Full Code Here

TOP

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

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.