KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > management > browser > model > ManagedObject


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.management.browser.model;
8
9 import java.awt.Component JavaDoc;
10 import java.beans.beancontext.BeanContextServices JavaDoc;
11 import java.io.PrintWriter JavaDoc;
12 import java.io.StringWriter JavaDoc;
13 import java.lang.reflect.Method JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.Hashtable JavaDoc;
16 import java.util.Iterator JavaDoc;
17
18 import javax.management.Attribute JavaDoc;
19 import javax.management.AttributeList JavaDoc;
20 import javax.management.MBeanAttributeInfo JavaDoc;
21 import javax.management.MBeanInfo JavaDoc;
22 import javax.management.ObjectName JavaDoc;
23 import javax.management.j2ee.statistics.Statistic JavaDoc;
24 import javax.management.j2ee.statistics.Stats JavaDoc;
25
26 import org.apache.log4j.Logger;
27 import org.ejtools.adwt.service.ConsoleService;
28 import org.ejtools.graph.service.GraphConsumer;
29 import org.ejtools.graph.service.GraphConsumerMediator;
30 import org.ejtools.graph.service.GraphProducer;
31 import org.ejtools.graph.service.GraphService;
32 import org.ejtools.jmx.MBeanInvokeAccessor;
33 import org.ejtools.management.browser.model.service.CacheService;
34 import org.ejtools.management.browser.model.service.ConnectionService;
35 import org.ejtools.management.browser.model.service.NotificationService;
36 import org.ejtools.management.browser.ui.ManagedObjectTabViewer;
37 import org.ejtools.util.ClassTools;
38
39 /**
40  * Description of the Class
41  *
42  * @author Laurent Etiemble
43  * @version $Revision: 1.4 $
44  * @todo Javadoc to complete
45  * @javabean:class displayName="J2EE ManagedObject"
46  * shortDescription="J2EE ManagedObject"
47  * @javabean:icons color16="/toolbarButtonGraphics/development/Bean16.gif"
48  * @javabean:property name="name"
49  * class="java.lang.String"
50  * displayName="Name"
51  * shortDescription="ManagedObject name"
52  * @javabean:property name="domain"
53  * class="java.lang.String"
54  * displayName="Domain"
55  * shortDescription="Domain name"
56  * @javabean:property name="description"
57  * class="java.lang.String"
58  * displayName="Description"
59  * shortDescription="Description"
60  */

