Return-Path: X-Original-To: apmail-geronimo-dev-archive@www.apache.org Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 485B162AF for ; Fri, 1 Jul 2011 01:47:12 +0000 (UTC) Received: (qmail 29714 invoked by uid 500); 1 Jul 2011 01:47:11 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 29621 invoked by uid 500); 1 Jul 2011 01:47:11 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 29614 invoked by uid 99); 1 Jul 2011 01:47:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 01:47:10 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rwonly@gmail.com designates 74.125.83.42 as permitted sender) Received: from [74.125.83.42] (HELO mail-gw0-f42.google.com) (74.125.83.42) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 01:47:04 +0000 Received: by gwb17 with SMTP id 17so2030413gwb.1 for ; Thu, 30 Jun 2011 18:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ink+FW/Mrqg+F7ZYBQt/B1BycecbvshW6PzOTqOpzU8=; b=jdgw3RxOqwXpE3WF8i7s2vcOZ6flIT4z/mZ33YFO0YSLy1f8wFtgtLIFm9R0iWN+T8 uPbpDe1RJuds+r4z7KAETKBm/LO2FF54jyGABRfk4WLpKnqHF/J8mtP3tT+fdzCiuiIB 2Ev81Pe+oQ27GMnlY8wB9oGJVmRL2uRgX5zvc= Received: by 10.151.123.10 with SMTP id a10mr2603194ybn.142.1309484801262; Thu, 30 Jun 2011 18:46:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.40.16 with HTTP; Thu, 30 Jun 2011 18:46:21 -0700 (PDT) In-Reply-To: References: From: Rex Wang Date: Fri, 1 Jul 2011 09:46:21 +0800 Message-ID: Subject: Re: svn commit: r1140441 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.runtime.v30/ org.apache.geronimo.runtime.v30/META-INF/ org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ org.apache.geroni To: dev@geronimo.apache.org Content-Type: multipart/alternative; boundary=000e0cd4b9e06b077e04a6f83022 --000e0cd4b9e06b077e04a6f83022 Content-Type: text/plain; charset=ISO-8859-1 You need take care to maintain such list in memory because you also need update it every time you install/uninstall/republish a bundle. So, just have a try to query the bundle id before every operation, and see if it bring significant impact. -rex 2011/6/29 Yi Xiao > Yes. As you said, the bundle ids can change. However, I still think it's > necessary to cache bundle ids in GEP side, for GEP needn't invoke OSGI api > to query the bundle id when every republish, start, stop or uninstall > bundle. We can synchronize the bundle ids when the server starts, restarts > and eclipse starts. > > > On Tue, Jun 28, 2011 at 1:48 PM, Jarek Gawor wrote: > >> -1 on this. I think this was committed prematurely. We were having a >> conversation on GERONIMODEVTOOLS-75 that caching bundle ids is bad. >> They are not the same as configuration ids for regular EE modules and >> they do change or can change quite frequently. >> >> Also, this change adds a number OSGIBundleHelper.isBundle() checks. >> There should only really be one (or just a few) checks for a bundle >> and then a bunch of separate and independent functions for managing >> the bundles deployment, undeployment, etc. so that it's very clean and >> easy to see what the given function should be doing. >> >> Jarek >> >> On Tue, Jun 28, 2011 at 1:28 AM, wrote: >> > Author: hanhongfang >> > Date: Tue Jun 28 05:28:54 2011 >> > New Revision: 1140441 >> > >> > URL: http://svn.apache.org/viewvc?rev=1140441&view=rev >> > Log: >> > GERONIMODEVTOOLS-759 Using the new APIs to manage the bundles status >> both in GEP and Server side. Thanks Yi Xiao for the patch. >> > >> > Added: >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java >> (with props) >> > Modified: >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/.classpath >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/pom.xml >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiConstants.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.java >> > >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages.properties >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/.classpath >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/.classpath?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/.classpath >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/.classpath >> Tue Jun 28 05:28:54 2011 >> > @@ -1,12 +1,15 @@ >> > >> > >> > + > path="lib/geronimo-bundle-recorder-3.0-SNAPSHOT.jar"/> >> > + > path="lib/geronimo-cli-3.0-SNAPSHOT.jar"/> >> > + > path="lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"/> >> > + > path="lib/geronimo-deploy-tool-3.0-SNAPSHOT.jar"/> >> > > path="lib/plexus-archiver-1.0-alpha-12.jar"/> >> > > path="lib/slf4j-api-1.5.5.jar"/> >> > > path="lib/slf4j-simple-1.5.5.jar"/> >> > > path="lib/geronimo-common-3.0-SNAPSHOT.jar"/> >> > > path="lib/geronimo-crypto-3.0-SNAPSHOT.jar"/> >> > > path="lib/geronimo-deploy-config-3.0-SNAPSHOT.jar"/> >> > - > path="lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"/> >> > > path="lib/geronimo-deployment-3.0-SNAPSHOT.jar"/> >> > > path="lib/geronimo-j2ee-schema-3.0-SNAPSHOT.jar"/> >> > > path="lib/geronimo-kernel-3.0-SNAPSHOT.jar"/> >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF >> Tue Jun 28 05:28:54 2011 >> > @@ -7,7 +7,6 @@ Require-Bundle: >> > org.eclipse.osgi, >> > org.apache.geronimo.runtime.common;visibility:=reexport >> > Bundle-ClassPath: lib/geronimo-common-3.0-SNAPSHOT.jar, >> > - lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar, >> > lib/geronimo-deployment-3.0-SNAPSHOT.jar, >> > lib/geronimo-j2ee-schema-3.0-SNAPSHOT.jar, >> > lib/geronimo-kernel-3.0-SNAPSHOT.jar, >> > @@ -18,7 +17,11 @@ Bundle-ClassPath: lib/geronimo-common-3. >> > lib/plexus-archiver-1.0-alpha-12.jar, >> > lib/geronimo-crypto-3.0-SNAPSHOT.jar, >> > lib/slf4j-api-1.5.5.jar, >> > - lib/slf4j-simple-1.5.5.jar >> > + lib/slf4j-simple-1.5.5.jar, >> > + lib/geronimo-bundle-recorder-3.0-SNAPSHOT.jar, >> > + lib/geronimo-cli-3.0-SNAPSHOT.jar, >> > + lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar, >> > + lib/geronimo-deploy-tool-3.0-SNAPSHOT.jar >> > Export-Package: >> > org.apache.geronimo.common;version=3.0, >> > org.apache.geronimo.common.propertyeditor;version=3.0, >> > @@ -50,6 +53,7 @@ Export-Package: >> > org.apache.geronimo.deployment.util;version=3.0, >> > org.apache.geronimo.deployment.xml;version=3.0, >> > org.apache.geronimo.deployment.xmlbeans;version=3.0, >> > + org.apache.geronimo.deployment.cli;version=3.0, >> > org.apache.geronimo.gbean;version=3.0, >> > org.apache.geronimo.gbean.annotation;version=3.0, >> > org.apache.geronimo.gbean.runtime;version=3.0, >> > @@ -82,6 +86,7 @@ Export-Package: >> > org.apache.geronimo.system.serverinfo;version=3.0, >> > org.apache.geronimo.system.threads;version=3.0, >> > org.apache.geronimo.system.util;version=3.0, >> > + org.apache.geronimo.cli;version=3.0, >> > org.codehaus.plexus.archiver;version=3.0, >> > org.codehaus.plexus.archiver.bzip2;version=3.0, >> > org.codehaus.plexus.archiver.dir;version=3.0, >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/pom.xml >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/pom.xml?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/pom.xml >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.runtime.v30/pom.xml >> Tue Jun 28 05:28:54 2011 >> > @@ -122,6 +122,23 @@ >> > >> geronimo-deploy-jsr88 >> > >> ${geronimoVersion} >> > >> > + >> > + >> > + >> org.apache.geronimo.framework >> > + >> geronimo-bundle-recorder >> > + >> ${geronimoVersion} >> > + >> > + >> > + >> org.apache.geronimo.framework >> > + >> geronimo-cli >> > + >> ${geronimoVersion} >> > + >> > + >> > + >> org.apache.geronimo.framework >> > + >> geronimo-deploy-tool >> > + >> ${geronimoVersion} >> > + >> > + >> > >> > >> org.apache.geronimo.framework >> > >> geronimo-common >> > @@ -232,6 +249,21 @@ >> > >> > >> > org.apache.geronimo.framework >> > + geronimo-bundle-recorder >> > + ${geronimoVersion} >> > + >> > + >> > + org.apache.geronimo.framework >> > + geronimo-cli >> > + ${geronimoVersion} >> > + >> > + >> > + org.apache.geronimo.framework >> > + geronimo-deploy-tool >> > + ${geronimoVersion} >> > + >> > + >> > + org.apache.geronimo.framework >> > geronimo-common >> > ${geronimoVersion} >> > >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java >> Tue Jun 28 05:28:54 2011 >> > @@ -135,6 +135,10 @@ public class DeploymentUtils { >> > return file; >> > } >> > >> > + public static int getModuleState(IServer server, IModule module) { >> > + return server.getModuleState(new IModule[] {module}); >> > + } >> > + >> > private static String getModuleExtension(IModule module) { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "DeploymentUtils.getModuleExtension", module); >> > >> > @@ -288,7 +292,6 @@ public class DeploymentUtils { >> > */ >> > public static String getLastKnownConfigurationId(IModule module, >> IServer server) throws Exception { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "DeploymentUtils.getLastKnownConfigurationId", module, server); >> > - >> > IGeronimoServer gs = (IGeronimoServer) >> server.getAdapter(IGeronimoServer.class); >> > String currentId = gs.getVersionHandler().getConfigID(module); >> > String publishedId = >> ModuleArtifactMapper.getInstance().resolveArtifact(server, module); >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java >> Tue Jun 28 05:28:54 2011 >> > @@ -52,7 +52,6 @@ public class GeronimoConnectionFactory { >> > >> > public DeploymentManager getDeploymentManager(IServer server) throws >> DeploymentManagerCreationException { >> > System.setProperty(Context.INITIAL_CONTEXT_FACTORY, >> "com.sun.jndi.rmi.registry.RegistryContextFactory"); >> > - >> > DeploymentManager dm = (DeploymentManager) >> connections.get(server.getId()); >> > IGeronimoServer geronimoServer = getGeronimoServer(server); >> > if (dm == null) { >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java >> Tue Jun 28 05:28:54 2011 >> > @@ -24,6 +24,7 @@ import java.util.Set; >> > >> > import >> javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; >> > import javax.management.MBeanServerConnection; >> > +import javax.management.ObjectName; >> > import javax.naming.directory.NoSuchAttributeException; >> > >> > import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager; >> > @@ -68,10 +69,25 @@ public class GeronimoServerBehaviour ext >> > * @see >> org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate#stopKernel() >> > */ >> > protected void stopKernel() { >> > - if (kernel != null) { >> > - kernel.shutdown(); >> > - kernel = null; >> > - } >> > + try { >> > + MBeanServerConnection connection = >> getServerConnection(); >> > + Set objectNameSet = >> > + connection.queryNames(new >> ObjectName("osgi.core:type=framework,*"), null); >> > + if (objectNameSet.isEmpty()) { >> > + throw new Exception("Framework mbean not found"); >> > + } else if (objectNameSet.size() == 1) { >> > + Trace.trace(Trace.INFO, "Server shutdown >> starting...", Activator.traceCore); >> > + Object obj = objectNameSet.iterator().next(); >> > + connection.invoke((ObjectName) obj, "stopBundle", >> > + new Object[] { 0 }, new >> String[] { long.class.getName() }); >> > + Trace.trace(Trace.INFO, "Server shutdown completed", >> Activator.traceCore); >> > + } else { >> > + throw new Exception("Found multiple framework >> mbeans"); >> > + } >> > + } catch (Exception e) { >> > + // TODO Auto-generated catch block >> > + Trace.trace(Trace.ERROR, e.getMessage(), e, >> Activator.traceCore); >> > + } >> > } >> > >> > /** >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java >> Tue Jun 28 05:28:54 2011 >> > @@ -30,6 +30,7 @@ import java.util.Iterator; >> > import java.util.LinkedHashMap; >> > import java.util.List; >> > import java.util.Map; >> > +import java.util.Set; >> > import java.util.Timer; >> > import java.util.concurrent.TimeUnit; >> > import java.util.concurrent.locks.Lock; >> > @@ -39,11 +40,13 @@ import javax.enterprise.deploy.spi.Deplo >> > import javax.enterprise.deploy.spi.Target; >> > import javax.enterprise.deploy.spi.TargetModuleID; >> > import javax.management.MBeanServerConnection; >> > +import javax.management.ObjectName; >> > import javax.management.remote.JMXConnector; >> > import javax.management.remote.JMXConnectorFactory; >> > import javax.management.remote.JMXServiceURL; >> > >> > import >> org.apache.geronimo.deployment.plugin.jmx.ExtendedDeploymentManager; >> > +import >> org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager; >> > import org.apache.geronimo.gbean.AbstractName; >> > import org.apache.geronimo.kernel.repository.Artifact; >> > import org.apache.geronimo.st.v30.core.UpdateServerStateTask; >> > @@ -56,6 +59,8 @@ import org.apache.geronimo.st.v30.core.o >> > import >> org.apache.geronimo.st.v30.core.operations.SharedLibEntryCreationOperation; >> > import >> org.apache.geronimo.st.v30.core.operations.SharedLibEntryDataModelProvider; >> > import org.apache.geronimo.st.v30.core.osgi.AriesHelper; >> > +import org.apache.geronimo.st.v30.core.osgi.OSGIBundleHelper; >> > +import org.apache.geronimo.st.v30.core.osgi.OsgiConstants; >> > import org.eclipse.core.commands.ExecutionException; >> > import org.eclipse.core.runtime.CoreException; >> > import org.eclipse.core.runtime.IPath; >> > @@ -131,7 +136,6 @@ abstract public class GeronimoServerBeha >> > return; >> > >> > >> wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, >> getRuntimeClass()); >> > - >> > GeronimoRuntimeDelegate runtime = getRuntimeDelegate(); >> > >> > IVMInstall vmInstall = runtime.getVMInstall(); >> > @@ -589,7 +593,8 @@ abstract public class GeronimoServerBeha >> > */ >> > public void publishModule(int kind, int deltaKind, IModule[] module, >> IProgressMonitor monitor) throws CoreException { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.publishModule", publishKindToString(kind), >> deltaKindToString(deltaKind), Arrays.asList(module), monitor); >> > - >> > + /* remove the OSGI bundles which are removed */ >> > + this.removeObsoleteOSGIBundles(); >> > try { >> > //NO_CHANGE need if app is associated but not started and no >> delta >> > if (deltaKind == NO_CHANGE && module.length == 1) { >> > @@ -615,7 +620,7 @@ abstract public class GeronimoServerBeha >> > >> > Trace.tracePoint("Exit ", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.publishModule"); >> > } >> > - >> > + >> > public Lock getPublishLock() { >> > return publishLock; >> > } >> > @@ -646,6 +651,27 @@ abstract public class GeronimoServerBeha >> > } >> > } >> > >> > + protected void removeObsoleteOSGIBundles() throws CoreException { >> > + try { >> > + Map bundleMap = >> ModuleArtifactMapper.getInstance().getServerBundlesMap(getServer()); >> > + synchronized(bundleMap) { >> > + Iterator> bundleIter = >> bundleMap.entrySet().iterator(); >> > + while(bundleIter.hasNext()) { >> > + Map.Entry bundleEntry = >> bundleIter.next(); >> > + if("true".equals(bundleEntry.getValue()[3])) { >> > + long bundleId = >> Long.parseLong(bundleEntry.getValue()[2]); >> > + IStatus status = >> this.removeOSGIBundleById(bundleId); >> > + if(status.isOK()) { >> > + bundleIter.remove(); >> > + } >> > + } >> > + } >> > + } >> > + } catch(Exception e) { >> > + throw new CoreException(Status.CANCEL_STATUS); >> > + } >> > + >> > + } >> > private void doPublishFinish(IProgressMonitor monitor) throws >> CoreException { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.publishFinish", monitor); >> > >> > @@ -807,7 +833,6 @@ abstract public class GeronimoServerBeha >> > >> > protected void invokeCommand(int deltaKind, IModule module, >> IProgressMonitor monitor) throws CoreException { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.invokeCommand", >> deltaKindToString(deltaKind), module.getName()); >> > - >> > ClassLoader old = >> Thread.currentThread().getContextClassLoader(); >> > try { >> > ClassLoader cl = getContextClassLoader(); >> > @@ -851,38 +876,61 @@ abstract public class GeronimoServerBeha >> > */ >> > protected void doAdded(IModule module, String configId, >> IProgressMonitor monitor) throws Exception { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.doAdded", module.getName(), configId); >> > - >> > - configId = getLastKnowConfigurationId(module, configId); >> > + if(OSGIBundleHelper.isBundle(module)) { >> > + configId = >> ModuleArtifactMapper.getInstance().resolveBundleByModule(getServer(), >> module); >> > + } else { >> > + configId = getLastKnowConfigurationId(module, configId); >> > + } >> > >> > IStatus status; >> > TargetModuleID[] ids; >> > >> > if (configId == null) { >> > - Map artifactsMap = >> ModuleArtifactMapper.getInstance().getServerArtifactsMap(getServer()); >> > - if (artifactsMap != null) { >> > - synchronized (artifactsMap) { >> > + if(OSGIBundleHelper.isBundle(module)) {/* If the module >> is the OSGI bundle */ >> > + Map bundlesMap = >> ModuleArtifactMapper.getInstance().getServerBundlesMap(getServer()); >> > + if(bundlesMap != null) { >> > + synchronized (bundlesMap) { >> > + Object[] ret = >> this.distributeOSGIBundles(module); >> > + status = (IStatus) ret[0]; >> > + if(status.isOK()) { >> > + /* Add the bundle info into the >> ModuleArtifactMapper's bundle cache */ >> > + Long bundleId = (Long) ret[1]; >> > + >> OSGIBundleHelper.addBundleToPublishedMap(getServer(), module, bundleId); >> > + /* end here */ >> > + setModuleState(new IModule [] { >> module }, IServer.STATE_STARTED); >> > + } else { >> > + doFail(status, >> Messages.DISTRIBUTE_FAIL); >> > + } >> > + } >> > + } >> > + >> > + } else { >> > + Map artifactsMap = >> ModuleArtifactMapper.getInstance().getServerArtifactsMap(getServer()); >> > + if (artifactsMap != null) { >> > + synchronized (artifactsMap) { >> > + status = distribute(module, monitor); >> > + if (!status.isOK()) { >> > + doFail(status, Messages.DISTRIBUTE_FAIL); >> > + } >> > + >> > + ids = updateServerModuleConfigIDMap(module, >> status); >> > + } >> > + } else { >> > status = distribute(module, monitor); >> > if (!status.isOK()) { >> > doFail(status, Messages.DISTRIBUTE_FAIL); >> > } >> > >> > ids = updateServerModuleConfigIDMap(module, status); >> > - } >> > - } else { >> > - status = distribute(module, monitor); >> > - if (!status.isOK()) { >> > - doFail(status, Messages.DISTRIBUTE_FAIL); >> > } >> > >> > - ids = updateServerModuleConfigIDMap(module, status); >> > - } >> > - >> > - status = start(ids, monitor); >> > - if (!status.isOK()) { >> > - doFail(status, Messages.START_FAIL); >> > - } else { >> > - setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > - } >> > + status = start(ids, monitor); >> > + if (!status.isOK()) { >> > + doFail(status, Messages.START_FAIL); >> > + } else { >> > + setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > + } >> > + } >> > } else { >> > //either (1) a configuration with the same module id exists >> already on the server >> > //or (2) the module now has a different configId and the >> configuration on the server using >> > @@ -899,32 +947,47 @@ abstract public class GeronimoServerBeha >> > */ >> > protected void doChanged(IModule module, String configId, >> IProgressMonitor monitor) throws Exception { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.doChanged", module.getName(), configId); >> > - >> > - configId = getLastKnowConfigurationId(module, configId); >> > - if(configId != null) { >> > - String moduleConfigId = getConfigId(module); >> > - if (moduleConfigId.equals(configId)) { >> > - IStatus status = reDeploy(module, monitor); >> > - if (!status.isOK()) { >> > - doFail(status, Messages.REDEPLOY_FAIL); >> > + IStatus status = null; >> > + Object[] ret = null; >> > + if(OSGIBundleHelper.isBundle(module)) { >> > + boolean isPublished = >> OSGIBundleHelper.checkBundleInPublishedMap(getServer(), module); >> > + if(isPublished) status = doOSGIBundleRedeploy(module); >> > + else { >> > + ret = this.distributeOSGIBundles(module); >> > + status = (IStatus) ret[0]; >> > + } >> > + if(status.isOK()) { >> > + if(! isPublished) >> OSGIBundleHelper.addBundleToPublishedMap(getServer(), module, (Long) >> ret[1]); >> > + setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > + } else { >> > + doFail(status, Messages.REDEPLOY_FAIL); >> > + } >> > + } else { >> > + configId = getLastKnowConfigurationId(module, configId); >> > + if(configId != null) { >> > + String moduleConfigId = getConfigId(module); >> > + if (moduleConfigId.equals(configId)) { >> > + status = reDeploy(module, monitor); >> > + if (!status.isOK()) { >> > + doFail(status, Messages.REDEPLOY_FAIL); >> > + } else { >> > + setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > + } >> > } else { >> > - setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > + //different configIds from what needs to be >> undeployed to what will be deployed >> > + doRemoved(module, monitor); >> > + doAdded(module, null, monitor); >> > } >> > } else { >> > - //different configIds from what needs to be undeployed >> to what will be deployed >> > - doRemoved(module, monitor); >> > - doAdded(module, null, monitor); >> > + //The checked configuration no longer exists on the >> server >> > + doAdded(module, configId, monitor); >> > } >> > - } else { >> > - //The checked configuration no longer exists on the server >> > - doAdded(module, configId, monitor); >> > } >> > - >> > Trace.tracePoint("Exit ", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.doChanged"); >> > } >> > - >> > + >> > private IStatus tryFileReplace(IModule[] module) { >> > - Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.tryFileReplace", module); >> > + Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.tryFileReplace", module.toString()); >> > >> > IModule webModule = module[module.length - 1]; >> > if (webModule.isExternal()) { >> > @@ -1076,30 +1139,44 @@ abstract public class GeronimoServerBeha >> > } >> > >> > private void _doRemove(IModule module, IProgressMonitor monitor) >> throws Exception { >> > - IStatus status = unDeploy(module, monitor); >> > - if (!status.isOK()) { >> > - doFail(status, Messages.UNDEPLOY_FAIL); >> > - } >> > + IStatus status = null; >> > + if(OSGIBundleHelper.isBundle(module)) {/* If the module is a >> OSGI bundle */ >> > + // must consider the situation of the project name or >> bundle name or both have been changed, not done yet!!! >> > + status= this.removeOSGIBundle(module); >> > + if(status.isOK()) { >> > + >> OSGIBundleHelper.removeBundleFromPublishedMap(getServer(), module); >> > + } else { >> > + doFail(status, Messages.DISTRIBUTE_FAIL); >> > + } >> > + } else { >> > + status = unDeploy(module, monitor); >> > + if (!status.isOK()) { >> > + doFail(status, Messages.UNDEPLOY_FAIL); >> > + } >> > + } >> > + >> > + >> > } >> > >> > protected void doNoChange(IModule module, IProgressMonitor monitor) >> throws Exception { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.doNoChange", module.getName()); >> > - >> > - DeploymentManager dm = >> DeploymentCommandFactory.getDeploymentManager(getServer()); >> > - String configId = >> DeploymentUtils.getLastKnownConfigurationId(module, getServer()); >> > - if (configId != null) { >> > - IModule[] rootModule = new IModule[] { module }; >> > - if (DeploymentUtils.isStartedModule(dm, configId) != null) >> { >> > - setModuleState(rootModule, IServer.STATE_STARTED); >> > - } else if (DeploymentUtils.isStoppedModule(dm, configId) != >> null) { >> > - setModuleState(rootModule, IServer.STATE_STOPPED); >> > + if(! OSGIBundleHelper.isBundle(module)) {/* if the module is >> the bundle, just return! */ >> > + DeploymentManager dm = >> DeploymentCommandFactory.getDeploymentManager(getServer()); >> > + String configId = >> DeploymentUtils.getLastKnownConfigurationId(module, getServer()); >> > + if (configId != null) { >> > + IModule[] rootModule = new IModule[] { module }; >> > + if (DeploymentUtils.isStartedModule(dm, configId) != >> null) { >> > + setModuleState(rootModule, IServer.STATE_STARTED); >> > + } else if (DeploymentUtils.isStoppedModule(dm, >> configId) != null) { >> > + setModuleState(rootModule, IServer.STATE_STOPPED); >> > + } else { >> > + setModuleState(rootModule, IServer.STATE_UNKNOWN); >> > + } >> > + ModuleArtifactMapper mapper = >> ModuleArtifactMapper.getInstance(); >> > + mapper.addArtifactEntry(getServer(), module, configId); >> > } else { >> > - setModuleState(rootModule, IServer.STATE_UNKNOWN); >> > + doAdded(module, null, monitor); >> > } >> > - ModuleArtifactMapper mapper = >> ModuleArtifactMapper.getInstance(); >> > - mapper.addArtifactEntry(getServer(), module, configId); >> > - } else { >> > - doAdded(module, null, monitor); >> > } >> > >> > Trace.tracePoint("Exit ", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.doNoChange"); >> > @@ -1138,7 +1215,75 @@ abstract public class GeronimoServerBeha >> > IDeploymentCommand cmd = >> DeploymentCommandFactory.createDistributeCommand(module, getServer()); >> > return cmd.execute(monitor); >> > } >> > - >> > + >> > + protected IStatus doOSGIBundleRedeploy(IModule module) throws >> Exception { >> > + IStatus status = Status.CANCEL_STATUS; >> > + Map bundlesMap = >> ModuleArtifactMapper.getInstance().getServerBundlesMap(getServer()); >> > + if(bundlesMap != null) { >> > + synchronized (bundlesMap) { >> > + status = this.removeOSGIBundle(module); >> > + if(status.isOK()) { >> > + >> OSGIBundleHelper.removeBundleFromPublishedMap(getServer(), module);/* >> remove the bundle from cache */ >> > + /* install the bundle as a new one */ >> > + Object[] ret = this.distributeOSGIBundles(module); >> > + status = (IStatus) ret[0]; >> > + if(status.isOK()) { >> > + /* Add the bundle info into the >> ModuleArtifactMapper's bundle cache */ >> > + Long bundleId = (Long) ret[1]; >> > + >> OSGIBundleHelper.addBundleToPublishedMap(getServer(), module, bundleId); >> > + /* end here */ >> > + } >> > + } >> > + } >> > + } >> > + return status; >> > + } >> > + protected Object[] distributeOSGIBundles(IModule module) throws >> Exception { >> > + RemoteDeploymentManager rDm = >> (RemoteDeploymentManager)DeploymentCommandFactory.getDeploymentManager(this.getServer()); >> > + try { >> > + /* Get target file */ >> > + File f = DeploymentUtils.getTargetFile(getServer(), >> module); >> > + if (f == null) { >> > + throw new CoreException(new Status(IStatus.ERROR, >> Activator.PLUGIN_ID, >> > + Messages.bind(Messages.moduleExportError, >> module.getProject().getName()))); >> > + } >> > + /* end here */ >> > + >> > + long bundleId = rDm.recordInstall(f, >> OsgiConstants.BUNDLE_IS_INPLACE, OsgiConstants.BUNDLE_DEFAULT_START_LEVLE); >> > + boolean ss = this._startBundle(bundleId); >> > + if(ss) { >> > + return new Object[] {Status.OK_STATUS, >> new Long(bundleId)}; >> > + } else { >> > + Trace.trace(Trace.ERROR, "The Bundle: " >> + module.getName() + " could not be installed", null, Activator.logCore); >> > + return new Object[] >> {Status.CANCEL_STATUS}; >> > + } >> > + } catch (IOException e) { >> > + Trace.trace(Trace.ERROR, "The Bundle: " + >> module.getName() + " could not be installed", e, Activator.logCore); >> > + return new Object[] {Status.CANCEL_STATUS}; >> > + } >> > + } >> > + protected IStatus removeOSGIBundle(IModule module) throws Exception >> { >> > + try { >> > + long bundleId = >> ModuleArtifactMapper.getInstance().getBundleId(getServer(), module); >> > + return this.removeOSGIBundleById(bundleId); >> > + } catch (Exception e) { >> > + Trace.trace(Trace.ERROR, "The Bundle: " + >> module.getName() + " could not be unInstalled", e, Activator.logCore); >> > + return Status.CANCEL_STATUS; >> > + } >> > + } >> > + >> > + protected IStatus removeOSGIBundleById(long bundleId) throws >> Exception { >> > + try { >> > + boolean isSuccess = this._unInstallBundle(bundleId); >> > + if(isSuccess) { >> > + return Status.OK_STATUS; >> > + } else { >> > + return Status.CANCEL_STATUS; >> > + } >> > + } catch (Exception e) { >> > + return Status.CANCEL_STATUS; >> > + } >> > + } >> > protected IStatus start(IModule module, IProgressMonitor monitor) >> throws Exception { >> > TargetModuleID id = >> DeploymentUtils.getTargetModuleID(getServer(), module); >> > IDeploymentCommand cmd = >> DeploymentCommandFactory.createStartCommand(new TargetModuleID[] { id }, >> module, getServer()); >> > @@ -1462,19 +1607,57 @@ abstract public class GeronimoServerBeha >> > public void startModule(IModule[] module, IProgressMonitor monitor) >> { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.startModule", Arrays.asList(module)); >> > try { >> > - start(module[0], monitor); >> > + if(OSGIBundleHelper.isBundle(module[0])) { >> > + boolean isIn = >> OSGIBundleHelper.checkBundleInPublishedMap(getServer(), module[0]); >> > + int state = DeploymentUtils.getModuleState(getServer(), >> module[0]); >> > + if(isIn && (state == IServer.STATE_STOPPED)) >> startOSGIBundle(module[0]); >> > + else throw new Exception(Messages.START_FAIL); >> > + } else { >> > + start(module[0], monitor); >> > + } >> > } catch (Exception e) { >> > Trace.trace(Trace.ERROR, "Error starting module " + >> module[0].getName(), e, Activator.logCore); >> > throw new RuntimeException("Error starting module " + >> module[0].getName(), e); >> > - } >> > + } >> > Trace.tracePoint("Exit ", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.startModule"); >> > } >> > >> > + protected void startOSGIBundle(IModule module) throws Exception { >> > + >> > + long bundleId = OSGIBundleHelper.getOSGIBundleId(getServer(), >> module); >> > + if(bundleId == -1) throw new Exception("can not start bundle"); >> > + boolean ss = this._startBundle(bundleId); >> > + if(ss) { >> > + setModuleState(new IModule [] { module }, >> IServer.STATE_STARTED); >> > + } else { >> > + throw new Exception("can not start bundle"); >> > + } >> > + } >> > + protected void stopOSGIBundle(IModule module) throws Exception { >> > + long bundleId = OSGIBundleHelper.getOSGIBundleId(getServer(), >> module); >> > + if(bundleId == -1) throw new Exception("can not stop bundle"); >> > + boolean ss = this._stopBundle(bundleId); >> > + if(ss) { >> > + setModuleState(new IModule [] { module }, >> IServer.STATE_STOPPED); >> > + } else { >> > + throw new Exception("can not start bundle"); >> > + } >> > + } >> > @Override >> > public void stopModule(IModule[] module, IProgressMonitor monitor) { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.stopModule", Arrays.asList(module)); >> > try { >> > - stop(module[0], monitor); >> > + if(OSGIBundleHelper.isBundle(module[0])) { >> > + boolean isIn = >> OSGIBundleHelper.checkBundleInPublishedMap(getServer(), module[0]); >> > + int state = DeploymentUtils.getModuleState(getServer(), >> module[0]); >> > + if(! isIn || state == IServer.STATE_UNKNOWN) >> doFail(Status.CANCEL_STATUS, Messages.DISTRIBUTE_FAIL); >> > + else { >> > + this.stopOSGIBundle(module[0]); >> > + } >> > + } else { >> > + stop(module[0], monitor); >> > + } >> > + >> > } catch (Exception e) { >> > Trace.trace(Trace.ERROR, "Error stopping module " + >> module[0].getName(), e, Activator.logCore); >> > throw new RuntimeException("Error stopping module " + >> module[0].getName(), e); >> > @@ -1486,8 +1669,20 @@ abstract public class GeronimoServerBeha >> > public void restartModule(IModule[] module, IProgressMonitor >> monitor) { >> > Trace.tracePoint("Entry", Activator.traceCore, >> "GeronimoServerBehaviourDelegate.restartModule", Arrays.asList(module)); >> > try { >> > - stop(module[0], monitor); >> > - start(module[0], monitor); >> > + if(OSGIBundleHelper.isBundle(module[0])) { >> > + boolean isIn = >> OSGIBundleHelper.checkBundleInPublishedMap(getServer(), module[0]); >> > + int state = DeploymentUtils.getModuleState(getServer(), >> module[0]); >> > + if(isIn && (state == IServer.STATE_STARTED)) { >> > + this.stopOSGIBundle(module[0]); >> > + this.startOSGIBundle(module[0]); >> > + } else { >> > + doFail(Status.CANCEL_STATUS, >> Messages.RESTART_OSGIBUNDLE_FAIL); >> > + } >> > + } else { >> > + stop(module[0], monitor); >> > + start(module[0], monitor); >> > + } >> > + >> > } catch (Exception e) { >> > Trace.trace(Trace.ERROR, "Error restarting module " + >> module[0].getName(), e, Activator.logCore); >> > throw new RuntimeException("Error restarting module " + >> module[0].getName(), e); >> > @@ -1514,5 +1709,55 @@ abstract public class GeronimoServerBeha >> > public void setModulesState(IModule[] module, int state) { >> > setModuleState(module, state); >> > } >> > + private boolean _startBundle(long bundleId) { >> > + try { >> > + MBeanServerConnection connection = >> getServerConnection(); >> > + connection.invoke(getFramework(), "startBundle", >> > + new Object[] { bundleId }, new String[] { >> long.class.getName() }); >> > + return true; >> > + } catch(Exception e) { >> > + Trace.trace(Trace.INFO, "Could not start bundle", >> Activator.traceCore); >> > + return false; >> > + } >> > + >> > + } >> > + private boolean _stopBundle(long bundleId) { >> > + try { >> > + MBeanServerConnection connection = >> getServerConnection(); >> > + connection.invoke(getFramework(), "stopBundle", >> > + new Object[] { bundleId }, new String[] { >> long.class.getName() }); >> > + return true; >> > + } catch(Exception e) { >> > + Trace.trace(Trace.INFO, "Could not stop bundle", >> Activator.traceCore); >> > + return false; >> > + } >> > + } >> > + private boolean _unInstallBundle(long bundleId) { >> > + try { >> > + MBeanServerConnection connection = >> getServerConnection(); >> > + connection.invoke(getFramework(), "uninstallBundle", >> > + new Object[] { bundleId }, new String[] { >> long.class.getName() }); >> > + return true; >> > + } catch(Exception e) { >> > + Trace.trace(Trace.INFO, "Could not uninstall bundle", >> Activator.traceCore); >> > + return false; >> > + } >> > + } >> > + protected ObjectName getFramework() throws Exception { >> > + try { >> > + MBeanServerConnection connection = >> getServerConnection(); >> > + Set objectNameSet = >> > + connection.queryNames(new >> ObjectName("osgi.core:type=framework,*"), null); >> > + if (objectNameSet.isEmpty()) { >> > + throw new >> Exception(Messages.frameworkMBeanNotFound); >> > + } else if (objectNameSet.size() == 1) { >> > + return objectNameSet.iterator().next(); >> > + } else { >> > + throw new >> Exception(Messages.multipleFramworkMBeans); >> > + } >> > + } catch (Exception e) { >> > + throw e; >> > + } >> > + } >> > >> > } >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java >> Tue Jun 28 05:28:54 2011 >> > @@ -44,8 +44,12 @@ import org.eclipse.wst.common.componentc >> > import >> org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; >> > import >> org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >> > import org.eclipse.wst.server.core.IModule; >> > +import org.eclipse.wst.server.core.IServer; >> > +import org.eclipse.wst.server.core.internal.ModuleFactory; >> > +import org.eclipse.wst.server.core.internal.ServerPlugin; >> > import org.osgi.framework.Version; >> > >> > + >> > /** >> > * @version $Rev$ $Date$ >> > */ >> > @@ -217,6 +221,24 @@ public class GeronimoUtils { >> > return id; >> > } >> > } >> > + if(isBundleModule(module)) { >> > + Class ariesUtilsClass = >> Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUtils"); >> > + Method method = >> ariesUtilsClass.getMethod("getBlueprintBundleManifest", IProject.class); >> > + Object object = method.invoke(null, >> module.getProject()); >> > + >> > + Class bundleManifest = >> Class.forName("com.ibm.etools.aries.core.models.BundleManifest"); >> > + method = >> bundleManifest.getMethod("getBundleSymbolicName"); >> > + String bundleSymName = (String) >> method.invoke(object); >> > + >> > + method = >> bundleManifest.getMethod("getBundleVersion"); >> > + String versionStr = (String) method.invoke(object); >> > + Version version = Version.parseVersion(versionStr); >> > + String newVersionStr = getVersion(version); >> > + >> > + if (bundleSymName != null && version != null) { >> > + return bundleSymName + ":" + newVersionStr; >> > + } >> > + } >> > } catch (Exception e) { >> > } >> > } >> > @@ -227,7 +249,7 @@ public class GeronimoUtils { >> > } >> > >> > // copied from >> org.apache.geronimo.aries.builder.ApplicationInstaller.getVersion(Version) >> > - private static String getVersion(Version version) { >> > + public static String getVersion(Version version) { >> > String str = version.getMajor() + "." + version.getMinor() + "." >> + version.getMicro(); >> > String qualifier = version.getQualifier(); >> > if (qualifier != null && qualifier.trim().length() > 0) { >> > @@ -235,12 +257,13 @@ public class GeronimoUtils { >> > } >> > return str; >> > } >> > - >> > + >> > public static String getQualifiedConfigID(String groupId, String >> artifactId, String version, String type) { >> > return groupId + "/" + artifactId + "/" + version + "/" + type; >> > } >> > >> > public static IFile getWebDeploymentPlanFile(IVirtualComponent comp) >> { >> > + if(comp == null) return null; >> > IPath deployPlanPath = >> comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("WEB-INF").append(WEB_PLAN_NAME); >> > return comp.getProject().getFile(deployPlanPath); >> > } >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java >> Tue Jun 28 05:28:54 2011 >> > @@ -18,9 +18,11 @@ package org.apache.geronimo.st.v30.core; >> > >> > import java.io.BufferedInputStream; >> > import java.io.BufferedOutputStream; >> > +import java.io.BufferedReader; >> > import java.io.File; >> > import java.io.FileInputStream; >> > import java.io.FileOutputStream; >> > +import java.io.FileReader; >> > import java.io.IOException; >> > import java.io.InputStream; >> > import java.io.ObjectInput; >> > @@ -29,28 +31,44 @@ import java.io.ObjectOutput; >> > import java.io.ObjectOutputStream; >> > import java.io.OutputStream; >> > import java.util.HashMap; >> > +import java.util.Iterator; >> > import java.util.Map; >> > >> > +import org.apache.geronimo.st.v30.core.internal.Trace; >> > +import org.eclipse.core.resources.IProject; >> > +import org.eclipse.core.resources.IResource; >> > +import org.eclipse.core.resources.IResourceChangeEvent; >> > +import org.eclipse.core.resources.IResourceChangeListener; >> > +import org.eclipse.core.resources.IResourceDelta; >> > +import org.eclipse.core.resources.IResourceDeltaVisitor; >> > +import org.eclipse.core.resources.ResourcesPlugin; >> > +import org.eclipse.core.runtime.CoreException; >> > import org.eclipse.core.runtime.IPath; >> > import org.eclipse.wst.server.core.IModule; >> > import org.eclipse.wst.server.core.IServer; >> > import org.eclipse.wst.server.core.util.SocketUtil; >> > >> > + >> > /** >> > * @version $Rev$ $Date$ >> > */ >> > public class ModuleArtifactMapper { >> > >> > private static ModuleArtifactMapper instance = new >> ModuleArtifactMapper(); >> > - >> > + >> > private static final String FILE_NAME = "servermodule.info"; >> > - >> > + private static final String BUNDLE_FILE_NAME = "serverbundle.info >> "; >> > + >> > private ServerEntries serverArtifactEntries = null; >> > - >> > + private ServerBundleEntries serverBundleEntries = null; >> > + >> > private ModuleArtifactMapper() { >> > if (serverArtifactEntries == null) { >> > serverArtifactEntries = new ServerEntries(); >> > } >> > + if(serverBundleEntries == null) { >> > + serverBundleEntries = new ServerBundleEntries(); >> > + } >> > load(); >> > } >> > >> > @@ -72,7 +90,6 @@ public class ModuleArtifactMapper { >> > artifactEntries.put(getId(module), configId); >> > } >> > } >> > - >> > synchronized public void removeArtifactEntry(IServer server, IModule >> module) { >> > Map artifactEntries = >> getServerArtifactsMap(server); >> > if (artifactEntries != null) { >> > @@ -80,6 +97,87 @@ public class ModuleArtifactMapper { >> > } >> > } >> > >> > + synchronized public void addBundleEntry(IServer server, IModule >> module, String symName, String version, long bundleId) { >> > + Map bundleEntries = >> getServerBundlesMap(server); >> > + if (bundleEntries != null && module != null) { >> > + bundleEntries.put(module.getProject().getName(), new >> String[] {symName, version, new Long(bundleId).toString(), "false"}); >> > + } >> > + } >> > + synchronized public String resolveBundleByModule(IServer server, >> IModule module) {// return the bundle symbolic name >> > + if(module != null && module.getProject() != null) { >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if (bundleEntries != null) { >> > + String[] vs = >> bundleEntries.get(module.getProject().getName()); >> > + return vs == null ? null : vs[0]; >> > + } >> > + } >> > + return null; >> > + } >> > + synchronized public String resolveBundleBySymbolicName(IServer >> server, String symName, String version) {// return the project name >> > + if(symName == null || version == null) return null; >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if (bundleEntries != null) { >> > + Iterator> iter = >> bundleEntries.entrySet().iterator(); >> > + while(iter.hasNext()) { >> > + Map.Entry entry = iter.next(); >> > + if(symName.equals(entry.getValue()[0]) && >> version.equals(entry.getValue()[1])) return entry.getKey(); >> > + } >> > + } >> > + return null; >> > + } >> > + synchronized public boolean checkBundleDirty(IServer server, >> IModule module) { >> > + boolean isDirty = false; >> > + if(module != null && module.getProject() != null) { >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if (bundleEntries != null) { >> > + String[] vs = >> bundleEntries.get(module.getProject().getName()); >> > + if(vs == null) isDirty = false; >> > + else isDirty = Boolean.parseBoolean(vs[3]); >> > + } >> > + } >> > + return isDirty; >> > + } >> > + @SuppressWarnings("finally") >> > + synchronized public String resolveBundleById(IServer server, int >> bundleId) {// return the project name >> > + String pName = null; >> > + try { >> > + String idStr = new Integer(bundleId).toString(); >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if (bundleEntries != null) { >> > + Iterator> iter = >> bundleEntries.entrySet().iterator(); >> > + while(iter.hasNext()) { >> > + Map.Entry entry = iter.next(); >> > + if(idStr.equals(entry.getValue()[2])) return >> entry.getKey(); >> > + } >> > + } >> > + } catch(Exception e) { >> > + Trace.trace(Trace.ERROR, e.getMessage(), e, >> Activator.logCore); >> > + } finally { >> > + return pName; >> > + } >> > + } >> > + synchronized public void removeBundle(IServer server, IModule >> module) { >> > + if(module != null && module.getProject() != null) { >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if(bundleEntries != null) { >> > + >> bundleEntries.remove(module.getProject().getName()); >> > + } >> > + } >> > + } >> > + >> > + public long getBundleId(IServer server, IModule module) { >> > + int id = -1; >> > + if(module != null && module.getProject() != null) { >> > + String projectName = module.getProject().getName(); >> > + Map bundleEntries = >> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile()); >> > + if (bundleEntries != null) { >> > + String[] strs = bundleEntries.get(projectName); >> > + if(strs != null) return new Long(strs[2]); >> > + } >> > + } >> > + return id; >> > + } >> > + >> > synchronized public String resolveArtifact(IServer server, IModule >> module) { >> > if (module != null) { >> > Map artifactEntries = >> getServerArtifactsMap(server); >> > @@ -88,7 +186,7 @@ public class ModuleArtifactMapper { >> > } >> > } >> > return null; >> > - } >> > + } >> > >> > synchronized public Map >> getServerArtifactsMap(IServer server) { >> > if (!SocketUtil.isLocalhost(server.getHost())) { >> > @@ -104,13 +202,26 @@ public class ModuleArtifactMapper { >> > >> > return artifactEntries; >> > } >> > - >> > + synchronized public Map >> getServerBundlesMap(IServer server) { >> > + if (!SocketUtil.isLocalhost(server.getHost())) { >> > + return null; >> > + } >> > + >> > + File runtimeLoc = server.getRuntime().getLocation().toFile(); >> > + Map bundleEntries = >> serverBundleEntries.get(runtimeLoc); >> > + if (bundleEntries == null) { >> > + bundleEntries = new HashMap(); >> > + serverBundleEntries.put(runtimeLoc, bundleEntries); >> > + } >> > + >> > + return bundleEntries; >> > + } >> > private void save(IServerEntries entries, String fileName) { >> > ObjectOutput output = null; >> > try { >> > IPath dest = >> Activator.getDefault().getStateLocation().append(fileName); >> > - OutputStream file = new FileOutputStream(dest.toFile()); >> > - OutputStream buffer = new BufferedOutputStream(file); >> > + OutputStream fos = new FileOutputStream(dest.toFile()); >> > + OutputStream buffer = new BufferedOutputStream(fos); >> > output = new ObjectOutputStream(buffer); >> > String xml = entries.toXML(); >> > output.writeObject(xml); >> > @@ -128,6 +239,7 @@ public class ModuleArtifactMapper { >> > >> > synchronized public void save() { >> > save(serverArtifactEntries, FILE_NAME); >> > + save(serverBundleEntries, BUNDLE_FILE_NAME); >> > } >> > >> > private void load(IServerEntries entries, String fileName) { >> > @@ -152,12 +264,14 @@ public class ModuleArtifactMapper { >> > } >> > } >> > } >> > - >> > synchronized private void load() { >> > load(serverArtifactEntries, FILE_NAME); >> > + load(serverBundleEntries, BUNDLE_FILE_NAME); >> > + addListener(); >> > } >> > >> > - protected interface IServerEntries { >> > + >> > + protected interface IServerEntries { >> > public void loadXML (String xml); >> > public String toXML (); >> > } >> > @@ -216,7 +330,88 @@ public class ModuleArtifactMapper { >> > Object[] serverKeySet = keySet().toArray(); >> > for (int i = 0; i < serverKeySet.length; i++) { >> > xmlString += " " + serverKeySet[i] + >> "\n"; >> > - Map projectMap = (Map)get(serverKeySet[i]); >> > + Map projectMap = (Map> String>)get(serverKeySet[i]); >> > + if (projectMap == null || projectMap.size() == 0) { >> > + xmlString += " \n"; >> > + } >> > + else { >> > + xmlString += " \n"; >> > + Object[] projectKeySet = >> projectMap.keySet().toArray(); >> > + for (int j = 0; j < projectKeySet.length; j++) >> > + { >> > + xmlString += " \n"; >> > + xmlString += " " + >> projectKeySet[j] + "\n"; >> > + xmlString += " " + >> projectMap.get(projectKeySet[j]) + "\n"; >> > + xmlString += " \n"; >> > + } >> > + xmlString += " \n"; >> > + } >> > + } >> > + xmlString += " \n"; >> > + } >> > + return xmlString; >> > + } >> > + } >> > + >> > + protected class ServerBundleEntries extends HashMap> Map> implements IServerEntries{ >> > + static final long serialVersionUID = 0; >> > + >> > + public void loadXML (String xml) { >> > + if (xml == null || xml.length() == 0) >> > + return; >> > + >> > + String projectName, bundleSymName, bundleVersion, bundleId, >> removed; >> > + int fileEndPos, nomapStartPos, mapStartPos, mapEndPos, >> stringStartPos, stringEndPos; >> > + int fileStartPos = xml.indexOf("", 0); >> > + Map artifactEntries; >> > + while (fileStartPos > -1) { >> > + fileEndPos = xml.indexOf("", fileStartPos); >> > + File runtimeLoc = new File(xml.substring(fileStartPos + >> 6, fileEndPos)); >> > + >> > + nomapStartPos = xml.indexOf("", fileEndPos); >> > + mapStartPos = xml.indexOf("", fileEndPos); >> > + artifactEntries = new HashMap(); >> > + // have projects on the server >> > + if ((nomapStartPos == -1) || (nomapStartPos > >> mapStartPos)) { >> > + mapEndPos = xml.indexOf("", mapStartPos); >> > + stringStartPos = xml.indexOf("", >> mapStartPos); >> > + while ((stringStartPos > -1) && (stringStartPos < >> mapEndPos)) { >> > + stringEndPos = xml.indexOf("", >> stringStartPos); >> > + projectName = xml.substring(stringStartPos + 8, >> stringEndPos);// load project name >> > + stringStartPos = xml.indexOf("", >> stringEndPos); >> > + stringEndPos = xml.indexOf("", >> stringStartPos); >> > + bundleSymName = xml.substring(stringStartPos + >> 8, stringEndPos);// load bundle symbolic name >> > + stringStartPos = xml.indexOf("", >> stringEndPos); >> > + stringEndPos = xml.indexOf("", >> stringStartPos); >> > + bundleVersion = xml.substring(stringStartPos + >> 8, stringEndPos);// load bundle version >> > + stringStartPos = xml.indexOf("", >> stringEndPos); >> > + stringEndPos = xml.indexOf("", >> stringStartPos); >> > + bundleId = xml.substring(stringStartPos + 8, >> stringEndPos);// load bundle id >> > + stringStartPos = xml.indexOf("", >> stringEndPos); >> > + stringEndPos = xml.indexOf("", >> stringStartPos); >> > + removed = xml.substring(stringStartPos + 8, >> stringEndPos);// load bundle removed >> > + >> > + artifactEntries.put(projectName, new String >> []{bundleSymName, bundleVersion, bundleId, removed}); >> > + stringStartPos = xml.indexOf("", >> stringEndPos); >> > + >> > + } >> > + } >> > + // if no projects on the server, it is ok to put an >> empty HashMap >> > + this.put (runtimeLoc, artifactEntries); >> > + >> > + fileStartPos = xml.indexOf("", fileEndPos); >> > + } >> > + } >> > + >> > + public String toXML () { >> > + String xmlString = ""; >> > + if (!isEmpty()) { >> > + xmlString = "\n \n"; >> > + >> > + Object[] serverKeySet = keySet().toArray(); >> > + for (int i = 0; i < serverKeySet.length; i++) { >> > + xmlString += " " + serverKeySet[i] + >> "\n"; >> > + Map projectMap = (Map> String[]>)get(serverKeySet[i]); >> > if (projectMap == null || projectMap.size() == 0) { >> > xmlString += " \n"; >> > } >> > @@ -227,7 +422,10 @@ public class ModuleArtifactMapper { >> > { >> > xmlString += " \n"; >> > xmlString += " " + >> (String)projectKeySet[j] + "\n"; >> > - xmlString += " " + >> (String)projectMap.get(projectKeySet[j]) + "\n"; >> > + xmlString += " " + >> (String)projectMap.get(projectKeySet[j])[0] + "\n"; >> > + xmlString += " " + >> (String)projectMap.get(projectKeySet[j])[1] + "\n"; >> > + xmlString += " " + >> (String)projectMap.get(projectKeySet[j])[2] + "\n"; >> > + xmlString += " " + >> (String)projectMap.get(projectKeySet[j])[3] + "\n"; >> > xmlString += " \n"; >> > } >> > xmlString += " \n"; >> > @@ -238,5 +436,94 @@ public class ModuleArtifactMapper { >> > return xmlString; >> > } >> > } >> > + // private methods >> > + private void addListener() { >> > + >> ResourcesPlugin.getWorkspace().addResourceChangeListener(new >> IResourceChangeListener() { >> > + @Override >> > + public void resourceChanged(IResourceChangeEvent >> event) { >> > + if(event.getType() == >> IResourceChangeEvent.POST_CHANGE) {// just listen to the project's change >> event >> > + try { >> > + event.getDelta().accept(new >> IResourceDeltaVisitor() { >> > + >> > + @Override >> > + public boolean visit(IResourceDelta delta) >> throws CoreException { >> > + if(delta.getKind() == >> IResourceDelta.REMOVED) { >> > + return >> processResourceRemoved(delta.getResource()); >> > + } else if(delta.getKind() == >> IResourceDelta.CHANGED) { >> > + return >> processResourceChanged(delta.getResource()); >> > + } >> > + return false; >> > + } >> > + >> > + private boolean >> processResourceRemoved(IResource res) { >> > + try { >> > + if(res instanceof IProject) { >> > + IProject p = (IProject) res; >> > + String projectName = >> p.getName(); >> > + >> > + Iterator> Map>> iter = serverBundleEntries.entrySet().iterator(); >> > + while(iter.hasNext()) { >> > + Map.Entry> String[]>> serverEntry = iter.next(); >> > + Map >> bundleMap = serverEntry.getValue(); >> > + String[] value = >> bundleMap.get(projectName); >> > + if(value != null) { >> > + value[3] = "true";// >> set removed flag to true >> > + } >> > + } >> > + } >> > + } catch (Exception e) { >> > + e.printStackTrace(); >> > + } >> > + return true; >> > + } >> > + >> > + private boolean >> processResourceChanged(IResource res) { >> > + try { >> > + >> if(res.getFullPath().toString().endsWith(".MF")) {// the project's menifest >> file is changed >> > + BufferedReader br = new >> BufferedReader(new FileReader(res.getLocation().toFile())); >> > + String projectName = >> res.getFullPath().toString().split("/")[1]; >> > + String fc = br.readLine(); >> > + String symbolicName = null, >> version = null; >> > + boolean bss = false, bvs = false; >> > + while(fc != null && (! bss || ! >> bvs)) { >> > + >> if(fc.startsWith("Bundle-SymbolicName")) { >> > + int index = >> fc.indexOf(":"); >> > + symbolicName = >> fc.substring(index+1).trim();bss = true; >> > + } else if >> (fc.startsWith("Bundle-Version")) { >> > + int index = >> fc.indexOf(":"); >> > + version = >> fc.substring(index+1).trim();bvs = true; >> > + } >> > + fc = br.readLine(); >> > + } >> > + Iterator> Map>> iter = serverBundleEntries.entrySet().iterator(); >> > + while(iter.hasNext()) { >> > + Map.Entry> String[]>> serverEntry = iter.next(); >> > + Map >> bundleMap = serverEntry.getValue(); >> > + >> > + String[] value = >> bundleMap.get(projectName); >> > + if(value != null) { >> > + >> if(value[0].equals(symbolicName) && value[1].equals(version)) break; >> > + value[0] = symbolicName; >> value[1] = version; >> > + } >> > + } >> > + } >> > + } catch (Exception e) { >> > + e.printStackTrace(); >> > + } >> > + return true; >> > + } >> > + >> > + }); >> > + } catch (CoreException e) { >> > + e.printStackTrace(); >> > + } >> > + } >> > + >> > + } >> > + }, IResourceChangeEvent.POST_CHANGE); >> > + >> > + } >> > + >> > + >> > >> > } >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java >> Tue Jun 28 05:28:54 2011 >> > @@ -34,6 +34,8 @@ public class Messages extends NLS { >> > public static String STOP_FAIL; >> > public static String UNDEPLOY_FAIL; >> > public static String REDEPLOY_FAIL; >> > + public static String RESTART_OSGIBUNDLE_FAIL; >> > + public static String OSGI_ARIES_NOT_INSTALLED; >> > public static String REFRESH_FAIL; >> > public static String REFRESH_NO_CONFIGURATION_FAIL; >> > public static String REFRESH_NO_BUNDLE_FAIL; >> > @@ -76,5 +78,7 @@ public class Messages extends NLS { >> > public static String moduleExportError; >> > >> > public static String serverStopFailed; >> > + public static String frameworkMBeanNotFound; >> > + public static String multipleFramworkMBeans; >> > >> > } >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties >> Tue Jun 28 05:28:54 2011 >> > @@ -21,6 +21,8 @@ START_FAIL=Starting of module failed. S >> > STOP_FAIL=Stopping of module failed. See log for details. >> > UNDEPLOY_FAIL=Undeploy of module failed. See log for details. >> > REDEPLOY_FAIL=Redeploy of module failed. See log for details. >> > +RESTART_OSGIBUNDLE_FAIL=Restart of OSGI bundle failed. The bundle must >> be the start state. >> > +OSGI_ARIES_NOT_INSTALLED=The Aries tool is not installed. You can >> download it from " >> http://public.dhe.ibm.com/ibmdl/export/pub/software/rational/OSGiAppTools >> ". >> > REFRESH_FAIL=Refresh of bundle failed. See log for details. >> > REFRESH_NO_CONFIGURATION_FAIL=The configuration ID of OSGi application >> project {0} can not be found. >> > REFRESH_NO_BUNDLE_FAIL=The bundle ID of OSGI bundle project {0} in OSGi >> application project {1} can not be found. >> > @@ -61,3 +63,5 @@ moduleModified=Modified >> > moduleExportError=Module {0} failed to export. >> > >> > serverStopFailed=Error stopping server. >> > +frameworkMBeanNotFound=Framework mbean not found. >> > +multipleFramworkMBeans=Found multiple framework mbeans. >> > >> > Modified: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java?rev=1140441&r1=1140440&r2=1140441&view=diff >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java >> (original) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java >> Tue Jun 28 05:28:54 2011 >> > @@ -63,9 +63,9 @@ public final class AriesHelper { >> > public static IModule[] getChildModules(IModule ebaModule) { >> > if (AriesHelper.isAriesInstalled()) { >> > try { >> > - Class class1 = >> Class.forName("com.ibm.etools.aries.internal.core.modules.AriesModuleDelegate"); >> > + Class class1 = >> Class.forName("com.ibm.etools.aries.internal.core.modules.AriesModuleDelegate"); >> > Method method = class1.getMethod("getChildModules"); >> > - Constructor constructor = >> class1.getConstructor(IProject.class); >> > + Constructor constructor = >> class1.getConstructor(IProject.class); >> > Object object = >> constructor.newInstance(ebaModule.getProject()); >> > return (IModule[]) method.invoke(object); >> > } catch (Exception e) { >> > @@ -78,7 +78,7 @@ public final class AriesHelper { >> > public static String getSymbolicName(IModule bundleModule) { >> > if (AriesHelper.isAriesInstalled()) { >> > try { >> > - Class class1 = >> Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUtils"); >> > + Class class1 = >> Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUtils"); >> > Method method = >> class1.getMethod("getBundleSymbolicName", IProject.class); >> > return (String) method.invoke(null, >> bundleModule.getProject()); >> > } catch (Exception e) { >> > @@ -87,4 +87,5 @@ public final class AriesHelper { >> > } >> > return null; >> > } >> > + >> > } >> > >> > Added: >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java >> > URL: >> http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java?rev=1140441&view=auto >> > >> ============================================================================== >> > --- >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java >> (added) >> > +++ >> geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java >> Tue Jun 28 05:28:54 2011 >> > @@ -0,0 +1,104 @@ >> > +/* >> > + * Licensed to the Apache Software Foundation (ASF) under one or more >> > + * contributor license agreements. See the NOTICE file distributed >> with >> > + * this work for additional information regarding copyright ownership. >> > + * The ASF licenses this file to You under the Apache License, Version >> 2.0 >> > + * (the "License"); you may not use this file except in compliance with >> > + * the License. You may obtain a copy of the License at >> > + * >> > + * http://www.apache.org/licenses/LICENSE-2.0 >> > + * >> > + * Unless required by applicable law or agreed to in writing, software >> > + * distributed under the License is distributed on an "AS IS" BASIS, >> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or >> implied. >> > + * See the License for the specific language governing permissions and >> > + * limitations under the License. >> > + */ >> > +package org.apache.geronimo.st.v30.core.osgi; >> > + >> > +import java.lang.reflect.Method; >> > + >> > +import org.apache.geronimo.st.v30.core.GeronimoUtils; >> > +import org.apache.geronimo.st.v30.core.ModuleArtifactMapper; >> > +import org.apache.geronimo.st.v30.core.internal.Messages; >> > +import org.eclipse.core.resources.IProject; >> > +import org.eclipse.wst.server.core.IModule; >> > +import org.eclipse.wst.server.core.IServer; >> > +import org.osgi.framework.Version; >> > + >> > +public class OSGIBundleHelper { >> > + public static void addBundleToPublishedMap(IServer server, IModule >> module, long bundleId) throws Exception { >> > + if(! GeronimoUtils.isBundleModule(module)) return; >> > + try { >> > + String[] strArray = >> getBundleSymbolicNameAndVersion(module.getProject()); >> > + ModuleArtifactMapper.getInstance().addBundleEntry(server, >> module, strArray[0], strArray[1], bundleId); >> > + } catch (Exception e) { >> > + throw e; >> > + } >> > + } >> > + public static boolean checkBundleInPublishedMap(IServer server, >> IModule module) { >> > + String symName = >> ModuleArtifactMapper.getInstance().resolveBundleByModule(server, module); >> > + return symName == null ? false : true; >> > + } >> > + >> > + public static void removeBundleFromPublishedMap(IServer server, >> IModule module) { >> > + ModuleArtifactMapper.getInstance().removeBundle(server, >> module); >> > + } >> > + >> > + public static boolean isBundle(IModule module) { >> > + return GeronimoUtils.isBundleModule(module); >> > + } >> > + public static boolean isBundle(IProject project) throws Exception { >> > + boolean ret = false; >> > + if(AriesHelper.isAriesInstalled()) { >> > + Class ariesUtilsClass = >> Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUtils"); >> > + Method method = ariesUtilsClass.getMethod("isOSGIBundle", >> IProject.class); >> > + ret = (Boolean) method.invoke(null, project); >> > + } else { >> > + throw new Exception(Messages.OSGI_ARIES_NO > > -- Lei Wang (Rex) rwonly AT apache.org --000e0cd4b9e06b077e04a6f83022 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable You need take care to maintain such list in memory because you also need up= date it every time you install/uninstall/republish a bundle. So, just have = a try to query the bundle id before every operation, and see if it bring si= gnificant impact.

-rex

2011/6/29 Yi Xiao <xiaoyijhondevelop@gm= ail.com>
Yes. As you said, the bundle ids can change. However, I still think it= 's necessary to cache bundle ids in GEP side, for GEP needn't invok= e OSGI api to query the bundle id when every republish, start, stop or unin= stall bundle. We can synchronize the bundle ids when the server starts, res= tarts and eclipse starts.


On Tue, Jun 28, 2011 at 1:48 PM, Jarek G= awor <jgawor@gmail.com> wrote:
-1 on this. I think this was committed prematurely. We were having a
conversation on GERONIMODEVTOOLS-75 that caching bundle ids is bad.
They are not the same as configuration ids for regular EE modules and
they do change or can change quite frequently.

Also, this change adds a number OSGIBundleHelper.isBundle() checks.
There should only really be one (or just a few) checks for a bundle
and then a bunch of separate and independent functions for managing
the bundles deployment, undeployment, etc. so that it's very clean and<= br> easy to see what the given function should be doing.

Jarek

On Tue, Jun 28, 2011 at 1:28 AM, =A0<hanhongfang@apache.org> wrote:
> Author: hanhongfang
> Date: Tue Jun 28 05:28:54 2011
> New Revision: 1140441
>
> URL: http://svn.apache.org/viewvc?rev=3D1140441&view= =3Drev
> Log:
> GERONIMODEVTOOLS-759 Using the new APIs to manage the bundles status b= oth in GEP and Server side. Thanks Yi Xiao for the patch.
>
> Added:
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBund= leHelper.java =A0 (with props)
> Modified:
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.runtime.v30/.classpath
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.runtime.v30/META-INF/MANIFEST.MF
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.runtime.v30/pom.xml
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUti= ls.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConne= ctionFactory.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServe= rBehaviour.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServe= rBehaviourDelegate.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils= .java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifac= tMapper.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Mess= ages.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Mess= ages.properties
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHel= per.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiCons= tants.java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages= .java
> =A0 =A0geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.ui/src/main/java/org/apache/geronimo/st/v30/ui/internal/Messages= .properties
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.runtime.v30/.classpath
> URL: ht= tp://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/o= rg.apache.geronimo.runtime.v30/.classpath?rev=3D1140441&r1=3D1140440&am= p;r2=3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/.classpath (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/.classpath Tue Jun 28 05:28:54 2011
> @@ -1,12 +1,15 @@
> =A0<?xml version=3D"1.0" encoding=3D"UTF-8"?>= ;
> =A0<classpath>
> + =A0 =A0 =A0 <classpathentry exported=3D"true" kind=3D&q= uot;lib" path=3D"lib/geronimo-bundle-recorder-3.0-SNAPSHOT.jar&qu= ot;/>
> + =A0 =A0 =A0 <classpathentry exported=3D"true" kind=3D&q= uot;lib" path=3D"lib/geronimo-cli-3.0-SNAPSHOT.jar"/>
> + =A0 =A0 =A0 <classpathentry exported=3D"true" kind=3D&q= uot;lib" path=3D"lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"= />
> + =A0 =A0 =A0 <classpathentry exported=3D"true" kind=3D&q= uot;lib" path=3D"lib/geronimo-deploy-tool-3.0-SNAPSHOT.jar"/= >
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/plexus-archiver-1.0-alpha-12.jar"/>=
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/slf4j-api-1.5.5.jar"/>
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/slf4j-simple-1.5.5.jar"/>
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-common-3.0-SNAPSHOT.jar"/>=
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-crypto-3.0-SNAPSHOT.jar"/>=
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-deploy-config-3.0-SNAPSHOT.jar&quo= t;/>
> - =A0 =A0 =A0 <classpathentry exported=3D"true" kind=3D&q= uot;lib" path=3D"lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"= />
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-deployment-3.0-SNAPSHOT.jar"/= >
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-j2ee-schema-3.0-SNAPSHOT.jar"= />
> =A0 =A0 =A0 =A0<classpathentry exported=3D"true" kind=3D&= quot;lib" path=3D"lib/geronimo-kernel-3.0-SNAPSHOT.jar"/>=
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.runtime.v30/META-INF/MANIFEST.MF
> URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk= /plugins/org.apache.geronimo.runtime.v30/META-INF/MANIFEST.MF?rev=3D1140441= &r1=3D1140440&r2=3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/META-INF/MANIFEST.MF (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/META-INF/MANIFEST.MF Tue Jun 28 05:28:54 2011
> @@ -7,7 +7,6 @@ Require-Bundle:
> =A0org.eclipse.osgi,
> =A0org.apache.geronimo.runtime.common;visibility:=3Dreexport
> =A0Bundle-ClassPath: lib/geronimo-common-3.0-SNAPSHOT.jar,
> - lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar,
> =A0lib/geronimo-deployment-3.0-SNAPSHOT.jar,
> =A0lib/geronimo-j2ee-schema-3.0-SNAPSHOT.jar,
> =A0lib/geronimo-kernel-3.0-SNAPSHOT.jar,
> @@ -18,7 +17,11 @@ Bundle-ClassPath: lib/geronimo-common-3.
> =A0lib/plexus-archiver-1.0-alpha-12.jar,
> =A0lib/geronimo-crypto-3.0-SNAPSHOT.jar,
> =A0lib/slf4j-api-1.5.5.jar,
> - lib/slf4j-simple-1.5.5.jar
> + lib/slf4j-simple-1.5.5.jar,
> + lib/geronimo-bundle-recorder-3.0-SNAPSHOT.jar,
> + lib/geronimo-cli-3.0-SNAPSHOT.jar,
> + lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar,
> + lib/geronimo-deploy-tool-3.0-SNAPSHOT.jar
> =A0Export-Package:
> =A0org.apache.geronimo.common;version=3D3.0,
> =A0org.apache.geronimo.common.propertyeditor;version=3D3.0,
> @@ -50,6 +53,7 @@ Export-Package:
> =A0org.apache.geronimo.deployment.util;version=3D3.0,
> =A0org.apache.geronimo.deployment.xml;version=3D3.0,
> =A0org.apache.geronimo.deployment.xmlbeans;version=3D3.0,
> + org.apache.geronimo.deployment.cli;version=3D3.0,
> =A0org.apache.geronimo.gbean;version=3D3.0,
> =A0org.apache.geronimo.gbean.annotation;version=3D3.0,
> =A0org.apache.geronimo.gbean.runtime;version=3D3.0,
> @@ -82,6 +86,7 @@ Export-Package:
> =A0org.apache.geronimo.system.serverinfo;version=3D3.0,
> =A0org.apache.geronimo.system.threads;version=3D3.0,
> =A0org.apache.geronimo.system.util;version=3D3.0,
> + org.apache.geronimo.cli;version=3D3.0,
> =A0org.codehaus.plexus.archiver;version=3D3.0,
> =A0org.codehaus.plexus.archiver.bzip2;version=3D3.0,
> =A0org.codehaus.plexus.archiver.dir;version=3D3.0,
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.runtime.v30/pom.xml
> URL: http:= //svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.= apache.geronimo.runtime.v30/pom.xml?rev=3D1140441&r1=3D1140440&r2= =3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/pom.xml (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .runtime.v30/pom.xml Tue Jun 28 05:28:54 2011
> @@ -122,6 +122,23 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 <artifactId>geronimo-deploy-jsr88</artifactId>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 <version>${geronimoVersion}</version>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 </a= rtifactItem>
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<a= rtifactItem>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<groupId>org.apache.geronimo.framework</groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<artifactId>geronimo-bundle-recorder</artifactId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<version>${geronimoVersion}</version>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</= artifactItem>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<a= rtifactItem>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<groupId>org.apache.geronimo.framework</groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<artifactId>geronimo-cli</artifactId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<version>${geronimoVersion}</version>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</= artifactItem>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<a= rtifactItem>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<groupId>org.apache.geronimo.framework</groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<artifactId>geronimo-deploy-tool</artifactId>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0<version>${geronimoVersion}</version>
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</= artifactItem>
> +
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <ar= tifactItem>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 <groupId>org.apache.geronimo.framework</groupId>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 <artifactId>geronimo-common</artifactId>
> @@ -232,6 +249,21 @@
> =A0 =A0 =A0 =A0 </dependency>
> =A0 =A0 =A0 =A0 <dependency>
> =A0 =A0 =A0 =A0 =A0 =A0 <groupId>org.apache.geronimo.framework&l= t;/groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0<artifactId>geronimo-bundle-recorder<= ;/artifactId>
> + =A0 =A0 =A0 =A0 =A0 =A0<version>${geronimoVersion}</version= >
> + =A0 =A0 =A0 =A0</dependency>
> + =A0 =A0 =A0 =A0<dependency>
> + =A0 =A0 =A0 =A0 =A0 =A0<groupId>org.apache.geronimo.framework&= lt;/groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0<artifactId>geronimo-cli</artifactId= >
> + =A0 =A0 =A0 =A0 =A0 =A0<version>${geronimoVersion}</version= >
> + =A0 =A0 =A0 =A0</dependency>
> + =A0 =A0 =A0 =A0<dependency>
> + =A0 =A0 =A0 =A0 =A0 =A0<groupId>org.apache.geronimo.framework&= lt;/groupId>
> + =A0 =A0 =A0 =A0 =A0 =A0<artifactId>geronimo-deploy-tool</ar= tifactId>
> + =A0 =A0 =A0 =A0 =A0 =A0<version>${geronimoVersion}</version= >
> + =A0 =A0 =A0 =A0</dependency>
> + =A0 =A0 =A0 =A0<dependency>
> + =A0 =A0 =A0 =A0 =A0 =A0<groupId>org.apache.geronimo.framework&= lt;/groupId>
> =A0 =A0 =A0 =A0 =A0 =A0 <artifactId>geronimo-common</artifact= Id>
> =A0 =A0 =A0 =A0 =A0 =A0 <version>${geronimoVersion}</version&= gt;
> =A0 =A0 =A0 =A0 </dependency>
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/Deployment= Utils.java
> URL: http://svn.apache.org= /viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.= st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.j= ava?rev=3D1140441&r1=3D1140440&r2=3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.= java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.= java Tue Jun 28 05:28:54 2011
> @@ -135,6 +135,10 @@ public class DeploymentUtils {
> =A0 =A0 =A0 =A0 return file;
> =A0 =A0 }
>
> + =A0 =A0public static int getModuleState(IServer server, IModule modu= le) {
> + =A0 =A0 =A0 =A0return server.getModuleState(new IModule[] {module});=
> + =A0 =A0}
> +
> =A0 =A0 private static String getModuleExtension(IModule module) {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "DeploymentUtils.getModuleExtension", module);
>
> @@ -288,7 +292,6 @@ public class DeploymentUtils {
> =A0 =A0 =A0*/
> =A0 =A0 public static String getLastKnownConfigurationId(IModule modul= e, IServer server) throws Exception {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "DeploymentUtils.getLastKnownConfigurationId", module, server)= ;
> -
> =A0 =A0 =A0 =A0 IGeronimoServer gs =3D (IGeronimoServer) server.getAda= pter(IGeronimoServer.class);
> =A0 =A0 =A0 =A0 String currentId =3D gs.getVersionHandler().getConfigI= D(module);
> =A0 =A0 =A0 =A0 String publishedId =3D ModuleArtifactMapper.getInstanc= e().resolveArtifact(server, module);
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoCo= nnectionFactory.java
> URL: http://svn.= apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache= .geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/Geronim= oConnectionFactory.java?rev=3D1140441&r1=3D1140440&r2=3D1140441&= ;view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnecti= onFactory.java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnecti= onFactory.java Tue Jun 28 05:28:54 2011
> @@ -52,7 +52,6 @@ public class GeronimoConnectionFactory {
>
> =A0 =A0 public DeploymentManager getDeploymentManager(IServer server) = throws DeploymentManagerCreationException {
> =A0 =A0 =A0 =A0 System.setProperty(Context.INITIAL_CONTEXT_FACTORY, &q= uot;com.sun.jndi.rmi.registry.RegistryContextFactory");
> -
> =A0 =A0 =A0 =A0 DeploymentManager dm =3D (DeploymentManager) connectio= ns.get(server.getId());
> =A0 =A0 =A0 =A0 IGeronimoServer geronimoServer =3D getGeronimoServer(s= erver);
> =A0 =A0 =A0 =A0 if (dm =3D=3D null) {
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSe= rverBehaviour.java
> URL: http://svn.a= pache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.= geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/Geronimo= ServerBehaviour.java?rev=3D1140441&r1=3D1140440&r2=3D1140441&vi= ew=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBe= haviour.java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBe= haviour.java Tue Jun 28 05:28:54 2011
> @@ -24,6 +24,7 @@ import java.util.Set;
>
> =A0import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCrea= tionException;
> =A0import javax.management.MBeanServerConnection;
> +import javax.management.ObjectName;
> =A0import javax.naming.directory.NoSuchAttributeException;
>
> =A0import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManag= er;
> @@ -68,10 +69,25 @@ public class GeronimoServerBehaviour ext
> =A0 =A0 =A0* @see org.apache.geronimo.st.v30.core.GeronimoServerBehavi= ourDelegate#stopKernel()
> =A0 =A0 =A0*/
> =A0 =A0 protected void stopKernel() {
> - =A0 =A0 =A0 =A0if (kernel !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0kernel.shutdown();
> - =A0 =A0 =A0 =A0 =A0 =A0kernel =3D null;
> - =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 MBeanServerConnection co= nnection =3D getServerConnection();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Set<ObjectName> objectNameSet =3D<= br> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.queryNames(ne= w ObjectName("osgi.core:type=3Dframework,*"), null);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (objectNameSet.isEmpty()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new Exception("Framew= ork mbean not found");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (objectNameSet.size() =3D=3D 1= ) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.INFO, "Se= rver shutdown starting...", Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Object obj =3D objectNameSet.ite= rator().next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.invoke((ObjectName) o= bj, "stopBundle",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 new Object[] { 0 }, new String[] { long.class.getName()= });
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.INFO, "Se= rver shutdown completed", Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new Exception("Found = multiple framework mbeans");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // TODO Auto-generated c= atch block
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR,= e.getMessage(), e, Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 }
>
> =A0 =A0 /**
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSe= rverBehaviourDelegate.java
> URL: http:= //svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.= apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/G= eronimoServerBehaviourDelegate.java?rev=3D1140441&r1=3D1140440&r2= =3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBe= haviourDelegate.java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBe= haviourDelegate.java Tue Jun 28 05:28:54 2011
> @@ -30,6 +30,7 @@ import java.util.Iterator;
> =A0import java.util.LinkedHashMap;
> =A0import java.util.List;
> =A0import java.util.Map;
> +import java.util.Set;
> =A0import java.util.Timer;
> =A0import java.util.concurrent.TimeUnit;
> =A0import java.util.concurrent.locks.Lock;
> @@ -39,11 +40,13 @@ import javax.enterprise.deploy.spi.Deplo
> =A0import javax.enterprise.deploy.spi.Target;
> =A0import javax.enterprise.deploy.spi.TargetModuleID;
> =A0import javax.management.MBeanServerConnection;
> +import javax.management.ObjectName;
> =A0import javax.management.remote.JMXConnector;
> =A0import javax.management.remote.JMXConnectorFactory;
> =A0import javax.management.remote.JMXServiceURL;
>
> =A0import org.apache.geronimo.deployment.plugin.jmx.ExtendedDeployment= Manager;
> +import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentMana= ger;
> =A0import org.apache.geronimo.gbean.AbstractName;
> =A0import org.apache.geronimo.kernel.repository.Artifact;
> =A0import org.apache.geronimo.st.v30.core.UpdateServerStateTask;
> @@ -56,6 +59,8 @@ import org.apache.geronimo.st.v30.core.o
> =A0import org.apache.geronimo.st.v30.core.operations.SharedLibEntryCre= ationOperation;
> =A0import org.apache.geronimo.st.v30.core.operations.SharedLibEntryDat= aModelProvider;
> =A0import org.apache.geronimo.st.v30.core.osgi.AriesHelper;
> +import org.apache.geronimo.st.v30.core.osgi.OSGIBundleHelper;
> +import org.apache.geronimo.st.v30.core.osgi.OsgiConstants;
> =A0import org.eclipse.core.commands.ExecutionException;
> =A0import org.eclipse.core.runtime.CoreException;
> =A0import org.eclipse.core.runtime.IPath;
> @@ -131,7 +136,6 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0 =A0 =A0 =A0 return;
>
> =A0 =A0 =A0 =A0 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR= _MAIN_TYPE_NAME, getRuntimeClass());
> -
> =A0 =A0 =A0 =A0 GeronimoRuntimeDelegate runtime =3D getRuntimeDelegate= ();
>
> =A0 =A0 =A0 =A0 IVMInstall vmInstall =3D runtime.getVMInstall();
> @@ -589,7 +593,8 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0*/
> =A0 =A0 public void publishModule(int kind, int deltaKind, IModule[] m= odule, IProgressMonitor monitor) throws CoreException {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.publishModule", publishKindTo= String(kind), deltaKindToString(deltaKind), Arrays.asList(module), monitor)= ;
> -
> + =A0 =A0 =A0 =A0/* remove the OSGI bundles which are removed */
> + =A0 =A0 =A0 =A0this.removeObsoleteOSGIBundles();
> =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 //NO_CHANGE need if app is associated but not = started and no delta
> =A0 =A0 =A0 =A0 =A0 =A0 if (deltaKind =3D=3D NO_CHANGE && modu= le.length =3D=3D 1) {
> @@ -615,7 +620,7 @@ abstract public class GeronimoServerBeha
>
> =A0 =A0 =A0 =A0 Trace.tracePoint("Exit ", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.publishModule");
> =A0 =A0 }
> -
> +
> =A0 =A0 public Lock getPublishLock() {
> =A0 =A0 =A0 =A0 return publishLock;
> =A0 =A0 }
> @@ -646,6 +651,27 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
>
> + =A0 =A0protected void removeObsoleteOSGIBundles() throws CoreExcepti= on {
> + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> bundleMap =3D Mod= uleArtifactMapper.getInstance().getServerBundlesMap(getServer());
> + =A0 =A0 =A0 =A0 =A0 =A0synchronized(bundleMap) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Iterator<Map.Entry<String, Stri= ng[]>> bundleIter =3D bundleMap.entrySet().iterator();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while(bundleIter.hasNext()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Map.Entry<String, String[]= > bundleEntry =3D bundleIter.next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if("true".equals(bu= ndleEntry.getValue()[3])) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0long bundleId =3D Lon= g.parseLong(bundleEntry.getValue()[2]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IStatus status =3D th= is.removeOSGIBundleById(bundleId);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(status.isOK()) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bundleIter.re= move();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0} catch(Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0throw new CoreException(Status.CANCEL_STATUS)= ;
> + =A0 =A0 =A0 =A0}
> +
> + =A0 =A0}
> =A0 =A0 private void doPublishFinish(IProgressMonitor monitor) throws = CoreException =A0{
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.publishFinish", monitor);
>
> @@ -807,7 +833,6 @@ abstract public class GeronimoServerBeha
>
> =A0 =A0 protected void invokeCommand(int deltaKind, IModule module, IP= rogressMonitor monitor) throws CoreException {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.invokeCommand", deltaKindToSt= ring(deltaKind), module.getName());
> -
> =A0 =A0 =A0 =A0 ClassLoader old =3D Thread.currentThread().getContextC= lassLoader();
> =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 ClassLoader cl =3D getContextClassLoader(); > @@ -851,38 +876,61 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0*/
> =A0 =A0 protected void doAdded(IModule module, String configId, IProgr= essMonitor monitor) throws Exception {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.doAdded", module.getName(), c= onfigId);
> -
> - =A0 =A0 =A0 =A0configId =3D getLastKnowConfigurationId(module, confi= gId);
> + =A0 =A0 =A0 =A0if(OSGIBundleHelper.isBundle(module)) {
> + =A0 =A0 =A0 =A0 =A0 =A0configId =3D ModuleArtifactMapper.getInstance= ().resolveBundleByModule(getServer(), module);
> + =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0configId =3D getLastKnowConfigurationId(modul= e, configId);
> + =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0 IStatus status;
> =A0 =A0 =A0 =A0 TargetModuleID[] ids;
>
> =A0 =A0 =A0 =A0 if (configId =3D=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0Map<String, String> artifactsMap =3D Mo= duleArtifactMapper.getInstance().getServerArtifactsMap(getServer());
> - =A0 =A0 =A0 =A0 =A0 =A0if (artifactsMap !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0synchronized (artifactsMap) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(OSGIBundleHelper.isBundle(module)) {/= * If the module is the OSGI bundle */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map<String, String[]&= gt; bundlesMap =3D ModuleArtifactMapper.getInstance().getServerBundlesMap(g= etServer());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(bundlesMap !=3D null)= {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 synchron= ized (bundlesMap) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 Object[] ret =3D this.distributeOSGIBundles(module);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 status = =3D (IStatus) ret[0];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(statu= s.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 /* Add the bundle info into the ModuleArtifactMapper's bundle c= ache */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 Long bundleId =3D (Long) ret[1];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 OSGIBundleHelper.addBundleToPublishedMap(getServer(), module, bundl= eId);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* end h= ere */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 setModuleState(new IModule [] { module }, IServer.STATE_STARTED); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 doFail(status, Messages.DISTRIBUTE_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map<String, String>= ; artifactsMap =3D ModuleArtifactMapper.getInstance().getServerArtifactsMap= (getServer());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (artifactsMap !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0synchronized (artifactsMap) {=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D distribute= (module, monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status= , Messages.DISTRIBUTE_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ids =3D updateServerM= oduleConfigIDMap(module, status);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 status =3D distribute(module, = monitor);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!status.isOK()) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 doFail(status, Message= s.DISTRIBUTE_FAIL);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ids =3D updateServerModuleConf= igIDMap(module, status);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> - =A0 =A0 =A0 =A0 =A0 =A0} else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D distribute(module, monitor= );
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.DISTR= IBUTE_FAIL);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ids =3D updateServerModuleConfigIDMap= (module, status);
> - =A0 =A0 =A0 =A0 =A0 =A0}
> -
> - =A0 =A0 =A0 =A0 =A0 =A0status =3D start(ids, monitor);
> - =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.START_FAIL);<= br> > - =A0 =A0 =A0 =A0 =A0 =A0} else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule [] { modul= e }, IServer.STATE_STARTED);
> - =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D start(ids, monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.START= _FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule []= { module }, IServer.STATE_STARTED);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 =A0 =A0 //either (1) a configuration with the same mod= ule id exists already on the server
> =A0 =A0 =A0 =A0 =A0 =A0 //or (2) the module now has a different config= Id and the configuration on the server using
> @@ -899,32 +947,47 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0*/
> =A0 =A0 protected void doChanged(IModule module, String configId, IPro= gressMonitor monitor) throws Exception {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.doChanged", module.getName(),= configId);
> -
> - =A0 =A0 =A0 =A0configId =3D getLastKnowConfigurationId(module, confi= gId);
> - =A0 =A0 =A0 =A0if(configId !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0String moduleConfigId =3D getConfigId(module)= ;
> - =A0 =A0 =A0 =A0 =A0 =A0if (moduleConfigId.equals(configId)) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IStatus status =3D reDeploy(module, m= onitor);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.REDEP= LOY_FAIL);
> + =A0 =A0 =A0 =A0IStatus status =3D null;
> + =A0 =A0 =A0 =A0Object[] ret =3D null;
> + =A0 =A0 =A0 =A0if(OSGIBundleHelper.isBundle(module)) {
> + =A0 =A0 =A0 =A0 =A0 =A0boolean isPublished =3D OSGIBundleHelper.chec= kBundleInPublishedMap(getServer(), module);
> + =A0 =A0 =A0 =A0 =A0 =A0if(isPublished) status =3D doOSGIBundleRedepl= oy(module);
> + =A0 =A0 =A0 =A0 =A0 =A0else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D this.distributeOSGIBundles(mo= dule);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D (IStatus) ret[0];
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0if(status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(! isPublished) OSGIBundleHelper.ad= dBundleToPublishedMap(getServer(), module, (Long) ret[1]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule [] { modul= e }, IServer.STATE_STARTED);
> + =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.REDEPLOY_FAIL= );
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0configId =3D getLastKnowConfigurationId(modul= e, configId);
> + =A0 =A0 =A0 =A0 =A0 =A0if(configId !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String moduleConfigId =3D getConfigId= (module);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (moduleConfigId.equals(configId)) = {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D reDeploy(module, m= onitor);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messag= es.REDEPLOY_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IM= odule [] { module }, IServer.STATE_STARTED);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule []= { module }, IServer.STATE_STARTED);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//different configIds from wh= at needs to be undeployed to what will be deployed
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doRemoved(module, monitor); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, null, monitor= );
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 } else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//different configIds from what needs= to be undeployed to what will be deployed
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doRemoved(module, monitor);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, null, monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//The checked configuration no longer= exists on the server
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, configId, monitor); > =A0 =A0 =A0 =A0 =A0 =A0 }
> - =A0 =A0 =A0 =A0} else {
> - =A0 =A0 =A0 =A0 =A0 =A0//The checked configuration no longer exists = on the server
> - =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, configId, monitor);
> =A0 =A0 =A0 =A0 }
> -
> =A0 =A0 =A0 =A0 Trace.tracePoint("Exit ", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.doChanged");
> =A0 =A0 }
> -
> +
> =A0 =A0 private IStatus tryFileReplace(IModule[] module) {
> - =A0 =A0 =A0 =A0Trace.tracePoint("Entry", Activator.traceCo= re, "GeronimoServerBehaviourDelegate.tryFileReplace", module); > + =A0 =A0 =A0 =A0Trace.tracePoint("Entry", Activator.traceCo= re, "GeronimoServerBehaviourDelegate.tryFileReplace", module.toSt= ring());
>
> =A0 =A0 =A0 =A0 IModule webModule =3D module[module.length - 1];
> =A0 =A0 =A0 =A0 if (webModule.isExternal()) {
> @@ -1076,30 +1139,44 @@ abstract public class GeronimoServerBeha
> =A0 =A0 }
>
> =A0 =A0 private void _doRemove(IModule module, IProgressMonitor monito= r) throws Exception {
> - =A0 =A0 =A0 =A0IStatus status =3D unDeploy(module, monitor);
> - =A0 =A0 =A0 =A0if (!status.isOK()) {
> - =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.UNDEPLOY_FAIL);
> - =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 IStatus status =3D null;
> + =A0 =A0 =A0 if(OSGIBundleHelper.isBundle(module)) {/* If the module = is a OSGI bundle */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 // must consider the situation of the pr= oject name or bundle name or both have been changed, not done yet!!!
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 status=3D this.removeOSGIBundle(module);=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 OSGIBundleHelper.removeB= undleFromPublishedMap(getServer(), module);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 doFail(status, Messages.= DISTRIBUTE_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0status =3D unDeploy(module, monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0if (!status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(status, Messages.UNDEPLOY_FAIL= );
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 }
> +
> +
> =A0 =A0 }
>
> =A0 =A0 protected void doNoChange(IModule module, IProgressMonitor mon= itor) throws Exception {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.doNoChange", module.getName()= );
> -
> - =A0 =A0 =A0 =A0DeploymentManager dm =3D DeploymentCommandFactory.get= DeploymentManager(getServer());
> - =A0 =A0 =A0 =A0String configId =3D DeploymentUtils.getLastKnownConfi= gurationId(module, getServer());
> - =A0 =A0 =A0 =A0if (configId !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0IModule[] rootModule =3D new IModule[] { modu= le };
> - =A0 =A0 =A0 =A0 =A0 =A0if (DeploymentUtils.isStartedModule(dm, confi= gId) !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IServer.ST= ATE_STARTED);
> - =A0 =A0 =A0 =A0 =A0 =A0} else if (DeploymentUtils.isStoppedModule(dm= , configId) !=3D null) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IServer.ST= ATE_STOPPED);
> + =A0 =A0 =A0 =A0if(! OSGIBundleHelper.isBundle(module)) {/* if the mo= dule is the bundle, just return! */
> + =A0 =A0 =A0 =A0 =A0 =A0DeploymentManager dm =3D DeploymentCommandFac= tory.getDeploymentManager(getServer());
> + =A0 =A0 =A0 =A0 =A0 =A0String configId =3D DeploymentUtils.getLastKn= ownConfigurationId(module, getServer());
> + =A0 =A0 =A0 =A0 =A0 =A0if (configId !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IModule[] rootModule =3D new IModule[= ] { module };
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (DeploymentUtils.isStartedModule(d= m, configId) !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IS= erver.STATE_STARTED);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (DeploymentUtils.isStoppedM= odule(dm, configId) !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IS= erver.STATE_STOPPED);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IS= erver.STATE_UNKNOWN);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ModuleArtifactMapper mapper =3D Modul= eArtifactMapper.getInstance();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mapper.addArtifactEntry(getServer(), = module, configId);
> =A0 =A0 =A0 =A0 =A0 =A0 } else {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setModuleState(rootModule, IServer.ST= ATE_UNKNOWN);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, null, monitor);
> =A0 =A0 =A0 =A0 =A0 =A0 }
> - =A0 =A0 =A0 =A0 =A0 =A0ModuleArtifactMapper mapper =3D ModuleArtifac= tMapper.getInstance();
> - =A0 =A0 =A0 =A0 =A0 =A0mapper.addArtifactEntry(getServer(), module, = configId);
> - =A0 =A0 =A0 =A0} else {
> - =A0 =A0 =A0 =A0 =A0 =A0doAdded(module, null, monitor);
> =A0 =A0 =A0 =A0 }
>
> =A0 =A0 =A0 =A0 Trace.tracePoint("Exit ", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.doNoChange");
> @@ -1138,7 +1215,75 @@ abstract public class GeronimoServerBeha
> =A0 =A0 =A0 =A0 IDeploymentCommand cmd =3D DeploymentCommandFactory.cr= eateDistributeCommand(module, getServer());
> =A0 =A0 =A0 =A0 return cmd.execute(monitor);
> =A0 =A0 }
> -
> +
> + =A0 =A0protected IStatus doOSGIBundleRedeploy(IModule module) throws= Exception {
> + =A0 =A0 =A0 =A0IStatus status =3D Status.CANCEL_STATUS;
> + =A0 =A0 =A0 =A0Map<String, String[]> bundlesMap =3D ModuleArti= factMapper.getInstance().getServerBundlesMap(getServer());
> + =A0 =A0 =A0 =A0if(bundlesMap !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0synchronized (bundlesMap) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D this.removeOSGIBundle(modu= le);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0OSGIBundleHelper.removeBundle= FromPublishedMap(getServer(), module);/* remove the bundle from cache */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* install the bundle as a ne= w one */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Object[] ret =3D this.distrib= uteOSGIBundles(module);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0status =3D (IStatus) ret[0];<= br> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(status.isOK()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Add the bundle inf= o into the ModuleArtifactMapper's bundle cache */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Long bundleId =3D (Lo= ng) ret[1];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0OSGIBundleHelper.addB= undleToPublishedMap(getServer(), module, bundleId);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* end here */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0return status;
> + =A0 =A0}
> + =A0 =A0protected Object[] distributeOSGIBundles(IModule module) thro= ws Exception {
> + =A0 =A0 =A0 RemoteDeploymentManager rDm =3D (RemoteDeploymentManager= )DeploymentCommandFactory.getDeploymentManager(this.getServer());
> + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Get target file */
> + =A0 =A0 =A0 =A0 =A0 =A0File f =3D DeploymentUtils.getTargetFile(getS= erver(), module);
> + =A0 =A0 =A0 =A0 =A0 =A0if (f =3D=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0throw new CoreException(new Status(IS= tatus.ERROR, Activator.PLUGIN_ID,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Messages.bind(Message= s.moduleExportError, module.getProject().getName())));
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0/* end here */
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 long bundleId =3D rDm.re= cordInstall(f, OsgiConstants.BUNDLE_IS_INPLACE, OsgiConstants.BUNDLE_DEFAUL= T_START_LEVLE);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 boolean ss =3D this._sta= rtBundle(bundleId);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(ss) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return n= ew Object[] {Status.OK_STATUS, new Long(bundleId)};
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.tr= ace(Trace.ERROR, "The Bundle: " + module.getName() + " could= not be installed", null, Activator.logCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return n= ew Object[] {Status.CANCEL_STATUS};
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (IOException e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR,= "The Bundle: " + module.getName() + " could not be installe= d", e, Activator.logCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return new Object[] {Sta= tus.CANCEL_STATUS};
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0}
> + =A0 =A0protected IStatus removeOSGIBundle(IModule module) throws Exc= eption {
> + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 long bundleId =3D ModuleArtifactMapper.g= etInstance().getBundleId(getServer(), module);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return this.removeOSGIBu= ndleById(bundleId);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR,= "The Bundle: " + module.getName() + " could not be unInstal= led", e, Activator.logCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return Status.CANCEL_STA= TUS;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0}
> +
> + =A0 =A0protected IStatus removeOSGIBundleById(long bundleId) throws = Exception {
> + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0boolean isSuccess =3D this._unInstallBundle(b= undleId);
> + =A0 =A0 =A0 =A0 =A0 =A0if(isSuccess) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return Status.OK_STATUS;
> + =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return Status.CANCEL_STATUS;
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0} catch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0return Status.CANCEL_STATUS;
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> =A0 =A0 protected IStatus start(IModule module, IProgressMonitor monit= or) throws Exception {
> =A0 =A0 =A0 =A0 TargetModuleID id =3D DeploymentUtils.getTargetModuleI= D(getServer(), module);
> =A0 =A0 =A0 =A0 IDeploymentCommand cmd =3D DeploymentCommandFactory.cr= eateStartCommand(new TargetModuleID[] { id }, module, getServer());
> @@ -1462,19 +1607,57 @@ abstract public class GeronimoServerBeha
> =A0 =A0 public void startModule(IModule[] module, IProgressMonitor mon= itor) {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.startModule", Arrays.asList(m= odule));
> =A0 =A0 =A0 =A0 try {
> - =A0 =A0 =A0 =A0 =A0 =A0start(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0if(OSGIBundleHelper.isBundle(module[0])) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0boolean isIn =3D OSGIBundleHelper.che= ckBundleInPublishedMap(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int state =3D DeploymentUtils.getModu= leState(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(isIn && (state =3D=3D ISer= ver.STATE_STOPPED)) startOSGIBundle(module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else throw new Exception(Messages.STA= RT_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0start(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 } catch (Exception e) {
> =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR, "Error starting = module " + module[0].getName(), e, Activator.logCore);
> =A0 =A0 =A0 =A0 =A0 =A0 throw new RuntimeException("Error startin= g module " + module[0].getName(), e);
> - =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 Trace.tracePoint("Exit ", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.startModule");
> =A0 =A0 }
>
> + =A0 =A0protected void startOSGIBundle(IModule module) throws Excepti= on {
> +
> + =A0 =A0 =A0 =A0long bundleId =3D OSGIBundleHelper.getOSGIBundleId(ge= tServer(), module);
> + =A0 =A0 =A0 =A0if(bundleId =3D=3D -1) throw new Exception("can = not start bundle");
> + =A0 =A0 =A0 =A0boolean ss =3D this._startBundle(bundleId);
> + =A0 =A0 =A0 =A0if(ss) {
> + =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule [] { module }, ISe= rver.STATE_STARTED);
> + =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0throw new Exception("can not start bundl= e");
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> + =A0 =A0protected void stopOSGIBundle(IModule module) throws Exceptio= n {
> + =A0 =A0 =A0 =A0long bundleId =3D OSGIBundleHelper.getOSGIBundleId(ge= tServer(), module);
> + =A0 =A0 =A0 =A0if(bundleId =3D=3D -1) throw new Exception("can = not stop bundle");
> + =A0 =A0 =A0 =A0boolean ss =3D this._stopBundle(bundleId);
> + =A0 =A0 =A0 =A0if(ss) {
> + =A0 =A0 =A0 =A0 =A0 =A0setModuleState(new IModule [] { module }, ISe= rver.STATE_STOPPED);
> + =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0throw new Exception("can not start bundl= e");
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> =A0 =A0 @Override
> =A0 =A0 public void stopModule(IModule[] module, IProgressMonitor moni= tor) {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.stopModule", Arrays.asList(mo= dule));
> =A0 =A0 =A0 =A0 try {
> - =A0 =A0 =A0 =A0 =A0 =A0stop(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0if(OSGIBundleHelper.isBundle(module[0])) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0boolean isIn =3D OSGIBundleHelper.che= ckBundleInPublishedMap(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int state =3D DeploymentUtils.getModu= leState(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(! isIn || state =3D=3D IServer.STA= TE_UNKNOWN) doFail(Status.CANCEL_STATUS, Messages.DISTRIBUTE_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this.stopOSGIBundle(module[0]= );
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stop(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> +
> =A0 =A0 =A0 =A0 } catch (Exception e) {
> =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR, "Error stopping = module " + module[0].getName(), e, Activator.logCore);
> =A0 =A0 =A0 =A0 =A0 =A0 throw new RuntimeException("Error stoppin= g module " + module[0].getName(), e);
> @@ -1486,8 +1669,20 @@ abstract public class GeronimoServerBeha
> =A0 =A0 public void restartModule(IModule[] module, IProgressMonitor m= onitor) {
> =A0 =A0 =A0 =A0 Trace.tracePoint("Entry", Activator.traceCor= e, "GeronimoServerBehaviourDelegate.restartModule", Arrays.asList= (module));
> =A0 =A0 =A0 =A0 try {
> - =A0 =A0 =A0 =A0 =A0 =A0stop(module[0], monitor);
> - =A0 =A0 =A0 =A0 =A0 =A0start(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0if(OSGIBundleHelper.isBundle(module[0])) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0boolean isIn =3D OSGIBundleHelper.che= ckBundleInPublishedMap(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int state =3D DeploymentUtils.getModu= leState(getServer(), module[0]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(isIn && (state =3D=3D ISer= ver.STATE_STARTED)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this.stopOSGIBundle(module[0]= );
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this.startOSGIBundle(module[0= ]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0doFail(Status.CANCEL_STATUS, = Messages.RESTART_OSGIBUNDLE_FAIL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stop(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0start(module[0], monitor);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> +
> =A0 =A0 =A0 =A0 } catch (Exception e) {
> =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR, "Error restartin= g module " + module[0].getName(), e, Activator.logCore);
> =A0 =A0 =A0 =A0 =A0 =A0 throw new RuntimeException("Error restart= ing module " + module[0].getName(), e);
> @@ -1514,5 +1709,55 @@ abstract public class GeronimoServerBeha
> =A0 =A0 public void setModulesState(IModule[] module, int state) {
> =A0 =A0 =A0 =A0 setModuleState(module, state);
> =A0 =A0 }
> + =A0 =A0private boolean _startBundle(long bundleId) {
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MBeanServerConnection connection =3D get= ServerConnection();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.invoke(getFramework(), "= startBundle",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0new Object[] { bundleId }, ne= w String[] { long.class.getName() });
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return true;
> + =A0 =A0 =A0 } catch(Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.INFO, "Could not = start bundle", Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return false;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0}
> + =A0 =A0private boolean _stopBundle(long bundleId) {
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MBeanServerConnection connection =3D get= ServerConnection();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.invoke(getFramework(), "= stopBundle",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0new Object[] { bundleId }, ne= w String[] { long.class.getName() });
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return true;
> + =A0 =A0 =A0 } catch(Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.INFO, "Could not = stop bundle", Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return false;
> + =A0 =A0 =A0 }
> + =A0 =A0}
> + =A0 =A0private boolean _unInstallBundle(long bundleId) {
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MBeanServerConnection connection =3D get= ServerConnection();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.invoke(getFramework(), "= uninstallBundle",
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0new Object[] { bundleId }, ne= w String[] { long.class.getName() });
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return true;
> + =A0 =A0 =A0 } catch(Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.INFO, "Could not = uninstall bundle", Activator.traceCore);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return false;
> + =A0 =A0 =A0 }
> + =A0 =A0}
> + =A0 =A0protected ObjectName getFramework() throws Exception {
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 MBeanServerConnection co= nnection =3D getServerConnection();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Set<ObjectName> objectNameSet =3D<= br> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 connection.queryNames(ne= w ObjectName("osgi.core:type=3Dframework,*"), null);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (objectNameSet.isEmpty()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new Exception(Mess= ages.frameworkMBeanNotFound);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (objectNameSet.size() =3D=3D 1= ) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return objectNameSet.ite= rator().next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new Exception(Mess= ages.multipleFramworkMBeans);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw e;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0}
>
> =A0}
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUt= ils.java
> URL: http://svn.apache.org/v= iewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st= .v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java?= rev=3D1140441&r1=3D1140440&r2=3D1140441&view=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.ja= va (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.ja= va Tue Jun 28 05:28:54 2011
> @@ -44,8 +44,12 @@ import org.eclipse.wst.common.componentc
> =A0import org.eclipse.wst.common.componentcore.internal.util.IModuleCo= nstants;
> =A0import org.eclipse.wst.common.componentcore.resources.IVirtualCompo= nent;
> =A0import org.eclipse.wst.server.core.IModule;
> +import org.eclipse.wst.server.core.IServer;
> +import org.eclipse.wst.server.core.internal.ModuleFactory;
> +import org.eclipse.wst.server.core.internal.ServerPlugin;
> =A0import org.osgi.framework.Version;
>
> +
> =A0/**
> =A0* @version $Rev$ $Date$
> =A0*/
> @@ -217,6 +221,24 @@ public class GeronimoUtils {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return id;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(isBundleModule(module)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class<?> ariesUtilsClas= s =3D Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUti= ls");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Method method =3D ariesUtilsC= lass.getMethod("getBlueprintBundleManifest", IProject.class);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Object object =3D method.invo= ke(null, module.getProject());
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class<?> bundleManifest= =3D Class.forName("com.ibm.etools.aries.core.models.BundleManifest&qu= ot;);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0method =3D bundleManifest.get= Method("getBundleSymbolicName");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String bundleSymName =3D (Str= ing) method.invoke(object);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0method =3D bundleManifest.get= Method("getBundleVersion");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String versionStr =3D (String= ) method.invoke(object);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Version version =3D Version.p= arseVersion(versionStr);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String newVersionStr =3D getV= ersion(version);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (bundleSymName !=3D null &= amp;& version !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return bundleSymName = + ":" + newVersionStr;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> @@ -227,7 +249,7 @@ public class GeronimoUtils {
> =A0 =A0 }
>
> =A0 =A0 // copied from org.apache.geronimo.aries.builder.ApplicationIn= staller.getVersion(Version)
> - =A0 =A0private static String getVersion(Version version) {
> + =A0 =A0public static String getVersion(Version version) {
> =A0 =A0 =A0 =A0 String str =3D version.getMajor() + "." + ve= rsion.getMinor() + "." + version.getMicro();
> =A0 =A0 =A0 =A0 String qualifier =3D version.getQualifier();
> =A0 =A0 =A0 =A0 if (qualifier !=3D null && qualifier.trim().le= ngth() > 0) {
> @@ -235,12 +257,13 @@ public class GeronimoUtils {
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 return str;
> =A0 =A0 }
> -
> +
> =A0 =A0 public static String getQualifiedConfigID(String groupId, Stri= ng artifactId, String version, String type) {
> =A0 =A0 =A0 =A0 return groupId + "/" + artifactId + "/&= quot; + version + "/" + type;
> =A0 =A0 }
>
> =A0 =A0 public static IFile getWebDeploymentPlanFile(IVirtualComponent= comp) {
> + =A0 =A0 =A0 if(comp =3D=3D null) return null;
> =A0 =A0 =A0 =A0 IPath deployPlanPath =3D comp.getRootFolder().getUnder= lyingFolder().getProjectRelativePath().append("WEB-INF").append(W= EB_PLAN_NAME);
> =A0 =A0 =A0 =A0 return comp.getProject().getFile(deployPlanPath);
> =A0 =A0 }
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArti= factMapper.java
> URL: http://svn.apach= e.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.gero= nimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifa= ctMapper.java?rev=3D1140441&r1=3D1140440&r2=3D1140441&view=3Ddi= ff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMa= pper.java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMa= pper.java Tue Jun 28 05:28:54 2011
> @@ -18,9 +18,11 @@ package org.apache.geronimo.st.v30.core;
>
> =A0import java.io.BufferedInputStream;
> =A0import java.io.BufferedOutputStream;
> +import java.io.BufferedReader;
> =A0import java.io.File;
> =A0import java.io.FileInputStream;
> =A0import java.io.FileOutputStream;
> +import java.io.FileReader;
> =A0import java.io.IOException;
> =A0import java.io.InputStream;
> =A0import java.io.ObjectInput;
> @@ -29,28 +31,44 @@ import java.io.ObjectOutput;
> =A0import java.io.ObjectOutputStream;
> =A0import java.io.OutputStream;
> =A0import java.util.HashMap;
> +import java.util.Iterator;
> =A0import java.util.Map;
>
> +import org.apache.geronimo.st.v30.core.internal.Trace;
> +import org.eclipse.core.resources.IProject;
> +import org.eclipse.core.resources.IResource;
> +import org.eclipse.core.resources.IResourceChangeEvent;
> +import org.eclipse.core.resources.IResourceChangeListener;
> +import org.eclipse.core.resources.IResourceDelta;
> +import org.eclipse.core.resources.IResourceDeltaVisitor;
> +import org.eclipse.core.resources.ResourcesPlugin;
> +import org.eclipse.core.runtime.CoreException;
> =A0import org.eclipse.core.runtime.IPath;
> =A0import org.eclipse.wst.server.core.IModule;
> =A0import org.eclipse.wst.server.core.IServer;
> =A0import org.eclipse.wst.server.core.util.SocketUtil;
>
> +
> =A0/**
> =A0* @version $Rev$ $Date$
> =A0*/
> =A0public class ModuleArtifactMapper {
>
> =A0 =A0 private static ModuleArtifactMapper instance =3D new ModuleArt= ifactMapper();
> -
> +
> =A0 =A0 private static final String FILE_NAME =3D "servermodule.info";
> -
> + =A0 =A0private static final String BUNDLE_FILE_NAME =3D "serverbundle.info"= ;;
> +
> =A0 =A0 private ServerEntries serverArtifactEntries =3D null;
> -
> + =A0 =A0private ServerBundleEntries serverBundleEntries =3D null;
> +
> =A0 =A0 private ModuleArtifactMapper() {
> =A0 =A0 =A0 =A0 if (serverArtifactEntries =3D=3D null) {
> =A0 =A0 =A0 =A0 =A0 =A0 serverArtifactEntries =3D new ServerEntries();=
> =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0if(serverBundleEntries =3D=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 serverBundleEntries =3D new ServerBundle= Entries();
> + =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 load();
> =A0 =A0 }
>
> @@ -72,7 +90,6 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 artifactEntries.put(getId(module), configId);<= br> > =A0 =A0 =A0 =A0 }
> =A0 =A0 }
> -
> =A0 =A0 synchronized public void removeArtifactEntry(IServer server, I= Module module) {
> =A0 =A0 =A0 =A0 Map<String, String> artifactEntries =3D getServe= rArtifactsMap(server);
> =A0 =A0 =A0 =A0 if (artifactEntries !=3D null) {
> @@ -80,6 +97,87 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
>
> + =A0 =A0synchronized public void addBundleEntry(IServer server, IModu= le module, String symName, String version, long bundleId) {
> + =A0 =A0 =A0 =A0Map<String, String[]> bundleEntries =3D getServ= erBundlesMap(server);
> + =A0 =A0 =A0 =A0if (bundleEntries !=3D null && module !=3D nu= ll) {
> + =A0 =A0 =A0 =A0 =A0 =A0bundleEntries.put(module.getProject().getName= (), new String[] {symName, version, new Long(bundleId).toString(), "fa= lse"});
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> + =A0 =A0synchronized public String resolveBundleByModule(IServer serv= er, IModule module) {// return the bundle symbolic name
> + =A0 =A0 =A0 if(module !=3D null && module.getProject() !=3D = null) {
> + =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> bundleEntries =3D= this.serverBundleEntries.get(server.getRuntime().getLocation().toFile());<= br> > + =A0 =A0 =A0 =A0 =A0 =A0if (bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String[] vs =3D bundleEntries.get(mod= ule.getProject().getName());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return vs =3D=3D null ? null : vs[0];=
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 }
> + =A0 =A0 =A0 return null;
> + =A0 =A0}
> + =A0 =A0synchronized public String resolveBundleBySymbolicName(IServe= r server, String symName, String version) {// return the project name
> + =A0 =A0 =A0 if(symName =3D=3D null || version =3D=3D null) return nu= ll;
> + =A0 =A0 =A0 Map<String, String[]> bundleEntries =3D this.serve= rBundleEntries.get(server.getRuntime().getLocation().toFile());
> + =A0 =A0 =A0 =A0if (bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Iterator<Map.Entry<String, String[= ]>> iter =3D bundleEntries.entrySet().iterator();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 while(iter.hasNext()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map.Entry<String, Str= ing[]> entry =3D iter.next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(symName.equals(entry.= getValue()[0]) && version.equals(entry.getValue()[1])) return entry= .getKey();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 return null;
> + =A0 =A0}
> + =A0 =A0synchronized public boolean checkBundleDirty(IServer server, = IModule module) {
> + =A0 =A0 =A0 =A0boolean isDirty =3D false;
> + =A0 =A0 =A0 =A0if(module !=3D null && module.getProject() != =3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> bundleEntries =3D= this.serverBundleEntries.get(server.getRuntime().getLocation().toFile());<= br> > + =A0 =A0 =A0 =A0 =A0 =A0if (bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String[] vs =3D bundleEntries.get(mod= ule.getProject().getName());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(vs =3D=3D null) isDirty =3D false;=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else isDirty =3D Boolean.parseBoolean= (vs[3]);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0return isDirty;
> + =A0 =A0}
> + =A0 =A0@SuppressWarnings("finally")
> + =A0 =A0 =A0 synchronized public String resolveBundleById(IServer ser= ver, int bundleId) {// return the project name
> + =A0 =A0 =A0 String pName =3D null;
> + =A0 =A0 =A0 try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 String idStr =3D new Integer(bundleId).t= oString();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map<String, String[]> bundleEntrie= s =3D this.serverBundleEntries.get(server.getRuntime().getLocation().toFile= ());
> + =A0 =A0 =A0 =A0 =A0 =A0if (bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Iterator<Map.Entry<String, String[= ]>> iter =3D bundleEntries.entrySet().iterator();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 while(iter.hasNext()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map.Entry<String, Str= ing[]> entry =3D iter.next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(idStr.equals(entry.ge= tValue()[2])) return entry.getKey();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 } catch(Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Trace.trace(Trace.ERROR, e.getMessage(),= e, Activator.logCore);
> + =A0 =A0 =A0 } finally {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return pName;
> + =A0 =A0 =A0 }
> + =A0 =A0}
> + =A0 =A0synchronized public void removeBundle(IServer server, IModule= module) {
> + =A0 =A0 =A0 if(module !=3D null && module.getProject() !=3D = null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Map<String, String[]> bundleEntrie= s =3D this.serverBundleEntries.get(server.getRuntime().getLocation().toFile= ());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bundleEntries.remove(mod= ule.getProject().getName());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 }
> + =A0 =A0}
> +
> + =A0 =A0public long getBundleId(IServer server, IModule module) {
> + =A0 =A0 =A0 int id =3D -1;
> + =A0 =A0 =A0 if(module !=3D null && module.getProject() !=3D = null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 String projectName =3D module.getProject= ().getName();
> + =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> bundleEntries =3D= this.serverBundleEntries.get(server.getRuntime().getLocation().toFile());<= br> > + =A0 =A0 =A0 =A0 =A0 =A0if (bundleEntries !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 String[] strs =3D bundleEntries.get(proj= ectName);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(strs !=3D null) return new Long(st= rs[2]);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 }
> + =A0 =A0 =A0 return id;
> + =A0 =A0}
> +
> =A0 =A0 synchronized public String resolveArtifact(IServer server, IMo= dule module) {
> =A0 =A0 =A0 =A0 if (module !=3D null) {
> =A0 =A0 =A0 =A0 =A0 =A0 Map<String, String> artifactEntries =3D = getServerArtifactsMap(server);
> @@ -88,7 +186,7 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 return null;
> - =A0 =A0}
> + =A0 =A0 }
>
> =A0 =A0 synchronized public Map<String, String> getServerArtifac= tsMap(IServer server) {
> =A0 =A0 =A0 =A0 if (!SocketUtil.isLocalhost(server.getHost())) {
> @@ -104,13 +202,26 @@ public class ModuleArtifactMapper {
>
> =A0 =A0 =A0 =A0 return artifactEntries;
> =A0 =A0 }
> -
> + =A0 =A0synchronized public Map<String, String[]> getServerBund= lesMap(IServer server) {
> + =A0 =A0 =A0 =A0if (!SocketUtil.isLocalhost(server.getHost())) {
> + =A0 =A0 =A0 =A0 =A0 =A0return null;
> + =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0File runtimeLoc =3D server.getRuntime().getLocation()= .toFile();
> + =A0 =A0 =A0 =A0Map<String, String[]> bundleEntries =3D serverB= undleEntries.get(runtimeLoc);
> + =A0 =A0 =A0 =A0if (bundleEntries =3D=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0bundleEntries =3D new HashMap<String, Stri= ng[]>();
> + =A0 =A0 =A0 =A0 =A0 =A0serverBundleEntries.put(runtimeLoc, bundleEnt= ries);
> + =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0return bundleEntries;
> + =A0 =A0}
> =A0 =A0 private void save(IServerEntries entries, String fileName) { > =A0 =A0 =A0 =A0 ObjectOutput output =3D null;
> =A0 =A0 =A0 =A0 try {
> =A0 =A0 =A0 =A0 =A0 =A0 IPath dest =3D Activator.getDefault().getState= Location().append(fileName);
> - =A0 =A0 =A0 =A0 =A0 =A0OutputStream file =3D new FileOutputStream(de= st.toFile());
> - =A0 =A0 =A0 =A0 =A0 =A0OutputStream buffer =3D new BufferedOutputStr= eam(file);
> + =A0 =A0 =A0 =A0 =A0 =A0OutputStream fos =3D new FileOutputStream(des= t.toFile());
> + =A0 =A0 =A0 =A0 =A0 =A0OutputStream buffer =3D new BufferedOutputStr= eam(fos);
> =A0 =A0 =A0 =A0 =A0 =A0 output =3D new ObjectOutputStream(buffer);
> =A0 =A0 =A0 =A0 =A0 =A0 String xml =3D entries.toXML();
> =A0 =A0 =A0 =A0 =A0 =A0 output.writeObject(xml);
> @@ -128,6 +239,7 @@ public class ModuleArtifactMapper {
>
> =A0 =A0 synchronized public void save() {
> =A0 =A0 =A0 =A0 save(serverArtifactEntries, FILE_NAME);
> + =A0 =A0 =A0 =A0save(serverBundleEntries, BUNDLE_FILE_NAME);
> =A0 =A0 }
>
> =A0 =A0 private void load(IServerEntries entries, String fileName) { > @@ -152,12 +264,14 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
> -
> =A0 =A0 synchronized private void load() {
> =A0 =A0 =A0 =A0 load(serverArtifactEntries, FILE_NAME);
> + =A0 =A0 =A0 =A0load(serverBundleEntries, BUNDLE_FILE_NAME);
> + =A0 =A0 =A0 =A0addListener();
> =A0 =A0 }
>
> - =A0 =A0protected interface IServerEntries {
> +
> + =A0 =A0 =A0 protected interface IServerEntries {
> =A0 =A0 =A0 =A0 public =A0void loadXML (String xml);
> =A0 =A0 =A0 =A0 public String toXML ();
> =A0 =A0 }
> @@ -216,7 +330,88 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Object[] serverKeySet =3D keySet().toA= rray();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (int i =3D 0; i < serverKeySet.= length; i++) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString +=3D " =A0 =A0&= lt;file>" + serverKeySet[i] + "</file>\n";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Map projectMap =3D (Map)get(s= erverKeySet[i]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Map<String, String> pro= jectMap =3D (Map<String, String>)get(serverKeySet[i]);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (projectMap =3D=3D null ||= projectMap.size() =3D=3D 0) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString +=3D "= =A0 =A0<map/>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString +=3D "= =A0 =A0<map>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Object[] projectKeySe= t =3D projectMap.keySet().toArray();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (int j =3D 0; j &= lt; projectKeySet.length; j++)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0<entry>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + projectKeySet[j] + "&= lt;/string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + projectMap.get(projectKeyS= et[j]) + "</string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0</entry>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString +=3D "= =A0 =A0</map>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString +=3D " =A0</entry&g= t;\n</map>";
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0return xmlString;
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> +
> + =A0 =A0protected class ServerBundleEntries extends HashMap<File, = Map<String, String[]>> implements IServerEntries{
> + =A0 =A0 =A0 =A0static final long serialVersionUID =3D 0;
> +
> + =A0 =A0 =A0 =A0public void loadXML (String xml) {
> + =A0 =A0 =A0 =A0 =A0 =A0if (xml =3D=3D null || xml.length() =3D=3D 0)=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0String projectName, bundleSymName, bundleVers= ion, bundleId, removed;
> + =A0 =A0 =A0 =A0 =A0 =A0int fileEndPos, nomapStartPos, mapStartPos, m= apEndPos, stringStartPos, stringEndPos;
> + =A0 =A0 =A0 =A0 =A0 =A0int fileStartPos =3D xml.indexOf("<fi= le>", 0);
> + =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> artifactEntries;<= br> > + =A0 =A0 =A0 =A0 =A0 =A0while (fileStartPos > -1) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fileEndPos =3D xml.indexOf("<= /file>", fileStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0File runtimeLoc =3D new File(xml.subs= tring(fileStartPos + 6, fileEndPos));
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nomapStartPos =3D xml.indexOf("&= lt;map/>", fileEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mapStartPos =3D xml.indexOf("<= ;map>", fileEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0artifactEntries =3D new HashMap<St= ring, String[]>();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// have projects on the server
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ((nomapStartPos =3D=3D -1) || (nom= apStartPos > mapStartPos)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mapEndPos =3D xml.indexOf(&qu= ot;</map>", mapStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xml.indexO= f("<string>", mapStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while ((stringStartPos > -= 1) && (stringStartPos < mapEndPos)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringEndPos =3D xml.= indexOf("</string>", stringStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0projectName =3D xml.s= ubstring(stringStartPos + 8, stringEndPos);// load project name
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xm= l.indexOf("<string>", stringEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringEndPos =3D xml.= indexOf("</string>", stringStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bundleSymName =3D xml= .substring(stringStartPos + 8, stringEndPos);// load bundle symbolic name > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xm= l.indexOf("<string>", stringEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringEndPos =3D xml.= indexOf("</string>", stringStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bundleVersion =3D xml= .substring(stringStartPos + 8, stringEndPos);// load bundle version
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xm= l.indexOf("<string>", stringEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringEndPos =3D xml.= indexOf("</string>", stringStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bundleId =3D xml.subs= tring(stringStartPos + 8, stringEndPos);// load bundle id
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xm= l.indexOf("<string>", stringEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringEndPos =3D xml.= indexOf("</string>", stringStartPos);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0removed =3D xml.subst= ring(stringStartPos + 8, stringEndPos);// load bundle removed
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0artifactEntries.put(p= rojectName, new String []{bundleSymName, bundleVersion, bundleId, removed})= ;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0stringStartPos =3D xm= l.indexOf("<string>", stringEndPos);
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// if no projects on the server, it i= s ok to put an empty HashMap
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this.put (runtimeLoc, artifactEntries= );
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fileStartPos =3D xml.indexOf("&l= t;file>", fileEndPos);
> + =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0public String toXML () {
> + =A0 =A0 =A0 =A0 =A0 =A0String xmlString =3D "";
> + =A0 =A0 =A0 =A0 =A0 =A0if (!isEmpty()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString =3D "<map>\n =A0= <entry>\n";
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Object[] serverKeySet =3D keySet().to= Array();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (int i =3D 0; i < serverKeySet= .length; i++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString +=3D " =A0 =A0= <file>" + serverKeySet[i] + "</file>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Map<String, String[]> p= rojectMap =3D (Map<String, String[]>)get(serverKeySet[i]);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (projectMap =3D=3D null || = projectMap.size() =3D=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString +=3D " = =A0 =A0<map/>\n";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> @@ -227,7 +422,10 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString += =3D " =A0 =A0 =A0<entry>\n";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectKeySet[j] += "</string>\n";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectMap.get(pro= jectKeySet[j]) + "</string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectMap.get(pro= jectKeySet[j])[0] + "</string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectMap.get(pro= jectKeySet[j])[1] + "</string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectMap.get(pro= jectKeySet[j])[2] + "</string>\n";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString += =3D " =A0 =A0 =A0 =A0<string>" + (String)projectMap.get(pro= jectKeySet[j])[3] + "</string>\n";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xmlString += =3D " =A0 =A0 =A0</entry>\n";
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xmlString +=3D " = =A0 =A0</map>\n";
> @@ -238,5 +436,94 @@ public class ModuleArtifactMapper {
> =A0 =A0 =A0 =A0 =A0 =A0 return xmlString;
> =A0 =A0 =A0 =A0 }
> =A0 =A0 }
> + =A0 =A0// private methods
> + =A0 =A0private void addListener() {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ResourcesPlugin.getWorkspace().addResour= ceChangeListener(new IResourceChangeListener() {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 @Override
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 public void resourceChan= ged(IResourceChangeEvent event) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(event= .getType() =3D=3D IResourceChangeEvent.POST_CHANGE) {// just listen to the = project's change event
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = try {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0event.getDelta().acce= pt(new IResourceDeltaVisitor() {
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0@Override
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0public boolea= n visit(IResourceDelta delta) throws CoreException {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(de= lta.getKind() =3D=3D IResourceDelta.REMOVED) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0return processResourceRemoved(delta.getResource());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} els= e if(delta.getKind() =3D=3D IResourceDelta.CHANGED) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0return processResourceChanged(delta.getResource());
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retur= n false;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0private boole= an processResourceRemoved(IResource res) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try {=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0if(res instanceof IProject) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0IProject p =3D (IProject) res;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0String projectName =3D p.getName();
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0Iterator<Map.Entry<File, Map<String, String[]>>&g= t; iter =3D serverBundleEntries.entrySet().iterator();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0while(iter.hasNext()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0Map.Entry<File, Map<String, String[]>> serve= rEntry =3D iter.next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0Map<String, String[]> bundleMap =3D serverEntry.ge= tValue();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0String[] value =3D bundleMap.get(projectName);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0if(value !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0value[3] =3D "true";// set removed fla= g to true
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} cat= ch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0e.printStackTrace();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retur= n true;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0private boole= an processResourceChanged(IResource res) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try {=
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0if(res.getFullPath().toString().endsWith(".MF")) {// the proje= ct's menifest file is changed
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0BufferedReader br =3D new BufferedReader(new FileReader(res.getLocat= ion().toFile()));
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0String projectName =3D res.getFullPath().toString().split("/&qu= ot;)[1];
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0String fc =3D br.readLine();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0String symbolicName =3D null, version =3D null;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0boolean bss =3D false, bvs =3D false;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0while(fc !=3D null && (! bss || ! bvs)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0if(fc.startsWith("Bundle-SymbolicName")) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0int index =3D fc.indexOf(":");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0symbolicName =3D fc.substring(index+1).trim();bss = =3D true;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0} else if (fc.startsWith("Bundle-Version")) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0int index =3D fc.indexOf(":");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0version =3D fc.substring(index+1).trim();bvs =3D tru= e;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0fc =3D br.readLine();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0Iterator<Map.Entry<File, Map<String, String[]>>> i= ter =3D serverBundleEntries.entrySet().iterator();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0while(iter.hasNext()) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0Map.Entry<File, Map<String, String[]>> serverEnt= ry =3D iter.next();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0Map<String, String[]> bundleMap =3D serverEntry.getVal= ue();
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0String[] value =3D bundleMap.get(projectName);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0if(value !=3D null) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0if(value[0].equals(symbolicName) && value[1]= .equals(version)) break;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0value[0] =3D symbolicName; value[1] =3D version;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} cat= ch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0e.printStackTrace();
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retur= n true;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0});
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} catch (CoreException e) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0e.printStackTrace();<= br> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }, IResourceChangeEvent.POST_CHANGE); > +
> + =A0 =A0 =A0 }
> +
> +
>
> =A0}
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/M= essages.java
> URL: http://svn.apache.o= rg/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronim= o.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messag= es.java?rev=3D1140441&r1=3D1140440&r2=3D1140441&view=3Ddiff=
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Message= s.java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Message= s.java Tue Jun 28 05:28:54 2011
> @@ -34,6 +34,8 @@ public class Messages extends NLS {
> =A0 =A0 public static String STOP_FAIL;
> =A0 =A0 public static String UNDEPLOY_FAIL;
> =A0 =A0 public static String REDEPLOY_FAIL;
> + =A0 =A0public static String RESTART_OSGIBUNDLE_FAIL;
> + =A0 =A0public static String OSGI_ARIES_NOT_INSTALLED;
> =A0 =A0 public static String REFRESH_FAIL;
> =A0 =A0 public static String REFRESH_NO_CONFIGURATION_FAIL;
> =A0 =A0 public static String REFRESH_NO_BUNDLE_FAIL;
> @@ -76,5 +78,7 @@ public class Messages extends NLS {
> =A0 =A0 public static String moduleExportError;
>
> =A0 =A0 public static String serverStopFailed;
> + =A0 =A0public static String frameworkMBeanNotFound;
> + =A0 =A0public static String multipleFramworkMBeans;
>
> =A0}
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/M= essages.properties
> URL: http://svn.a= pache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.= geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal= /Messages.properties?rev=3D1140441&r1=3D1140440&r2=3D1140441&vi= ew=3Ddiff
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Message= s.properties (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Message= s.properties Tue Jun 28 05:28:54 2011
> @@ -21,6 +21,8 @@ START_FAIL=3DStarting of module failed. =A0S
> =A0STOP_FAIL=3DStopping of module failed. =A0See log for details.
> =A0UNDEPLOY_FAIL=3DUndeploy of module failed. =A0See log for details.<= br> > =A0REDEPLOY_FAIL=3DRedeploy of module failed. =A0See log for details.<= br> > +RESTART_OSGIBUNDLE_FAIL=3DRestart of OSGI bundle failed. =A0The bundl= e must be the start state.
> +OSGI_ARIES_NOT_INSTALLED=3DThe Aries tool is not installed. You can d= ownload it from "http://public.dhe.ibm.co= m/ibmdl/export/pub/software/rational/OSGiAppTools".
> =A0REFRESH_FAIL=3DRefresh of bundle failed. See log for details.
> =A0REFRESH_NO_CONFIGURATION_FAIL=3DThe configuration ID of OSGi applic= ation project {0} can not be found.
> =A0REFRESH_NO_BUNDLE_FAIL=3DThe bundle ID of OSGI bundle project {0} i= n OSGi application project {1} can not be found.
> @@ -61,3 +63,5 @@ moduleModified=3DModified
> =A0moduleExportError=3DModule {0} failed to export.
>
> =A0serverStopFailed=3DError stopping server.
> +frameworkMBeanNotFound=3DFramework mbean not found.
> +multipleFramworkMBeans=3DFound multiple framework mbeans.
>
> Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.ge= ronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/Aries= Helper.java
> URL: http://svn.apache.or= g/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper= .java?rev=3D1140441&r1=3D1140440&r2=3D1140441&view=3Ddiff > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper= .java (original)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper= .java Tue Jun 28 05:28:54 2011
> @@ -63,9 +63,9 @@ public final class AriesHelper {
> =A0 =A0 public static IModule[] getChildModules(IModule ebaModule) { > =A0 =A0 =A0 =A0 if (AriesHelper.isAriesInstalled()) {
> =A0 =A0 =A0 =A0 =A0 =A0 try {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class class1 =3D Class.forName("= com.ibm.etools.aries.internal.core.modules.AriesModuleDelegate");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class<?> class1 =3D Class.forNa= me("com.ibm.etools.aries.internal.core.modules.AriesModuleDelegate&quo= t;);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Method method =3D class1.getMethod(&qu= ot;getChildModules");
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Constructor constructor =3D class1.ge= tConstructor(IProject.class);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Constructor<?> constructor =3D = class1.getConstructor(IProject.class);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Object object =3D constructor.newInsta= nce(ebaModule.getProject());
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (IModule[]) method.invoke(objec= t);
> =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> @@ -78,7 +78,7 @@ public final class AriesHelper {
> =A0 =A0 public static String getSymbolicName(IModule bundleModule) { > =A0 =A0 =A0 =A0 if (AriesHelper.isAriesInstalled()) {
> =A0 =A0 =A0 =A0 =A0 =A0 try {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class class1 =3D Class.forName("= com.ibm.etools.aries.internal.core.utils.AriesUtils");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Class<?> class1 =3D Class.forNa= me("com.ibm.etools.aries.internal.core.utils.AriesUtils");
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Method method =3D class1.getMethod(&qu= ot;getBundleSymbolicName", IProject.class);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (String) method.invoke(null, bu= ndleModule.getProject());
> =A0 =A0 =A0 =A0 =A0 =A0 } catch (Exception e) {
> @@ -87,4 +87,5 @@ public final class AriesHelper {
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 return null;
> =A0 =A0 }
> +
> =A0}
>
> Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geron= imo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBund= leHelper.java
> URL: http://svn.apache.org/viewvc/geronimo/devtools/e= clipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/o= rg/apache/geronimo/st/v30/core/osgi/OSGIBundleHelper.java?rev=3D1140441&= ;view=3Dauto
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleH= elper.java (added)
> +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo= .st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OSGIBundleH= elper.java Tue Jun 28 05:28:54 2011
> @@ -0,0 +1,104 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more=
> + * contributor license agreements. =A0See the NOTICE file distributed= with
> + * this work for additional information regarding copyright ownership= .
> + * The ASF licenses this file to You under the Apache License, Versio= n 2.0
> + * (the "License"); you may not use this file except in com= pliance with
> + * the License. =A0You may obtain a copy of the License at
> + *
> + * =A0 =A0http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, softwar= e
> + * distributed under the License is distributed on an "AS IS&quo= t; BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im= plied.
> + * See the License for the specific language governing permissions an= d
> + * limitations under the License.
> + */
> +package org.apache.geronimo.st.v30.core.osgi;
> +
> +import java.lang.reflect.Method;
> +
> +import org.apache.geronimo.st.v30.core.GeronimoUtils;
> +import org.apache.geronimo.st.v30.core.ModuleArtifactMapper;
> +import org.apache.geronimo.st.v30.core.internal.Messages;
> +import org.eclipse.core.resources.IProject;
> +import org.eclipse.wst.server.core.IModule;
> +import org.eclipse.wst.server.core.IServer;
> +import org.osgi.framework.Version;
> +
> +public class OSGIBundleHelper {
> + =A0 =A0public static void addBundleToPublishedMap(IServer server, IM= odule module, long bundleId) throws Exception {
> + =A0 =A0 =A0 =A0if(! GeronimoUtils.isBundleModule(module)) return; > + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0String[] strArray =3D getBundleSymbolicNameAn= dVersion(module.getProject());
> + =A0 =A0 =A0 =A0 =A0 =A0ModuleArtifactMapper.getInstance().addBundleE= ntry(server, module, strArray[0], strArray[1], bundleId);
> + =A0 =A0 =A0 =A0} catch (Exception e) {
> + =A0 =A0 =A0 =A0 =A0 =A0throw e;
> + =A0 =A0 =A0 =A0}
> + =A0 =A0}
> + =A0 =A0public static boolean checkBundleInPublishedMap(IServer serve= r, IModule module) {
> + =A0 =A0 =A0 =A0String symName =3D ModuleArtifactMapper.getInstance()= .resolveBundleByModule(server, module);
> + =A0 =A0 =A0 =A0return symName =3D=3D null ? false : true;
> + =A0 =A0}
> +
> + =A0 =A0public static void removeBundleFromPublishedMap(IServer serve= r, IModule module) {
> + =A0 =A0 =A0 =A0ModuleArtifactMapper.getInstance().removeBundle(serve= r, module);
> + =A0 =A0}
> +
> + =A0 =A0public static boolean isBundle(IModule module) {
> + =A0 =A0 =A0 =A0return GeronimoUtils.isBundleModule(module);
> + =A0 =A0}
> + =A0 =A0public static boolean isBundle(IProject project) throws Excep= tion {
> + =A0 =A0 =A0 =A0boolean ret =3D false;
> + =A0 =A0 =A0 =A0if(AriesHelper.isAriesInstalled()) {
> + =A0 =A0 =A0 =A0 =A0 =A0Class<?> ariesUtilsClass =3D Class.forN= ame("com.ibm.etools.aries.internal.core.utils.AriesUtils");
> + =A0 =A0 =A0 =A0 =A0 =A0Method method =3D ariesUtilsClass.getMethod(&= quot;isOSGIBundle", IProject.class);
> + =A0 =A0 =A0 =A0 =A0 =A0ret =3D (Boolean) method.invoke(null, project= );
> + =A0 =A0 =A0 =A0} else {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 throw new Exception(Messages.OSGI_ARIES_= NO


<= br>--
Lei Wang (Rex)
rwonly AT apache.= org
--000e0cd4b9e06b077e04a6f83022--