al =3D container.getComponentInstancesOfType(Appli=
cation.class);
+ for (Application a : al)
+ {
+ try
+ {
+ addApplication(a);
+ }
+ catch (Exception e)
+ {
+ LOG.error("Failed add JAX-RS application " + a.getClass().getN=
ame(), e);
+ }
+ }
+
+ // Lookup all object which implements ResourceContainer interface and
+ // process them to be add as root resources.
+ for (Object resource : container.getComponentInstancesOfType(Resourc=
eContainer.class))
+ {
+ try
+ {
+ addResource(resource, null);
+ }
+ catch (Exception e)
+ {
+ LOG.error("Failed add JAX-RS resource " + resource.getClass().=
getName(), e);
+ }
+ }
+
+ startResourceCleaner();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ cleanerStop =3D true;
+ }
+
+ /**
+ * Start resource cleaner which periodically check all available resour=
ces
+ * and remove expired. Expired date may be specified by adding special
+ * property (see {@link #RESOURCE_EXPIRED}) when resource added. In exa=
mple
+ * below resource will be expired in one minute. By default resources c=
heck
+ * one time per minute so live time less than one minute is not guarant=
eed.
+ *
+ *
+ * ResourceBinder binder =3D ...
+ * Class> resource =3D ...
+ * MultivaluedMap properties =3D new MultivaluedMapImpl=
();
+ * properties.putSingle("resource.expiration.date",
+ * Long.toString(System.currentTimeMillis() + 60000L));
+ * binder.addResource(resource, properties);
+ *
+ */
+ protected void startResourceCleaner()
+ {
+ Thread thread =3D new Thread(new ResourceCleaner(60));
+ thread.setDaemon(true);
+ thread.start();
+ }
}
--===============2837639083031591264==--