61 public class ManagedObject extends Node implements MBeanInvokeAccessor, GraphConsumerMediator
62 {
63    /** Description of the Field */
64    protected String JavaDoc canonicalName;
65    /** Description of the Field */
66    protected String JavaDoc description;
67    /** Description of the Field */
68    protected String JavaDoc domain;
69    /** Description of the Field */
70    protected boolean eventProvider = false;
71    /** Description of the Field */
72    protected transient Hashtable JavaDoc graphProducers = new Hashtable JavaDoc();
73    /** Description of the Field */
74    protected transient MBeanInfo JavaDoc info;
75    /** Description of the Field */
76    protected String JavaDoc j2eeType;
77    /** Description of the Field */
78    protected transient ObjectName JavaDoc objectName;
79    /** Description of the Field */
80    protected boolean stateManageable = false;
81    /** Description of the Field */
82    protected boolean statisticsProvider = false;
83    /** Description of the Field */
84    private static Logger logger = Logger.getLogger(ManagedObject.class);
85
86
87    /** Constructor for the ManagedObject object */
88    public ManagedObject()
89    {
90       super();
91    }
92
93
94    /** Description of the Method */
95    public void clear()
96    {
97       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
98       this.releaseServices(context);
99
100       super.clear();
101    }
102
103
104    /**
105     * Getter for the attribute attribute
106     *
107     * @param attribute Description of the Parameter
108     * @return The attribute value
109     * @exception Exception Description of the Exception
110     */

111    public Object JavaDoc getAttribute(String JavaDoc attribute)
112       throws Exception JavaDoc
113    {
114       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
115       Object JavaDoc result = null;
116
117       if (context.hasService(ConnectionService.class))
118       {
119          try
120          {
121             ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
122             result = service.getMEJB().getAttribute(objectName, attribute);
123             context.releaseService(this, this, ConnectionService.class);
124          }
125          catch (Exception JavaDoc e)
126          {
127             logger.error("Error while getting attribute", e);
128             throw e;
129          }
130       }
131       return result;
132    }
133
134
135    /**
136     * @param as Description of the Parameter
137     * @return The attributes value
138     * @exception Exception Description of the Exception
139     */

140    public AttributeList JavaDoc getAttributes(String JavaDoc[] as)
141       throws Exception JavaDoc
142    {
143       return null;
144    }
145
146
147    /**
148     * Gets the canonicalName attribute of the ManagedObject object
149     *
150     * @return The canonicalName value
151     */

152    public String JavaDoc getCanonicalName()
153    {
154       return this.canonicalName;
155    }
156
157
158    /**
159     * Gets the component attribute of the ManagedObject object
160     *
161     * @return The component value
162     * @author laurent
163     * @created 23 mars 2002
164     */

165    public Component JavaDoc getComponent()
166    {
167       if (c == null)
168       {
169          c = new ManagedObjectTabViewer(this);
170       }
171       return (Component JavaDoc) c;
172    }
173
174
175    /**
176     * Gets the description attribute of the ManagedObject object
177     *
178     * @return The description value
179     */

180    public String JavaDoc getDescription()
181    {
182       return this.description;
183    }
184
185
186    /**
187     * Gets the domain attribute of the ManagedObject object
188     *
189     * @return The domain value
190     */

191    public String JavaDoc getDomain()
192    {
193       return this.domain;
194    }
195
196
197    /**
198     * Gets the graphConsumers attribute of the ManagedObject object
199     *
200     * @return The graphConsumers value
201     */

202    public GraphConsumer[] getGraphConsumers()
203    {
204       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
205       GraphConsumer[] result = new GraphConsumer[0];
206
207       if (context.hasService(GraphService.class))
208       {
209          try
210          {
211             GraphService service = (GraphService) context.getService(this, this, GraphService.class, this, this);
212             result = service.getGraphConsumers();
213             context.releaseService(this, this, GraphService.class);
214          }
215          catch (Exception JavaDoc e)
216          {
217             logger.error("Error while using GraphService", e);
218          }
219       }
220       return result;
221    }
222
223
224    /**
225     * Gets the graphProducers attribute of the Resource object
226     *
227     * @return The graphProducers value
228     */

229    public Hashtable JavaDoc getGraphProducers()
230    {
231       return this.graphProducers;
232    }
233
234
235    /**
236     * Gets the j2EEType attribute of the ManagedObject object
237     *
238     * @return The j2EEType value
239     */

240    public String JavaDoc getJ2EEType()
241    {
242       return this.j2eeType;
243    }
244
245
246    /**
247     * Gets the mBeanInfo attribute of the ManagedObject object
248     *
249     * @return The mBeanInfo value
250     */

251    public MBeanInfo JavaDoc getMBeanInfo()
252    {
253       if (this.info == null)
254       {
255          BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
256          if (context.hasService(ConnectionService.class))
257          {
258             try
259             {
260                ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
261                this.info = service.getMEJB().getMBeanInfo(this.objectName);
262                if (this.info == null)
263                {
264                   logger.warn("MBeanInfo for " + this.objectName + " is null");
265                   throw new Exception JavaDoc("MBeanInfo for " + this.objectName + " is null");
266                }
267
268                // Set some attributes
269
MBeanAttributeInfo JavaDoc[] infos = this.info.getAttributes();
270                for (int i = 0; i < infos.length; i++)
271                {
272                   MBeanAttributeInfo JavaDoc attribute = infos[i];
273                   if ("StateManageable".equalsIgnoreCase(attribute.getName()))
274                   {
275                      Object JavaDoc o = this.getAttribute(attribute.getName());
276                      this.stateManageable = Boolean.valueOf("" + o).booleanValue();
277                   }
278                   if ("EventProvider".equalsIgnoreCase(attribute.getName()))
279                   {
280                      Object JavaDoc o = this.getAttribute(attribute.getName());
281                      this.eventProvider = Boolean.valueOf("" + o).booleanValue();
282                   }
283                   if ("StatisticsProvider".equalsIgnoreCase(attribute.getName()))
284                   {
285                      Object JavaDoc o = this.getAttribute(attribute.getName());
286                      this.statisticsProvider = Boolean.valueOf("" + o).booleanValue();
287                   }
288                }
289
290                context.releaseService(this, this, ConnectionService.class);
291             }
292             catch (Exception JavaDoc e)
293             {
294                logger.error("Error during utilisation of service ConnectionService", e);
295             }
296          }
297       }
298       return this.info;
299    }
300
301
302    /**
303     * Gets the objectName attribute of the ManagedObject object
304     *
305     * @return The objectName value
306     */

307    public ObjectName JavaDoc getObjectName()
308    {
309       return this.objectName;
310    }
311
312
313    /**
314     * Gets the stats attribute of the ManagedObjectStatsViewer object
315     *
316     * @return The stats value
317     * @exception Exception Description of the Exception
318     */

319    public Stats JavaDoc getStats()
320       throws Exception JavaDoc
321    {
322 // MBeanInfo beaninfo = this.getMBeanInfo();
323
MBeanAttributeInfo JavaDoc[] infos = this.filter("stats", null);
324       if (infos.length == 0)
325       {
326          return null;
327       }
328       Stats JavaDoc stats = (Stats JavaDoc) this.getAttribute(infos[0].getName());
329       return stats;
330    }
331
332
333    /**
334     * Description of the Method
335     *
336     * @param action Description of the Parameter
337     * @param params Description of the Parameter
338     * @param signatures Description of the Parameter
339     * @return Description of the Return Value
340     * @exception Exception Description of the Exception
341     */

342    public Object JavaDoc invoke(String JavaDoc action, Object JavaDoc[] params, String JavaDoc[] signatures)
343       throws Exception JavaDoc
344    {
345       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
346       Object JavaDoc result = null;
347
348       if (context.hasService(ConnectionService.class))
349       {
350          try
351          {
352             this.log("Invoking " + action + "...");
353
354             ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
355             result = service.getMEJB().invoke(objectName, action, params, signatures);
356             context.releaseService(this, this, ConnectionService.class);
357
358             this.log("Result :");
359             this.log("" + result);
360          }
361          catch (Exception JavaDoc e)
362          {
363             this.log(e);
364             logger.error("Error while invoking method", e);
365             throw e;
366          }
367       }
368       this.log("");
369       return result;
370    }
371
372
373    /**
374     * Returns the eventProvider.
375     *
376     * @return boolean
377     */

378    public boolean isEventProvider()
379    {
380       if (this.info == null)
381       {
382          this.getMBeanInfo();
383       }
384       return this.eventProvider;
385    }
386
387
388    /**
389     * @param s Description of the Parameter
390     * @return The instanceOf value
391     * @exception Exception Description of the Exception
392     */

393    public boolean isInstanceOf(String JavaDoc s)
394       throws Exception JavaDoc
395    {
396       return false;
397    }
398
399
400    /**
401     * Gets the registered attribute of the ManagedObject object
402     *
403     * @return The registered value
404     * @exception Exception Description of the Exception
405     */

406    public boolean isRegistered()
407       throws Exception JavaDoc
408    {
409       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
410       boolean result = false;
411
412       if (context.hasService(ConnectionService.class))
413       {
414          try
415          {
416             ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
417             result = service.getMEJB().isRegistered(this.objectName);
418             context.releaseService(this, this, ConnectionService.class);
419          }
420          catch (Exception JavaDoc e)
421          {
422             logger.error("Error while testing registration", e);
423             throw e;
424          }
425       }
426       return result;
427    }
428
429
430    /**
431     * Gets the registeredForNotifications attribute of the ManagedObject object
432     *
433     * @return The registeredForNotifications value
434     * @exception Exception Description of the Exception
435     */

436    public boolean isRegisteredForNotifications()
437       throws Exception JavaDoc
438    {
439       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
440       boolean result = false;
441
442       if (context.hasService(NotificationService.class))
443       {
444          try
445          {
446             NotificationService service = (NotificationService) context.getService(this, this, NotificationService.class, this, this);
447             result = service.hasObjectName(objectName);
448             context.releaseService(this, this, NotificationService.class);
449          }
450          catch (Exception JavaDoc e)
451          {
452             logger.error("Error while using NotificationService", e);
453             throw e;
454          }
455       }
456       return result;
457    }
458
459
460    /**
461     * Returns the stateManageable.
462     *
463     * @return boolean
464     */

465    public boolean isStateManageable()
466    {
467       if (this.info == null)
468       {
469          this.getMBeanInfo();
470       }
471       return this.stateManageable;
472    }
473
474
475    /**
476     * Returns the statsProvider.
477     *
478     * @return boolean
479     */

480    public boolean isStatisticsProvider()
481    {
482       if (this.info == null)
483       {
484          this.getMBeanInfo();
485       }
486       return this.statisticsProvider;
487    }
488
489
490    /**
491     * Description of the Method
492     *
493     * @param text Description of the Parameter
494     */

495    public void log(String JavaDoc text)
496    {
497       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
498
499       if (context.hasService(ConsoleService.class))
500       {
501          try
502          {
503             ConsoleService service = (ConsoleService) context.getService(this, this, ConsoleService.class, this, this);
504             service.append(text);
505             context.releaseService(this, this, ConsoleService.class);
506          }
507          catch (Exception JavaDoc e)
508          {
509             logger.error("Error while logging", e);
510          }
511       }
512    }
513
514
515    /**
516     * Description of the Method
517     *
518     * @param t Description of the Parameter
519     */

520    public void log(Throwable JavaDoc t)
521    {
522       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
523
524       if (context.hasService(ConsoleService.class))
525       {
526          try
527          {
528             ConsoleService service = (ConsoleService) context.getService(this, this, ConsoleService.class, this, this);
529             StringWriter JavaDoc w = new StringWriter JavaDoc();
530             PrintWriter JavaDoc pw = new PrintWriter JavaDoc(w);
531             t.printStackTrace(pw);
532             pw.close();
533             this.log("Exception occured :");
534             this.log(w.toString());
535             context.releaseService(this, this, ConsoleService.class);
536          }
537          catch (Exception JavaDoc e)
538          {
539             logger.error("Error while logging", e);
540          }
541       }
542    }
543
544
545    /**
546     * Description of the Method
547     *
548     * @param consumer Description of the Parameter
549     * @param statisticName Description of the Parameter
550     * @param statisticProperty Description of the Parameter
551     */

552    public void registerForGraph(GraphConsumer consumer, String JavaDoc statisticName, String JavaDoc statisticProperty)
553    {
554       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
555
556       if (context.hasService(GraphService.class))
557       {
558          try
559          {
560             GraphService service = (GraphService) context.getService(this, this, GraphService.class, this, this);
561
562             final String JavaDoc fStatisticName = statisticName;
563             final String JavaDoc fStatisticProperty = statisticProperty;
564             String JavaDoc key = statisticName + "@" + statisticProperty;
565
566             GraphProducer producer = (GraphProducer) this.graphProducers.get(key);
567             if (producer == null)
568             {
569                producer =
570                   new GraphProducer()
571                   {
572                      /**
573                       * @return The graphProducerId value
574                       */

575                      public String JavaDoc getGraphProducerId()
576                      {
577                         return ManagedObject.this.getName() + " : " + fStatisticName + " : " + fStatisticProperty;
578                      }
579
580
581                      /**
582                       * @return Description of the Return Value
583                       */

584                      public double produce()
585                      {
586                         try
587                         {
588                            Stats JavaDoc stats = getStats();
589                            Statistic JavaDoc statistic = stats.getStatistic(fStatisticName);
590                            Method JavaDoc m = statistic.getClass().getMethod("get" + fStatisticProperty, new Class JavaDoc[0]);
591                            Object JavaDoc o = m.invoke(statistic, new Object JavaDoc[0]);
592                            return ClassTools.getValue(o);
593                         }
594                         catch (Exception JavaDoc e)
595                         {
596                            logger.warn("Cannot produce a numerical value for " + this.getGraphProducerId(), e);
597                         }
598                         return 0;
599                      }
600                   };
601                this.graphProducers.put(key, producer);
602             }
603             service.addGraphProducer(consumer, producer);
604             context.releaseService(this, this, GraphService.class);
605          }
606          catch (Exception JavaDoc e)
607          {
608             logger.error("Error while using GraphService", e);
609          }
610       }
611    }
612
613
614    /**
615     * Description of the Method
616     *
617     * @exception Exception Description of the Exception
618     */

619    public void registerForNotifications()
620       throws Exception JavaDoc
621    {
622       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
623
624       if (this.isEventProvider() && !this.isRegisteredForNotifications())
625       {
626          if (context.hasService(NotificationService.class))
627          {
628             try
629             {
630                NotificationService service = (NotificationService) context.getService(this, this, NotificationService.class, this, this);
631                service.addObjectName(objectName);
632                context.releaseService(this, this, NotificationService.class);
633                logger.debug("ManagedObject " + this.objectName + " added for broadcasting");
634             }
635             catch (Exception JavaDoc e)
636             {
637                logger.error("Error while using NotificationService", e);
638                throw e;
639             }
640          }
641       }
642    }
643
644
645    /**
646     * Getter for the attribute attribute
647     *
648     * @param attribute The new attribute value
649     * @exception Exception Description of the Exception
650     */

651    public void setAttribute(Attribute JavaDoc attribute)
652       throws Exception JavaDoc
653    {
654       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
655
656       if (context.hasService(ConnectionService.class))
657       {
658          try
659          {
660             ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
661             service.getMEJB().setAttribute(objectName, attribute);
662             context.releaseService(this, this, ConnectionService.class);
663          }
664          catch (Exception JavaDoc e)
665          {
666             logger.error("Error while setting attribute", e);
667             throw e;
668          }
669       }
670    }
671
672
673    /**
674     * Sets the attributes attribute of the ManagedObject object
675     *
676     * @param list The new attributes value
677     * @return Description of the Return Value
678     * @exception Exception Description of the Exception
679     */

680    public AttributeList JavaDoc setAttributes(AttributeList JavaDoc list)
681       throws Exception JavaDoc
682    {
683       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
684       AttributeList JavaDoc result = null;
685
686       if (context.hasService(ConnectionService.class))
687       {
688          try
689          {
690             ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this);
691             result = service.getMEJB().setAttributes(this.objectName, list);
692             context.releaseService(this, this, ConnectionService.class);
693          }
694          catch (Exception JavaDoc e)
695          {
696             logger.error("Error while setting attributes", e);
697             throw e;
698          }
699       }
700       return result;
701    }
702
703
704
705    /**
706     * Sets the reference attribute of the ManagedObject object
707     *
708     * @param objectName The new reference value
709     * @exception Exception Description of the Exception
710     */

