Package org.apache.geronimo.xml.ns.j2ee.application_1

Examples of org.apache.geronimo.xml.ns.j2ee.application_1.ApplicationType


                null);
    }

    private ApplicationInfo getEarPlan(File planFile, JarFile earFile, ModuleIDBuilder idBuilder) throws DeploymentException {
        String specDD;
        ApplicationType application = null;
        if (earFile != null) {
            try {
                URL applicationXmlUrl = JarUtils.createJarURL(earFile, "META-INF/application.xml");
                specDD = JarUtils.readAll(applicationXmlUrl);
                //we found something called application.xml in the right place, if we can't parse it it's an error
                XmlObject xmlObject = XmlBeansUtil.parse(specDD);
                application = convertToApplicationSchema(xmlObject).getApplication();
            } catch (XmlException e) {
                throw new DeploymentException("Could not parse application.xml", e);
            } catch (Exception e) {
                //ee5 spec allows optional application.xml, continue with application == null
                if (!earFile.getName().endsWith(".ear")) {
                    return null;
                }
                //TODO return application.xml that we can make metadata complete?
            }
        }

        GerApplicationType gerApplication = null;
        try {
            // load the geronimo-application.xml from either the supplied plan or from the earFile
            XmlObject rawPlan;
            try {
                if (planFile != null) {
                    rawPlan = XmlBeansUtil.parse(planFile.toURI().toURL(), getClass().getClassLoader());
                    gerApplication = (GerApplicationType) SchemaConversionUtils.fixGeronimoSchema(rawPlan, APPLICATION_QNAME, GerApplicationType.type);
                    if (gerApplication == null) {
                        return null;
                    }
                } else {
                    URL path = JarUtils.createJarURL(earFile, "META-INF/geronimo-application.xml");
                    rawPlan = XmlBeansUtil.parse(path, getClass().getClassLoader());
                    gerApplication = (GerApplicationType) SchemaConversionUtils.fixGeronimoSchema(rawPlan, APPLICATION_QNAME, GerApplicationType.type);
                }
            } catch (IOException e) {
                //TODO isn't this an error?
            }

            // if we got one extract the validate it otherwise create a default one
            if (gerApplication == null) {
                gerApplication = createDefaultPlan(application, earFile);
            }
        } catch (XmlException e) {
            throw new DeploymentException(e);
        }

        EnvironmentType environmentType = gerApplication.getEnvironment();
        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
        idBuilder.resolve(environment, earFile == null ? planFile.getName() : new File(earFile.getName()).getName(), "ear");
        // Make this EAR's settings the default for child modules
        idBuilder.setDefaultGroup(environment.getConfigId().getGroupId());
        idBuilder.setDefaultVersion(environment.getConfigId().getVersion());

        Artifact artifact = environment.getConfigId();
        AbstractName earName = naming.createRootName(artifact, artifact.toString(), NameFactory.J2EE_APPLICATION);

        // get the modules either the application plan or for a stand alone module from the specific deployer
        // todo change module so you can extract the real module path back out.. then we can eliminate
        // the moduleLocations and have addModules return the modules
        ModuleList moduleLocations = new ModuleList();
        LinkedHashSet<Module> modules = new LinkedHashSet<Module>();
        try {
            addModules(earFile, application, gerApplication, moduleLocations, modules, environment, earName, idBuilder);
            if (application == null && modules.isEmpty()) {
                //if no application.xml and no modules detected, return null for stand-alone module processing
                return null;
            }
        } catch (Throwable e) {
            // close all the modules
            for (Module module : modules) {
                module.close();
            }

            if (e instanceof DeploymentException) {
                throw (DeploymentException) e;
            } else if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            } else if (e instanceof Error) {
                throw (Error) e;
            }
            throw new DeploymentException(e);
        }

        String applicationName = null;
        if (application != null && application.isSetApplicationName()) {
            applicationName = application.getApplicationName().getStringValue().trim();           
        } else if (earFile != null) {
            applicationName = FileUtils.removeExtension(new File(earFile.getName()).getName(), ".ear");
        } else {
            applicationName = artifact.toString();
        }
       
        return new ApplicationInfo(ConfigurationModuleType.EAR,
                environment,
                earName,
                applicationName,
                earFile,
                application,
                gerApplication,
                modules,
                moduleLocations,
                application == null ? null : application.toString());
    }
