228 this.attributes = Collections.unmodifiableMap(environment); |
228 this.attributes = Collections.unmodifiableMap(environment); |
229 } |
229 } |
230 |
230 |
231 this.address = url; |
231 this.address = url; |
232 this.rmiServerImpl = rmiServerImpl; |
232 this.rmiServerImpl = rmiServerImpl; |
|
233 |
|
234 installStandardForwarders(this.attributes); |
233 } |
235 } |
234 |
236 |
235 /** |
237 /** |
236 * <p>Returns a client stub for this connector server. A client |
238 * <p>Returns a client stub for this connector server. A client |
237 * stub is a serializable object whose {@link |
239 * stub is a serializable object whose {@link |
378 } |
380 } |
379 } |
381 } |
380 |
382 |
381 try { |
383 try { |
382 if (tracing) logger.trace("start", "setting default class loader"); |
384 if (tracing) logger.trace("start", "setting default class loader"); |
383 defaultClassLoader = |
385 defaultClassLoader = EnvHelp.resolveServerClassLoader( |
384 EnvHelp.resolveServerClassLoader(attributes, getMBeanServer()); |
386 attributes, getSystemMBeanServer()); |
385 } catch (InstanceNotFoundException infc) { |
387 } catch (InstanceNotFoundException infc) { |
386 IllegalArgumentException x = new |
388 IllegalArgumentException x = new |
387 IllegalArgumentException("ClassLoader not found: "+infc); |
389 IllegalArgumentException("ClassLoader not found: "+infc); |
388 throw EnvHelp.initCause(x,infc); |
390 throw EnvHelp.initCause(x,infc); |
389 } |
391 } |
394 if (rmiServerImpl != null) |
396 if (rmiServerImpl != null) |
395 rmiServer = rmiServerImpl; |
397 rmiServer = rmiServerImpl; |
396 else |
398 else |
397 rmiServer = newServer(); |
399 rmiServer = newServer(); |
398 |
400 |
399 rmiServer.setMBeanServer(getMBeanServer()); |
401 rmiServer.setMBeanServer(getSystemMBeanServer()); |
400 rmiServer.setDefaultClassLoader(defaultClassLoader); |
402 rmiServer.setDefaultClassLoader(defaultClassLoader); |
401 rmiServer.setRMIConnectorServer(this); |
403 rmiServer.setRMIConnectorServer(this); |
402 rmiServer.export(); |
404 rmiServer.export(); |
403 |
405 |
404 try { |
406 try { |
411 if (tracing) |
413 if (tracing) |
412 logger.trace("start", "Using external directory: " + jndiUrl); |
414 logger.trace("start", "Using external directory: " + jndiUrl); |
413 |
415 |
414 final boolean rebind = EnvHelp.computeBooleanFromString( |
416 final boolean rebind = EnvHelp.computeBooleanFromString( |
415 attributes, |
417 attributes, |
416 JNDI_REBIND_ATTRIBUTE); |
418 JNDI_REBIND_ATTRIBUTE,false); |
417 |
419 |
418 if (tracing) |
420 if (tracing) |
419 logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind); |
421 logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind); |
420 |
422 |
421 try { |
423 try { |
588 public Map<String,?> getAttributes() { |
590 public Map<String,?> getAttributes() { |
589 Map<String, ?> map = EnvHelp.filterAttributes(attributes); |
591 Map<String, ?> map = EnvHelp.filterAttributes(attributes); |
590 return Collections.unmodifiableMap(map); |
592 return Collections.unmodifiableMap(map); |
591 } |
593 } |
592 |
594 |
593 public synchronized |
595 @Override |
594 void setMBeanServerForwarder(MBeanServerForwarder mbsf) { |
596 public synchronized void setMBeanServerForwarder(MBeanServerForwarder mbsf) { |
|
597 MBeanServer oldSMBS = getSystemMBeanServer(); |
595 super.setMBeanServerForwarder(mbsf); |
598 super.setMBeanServerForwarder(mbsf); |
|
599 if (oldSMBS != getSystemMBeanServer()) |
|
600 updateMBeanServer(); |
|
601 // If the system chain of MBeanServerForwarders is not empty, then |
|
602 // there is no need to call rmiServerImpl.setMBeanServer, because |
|
603 // it is pointing to the head of the system chain and that has not |
|
604 // changed. (The *end* of the system chain will have been changed |
|
605 // to point to mbsf.) |
|
606 } |
|
607 |
|
608 private void updateMBeanServer() { |
596 if (rmiServerImpl != null) |
609 if (rmiServerImpl != null) |
597 rmiServerImpl.setMBeanServer(getMBeanServer()); |
610 rmiServerImpl.setMBeanServer(getSystemMBeanServer()); |
|
611 } |
|
612 |
|
613 @Override |
|
614 public synchronized void setSystemMBeanServerForwarder( |
|
615 MBeanServerForwarder mbsf) { |
|
616 super.setSystemMBeanServerForwarder(mbsf); |
|
617 updateMBeanServer(); |
|
618 } |
|
619 |
|
620 /** |
|
621 * {@inheritDoc} |
|
622 * @return true, since this connector server does support a system chain |
|
623 * of forwarders. |
|
624 */ |
|
625 @Override |
|
626 public boolean supportsSystemMBeanServerForwarder() { |
|
627 return true; |
598 } |
628 } |
599 |
629 |
600 /* We repeat the definitions of connection{Opened,Closed,Failed} |
630 /* We repeat the definitions of connection{Opened,Closed,Failed} |
601 here so that they are accessible to other classes in this package |
631 here so that they are accessible to other classes in this package |
602 even though they have protected access. */ |
632 even though they have protected access. */ |