711    public void setReference(ObjectName JavaDoc objectName)
712       throws Exception JavaDoc
713    {
714       this.objectName = objectName;
715       this.name = this.objectName.getKeyProperty("name");
716       this.j2eeType = this.objectName.getKeyProperty("j2eeType");
717       this.canonicalName = this.objectName.getCanonicalName();
718       this.domain = this.objectName.getDomain();
719    }
720
721
722    /** Description of the Method */
723    public void unregisterForGraph()
724    {
725       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
726
727       if (context.hasService(GraphService.class))
728       {
729          try
730          {
731             GraphService service = (GraphService) context.getService(this, this, GraphService.class, this, this);
732             for (Iterator JavaDoc iterator = this.graphProducers.keySet().iterator(); iterator.hasNext(); )
733             {
734                String JavaDoc attribute = (String JavaDoc) iterator.next();
735                GraphProducer producer = (GraphProducer) this.graphProducers.get(attribute);
736                service.removeGraphProducer(producer);
737             }
738             context.releaseService(this, this, GraphService.class);
739          }
740          catch (Exception JavaDoc e)
741          {
742             logger.error("Error while using GraphService", e);
743          }
744       }
745    }
746
747
748    /**
749     * Description of the Method
750     *
751     * @exception Exception Description of the Exception
752     */

