This content has been marked as final. 
    
Show                 7 replies
    
- 
        1. Re: ServiceControllerContext.target is null via @JMXalesj Aug 8, 2008 7:41 AM (in response to alesj)This would probably do the trick. 
 Legit enough?Index: src/main/org/jboss/system/ServiceController.java =================================================================== --- src/main/org/jboss/system/ServiceController.java (revision 76752) +++ src/main/org/jboss/system/ServiceController.java (working copy) @@ -327,12 +327,12 @@ register(serviceName, depends, true); } - public void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle) throws Excep + public ServiceControllerContext register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLife { if (serviceName == null) { log.warn("Ignoring request to register null service: ", new Exception("STACKTRACE")); - return; + return null; } log.debug("Registering service " + serviceName); @@ -348,13 +348,14 @@ { doInstall(controller, context); doChange(controller, context, ControllerState.CONFIGURED, "configure"); + return context; } catch (Throwable t) { // Something went wrong safelyRemoveAnyRegisteredContext(context); - DeploymentException.rethrowAsDeploymentException("Error during register: " + serviceName, t); + throw DeploymentException.rethrowAsDeploymentException("Error during register: " + serviceName, t); } } Index: src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java =================================================================== --- src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java (revision 76752) +++ src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java (working copy) @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.Map; - import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.StandardMBean; @@ -34,6 +33,7 @@ import org.jboss.dependency.spi.dispatch.InvokeDispatchContext; import org.jboss.logging.Logger; import org.jboss.mx.server.ServerConstants; +import org.jboss.system.microcontainer.ServiceControllerContext; /** * ServiceControllerLifecycleCallback. @@ -102,7 +102,9 @@ { // Don't include the lifecycle callouts unless we know the MBean implementation // wants them and supports "double invocation" - getServiceController().register(objectName, null, false); + ServiceControllerContext scc = getServiceController().register(objectName, null, false); + if (scc != null) + scc.setTarget(context.getTarget()); } catch (Exception e) {
- 
        2. Re: ServiceControllerContext.target is null via @JMXadrian.brock Aug 8, 2008 7:50 AM (in response to alesj)Yes. I hadn't considered that somebody would expose their POJO via 
 @JMX and then expect POJO injection to work using the JMX name
 instead of the POJO name. ;-)
 Can you see if there is an easy way to issue a warning for this case?
 It looks like bad practice to me. I also think it is shows some confusion.
 It should work with the current configuration of JBossAS,
 but we may in the future come up with a JBossAS config where there is
 no JMX exposed.
 Which means @JMX won't map to an aspect that registers pojos in the MBeanServer
 so there will be no ServiceControllerContext for the jmx name, just the POJO
 ControllerContext.
- 
        3. Re: ServiceControllerContext.target is null via @JMXalesj Aug 8, 2008 8:01 AM (in response to alesj)"adrian@jboss.org" wrote: 
 Can you see if there is an easy way to issue a warning for this case?
 Hmmm, I doubt it.
 Unless there is some flag on (Service)ControllerContext saying that we actually have a 'better' ControllerContext to access.
 Since the only things we do,
 are parse name from inject element - no knowlegde about ObjectName -,
 set this String name as underlying value to AbstractDependencyValueMetaData,
 then at ADVMD.getValue(TypeInfo, ClassLoader) do lookup by name (underlying value),
 which matches our mbean's ObjectName::getCanonicalName.
 And to get the actual bean, we just call ControllerContext::getTarget,
 not caring where it comes from.
 As you can see, it's your fault due to such ControllerContext abstraction. :-)
- 
        4. Re: ServiceControllerContext.target is null via @JMXalesj Aug 8, 2008 8:03 AM (in response to alesj)"alesj" wrote: 
 This would probably do the trick.
 Legit enough?
 Yup, this works - tested on my demo.
 Commit?
- 
        5. Re: ServiceControllerContext.target is null via @JMXadrian.brock Aug 8, 2008 8:28 AM (in response to alesj)"alesj" wrote: "alesj" wrote: 
 This would probably do the trick.
 Legit enough?
 Yup, this works - tested on my demo.
 Commit?
 JFDI - I'll complain about it later when I have more time to understand the problem.
 P.S. Since you're now project lead, it should be me asking you. ;-)
- 
        6. Re: ServiceControllerContext.target is null via @JMXalesj Aug 8, 2008 8:41 AM (in response to alesj)"adrian@jboss.org" wrote: 
 P.S. Since you're now project lead, it should be me asking you. ;-)
 Haven't seen this officially yet, ;-)
 so I though the handover wasn't final yet,
 hence still asking you. :-)
- 
        7. Re: ServiceControllerContext.target is null via @JMXalesj Aug 8, 2008 9:11 AM (in response to alesj)"adrian@jboss.org" wrote: 
 JFDI - I'll complain about it later when I have more time to understand the problem.
 JFDone:
 https://jira.jboss.org/jira/browse/JBAS-5843
 
    