1 19 20 package org.netbeans.modules.j2ee.ejbfreeform; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 25 import org.netbeans.api.java.project.JavaProjectConstants; 26 import org.netbeans.api.project.ant.AntArtifact; 27 import org.netbeans.spi.project.LookupMerger; 28 import org.netbeans.spi.project.ant.AntArtifactProvider; 29 import org.openide.util.Lookup; 30 31 37 public class LookupMergerImpl implements LookupMerger { 38 39 public LookupMergerImpl() { } 40 41 public Class getMergeableClass() { 42 return AntArtifactProvider.class; 43 } 44 45 public Object merge(Lookup lookup) { 46 return new AntArtifactProviderImpl(lookup); 47 } 48 49 private static class AntArtifactProviderImpl implements AntArtifactProvider { 50 51 private Lookup lkp; 52 53 public AntArtifactProviderImpl(Lookup lookup) { 54 this.lkp = lookup; 55 } 56 57 public AntArtifact[] getBuildArtifacts() { 58 AntArtifactProvider aap = (AntArtifactProvider) lkp.lookup(AntArtifactProvider.class); 59 AntArtifact artifacts[] = aap.getBuildArtifacts(); 60 List ejbArtifactList = new ArrayList (); 61 for (int i = 0; i < artifacts.length; i++) { 62 if (artifacts[i].getType().equals(JavaProjectConstants.ARTIFACT_TYPE_JAR)) { 63 ejbArtifactList.add(new EJBFreeformAntArtifact(artifacts[i])); 64 } 65 } 66 AntArtifact allArtifacts[] = new AntArtifact[artifacts.length + ejbArtifactList.size()]; 67 AntArtifact ejbArtifacts[] = (AntArtifact[]) ejbArtifactList.toArray(new AntArtifact[ejbArtifactList.size()]); 68 System.arraycopy(artifacts, 0, allArtifacts, 0, artifacts.length); 69 System.arraycopy(ejbArtifacts, 0, allArtifacts, artifacts.length, ejbArtifacts.length); 70 return allArtifacts; 71 } 72 73 } 74 75 } 76 | Popular Tags |