geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rex Wang <rwo...@gmail.com>
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
Date Fri, 01 Jul 2011 01:46:21 GMT
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 <xiaoyijhondevelop@gmail.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 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 <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
>> easy to see what the given function should be doing.
>>
>> Jarek
>>
>> On Tue, Jun 28, 2011 at 1:28 AM,  <hanhongfang@apache.org> 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 @@
>> >  <?xml version="1.0" encoding="UTF-8"?>
>> >  <classpath>
>> > +       <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-bundle-recorder-3.0-SNAPSHOT.jar"/>
>> > +       <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-cli-3.0-SNAPSHOT.jar"/>
>> > +       <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"/>
>> > +       <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-deploy-tool-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/plexus-archiver-1.0-alpha-12.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/slf4j-api-1.5.5.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/slf4j-simple-1.5.5.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-common-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-crypto-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-deploy-config-3.0-SNAPSHOT.jar"/>
>> > -       <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-deploy-jsr88-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-deployment-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> path="lib/geronimo-j2ee-schema-3.0-SNAPSHOT.jar"/>
>> >        <classpathentry exported="true" kind="lib"
>> 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 @@
>> >
>> <artifactId>geronimo-deploy-jsr88</artifactId>
>> >
>> <version>${geronimoVersion}</version>
>> >                                 </artifactItem>
>> > +
>> > +                                <artifactItem>
>> > +
>>  <groupId>org.apache.geronimo.framework</groupId>
>> > +
>>  <artifactId>geronimo-bundle-recorder</artifactId>
>> > +
>>  <version>${geronimoVersion}</version>
>> > +                                </artifactItem>
>> > +                                <artifactItem>
>> > +
>>  <groupId>org.apache.geronimo.framework</groupId>
>> > +
>>  <artifactId>geronimo-cli</artifactId>
>> > +
>>  <version>${geronimoVersion}</version>
>> > +                                </artifactItem>
>> > +                                <artifactItem>
>> > +
>>  <groupId>org.apache.geronimo.framework</groupId>
>> > +
>>  <artifactId>geronimo-deploy-tool</artifactId>
>> > +
>>  <version>${geronimoVersion}</version>
>> > +                                </artifactItem>
>> > +
>> >                                 <artifactItem>
>> >
>> <groupId>org.apache.geronimo.framework</groupId>
>> >
>> <artifactId>geronimo-common</artifactId>
>> > @@ -232,6 +249,21 @@
>> >         </dependency>
>> >         <dependency>
>> >             <groupId>org.apache.geronimo.framework</groupId>
>> > +            <artifactId>geronimo-bundle-recorder</artifactId>
>> > +            <version>${geronimoVersion}</version>
>> > +        </dependency>
>> > +        <dependency>
>> > +            <groupId>org.apache.geronimo.framework</groupId>
>> > +            <artifactId>geronimo-cli</artifactId>
>> > +            <version>${geronimoVersion}</version>
>> > +        </dependency>
>> > +        <dependency>
>> > +            <groupId>org.apache.geronimo.framework</groupId>
>> > +            <artifactId>geronimo-deploy-tool</artifactId>
>> > +            <version>${geronimoVersion}</version>
>> > +        </dependency>
>> > +        <dependency>
>> > +            <groupId>org.apache.geronimo.framework</groupId>
>> >             <artifactId>geronimo-common</artifactId>
>> >             <version>${geronimoVersion}</version>
>> >         </dependency>
>> >
>> > 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<ObjectName> 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<String, String[]> bundleMap =
>> ModuleArtifactMapper.getInstance().getServerBundlesMap(getServer());
>> > +            synchronized(bundleMap) {
>> > +                Iterator<Map.Entry<String, String[]>> bundleIter =
>> bundleMap.entrySet().iterator();
>> > +                while(bundleIter.hasNext()) {
>> > +                    Map.Entry<String, String[]> 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<String, String> artifactsMap =
>> ModuleArtifactMapper.getInstance().getServerArtifactsMap(getServer());
>> > -            if (artifactsMap != null) {
>> > -                synchronized (artifactsMap) {
>> > +               if(OSGIBundleHelper.isBundle(module)) {/* If the module
>> is the OSGI bundle */
>> > +                       Map<String, String[]> 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<String, String> 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<String, String[]> 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<ObjectName> 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<String, String> 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<String, String[]> 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<String, String[]> 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<String, String[]> bundleEntries =
>> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile());
>> > +        if (bundleEntries != null) {
>> > +               Iterator<Map.Entry<String, String[]>> iter =
>> bundleEntries.entrySet().iterator();
>> > +               while(iter.hasNext()) {
>> > +                       Map.Entry<String, String[]> 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<String, String[]> 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<String, String[]> bundleEntries =
>> this.serverBundleEntries.get(server.getRuntime().getLocation().toFile());
>> > +            if (bundleEntries != null) {
>> > +               Iterator<Map.Entry<String, String[]>> iter =
>> bundleEntries.entrySet().iterator();
>> > +               while(iter.hasNext()) {
>> > +                       Map.Entry<String, String[]> 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<String, String[]> 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<String, String[]> 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<String, String> artifactEntries =
>> getServerArtifactsMap(server);
>> > @@ -88,7 +186,7 @@ public class ModuleArtifactMapper {
>> >             }
>> >         }
>> >         return null;
>> > -    }
>> > +     }
>> >
>> >     synchronized public Map<String, String>
>> getServerArtifactsMap(IServer server) {
>> >         if (!SocketUtil.isLocalhost(server.getHost())) {
>> > @@ -104,13 +202,26 @@ public class ModuleArtifactMapper {
>> >
>> >         return artifactEntries;
>> >     }
>> > -
>> > +    synchronized public Map<String, String[]>
>> getServerBundlesMap(IServer server) {
>> > +        if (!SocketUtil.isLocalhost(server.getHost())) {
>> > +            return null;
>> > +        }
>> > +
>> > +        File runtimeLoc = server.getRuntime().getLocation().toFile();
>> > +        Map<String, String[]> bundleEntries =
>> serverBundleEntries.get(runtimeLoc);
>> > +        if (bundleEntries == null) {
>> > +            bundleEntries = new HashMap<String, String[]>();
>> > +            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 += "    <file>" + serverKeySet[i] +
>> "</file>\n";
>> > -                    Map projectMap = (Map)get(serverKeySet[i]);
>> > +                    Map<String, String> projectMap = (Map<String,
>> String>)get(serverKeySet[i]);
>> > +                    if (projectMap == null || projectMap.size() == 0) {
>> > +                        xmlString += "    <map/>\n";
>> > +                    }
>> > +                    else {
>> > +                        xmlString += "    <map>\n";
>> > +                        Object[] projectKeySet =
>> projectMap.keySet().toArray();
>> > +                        for (int j = 0; j < projectKeySet.length; j++)
>> > +                        {
>> > +                             xmlString += "      <entry>\n";
>> > +                             xmlString += "        <string>" +
>> projectKeySet[j] + "</string>\n";
>> > +                             xmlString += "        <string>" +
>> projectMap.get(projectKeySet[j]) + "</string>\n";
>> > +                             xmlString += "      </entry>\n";
>> > +                        }
>> > +                        xmlString += "    </map>\n";
>> > +                    }
>> > +                }
>> > +                xmlString += "  </entry>\n</map>";
>> > +            }
>> > +            return xmlString;
>> > +        }
>> > +    }
>> > +
>> > +    protected class ServerBundleEntries extends HashMap<File,
>> Map<String, String[]>> 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("<file>", 0);
>> > +            Map<String, String[]> artifactEntries;
>> > +            while (fileStartPos > -1) {
>> > +                fileEndPos = xml.indexOf("</file>", fileStartPos);
>> > +                File runtimeLoc = new File(xml.substring(fileStartPos +
>> 6, fileEndPos));
>> > +
>> > +                nomapStartPos = xml.indexOf("<map/>", fileEndPos);
>> > +                mapStartPos = xml.indexOf("<map>", fileEndPos);
>> > +                artifactEntries = new HashMap<String, String[]>();
>> > +                // have projects on the server
>> > +                if ((nomapStartPos == -1) || (nomapStartPos >
>> mapStartPos)) {
>> > +                    mapEndPos = xml.indexOf("</map>", mapStartPos);
>> > +                    stringStartPos = xml.indexOf("<string>",
>> mapStartPos);
>> > +                    while ((stringStartPos > -1) && (stringStartPos <
>> mapEndPos)) {
>> > +                        stringEndPos = xml.indexOf("</string>",
>> stringStartPos);
>> > +                        projectName = xml.substring(stringStartPos + 8,
>> stringEndPos);// load project name
>> > +                        stringStartPos = xml.indexOf("<string>",
>> stringEndPos);
>> > +                        stringEndPos = xml.indexOf("</string>",
>> stringStartPos);
>> > +                        bundleSymName = xml.substring(stringStartPos +
>> 8, stringEndPos);// load bundle symbolic name
>> > +                        stringStartPos = xml.indexOf("<string>",
>> stringEndPos);
>> > +                        stringEndPos = xml.indexOf("</string>",
>> stringStartPos);
>> > +                        bundleVersion = xml.substring(stringStartPos +
>> 8, stringEndPos);// load bundle version
>> > +                        stringStartPos = xml.indexOf("<string>",
>> stringEndPos);
>> > +                        stringEndPos = xml.indexOf("</string>",
>> stringStartPos);
>> > +                        bundleId = xml.substring(stringStartPos + 8,
>> stringEndPos);// load bundle id
>> > +                        stringStartPos = xml.indexOf("<string>",
>> stringEndPos);
>> > +                        stringEndPos = xml.indexOf("</string>",
>> stringStartPos);
>> > +                        removed = xml.substring(stringStartPos + 8,
>> stringEndPos);// load bundle removed
>> > +
>> > +                        artifactEntries.put(projectName, new String
>> []{bundleSymName, bundleVersion, bundleId, removed});
>> > +                        stringStartPos = xml.indexOf("<string>",
>> stringEndPos);
>> > +
>> > +                    }
>> > +                }
>> > +                // if no projects on the server, it is ok to put an
>> empty HashMap
>> > +                this.put (runtimeLoc, artifactEntries);
>> > +
>> > +                fileStartPos = xml.indexOf("<file>", fileEndPos);
>> > +            }
>> > +        }
>> > +
>> > +        public String toXML () {
>> > +            String xmlString = "";
>> > +            if (!isEmpty()) {
>> > +                xmlString = "<map>\n  <entry>\n";
>> > +
>> > +                Object[] serverKeySet = keySet().toArray();
>> > +                for (int i = 0; i < serverKeySet.length; i++) {
>> > +                    xmlString += "    <file>" + serverKeySet[i] +
>> "</file>\n";
>> > +                    Map<String, String[]> projectMap = (Map<String,
>> String[]>)get(serverKeySet[i]);
>> >                     if (projectMap == null || projectMap.size() == 0) {
>> >                         xmlString += "    <map/>\n";
>> >                     }
>> > @@ -227,7 +422,10 @@ public class ModuleArtifactMapper {
>> >                         {
>> >                              xmlString += "      <entry>\n";
>> >                              xmlString += "        <string>" +
>> (String)projectKeySet[j] + "</string>\n";
>> > -                             xmlString += "        <string>" +
>> (String)projectMap.get(projectKeySet[j]) + "</string>\n";
>> > +                             xmlString += "        <string>" +
>> (String)projectMap.get(projectKeySet[j])[0] + "</string>\n";
>> > +                             xmlString += "        <string>" +
>> (String)projectMap.get(projectKeySet[j])[1] + "</string>\n";
>> > +                             xmlString += "        <string>" +
>> (String)projectMap.get(projectKeySet[j])[2] + "</string>\n";
>> > +                             xmlString += "        <string>" +
>> (String)projectMap.get(projectKeySet[j])[3] + "</string>\n";
>> >                              xmlString += "      </entry>\n";
>> >                         }
>> >                         xmlString += "    </map>\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.Entry<File,
>> Map<String, String[]>>> iter = serverBundleEntries.entrySet().iterator();
>> > +                                        while(iter.hasNext()) {
>> > +                                            Map.Entry<File, Map<String,
>> String[]>> serverEntry = iter.next();
>> > +                                            Map<String, String[]>
>> 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.Entry<File,
>> Map<String, String[]>>> iter = serverBundleEntries.entrySet().iterator();
>> > +                                      while(iter.hasNext()) {
>> > +                                          Map.Entry<File, Map<String,
>> String[]>> serverEntry = iter.next();
>> > +                                          Map<String, String[]>
>> 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

Mime
View raw message