753    public void unregisterForNotifications()
754       throws Exception JavaDoc
755    {
756       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) getBeanContext();
757
758       if (this.isRegisteredForNotifications())
759       {
760          if (context.hasService(NotificationService.class))
761          {
762             try
763             {
764                NotificationService service = (NotificationService) context.getService(this, this, NotificationService.class, this, this);
765                service.removeObjectName(this.objectName);
766                context.releaseService(this, this, NotificationService.class);
767                logger.debug("ManagedObject " + this.objectName + " removed for broadcasting");
768             }
769             catch (Exception JavaDoc e)
770             {
771                logger.error("Error while using NotificationService", e);
772                throw e;
773             }
774          }
775       }
776    }
777
778
779    /**
780     * @param includes Description of the Parameter
781     * @param excludes Description of the Parameter
782     * @return Description of the Return Value
783     */

784    protected MBeanAttributeInfo JavaDoc[] filter(String JavaDoc includes, String JavaDoc excludes)
785    {
786       MBeanAttributeInfo JavaDoc[] infos = this.getMBeanInfo().getAttributes();
787       ArrayList JavaDoc filteredInfos = new ArrayList JavaDoc();
788
789       if (includes != null)
790       {
791          for (int i = 0; i < infos.length; i++)
792          {
793             String JavaDoc name = infos[i].getName();
794
795             if (includes.indexOf(name.toLowerCase()) >= 0)
796             {
797                filteredInfos.add(infos[i]);
798             }
799          }
800       }
801       if (excludes != null)
802       {
803          for (int i = 0; i < infos.length; i++)
804          {
805             String JavaDoc name = infos[i].getName();
806
807             if (excludes.indexOf(name.toLowerCase()) < 0)
808             {
809                filteredInfos.add(infos[i]);
810             }
811          }
812
813       }
814
815       return (MBeanAttributeInfo JavaDoc[]) filteredInfos.toArray(new MBeanAttributeInfo JavaDoc[0]);
816    }
817
818
819    /** Description of the Method */
820    protected void initializeBeanContextResources()
821    {
822       super.initializeBeanContextResources();
823
824       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) this.getBeanContext();
825       this.useServices(context);
826    }
827
828
829
830    /** Description of the Method */
831    protected void releaseBeanContextResources()
832    {
833       super.releaseBeanContextResources();
834
835       BeanContextServices JavaDoc context = (BeanContextServices JavaDoc) this.getBeanContext();
836       this.releaseServices(context);
837    }
838
839
840    /**
841     * Description of the Method
842     *
843     * @param context Description of the Parameter
844     */

845    protected void releaseServices(BeanContextServices JavaDoc context)
846    {
847       this.c = null;
848
849       if (context.hasService(CacheService.class))
850       {
851 // logger.debug("Using service CacheService... for " + this + " nested in " + context);
852
try
853          {
854             CacheService service = (CacheService) context.getService(this, this, CacheService.class, this, this);
855             service.remove(CacheService.RESOURCE_TYPE, this.getCanonicalName());
856             context.releaseService(this, this, CacheService.class);
857          }
858          catch (Exception JavaDoc e)
859          {
860             logger.error("Error during utilisation of service CacheService for " + this.getName(), e);
861          }
862       }
863    }
864
865
866    /**
867     * Description of the Method
868     *
869     * @param context Description of the Parameter
870     */

871    protected void useServices(BeanContextServices JavaDoc context)
872    {
873       if (context.hasService(CacheService.class))
874       {
875 // logger.debug("Using service CacheService... for " + this + " nested in " + context);
876
try
877          {
878             CacheService service = (CacheService) context.getService(this, this, CacheService.class, this, this);
879             service.add(CacheService.RESOURCE_TYPE, this.getCanonicalName(), this);
880             context.releaseService(this, this, CacheService.class);
881          }
882          catch (Exception JavaDoc e)
883          {
884             logger.error("Error during utilisation of service CacheService for " + this.getName(), e);
885          }
886       }
887    }
888 }
889
Popular Tags