Source Code Cross Referenced for GenericQueryImpl.java in  » ESB » open-esb » com » sun » jbi » management » registry » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.jbi.management.registry.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * BEGIN_HEADER - DO NOT EDIT
0003:         *
0004:         * The contents of this file are subject to the terms
0005:         * of the Common Development and Distribution License
0006:         * (the "License").  You may not use this file except
0007:         * in compliance with the License.
0008:         *
0009:         * You can obtain a copy of the license at
0010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011:         * See the License for the specific language governing
0012:         * permissions and limitations under the License.
0013:         *
0014:         * When distributing Covered Code, include this CDDL
0015:         * HEADER in each file and include the License file at
0016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017:         * If applicable add the following below this CDDL HEADER,
0018:         * with the fields enclosed by brackets "[]" replaced with
0019:         * your own identifying information: Portions Copyright
0020:         * [year] [name of copyright owner]
0021:         */
0022:
0023:        /*
0024:         * @(#)GenericQueryImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        /**
0030:         *  GenericQueryImpl.java
0031:         *
0032:         *  SUN PROPRIETARY/CONFIDENTIAL.
0033:         *  This software is the proprietary information of Sun Microsystems, Inc.
0034:         *  Use is subject to license terms.
0035:         *
0036:         *  Created on August 23, 2006, 5:17 PM
0037:         */package com.sun.jbi.management.registry.xml;
0038:
0039:        import java.io.File;
0040:        import java.util.List;
0041:        import java.util.ArrayList;
0042:        import java.util.Collections;
0043:        import java.util.Map;
0044:        import java.util.HashMap;
0045:        import java.util.logging.Logger;
0046:
0047:        import com.sun.jbi.ComponentInfo;
0048:        import com.sun.jbi.ComponentQuery;
0049:        import com.sun.jbi.ComponentType;
0050:        import com.sun.jbi.ComponentState;
0051:        import com.sun.jbi.ServiceUnitInfo;
0052:        import com.sun.jbi.StringTranslator;
0053:        import com.sun.jbi.management.LocalStringKeys;
0054:        import com.sun.jbi.management.ConfigurationCategory;
0055:        import com.sun.jbi.management.registry.Registry;
0056:        import com.sun.jbi.management.registry.Updater;
0057:        import com.sun.jbi.management.registry.RegistryException;
0058:        import com.sun.jbi.management.repository.Repository;
0059:        import com.sun.jbi.management.repository.RepositoryException;
0060:        import com.sun.jbi.management.repository.Archive;
0061:        import com.sun.jbi.management.repository.ArchiveType;
0062:        import com.sun.jbi.management.system.ManagementContext;
0063:        import com.sun.jbi.management.system.ManagementException;
0064:        import com.sun.jbi.management.util.LockManager;
0065:        import com.sun.jbi.management.util.PropertyFilter;
0066:
0067:        /**
0068:         * This class encapsulates queries which are common to 
0069:         * all targets ( domain / server / cluster ).
0070:         *
0071:         * @author Sun Microsystems, Inc.
0072:         */
0073:        public class GenericQueryImpl implements 
0074:                com.sun.jbi.management.registry.GenericQuery {
0075:
0076:            private Jbi mJbiRegistry;
0077:            private RegistryImpl mRegistry;
0078:            private boolean mValidate;
0079:            private boolean mReadonly;
0080:            private ManagementContext mMgtCtx;
0081:            private StringTranslator mTranslator;
0082:            private Logger mLog;
0083:            private LockManager mRegObjLM;
0084:            private RegistryUtil mRegUtil;
0085:
0086:            /**
0087:             * Cache for the deployment/installation descriptors
0088:             */
0089:            private Map<String, String> mComponentCache;
0090:            private Map<String, String> mSharedLibraryCache;
0091:            private Map<String, String> mServiceAssemblyCache;
0092:
0093:            private Map<String, com.sun.jbi.management.descriptor.Jbi> mJbiComponentCache;
0094:            private Map<String, com.sun.jbi.management.descriptor.Jbi> mJbiSharedLibraryCache;
0095:            private Map<String, com.sun.jbi.management.descriptor.Jbi> mJbiServiceAssemblyCache;
0096:
0097:            public GenericQueryImpl(Jbi jbi, ManagementContext mgtCtx,
0098:                    boolean validate, RegistryImpl registry) {
0099:                mJbiRegistry = jbi;
0100:                mRegistry = registry;
0101:                mValidate = validate;
0102:                mReadonly = registry
0103:                        .getProperty(Registry.REGISTRY_READONLY_PROPERTY) != null;
0104:                mMgtCtx = mgtCtx;
0105:                mLog = mgtCtx.getLogger();
0106:                mRegUtil = new RegistryUtil(mgtCtx, registry);
0107:                mTranslator = mgtCtx.getEnvironmentContext()
0108:                        .getStringTranslator("com.sun.jbi.management");
0109:
0110:                mComponentCache = Collections.synchronizedMap(new HashMap());
0111:                mSharedLibraryCache = Collections
0112:                        .synchronizedMap(new HashMap());
0113:                mServiceAssemblyCache = Collections
0114:                        .synchronizedMap(new HashMap());
0115:
0116:                mJbiComponentCache = Collections.synchronizedMap(new HashMap());
0117:                mJbiSharedLibraryCache = Collections
0118:                        .synchronizedMap(new HashMap());
0119:                mJbiServiceAssemblyCache = Collections
0120:                        .synchronizedMap(new HashMap());
0121:
0122:                mRegObjLM = mRegistry.getRegistryObjectLockManager();
0123:            }
0124:
0125:            /** 
0126:             * @param componentName - Component name
0127:             * @return a List<String> of all servers installing a component.
0128:             *         The list excludes all non-clustered servers.
0129:             * @throws RegistryException if a read lock cannot be acquired to access the 
0130:             *         in-memory Registry.
0131:             *
0132:             */
0133:            public List<String> getServersInstallingComponent(
0134:                    String componentName) throws RegistryException {
0135:                ArrayList<String> resServers = new ArrayList();
0136:
0137:                if (isComponentRegistered(componentName)) {
0138:                    mRegObjLM.acquireReadLock();
0139:                    if (mJbiRegistry.getServers() != null) {
0140:                        List<InstalledComponentsListType> servers = mJbiRegistry
0141:                                .getServers().getServer();
0142:                        for (InstalledComponentsListType server : servers) {
0143:                            List<ComponentRefType> refs = server
0144:                                    .getComponentRef();
0145:                            for (ComponentRefType compRef : refs) {
0146:                                if (compRef.getNameRef().equals(componentName)) {
0147:                                    resServers.add(server.getNameRef());
0148:                                }
0149:                            }
0150:                        }
0151:                    }
0152:                    mRegObjLM.releaseReadLock();
0153:                }
0154:
0155:                return resServers;
0156:            }
0157:
0158:            /** 
0159:             * @param  sharedLibraryName - Shared Library name
0160:             * @return a List<String> of all servers installing a shared library.
0161:             *         The list excludes all non-clustered servers.
0162:             * @throws RegistryException if a read lock cannot be acquired to access the 
0163:             *         in-memory Registry.
0164:             *
0165:             */
0166:            public List<String> getServersInstallingSharedLibrary(
0167:                    String sharedLibraryName) throws RegistryException {
0168:
0169:                ArrayList<String> resServers = new ArrayList();
0170:
0171:                if (isSharedLibraryRegistered(sharedLibraryName)) {
0172:                    mRegObjLM.acquireReadLock();
0173:                    try {
0174:                        if (mJbiRegistry.getServers() != null) {
0175:                            List<InstalledComponentsListType> servers = mJbiRegistry
0176:                                    .getServers().getServer();
0177:
0178:                            for (InstalledComponentsListType server : servers) {
0179:                                List<SharedLibraryRefType> refs = server
0180:                                        .getSharedLibraryRef();
0181:
0182:                                for (SharedLibraryRefType slRef : refs) {
0183:                                    if (slRef.getNameRef().equals(
0184:                                            sharedLibraryName)) {
0185:                                        resServers.add(server.getNameRef());
0186:                                    }
0187:                                }
0188:                            }
0189:                        }
0190:                    } finally {
0191:                        mRegObjLM.releaseReadLock();
0192:                    }
0193:                }
0194:                return resServers;
0195:
0196:            }
0197:
0198:            /** 
0199:             * @param  serviceAssemblyName - Service Assembly name
0200:             * @return a List<String> of all servers deploying a service assembly.
0201:             *         The list excludes all non-clustered servers.
0202:             * @throws RegistryException if a read lock cannot be acquired to access the 
0203:             *         in-memory Registry.
0204:             *
0205:             */
0206:            public List<String> getServersDeployingServiceAssembly(
0207:                    String serviceAssemblyName) throws RegistryException {
0208:
0209:                ArrayList<String> resServers = new ArrayList();
0210:
0211:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0212:                    mRegObjLM.acquireReadLock();
0213:                    try {
0214:                        if (mJbiRegistry.getServers() != null) {
0215:                            List<InstalledComponentsListType> servers = mJbiRegistry
0216:                                    .getServers().getServer();
0217:                            for (InstalledComponentsListType server : servers) {
0218:                                List<ServiceAssemblyRefType> refs = server
0219:                                        .getServiceAssemblyRef();
0220:
0221:                                for (ServiceAssemblyRefType saRef : refs) {
0222:                                    if (saRef.getNameRef().equals(
0223:                                            serviceAssemblyName)) {
0224:                                        resServers.add(server.getNameRef());
0225:                                    }
0226:                                }
0227:                            }
0228:                        }
0229:                    } finally {
0230:                        mRegObjLM.releaseReadLock();
0231:                    }
0232:                }
0233:                return resServers;
0234:            }
0235:
0236:            /** 
0237:             * @param componentName - Component name
0238:             * @return a List<String> of all clusters installing a component.
0239:             * @throws RegistryException if a read lock cannot be acquired to access the 
0240:             *         in-memory Registry.
0241:             *
0242:             */
0243:            public List<String> getClustersInstallingComponent(
0244:                    String componentName) throws RegistryException {
0245:                ArrayList<String> resClusters = new ArrayList();
0246:                if (isComponentRegistered(componentName)) {
0247:                    mRegObjLM.acquireReadLock();
0248:                    try {
0249:                        if (mJbiRegistry.getClusters() != null) {
0250:
0251:                            List<InstalledComponentsListType> clusters = mJbiRegistry
0252:                                    .getClusters().getCluster();
0253:                            for (InstalledComponentsListType cluster : clusters) {
0254:                                List<ComponentRefType> refs = cluster
0255:                                        .getComponentRef();
0256:                                for (ComponentRefType compRef : refs) {
0257:                                    if (compRef.getNameRef().equals(
0258:                                            componentName)) {
0259:                                        resClusters.add(cluster.getNameRef());
0260:                                    }
0261:                                }
0262:                            }
0263:                        }
0264:                    } finally {
0265:                        mRegObjLM.releaseReadLock();
0266:                    }
0267:                }
0268:
0269:                return resClusters;
0270:            }
0271:
0272:            /** 
0273:             * @param  sharedLibraryName - Shared Library name
0274:             * @return a List<String> of all clusters installing a shared library.
0275:             * @throws RegistryException if a read lock cannot be acquired to access the 
0276:             *         in-memory Registry.
0277:             *
0278:             */
0279:            public List<String> getClustersInstallingSharedLibrary(
0280:                    String sharedLibraryName) throws RegistryException {
0281:                ArrayList<String> resClusters = new ArrayList();
0282:
0283:                if (isSharedLibraryRegistered(sharedLibraryName)) {
0284:                    mRegObjLM.acquireReadLock();
0285:                    try {
0286:                        if (mJbiRegistry.getClusters() != null) {
0287:                            List<InstalledComponentsListType> clusters = mJbiRegistry
0288:                                    .getClusters().getCluster();
0289:                            for (InstalledComponentsListType cluster : clusters) {
0290:                                List<SharedLibraryRefType> refs = cluster
0291:                                        .getSharedLibraryRef();
0292:                                for (SharedLibraryRefType slRef : refs) {
0293:                                    if (slRef.getNameRef().equals(
0294:                                            sharedLibraryName)) {
0295:                                        resClusters.add(cluster.getNameRef());
0296:                                    }
0297:                                }
0298:                            }
0299:                        }
0300:                    } finally {
0301:                        mRegObjLM.releaseReadLock();
0302:                    }
0303:                }
0304:                return resClusters;
0305:            }
0306:
0307:            /** 
0308:             * @param  serviceAssemblyName - Service Assembly name
0309:             * @return a List<String> of all clusters deploying a service assembly.
0310:             *         The list excludes all non-clustered servers.
0311:             * @throws RegistryException if a read lock cannot be acquired to access the 
0312:             *         in-memory Registry.
0313:             *
0314:             */
0315:            public List<String> getClustersDeployingServiceAssembly(
0316:                    String serviceAssemblyName) throws RegistryException {
0317:
0318:                ArrayList<String> resClusters = new ArrayList();
0319:
0320:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0321:                    mRegObjLM.acquireReadLock();
0322:                    try {
0323:                        if (mJbiRegistry.getClusters() != null) {
0324:                            List<InstalledComponentsListType> clusters = mJbiRegistry
0325:                                    .getClusters().getCluster();
0326:                            for (InstalledComponentsListType cluster : clusters) {
0327:                                List<ServiceAssemblyRefType> refs = cluster
0328:                                        .getServiceAssemblyRef();
0329:
0330:                                for (ServiceAssemblyRefType saRef : refs) {
0331:                                    if (saRef.getNameRef().equals(
0332:                                            serviceAssemblyName)) {
0333:                                        resClusters.add(cluster.getNameRef());
0334:                                    }
0335:                                }
0336:                            }
0337:                        }
0338:                    } finally {
0339:                        mRegObjLM.releaseReadLock();
0340:                    }
0341:                }
0342:                return resClusters;
0343:            }
0344:
0345:            /**
0346:             * @param componentName - component name
0347:             * @return the Installation descriptor for the component.
0348:             * @throws RegistryException if a read lock cannot be acquired to access the 
0349:             *         in-memory Registry.
0350:             */
0351:            public String getComponentInstallationDescriptor(
0352:                    String componentName) throws RegistryException {
0353:                String jbiXml = null;
0354:                if (isComponentRegistered(componentName)) {
0355:                    if (mComponentCache.containsKey(componentName)) {
0356:                        jbiXml = mComponentCache.get(componentName);
0357:                    } else {
0358:                        Repository repos = mMgtCtx.getRepository();
0359:                        Archive componentArchive = null;
0360:
0361:                        componentArchive = repos.getArchive(
0362:                                ArchiveType.COMPONENT, componentName);
0363:
0364:                        if (componentArchive != null) {
0365:                            jbiXml = componentArchive.getJbiXmlString(true);
0366:                            mComponentCache.put(componentName, jbiXml);
0367:                        }
0368:                    }
0369:                }
0370:                return jbiXml;
0371:            }
0372:
0373:            /**
0374:             * Get the wrapper for the JAXB model for the installation descriptor for
0375:             * a component.
0376:             * @param componentName - component name
0377:             * @return the wrapper for the installation descriptor for the component.
0378:             * @throws RegistryException if a read lock cannot be acquired to access the
0379:             *         in-memory Registry.
0380:             */
0381:            public com.sun.jbi.management.descriptor.ComponentDescriptor getComponentDescriptor(
0382:                    String componentName) throws RegistryException {
0383:                com.sun.jbi.management.descriptor.ComponentDescriptor desc = null;
0384:                com.sun.jbi.management.descriptor.Jbi jbiXml = getComponentJbi(componentName);
0385:
0386:                if (null != jbiXml) {
0387:                    desc = new com.sun.jbi.management.descriptor.ComponentDescriptor(
0388:                            jbiXml);
0389:                }
0390:                return desc;
0391:            }
0392:
0393:            /**
0394:             * @param componentName - component name
0395:             * @return the Installation descriptor for the component.
0396:             * @throws RegistryException if a read lock cannot be acquired to access the 
0397:             *         in-memory Registry.
0398:             */
0399:            public com.sun.jbi.management.descriptor.Jbi getComponentJbi(
0400:                    String componentName) throws RegistryException {
0401:                com.sun.jbi.management.descriptor.Jbi jbiXml = null;
0402:                if (isComponentRegistered(componentName)) {
0403:                    if (mJbiComponentCache.containsKey(componentName)) {
0404:                        jbiXml = mJbiComponentCache.get(componentName);
0405:                    } else {
0406:
0407:                        Repository repos = mMgtCtx.getRepository();
0408:                        Archive componentArchive = null;
0409:
0410:                        componentArchive = repos.getArchive(
0411:                                ArchiveType.COMPONENT, componentName);
0412:
0413:                        if (componentArchive != null) {
0414:                            jbiXml = componentArchive.getJbiXml(true);
0415:                            mJbiComponentCache.put(componentName, jbiXml);
0416:                        }
0417:                    }
0418:                }
0419:                return jbiXml;
0420:            }
0421:
0422:            /**
0423:             * @param sharedLibraryName - shared library name
0424:             * @return the Installation descriptor for the shared library.
0425:             * @throws RegistryException if a read lock cannot be acquired to access the 
0426:             *         in-memory Registry.
0427:             */
0428:            public String getSharedLibraryInstallationDescriptor(
0429:                    String sharedLibraryName) throws RegistryException {
0430:                String jbiXml = null;
0431:                if (isSharedLibraryRegistered(sharedLibraryName)) {
0432:                    if (mSharedLibraryCache.containsKey(sharedLibraryName)) {
0433:                        jbiXml = mSharedLibraryCache.get(sharedLibraryName);
0434:                    } else {
0435:                        Repository repos = mMgtCtx.getRepository();
0436:                        Archive sharedLibraryArchive = null;
0437:
0438:                        sharedLibraryArchive = repos.getArchive(
0439:                                ArchiveType.SHARED_LIBRARY, sharedLibraryName);
0440:
0441:                        if (sharedLibraryArchive != null) {
0442:                            jbiXml = sharedLibraryArchive.getJbiXmlString(true);
0443:                            mSharedLibraryCache.put(sharedLibraryName, jbiXml);
0444:                        }
0445:                    }
0446:                }
0447:                return jbiXml;
0448:            }
0449:
0450:            /**
0451:             * @param sharedLibraryName - shared library name
0452:             * @return the Installation descriptor for the shared library.
0453:             * @throws RegistryException if a read lock cannot be acquired to access the 
0454:             *         in-memory Registry.
0455:             */
0456:            public com.sun.jbi.management.descriptor.Jbi getSharedLibraryJbi(
0457:                    String sharedLibraryName) throws RegistryException {
0458:                com.sun.jbi.management.descriptor.Jbi jbiXml = null;
0459:                if (isSharedLibraryRegistered(sharedLibraryName)) {
0460:                    if (mJbiSharedLibraryCache.containsKey(sharedLibraryName)) {
0461:                        jbiXml = mJbiSharedLibraryCache.get(sharedLibraryName);
0462:                    } else {
0463:                        Repository repos = mMgtCtx.getRepository();
0464:                        Archive sharedLibraryArchive = null;
0465:
0466:                        sharedLibraryArchive = repos.getArchive(
0467:                                ArchiveType.SHARED_LIBRARY, sharedLibraryName);
0468:
0469:                        if (sharedLibraryArchive != null) {
0470:                            jbiXml = sharedLibraryArchive.getJbiXml(true);
0471:                            mJbiSharedLibraryCache.put(sharedLibraryName,
0472:                                    jbiXml);
0473:                        }
0474:                    }
0475:                }
0476:                return jbiXml;
0477:            }
0478:
0479:            /**
0480:             * @param serviceAssemblyName - service assembly name
0481:             * @return the Installation descriptor for the component.
0482:             * @throws RegistryException if a read lock cannot be acquired to access the 
0483:             *         in-memory Registry.
0484:             */
0485:            public String getServiceAssemblyDeploymentDescriptor(
0486:                    String serviceAssemblyName) throws RegistryException {
0487:                String jbiXml = null;
0488:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0489:                    if (mServiceAssemblyCache.containsKey(serviceAssemblyName)) {
0490:                        jbiXml = mServiceAssemblyCache.get(serviceAssemblyName);
0491:                    } else {
0492:                        Repository repos = mMgtCtx.getRepository();
0493:                        Archive serviceAssemblyArchive = repos.getArchive(
0494:                                ArchiveType.SERVICE_ASSEMBLY,
0495:                                serviceAssemblyName);
0496:                        if (serviceAssemblyArchive != null) {
0497:                            jbiXml = serviceAssemblyArchive
0498:                                    .getJbiXmlString(true);
0499:                            mServiceAssemblyCache.put(serviceAssemblyName,
0500:                                    jbiXml);
0501:                        }
0502:                    }
0503:                }
0504:                return jbiXml;
0505:            }
0506:
0507:            /**
0508:             * @param serviceAssemblyName - service assembly name
0509:             * @param serviceUnitName - service unit name
0510:             * @return the deployment descriptor for the service unit.
0511:             * @throws RegistryException if a read lock cannot be acquired to access the 
0512:             *         in-memory Registry.
0513:             */
0514:            public String getServiceUnitDeploymentDescriptor(
0515:                    String serviceAssemblyName, String serviceUnitName)
0516:                    throws RegistryException {
0517:
0518:                String jbiXml = null;
0519:
0520:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0521:                    Repository repos = mMgtCtx.getRepository();
0522:                    String queryStr = serviceAssemblyName
0523:                            + java.io.File.separator + serviceUnitName;
0524:                    Archive serviceUnitArchive = repos.getArchive(
0525:                            ArchiveType.SERVICE_UNIT, queryStr);
0526:                    if (serviceUnitArchive != null) {
0527:                        jbiXml = serviceUnitArchive.getJbiXmlString(true);
0528:                    }
0529:                }
0530:                return jbiXml;
0531:            }
0532:
0533:            /**
0534:             * @param serviceAssemblyName - service assembly name
0535:             * @return the Installation descriptor for the component.
0536:             * @throws RegistryException if a read lock cannot be acquired to access the 
0537:             *         in-memory Registry.
0538:             */
0539:            public com.sun.jbi.management.descriptor.Jbi getServiceAssemblyJbi(
0540:                    String serviceAssemblyName) throws RegistryException {
0541:                com.sun.jbi.management.descriptor.Jbi jbiXml = null;
0542:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0543:                    if (mJbiServiceAssemblyCache
0544:                            .containsKey(serviceAssemblyName)) {
0545:                        jbiXml = mJbiServiceAssemblyCache
0546:                                .get(serviceAssemblyName);
0547:                    } else {
0548:                        Repository repos = mMgtCtx.getRepository();
0549:                        Archive serviceAssemblyArchive = repos.getArchive(
0550:                                ArchiveType.SERVICE_ASSEMBLY,
0551:                                serviceAssemblyName);
0552:                        if (serviceAssemblyArchive != null) {
0553:                            jbiXml = serviceAssemblyArchive.getJbiXml(true);
0554:                            mJbiServiceAssemblyCache.put(serviceAssemblyName,
0555:                                    jbiXml);
0556:                        }
0557:                    }
0558:                }
0559:                return jbiXml;
0560:            }
0561:
0562:            /**
0563:             * @param saName - service assembly name
0564:             * @return the filename for the associated archive
0565:             * @throws RegistryException if a problem exists.
0566:             */
0567:            public String getServiceAssemblyArchive(String saName)
0568:                    throws RegistryException {
0569:                return mRegistry.getRepository().findArchive(
0570:                        ArchiveType.SERVICE_ASSEMBLY, saName);
0571:            }
0572:
0573:            /**
0574:            /**
0575:             * @param componentName - component name
0576:             * @return the filename for the associated archive
0577:             * @throws RegistryException if a problem exists.
0578:             */
0579:            public String getComponentArchive(String componentName)
0580:                    throws RegistryException {
0581:                return mRegistry.getRepository().findArchive(
0582:                        ArchiveType.COMPONENT, componentName);
0583:            }
0584:
0585:            /**
0586:             * @param sharedLibraryName - sharedLibrary name
0587:             * @return the filename for the associated archive
0588:             * @throws RegistryException if a problem exists.
0589:             */
0590:            public String getSharedLibraryArchive(String sharedLibraryName)
0591:                    throws RegistryException {
0592:                return mRegistry.getRepository().findArchive(
0593:                        ArchiveType.SHARED_LIBRARY, sharedLibraryName);
0594:            }
0595:
0596:            /**
0597:             * @return true if a component is installed on one or more servers / clusters
0598:             * @throws RegistryException if a read lock cannot be acquired to access the 
0599:             *         in-memory Registry.
0600:             */
0601:            public boolean isComponentInstalled(String componentName)
0602:                    throws RegistryException {
0603:                boolean installed = false;
0604:                if (isComponentRegistered(componentName)) {
0605:                    List<String> servers = getServersInstallingComponent(componentName);
0606:                    List<String> clusters = getClustersInstallingComponent(componentName);
0607:                    if ((servers.size() > 0) || (clusters.size() > 0)) {
0608:                        installed = true;
0609:                    }
0610:                }
0611:                return installed;
0612:            }
0613:
0614:            /**
0615:             * @return true if a shared library is installed on one or more servers / clusters
0616:             * @throws RegistryException if a read lock cannot be acquired to access the 
0617:             *         in-memory Registry.
0618:             */
0619:            public boolean isSharedLibraryInstalled(String sharedLibraryName)
0620:                    throws RegistryException {
0621:                boolean installed = false;
0622:
0623:                if (isSharedLibraryRegistered(sharedLibraryName)) {
0624:                    List<String> servers = getServersInstallingSharedLibrary(sharedLibraryName);
0625:                    List<String> clusters = getClustersInstallingSharedLibrary(sharedLibraryName);
0626:
0627:                    if ((servers.size() > 0) || (clusters.size() > 0)) {
0628:                        installed = true;
0629:                    }
0630:                }
0631:                return installed;
0632:            }
0633:
0634:            /**
0635:             * @return true if a service assembly is deployed on one or more servers / clusters
0636:             * @throws RegistryException if a read lock cannot be acquired to access the 
0637:             *         in-memory Registry.
0638:             */
0639:            public boolean isServiceAssemblyDeployed(String serviceAssemblyName)
0640:                    throws RegistryException {
0641:                boolean deployed = false;
0642:
0643:                if (isServiceAssemblyRegistered(serviceAssemblyName)) {
0644:
0645:                    List<String> servers = getServersDeployingServiceAssembly(serviceAssemblyName);
0646:                    List<String> clusters = getClustersDeployingServiceAssembly(serviceAssemblyName);
0647:
0648:                    if ((servers.size() > 0) || (clusters.size() > 0)) {
0649:                        deployed = true;
0650:                    }
0651:                }
0652:
0653:                return deployed;
0654:            }
0655:
0656:            /**
0657:             * @return a List of Servers in the registry
0658:             */
0659:            public List<String> getServers() throws RegistryException {
0660:                mRegObjLM.acquireReadLock();
0661:                List servers = new ArrayList();
0662:                try {
0663:                    ServerListType serverLT = mJbiRegistry.getServers();
0664:
0665:                    if (serverLT != null) {
0666:                        List<InstalledComponentsListType> serverList = serverLT
0667:                                .getServer();
0668:                        for (InstalledComponentsListType server : serverList) {
0669:                            servers.add(server.getNameRef());
0670:                        }
0671:                    }
0672:                } finally {
0673:                    mRegObjLM.releaseReadLock();
0674:                }
0675:                return servers;
0676:            }
0677:
0678:            /**
0679:             * @return a List of Clusters in the registry
0680:             */
0681:            public List<String> getClusters() throws RegistryException {
0682:                mRegObjLM.acquireReadLock();
0683:                List clusters = new ArrayList();
0684:                try {
0685:                    ClusterListType clusterLT = mJbiRegistry.getClusters();
0686:
0687:                    if (clusterLT != null) {
0688:                        List<InstalledComponentsListType> clusterList = clusterLT
0689:                                .getCluster();
0690:                        for (InstalledComponentsListType cluster : clusterList) {
0691:                            clusters.add(cluster.getNameRef());
0692:                        }
0693:                    }
0694:                } finally {
0695:                    mRegObjLM.releaseReadLock();
0696:                }
0697:                return clusters;
0698:            }
0699:
0700:            boolean isTargetServer(String targetName) throws RegistryException {
0701:                return getServers().contains(targetName);
0702:            }
0703:
0704:            boolean isTargetCluster(String targetName) throws RegistryException {
0705:                return getClusters().contains(targetName);
0706:            }
0707:
0708:            boolean isTargetDomain(String targetName) {
0709:                return "domain".equals(targetName);
0710:            }
0711:
0712:            public void removeComponentFromCache(String componentName) {
0713:                if (mComponentCache.containsKey(componentName)) {
0714:                    mComponentCache.remove(componentName);
0715:                }
0716:
0717:                if (mJbiComponentCache.containsKey(componentName)) {
0718:                    mJbiComponentCache.remove(componentName);
0719:                }
0720:            }
0721:
0722:            public void removeServiceAssemblyFromCache(
0723:                    String serviceAssemblyName) {
0724:                if (mServiceAssemblyCache.containsKey(serviceAssemblyName)) {
0725:                    mServiceAssemblyCache.remove(serviceAssemblyName);
0726:                }
0727:
0728:                if (mJbiServiceAssemblyCache.containsKey(serviceAssemblyName)) {
0729:                    mJbiServiceAssemblyCache.remove(serviceAssemblyName);
0730:                }
0731:            }
0732:
0733:            public void removeSharedLibraryFromCache(String sharedLibraryName) {
0734:                if (mSharedLibraryCache.containsKey(sharedLibraryName)) {
0735:                    mSharedLibraryCache.remove(sharedLibraryName);
0736:                }
0737:
0738:                if (mJbiSharedLibraryCache.containsKey(sharedLibraryName)) {
0739:                    mJbiSharedLibraryCache.remove(sharedLibraryName);
0740:                }
0741:            }
0742:
0743:            public ComponentType getComponentType(String componentName)
0744:                    throws RegistryException {
0745:                ComponentType compType = null;
0746:
0747:                if (isComponentRegistered(componentName)) {
0748:                    com.sun.jbi.management.descriptor.Jbi jbiXML = getComponentJbi(componentName);
0749:
0750:                    com.sun.jbi.management.descriptor.Component comp = jbiXML
0751:                            .getComponent();
0752:
0753:                    if (comp != null) {
0754:                        if (comp.getType()
0755:                                .equalsIgnoreCase("binding-component")) {
0756:                            compType = ComponentType.BINDING;
0757:                        } else if (comp.getType().equalsIgnoreCase(
0758:                                "service-engine")) {
0759:                            compType = ComponentType.ENGINE;
0760:                        }
0761:                    }
0762:                }
0763:                return compType;
0764:            }
0765:
0766:            /**
0767:             * Return the state of the component on the specified target.
0768:             */
0769:            public ComponentState getComponentState(String componentName,
0770:                    String targetName) throws RegistryException {
0771:                ComponentState compState = ComponentState.UNKNOWN;
0772:
0773:                if (isComponentRegistered(componentName)) {
0774:                    ComponentRefType comp = getComponent(componentName,
0775:                            targetName);
0776:
0777:                    if (comp != null) {
0778:                        compState = ComponentState.valueOfString(comp
0779:                                .getState().value());
0780:                    }
0781:                }
0782:                return compState;
0783:            }
0784:
0785:            public boolean isComponentRegistered(String componentName)
0786:                    throws RegistryException {
0787:
0788:                boolean isReadLocked = false;
0789:                boolean isInRegistry = false;
0790:                boolean isInRepository = false;
0791:                boolean isRegistered = false;
0792:
0793:                // -- Check if in Registry
0794:                mRegObjLM.acquireReadLock();
0795:                try {
0796:                    isReadLocked = true;
0797:                    Components compTypes = mJbiRegistry.getComponents();
0798:
0799:                    if (compTypes != null) {
0800:                        List<DomainComponentType> comps = compTypes
0801:                                .getComponent();
0802:
0803:                        for (DomainComponentType comp : comps) {
0804:                            if (comp.getName().equals(componentName)) {
0805:                                if (mReadonly) {
0806:                                    mRegObjLM.releaseReadLock();
0807:                                    isReadLocked = false;
0808:                                    return (true);
0809:                                }
0810:                                isInRegistry = true;
0811:                                break;
0812:                            }
0813:                        }
0814:                    }
0815:
0816:                    try {
0817:                        // -- Check if in Repository
0818:                        Repository repos = mMgtCtx.getRepository();
0819:                        Archive componentArchive = null;
0820:
0821:                        componentArchive = repos.getArchive(
0822:                                ArchiveType.COMPONENT, componentName);
0823:                        if (componentArchive != null) {
0824:                            isInRepository = true;
0825:                        }
0826:
0827:                        if (isInRegistry != isInRepository) {
0828:                            mRegObjLM.releaseReadLock();
0829:                            isReadLocked = false;
0830:                            mRegUtil
0831:                                    .cleanEntity(ArchiveType.COMPONENT,
0832:                                            componentName, isInRegistry,
0833:                                            isInRepository);
0834:                        }
0835:                    } catch (Exception ex) {
0836:                        mLog.warning(ex.getMessage());
0837:                    }
0838:                    isRegistered = (isInRegistry && isInRepository);
0839:                } finally {
0840:                    if (isReadLocked) {
0841:                        mRegObjLM.releaseReadLock();
0842:                    }
0843:                }
0844:                return isRegistered;
0845:            }
0846:
0847:            public boolean isSharedLibraryRegistered(String sharedLibraryName)
0848:                    throws RegistryException {
0849:                boolean isReadLocked = false;
0850:                boolean isInRegistry = false;
0851:                boolean isInRepository = false;
0852:                boolean isRegistered = false;
0853:
0854:                // -- Check if in Registry
0855:                mRegObjLM.acquireReadLock();
0856:                try {
0857:                    isReadLocked = true;
0858:                    SharedLibraries slsType = mJbiRegistry.getSharedLibraries();
0859:
0860:                    if (slsType != null) {
0861:                        List<DomainSharedLibraryType> sls = slsType
0862:                                .getSharedLibrary();
0863:
0864:                        for (DomainSharedLibraryType sl : sls) {
0865:                            if (sl.getName().equals(sharedLibraryName)) {
0866:                                if (mReadonly) {
0867:                                    mRegObjLM.releaseReadLock();
0868:                                    isReadLocked = false;
0869:                                    return (true);
0870:                                }
0871:                                isInRegistry = true;
0872:                                break;
0873:                            }
0874:                        }
0875:                    }
0876:
0877:                    try {
0878:                        Repository repos = mMgtCtx.getRepository();
0879:                        Archive slArchive = null;
0880:
0881:                        // -- Check if in Repository
0882:                        slArchive = repos.getArchive(
0883:                                ArchiveType.SHARED_LIBRARY, sharedLibraryName);
0884:
0885:                        if (slArchive != null) {
0886:                            isInRepository = true;
0887:                        }
0888:
0889:                        if (isInRegistry != isInRepository) {
0890:                            mRegObjLM.releaseReadLock();
0891:                            isReadLocked = false;
0892:                            mRegUtil.cleanEntity(ArchiveType.SHARED_LIBRARY,
0893:                                    sharedLibraryName, isInRegistry,
0894:                                    isInRepository);
0895:                        }
0896:                    } catch (Exception ex) {
0897:                        mLog.warning(ex.getMessage());
0898:                    }
0899:
0900:                    isRegistered = (isInRegistry && isInRepository);
0901:                } finally {
0902:                    if (isReadLocked) {
0903:                        mRegObjLM.releaseReadLock();
0904:                    }
0905:                }
0906:                return isRegistered;
0907:            }
0908:
0909:            /**
0910:             * If a service assembly is registered in the registry and not in the repository
0911:             * it is removed from the repository.
0912:             *
0913:             * If a service assembly is registered in the repository and not in the registry
0914:             * then the service assembly is removed from the domain entry as well as any other
0915:             * installed entry.
0916:             *
0917:             * @return true if the service assembly is there in registry and repository
0918:             */
0919:            public boolean isServiceAssemblyRegistered(
0920:                    String serviceAssemblyName) throws RegistryException {
0921:
0922:                boolean isReadLocked = false;
0923:                boolean isInRegistry = false;
0924:                boolean isInRepository = false;
0925:                boolean isRegistered = false;
0926:
0927:                try {
0928:                    // -- Check if in Registry
0929:
0930:                    mRegObjLM.acquireReadLock();
0931:                    try {
0932:                        isReadLocked = true;
0933:                        ServiceAssemblies sasType = mJbiRegistry
0934:                                .getServiceAssemblies();
0935:
0936:                        if (sasType != null) {
0937:                            List<DomainEntityType> sas = sasType
0938:                                    .getServiceAssembly();
0939:
0940:                            for (DomainEntityType sa : sas) {
0941:                                if (sa.getName().equals(serviceAssemblyName)) {
0942:                                    if (mReadonly) {
0943:                                        mRegObjLM.releaseReadLock();
0944:                                        isReadLocked = false;
0945:                                        return (true);
0946:                                    }
0947:                                    isInRegistry = true;
0948:                                    break;
0949:                                }
0950:                            }
0951:                        }
0952:
0953:                        // -- Check if in Repository
0954:                        Repository repos = mMgtCtx.getRepository();
0955:                        Archive saArchive = repos.getArchive(
0956:                                ArchiveType.SERVICE_ASSEMBLY,
0957:                                serviceAssemblyName);
0958:                        isInRepository = saArchive != null;
0959:
0960:                        if (isInRegistry != isInRepository) {
0961:                            mRegObjLM.releaseReadLock();
0962:                            isReadLocked = false;
0963:                            mRegUtil.cleanEntity(ArchiveType.SERVICE_ASSEMBLY,
0964:                                    serviceAssemblyName, isInRegistry,
0965:                                    isInRepository);
0966:                        }
0967:                    } catch (Exception ex) {
0968:                        mLog.warning(ex.getMessage());
0969:                    }
0970:                    isRegistered = (isInRegistry && isInRepository);
0971:                } finally {
0972:                    if (isReadLocked) {
0973:                        mRegObjLM.releaseReadLock();
0974:                    }
0975:                }
0976:
0977:                return isRegistered;
0978:            }
0979:
0980:            /**
0981:             * @return a List of Service Assemblies registered in the domain.
0982:             */
0983:            public List<String> getRegisteredServiceAssemblies()
0984:                    throws RegistryException {
0985:                mRegObjLM.acquireReadLock();
0986:                List<String> saList = new ArrayList();
0987:                try {
0988:                    ServiceAssemblies sasType = mJbiRegistry
0989:                            .getServiceAssemblies();
0990:
0991:                    if (sasType != null) {
0992:                        List<DomainEntityType> sas = sasType
0993:                                .getServiceAssembly();
0994:
0995:                        for (DomainEntityType sa : sas) {
0996:                            saList.add(sa.getName());
0997:                        }
0998:                    }
0999:                } finally {
1000:                    mRegObjLM.releaseReadLock();
1001:                }
1002:                return saList;
1003:            }
1004:
1005:            /**
1006:             * @return a List of Shared Libraries registered in the domain.
1007:             */
1008:            public List<String> getRegisteredSharedLibraries()
1009:                    throws RegistryException {
1010:                mRegObjLM.acquireReadLock();
1011:                List<String> slList = new ArrayList();
1012:                try {
1013:                    SharedLibraries slsType = mJbiRegistry.getSharedLibraries();
1014:
1015:                    if (slsType != null) {
1016:                        List<DomainSharedLibraryType> sls = slsType
1017:                                .getSharedLibrary();
1018:
1019:                        for (DomainSharedLibraryType sl : sls) {
1020:                            slList.add(sl.getName());
1021:                        }
1022:                    }
1023:                } finally {
1024:                    mRegObjLM.releaseReadLock();
1025:                }
1026:                return slList;
1027:            }
1028:
1029:            /**
1030:             * @return a List of Components registered in the domain.
1031:             */
1032:            public List<String> getRegisteredComponents()
1033:                    throws RegistryException {
1034:                mRegObjLM.acquireReadLock();
1035:                List<String> compList = new ArrayList();
1036:                try {
1037:                    Components compTypes = mJbiRegistry.getComponents();
1038:                    if (compTypes != null) {
1039:                        List<DomainComponentType> comps = compTypes
1040:                                .getComponent();
1041:
1042:                        for (DomainComponentType comp : comps) {
1043:                            compList.add(comp.getName());
1044:                        }
1045:                    }
1046:                } finally {
1047:                    mRegObjLM.releaseReadLock();
1048:                }
1049:                return compList;
1050:            }
1051:
1052:            /**
1053:             * This method is used to find out if this is a system
1054:             * component.
1055:             * This method returns the value of system-install attribute
1056:             * for this component from the registry
1057:             * A component that has system-install set to true will have
1058:             * its install root under AS_INSTALL/jbi and it should not be
1059:             * deleted on unload of the component's uninstaller.
1060:             * @param componentName the name of the component
1061:             * @return boolean true if system-install is true, false otherwise
1062:             *
1063:             */
1064:            public boolean isSystemComponent(String componentName)
1065:                    throws RegistryException {
1066:                mRegObjLM.acquireReadLock();
1067:                boolean isSystemComponent = false;
1068:                try {
1069:                    Components compTypes = mJbiRegistry.getComponents();
1070:                    if (compTypes != null) {
1071:                        List<DomainComponentType> comps = compTypes
1072:                                .getComponent();
1073:                        for (DomainComponentType comp : comps) {
1074:                            if (comp.getName().equals(componentName)) {
1075:
1076:                                if (comp.isDefaultInstall() == true) {
1077:                                    isSystemComponent = true;
1078:                                }
1079:                                break;
1080:                            }
1081:                        }
1082:                    }
1083:                } finally {
1084:                    mRegObjLM.releaseReadLock();
1085:                }
1086:                return isSystemComponent;
1087:            }
1088:
1089:            /**
1090:             * This method is used to find out if this is a system
1091:             * shared library 
1092:             * This method returns the value of system-install attribute
1093:             * for this shared library from the registry
1094:             * A shared library that has system-install set to true will have
1095:             * its install root under AS_INSTALL/jbi and it should not be
1096:             * deleted on uninstall
1097:             * @param sharedLibraryName the name of the shared library
1098:             * @return boolean true if system-install is true, false otherwise
1099:             */
1100:            public boolean isSystemSharedLibrary(String sharedLibraryName)
1101:                    throws RegistryException {
1102:                mRegObjLM.acquireReadLock();
1103:                boolean isSystemSharedLibrary = false;
1104:                try {
1105:                    SharedLibraries sharedLibTypes = mJbiRegistry
1106:                            .getSharedLibraries();
1107:                    if (sharedLibTypes != null) {
1108:                        List<DomainSharedLibraryType> sharedLibs = sharedLibTypes
1109:                                .getSharedLibrary();
1110:                        for (DomainSharedLibraryType sharedLib : sharedLibs) {
1111:                            if (sharedLib.getName().equals(sharedLibraryName)) {
1112:
1113:                                if (sharedLib.isDefaultInstall() == true) {
1114:                                    isSystemSharedLibrary = true;
1115:                                }
1116:                                break;
1117:                            }
1118:
1119:                        }
1120:                    }
1121:                } finally {
1122:                    mRegObjLM.releaseReadLock();
1123:                }
1124:                return isSystemSharedLibrary;
1125:            }
1126:
1127:            public boolean doesComponentDeployServiceAssembly(
1128:                    ComponentRefType componentRef, String serviceAssemblyName)
1129:                    throws RegistryException {
1130:                mRegObjLM.acquireReadLock();
1131:                boolean deploys = false;
1132:
1133:                try {
1134:                    ServiceUnitListType suList = componentRef.getServiceUnits();
1135:
1136:                    if (suList != null) {
1137:                        List<ServiceUnitType> sus = suList.getServiceUnit();
1138:
1139:                        for (ServiceUnitType su : sus) {
1140:                            if (su.getServiceAssemblyRef().equals(
1141:                                    serviceAssemblyName)) {
1142:                                deploys = true;
1143:                            }
1144:                        }
1145:                    }
1146:                } finally {
1147:                    mRegObjLM.releaseReadLock();
1148:                }
1149:                return deploys;
1150:            }
1151:
1152:            /**
1153:             * Search for a domain Component with the specified componentName
1154:             *
1155:             * @return the Component with the specified name null if not found
1156:             */
1157:            public DomainComponentType getComponent(String componentName)
1158:                    throws RegistryException {
1159:                mRegObjLM.acquireReadLock();
1160:                DomainComponentType component = null;
1161:                try {
1162:                    if (mJbiRegistry.getComponents() != null) {
1163:                        List<DomainComponentType> comps = mJbiRegistry
1164:                                .getComponents().getComponent();
1165:
1166:                        for (DomainComponentType comp : comps) {
1167:                            if (comp.getName().equals(componentName)) {
1168:                                component = comp;
1169:                            }
1170:                        }
1171:                    }
1172:                } finally {
1173:                    mRegObjLM.releaseReadLock();
1174:                }
1175:                return component;
1176:            }
1177:
1178:            public ComponentRefType getComponent(String componentName,
1179:                    String targetName) throws RegistryException {
1180:                mRegObjLM.acquireReadLock();
1181:                ComponentRefType compRefType = null;
1182:                try {
1183:                    InstalledComponentsListType target = getInstalledEntities(targetName);
1184:
1185:                    if (target != null) {
1186:                        List<ComponentRefType> compRefs = target
1187:                                .getComponentRef();
1188:                        for (ComponentRefType compRef : compRefs) {
1189:                            if (compRef.getNameRef().equals(componentName)) {
1190:                                compRefType = compRef;
1191:                            }
1192:                        }
1193:
1194:                    }
1195:                } finally {
1196:                    mRegObjLM.releaseReadLock();
1197:                }
1198:                return compRefType;
1199:            }
1200:
1201:            /**
1202:             * Search for a domain Shared Library with the specified slName
1203:             *
1204:             * @return the SharedLibrary with the specified name null if not found
1205:             */
1206:            public DomainSharedLibraryType getSharedLibrary(String slName)
1207:                    throws RegistryException {
1208:                mRegObjLM.acquireReadLock();
1209:                DomainSharedLibraryType sharedLibrary = null;
1210:                try {
1211:                    if (mJbiRegistry.getSharedLibraries() != null) {
1212:                        List<DomainSharedLibraryType> sls = mJbiRegistry
1213:                                .getSharedLibraries().getSharedLibrary();
1214:
1215:                        for (DomainSharedLibraryType sl : sls) {
1216:                            if (sl.getName().equals(slName)) {
1217:                                sharedLibrary = sl;
1218:                            }
1219:                        }
1220:                    }
1221:                } finally {
1222:                    mRegObjLM.releaseReadLock();
1223:                }
1224:                return sharedLibrary;
1225:            }
1226:
1227:            public SharedLibraryRefType getSharedLibrary(String slName,
1228:                    String targetName) throws RegistryException {
1229:                mRegObjLM.acquireReadLock();
1230:                SharedLibraryRefType slRefType = null;
1231:                try {
1232:                    InstalledComponentsListType target = getInstalledEntities(targetName);
1233:
1234:                    if (target != null) {
1235:                        List<SharedLibraryRefType> slRefs = target
1236:                                .getSharedLibraryRef();
1237:                        for (SharedLibraryRefType slRef : slRefs) {
1238:                            if (slRef.getNameRef().equals(slName)) {
1239:                                slRefType = slRef;
1240:                            }
1241:                        }
1242:                    }
1243:                } finally {
1244:                    mRegObjLM.releaseReadLock();
1245:                }
1246:                return slRefType;
1247:            }
1248:
1249:            /**
1250:             * Search for a domain Service Assembly with the specified saName
1251:             *
1252:             * @return the SharedLibrary with the specified name null if not found
1253:             */
1254:            public DomainEntityType getServiceAssembly(String saName)
1255:                    throws RegistryException {
1256:                mRegObjLM.acquireReadLock();
1257:                DomainEntityType serviceAssembly = null;
1258:                try {
1259:                    if (mJbiRegistry.getServiceAssemblies() != null) {
1260:                        List<DomainEntityType> sas = mJbiRegistry
1261:                                .getServiceAssemblies().getServiceAssembly();
1262:
1263:                        for (DomainEntityType sa : sas) {
1264:                            if (sa.getName().equals(saName)) {
1265:                                serviceAssembly = sa;
1266:                            }
1267:                        }
1268:                    }
1269:                } finally {
1270:                    mRegObjLM.releaseReadLock();
1271:                }
1272:                return serviceAssembly;
1273:            }
1274:
1275:            /**
1276:             * Get the ServiceAssemblyRef for a service assembly.
1277:             *
1278:             * @param saName - service assembly name
1279:             * @param targetName - server/cluster name
1280:             * @throws RegistryException on errors
1281:             */
1282:            public ServiceAssemblyRefType getServiceAssembly(String saName,
1283:                    String targetName) throws RegistryException {
1284:                mRegObjLM.acquireReadLock();
1285:                ServiceAssemblyRefType saRefType = null;
1286:                try {
1287:                    InstalledComponentsListType target = getInstalledEntities(targetName);
1288:
1289:                    if (target != null) {
1290:                        List<ServiceAssemblyRefType> saRefs = target
1291:                                .getServiceAssemblyRef();
1292:                        for (ServiceAssemblyRefType saRef : saRefs) {
1293:                            if (saRef.getNameRef().equals(saName)) {
1294:                                saRefType = saRef;
1295:                            }
1296:                        }
1297:                    }
1298:                } finally {
1299:                    mRegObjLM.releaseReadLock();
1300:                }
1301:                return saRefType;
1302:            }
1303:
1304:            /**
1305:             * Get the file name for the domain component.
1306:             *
1307:             * @param componentName - component name
1308:             */
1309:            public String getComponentFileName(String componentName)
1310:                    throws RegistryException {
1311:                mRegObjLM.acquireReadLock();
1312:                String fname = null;
1313:                try {
1314:                    DomainEntityType comp = getComponent(componentName);
1315:
1316:                    if (comp != null) {
1317:                        fname = comp.getFileName();
1318:                    }
1319:                } finally {
1320:                    mRegObjLM.releaseReadLock();
1321:                }
1322:                return fname;
1323:            }
1324:
1325:            /**
1326:             * Get the file name for the domain shared library.
1327:             *
1328:             * @param slName - shared library  name
1329:             */
1330:            public String getSharedLibraryFileName(String slName)
1331:                    throws RegistryException {
1332:                mRegObjLM.acquireReadLock();
1333:                String fname = null;
1334:                try {
1335:                    DomainEntityType sl = getSharedLibrary(slName);
1336:
1337:                    if (sl != null) {
1338:                        fname = sl.getFileName();
1339:                    }
1340:                } finally {
1341:                    mRegObjLM.releaseReadLock();
1342:                }
1343:                return fname;
1344:            }
1345:
1346:            /**
1347:             * Get the file name for the domain service assembly.
1348:             *
1349:             * @param saName - service assembly name
1350:             */
1351:            public String getServiceAssemblyFileName(String saName)
1352:                    throws RegistryException {
1353:                mRegObjLM.acquireReadLock();
1354:                String fname = null;
1355:                try {
1356:                    DomainEntityType sa = getServiceAssembly(saName);
1357:
1358:                    if (sa != null) {
1359:                        fname = sa.getFileName();
1360:                    }
1361:                } finally {
1362:                    mRegObjLM.releaseReadLock();
1363:                }
1364:                return fname;
1365:            }
1366:
1367:            /**
1368:             * Get the timestamp for the domain component.
1369:             *
1370:             * @param componentName - component name
1371:             */
1372:            public long getComponentTimestamp(String componentName)
1373:                    throws RegistryException {
1374:                mRegObjLM.acquireReadLock();
1375:                long timestamp = 0;
1376:                try {
1377:                    DomainEntityType comp = getComponent(componentName);
1378:
1379:                    if (comp != null) {
1380:                        timestamp = comp.getTimestamp().longValue();
1381:                    }
1382:                } finally {
1383:                    mRegObjLM.releaseReadLock();
1384:                }
1385:                return timestamp;
1386:            }
1387:
1388:            /**
1389:             * Get the file name for the domain shared library.
1390:             *
1391:             * @param slName - shared library  name
1392:             */
1393:            public long getSharedLibraryTimestamp(String slName)
1394:                    throws RegistryException {
1395:                mRegObjLM.acquireReadLock();
1396:                long timestamp = 0;
1397:                try {
1398:                    DomainEntityType sl = getSharedLibrary(slName);
1399:
1400:                    if (sl != null) {
1401:                        timestamp = sl.getTimestamp().longValue();
1402:                    }
1403:                } finally {
1404:                    mRegObjLM.releaseReadLock();
1405:                }
1406:                return timestamp;
1407:            }
1408:
1409:            /**
1410:             * Get the file name for the domain service assembly.
1411:             *
1412:             * @param saName - service assembly name
1413:             */
1414:            public long getServiceAssemblyTimestamp(String saName)
1415:                    throws RegistryException {
1416:                mRegObjLM.acquireReadLock();
1417:                long timestamp = 0;
1418:                try {
1419:                    DomainEntityType sa = getServiceAssembly(saName);
1420:
1421:                    if (sa != null) {
1422:                        timestamp = sa.getTimestamp().longValue();
1423:                    }
1424:                } finally {
1425:                    mRegObjLM.releaseReadLock();
1426:                }
1427:                return timestamp;
1428:            }
1429:
1430:            /**
1431:             *
1432:             */
1433:            public InstalledComponentsListType getInstalledEntities(
1434:                    String targetName) throws RegistryException {
1435:                mRegObjLM.acquireReadLock();
1436:                InstalledComponentsListType target = null;
1437:                try {
1438:                    if (isTargetServer(targetName)) {
1439:                        List<InstalledComponentsListType> servers = mJbiRegistry
1440:                                .getServers().getServer();
1441:
1442:                        for (InstalledComponentsListType server : servers) {
1443:                            if (server.getNameRef().equals(targetName)) {
1444:                                target = server;
1445:                            }
1446:                        }
1447:                    } else if (isTargetCluster(targetName)) {
1448:                        List<InstalledComponentsListType> clusters = mJbiRegistry
1449:                                .getClusters().getCluster();
1450:
1451:                        for (InstalledComponentsListType cluster : clusters) {
1452:                            if (cluster.getNameRef().equals(targetName)) {
1453:                                target = cluster;
1454:                            }
1455:                        }
1456:                    }
1457:                } finally {
1458:                    mRegObjLM.releaseReadLock();
1459:                }
1460:                return target;
1461:            }
1462:
1463:            /**
1464:             * This method is used to get the value of the attribute upgrade-number from the 
1465:             * domain level entry for the component in the registry
1466:             * @param componentName the componentName
1467:             * @return BigInteger the upgrade number
1468:             * @throws RegistryException if the upgrade number could not be retrieved
1469:             */
1470:            public java.math.BigInteger getComponentUpgradeNumber(
1471:                    String componentName) throws RegistryException {
1472:                mRegObjLM.acquireReadLock();
1473:                java.math.BigInteger upgradeNumber = null;
1474:
1475:                try {
1476:                    Components compTypes = mJbiRegistry.getComponents();
1477:                    if (compTypes != null) {
1478:                        List<DomainComponentType> comps = compTypes
1479:                                .getComponent();
1480:                        for (DomainComponentType comp : comps) {
1481:                            if (comp.getName().equals(componentName)) {
1482:                                upgradeNumber = comp.getUpgradeNumber();
1483:                                break;
1484:                            }
1485:                        }
1486:                    }
1487:                } finally {
1488:                    mRegObjLM.releaseReadLock();
1489:                }
1490:                return upgradeNumber;
1491:            }
1492:
1493:            /*--------------------------------------------------------------------------------*\
1494:             *                       Get configuration attribute values                       *
1495:            \*--------------------------------------------------------------------------------*/
1496:
1497:            /**
1498:             * Get the value of a configuration attribute belonging to the
1499:             * specified category, for the runtime target. 
1500:             *
1501:             * @param type - configuration category 
1502:             * @param name - identification for the attribute
1503:             * @exception RegistryException on errors in getting the attribute value
1504:             * @return the String representation of the attributes value
1505:             */
1506:            public String getAttribute(ConfigurationCategory type, String name)
1507:                    throws RegistryException {
1508:                String target = mMgtCtx.getEnvironmentContext()
1509:                        .getPlatformContext().getTargetName();
1510:                return getAttribute(target, type, name);
1511:            }
1512:
1513:            /**
1514:             * Get the value of a configuration attribute belonging to the
1515:             * specified category, for the specified target. 
1516:             *
1517:             * @param targetName - target instance/cluster name.
1518:             * @param type - configuration category 
1519:             * @param name - identification for the attribute
1520:             * @exception RegistryException on errors in getting the attribute value
1521:             * @return the String representation of the attributes value
1522:             */
1523:            public String getAttribute(String targetName,
1524:                    ConfigurationCategory type, String name)
1525:                    throws RegistryException {
1526:                mRegObjLM.acquireReadLock();
1527:                String value = null;
1528:                try {
1529:                    Map<String, String> attribs = null;
1530:                    if (isAttributeOverriden(targetName, type, name)) {
1531:                        attribs = getConfigurationAttributes(targetName, type);
1532:                    } else {
1533:                        attribs = getConfigurationAttributes("domain", type);
1534:                    }
1535:
1536:                    value = attribs.get(name);
1537:                } finally {
1538:                    mRegObjLM.releaseReadLock();
1539:                }
1540:                return value;
1541:            }
1542:
1543:            /**
1544:             * Determine if the domain configuration is present in the registry
1545:             *
1546:             * @return true if the domain-config is defined in the registry
1547:             */
1548:            public boolean isGlobalConfigurationDefined() {
1549:                return (getConfig("domain") != null);
1550:            }
1551:
1552:            /**
1553:             * @return the configuration name based on the target name
1554:             */
1555:            public String getConfigName(String targetName) {
1556:                StringBuffer configName = new StringBuffer(targetName);
1557:                configName.append(Registry.CONFIG_SUFFIX);
1558:                return configName.toString();
1559:            }
1560:
1561:            /** 
1562:             * Determine if a configuration attribute is overriden by a target.
1563:             *
1564:             * @param targetName - target instance/cluster name.
1565:             * @param type - configuration category 
1566:             * @param name - identification for the attribute
1567:             * @return true if the attribute is overriden by a target
1568:             */
1569:            public boolean isAttributeOverriden(String targetName,
1570:                    ConfigurationCategory type, String name) {
1571:                boolean isOverrriden = false;
1572:
1573:                ConfigCategoryType configType = getConfigCategory(targetName,
1574:                        type);
1575:
1576:                if (configType != null) {
1577:                    Map propertyMap = getPropertyMap(configType.getProperty());
1578:                    isOverrriden = (propertyMap.get(name.trim()) != null);
1579:                }
1580:                return isOverrriden;
1581:            }
1582:
1583:            /**
1584:             * @param propertyList a list of PropertyType elements
1585:             * @return the properties in a category in  map keyed by the property name.
1586:             */
1587:            public Map getPropertyMap(List<PropertyType> propertyList) {
1588:                HashMap<String, String> propertyMap = new HashMap();
1589:                for (PropertyType property : propertyList) {
1590:                    propertyMap.put(property.getName().trim(), property
1591:                            .getValue().trim());
1592:                }
1593:                return propertyMap;
1594:            }
1595:
1596:            /** 
1597:             * Get a particular configuration category in a target configuration.
1598:             *
1599:             * @param targetName - target instance/cluster name.
1600:             * @param type - configuration category 
1601:             * @return the Configuration Category handle if found or null otherwise
1602:             */
1603:            public ConfigCategoryType getConfigCategory(String targetName,
1604:                    ConfigurationCategory type) {
1605:                ConfigCategoryType cfgType = null;
1606:
1607:                ConfigType config = getConfig(targetName);
1608:                if (config != null) {
1609:                    List<ConfigCategoryType> configTypes = config
1610:                            .getConfigType();
1611:
1612:                    for (ConfigCategoryType configType : configTypes) {
1613:                        ConfigurationCategory category = ConfigurationCategory
1614:                                .valueOf(configType.getCategory().value());
1615:                        if (category == type) {
1616:                            cfgType = configType;
1617:                        }
1618:                    }
1619:                }
1620:                return cfgType;
1621:            }
1622:
1623:            /** 
1624:             * Get a particular configuration for a target.
1625:             *
1626:             * @param targetName - target instance/cluster name.
1627:             * @return the Configuration for the target if found or null otherwise
1628:             */
1629:            public ConfigType getConfig(String targetName) {
1630:                ConfigType cfg = null;
1631:                String configName = getConfigName(targetName);
1632:
1633:                Configs cfgs = mJbiRegistry.getConfigs();
1634:                if (cfgs != null) {
1635:                    List<ConfigType> configs = cfgs.getConfig();
1636:                    for (ConfigType config : configs) {
1637:                        if (config.getName().equals(configName)) {
1638:                            cfg = config;
1639:                        }
1640:                    }
1641:                }
1642:                return cfg;
1643:            }
1644:
1645:            /**
1646:             * @return a Map containing all the configuration attributes for a given category
1647:             *         in a given target
1648:             */
1649:            private Map<String, String> getConfigurationAttributes(
1650:                    String targetName, ConfigurationCategory type) {
1651:                Map<String, String> attributes;
1652:                ConfigCategoryType category = getConfigCategory(targetName,
1653:                        type);
1654:
1655:                if (category != null) {
1656:                    attributes = getPropertyMap(category.getProperty());
1657:                } else {
1658:                    attributes = new HashMap();
1659:                }
1660:                return attributes;
1661:            }
1662:
1663:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.