KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > plugins > keygenerator > uuid > UUIDKeyGeneratorFactoryService


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb.plugins.keygenerator.uuid;
23
24 import javax.naming.Context JavaDoc;
25 import javax.naming.InitialContext JavaDoc;
26
27 import org.jboss.system.ServiceMBeanSupport;
28 import org.jboss.naming.Util;
29
30 import org.jboss.ejb.plugins.keygenerator.KeyGeneratorFactory;
31
32 /**
33  * Implements UUID key generator factory service
34  *
35  * @jjmx:mbean name="jboss.system:service=KeyGeneratorFactory,type=UUID"
36  * extends="org.jboss.system.ServiceMBean"
37  *
38  * @author <a HREF="mailto:loubyansky@ukr.net">Alex Loubyansky</a>
39  *
40  * @version $Revision: 37459 $
41  */

42 public class UUIDKeyGeneratorFactoryService
43    extends ServiceMBeanSupport
44    implements UUIDKeyGeneratorFactoryServiceMBean
45 {
46
47    // Attributes ----------------------------------------------------
48

49    /** uuid key generator factory implementation */
50    KeyGeneratorFactory keyGeneratorFactory;
51
52    // ServiceMBeanSupport overridding ------------------------------
53

54    public void startService()
55    {
56       // create uuid key generator factory instance
57
try
58       {
59          keyGeneratorFactory = new UUIDKeyGeneratorFactory();
60       }
61       catch( Exception JavaDoc e ) {
62          log.error( "Caught exception during startService()", e );
63          // Ingore
64
}
65
66       // bind the factory
67
try
68       {
69          Context JavaDoc ctx = (Context JavaDoc) new InitialContext JavaDoc();
70          Util.rebind( ctx, keyGeneratorFactory.getFactoryName(),
71             keyGeneratorFactory );
72       }
73       catch( Exception JavaDoc e ) {
74          log.error( "Caught exception during startService()", e );
75          // Ingore
76
}
77    }
78
79    public void stopService()
80    {
81       // unbind the factory
82
try
83       {
84          Context JavaDoc ctx = (Context JavaDoc) new InitialContext JavaDoc();
85          Util.unbind( ctx, keyGeneratorFactory.getFactoryName() );
86       }
87       catch( Exception JavaDoc e ) {
88          log.error( "Caught exception during stopService()", e );
89          // Ingore
90
}
91    }
92 }
93
Popular Tags