org.eclipse.jst.j2ee.ejb_1.1.505.v201202020200

16:45:45.041 INFO  jd.cli.Main - Decompiling org.eclipse.jst.j2ee.ejb_1.1.505.v201202020200.jar
package org.eclipse.jst.j2ee.ejb.archiveoperations;

import org.eclipse.jst.j2ee.internal.ejb.archiveoperations.EjbClientProjectCreationDataModelProvider;
import org.eclipse.jst.j2ee.project.facet.IJavaUtilityProjectCreationDataModelProperties;

public abstract interface IEjbClientProjectCreationDataModelProperties
  extends IJavaUtilityProjectCreationDataModelProperties
{
  public static final Class _provider_class = EjbClientProjectCreationDataModelProvider.class;
  public static final String EJB_PROJECT_NAME = "IEjbClientProjectCreationDataModelProperties.EJB_PROJECT_NAME";
  public static final String CLIENT_URI = "IEjbClientProjectCreationDataModelProperties.CLIENT_URI ";
  public static final String ADD_TO_EAR = "IJ2EEFacetInstallDataModelProperties.ADD_TO_EAR";
  public static final String DEFAULT_OUTPUT_FOLDER = "IEjbClientProjectCreationDataModelProperties.DEFAULT_OUTPUT_FOLDER";
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.archiveoperations.IEjbClientProjectCreationDataModelProperties
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.componentcore.util;

import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jst.j2ee.application.ApplicationFactory;
import org.eclipse.jst.j2ee.application.ApplicationPackage;
import org.eclipse.jst.j2ee.application.Module;
import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit;
import org.eclipse.jst.j2ee.ejb.EJBJar;
import org.eclipse.jst.j2ee.ejb.EJBResource;
import org.eclipse.jst.j2ee.ejb.EjbFactory;
import org.eclipse.jst.j2ee.ejb.internal.plugin.EjbPlugin;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.common.XMLResource;
import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper;
import org.eclipse.jst.j2ee.internal.ejb.archiveoperations.EJBComponentLoadStrategyImpl;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.wst.common.componentcore.ArtifactEdit;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.ModuleCoreNature;
import org.eclipse.wst.common.componentcore.UnresolveableURIException;
import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel;
import org.eclipse.wst.common.componentcore.internal.BinaryComponentHelper;
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
import org.eclipse.wst.common.componentcore.internal.util.IArtifactEditFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;

public class EJBArtifactEdit
  extends EnterpriseArtifactEdit
  implements IArtifactEditFactory
{
  private static final String EJB_CONTENT_TYPE = "org.eclipse.jst.j2ee.ejbDD";
  public static final Class ADAPTER_TYPE = EJBArtifactEdit.class;
  
  public EJBArtifactEdit() {}
  
  public EJBArtifactEdit(IVirtualComponent aModule)
  {
    super(aModule);
  }
  
  protected BinaryComponentHelper initBinaryComponentHelper(IVirtualComponent binaryModule)
  {
    return new JavaEEBinaryComponentHelper(binaryModule);
  }
  
  public EJBArtifactEdit(IProject aProject, boolean toAccessAsReadOnly)
    throws IllegalArgumentException
  {
    super(aProject, toAccessAsReadOnly);
  }
  
  public EJBArtifactEdit(IProject aProject, boolean toAccessAsReadOnly, boolean forCreate)
    throws IllegalArgumentException
  {
    super(aProject, toAccessAsReadOnly, forCreate, "jst.ejb");
  }
  
  public EJBArtifactEdit(ArtifactEditModel model)
  {
    super(model);
  }
  
  public EJBArtifactEdit(ModuleCoreNature aNature, IVirtualComponent aModule, boolean toAccessAsReadOnly)
  {
    super(aNature, aModule, toAccessAsReadOnly);
  }
  
  public EJBResource getEJBJarXmiResource()
  {
    verifyOperationSupported();
    return (EJBResource)getDeploymentDescriptorResource();
  }
  
  public IVirtualFolder getDeploymentDescriptorFolder()
    throws CoreException
  {
    IVirtualResource[] resources = getComponent().getRootFolder().members();
    if ((resources != null) && (resources.length > 0)) {
      for (int i = 0; i < resources.length; i++)
      {
        IVirtualResource resource = resources[i];
        if (resource.getType() == 32)
        {
          IVirtualFolder folder = (IVirtualFolder)resource;
          IVirtualResource ddResource = folder.findMember("ejb-jar.xml");
          if (ddResource != null) {
            return folder;
          }
        }
      }
    }
    return null;
  }
  
  public String getEjbModuleRelative(String fullPath)
    throws CoreException
  {
    if ((fullPath != null) && 
      (getDeploymentDescriptorFolder() != null))
    {
      String modulePath;
      String modulePath;
      if (fullPath.indexOf('/') == 0) {
        modulePath = getDeploymentDescriptorFolder().getProjectRelativePath().removeTrailingSeparator().removeLastSegments(1).toOSString();
      } else {
        modulePath = getDeploymentDescriptorFolder().getProjectRelativePath().removeTrailingSeparator().removeLastSegments(1).makeRelative().toOSString();
      }
      int indx = fullPath.indexOf(modulePath) + modulePath.length() + 1;
      if (fullPath.indexOf(modulePath) != -1) {
        return fullPath.substring(indx);
      }
    }
    return fullPath;
  }
  
  public int getJ2EEVersion()
  {
    verifyOperationSupported();
    return getEJBJarXmiResource().getJ2EEVersionID();
  }
  
  public boolean hasEJBClientJARProject()
  {
    verifyOperationSupported();
    if (getEJBClientJarModule() != null) {
      return true;
    }
    return false;
  }
  
  public Module createNewModule()
  {
    verifyOperationSupported();
    if (isBinary()) {
      throwAttemptedBinaryEditModelAccess();
    }
    return ((ApplicationPackage)EPackage.Registry.INSTANCE.getEPackage("application.xmi")).getApplicationFactory().createEjbModule();
  }
  
  public IVirtualComponent getEJBClientJarModule()
  {
    verifyOperationSupported();
    EJBJar jar = getEJBJar();
    IVirtualComponent ejbClientComponent = null;
    IVirtualComponent ejbComponent = ComponentCore.createComponent(getProject());
    if (ejbComponent == null) {
      return null;
    }
    Properties props = ejbComponent.getMetaProperties();
    String clientCompName = props.getProperty("ClientProject");
    if ((clientCompName != null) && (!clientCompName.equals("")))
    {
      IVirtualReference vRef = ejbComponent.getReference(clientCompName);
      if (vRef != null) {
        ejbClientComponent = vRef.getReferencedComponent();
      }
    }
    else
    {
      String clientJAR = null;
      if (jar != null) {
        clientJAR = jar.getEjbClientJar();
      }
      if (clientJAR != null)
      {
        clientJAR = clientJAR.substring(0, clientJAR.length() - 4);
        ejbComponent = ComponentCore.createComponent(getProject());
        if (ejbComponent == null) {
          return null;
        }
        IVirtualReference ref = ejbComponent.getReference(clientJAR);
        if (ref != null) {
          ejbClientComponent = ref.getReferencedComponent();
        }
      }
    }
    return ejbClientComponent;
  }
  
  public Resource getDeploymentDescriptorResource()
  {
    verifyOperationSupported();
    if (isBinary()) {
      return getBinaryComponentHelper().getResource(J2EEConstants.EJBJAR_DD_URI_OBJ);
    }
    return getArtifactEditModel().getResource(J2EEConstants.EJBJAR_DD_URI_OBJ);
  }
  
  public EJBJar getEJBJar()
  {
    verifyOperationSupported();
    return (EJBJar)getDeploymentDescriptorRoot();
  }
  
  public EObject getDeploymentDescriptorRoot()
  {
    verifyOperationSupported();
    Resource res = getDeploymentDescriptorResource();
    List contents = res.getContents();
    if (contents.size() > 0) {
      return (EObject)contents.get(0);
    }
    if (isBinary()) {
      return null;
    }
    if (!WorkbenchResourceHelper.getFile(res).exists()) {
      return null;
    }
    addEJBJarIfNecessary((EJBResource)getDeploymentDescriptorResource());
    return (EObject)contents.get(0);
  }
  
  public int getDeploymentDescriptorType()
  {
    return 3;
  }
  
  protected void addEJBJarIfNecessary(XMLResource aResource)
  {
    if (isBinary()) {
      throwAttemptedBinaryEditModelAccess();
    }
    if (aResource != null)
    {
      if ((aResource.getContents() == null) || (aResource.getContents().isEmpty()))
      {
        EJBJar ejbJar = EjbFactory.eINSTANCE.createEJBJar();
        aResource.getContents().add(ejbJar);
      }
      EJBJar ejbJar = (EJBJar)aResource.getContents().get(0);
      URI moduleURI = getArtifactEditModel().getModuleURI();
      try
      {
        ejbJar.setDisplayName(StructureEdit.getDeployedName(moduleURI));
      }
      catch (UnresolveableURIException localUnresolveableURIException) {}
      aResource.setID(ejbJar, "ejb-jar_ID");
      try
      {
        if (aResource.isModified()) {
          aResource.saveIfNecessary();
        }
      }
      catch (Exception e)
      {
        EjbPlugin.logError(e);
      }
    }
  }
  
  public static EJBArtifactEdit getEJBArtifactEditForRead(IProject aProject)
  {
    EJBArtifactEdit artifactEdit = null;
    try
    {
      if (isValidEJBModule(ComponentCore.createComponent(aProject))) {
        artifactEdit = new EJBArtifactEdit(aProject, true, false);
      }
    }
    catch (Exception localException)
    {
      artifactEdit = null;
    }
    return artifactEdit;
  }
  
  public static EJBArtifactEdit getEJBArtifactEditForWrite(IProject aProject)
  {
    EJBArtifactEdit artifactEdit = null;
    try
    {
      if (isValidEJBModule(ComponentCore.createComponent(aProject))) {
        artifactEdit = new EJBArtifactEdit(aProject, false, false);
      }
    }
    catch (Exception localException)
    {
      artifactEdit = null;
    }
    return artifactEdit;
  }
  
  public static EJBArtifactEdit getEJBArtifactEditForRead(IVirtualComponent aModule)
  {
    if (aModule == null) {
      return null;
    }
    if (aModule.isBinary()) {
      return new EJBArtifactEdit(aModule);
    }
    return getEJBArtifactEditForRead(aModule.getProject());
  }
  
  public static EJBArtifactEdit getEJBArtifactEditForWrite(IVirtualComponent aModule)
  {
    if ((aModule == null) || (aModule.isBinary())) {
      return null;
    }
    return getEJBArtifactEditForWrite(aModule.getProject());
  }
  
  public static boolean isValidEJBModule(IVirtualComponent aModule)
    throws UnresolveableURIException
  {
    if (!isValidEditableModule(aModule)) {
      return false;
    }
    return JavaEEProjectUtilities.isEJBProject(aModule.getProject());
  }
  
  public EObject createModelRoot()
  {
    verifyOperationSupported();
    if (isBinary()) {
      throwAttemptedBinaryEditModelAccess();
    }
    return createModelRoot(getJ2EEVersion());
  }
  
  public EObject createModelRoot(int version)
  {
    verifyOperationSupported();
    if (isBinary()) {
      throwAttemptedBinaryEditModelAccess();
    }
    EJBResource res = (EJBResource)getDeploymentDescriptorResource();
    res.setModuleVersionID(version);
    addEJBJarIfNecessary(res);
    return ((EJBResource)getDeploymentDescriptorResource()).getRootObject();
  }
  
  public ArtifactEdit createArtifactEditForRead(IVirtualComponent aComponent)
  {
    return getEJBArtifactEditForRead(aComponent);
  }
  
  public ArtifactEdit createArtifactEditForWrite(IVirtualComponent aComponent)
  {
    return getEJBArtifactEditForWrite(aComponent);
  }
  
  public Archive asArchive(boolean includeSource, boolean includeClasspathComponents)
    throws OpenFailureException
  {
    if (isBinary())
    {
      JavaEEBinaryComponentHelper helper = (JavaEEBinaryComponentHelper)getBinaryComponentHelper();
      return helper.accessLegacyArchive();
    }
    EJBComponentLoadStrategyImpl loader = new EJBComponentLoadStrategyImpl(getComponent(), includeClasspathComponents);
    loader.setExportSource(includeSource);
    String uri = ModuleURIUtil.getHandleString(getComponent());
    return CommonarchiveFactory.eINSTANCE.openEJBJarFile(loader, uri);
  }
  
  /* Error */
  public static void createDeploymentDescriptor(IProject project, int version)
  {
    // Byte code:
    //   0: new 7	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit
    //   3: dup
    //   4: aload_0
    //   5: iconst_0
    //   6: iconst_1
    //   7: invokespecial 463	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:<init>	(Lorg/eclipse/core/resources/IProject;ZZ)V
    //   10: astore_2
    //   11: aload_2
    //   12: iload_1
    //   13: invokevirtual 452	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:createModelRoot	(I)Lorg/eclipse/emf/ecore/EObject;
    //   16: pop
    //   17: aload_2
    //   18: aconst_null
    //   19: invokevirtual 451	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:save	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   22: goto +40 -> 62
    //   25: astore_3
    //   26: aload_2
    //   27: invokevirtual 453	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:getDeploymentDescriptorResource	()Lorg/eclipse/emf/ecore/resource/Resource;
    //   30: astore 4
    //   32: aload_0
    //   33: invokestatic 447	org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase:getResourceSet	(Lorg/eclipse/core/resources/IProject;)Lorg/eclipse/emf/ecore/resource/ResourceSet;
    //   36: invokeinterface 514 1 0
    //   41: aload 4
    //   43: invokeinterface 510 2 0
    //   48: pop
    //   49: aload 4
    //   51: invokeinterface 512 1 0
    //   56: aload_2
    //   57: invokevirtual 449	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:dispose	()V
    //   60: aload_3
    //   61: athrow
    //   62: aload_2
    //   63: invokevirtual 453	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:getDeploymentDescriptorResource	()Lorg/eclipse/emf/ecore/resource/Resource;
    //   66: astore 4
    //   68: aload_0
    //   69: invokestatic 447	org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase:getResourceSet	(Lorg/eclipse/core/resources/IProject;)Lorg/eclipse/emf/ecore/resource/ResourceSet;
    //   72: invokeinterface 514 1 0
    //   77: aload 4
    //   79: invokeinterface 510 2 0
    //   84: pop
    //   85: aload 4
    //   87: invokeinterface 512 1 0
    //   92: aload_2
    //   93: invokevirtual 449	org/eclipse/jst/j2ee/componentcore/EnterpriseArtifactEdit:dispose	()V
    //   96: return
    // Line number table:
    //   Java source line #583	-> byte code offset #0
    //   Java source line #585	-> byte code offset #11
    //   Java source line #586	-> byte code offset #17
    //   Java source line #587	-> byte code offset #25
    //   Java source line #588	-> byte code offset #26
    //   Java source line #589	-> byte code offset #32
    //   Java source line #590	-> byte code offset #49
    //   Java source line #591	-> byte code offset #56
    //   Java source line #592	-> byte code offset #60
    //   Java source line #588	-> byte code offset #62
    //   Java source line #589	-> byte code offset #68
    //   Java source line #590	-> byte code offset #85
    //   Java source line #591	-> byte code offset #92
    //   Java source line #593	-> byte code offset #96
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	97	0	project	IProject
    //   0	97	1	version	int
    //   10	83	2	ejbEdit	EnterpriseArtifactEdit
    //   25	36	3	localObject	Object
    //   30	20	4	newRes	Resource
    //   66	20	4	newRes	Resource
    // Exception table:
    //   from	to	target	type
    //   11	25	25	finally
  }
  
  public IModelProvider create(IProject project)
  {
    return getEJBArtifactEditForRead(project);
  }
  
  public IModelProvider create(IVirtualComponent component)
  {
    return getEJBArtifactEditForRead(component);
  }
  
  /* Error */
  public void modify(Runnable runnable, IPath modelPath)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_0
    //   2: invokevirtual 462	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getProject	()Lorg/eclipse/core/resources/IProject;
    //   5: invokestatic 481	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getEJBArtifactEditForWrite	(Lorg/eclipse/core/resources/IProject;)Lorg/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit;
    //   8: invokevirtual 471	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:setWritableEdit	(Lorg/eclipse/wst/common/componentcore/ArtifactEdit;)V
    //   11: aload_1
    //   12: invokeinterface 499 1 0
    //   17: aload_0
    //   18: invokevirtual 470	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getWritableEdit	()Lorg/eclipse/wst/common/componentcore/ArtifactEdit;
    //   21: ifnull +35 -> 56
    //   24: aload_0
    //   25: invokevirtual 470	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getWritableEdit	()Lorg/eclipse/wst/common/componentcore/ArtifactEdit;
    //   28: new 218	org/eclipse/core/runtime/NullProgressMonitor
    //   31: dup
    //   32: invokespecial 446	org/eclipse/core/runtime/NullProgressMonitor:<init>	()V
    //   35: invokevirtual 491	org/eclipse/wst/common/componentcore/ArtifactEdit:saveIfNecessary	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   38: goto +18 -> 56
    //   41: astore_3
    //   42: aload_0
    //   43: invokevirtual 470	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getWritableEdit	()Lorg/eclipse/wst/common/componentcore/ArtifactEdit;
    //   46: invokevirtual 490	org/eclipse/wst/common/componentcore/ArtifactEdit:dispose	()V
    //   49: aload_0
    //   50: aconst_null
    //   51: invokevirtual 471	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:setWritableEdit	(Lorg/eclipse/wst/common/componentcore/ArtifactEdit;)V
    //   54: aload_3
    //   55: athrow
    //   56: aload_0
    //   57: invokevirtual 470	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getWritableEdit	()Lorg/eclipse/wst/common/componentcore/ArtifactEdit;
    //   60: invokevirtual 490	org/eclipse/wst/common/componentcore/ArtifactEdit:dispose	()V
    //   63: aload_0
    //   64: aconst_null
    //   65: invokevirtual 471	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:setWritableEdit	(Lorg/eclipse/wst/common/componentcore/ArtifactEdit;)V
    //   68: return
    // Line number table:
    //   Java source line #605	-> byte code offset #0
    //   Java source line #607	-> byte code offset #11
    //   Java source line #608	-> byte code offset #17
    //   Java source line #610	-> byte code offset #24
    //   Java source line #613	-> byte code offset #41
    //   Java source line #614	-> byte code offset #42
    //   Java source line #615	-> byte code offset #49
    //   Java source line #616	-> byte code offset #54
    //   Java source line #614	-> byte code offset #56
    //   Java source line #615	-> byte code offset #63
    //   Java source line #617	-> byte code offset #68
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	69	0	this	EJBArtifactEdit
    //   0	69	1	runnable	Runnable
    //   0	69	2	modelPath	IPath
    //   41	14	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   11	41	41	finally
  }
  
  protected String getContentTypeDescriber()
  {
    return "org.eclipse.jst.j2ee.ejbDD";
  }
  
  protected URI getRootURI()
  {
    return J2EEConstants.EJBJAR_DD_URI_OBJ;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.datamodel.properties;

import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties;

public abstract interface IEJBComponentExportDataModelProperties
  extends IJ2EEComponentExportDataModelProperties
{}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.datamodel.properties.IEJBComponentExportDataModelProperties
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.datamodel.properties;

import org.eclipse.jst.j2ee.datamodel.properties.IJ2EEModuleImportDataModelProperties;

public abstract interface IEJBComponentImportDataModelProperties
  extends IJ2EEModuleImportDataModelProperties
{}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.datamodel.properties.IEJBComponentImportDataModelProperties
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.deployables;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
import org.eclipse.jst.j2ee.ejb.EJBJar;
import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
import org.eclipse.jst.j2ee.ejb.internal.plugin.EjbPlugin;
import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.jst.server.core.EJBBean;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IModuleArtifact;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.util.NullModuleArtifact;

public class EJBDeployableArtifactAdapterUtil
{
  public static IModuleArtifact getModuleObject(Object obj)
  {
    if (obj == null) {
      return null;
    }
    if ((obj instanceof EJBJar)) {
      return getModuleObject((EJBJar)obj);
    }
    if ((obj instanceof EnterpriseBean)) {
      return getModuleObject((EnterpriseBean)obj);
    }
    if ((obj instanceof IProject)) {
      return getModuleObject((IProject)obj);
    }
    if ((obj instanceof IJavaProject)) {
      return getModuleObject(((IJavaProject)obj).getProject());
    }
    if ((obj instanceof IFile)) {
      return getModuleObject((IFile)obj);
    }
    if ((obj instanceof ICompilationUnit)) {
      return getModuleObject((ICompilationUnit)obj);
    }
    return null;
  }
  
  protected static boolean hasInterestedComponents(IProject project)
  {
    return JavaEEProjectUtilities.isEJBProject(project);
  }
  
  protected static IModuleArtifact getModuleObject(ICompilationUnit cu)
  {
    try
    {
      IFile file = (IFile)cu.getCorrespondingResource();
      IProject project = file.getProject();
      if (hasInterestedComponents(project)) {
        return getModuleJavaObject(file);
      }
    }
    catch (JavaModelException e)
    {
      EjbPlugin.logError(e);
    }
    return null;
  }
  
  protected static IModuleArtifact getModuleObject(EJBJar ejbJar)
  {
    IModule dep = getModule(ejbJar);
    return createModuleObject(dep, null, false, false);
  }
  
  protected static IModuleArtifact getModuleObject(EnterpriseBean ejb)
  {
    IModule dep = getModule(ejb);
    return createModuleObject(dep, ejb.getName(), ejb.hasRemoteClient(), ejb.hasLocalClient());
  }
  
  protected static IModuleArtifact getModuleObject(IProject project)
  {
    if (hasInterestedComponents(project))
    {
      IModule dep = getModule(project, null);
      return createModuleObject(dep, null, false, false);
    }
    return null;
  }
  
  protected static IModuleArtifact getModuleObject(IFile file)
  {
    IVirtualResource[] resources = ComponentCore.createResources(file);
    IVirtualComponent component = null;
    if ((resources[0] != null) || (resources.length <= 0)) {
      component = resources[0].getComponent();
    }
    if (hasInterestedComponents(file.getProject()))
    {
      String ext = file.getFileExtension();
      if (("java".equals(ext)) || ("class".equals(ext))) {
        return getModuleJavaObject(file);
      }
      if (file.getProjectRelativePath().toString().endsWith("META-INF/ejb-jar.xml")) {
        return createModuleObject(getModule(file.getProject(), component), null, false, false);
      }
    }
    return null;
  }
  
  protected static IModule getModule(EObject refObject)
  {
    IProject proj = ProjectUtilities.getProject(refObject);
    if (proj == null) {
      return null;
    }
    Resource refResource = refObject.eResource();
    IVirtualResource[] resources = (IVirtualResource[])null;
    IVirtualComponent component = null;
    try
    {
      IResource eclipeServResoruce = WorkbenchResourceHelper.getFile(refResource);
      resources = ComponentCore.createResources(eclipeServResoruce);
      if (resources[0] != null) {
        component = resources[0].getComponent();
      }
    }
    catch (Exception e)
    {
      EjbPlugin.logError(e);
    }
    return getModule(proj, component);
  }
  
  protected static IModule getModule(IProject project, IVirtualComponent component)
  {
    IModule deployable = null;
    Iterator iterator = Arrays.asList(ServerUtil.getModules("jst.ejb")).iterator();
    String componentName = null;
    if (component != null) {
      componentName = component.getName();
    }
    while (iterator.hasNext())
    {
      Object next = iterator.next();
      if ((next instanceof IModule))
      {
        deployable = (IModule)next;
        if (deployable.getName().equals(componentName)) {
          return deployable;
        }
      }
    }
    return null;
  }
  
  protected static IModule getModuleProject(IProject project, Iterator iterator)
  {
    IModule deployable = null;
    while (iterator.hasNext())
    {
      Object next = iterator.next();
      if ((next instanceof IModule))
      {
        deployable = (IModule)next;
        if (deployable.getProject().equals(project)) {
          return deployable;
        }
      }
    }
    return null;
  }
  
  protected static IModuleArtifact getModuleJavaObject(IFile file)
  {
    IVirtualComponent comp = (IVirtualComponent)file.getAdapter(IVirtualComponent.class);
    if (comp != null)
    {
      JavaClass javaClass = JemProjectUtilities.getJavaClass(file);
      if (javaClass != null)
      {
        EJBArtifactEdit edit = null;
        try
        {
          edit = EJBArtifactEdit.getEJBArtifactEditForRead(comp);
          EJBJar jar = edit.getEJBJar();
          if (jar != null)
          {
            EnterpriseBean ejb = jar.getEnterpriseBeanWithReference(javaClass);
            return createModuleObject(getModule(comp.getProject(), comp), ejb.getName(), isRemote(ejb, javaClass), isLocal(ejb, javaClass));
          }
        }
        finally
        {
          if (edit != null) {
            edit.dispose();
          }
        }
        if (edit != null) {
          edit.dispose();
        }
      }
    }
    return null;
  }
  
  protected static boolean isRemote(EnterpriseBean ejb, JavaClass javaClass)
  {
    if ((javaClass.equals(ejb.getHomeInterface())) || (javaClass.equals(ejb.getRemoteInterface()))) {
      return true;
    }
    return false;
  }
  
  protected static boolean isLocal(EnterpriseBean ejb, JavaClass javaClass)
  {
    if ((javaClass.equals(ejb.getLocalHomeInterfaceName())) || (javaClass.equals(ejb.getLocalInterface()))) {
      return true;
    }
    return false;
  }
  
  protected static IModuleArtifact createModuleObject(IModule module, String ejbName, boolean remote, boolean local)
  {
    if (module != null)
    {
      String jndiName = null;
      if (ejbName != null)
      {
        module.loadAdapter(ModuleDelegate.class, new NullProgressMonitor());
        J2EEFlexProjDeployable moduleDelegate = (J2EEFlexProjDeployable)module.getAdapter(ModuleDelegate.class);
        jndiName = moduleDelegate.getJNDIName(ejbName);
        return new EJBBean(module, jndiName, remote, local);
      }
      return new NullModuleArtifact(module);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.deployables.EJBDeployableArtifactAdapterUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.deployables;

public abstract interface IEJBModuleArtifact {}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.deployables.IEJBModuleArtifact
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.modulecore.util;

import org.eclipse.core.resources.IProject;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jst.j2ee.ejb.EJBJar;
import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;

public class EJBArtifactEditUtilities
{
  public static IVirtualComponent getEJBComponent(EnterpriseBean bean)
  {
    IProject project = ProjectUtilities.getProject(bean);
    IVirtualComponent component = ComponentCore.createComponent(project);
    if (component == null) {
      return null;
    }
    EJBArtifactEdit edit = null;
    try
    {
      if (JavaEEProjectUtilities.isEJBProject(component.getProject()))
      {
        edit = EJBArtifactEdit.getEJBArtifactEditForRead(component);
        EJBJar jar = edit.getEJBJar();
        if (jar.getEnterpriseBeanNamed(bean.getName()) != null) {
          return component;
        }
      }
    }
    finally
    {
      if (edit != null) {
        edit.dispose();
      }
    }
    if (edit != null) {
      edit.dispose();
    }
    return null;
  }
  
  /* Error */
  public static EJBJar getEJBJar(IVirtualComponent comp)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aconst_null
    //   3: astore_2
    //   4: aload_0
    //   5: invokestatic 68	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getEJBArtifactEditForRead	(Lorg/eclipse/wst/common/componentcore/resources/IVirtualComponent;)Lorg/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit;
    //   8: astore_1
    //   9: aload_1
    //   10: ifnull +22 -> 32
    //   13: aload_1
    //   14: invokevirtual 67	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:getEJBJar	()Lorg/eclipse/jst/j2ee/ejb/EJBJar;
    //   17: astore_2
    //   18: goto +14 -> 32
    //   21: astore_3
    //   22: aload_1
    //   23: ifnull +7 -> 30
    //   26: aload_1
    //   27: invokevirtual 66	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:dispose	()V
    //   30: aload_3
    //   31: athrow
    //   32: aload_1
    //   33: ifnull +7 -> 40
    //   36: aload_1
    //   37: invokevirtual 66	org/eclipse/jst/j2ee/ejb/componentcore/util/EJBArtifactEdit:dispose	()V
    //   40: aload_2
    //   41: areturn
    // Line number table:
    //   Java source line #45	-> byte code offset #0
    //   Java source line #46	-> byte code offset #2
    //   Java source line #48	-> byte code offset #4
    //   Java source line #49	-> byte code offset #9
    //   Java source line #50	-> byte code offset #13
    //   Java source line #51	-> byte code offset #21
    //   Java source line #52	-> byte code offset #22
    //   Java source line #53	-> byte code offset #26
    //   Java source line #54	-> byte code offset #30
    //   Java source line #52	-> byte code offset #32
    //   Java source line #53	-> byte code offset #36
    //   Java source line #55	-> byte code offset #40
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	42	0	comp	IVirtualComponent
    //   1	36	1	edit	EJBArtifactEdit
    //   3	38	2	ejbJar	EJBJar
    //   21	10	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   4	21	21	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.modulecore.util.EJBArtifactEditUtilities
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.modulecore.util;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.wst.common.componentcore.ArtifactEdit;
import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel;

public class EJBEditAdapterFactory
  implements IAdapterFactory
{
  public Object getAdapter(Object adaptableObject, Class adapterType)
  {
    if ((adapterType == EJBArtifactEdit.ADAPTER_TYPE) || (adapterType == ArtifactEdit.ADAPTER_TYPE))
    {
      ArtifactEditModel editModel = (ArtifactEditModel)adaptableObject;
      if (JavaEEProjectUtilities.isEJBProject(editModel.getProject())) {
        return new EJBArtifactEdit((ArtifactEditModel)adaptableObject);
      }
    }
    return null;
  }
  
  public Class[] getAdapterList()
  {
    return new Class[] { ArtifactEdit.class, EJBArtifactEdit.class };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.modulecore.util.EJBEditAdapterFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.operations;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.codegen.jet.JETException;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException;

public class AddEjbTimerClassOperation
  extends NewEnterpriseBeanClassOperation
{
  protected static final String TEMPLATE_FILE = "/templates/ejbtimer.javajet";
  
  public AddEjbTimerClassOperation(IDataModel dataModel)
  {
    super(dataModel);
  }
  
  protected void generateUsingTemplates(IProgressMonitor monitor, IPackageFragment fragment)
    throws WFTWrappedException, CoreException
  {
    AddEjbTimerTemplateModel tempModel = new AddEjbTimerTemplateModel(model);
    try
    {
      if (fragment != null)
      {
        EjbTimerTemplate tempImpl = EjbTimerTemplate.create(null);
        try
        {
          Method method = tempImpl.getClass().getMethod("generate", 
            new Class[] { Object.class });
          String source = (String)method.invoke(tempImpl, new Object[] { tempModel });
          String javaFileName = tempModel.getClassName() + ".java";
          createJavaFile(monitor, fragment, source, javaFileName);
        }
        catch (SecurityException e)
        {
          throw new JETException(e);
        }
        catch (NoSuchMethodException e)
        {
          throw new JETException(e);
        }
        catch (IllegalArgumentException e)
        {
          throw new JETException(e);
        }
        catch (IllegalAccessException e)
        {
          throw new JETException(e);
        }
        catch (InvocationTargetException e)
        {
          throw new JETException(e);
        }
      }
    }
    catch (Exception e)
    {
      throw new WFTWrappedException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.operations.AddEjbTimerClassOperation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.operations;

import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;

class AddEjbTimerDataModelProvider$1
  extends AddEnterpriseBeanOperation
{
  AddEjbTimerDataModelProvider$1(AddEjbTimerDataModelProvider paramAddEjbTimerDataModelProvider, IDataModel $anonymous0)
  {
    super($anonymous0);
  }
  
  protected NewJavaEEArtifactClassOperation getNewClassOperation()
  {
    return new AddEjbTimerClassOperation(getDataModel());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.operations.AddEjbTimerDataModelProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.operations;

import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBCreationResourceHandler;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;

public class AddEjbTimerDataModelProvider
  extends NewEnterpriseBeanClassDataModelProvider
{
  public static final String SCHEDULE = "AddEjbTimer.SCHEDULE";
  
  public IDataModelOperation getDefaultOperation()
  {
    new AddEnterpriseBeanOperation(getDataModel())
    {
      protected NewJavaEEArtifactClassOperation getNewClassOperation()
      {
        return new AddEjbTimerClassOperation(getDataModel());
      }
    };
  }
  
  public Set<String> getPropertyNames()
  {
    Set<String> propertyNames = super.getPropertyNames();
    
    propertyNames.add("AddEjbTimer.SCHEDULE");
    
    return propertyNames;
  }
  
  public Object getDefaultProperty(String propertyName)
  {
    if (propertyName.equals("AddEjbTimer.SCHEDULE")) {
      return EJBCreationResourceHandler.timerScheduleDefault;
    }
    return super.getDefaultProperty(propertyName);
  }
  
  public IStatus validate(String propertyName)
  {
    if ("INewEnterpriseBeanClassDataModelProperties.EJB_NAME".equals(propertyName)) {
      return null;
    }
    if ("AddEjbTimer.SCHEDULE".equals(propertyName))
    {
      String value = (String)getProperty("AddEjbTimer.SCHEDULE");
      if ((value == null) || (value.trim().length() == 0)) {
        return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.errorTimerScheduleMissing);
      }
    }
    IStatus status = super.validate(propertyName);
    return status;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.j2ee.ejb.internal.operations.AddEjbTimerDataModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.j2ee.ejb.internal.operations;

import java.util.Collection;
imp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd