Package org.apache.tuscany.sca.contribution.jee

Examples of org.apache.tuscany.sca.contribution.jee.ExternalEarInfo


    }

    public <T> T resolveModel(final Class<T> modelClass, T unresolved) {
        URI uri = ((ExternalEarInfo)unresolved).getAppInfo().getUri();
        if (uri != null) {
            ExternalEarInfo resolved = (ExternalEarInfo) map.get(uri);
            if (resolved != null) {
                return modelClass.cast(resolved);
            } else {
                // if you don't care about application composites you can
                // simply read the EAR directly
                /*               
                try {
                    File f = new File(uri.toString());
                    final JavaEEApplicationInfo o = jeeIntrospector.introspectJeeArchive(f.toURI().toURL());
                    return (T)new ExternalEarInfo() {
                        public JavaEEApplicationInfo getAppInfo() {
                            return (JavaEEApplicationInfo)o;
                        }
                    };
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                */
               
                // if you do care about the application composite you
                // need to process the ear as a contribution
                try{
                    // find the location of the ear using a very specific algorithm
                    URL earLocation = null;
                    if ( uri.toString().equals("itest-contribution-jee-samples-13-ear-nonenhanced.ear")){                      
                        earLocation = new File("../contribution-jee-samples/ear-nonenhanced/target/itest-contribution-jee-samples-13-ear-nonenhanced.ear").toURL();
                    } else if ( uri.toString().equals("./itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear")){                      
                        earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit/target/itest-contribution-jee-samples-29-ear-appcomp-contrib-implicit.ear").toURL();
                    } else if ( uri.toString().equals("itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear")){                      
                        earLocation = new File("../contribution-jee-samples/ear-appcomp-contrib-implicit-war-appcomp/target/itest-contribution-jee-samples-30-ear-appcomp-contrib-implicit-war-appcomp.ear").toURL();                       
                    } else {
                        return unresolved;
                    }
                   
                    // if you do care about application composites we have
                    // to process the EAR as a contribution
                    Contribution contribution = contributionService.contribute(uri.toString(), earLocation, false);
                   
                    JavaEEApplicationInfo appInfo = null;
                    Composite appComposite = null;
                   
                    // get the ear info
                    for (Artifact artifact : contribution.getArtifacts()){
                        if (artifact.getModel() instanceof JavaEEApplicationInfo){
                            appInfo = (JavaEEApplicationInfo)artifact.getModel();
                        }
                       
                        if (artifact.getURI().equals("META-INF/application.composite")){
                            appComposite = (Composite)artifact.getModel();
                        }
                    }
                                      
                   
                    final JavaEEApplicationInfo returnAppInfo = appInfo;
                    final Composite returnAppComposite = appComposite;
                   
                    return (T)new ExternalEarInfo() {
                        public JavaEEApplicationInfo getAppInfo() {
                            return returnAppInfo;
                        }
                        public Composite getAppComposite() {
                            return returnAppComposite;
View Full Code Here


        // Resolve the component type
        String uri = implementation.getURI();
        String archive = implementation.getArchive();
        if (uri != null) {
            Object moduleInfo = null;
            ExternalEarInfo extEar = null;           
            if(uri.equals("")) {
                if(moduleInfo == null) {
                    WebModuleInfo unresolved = new WebModuleInfoImpl();
                    unresolved.setUri(URI.create(archive));
                    WebModuleInfo resolved = resolver.resolveModel(WebModuleInfo.class, unresolved);
                    if(unresolved != resolved) {
                        moduleInfo = resolved;
                    }
                }
                if(moduleInfo == null) {
                    EjbModuleInfo unresolved = new EjbModuleInfoImpl();
                    unresolved.setUri(URI.create(archive));
                    EjbModuleInfo resolved = resolver.resolveModel(EjbModuleInfo.class, unresolved);
                    if(unresolved != resolved) {
                        moduleInfo = resolved;
                    }
                }
                if(moduleInfo == null) {
                    JavaEEApplicationInfo unresolved = new JavaEEApplicationInfoImpl();
                    unresolved.setUri(URI.create(archive));
                    JavaEEApplicationInfo resolved = resolver.resolveModel(JavaEEApplicationInfo.class, unresolved);
                    if(unresolved != resolved) {
                        moduleInfo = resolved;
                    }
                }
            } else if(uri.endsWith(".war")) {
                WebModuleInfo webModuleInfo = new WebModuleInfoImpl();
                webModuleInfo.setUri(URI.create(archive));
                webModuleInfo = resolver.resolveModel(WebModuleInfo.class, webModuleInfo);
                moduleInfo = webModuleInfo;
            } else if(uri.endsWith(".jar")) {
                EjbModuleInfo ejbModuleInfo = new EjbModuleInfoImpl();
                ejbModuleInfo.setUri(URI.create(archive));
                ejbModuleInfo = resolver.resolveModel(EjbModuleInfo.class, ejbModuleInfo);
                moduleInfo = ejbModuleInfo;
            } else if(uri.endsWith(".ear")) {
                final JavaEEApplicationInfo appInfo = new JavaEEApplicationInfoImpl();
                appInfo.setUri(URI.create(archive));
                ExternalEarInfo unresolved = new ExternalEarInfo() {
                    public JavaEEApplicationInfo getAppInfo() {
                        return appInfo;
                    }
                    public Composite getAppComposite() {
                        return null;
                    }};

                ExternalEarInfo resolved = resolver.resolveModel(ExternalEarInfo.class, unresolved);
                if(resolved != unresolved) {
                    extEar = resolved;
                }
                moduleInfo = resolved.getAppInfo();               
            }
           
            if(moduleInfo instanceof WebModuleInfo) {
                // Check for web composite
                ModelObject unresolved = new ModelObjectImpl();
                unresolved.setUri(URI.create("WEB-INF/web.composite"));
                ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
                if(resolved != unresolved) {
                    // Found web composite so the war itself must have been the contribution
                    Composite appComposite = (Composite)resolved.getObject();
                    mergeCompositeInfo(appComposite, implementation);
                }

                // TODO: Obtain includeDefaults value from the composite
                boolean includeDefaults = false;
               
                if(includeDefaults || resolved == unresolved) {
                    // there is either no application composite or we are ignoring it as the
                    // war is nested inside another contribution
                    if(jeeOptionalExtension != null) {
                        jeeOptionalExtension.createImplementationJeeComposite((WebModuleInfo)moduleInfo, implementation);
                    }
                    // now resolve the implementation composite as a real composite.
                    compositeProcessor.resolve((Composite)implementation, resolver);
                }
            } else if(moduleInfo instanceof EjbModuleInfo) {
                // Check for ejb-jar composite
                ModelObject unresolved = new ModelObjectImpl();
                unresolved.setUri(URI.create("META-INF/ejb-jar.composite"));
                ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
                if(resolved != unresolved) {
                    // Found ejb-jar composite so the ejb jar itself must have been the contribution
                    Composite appComposite = (Composite)resolved.getObject();
                    mergeCompositeInfo(appComposite, implementation);
                }

                // TODO: Obtain includeDefaults value from the composite
                boolean includeDefaults = false;
               
                if(includeDefaults || resolved == unresolved) {
                    if(jeeExtension != null) {
                        jeeExtension.createImplementationJeeComposite((EjbModuleInfo)moduleInfo, implementation);

                    }
                    if(jeeOptionalExtension != null) {
                        jeeOptionalExtension.createImplementationJeeComposite((EjbModuleInfo)moduleInfo, implementation);
                    }
                    // now resolve the implementation composite as a real composite.
                    compositeProcessor.resolve((Composite)implementation, resolver);
                }
            } else if(moduleInfo instanceof JavaEEApplicationInfo) {
                // Check for application composite
                Composite appComposite = null;
                if(extEar != null) {
                    appComposite = extEar.getAppComposite();
                } else {
                    ModelObject unresolved = new ModelObjectImpl();
                    unresolved.setUri(URI.create("META-INF/application.composite"));
                    ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
                    if(resolved != unresolved) {
                       // Found application composite
                       appComposite = (Composite)resolved.getObject();
                    }
                }
               
                if(appComposite != null) {
                    // Found application composite so copy it's details across into
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.jee.ExternalEarInfo

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.