private PatternBinding( int hasCode, @NotNull String verb, @Nullable String route, @NotNull Pattern pattern, @Nullable Set<String> paramNames, @NotNull Middleware[] middleware) { this.route = route; this.pattern = pattern; this.paramNames = paramNames; Collections.addAll(this.middleware, middleware); // register on JMX try { objectName = new ObjectName( "com.jetdrone.yoke:type=Route@" + hasCode + ",method=" + verb + ",path=" + ObjectName.quote(route)); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } try { mbs.registerMBean(new RouteMBean(this.middleware), objectName); } catch (InstanceAlreadyExistsException e) { // ignore } catch (MBeanRegistrationException | NotCompliantMBeanException e) { throw new RuntimeException(e); } }
private void addMiddleware(@NotNull Middleware[] middleware) { Collections.addAll(this.middleware, middleware); // un register if present try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException e) { // ignore } catch (MBeanRegistrationException e) { throw new RuntimeException(e); } // re register if present try { mbs.registerMBean(new RouteMBean(this.middleware), objectName); } catch (InstanceAlreadyExistsException e) { // ignore } catch (MBeanRegistrationException | NotCompliantMBeanException e) { throw new RuntimeException(e); } }