brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alasdairhodge <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: SoftwareProcess exposes Lifecycle...
Date Thu, 09 Jul 2015 12:09:03 GMT
Github user alasdairhodge commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/735#discussion_r34248099
  
    --- Diff: software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java
---
    @@ -91,4 +73,25 @@ public int getB() {
         public int getC() {
             return c;
         }
    +
    +    @Override
    +    protected SoftwareProcessDriverLifecycleEffectorTasks getLifecycleEffectorTasks()
{
    +        return new SoftwareProcessDriverLifecycleEffectorTasks() {
    +            public void start(java.util.Collection<? extends Location> locations)
{
    +                ServiceStateLogic.setExpectedState(entity(), Lifecycle.STARTING);
    +                LOG.trace("Starting {}", this);
    +                entity().setAttribute(SERVICE_PROCESS_IS_RUNNING, true);
    +                entity().setAttribute(Attributes.SERVICE_UP, true);
    +                ServiceStateLogic.setExpectedState(entity(), Lifecycle.RUNNING);
    +            }
    +
    +            public void stop() {
    +                ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPING);
    +                LOG.trace("Stopping {}", this);
    +                entity().setAttribute(Attributes.SERVICE_UP, false);
    +                entity().setAttribute(SERVICE_PROCESS_IS_RUNNING, false);
    +                ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPED);
    +            }
    +        };
    +    }
    --- End diff --
    
    Even though it's just a "minor" class, it nonetheless serves as an example of how we recommend
navigating this maze of lifecycle methods/effectors/overrides/fields/annotations; doubly so
in the absence of decent documentation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message