Discussion:
Component does not get started when using ProviderAdapter
David García
2010-01-23 01:44:23 UTC
Permalink
I'm trying to use Provider Injection to create and configure a
startable component, but for some reason my component does not get
started after calling start() on the container.
Any ideas on how should I configure my container to support it?
Here is my sample code:


ComponentMonitor componentMonitor = new LifecycleComponentMonitor();
LifecycleStrategy lifecycleStrategy = new
ReflectionLifecycleStrategy(componentMonitor);

MutablePicoContainer pico = new DefaultPicoContainer(new
ThreadCaching(), lifecycleStrategy, null);

pico.addComponent(Configuration.class, ConfigurationImpl.class);
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));

pico.start();


public class ComponentProvider implements Provider {

    public Component provide(Configuration config) {
        return new Component(config.getHost(), config.getPort());
    }
}

public interface Component {

    public void start();

    public void stop();

    public void doSomething();
}

public class ComponentImpl {

    public Component(String host, int port) {
        //some stuff
    }

    public void start() {
        //this never gets executed!!!
    }

}


I cannot modify Component or ComponentImpl, I'm trying to use the
Provider to crate ComponentImpl instances using data from
Configuration class.
When in some other place i do:

pico.getComponent(Component.class);

the instance is created, but it's not started.
What am I missing??

Thanks.

David

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2010-01-23 18:58:54 UTC
Permalink
Thanks for this. It could be that Pico needs a change or two. I'll use your testcase as the driver, maybe later today

Regards,

- Paul
Post by David García
I'm trying to use Provider Injection to create and configure a
startable component, but for some reason my component does not get
started after calling start() on the container.
Any ideas on how should I configure my container to support it?
ComponentMonitor componentMonitor = new LifecycleComponentMonitor();
LifecycleStrategy lifecycleStrategy = new
ReflectionLifecycleStrategy(componentMonitor);
MutablePicoContainer pico = new DefaultPicoContainer(new
ThreadCaching(), lifecycleStrategy, null);
pico.addComponent(Configuration.class, ConfigurationImpl.class);
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.start();
public class ComponentProvider implements Provider {
public Component provide(Configuration config) {
return new Component(config.getHost(), config.getPort());
}
}
public interface Component {
public void start();
public void stop();
public void doSomething();
}
public class ComponentImpl {
public Component(String host, int port) {
//some stuff
}
public void start() {
//this never gets executed!!!
}
}
I cannot modify Component or ComponentImpl, I'm trying to use the
Provider to crate ComponentImpl instances using data from
Configuration class.
pico.getComponent(Component.class);
the instance is created, but it's not started.
What am I missing??
Thanks.
David
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2010-01-25 19:17:06 UTC
Permalink
Hi David,

I've fixed pico such that provider-made instances can have a lifecycle (if cached of course). It'll be in the next release.

Can you work from a snapshot version or should we ship a release ?

Regards,

- Paul
Post by David García
I'm trying to use Provider Injection to create and configure a
startable component, but for some reason my component does not get
started after calling start() on the container.
Any ideas on how should I configure my container to support it?
ComponentMonitor componentMonitor = new LifecycleComponentMonitor();
LifecycleStrategy lifecycleStrategy = new
ReflectionLifecycleStrategy(componentMonitor);
MutablePicoContainer pico = new DefaultPicoContainer(new
ThreadCaching(), lifecycleStrategy, null);
pico.addComponent(Configuration.class, ConfigurationImpl.class);
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.start();
public class ComponentProvider implements Provider {
public Component provide(Configuration config) {
return new Component(config.getHost(), config.getPort());
}
}
public interface Component {
public void start();
public void stop();
public void doSomething();
}
public class ComponentImpl {
public Component(String host, int port) {
//some stuff
}
public void start() {
//this never gets executed!!!
}
}
I cannot modify Component or ComponentImpl, I'm trying to use the
Provider to crate ComponentImpl instances using data from
Configuration class.
pico.getComponent(Component.class);
the instance is created, but it's not started.
What am I missing??
Thanks.
David
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David García
2010-01-25 22:49:19 UTC
Permalink
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
Thanks
Post by Paul Hammant
Hi David,
I've fixed pico such that provider-made instances can have a lifecycle (if cached of course).  It'll be in the next release.
Can you work from a snapshot version or should we ship a release ?
Regards,
- Paul
Post by David García
I'm trying to use Provider Injection to create and configure a
startable component, but for some reason my component does not get
started after calling start() on the container.
Any ideas on how should I configure my container to support it?
ComponentMonitor componentMonitor = new LifecycleComponentMonitor();
LifecycleStrategy lifecycleStrategy = new
ReflectionLifecycleStrategy(componentMonitor);
MutablePicoContainer pico = new DefaultPicoContainer(new
ThreadCaching(), lifecycleStrategy, null);
pico.addComponent(Configuration.class, ConfigurationImpl.class);
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.start();
public class ComponentProvider implements Provider {
    public Component provide(Configuration config) {
        return new Component(config.getHost(), config.getPort());
    }
}
public interface Component {
    public void start();
    public void stop();
    public void doSomething();
}
public class ComponentImpl {
    public Component(String host, int port) {
        //some stuff
    }
    public void start() {
        //this never gets executed!!!
    }
}
I cannot modify Component or ComponentImpl, I'm trying to use the
Provider to crate ComponentImpl instances using data from
Configuration class.
pico.getComponent(Component.class);
the instance is created, but it's not started.
What am I missing??
Thanks.
David
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Michael Rimov
2010-01-26 16:38:07 UTC
Permalink
Post by David García
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
The good news:
In general, since you're using maven, you can access any snapshot releases
by setting the following up:

<repositories>
<repository>
<id>Codehaus</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

....
<dependencies>
.....
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.10-SNAPSHOT</version>
</dependency>
.....
</dependencies>


The bad news:

There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes aren't
in it yet. Paul, or Mauro, what would it take to get a new snapshot
uploaded?


-Mike

P.S. I tend to use:

<repository>
<id>Codehaus</id>
<url>http://repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>

normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David García
2010-01-26 19:39:06 UTC
Permalink
Nice, thanks for this.
I'll wait for the snapshot.

David
Post by Michael Rimov
Post by David García
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
       <repositories>
               <repository>
                       <id>Codehaus</id>
                       <url>http://snapshots.repository.codehaus.org/</url>
                       <releases>
                               <enabled>false</enabled>
                       </releases>
                       <snapshots>
                               <enabled>true</enabled>
                       </snapshots>
               </repository>
       </repositories>
....
       <dependencies>
               .....
                       <dependency>
                               <groupId>org.picocontainer</groupId>
                               <artifactId>picocontainer</artifactId>
                               <version>2.10-SNAPSHOT</version>
                       </dependency>
               .....
       </dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes aren't
in it yet.  Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
               <repository>
                       <id>Codehaus</id>
                       <url>http://repository.codehaus.org/</url>
                       <releases>
                               <enabled>true</enabled>
                       </releases>
                       <snapshots>
                               <enabled>false</enabled>
                       </snapshots>
               </repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2010-01-26 21:00:23 UTC
Permalink
Deployed .. Enjoy!

Sent from my iPhone
Post by Michael Rimov
Post by David García
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
<repositories>
<repository>
<id>Codehaus</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
....
<dependencies>
.....
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.10-SNAPSHOT</version>
</dependency>
.....
</dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixe
s aren't
in it yet. Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
<repository>
<id>Codehaus</id>
<url>http://repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David García
2010-01-27 00:19:17 UTC
Permalink
I updated my dependencies to use 2.0-SNAPSHOT but still my component
does not get started. :(

I made sure i got the right jar:
1/26/10 2:49:27 PM PST: Downloaded [Codehaus] ->
http://snapshots.repository.codehaus.org//org/picocontainer/picocontainer/2.10-SNAPSHOT/picocontainer-2.10-20100126.205907-2.jar

To test my component does get started, i created something like:

public class ConfigurableComponent extends ComponentImpl {

public ConfigurableComponent(Configuration config) {
super(config.getHost, config.getPort);
}

@Override
public void start() {
LOG.debug("Starting component...");
super.start();
LOG.debug("done.");
}
}

and added it to the container, replacing this:
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));

for this:
pico.addComponent(Component.class, ConfigurableComponent.class)

in that case the component gets started successfully, but still
ProviderAdapter does not work for me.
Post by Paul Hammant
Deployed .. Enjoy!
Sent from my iPhone
Post by Michael Rimov
Post by David García
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
  <repositories>
      <repository>
          <id>Codehaus</id>
          <url>http://snapshots.repository.codehaus.org/</url>
          <releases>
              <enabled>false</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
....
  <dependencies>
      .....
          <dependency>
              <groupId>org.picocontainer</groupId>
              <artifactId>picocontainer</artifactId>
              <version>2.10-SNAPSHOT</version>
          </dependency>
      .....
  </dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes
aren't
in it yet.  Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
      <repository>
          <id>Codehaus</id>
          <url>http://repository.codehaus.org/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>false</enabled>
          </snapshots>
      </repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2010-01-27 03:13:07 UTC
Permalink
Here's the testcase I made :-

I forgot to mention that you need to pass lifecyclestrategy into the provider adapter now (optional ctor)

- Paul

+ @Test
+ public void providersCanHaveLifecyclesToo() {
+ ComponentMonitor componentMonitor = new LifecycleComponentMonitor();
+ LifecycleStrategy lifecycleStrategy = new
+ ReflectionLifecycleStrategy(componentMonitor);

+ MutablePicoContainer pico = new DefaultPicoContainer(new
+ ThreadCaching(), lifecycleStrategy, null);
+
+ StringBuilder sb = new StringBuilder();
+ pico.addComponent(Configuration.class);
+ pico.addAdapter(new ProviderAdapter(lifecycleStrategy, new ComponentProvider(sb)));
+ Object foo = pico.getComponent(Component.class);
+ pico.start();
+ pico.stop();
+ assertEquals("@<>", sb.toString());
+
+ }
+
+ public class ComponentProvider implements Provider {
+ private StringBuilder sb;
+
+ public ComponentProvider(StringBuilder sb) {
+ this.sb = sb;
+ }
+
+ public Component provide(Configuration config) {
+ return new ComponentImpl(sb, config.getHost(), config.getPort());
+ }
+ }
+
+ public static class Configuration {
+
+ public String getHost() {
+ return "hello";
+ }
+
+ public int getPort() {
+ return 99;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ }
+
+ public static interface Component {
+
+ public void start();
+
+ public void stop();
+
+ }
+
+ public static class ComponentImpl implements Component {
+
+ private StringBuilder sb;
+
+ public ComponentImpl(StringBuilder sb, String host, int port) {
+ this.sb = sb.append("@");
+ }
+
+ public void start() {
+ sb.append("<");
+ }
+ public void stop() {
+ sb.append(">");
+ }
+
+ }
+



Regards,

- Paul
Post by David García
I updated my dependencies to use 2.0-SNAPSHOT but still my component
does not get started. :(
1/26/10 2:49:27 PM PST: Downloaded [Codehaus] ->
http://snapshots.repository.codehaus.org//org/picocontainer/picocontainer/2.10-SNAPSHOT/picocontainer-2.10-20100126.205907-2.jar
public class ConfigurableComponent extends ComponentImpl {
public ConfigurableComponent(Configuration config) {
super(config.getHost, config.getPort);
}
@Override
public void start() {
LOG.debug("Starting component...");
super.start();
LOG.debug("done.");
}
}
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.addComponent(Component.class, ConfigurableComponent.class)
in that case the component gets started successfully, but still
ProviderAdapter does not work for me.
Post by Paul Hammant
Deployed .. Enjoy!
Sent from my iPhone
Post by Michael Rimov
Great, IŽll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
<repositories>
<repository>
<id>Codehaus</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
....
<dependencies>
.....
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.10-SNAPSHOT</version>
</dependency>
.....
</dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes aren't
in it yet. Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
<repository>
<id>Codehaus</id>
<url>http://repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
David García
2010-01-28 02:31:56 UTC
Permalink
That constructor seems to be missing :s
Post by Paul Hammant
Here's the testcase I made :-
I forgot to mention that you need to pass lifecyclestrategy into the
provider adapter now (optional ctor)
- Paul
+ public void providersCanHaveLifecyclesToo() {
+ ComponentMonitor componentMonitor = new
LifecycleComponentMonitor();
+ LifecycleStrategy lifecycleStrategy = new
+ ReflectionLifecycleStrategy(componentMonitor);
+ MutablePicoContainer pico = new DefaultPicoContainer(new
+ ThreadCaching(), lifecycleStrategy, null);
+
+ StringBuilder sb = new StringBuilder();
+ pico.addComponent(Configuration.class);
+ pico.addAdapter(new ProviderAdapter(lifecycleStrategy, new
ComponentProvider(sb)));
+ Object foo = pico.getComponent(Component.class);
+ pico.start();
+ pico.stop();
+
+ }
+
+ public class ComponentProvider implements Provider {
+ private StringBuilder sb;
+
+ public ComponentProvider(StringBuilder sb) {
+ this.sb = sb;
+ }
+
+ public Component provide(Configuration config) {
+ return new ComponentImpl(sb, config.getHost(),
config.getPort());
+ }
+ }
+
+ public static class Configuration {
+
+ public String getHost() {
+ return "hello";
+ }
+
+ public int getPort() {
+ return 99;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ }
+
+ public static interface Component {
+
+ public void start();
+
+ public void stop();
+
+ }
+
+ public static class ComponentImpl implements Component {
+
+ private StringBuilder sb;
+
+ public ComponentImpl(StringBuilder sb, String host, int port) {
+ }
+
+ public void start() {
+ sb.append("<");
+ }
+ public void stop() {
+ sb.append(">");
+ }
+
+ }
+
Regards,
- Paul
I updated my dependencies to use 2.0-SNAPSHOT but still my component
does not get started. :(
1/26/10 2:49:27 PM PST: Downloaded [Codehaus] ->
http://snapshots.repository.codehaus.org//org/picocontainer/picocontainer/2.10-SNAPSHOT/picocontainer-2.10-20100126.205907-2.jar
public class ConfigurableComponent extends ComponentImpl {
   public ConfigurableComponent(Configuration config) {
       super(config.getHost, config.getPort);
   }
   public void start() {
       LOG.debug("Starting component...");
       super.start();
       LOG.debug("done.");
   }
}
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.addComponent(Component.class, ConfigurableComponent.class)
in that case the component gets started successfully, but still
ProviderAdapter does not work for me.
Deployed .. Enjoy!
Sent from my iPhone
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
  <repositories>
      <repository>
          <id>Codehaus</id>
          <url>http://snapshots.repository.codehaus.org/</url>
          <releases>
              <enabled>false</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
....
  <dependencies>
      .....
          <dependency>
              <groupId>org.picocontainer</groupId>
              <artifactId>picocontainer</artifactId>
              <version>2.10-SNAPSHOT</version>
          </dependency>
      .....
  </dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes
aren't
in it yet.  Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
      <repository>
          <id>Codehaus</id>
          <url>http://repository.codehaus.org/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>false</enabled>
          </snapshots>
      </repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2010-01-28 04:12:26 UTC
Permalink
My bad. I forgot to do a svn up before deploying. Check again now.

Regards,

- Paul
Post by David García
That constructor seems to be missing :s
Post by Paul Hammant
Here's the testcase I made :-
I forgot to mention that you need to pass lifecyclestrategy into the
provider adapter now (optional ctor)
- Paul
+ public void providersCanHaveLifecyclesToo() {
+ ComponentMonitor componentMonitor = new
LifecycleComponentMonitor();
+ LifecycleStrategy lifecycleStrategy = new
+ ReflectionLifecycleStrategy(componentMonitor);
+ MutablePicoContainer pico = new DefaultPicoContainer(new
+ ThreadCaching(), lifecycleStrategy, null);
+
+ StringBuilder sb = new StringBuilder();
+ pico.addComponent(Configuration.class);
+ pico.addAdapter(new ProviderAdapter(lifecycleStrategy, new
ComponentProvider(sb)));
+ Object foo = pico.getComponent(Component.class);
+ pico.start();
+ pico.stop();
+
+ }
+
+ public class ComponentProvider implements Provider {
+ private StringBuilder sb;
+
+ public ComponentProvider(StringBuilder sb) {
+ this.sb = sb;
+ }
+
+ public Component provide(Configuration config) {
+ return new ComponentImpl(sb, config.getHost(),
config.getPort());
+ }
+ }
+
+ public static class Configuration {
+
+ public String getHost() {
+ return "hello";
+ }
+
+ public int getPort() {
+ return 99;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ }
+
+ public static interface Component {
+
+ public void start();
+
+ public void stop();
+
+ }
+
+ public static class ComponentImpl implements Component {
+
+ private StringBuilder sb;
+
+ public ComponentImpl(StringBuilder sb, String host, int port) {
+ }
+
+ public void start() {
+ sb.append("<");
+ }
+ public void stop() {
+ sb.append(">");
+ }
+
+ }
+
Regards,
- Paul
I updated my dependencies to use 2.0-SNAPSHOT but still my component
does not get started. :(
1/26/10 2:49:27 PM PST: Downloaded [Codehaus] ->
http://snapshots.repository.codehaus.org//org/picocontainer/picocontainer/2.10-SNAPSHOT/picocontainer-2.10-20100126.205907-2.jar
public class ConfigurableComponent extends ComponentImpl {
public ConfigurableComponent(Configuration config) {
super(config.getHost, config.getPort);
}
@Override
public void start() {
LOG.debug("Starting component...");
super.start();
LOG.debug("done.");
}
}
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.addComponent(Component.class, ConfigurableComponent.class)
in that case the component gets started successfully, but still
ProviderAdapter does not work for me.
Deployed .. Enjoy!
Sent from my iPhone
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
<repositories>
<repository>
<id>Codehaus</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
....
<dependencies>
.....
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.10-SNAPSHOT</version>
</dependency>
.....
</dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes
aren't
in it yet. Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
<repository>
<id>Codehaus</id>
<url>http://repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David García
2010-01-28 18:48:01 UTC
Permalink
It works now, thanks!!
My bad.  I forgot to do a svn up before deploying.  Check again now.
Regards,
- Paul
Post by David García
That constructor seems to be missing :s
Post by Paul Hammant
Here's the testcase I made :-
I forgot to mention that you need to pass lifecyclestrategy into the
provider adapter now (optional ctor)
- Paul
+    public void providersCanHaveLifecyclesToo() {
+        ComponentMonitor componentMonitor = new
LifecycleComponentMonitor();
+        LifecycleStrategy lifecycleStrategy = new
+                ReflectionLifecycleStrategy(componentMonitor);
+        MutablePicoContainer pico = new DefaultPicoContainer(new
+                ThreadCaching(), lifecycleStrategy, null);
+
+        StringBuilder sb = new StringBuilder();
+        pico.addComponent(Configuration.class);
+        pico.addAdapter(new ProviderAdapter(lifecycleStrategy, new
ComponentProvider(sb)));
+        Object foo = pico.getComponent(Component.class);
+        pico.start();
+        pico.stop();
+
+    }
+
+    public class ComponentProvider implements Provider {
+        private StringBuilder sb;
+
+        public ComponentProvider(StringBuilder sb) {
+            this.sb = sb;
+        }
+
+        public Component provide(Configuration config) {
+            return new ComponentImpl(sb, config.getHost(),
config.getPort());
+        }
+    }
+
+    public static class Configuration {
+
+        public String getHost() {
+            return "hello";
+        }
+
+        public int getPort() {
+            return 99;
+        }
+
+        public void start() {
+        }
+
+        public void stop() {
+        }
+
+    }
+
+    public static interface Component {
+
+        public void start();
+
+        public void stop();
+
+    }
+
+    public static class ComponentImpl implements Component {
+
+        private StringBuilder sb;
+
+        public ComponentImpl(StringBuilder sb, String host, int port) {
+        }
+
+        public void start() {
+            sb.append("<");
+        }
+        public void stop() {
+            sb.append(">");
+        }
+
+    }
+
Regards,
- Paul
I updated my dependencies to use 2.0-SNAPSHOT but still my component
does not get started. :(
1/26/10 2:49:27 PM PST: Downloaded [Codehaus] ->
http://snapshots.repository.codehaus.org//org/picocontainer/picocontainer/2.10-SNAPSHOT/picocontainer-2.10-20100126.205907-2.jar
public class ConfigurableComponent extends ComponentImpl {
   public ConfigurableComponent(Configuration config) {
       super(config.getHost, config.getPort);
   }
   public void start() {
       LOG.debug("Starting component...");
       super.start();
       LOG.debug("done.");
   }
}
pico.addAdapter(new ProviderAdapter(new ComponentProvider()));
pico.addComponent(Component.class, ConfigurableComponent.class)
in that case the component gets started successfully, but still
ProviderAdapter does not work for me.
Deployed .. Enjoy!
Sent from my iPhone
Great, I´ll give it a try.
It would be great if there is a release since i'm using maven to pull
the dependencies.
In general, since you're using maven, you can access any snapshot releases
  <repositories>
      <repository>
          <id>Codehaus</id>
          <url>http://snapshots.repository.codehaus.org/</url>
          <releases>
              <enabled>false</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
....
  <dependencies>
      .....
          <dependency>
              <groupId>org.picocontainer</groupId>
              <artifactId>picocontainer</artifactId>
              <version>2.10-SNAPSHOT</version>
          </dependency>
      .....
  </dependencies>
There hasn’t been a snapshot unloaded since 1/5/2010... so your fixes
aren't
in it yet.  Paul, or Mauro, what would it take to get a new snapshot
uploaded?
-Mike
      <repository>
          <id>Codehaus</id>
          <url>http://repository.codehaus.org/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>false</enabled>
          </snapshots>
      </repository>
normally, since once a new PicoContainer is actually released, then I can
access it without waiting for the sync with the central repository :)
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
  http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
   http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...