org.eclipse.jst.jee_1.0.402.v201202021530

16:45:48.280 INFO  jd.cli.Main - Decompiling org.eclipse.jst.jee_1.0.402.v201202021530.jar
package org.eclipse.jst.jee;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
import org.osgi.framework.BundleContext;

public class JEEPlugin
  extends WTPPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.jst.jee";
  private static JEEPlugin plugin;
  private JEEPreferences preferences = null;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static JEEPlugin getDefault()
  {
    return plugin;
  }
  
  public String getPluginID()
  {
    return "org.eclipse.jst.jee";
  }
  
  public JEEPreferences getJEEPreferences()
  {
    if (preferences == null) {
      preferences = new JEEPreferences(this);
    }
    return preferences;
  }
  
  protected void initializeDefaultPluginPreferences()
  {
    getJEEPreferences().initializeDefaultPreferences();
  }
  
  public static IStatus createStatus(int severity, String message, Throwable exception)
  {
    return new Status(severity, "org.eclipse.jst.jee", message, exception);
  }
  
  public static IStatus createStatus(int severity, String message)
  {
    return createStatus(severity, message, null);
  }
  
  public static void logError(Throwable exception)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.jst.jee")).log(createStatus(4, exception.getMessage(), exception));
  }
  
  public static void logError(CoreException exception)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.jst.jee")).log(exception.getStatus());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.JEEPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee;

public abstract interface JEEPreferences$Keys {}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.JEEPreferences.Keys
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee;

import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;

public class JEEPreferences
{
  private Plugin owner = null;
  private Preferences preferences = null;
  private boolean persistOnChange = false;
  
  public JEEPreferences(Plugin owner)
  {
    this.owner = owner;
  }
  
  protected void initializeDefaultPreferences() {}
  
  public void firePreferenceChanged()
  {
    if (isPersistOnChange()) {
      persist();
    }
  }
  
  public void persist()
  {
    getOwner().savePluginPreferences();
  }
  
  public boolean isPersistOnChange()
  {
    return persistOnChange;
  }
  
  public void setPersistOnChange(boolean persistOnChange)
  {
    this.persistOnChange = persistOnChange;
  }
  
  public Preferences getPreferences()
  {
    if (preferences == null) {
      preferences = getOwner().getPluginPreferences();
    }
    return preferences;
  }
  
  private Plugin getOwner()
  {
    return owner;
  }
  
  public boolean getBoolean(String name)
  {
    return getPreferences().getBoolean(name);
  }
  
  public void setValue(String name, boolean value)
  {
    getPreferences().setValue(name, value);
    firePreferenceChanged();
  }
  