View Full Code Here


            // Copy over all files that are _NOT_ modules (e.g. META-INF and APP-INF files)
            ModuleList moduleLocations = applicationInfo.getModuleLocations();
            if (ConfigurationModuleType.EAR == applicationType && earFile != null) {
                //get the value of the library-directory element in spec DD
                ApplicationType specDD = (ApplicationType) applicationInfo.getSpecDD();
                String libDir = getLibraryDirectory(specDD);
                ClassPathList libClasspath = new ClassPathList();
                for (Enumeration<JarEntry> e = earFile.entries(); e.hasMoreElements();) {
                    ZipEntry entry = e.nextElement();
                    String entryName = entry.getName();
View Full Code Here

  public JAXBElement createGeronimoApplicationDeploymentPlan(IFile dpFile) throws Exception {
    Trace.tracePoint("Entry",
        "V11DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan", dpFile);

    ObjectFactory applicationFactory = new ObjectFactory();
    ApplicationType application = applicationFactory.createApplicationType();

    application.setApplicationName(getProject().getName());
    application.setEnvironment(getConfigEnvironment());

    JAXBElement jaxbElement = applicationFactory.createApplication(application);
    JAXBUtils.marshalDeploymentPlan(jaxbElement, dpFile);

    Trace.tracePoint("Exit ", "V11DeploymentPlanCreationOperation.createGeronimoApplicationDeploymentPlan",
View Full Code Here

                    environment = plan.getEnvironment();
            }
        }
        else if (GeronimoUtils.isEarModule(module)) {
            if (getApplicationDeploymentPlan(module) != null) {
                ApplicationType plan = getApplicationDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }
        else if (GeronimoUtils.isRARModule(module)) {
            if (getConnectorDeploymentPlan(module) != null) {
                ConnectorType plan = getConnectorDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getEnvironment();
            }
        }else if (GeronimoUtils.isAppClientModule(module)) {
            if (getAppClientDeploymentPlan(module) != null) {
                ApplicationClientType plan = getAppClientDeploymentPlan(module).getValue();
                if (plan != null)
                    environment = plan.getServerEnvironment();
            }
        }

        Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
        return environment;
View Full Code Here

    } else if (isEjbJarModule(module)) {
      OpenejbJarType plan = getOpenEjbDeploymentPlan(module).getValue();
      // if (plan != null)
      // environment = plan.getEnvironment();
    } else if (isEarModule(module)) {
      ApplicationType plan = getApplicationDeploymentPlan(module).getValue();
      if (plan != null)
        environment = plan.getEnvironment();
    } else if (isRARModule(module)) {
      ConnectorType plan = getConnectorDeploymentPlan(module).getValue();
      if (plan != null)
        environment = plan.getEnvironment();
    }
    if (environment != null
              && environment.getModuleId() != null) {
              Trace.tracePoint("EXIT", "GeronimoV11Utils.getConfigId", getQualifiedConfigID(environment.getModuleId()));
              return getQualifiedConfigID(environment.getModuleId());
View Full Code Here

        managedForm.addPart(new GBeanSection(getDeploymentPlan(), JAXBModelUtils.getGbeans(getDeploymentPlan()), body, toolkit, getStyle()));
        managedForm.addPart(new ClassFilterSection(getDeploymentPlan(), JAXBModelUtils.getEnvironment(getDeploymentPlan()), body, toolkit, getStyle(), true, true));
        managedForm.addPart(new ClassFilterSection(getDeploymentPlan(), JAXBModelUtils.getEnvironment(getDeploymentPlan()), body, toolkit, getStyle(), true, false));

        if (ApplicationType.class.isInstance(getDeploymentPlan().getValue())) {
          ApplicationType application = (ApplicationType)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue();
            managedForm.addPart(new ModuleSection(getDeploymentPlan(), body, toolkit, getStyle(), application.getModule()));
            managedForm.addPart(new ExtModuleSection(getDeploymentPlan(), body, toolkit, getStyle(), application.getExtModule()));
        }
        if (ConnectorType.class.isInstance(getDeploymentPlan().getValue())) {
          ConnectorType connector = (ConnectorType)((AbstractGeronimoDeploymentPlanEditor) getEditor()).getDeploymentPlan().getValue();
            managedForm.addPart(new AdminObjectSection(getDeploymentPlan(), body, toolkit, getStyle(), connector.getAdminobject()));
        }
View Full Code Here

    }
   
    public boolean performFinish() {
        ModuleWizardPage page = (ModuleWizardPage) getPages()[0];
        PathType path;
        ExtModuleType extModule;

        if (eObject == null) {
            eObject = getEFactory().create(ExtModuleType.class);
            JAXBElement plan = section.getPlan();

            extModule = (ExtModuleType)eObject;

            List extModuleList = ((ApplicationType)plan.getValue()).getExtModule();
            if (extModuleList == null) {
                extModuleList = (List)getEFactory().create(ExtModuleType.class);
            }
            extModuleList.add(eObject);
        }
        else {
            extModule = (ExtModuleType)eObject;
            extModule.setConnector(null);
            extModule.setEjb(null);
            extModule.setJava(null);
            extModule.setWeb(null);
            extModule.setExternalPath(null);
        }

        // NOTE!! this replaces the call to processEAttributes (page);
        path = (PathType)getEFactory().create(PathType.class);
        path.setValue(page.getTextEntry(0).getText());

        if (((ModuleWizardPage)page).buttonList[0].getSelection())
            extModule.setConnector(path);
        else if (((ModuleWizardPage)page).buttonList[1].getSelection())
            extModule.setEjb(path);
        else if (((ModuleWizardPage)page).buttonList[2].getSelection())
            extModule.setJava(path);
        else if (((ModuleWizardPage)page).buttonList[3].getSelection())
            extModule.setWeb(path);

        if (page.buttonList[4].getSelection()) {
            extModule.setInternalPath (page.getTextEntry(1).getText());
            extModule.setExternalPath(null);
        }
        else if (page.buttonList[5].getSelection()) {
         
          StringBuilder sb = new StringBuilder();
            for (int i = 2; i < 6; i++) {
                String value = page.getTextEntry(i).getText();
                 sb.append(value).append("/");
            }
            //remove last "/"
            sb.deleteCharAt(sb.length()-1);
           
            //for 1.1 external path is in this format: groupid/artifactid/version/type
            extModule.setExternalPath(sb.toString());

            extModule.setInternalPath(null);
        }

        if (section.getViewer().getInput() == section.getPlan()) {
            section.getViewer().setInput(section.getInput());
        }
View Full Code Here

        }

        public void createControl(Composite parent) {
            Composite composite = createComposite(parent);
            GridData data;
            ExtModuleType extModule = (ExtModuleType)eObject;
           
            // First we need a set of radio buttons to determine what kind of module we are
            // dealing with.
            Group group = new Group (composite, SWT.NONE);
            Button button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.connector);
            buttonList[0] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.ejb);
            buttonList[1] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.java);
            buttonList[2] = button;
            button = new Button (group, SWT.RADIO);
            button.setText(CommonMessages.web);
            buttonList[3] = button;
            GridLayout gridLayout = new GridLayout();
            gridLayout.numColumns = 4;
            group.setLayout(gridLayout);
            data = new GridData();
            data.horizontalAlignment = GridData.FILL;
            data.grabExcessHorizontalSpace = true;
            data.horizontalSpan = 2;
            group.setLayoutData(data);
           
            Group group2 = new Group (composite, SWT.NONE);
            for (int i = 1; i < section.getTableColumnNames().length; i++) {
                if (i == 2) {
                    button = new Button (group2, SWT.RADIO);
                    button.setText(CommonMessages.internalPath);
                    buttonList[4] = button;
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    data.horizontalSpan = 2;
                    button.setLayoutData(data);
                }
                if (i == 3) {
                    button = new Button (group2, SWT.RADIO);
                    button.setText(CommonMessages.externalPath);
                    buttonList[5] = button;
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    data.horizontalSpan = 2;
                    button.setLayoutData(data);
                }
                Text text;

                if (i == 1) {
                    Label label = new Label(group, SWT.LEFT);
                    String columnName = section.getTableColumnNames()[i];
                    if (!columnName.endsWith(":"))
                        columnName = columnName.concat(":");
                    label.setText(columnName);
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    label.setLayoutData(data);

                    text = new Text(group, SWT.SINGLE | SWT.BORDER);
                    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
                            | GridData.VERTICAL_ALIGN_FILL);
                    data.grabExcessHorizontalSpace = true;
                    data.widthHint = 100;
                    data.horizontalSpan = 3;
                    text.setLayoutData(data);
                }
                else {
                    Label label = new Label(group2, SWT.LEFT);
                    String columnName = section.getTableColumnNames()[i];
                    if (!columnName.endsWith(":"))
                        columnName = columnName.concat(":");
                    label.setText(columnName);
                    data = new GridData();
                    data.horizontalAlignment = GridData.FILL;
                    label.setLayoutData(data);

                    text = new Text(group2, SWT.SINGLE | SWT.BORDER);
                    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
                            | GridData.VERTICAL_ALIGN_FILL);
                    data.grabExcessHorizontalSpace = true;
                    data.widthHint = 100;
                    text.setLayoutData(data);
                }

                if (extModule != null) {
                    if (i == 1) {
                        if (extModule.getConnector() != null) {
                            text.setText(extModule.getConnector().getValue());
                            buttonList[0].setSelection(true);
                        }
                        else if (extModule.getEjb() != null) {
                            text.setText(extModule.getEjb().getValue());
                            buttonList[1].setSelection(true);
                        }
                        else if (extModule.getJava() != null) {
                            text.setText(extModule.getJava().getValue());
                            buttonList[2].setSelection(true);
                        }
                        else if (extModule.getWeb() != null) {
                            text.setText(extModule.getWeb().getValue());
                            buttonList[3].setSelection(true);
                        }                       
                    }
                    else if (i == 2 && extModule.getInternalPath() != null) {
                        text.setText(extModule.getInternalPath());
                    }
                    else if (i > 2 && extModule.getExternalPath() != null) {
                        String value= extModule.getExternalPath();
                        text.setText(value);
//            try {
//              value = (String) JAXBUtils.getValue(pattern,getTableColumnEAttributes()[i]);
//            } catch (Exception e1) {
//              value = e1.getMessage();
//            }
//                        if (value != null) {
//                            text.setText(value);
//                        }
                    }
                }
                textEntries[i - 1] = text;
            }
            gridLayout = new GridLayout();
            gridLayout.numColumns = 2;
            group2.setLayout(gridLayout);
            data = new GridData();
            data.horizontalAlignment = GridData.FILL;
            data.grabExcessHorizontalSpace = true;
            data.horizontalSpan = 2;
            group2.setLayoutData(data);

            buttonList[4].addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (buttonList[4].getSelection()) {
                       toggle();
                    }
                }
            });
            buttonList[5].addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (buttonList[5].getSelection()) {
                        toggle();
                    }
                }
            });

            if (extModule == null) {
                buttonList[0].setSelection(true);
                buttonList[4].setSelection(true);
            }
            else if (extModule.getInternalPath() != null) {
                buttonList[4].setSelection(true);
            }
            else {
                buttonList[5].setSelection(true);
            }
View Full Code Here

    public ITableLabelProvider getLabelProvider() {
        return new LabelProvider() {
            @Override
            public String getColumnText(Object element, int columnIndex) {
                if (ExtModuleType.class.isInstance(element)) {
                  ExtModuleType extModule = (ExtModuleType) element;
                    switch (columnIndex) {
                    case 0:
                        if (extModule.getConnector() != null) {
                            return "connector";
                        } else if (extModule.getEjb() != null) {
                            return "ejb";
                        } else if (extModule.getJava() != null) {
                            return "java";
                        } else if (extModule.getWeb() != null) {
                            return "web";
                        }
                        return "";
                    case 1:
                        if (extModule.getConnector() != null) {
                            return extModule.getConnector().getValue();
                        } else if (extModule.getEjb() != null) {
                            return extModule.getEjb().getValue();
                        } else if (extModule.getJava() != null) {
                            return extModule.getJava().getValue();
                        } else if (extModule.getWeb() != null) {
                            return extModule.getWeb().getValue();
                        }
                        return "";
                    case 2:
                        if (extModule.getInternalPath() != null) {
                            return extModule.getInternalPath();
                        }
                        return "";
                    case 3:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[0];
                        }
                        return "";
                    case 4:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[1];
                        }
                        return "";
                    case 5:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[2];
                        }
                        return "";
                    case 6:
                        if (extModule.getExternalPath() != null) {
                          String externalPath = extModule.getExternalPath();
                          //suppose external path is in format of "groupId/artifactId/version/type"
                          String[] segments = externalPath.split("/");
                            return segments[3];
                        }
                        return "";
View Full Code Here

    }

    public boolean performFinish() {
        AbstractTableWizardPage page = (AbstractTableWizardPage) getPages()[0];
        PathType path;
        ModuleType module;

        if (eObject == null) {
            eObject = getEFactory().create(ModuleType.class);
            JAXBElement plan = section.getPlan();

            module = (ModuleType)eObject;

            List moduleList = ((ApplicationType)plan.getValue()).getModule();
            if (moduleList == null) {
                moduleList = (List)getEFactory().create(ModuleType.class);
            }
            moduleList.add(eObject);
        }
        else {
            module = (ModuleType)eObject;
            module.setConnector(null);
            module.setEjb(null);
            module.setJava(null);
            module.setWeb(null);
        }

        // NOTE!! this replaces the call to processEAttributes (page);
        path = (PathType)getEFactory().create(PathType.class);
        path.setValue(page.getTextEntry(0).getText());

        if (((ModuleWizardPage)page).buttonList[0].getSelection())
            module.setConnector(path);
        else if (((ModuleWizardPage)page).buttonList[1].getSelection())
            module.setEjb(path);
        else if (((ModuleWizardPage)page).buttonList[2].getSelection())
            module.setJava(path);
        else if (((ModuleWizardPage)page).buttonList[3].getSelection())
            module.setWeb(path);
       
        String altDD = page.getTextEntry(1).getText();
        path = (PathType)getEFactory().create(PathType.class);
        path.setValue(altDD);
        module.setAltDd(path);
       
        if (section.getViewer().getInput() == section.getPlan()) {
            section.getViewer().setInput(section.getInput());
        }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.xml.ns.j2ee.application_1.ApplicationType

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.