  public static abstract interface Keys {}
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.JEEPreferences
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.contenttype;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;

public final class JEE6ContentDescriber
  implements IContentDescriber
{
  public static final QualifiedName JEEVERSION = new QualifiedName("jee-version", "5.0");
  
  public int describe(InputStream contents, IContentDescription description)
    throws IOException
  {
    JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(contents);
    switch (quickPeek.getType())
    {
    case 1: 
    case 3: 
      switch (quickPeek.getVersion())
      {
      case 60: 
        return 2;
      }
      return 0;
    case 0: 
      switch (quickPeek.getVersion())
      {
      case 31: 
        return 2;
      }
      return 0;
    case 4: 
      switch (quickPeek.getVersion())
      {
      case 30: 
        return 2;
      }
      return 0;
    case 6: 
      switch (quickPeek.getVersion())
      {
      case 30: 
        return 2;
      }
      return 0;
    case 2: 
      switch (quickPeek.getVersion())
      {
      case 16: 
        return 2;
      }
      return 0;
    }
    return 0;
  }
  
  public QualifiedName[] getSupportedOptions()
  {
    return new QualifiedName[] { JEEVERSION };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.contenttype.JEE6ContentDescriber
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.contenttype;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;

public final class JEEContentDescriber
  implements IContentDescriber
{
  public static final QualifiedName JEEVERSION = new QualifiedName("jee-version", "5.0");
  
  public int describe(InputStream contents, IContentDescription description)
    throws IOException
  {
    JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(contents);
    switch (quickPeek.getType())
    {
    case 1: 
    case 3: 
      switch (quickPeek.getVersion())
      {
      case 50: 
        return 2;
      }
      return 0;
    case 0: 
      switch (quickPeek.getVersion())
      {
      case 30: 
        return 2;
      }
      return 0;
    case 4: 
      switch (quickPeek.getVersion())
      {
      case 25: 
        return 2;
      }
      return 0;
    }
    return 0;
  }
  
  public QualifiedName[] getSupportedOptions()
  {
    return new QualifiedName[] { JEEVERSION };
  }
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFactory;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.web.internal.deployables.FlatComponentDeployable;

public class JEEDeployableFactory
  extends J2EEDeployableFactory
{
  public static final String JEE_ID = "org.eclipse.jst.jee.server";
  public static JEEDeployableFactory JEE_INSTANCE;
  
  public static JEEDeployableFactory jeeInstance()
  {
    if (JEE_INSTANCE == null) {
      ensureFactoryLoaded("org.eclipse.jst.jee.server");
    }
    return JEE_INSTANCE;
  }
  
  public void initialize()
  {
    super.initialize();
    if (getId().equals("org.eclipse.jst.jee.server")) {
      JEE_INSTANCE = this;
    }
  }
  
  protected FlatComponentDeployable createModuleDelegate(IProject project, IVirtualComponent component)
  {
    return new JEEFlexProjDeployable(project, component);
  }
  
  protected boolean canHandleProject(IProject p)
  {
    IVirtualComponent comp = ComponentCore.createComponent(p);
    return (JavaEEProjectUtilities.usesJavaEEComponent(comp)) && (J2EEProjectUtilities.isJEEProject(p));
  }
  
  protected FlatComponentDeployable getNestedDelegate(IVirtualComponent component)
  {
    return new JEEFlexProjDeployable(component.getProject(), component);
  }
}

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

import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper;
import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.ModelProviderManager;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.jst.javaee.ejb.EJBJar;
import org.eclipse.jst.javaee.ejb.EnterpriseBeans;
import org.eclipse.jst.javaee.ejb.SessionBean;
import org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.server.core.IModule;

public class JEEFlexProjDeployable
  extends J2EEFlexProjDeployable
{
  public JEEFlexProjDeployable(IProject project, IVirtualComponent aComponent)
  {
    super(project, aComponent);
  }
  
  public JEEFlexProjDeployable(IProject project)
  {
    super(project);
  }
  
  protected IModule gatherModuleReference(IVirtualComponent component, IChildModuleReference child)
  {
    if (!child.isBinary()) {
      return super.gatherModuleReference(component, child);
    }
    return JEEDeployableFactory.jeeInstance().createChildModule(this, child);
  }
  
  public String getJNDIName(String ejbName, String interfaceName)
  {
    if (!JavaEEProjectUtilities.isEJBProject(component.getProject())) {
      return null;
    }
    EjbModuleExtensionHelper modHelper = null;
    EJBJar jar = null;
    
    IModelProvider model = ModelProviderManager.getModelProvider(component.getProject());
    if (model != null)
    {
      jar = (EJBJar)model.getModelObject();
      SessionBean bean = getSessionBeanNamed(jar, ejbName);
      modHelper = IEJBModelExtenderManager.INSTANCE.getEJBModuleExtension(null);
      return modHelper == null ? null : modHelper.getJavaEEJNDIName(jar, bean, interfaceName);
    }
    return null;
  }
  
  public SessionBean getSessionBeanNamed(EJBJar jar, String beanName)
  {
    EnterpriseBeans allBeans = jar.getEnterpriseBeans();
    for (Iterator iterator = allBeans.getSessionBeans().iterator(); iterator.hasNext();)
    {
      SessionBean bean = (SessionBean)iterator.next();
      if (bean.getEjbName().equals(beanName)) {
        return bean;
      }
    }
    return null;
  }
}

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

import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.javaee.applicationclient.ApplicationClient;
import org.eclipse.jst.javaee.applicationclient.ApplicationClientDeploymentDescriptor;
import org.eclipse.jst.javaee.applicationclient.ApplicationclientFactory;
import org.eclipse.jst.javaee.applicationclient.IApplicationClientResource;
import org.eclipse.jst.javaee.core.DisplayName;
import org.eclipse.jst.javaee.core.JavaeeFactory;

public class AppClient5ModelProvider
  extends JEE5ModelProvider
{
  private static final String APPCLIENT5_CONTENT_TYPE = "org.eclipse.jst.jee.ee5appclientDD";
  
  public AppClient5ModelProvider(IProject proj)
  {
    this.proj = proj;
    setDefaultResourcePath(new Path("META-INF/application-client.xml"));
  }
  
  public Object getModelObject(IPath modelPath)
  {
    IApplicationClientResource appRes = (IApplicationClientResource)getModelResource(modelPath);
    if ((appRes != null) && (appRes.getRootObject() != null)) {
      return appRes.getApplicationClient();
    }
    return null;
  }
  
  protected String getContentTypeDescriber()
  {
    return "org.eclipse.jst.jee.ee5appclientDD";
  }
  
  public void populateRoot(XMLResourceImpl res, String name)
  {
    ApplicationClientDeploymentDescriptor dd = ApplicationclientFactory.eINSTANCE.createApplicationClientDeploymentDescriptor();
    dd.getXMLNSPrefixMap().put("", "http://java.sun.com/xml/ns/javaee");
    dd.getXMLNSPrefixMap().put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    
    ApplicationClient client = ApplicationclientFactory.eINSTANCE.createApplicationClient();
    DisplayName dn = JavaeeFactory.eINSTANCE.createDisplayName();
    dn.setValue(name);
    client.getDisplayNames().add(dn);
    
    String version = J2EEProjectUtilities.getJ2EEProjectVersion(proj);
    if ((version != null) && (version.equals("5.0")))
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/application-client_5.xsd");
      client.setVersion("5");
    }
    else
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/application-client_6.xsd");
      client.setVersion("6");
    }
    dd.setApplicationClient(client);
    res.getContents().add((EObject)dd);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.AppClient5ModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import org.eclipse.core.resources.IProject;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.IModelProviderFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;

public class AppClient5ModelProviderFactory
  implements IModelProviderFactory
{
  public IModelProvider create(IProject project)
  {
    return new AppClient5ModelProvider(project);
  }
  
  public IModelProvider create(IVirtualComponent component)
  {
    return new AppClient5ModelProvider(component.getProject());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.AppClient5ModelProviderFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.javaee.core.DisplayName;
import org.eclipse.jst.javaee.core.JavaeeFactory;
import org.eclipse.jst.javaee.jca.Connector;
import org.eclipse.jst.javaee.jca.ConnectorDeploymentDescriptor;
import org.eclipse.jst.javaee.jca.IConnectorResource;
import org.eclipse.jst.javaee.jca.JcaFactory;

public class Connector16ModelProvider
  extends JEE5ModelProvider
{
  private static final String CONNECTOR16_CONTENT_TYPE = "org.eclipse.jst.jee.ee6connectorDD";
  
  public Connector16ModelProvider(IProject proj)
  {
    this.proj = proj;
    setDefaultResourcePath(new Path("META-INF/ra.xml"));
  }
  
  public Object getModelObject(IPath modelPath)
  {
    IConnectorResource connectorRes = (IConnectorResource)getModelResource(modelPath);
    if ((connectorRes != null) && (connectorRes.getRootObject() != null)) {
      return connectorRes.getConnector();
    }
    return null;
  }
  
  protected String getContentTypeDescriber()
  {
    return "org.eclipse.jst.jee.ee6connectorDD";
  }
  
  public void populateRoot(XMLResourceImpl res, String name)
  {
    ConnectorDeploymentDescriptor dd = JcaFactory.eINSTANCE.createConnectorDeploymentDescriptor();
    dd.getXMLNSPrefixMap().put("", "http://java.sun.com/xml/ns/javaee");
    dd.getXMLNSPrefixMap().put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    
    Connector connector = JcaFactory.eINSTANCE.createConnector();
    DisplayName dn = JavaeeFactory.eINSTANCE.createDisplayName();
    dn.setValue(name);
    connector.getDisplayNames().add(dn);
    
    String version = J2EEProjectUtilities.getJ2EEProjectVersion(proj);
    if ((version != null) && (version.equals("1.6")))
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/connector_1_6.xsd");
      connector.setVersion("1.6");
    }
    else
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/connector_1_6.xsd");
      connector.setVersion("1.6");
    }
    dd.setConnector(connector);
    res.getContents().add((EObject)dd);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.Connector16ModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import org.eclipse.core.resources.IProject;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.IModelProviderFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;

public class Connector16ModelProviderFactory
  implements IModelProviderFactory
{
  public IModelProvider create(IProject project)
  {
    return new Connector16ModelProvider(project);
  }
  
  public IModelProvider create(IVirtualComponent component)
  {
    return new Connector16ModelProvider(component.getProject());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.Connector16ModelProviderFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import org.eclipse.jst.j2ee.application.WebModule;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.model.IEARModelProvider;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.jst.javaee.application.Application;
import org.eclipse.jst.javaee.application.ApplicationDeploymentDescriptor;
import org.eclipse.jst.javaee.application.ApplicationFactory;
import org.eclipse.jst.javaee.application.IApplicationResource;
import org.eclipse.jst.javaee.application.Module;
import org.eclipse.jst.javaee.application.Web;
import org.eclipse.jst.javaee.core.DisplayName;
import org.eclipse.jst.javaee.core.JavaeeFactory;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;

public class EAR5ModelProvider
  extends JEE5ModelProvider
  implements IEARModelProvider
{
  private static final String EAR5_CONTENT_TYPE = "org.eclipse.jst.jee.ee5earDD";
  
  public EAR5ModelProvider(IProject proj)
  {
    this.proj = proj;
    setDefaultResourcePath(new Path("META-INF/application.xml"));
  }
  
  protected String getContentTypeDescriber()
  {
    return "org.eclipse.jst.jee.ee5earDD";
  }
  
  public Object getModelObject(IPath modelPath)
  {
    IApplicationResource earRes = (IApplicationResource)getModelResource(modelPath);
    if ((earRes != null) && (earRes.getRootObject() != null)) {
      return earRes.getApplication();
    }
    return null;
  }
  
  public String getModuleURI(IVirtualComponent moduleComp)
  {
    IVirtualComponent comp = ComponentCore.createComponent(proj);
    IVirtualReference[] refs = comp.getReferences();
    for (int i = 0; i < refs.length; i++) {
      if ((refs[i].getDependencyType() == 0) && 
        (refs[i].getReferencedComponent().equals(moduleComp))) {
        return refs[i].getArchiveName();
      }
    }
    return null;
  }
  
  public String getWebContextRoot(IProject webProject)
  {
    if ((webProject == null) || (!JavaEEProjectUtilities.isDynamicWebProject(webProject))) {
      return null;
    }
    IVirtualComponent webComp = ComponentCore.createComponent(webProject);
    String webModuleURI = getModuleURI(webComp);
    if (webModuleURI != null)
    {
      Module webModule = ((Application)getModelObject()).getModule(webModuleURI, null);
      if (webModule != null) {
        return webModule.getWeb().getContextRoot();
      }
    }
    return null;
  }
  
  public void populateRoot(XMLResourceImpl res, String name)
  {
    ApplicationDeploymentDescriptor dd = ApplicationFactory.eINSTANCE.createApplicationDeploymentDescriptor();
    dd.getXMLNSPrefixMap().put("", "http://java.sun.com/xml/ns/javaee");
    dd.getXMLNSPrefixMap().put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    
    Application ear = ApplicationFactory.eINSTANCE.createApplication();
    DisplayName dn = JavaeeFactory.eINSTANCE.createDisplayName();
    dn.setValue(name);
    ear.getDisplayNames().add(dn);
    
    String version = J2EEProjectUtilities.getJ2EEProjectVersion(proj);
    if ((version != null) && (version.equals("5.0")))
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/application_5.xsd");
      ear.setVersion("5");
    }
    else
    {
      dd.getXSISchemaLocation().put("http://java.sun.com/xml/ns/javaee", "http://java.sun.com/xml/ns/javaee/application_6.xsd");
      ear.setVersion("6");
    }
    dd.setApplication(ear);
    res.getContents().add((EObject)dd);
  }
  
  public void setWebContextRoot(IProject webProject, String aContextRoot)
  {
    if ((webProject == null) || (!JavaEEProjectUtilities.isDynamicWebProject(webProject))) {
      return;
    }
    IVirtualComponent webComp = ComponentCore.createComponent(webProject);
    String webModuleURI = getModuleURI(webComp);
    if (webModuleURI != null)
    {
      WebModule webModule = (WebModule)((Application)getModelObject()).getModule(webModuleURI, null);
      if (webModule != null) {
        webModule.setContextRoot(aContextRoot);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.EAR5ModelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import org.eclipse.core.resources.IProject;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.IModelProviderFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;

public class EAR5ModelProviderFactory
  implements IModelProviderFactory
{
  public IModelProvider create(IProject project)
  {
    return new EAR5ModelProvider(project);
  }
  
  public IModelProvider create(IVirtualComponent component)
  {
    return new EAR5ModelProvider(component.getProject());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.EAR5ModelProviderFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.j2ee.model.IModelProviderEvent;
import org.eclipse.jst.j2ee.model.IModelProviderListener;
import org.eclipse.jst.jee.JEEPlugin;

public class JEE5ModelProvider$NotifyRunner
  implements ISafeRunnable
{
  private final IModelProviderEvent event;
  private IModelProviderListener listener;
  
  public JEE5ModelProvider$NotifyRunner(JEE5ModelProvider paramJEE5ModelProvider, IModelProviderEvent event)
  {
    Assert.isNotNull(event);
    this.event = event;
  }
  
  public void setListener(IModelProviderListener listener)
  {
    this.listener = listener;
  }
  
  public void handleException(Throwable exception)
  {
    JEEPlugin.getDefault().getLog().log(new Status(4, "org.eclipse.jst.jee", 0, exception.getMessage(), exception));
  }
  
  public void run()
    throws Exception
  {
    if (listener != null) {
      listener.modelsChanged(event);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.JEE5ModelProvider.NotifyRunner
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.resource.Resource;

public class JEE5ModelProvider$ResourceAdapter
  extends AdapterImpl
{
  protected JEE5ModelProvider$ResourceAdapter(JEE5ModelProvider paramJEE5ModelProvider) {}
  
  public void notifyChanged(Notification notification)
  {
    if ((notification.getEventType() == 1) && 
      (notification.getFeatureID(null) == 4)) {
      this$0.resourceIsLoadedChanged((Resource)notification.getNotifier(), notification.getOldBooleanValue(), notification.getNewBooleanValue());
    } else if (notification.getFeatureID(null) == 3) {
      this$0.resourceChanged((Resource)notification.getNotifier());
    }
  }
  
  public boolean equals(Object arg0)
  {
    return getClass().equals(arg0.getClass());
  }
  
  public int hashCode()
  {
    return getClass().hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jee.model.internal.JEE5ModelProvider.ResourceAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jee.model.internal;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import org.eclipse.jem.util.emf.workbench.FlexibleProjectResourceSet;
import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.IModelProviderEvent;
import org.eclipse.jst.j2ee.model.IModelProviderListener;
import org.eclipse.jst.j2ee.model.ModelProviderEvent;
import org.eclipse.jst.jee.JEEPlugin;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateInputProvider;
import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidator;
import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorImpl;
import org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateValidatorPresenter;

public class JEE5ModelProvider
  implements IModelProvider, ResourceStateInputProvider, ResourceStateValidator, IModelProviderListener
{
  protected XMLResourceImpl writableResource;
  protected IProject proj;
  protected IPath defaultResourcePath;
  protected ResourceStateValidator stateValidator;
  protected ResourceAdapter resourceAdapter = new ResourceAdapter();
  protected final ListenerList listeners = new ListenerList();
  private List modelResources = new ArrayList();
  
  protected class ResourceAdapter
    extends AdapterImpl
  {
    protected ResourceAdapter() {}
    
    public void notifyChanged(Notification notification)
    {
      if ((notification.getEventType() == 1) && 
        (notification.getFeatureID(null) == 4)) {
        resourceIsLoadedChanged((Resource)notification.getNotifier(), notification.getOldBooleanValue(), notification.getNewBooleanValue());
      } else if (notification.getFeatureID(null) == 3) {
        resourceChanged((Resource)notification.getNotifier());
      }
    }
    
    public boolean equals(Object arg0)
    {
      return getClass().equals(arg0.getClass());
    }
    
    public int hashCode()
    {
      return getClass().hashCode();
    }
  }
  
  protected ProjectResourceSet getResourceSet(IProject proj2)
  {
    return (ProjectResourceSet)WorkbenchResourceHelperBase.getResourceSet(proj);
  }
  
  public XMLResourceImpl getWritableResource()
  {
    return writableResource;
  }
  
  public void setWritableResource(XMLResourceImpl writableResource)
  {
    this.writableResource = writableResource;
  }
  
  protected void resourceChanged(Resource aResource)
  {
    if (hasListeners())
    {
      int eventCode = 256;
      ModelProviderEvent evt = new ModelProviderEvent(eventCode, this, proj);
      evt.addResource(aResource);
      notifyListeners(evt);
    }
  }
  
  protected void resourceIsLoadedChanged(Resource aResource, boolean oldValue, boolean newValue)
  {
    if (hasListeners())
    {
      int eventCode = newValue ? 32 : 64;
      ModelProviderEvent evt = new ModelProviderEvent(eventCode, this, proj);
      evt.addResource(aResource);
      notifyListeners(evt);
    }
  }
  
  private void addManagedResource(XMLResourceImpl res)
  {
    modelResources.add(res);
    if (!res.eAdapters().contains(resourceAdapter)) {
      res.eAdapters().add(resourceAdapter);
    }
  }
  
  public boolean hasListeners()
  {
    return !listeners.isEmpty();
  }
  
  private URI getModuleURI(URI uri)
  {
    URI moduleuri = ModuleURIUtil.fullyQualifyURI(proj, getContentTypeDescriber());
    IPath requestPath = new Path(moduleuri.path()).append(new Path(uri.path()));
    URI resourceURI = URI.createURI("module:" + requestPath.toString());
    return resourceURI;
  }
  
  protected XMLResourceImpl getModelResource(IPath modelPath)
  {
    if ((proj == null) || (!proj.isAccessible())) {
      throw new IllegalStateException("The project <" + proj + "> is not accessible.");
    }
    if (writableResource != null)
    {
      addManagedResource(writableResource);
      return writableResource;
    }
    IPath innerModelPath = modelPath;
    if ((innerModelPath == null) || (innerModelPath.equals(IModelProvider.FORCESAVE))) {
      innerModelPath = getDefaultResourcePath();
    }
    ProjectResourceSet resSet = getResourceSet(proj);
    IVirtualFolder container = ComponentCore.createComponent(proj).getRootFolder();
    String modelPathURI = innerModelPath.toString();
    URI uri = URI.createURI(modelPathURI);
    
    IVirtualFile dd = container.getFile(innerModelPath);
    URI projURI = URI.createURI(dd.getProjectRelativePath().toString());
    
    XMLResourceImpl res = null;
    try
    {
      if (dd.exists())
      {
        res = (XMLResourceImpl)resSet.getResource(getModuleURI(uri), true);
        addManagedResource(res);
      }
      else
      {
        XMLResourceImpl newRes = createModelResource(innerModelPath, resSet, projURI);
        addManagedResource(newRes);
        return newRes;
      }
    }
    catch (WrappedException ex)
    {
      if ((ex.getCause() instanceof FileNotFoundException)) {
        return null;
      }
      throw ex;
    }
    return res;
  }
  
  protected XMLResourceImpl createModelResource(IPath modelPath, ProjectResourceSet resourceSet, URI uri)
  {
    XMLResourceImpl res = (XMLResourceImpl)resourceSet.getResource(getModuleURI(uri), false);
    if ((res == null) || (!res.isLoaded()))
    {
      res = (XMLResourceImpl)((FlexibleProjectResourceSet)resourceSet).createResource(getModuleURI(uri), WTPResourceFactoryRegistry.INSTANCE.getFactory(uri, getContentType(getContentTypeDescriber())));
      res.setEncoding("UTF-8");
      populateRoot(res, resourceSet.getProject().getName());
    }
    return res;
  }
  
  public void populateRoot(XMLResourceImpl res, String string) {}
  
  private IContentDescription getContentType(String contentTypeDescriber)
  {
    if (contentTypeDescriber != null) {
      return Platform.getContentTypeManager().getContentType(contentTypeDescriber).getDefaultDescription();
    }
    return null;
  }
  
  public IPath getDefaultResourcePath()
  {
    return defaultResourcePath;
  }
  
  public void setDefaultResourcePath(IPath defaultResourcePath)
  {
    this.defaultResourcePath = defaultResourcePath;
  }
  
  public Object getModelObject()
  {
    return getModelObject(getDefaultResourcePath());
  }
  
  public Object getModelObject(IPath modelPath)
  {
    return null;
  }
  
  protected String getContentTypeDescriber()
  {
    return null;
  }
  
  public IStatus validateEdit(IPath modelPath, Object context)
  {
    IPath innaerModelPath = modelPath;
    Object innerContext = context;
    if (innaerModelPath == null) {
      innaerModelPath = getDefaultResourcePath();
    }
    IWorkspace work = ResourcesPlugin.getWorkspace();
    IFile file = WorkbenchResourceHelper.getFile(getModelResource(innaerModelPath));
    if ((file != null) && (file.exists()))
    {
      IFile[] files = { file };
      if (innerContext == null) {
        innerContext = IWorkspace.VALIDATE_PROMPT;
      }
      return work.validateEdit(files, innerContext);
    }
    return Status.OK_STATUS;
  }
  
  /* Error */
  public void modify(Runnable runnable, IPath modelPath)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_2
    //   2: invokevirtual 496	org/eclipse/jst/jee/model/internal/JEE5ModelProvider:getModelResource	(Lorg/eclipse/core/runtime/IPath;)Lorg/eclipse/emf/ecore/xmi/impl/XMLResourceImpl;
    //   5: checkcast 236	org/eclipse/jst/javaee/core/internal/util/JavaeeResourceImpl
    //   8: astore_3
    //   9: aload_3
    //   10: ifnull +8 -> 18
    //   13: aload_0
    //   14: aload_3
    //   15: invokevirtual 488	org/eclipse/jst/jee/model/internal/JEE5ModelProvider:setWritableResource	(Lorg/eclipse/emf/ecore/xmi/impl/XMLResourceImpl;)V
    //   18: aload_1
    //   19: invokeinterface 507 1 0
    //   24: aload_3
    //   25: ifnull +73 -> 98
    //   28: aload_2
    //   29: ifnull +26 -> 55
    //   32: aload_2
    //   33: getstatic 441	org/eclipse/jst/j2ee/model/IModelProvider:FORCESAVE	Lorg/eclipse/core/runtime/IPath;
    //   36: invokeinterface 517 2 0
    //   41: ifeq +14 -> 55
    //   44: aload_3
    //   45: getstatic 438	java/util/Collections:EMPTY_MAP	Ljava/util/Map;
    //   48: iconst_1
    //   49: invokevirtual 477	org/eclipse/jst/javaee/core/internal/util/JavaeeResourceImpl:save	(Ljava/util/Map;Z)V
    //   52: goto +46 -> 98
    //   55: aload_3
    //   56: getstatic 438	java/util/Collections:EMPTY_MAP	Ljava/util/Map;
    //   59: invokevirtual 476	org/eclipse/jst/javaee/core/internal/util/JavaeeResourceImpl:save	(Ljava/util/Map;)V
    //   62: goto +36 -> 98
    //   65: astore 4
    //   67: aload 4
    //   69: invokestatic 478	org/eclipse/jst/jee/JEEPlugin:logError	(Ljava/lang/Throwable;)V
    //   72: goto +26 -> 98
    //   75: astore_3
    //   76: aload_3
    //   77: invokestatic 478	org/eclipse/jst/jee/JEEPlugin:logError	(Ljava/lang/Throwable;)V
    //   80: aload_0
    //   81: aconst_null
    //   82: invokevirtual 488	org/eclipse/jst/jee/model/internal/JEE5ModelProvider:setWritableResource	(Lorg/eclipse/emf/ecore/xmi/impl/XMLResourceImpl;)V
    //   85: goto +18 -> 103
    //   88: astore 5
    //   90: aload_0
    //   91: aconst_null
    //   92: invokevirtual 488	org/eclipse/jst/jee/model/internal/JEE5ModelProvider:setWritableResource	(Lorg/eclipse/emf/ecore/xmi/impl/XMLResourceImpl;)V
    //   95: aload 5
    //   97: athrow
    //   98: aload_0
    //   99: aconst_null
    //   100: invokevirtual 488	org/eclipse/jst/jee/model/internal/JEE5ModelProvider:setWritableResource	(Lorg/eclipse/emf/ecore/xmi/impl/XMLResourceImpl;)V
    //   103: return
    // Line number table:
    //   Java source line #252	-> byte code offset #0
    //   Java source line #253	-> byte code offset #9
    //   Java source line #254	-> byte code offset #13
    //   Java source line #255	-> byte code offset #18
    //   Java source line #257	-> byte code offset #24
    //   Java source line #258	-> byte code offset #28
    //   Java source line #259	-> byte code offset #44
    //   Java source line #261	-> byte code offset #55
    //   Java source line #263	-> byte code offset #65
    //   Java source line #264	-> byte code offset #67
    //   Java source line #266	-> byte code offset #75
    //   Java source line #267	-> byte code offset #76
    //   Java source line #269	-> byte code offset #80
    //   Java source line #268	-> byte code offset #88
    //   Java source line #269	-> byte code offset #90
    //   Java source line #270	-> byte code offset #95
    //   Java source line #269	-> byte code offset #98
    //   Java source line #272	-> byte code offset #103
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	104	0	this	JEE5ModelProvider
    //   0	104	1	runnable	Runnable
    //   0	104	2	modelPath	IPath
    //   8	48	3	res	org.eclipse.jst.javaee.core.internal.util.JavaeeResourceImpl
    //   75	2	3	ex	Exception
    //   65	3	4	e	java.io.IOException
    //   88	8	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   24	62	65	java/io/IOException
    //   0	72	75	java/lang/Exception
    //   0	80	88	finally
  }
  
  public void addListener(IModelProviderListener listener)
  {
    listeners.add(listener);
  }
  
  public void removeListener(IModelProviderListener listener)
  {
    listeners.remove(listener);
  }
  
  public void modelsChanged(IModelProviderEvent anEvent)
  {
    int code = anEvent.getEventCode();
    switch (code)
    {
    case 4: 
      if (hasResourceReference(anEvent.getChangedResources())) {
        removeResources(anEvent.getChangedResources());
      } else {
        return;
      }
      break;
    }
    if (hasListeners())
    {
      anEvent.setModel(this);
      notifyListeners(anEvent);
    }
  }
  
  protected void removeResources(List aList)
  {
    for (int i = 0; i < aList.size(); i++)
    {
      Resource res = (Resource)aList.get(i);
      removeResource(res);
    }
  }
  
  protected boolean removeResource(Resource aResource)
  {
    if (aResource != null)
    {
      aResource.eAdapters().remove(resourceAdapter);
      return getResources().remove(aResource);
    }
    return false;
  }
  
  protected boolean hasResourceReference(List tResources)
  {
    for (int i = 0; i < tResources.size(); i++) {
      if (hasRe
1 2 3 4 5

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