Source Code Cross Referenced for POA.java in  » Collaboration » JacORB » org » jacorb » poa » 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 » Collaboration » JacORB » org.jacorb.poa 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package org.jacorb.poa;
0002:
0003:        /*
0004:         *        JacORB - a free Java ORB
0005:         *
0006:         *   Copyright (C) 1997-2004 Gerald Brose.
0007:         *
0008:         *   This library is free software; you can redistribute it and/or
0009:         *   modify it under the terms of the GNU Library General Public
0010:         *   License as published by the Free Software Foundation; either
0011:         *   version 2 of the License, or (at your option) any later version.
0012:         *
0013:         *   This library is distributed in the hope that it will be useful,
0014:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0015:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016:         *   Library General Public License for more details.
0017:         *
0018:         *   You should have received a copy of the GNU Library General Public
0019:         *   License along with this library; if not, write to the Free
0020:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0021:         */
0022:
0023:        import org.jacorb.poa.util.*;
0024:        import org.jacorb.poa.except.*;
0025:
0026:        import org.jacorb.orb.dsi.ServerRequest;
0027:        import org.jacorb.ssl.SSLPolicy;
0028:        import org.jacorb.ssl.SSLPolicyValue;
0029:        import org.jacorb.ssl.SSL_POLICY_TYPE;
0030:        import org.jacorb.util.ObjectUtil;
0031:
0032:        import org.omg.PortableServer.*;
0033:        import org.omg.PortableServer.POAPackage.*;
0034:        import org.omg.PortableServer.POAManagerPackage.State;
0035:
0036:        import org.omg.BiDirPolicy.*;
0037:
0038:        import org.apache.avalon.framework.logger.Logger;
0039:        import org.apache.avalon.framework.configuration.*;
0040:
0041:        import java.util.*;
0042:
0043:        /**
0044:         * The main POA class, an implementation of
0045:         * <code>org.omg.PortableServer.POA</code>
0046:         *
0047:         * @author Reimo Tiedemann, FU Berlin
0048:         * @version $Id: POA.java,v 1.65 2006/07/13 08:46:37 nick.cross Exp $
0049:         */
0050:
0051:        public class POA extends _POALocalBase implements  Configurable {
0052:            // my orb instance
0053:            private final org.jacorb.orb.ORB orb;
0054:
0055:            /** the configuration object for this POA instance */
0056:            private org.jacorb.config.Configuration configuration = null;
0057:
0058:            /** the POA logger instance */
0059:            private Logger logger = null;
0060:            private byte[] implName = null;
0061:
0062:            /** used to hold the POA name for logging */
0063:            private final String logPrefix;
0064:
0065:            // for listening POA Events
0066:            private POAListener poaListener;
0067:            // for monitoring
0068:            private POAMonitor monitor;
0069:
0070:            private final POAManager poaManager;
0071:            private final POA parent;
0072:            private final String name;
0073:            private String qualifiedName;
0074:
0075:            // name -> child POA's
0076:            private final Hashtable childs = new Hashtable();
0077:
0078:            Servant defaultServant;
0079:            ServantManager servantManager;
0080:            private AdapterActivator adapterActivator;
0081:
0082:            private AOM aom;
0083:            // thread for handle Requests
0084:            private RequestController requestController;
0085:
0086:            // poa identity and a counter for oid generation
0087:            private byte[] poaId;
0088:            private byte[] watermark;
0089:            private long objectIdCount;
0090:
0091:            /* policies */
0092:
0093:            // default: ORB_CTRL_MODEL
0094:            protected ThreadPolicy threadPolicy;
0095:
0096:            // default: TRANSIENT
0097:            protected LifespanPolicy lifespanPolicy;
0098:
0099:            // default: UNIQUE_ID
0100:            protected IdUniquenessPolicy idUniquenessPolicy;
0101:
0102:            // default: SYSTEM_ID
0103:            protected IdAssignmentPolicy idAssignmentPolicy;
0104:
0105:            // default: RETAIN
0106:            protected ServantRetentionPolicy servantRetentionPolicy;
0107:
0108:            // default: USE_ACTIVE_OBJECT_MAP_ONLY
0109:            protected RequestProcessingPolicy requestProcessingPolicy;
0110:
0111:            // default: NO_IMPLICIT_ACTIVATION
0112:            protected ImplicitActivationPolicy implicitActivationPolicy;
0113:
0114:            // default: NORMAL
0115:            protected BidirectionalPolicy bidirectionalPolicy;
0116:
0117:            // default: SSL_NOT_REQUIRED
0118:            protected SSLPolicy sslPolicy;
0119:
0120:            private final Hashtable all_policies;
0121:
0122:            /** key: , value: CORBA.Object */
0123:            private final Hashtable createdReferences;
0124:
0125:            // stores the etherealize_objects value from the first call of destroy
0126:            private boolean etherealize;
0127:
0128:            // synchronisation stuff
0129:            private int shutdownState = POAConstants.NOT_CALLED;
0130:            private final java.lang.Object poaCreationLog = new java.lang.Object();
0131:            private final java.lang.Object poaDestructionLog = new java.lang.Object();
0132:            private final java.lang.Object unknownAdapterLog = new java.lang.Object();
0133:            private boolean unknownAdapterCalled;
0134:
0135:            private boolean configured = false;
0136:
0137:            private POA(org.jacorb.orb.ORB _orb, String _name, POA _parent,
0138:                    POAManager _poaManager, org.omg.CORBA.Policy[] policies) {
0139:                super ();
0140:
0141:                orb = _orb;
0142:                name = _name;
0143:                parent = _parent;
0144:                poaManager = _poaManager;
0145:                logPrefix = "POA " + name;
0146:
0147:                all_policies = new Hashtable();
0148:                createdReferences = new Hashtable();
0149:
0150:                if (policies != null) {
0151:                    for (int i = 0; i < policies.length; i++) {
0152:                        all_policies.put(ObjectUtil.newInteger(policies[i]
0153:                                .policy_type()), policies[i]);
0154:
0155:                        switch (policies[i].policy_type()) {
0156:                        case THREAD_POLICY_ID.value:
0157:                            threadPolicy = (org.omg.PortableServer.ThreadPolicy) policies[i];
0158:                            break;
0159:                        case LIFESPAN_POLICY_ID.value:
0160:                            lifespanPolicy = (org.omg.PortableServer.LifespanPolicy) policies[i];
0161:                            break;
0162:                        case ID_UNIQUENESS_POLICY_ID.value:
0163:                            idUniquenessPolicy = (org.omg.PortableServer.IdUniquenessPolicy) policies[i];
0164:                            break;
0165:                        case ID_ASSIGNMENT_POLICY_ID.value:
0166:                            idAssignmentPolicy = (org.omg.PortableServer.IdAssignmentPolicy) policies[i];
0167:                            break;
0168:                        case SERVANT_RETENTION_POLICY_ID.value:
0169:                            servantRetentionPolicy = (org.omg.PortableServer.ServantRetentionPolicy) policies[i];
0170:                            break;
0171:                        case REQUEST_PROCESSING_POLICY_ID.value:
0172:                            requestProcessingPolicy = (org.omg.PortableServer.RequestProcessingPolicy) policies[i];
0173:                            break;
0174:                        case IMPLICIT_ACTIVATION_POLICY_ID.value:
0175:                            implicitActivationPolicy = (org.omg.PortableServer.ImplicitActivationPolicy) policies[i];
0176:                            break;
0177:                        case BIDIRECTIONAL_POLICY_TYPE.value:
0178:                            bidirectionalPolicy = (org.omg.BiDirPolicy.BidirectionalPolicy) policies[i];
0179:                            break;
0180:                        case SSL_POLICY_TYPE.value:
0181:                            sslPolicy = (SSLPolicy) policies[i];
0182:                            break;
0183:                        }
0184:                    }
0185:                }
0186:
0187:                //check if BiDir policy tell us to use BiDirGIOP (for the
0188:                //whole ORB)
0189:                if (bidirectionalPolicy != null) {
0190:                    org.jacorb.orb.giop.BiDirPolicy bdp = (org.jacorb.orb.giop.BiDirPolicy) bidirectionalPolicy;
0191:
0192:                    if (bdp.useBiDirGIOP()) {
0193:                        _orb.turnOnBiDirGIOP();
0194:                    }
0195:                }
0196:            }
0197:
0198:            public void configure(Configuration myConfiguration)
0199:                    throws ConfigurationException {
0200:                this .configuration = (org.jacorb.config.Configuration) myConfiguration;
0201:                logger = configuration.getNamedLogger("jacorb.poa");
0202:
0203:                String tmp = configuration.getAttribute("jacorb.implname", "");
0204:
0205:                if (tmp.length() > 0) {
0206:                    implName = tmp.getBytes();
0207:                }
0208:
0209:                watermark = generateWatermark();
0210:
0211:                aom = isRetain() ? new AOM(isUniqueId(), logger) : null;
0212:
0213:                // GB: modified
0214:                requestController = new RequestController(this , orb, aom, orb
0215:                        .newRPPoolManager(isSingleThreadModel()));
0216:                requestController.configure(configuration);
0217:
0218:                poaManager.registerPOA(this );
0219:                monitor = new POAMonitorLightImpl();
0220:                monitor.init(this , aom, requestController.getRequestQueue(),
0221:                        requestController.getPoolManager(), "POA " + name);
0222:
0223:                monitor.openMonitor();
0224:                if (poaListener != null) {
0225:                    poaListener.poaCreated(this );
0226:                }
0227:
0228:                monitor.configure(configuration);
0229:
0230:                if (logger.isDebugEnabled()) {
0231:                    logger.debug("POA " + name + " ready");
0232:                }
0233:                configured = true;
0234:            }
0235:
0236:            /**
0237:             * Everybody who is interested in poa events can use this method
0238:             * to register an event listener. The poa will pass the register calls
0239:             * to the right components
0240:             */
0241:
0242:            public void _addPOAEventListener(EventListener listener) {
0243:                checkIsConfigured();
0244:
0245:                if (listener instanceof  POAListener) {
0246:                    addPOAListener((POAListener) listener);
0247:                }
0248:
0249:                if (listener instanceof  AOMListener && aom != null) {
0250:                    aom.addAOMListener((AOMListener) listener);
0251:                }
0252:
0253:                if (listener instanceof  RequestQueueListener) {
0254:                    requestController.getRequestQueue()
0255:                            .addRequestQueueListener(
0256:                                    (RequestQueueListener) listener);
0257:                }
0258:
0259:                if (listener instanceof  RPPoolManagerListener) {
0260:                    requestController.getPoolManager()
0261:                            .addRPPoolManagerListener(
0262:                                    (RPPoolManagerListener) listener);
0263:                }
0264:            }
0265:
0266:            /**
0267:             * Called from Delegate. To ensure thread safety we use the AOM::incarnate method
0268:             * when activating a servant with the ServantActivator.
0269:             */
0270:            public Servant _incarnateServant(byte[] oid, ServantActivator sa)
0271:                    throws org.omg.PortableServer.ForwardRequest {
0272:                return aom.incarnate(oid, sa, this );
0273:            }
0274:
0275:            /**
0276:             * called from orb, returns a registered child poa,
0277:             * if no child poa exists a adapter activator will used
0278:             * to create a new poa unter this name
0279:             */
0280:
0281:            public org.jacorb.poa.POA _getChildPOA(String adapter_name)
0282:                    throws ParentIsHolding {
0283:                checkIsConfigured();
0284:
0285:                checkDestructionApparent();
0286:
0287:                POA child = (POA) childs.get(adapter_name);
0288:
0289:                if (child == null || child.isDestructionApparent()) {
0290:                    if (adapterActivator == null) {
0291:                        if (isHolding()) {
0292:                            throw new ParentIsHolding();
0293:                        }
0294:                        throw new org.omg.CORBA.OBJECT_NOT_EXIST(
0295:                                "no adapter activator exists for "
0296:                                        + adapter_name);
0297:                    }
0298:
0299:                    if (isDiscarding()) {
0300:                        throw new org.omg.CORBA.TRANSIENT(
0301:                                "a parent poa is in discarding state");
0302:                    }
0303:
0304:                    if (isInactive()) {
0305:                        throw new org.omg.CORBA.OBJ_ADAPTER(
0306:                                "a parent poa is in inactive state");
0307:                    }
0308:
0309:                    /* poa should be active */
0310:
0311:                    boolean successful = false;
0312:
0313:                    if (isSingleThreadModel()) {
0314:                        /* all invocations an adapter activator are serialized
0315:                           if the single thread model is in use */
0316:                        synchronized (unknownAdapterLog) {
0317:                            while (unknownAdapterCalled) {
0318:                                try {
0319:                                    unknownAdapterLog.wait();
0320:                                } catch (InterruptedException e) {
0321:                                }
0322:                            }
0323:                            unknownAdapterCalled = true;
0324:                            try {
0325:                                successful = the_activator().unknown_adapter(
0326:                                        this , POAUtil.unmaskStr(adapter_name));
0327:                            } finally {
0328:                                unknownAdapterCalled = false;
0329:                                unknownAdapterLog.notifyAll();
0330:                            }
0331:                        }
0332:                    } else {
0333:                        /* ORB_CTRL_MODEL */
0334:                        successful = the_activator().unknown_adapter(this ,
0335:                                POAUtil.unmaskStr(adapter_name));
0336:                    }
0337:
0338:                    /* unknown_adapter doesn't return until the
0339:                       poa is created and initialized */
0340:                    if (successful) {
0341:                        child = (POA) childs.get(adapter_name);
0342:                        if (child == null) {
0343:                            throw new POAInternalError(
0344:                                    "error: unknown_adapter returns true, but the child poa doesn't extist");
0345:                        }
0346:                    } else {
0347:                        throw new org.omg.CORBA.OBJECT_NOT_EXIST(
0348:                                "poa activation is failed");
0349:                    }
0350:                }
0351:                return child;
0352:            }
0353:
0354:            /**
0355:             * returns the complete poa name
0356:             */
0357:
0358:            public String _getQualifiedName() {
0359:                if (qualifiedName == null) {
0360:                    if (parent == null) {
0361:                        qualifiedName = "";
0362:                    } else if (parent.the_parent() == null) {
0363:                        qualifiedName = name;
0364:                    } else {
0365:                        qualifiedName = parent._getQualifiedName()
0366:                                + POAConstants.OBJECT_KEY_SEPARATOR + name;
0367:                    }
0368:                }
0369:                return qualifiedName;
0370:            }
0371:
0372:            /**
0373:             * called from orb for handing over a request
0374:             */
0375:
0376:            public void _invoke(ServerRequest request) throws WrongAdapter {
0377:                checkIsConfigured();
0378:
0379:                synchronized (poaDestructionLog) {
0380:                    checkDestructionApparent();
0381:
0382:                    // if the request is for this poa check whether the object
0383:                    // key is generated from him
0384:                    if (request.remainingPOAName() == null) {
0385:                        if (!previouslyGeneratedObjectKey(request.objectKey())) {
0386:                            if (logger.isWarnEnabled()) {
0387:                                logger
0388:                                        .warn(logPrefix
0389:                                                + " rid: "
0390:                                                + request.requestId()
0391:                                                + " opname: "
0392:                                                + request.operation()
0393:                                                + " _invoke: object key not previously generated!");
0394:                                if (logger.isDebugEnabled()) {
0395:                                    logger.debug(logPrefix
0396:                                            + " ObjectKey : "
0397:                                            + org.jacorb.orb.util.CorbaLoc
0398:                                                    .parseKey(request
0399:                                                            .objectKey())
0400:                                            + " to POA Id : "
0401:                                            + org.jacorb.orb.util.CorbaLoc
0402:                                                    .parseKey(getPOAId())
0403:                                            + " mismatch.");
0404:                                }
0405:                            }
0406:                            throw new WrongAdapter();
0407:                        }
0408:                        if (isSystemId()
0409:                                && !previouslyGeneratedObjectId(request
0410:                                        .objectId())) {
0411:                            if (logger.isWarnEnabled()) {
0412:                                logger
0413:                                        .warn(logPrefix
0414:                                                + " rid: "
0415:                                                + request.requestId()
0416:                                                + " opname: "
0417:                                                + request.operation()
0418:                                                + " _invoke: object id not previously generated!");
0419:                                if (logger.isDebugEnabled()) {
0420:                                    logger.debug(logPrefix
0421:                                            + " ObjectId : "
0422:                                            + org.jacorb.orb.util.CorbaLoc
0423:                                                    .parseKey(request
0424:                                                            .objectId())
0425:                                            + " to POA watermark : "
0426:                                            + org.jacorb.orb.util.CorbaLoc
0427:                                                    .parseKey(watermark)
0428:                                            + " mismatch.");
0429:                                }
0430:                            }
0431:                            throw new WrongAdapter();
0432:                        }
0433:                    }
0434:
0435:                    try {
0436:                        //  pass the  request  to the  request controller  the
0437:                        // operation returns  immediately after the request is
0438:                        // queued
0439:                        if (logger.isDebugEnabled()) {
0440:                            logger.debug(logPrefix + " rid: "
0441:                                    + request.requestId() + " opname: "
0442:                                    + request.operation()
0443:                                    + " _invoke: queuing request");
0444:                        }
0445:                        requestController.queueRequest(request);
0446:                    } catch (ResourceLimitReachedException e) {
0447:                        if (logger.isDebugEnabled()) {
0448:                            logger.debug("Caught " + e + " when queueing "
0449:                                    + request.operation());
0450:                        }
0451:                        throw new org.omg.CORBA.TRANSIENT(
0452:                                "resource limit reached");
0453:                    }
0454:                }
0455:            }
0456:
0457:            /**
0458:             * called from orb to obtain the RootPOA
0459:             */
0460:
0461:            static public POA _POA_init(org.jacorb.orb.ORB orb) {
0462:                POAManager poaMgr = new POAManager(orb);
0463:
0464:                /* the only policy value that differs from default */
0465:                org.omg.CORBA.Policy[] policies = null;
0466:
0467:                policies = new org.omg.CORBA.Policy[1];
0468:
0469:                policies[0] = new org.jacorb.poa.policy.ImplicitActivationPolicy(
0470:                        ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
0471:
0472:                POA rootPOA = new POA(orb, POAConstants.ROOT_POA_NAME, null,
0473:                        poaMgr, policies);
0474:
0475:                return rootPOA;
0476:            }
0477:
0478:            /**
0479:             * Unregister an event listener. The poa will pass the
0480:             * unregister calls to the right components
0481:             */
0482:
0483:            public void _removePOAEventListener(EventListener listener) {
0484:                if (listener instanceof  POAListener) {
0485:                    removePOAListener((POAListener) listener);
0486:                }
0487:                if (listener instanceof  AOMListener && aom != null) {
0488:                    aom.removeAOMListener((AOMListener) listener);
0489:                }
0490:                if (listener instanceof  RequestQueueListener) {
0491:                    requestController.getRequestQueue()
0492:                            .removeRequestQueueListener(
0493:                                    (RequestQueueListener) listener);
0494:                }
0495:                if (listener instanceof  RPPoolManagerListener) {
0496:                    requestController.getPoolManager()
0497:                            .removeRPPoolManagerListener(
0498:                                    (RPPoolManagerListener) listener);
0499:                }
0500:            }
0501:
0502:            public byte[] activate_object(Servant servant)
0503:                    throws ServantAlreadyActive, WrongPolicy {
0504:                checkIsConfigured();
0505:
0506:                checkDestructionApparent();
0507:
0508:                if (!isRetain() || !isSystemId()) {
0509:                    throw new WrongPolicy();
0510:                }
0511:
0512:                byte[] objectId = generateObjectId();
0513:
0514:                try {
0515:                    aom.add(objectId, servant);
0516:
0517:                    orb.set_delegate(servant);
0518:                } catch (ObjectAlreadyActive e) {
0519:                    throw new POAInternalError(
0520:                            "error: object already active (activate_object)");
0521:                }
0522:
0523:                return objectId;
0524:            }
0525:
0526:            public void activate_object_with_id(byte[] oid, Servant servant)
0527:                    throws ServantAlreadyActive, ObjectAlreadyActive,
0528:                    WrongPolicy {
0529:                checkIsConfigured();
0530:
0531:                checkDestructionApparent();
0532:
0533:                if (oid == null) {
0534:                    throw new org.omg.CORBA.BAD_PARAM(
0535:                            "Cannot activate_object_with_id with null ID.");
0536:                }
0537:
0538:                if (!isRetain()) {
0539:                    throw new WrongPolicy();
0540:                }
0541:
0542:                if (isSystemId() && !previouslyGeneratedObjectId(oid)) {
0543:                    if (logger.isWarnEnabled()) {
0544:                        logger
0545:                                .warn(logPrefix
0546:                                        + "oid: "
0547:                                        + POAUtil.convert(oid)
0548:                                        + " - activate_object_with_id: oid not previously generated!");
0549:                    }
0550:                    throw new org.omg.CORBA.BAD_PARAM();
0551:                }
0552:
0553:                aom.add(oid, servant);
0554:
0555:                orb.set_delegate(servant);
0556:            }
0557:
0558:            protected synchronized void addPOAListener(POAListener listener) {
0559:                poaListener = EventMulticaster.add(poaListener, listener);
0560:            }
0561:
0562:            protected void changeToActive() {
0563:                if (poaListener != null) {
0564:                    poaListener.poaStateChanged(this , POAConstants.ACTIVE);
0565:                }
0566:
0567:                monitor.changeState("changed to active...");
0568:
0569:                // notify everybody who is waiting for request completion
0570:                requestController.resetPreviousCompletionCall();
0571:                // continue the request dispatching
0572:                requestController.continueToWork();
0573:
0574:                monitor.changeState("active");
0575:            }
0576:
0577:            protected void changeToDiscarding() {
0578:
0579:                if (poaListener != null) {
0580:                    poaListener.poaStateChanged(this , POAConstants.DISCARDING);
0581:                }
0582:
0583:                monitor.changeState("changed to discarding ...");
0584:
0585:                // notify everybody who is waiting for request completion
0586:                requestController.resetPreviousCompletionCall();
0587:                // continue the request dispatching
0588:                requestController.continueToWork();
0589:                // wait for completion of all active requests
0590:                requestController.waitForCompletion();
0591:
0592:                monitor.changeState("discarding");
0593:            }
0594:
0595:            protected void changeToHolding() {
0596:                if (poaListener != null) {
0597:                    poaListener.poaStateChanged(this , POAConstants.HOLDING);
0598:                }
0599:                monitor.changeState("changed to holding ...");
0600:
0601:                // notify everybody who is waiting for request completion
0602:                requestController.resetPreviousCompletionCall();
0603:                // wait for completion of all active requests
0604:                requestController.waitForCompletion();
0605:
0606:                monitor.changeState("holding");
0607:            }
0608:
0609:            protected void changeToInactive(boolean etherealize_objects) {
0610:                if (poaListener != null) {
0611:                    poaListener.poaStateChanged(this , POAConstants.INACTIVE);
0612:                }
0613:
0614:                monitor.changeState("changed to inactive ...");
0615:
0616:                // notify everybody who is waiting for request completion
0617:                requestController.resetPreviousCompletionCall();
0618:
0619:                // continue the request dispatching
0620:                requestController.continueToWork();
0621:
0622:                // wait for completion of all active requests
0623:                requestController.waitForCompletion();
0624:
0625:                /* etherialize all active objects */
0626:                if (etherealize && isRetain() && useServantManager()) {
0627:                    if (logger.isInfoEnabled()) {
0628:                        logger.info(logPrefix + "etherialize all servants ...");
0629:                    }
0630:
0631:                    aom
0632:                            .removeAll((ServantActivator) servantManager, this ,
0633:                                    true);
0634:
0635:                    if (logger.isInfoEnabled()) {
0636:                        logger.info(logPrefix + "etherialize all servants ...");
0637:                    }
0638:
0639:                    if (monitor != null) {
0640:                        monitor
0641:                                .changeState("inactive (etherialization completed)");
0642:                    }
0643:
0644:                } else {
0645:                    if (monitor != null) {
0646:                        monitor.changeState("inactive (no etherialization)");
0647:                    }
0648:                }
0649:            }
0650:
0651:            public IdAssignmentPolicy create_id_assignment_policy(
0652:                    IdAssignmentPolicyValue value) {
0653:                checkDestructionApparent();
0654:                return new org.jacorb.poa.policy.IdAssignmentPolicy(value);
0655:            }
0656:
0657:            public IdUniquenessPolicy create_id_uniqueness_policy(
0658:                    IdUniquenessPolicyValue value) {
0659:                checkDestructionApparent();
0660:                return new org.jacorb.poa.policy.IdUniquenessPolicy(value);
0661:            }
0662:
0663:            public ImplicitActivationPolicy create_implicit_activation_policy(
0664:                    ImplicitActivationPolicyValue value) {
0665:                checkDestructionApparent();
0666:                return new org.jacorb.poa.policy.ImplicitActivationPolicy(value);
0667:            }
0668:
0669:            public LifespanPolicy create_lifespan_policy(
0670:                    LifespanPolicyValue value) {
0671:                checkDestructionApparent();
0672:                return new org.jacorb.poa.policy.LifespanPolicy(value);
0673:            }
0674:
0675:            /**
0676:             * additionally raises an org.omg.CORBA.BAD_INV_ORDER exception if the poa
0677:             * goes shutdown and this method will called (not spec.)
0678:             */
0679:
0680:            public org.omg.PortableServer.POA create_POA(String adapter_name,
0681:                    org.omg.PortableServer.POAManager a_POAManager,
0682:                    org.omg.CORBA.Policy[] policies)
0683:                    throws AdapterAlreadyExists, InvalidPolicy {
0684:                checkIsConfigured();
0685:
0686:                checkDestructionApparent();
0687:
0688:                String poa_name = POAUtil.maskStr(adapter_name);
0689:
0690:                /* this implementation works only with a instance of org.jacorb.poa.POAManager */
0691:                if (a_POAManager != null
0692:                        && !(a_POAManager instanceof  org.jacorb.poa.POAManager)) {
0693:                    throw new ApplicationError(
0694:                            "error: the POAManager is incompatible with type \"jacorb.poa.POAManager\"!");
0695:                }
0696:
0697:                org.omg.CORBA.Policy[] policyList = null;
0698:                if (policies != null) {
0699:                    // check the policy list for inconstancies
0700:                    short index = verifyPolicyList(policies);
0701:
0702:                    if (index != -1) {
0703:                        if (logger.isDebugEnabled()) {
0704:                            logger.debug("Policy list invalid at index "
0705:                                    + index);
0706:                        }
0707:                        throw new InvalidPolicy(index);
0708:                    }
0709:
0710:                    // copy the policy list
0711:                    policyList = new org.omg.CORBA.Policy[policies.length];
0712:
0713:                    for (int i = 0; i < policies.length; i++) {
0714:                        policyList[i] = policies[i].copy();
0715:                    }
0716:                }
0717:
0718:                POA child;
0719:
0720:                synchronized (poaCreationLog) {
0721:                    child = (POA) childs.get(poa_name);
0722:                    if (child != null && !child.isDestructionApparent()) {
0723:                        throw new AdapterAlreadyExists();
0724:                    }
0725:                    // wait for completion of a concurrent destruction process
0726:                    if (child != null) {
0727:                        POA aChild;
0728:                        while ((aChild = (POA) childs.get(poa_name)) != null) {
0729:                            try {
0730:                                poaCreationLog.wait(); // notification is in unregisterChild
0731:                            } catch (InterruptedException e) {
0732:                            }
0733:
0734:                            // someone else has won the race
0735:                            if (child != aChild) {
0736:                                throw new AdapterAlreadyExists();
0737:                            }
0738:                        }
0739:                    }
0740:
0741:                    if (isShutdownInProgress()) {
0742:                        throw new org.omg.CORBA.BAD_INV_ORDER();
0743:                    }
0744:
0745:                    POAManager aPOAManager = a_POAManager == null ? new POAManager(
0746:                            orb)
0747:                            : (POAManager) a_POAManager;
0748:
0749:                    child = new POA(orb, poa_name, this , aPOAManager,
0750:                            policyList);
0751:
0752:                    try {
0753:                        child.configure(configuration);
0754:                    } catch (ConfigurationException e) {
0755:                        throw new org.omg.CORBA.INTERNAL(e.toString());
0756:                    }
0757:
0758:                    // notify a poa listener
0759:                    try {
0760:                        if (poaListener != null) {
0761:                            poaListener.poaCreated(child);
0762:                        }
0763:                    } catch (org.omg.CORBA.INTERNAL e) {
0764:                        aPOAManager.poaCreationFailed = true;
0765:                        throw e;
0766:                    }
0767:                    // register the child poa
0768:                    childs.put(poa_name, child);
0769:                }
0770:                return child;
0771:            }
0772:
0773:            /**
0774:             * The specified repository id, which may be a null string, will become the
0775:             * type_id of the generated object reference
0776:             */
0777:
0778:            public org.omg.CORBA.Object create_reference(String intf_rep_id)
0779:                    throws WrongPolicy {
0780:                checkIsConfigured();
0781:
0782:                checkDestructionApparent();
0783:
0784:                if (!isSystemId()) {
0785:                    throw new WrongPolicy();
0786:                }
0787:
0788:                return getReference(generateObjectId(), intf_rep_id, false);
0789:            }
0790:
0791:            /**
0792:             * The specified repository id, which may be a null string, will become the
0793:             * type_id of the generated object reference
0794:             */
0795:
0796:            public org.omg.CORBA.Object create_reference_with_id(byte[] oid,
0797:                    String intf_rep_id) throws WrongPolicy {
0798:                checkIsConfigured();
0799:
0800:                checkDestructionApparent();
0801:
0802:                if (isSystemId() && !previouslyGeneratedObjectId(oid)) {
0803:                    if (logger.isWarnEnabled()) {
0804:                        logger
0805:                                .warn(logPrefix
0806:                                        + "oid: "
0807:                                        + POAUtil.convert(oid)
0808:                                        + "create_reference_with_id : object key not previously generated!");
0809:                    }
0810:
0811:                    throw new org.omg.CORBA.BAD_PARAM();
0812:                }
0813:
0814:                return getReference(oid, intf_rep_id, false);
0815:            }
0816:
0817:            public RequestProcessingPolicy create_request_processing_policy(
0818:                    RequestProcessingPolicyValue value) {
0819:                checkDestructionApparent();
0820:                return new org.jacorb.poa.policy.RequestProcessingPolicy(value);
0821:            }
0822:
0823:            public ServantRetentionPolicy create_servant_retention_policy(
0824:                    ServantRetentionPolicyValue value) {
0825:                checkDestructionApparent();
0826:                return new org.jacorb.poa.policy.ServantRetentionPolicy(value);
0827:            }
0828:
0829:            public ThreadPolicy create_thread_policy(ThreadPolicyValue value) {
0830:                checkDestructionApparent();
0831:                return new org.jacorb.poa.policy.ThreadPolicy(value);
0832:            }
0833:
0834:            /**
0835:             * The operation does not wait for requests or etherealization to complete
0836:             * and always returns immediately (after deactivating the oid?)
0837:             */
0838:
0839:            public synchronized void deactivate_object(byte[] oid)
0840:                    throws ObjectNotActive, WrongPolicy {
0841:                checkIsConfigured();
0842:
0843:                if (!isRetain()) {
0844:                    throw new WrongPolicy();
0845:                }
0846:
0847:                aom.remove(oid, requestController,
0848:                        useServantManager() ? (ServantActivator) servantManager
0849:                                : null, this , false);
0850:
0851:                createdReferences.remove(new ByteArrayKey(oid));
0852:            }
0853:
0854:            public void destroy(boolean etherealize_objects,
0855:                    boolean wait_for_completion) {
0856:                checkIsConfigured();
0857:
0858:                if (wait_for_completion && isInInvocationContext()) {
0859:                    throw new org.omg.CORBA.BAD_INV_ORDER();
0860:                }
0861:
0862:                makeShutdownInProgress(etherealize_objects);
0863:
0864:                /* synchronized with creationLog */
0865:                /* child poa creations are impossible now */
0866:                // destroy all childs first
0867:                Enumeration en = childs.elements();
0868:                while (en.hasMoreElements()) {
0869:                    POA child = (POA) en.nextElement();
0870:                    child.destroy(etherealize, wait_for_completion);
0871:                }
0872:
0873:                Thread thread = new Thread() {
0874:                    public void run() {
0875:                        /* The apparent destruction of the POA
0876:                           occurs  only  after  all  executing
0877:                           requests in the POA have completed,
0878:                           but before any calls to etherealize
0879:                           are made. */
0880:                        requestController.waitForShutdown();
0881:                        /*  poa behaves  as  if he  is in  the
0882:                            holding state  now and blocks until
0883:                            all active request have comleted */
0884:                        makeDestructionApparent();
0885:                        /* unregister poa from the POAManager,
0886:                           any calls on the poa are impossible
0887:                           now especially  you cannot activate
0888:                           or  deactivate  objects  (raises  a
0889:                           OBJ_NOT_EXIST  exception),  but you
0890:                           have   a    race   condition   with
0891:                           currently       running      object
0892:                           (de)activation processes */
0893:                        makeDestructionComplete();
0894:                    }
0895:                };
0896:                thread.setName("POADestructor");
0897:                thread.start();
0898:                if (wait_for_completion) {
0899:                    try {
0900:                        thread.join();
0901:                    } catch (InterruptedException e) {
0902:                    }
0903:                }
0904:            }
0905:
0906:            private byte[] extractWatermark(byte[] id) {
0907:                if (id.length < watermark.length) {
0908:                    return new byte[0];
0909:                }
0910:
0911:                return IdUtil.extract(id, id.length - watermark.length,
0912:                        watermark.length);
0913:            }
0914:
0915:            /**
0916:             * If the intended child poa is not found and activate_it is TRUE,
0917:             * it is  possible for another thread to create  the same poa with
0918:             * create_POA at the same  time in a race condition.  Applications
0919:             *  should be  prepared  to  deal with  failures  from the  manual
0920:             *  (create_POA)  or automatic  (findPOA  or unknown_adapter  from
0921:             * AdapterActivator) POA  creation.  Another possible situation is
0922:             * that  the poa  returned goes shutdown  but the orb  will notice
0923:             * this situation if he will proceed with request processing.
0924:             */
0925:            public org.omg.PortableServer.POA find_POA(String adapter_name,
0926:                    boolean activate_it) throws AdapterNonExistent {
0927:                checkDestructionApparent();
0928:
0929:                String poa_name = POAUtil.maskStr(adapter_name);
0930:
0931:                POA child = (POA) childs.get(poa_name);
0932:
0933:                if (child == null || child.isDestructionApparent()) {
0934:
0935:                    boolean successful = false;
0936:
0937:                    if (activate_it && the_activator() != null) {
0938:                        /* all invocations an adapter activator are serialized
0939:                           if the single thread model is in use */
0940:                        if (isSingleThreadModel()) {
0941:                            synchronized (unknownAdapterLog) {
0942:                                while (unknownAdapterCalled) {
0943:                                    try {
0944:                                        unknownAdapterLog.wait();
0945:                                    } catch (InterruptedException e) {
0946:                                    }
0947:                                }
0948:                                unknownAdapterCalled = true;
0949:                                try {
0950:                                    successful = the_activator()
0951:                                            .unknown_adapter(this , adapter_name);
0952:                                } finally {
0953:                                    unknownAdapterCalled = false;
0954:                                    unknownAdapterLog.notifyAll();
0955:                                }
0956:                            }
0957:
0958:                        } else { /* ORB_CTRL_MODEL */
0959:                            successful = the_activator().unknown_adapter(this ,
0960:                                    adapter_name);
0961:                        }
0962:                    }
0963:
0964:                    /* unknown_adapter returns not until the poa is created and initialized */
0965:                    if (successful) {
0966:                        child = (POA) childs.get(poa_name);
0967:                        if (child == null) {
0968:                            throw new POAInternalError(
0969:                                    "error: unknown_adapter returns true, but the child poa does'n extist");
0970:                        }
0971:
0972:                    } else {
0973:                        throw new AdapterNonExistent();
0974:                    }
0975:                }
0976:                return child;
0977:            }
0978:
0979:            /**
0980:             * <code>generateObjectId</code> creates a new ObjectId for an object.
0981:             *
0982:             * @return a <code>byte[]</code> value.
0983:             */
0984:            private synchronized byte[] generateObjectId() {
0985:                if (isPersistent()) {
0986:                    return IdUtil.concat(IdUtil.createId(4), watermark);
0987:                }
0988:
0989:                // Synchonize as the increment is not an atomic operation.
0990:                return IdUtil.concat(IdUtil.toId(objectIdCount++), watermark);
0991:            }
0992:
0993:            private byte[] generateWatermark() {
0994:                if (watermark == null) {
0995:                    if (isPersistent()) {
0996:                        watermark = IdUtil.toId(new String(getPOAId())
0997:                                .hashCode());
0998:                    } else {
0999:                        watermark = IdUtil.createId(4);
1000:                    }
1001:                }
1002:                return watermark;
1003:            }
1004:
1005:            public Servant get_servant() throws NoServant, WrongPolicy {
1006:                checkIsConfigured();
1007:
1008:                checkDestructionApparent();
1009:
1010:                if (!isUseDefaultServant()) {
1011:                    throw new WrongPolicy();
1012:                }
1013:
1014:                if (defaultServant == null) {
1015:                    throw new NoServant();
1016:                }
1017:
1018:                return defaultServant;
1019:            }
1020:
1021:            public org.omg.PortableServer.ServantManager get_servant_manager()
1022:                    throws WrongPolicy {
1023:                checkIsConfigured();
1024:
1025:                checkDestructionApparent();
1026:
1027:                if (!isUseServantManager()) {
1028:                    throw new WrongPolicy();
1029:                }
1030:
1031:                return servantManager;
1032:            }
1033:
1034:            private void checkIsConfigured() {
1035:                if (!configured) {
1036:                    throw new IllegalStateException("POA: not configured!");
1037:                }
1038:            }
1039:
1040:            protected POAMonitor getMonitor() {
1041:                return monitor;
1042:            }
1043:
1044:            protected org.jacorb.orb.ORB getORB() {
1045:                return orb;
1046:            }
1047:
1048:            public byte[] getPOAId() {
1049:                if (poaId == null) {
1050:                    final byte[] impl_name = getImplName();
1051:
1052:                    int in_length = impl_name.length;
1053:
1054:                    byte[] poa_name = _getQualifiedName().getBytes();
1055:                    int pn_length = poa_name.length;
1056:
1057:                    int offset = 0;
1058:                    if (pn_length == 0) {
1059:                        poaId = new byte[in_length];
1060:                        System.arraycopy(impl_name, 0, poaId, 0, in_length);
1061:                    } else {
1062:                        poaId = new byte[in_length + pn_length + 1];
1063:                        System.arraycopy(impl_name, 0, poaId, 0, in_length);
1064:                        offset += in_length;
1065:                        poaId[offset] = POAConstants.OBJECT_KEY_SEP_BYTE;
1066:                        offset++;
1067:                        System.arraycopy(poa_name, 0, poaId, offset, pn_length);
1068:                    }
1069:                }
1070:                return poaId;
1071:            }
1072:
1073:            private byte[] getImplName() {
1074:                final byte[] impl;
1075:                // If we are using a transient object then we must place some random information
1076:                // in the IOR so that it is unique.
1077:                if ((!isPersistent()) || implName == null) {
1078:                    impl = orb.getServerId();
1079:
1080:                    if (logger.isInfoEnabled()) {
1081:                        if (isPersistent()) {
1082:                            logger.info("Impl name not set; using server ID: "
1083:                                    + (new String(impl)));
1084:                        } else {
1085:                            logger.info("Using server ID ("
1086:                                    + (new String(impl))
1087:                                    + ") for transient POA");
1088:                        }
1089:                    }
1090:                } else {
1091:                    impl = implName;
1092:                }
1093:                return POAUtil.maskId(impl);
1094:            }
1095:
1096:            protected org.omg.CORBA.Object getReference(byte[] oid,
1097:                    String intf_rep_id, boolean cache) {
1098:                byte[] object_id = POAUtil.maskId(oid);
1099:                int pid_length = getPOAId().length;
1100:                int oid_length = object_id.length;
1101:                byte[] object_key = new byte[pid_length + oid_length + 1];
1102:                int offset = 0;
1103:
1104:                System.arraycopy(getPOAId(), 0, object_key, offset, pid_length);
1105:                offset += pid_length;
1106:                object_key[offset] = POAConstants.OBJECT_KEY_SEP_BYTE;
1107:                offset++;
1108:                System.arraycopy(object_id, 0, object_key, offset, oid_length);
1109:
1110:                ByteArrayKey key = new ByteArrayKey(oid);
1111:
1112:                org.omg.CORBA.Object result = (org.omg.CORBA.Object) createdReferences
1113:                        .get(key);
1114:
1115:                if (result == null) {
1116:                    result = orb.getReference(this , object_key, intf_rep_id,
1117:                            !isPersistent());
1118:
1119:                    if (cache) {
1120:                        createdReferences.put(key, result);
1121:                    }
1122:
1123:                    if (poaListener != null) {
1124:                        poaListener.referenceCreated(result);
1125:                    }
1126:                }
1127:
1128:                return result;
1129:            }
1130:
1131:            protected RequestController getRequestController() {
1132:                return requestController;
1133:            }
1134:
1135:            protected State getState() {
1136:                return poaManager.get_state();
1137:            }
1138:
1139:            public org.omg.CORBA.Object id_to_reference(byte[] oid)
1140:                    throws ObjectNotActive, WrongPolicy {
1141:                checkDestructionApparent();
1142:
1143:                if (!isRetain()) {
1144:                    throw new WrongPolicy();
1145:                }
1146:
1147:                final Servant servant = aom.getServant(oid);
1148:                // objectId is not active
1149:                if (servant == null) {
1150:                    throw new ObjectNotActive();
1151:                }
1152:
1153:                /* If the object with the specified ObjectId currently active,
1154:                   a reference encapsulating  the information used to activate
1155:                   the object is returned.  */
1156:                return getReference(oid, servant._all_interfaces(this , oid)[0],
1157:                        true);
1158:            }
1159:
1160:            public Servant id_to_servant(byte[] oid) throws ObjectNotActive,
1161:                    WrongPolicy {
1162:                checkDestructionApparent();
1163:
1164:                if (!isRetain() && !isUseDefaultServant()) {
1165:                    throw new WrongPolicy();
1166:                }
1167:
1168:                // servant is active
1169:                if (isRetain()) {
1170:                    final Servant servant = aom.getServant(oid);
1171:
1172:                    if (servant != null) {
1173:                        return servant;
1174:                    }
1175:                }
1176:
1177:                if (useDefaultServant()) {
1178:                    return defaultServant;
1179:                }
1180:
1181:                throw new ObjectNotActive();
1182:            }
1183:
1184:            protected boolean isActive() {
1185:                return poaManager.get_state().value() == org.omg.PortableServer.POAManagerPackage.State._ACTIVE ? true
1186:                        : false;
1187:            }
1188:
1189:            protected void checkDestructionApparent() {
1190:                if (isDestructionApparent()) {
1191:                    throw new org.omg.CORBA.OBJECT_NOT_EXIST("POA destroyed");
1192:                }
1193:            }
1194:
1195:            protected static void checkNotLocal(org.omg.CORBA.Object obj)
1196:                    throws WrongAdapter {
1197:                if (obj instanceof  org.omg.CORBA.LocalObject) {
1198:                    throw new WrongAdapter("Local object");
1199:                }
1200:            }
1201:
1202:            protected boolean isDestructionApparent() {
1203:                return shutdownState >= POAConstants.DESTRUCTION_APPARENT;
1204:            }
1205:
1206:            /**
1207:             * <code>isDestructionComplete</code> returns whether the POA has been
1208:             * completely destroyed (including finishing outstanding requests). This
1209:             * is public not protected as it is called from orb/Delegate.
1210:             *
1211:             * @return a <code>boolean</code> value.
1212:             */
1213:            public boolean isDestructionComplete() {
1214:                return shutdownState >= POAConstants.DESTRUCTION_COMPLETE;
1215:            }
1216:
1217:            protected boolean isDiscarding() {
1218:                return poaManager.get_state().value() == org.omg.PortableServer.POAManagerPackage.State._DISCARDING ? true
1219:                        : false;
1220:            }
1221:
1222:            protected boolean isHolding() {
1223:                return poaManager.get_state().value() == org.omg.PortableServer.POAManagerPackage.State._HOLDING ? true
1224:                        : false;
1225:            }
1226:
1227:            protected boolean isImplicitActivation() {
1228:                return implicitActivationPolicy != null
1229:                        && implicitActivationPolicy.value() == ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION;
1230:            }
1231:
1232:            protected boolean isInactive() {
1233:                return poaManager.get_state().value() == org.omg.PortableServer.POAManagerPackage.State._INACTIVE ? true
1234:                        : false;
1235:
1236:            }
1237:
1238:            /**
1239:             *  returns  true if  the  current thread  is  in  the context  of
1240:             * executing a request from some  POA belonging to the same ORB as
1241:             * this POA */
1242:
1243:            private boolean isInInvocationContext() {
1244:                try {
1245:                    if (orb.getPOACurrent().getORB() == orb) {
1246:                        return true;
1247:                    }
1248:                } catch (org.omg.PortableServer.CurrentPackage.NoContext e) {
1249:                }
1250:                return false;
1251:            }
1252:
1253:            /**
1254:             * returns true if the current thread is in the context of executing
1255:             * a request on the specified servant from this POA,
1256:             * if the specified servant is null, it returns true if the current
1257:             * thread is in an invocation context from this POA.
1258:             */
1259:
1260:            private boolean isInInvocationContext(Servant servant) {
1261:                try {
1262:                    if (orb.getPOACurrent().get_POA() == this 
1263:                            && (servant == null || orb.getPOACurrent()
1264:                                    .getServant() == servant)) {
1265:                        return true;
1266:                    }
1267:                } catch (org.omg.PortableServer.CurrentPackage.NoContext e) {
1268:                }
1269:                return false;
1270:            }
1271:
1272:            protected boolean isMultipleId() {
1273:                return idUniquenessPolicy != null
1274:                        && idUniquenessPolicy.value() == IdUniquenessPolicyValue.MULTIPLE_ID;
1275:            }
1276:
1277:            public boolean isPersistent() {
1278:                return lifespanPolicy != null
1279:                        && lifespanPolicy.value() == LifespanPolicyValue.PERSISTENT;
1280:            }
1281:
1282:            /**
1283:             * also called from Delegate
1284:             */
1285:
1286:            public boolean isRetain() {
1287:                return servantRetentionPolicy == null
1288:                        || servantRetentionPolicy.value() == ServantRetentionPolicyValue.RETAIN;
1289:            }
1290:
1291:            protected boolean isShutdownInProgress() {
1292:                return shutdownState >= POAConstants.SHUTDOWN_IN_PROGRESS;
1293:            }
1294:
1295:            protected boolean isSingleThreadModel() {
1296:                return threadPolicy != null
1297:                        && threadPolicy.value() == ThreadPolicyValue.SINGLE_THREAD_MODEL;
1298:            }
1299:
1300:            public boolean isSystemId() {
1301:                return idAssignmentPolicy == null
1302:                        || idAssignmentPolicy.value() == IdAssignmentPolicyValue.SYSTEM_ID;
1303:            }
1304:
1305:            protected boolean isUniqueId() {
1306:                return idUniquenessPolicy == null
1307:                        || idUniquenessPolicy.value() == IdUniquenessPolicyValue.UNIQUE_ID;
1308:            }
1309:
1310:            /**
1311:             */
1312:
1313:            protected boolean isUseDefaultServant() {
1314:                return requestProcessingPolicy != null
1315:                        && requestProcessingPolicy.value() == RequestProcessingPolicyValue.USE_DEFAULT_SERVANT;
1316:            }
1317:
1318:            public boolean isUseServantManager() {
1319:                return requestProcessingPolicy != null
1320:                        && requestProcessingPolicy.value() == RequestProcessingPolicyValue.USE_SERVANT_MANAGER;
1321:            }
1322:
1323:            public boolean isSSLRequired() {
1324:                return sslPolicy != null
1325:                        && sslPolicy.value() == SSLPolicyValue.SSL_REQUIRED;
1326:            }
1327:
1328:            /**
1329:             * Any calls on the  poa are impossible now, especially you cannot
1330:             *  activate   or  deactivate  objects   (raises  a  OBJ_NOT_EXIST
1331:             *  exception). The  poa  will unregistered  with the  POAManager.
1332:             *  After  destruction  has   become  apparent,  the  POA  may  be
1333:             *  re-created  via  either  the  AdapterActivator or  a  call  to
1334:             * create_POA
1335:             */
1336:
1337:            private void makeDestructionApparent() {
1338:                synchronized (poaDestructionLog) {
1339:                    if (shutdownState < POAConstants.DESTRUCTION_APPARENT) {
1340:                        /* do */
1341:                        poaManager.unregisterPOA(this );
1342:
1343:                        /* set */
1344:                        shutdownState = POAConstants.DESTRUCTION_APPARENT;
1345:
1346:                        /* announce */
1347:                        if (poaListener != null) {
1348:                            poaListener.poaStateChanged(this ,
1349:                                    POAConstants.DESTROYED);
1350:                        }
1351:
1352:                        if (logger.isDebugEnabled()) {
1353:                            logger.debug(logPrefix + "destruction is apparent");
1354:                        }
1355:
1356:                        monitor.changeState("destruction is apparent ...");
1357:                    }
1358:                }
1359:            }
1360:
1361:            /**
1362:             * After destruction has become complete, a poa creation process
1363:             * under the same poa name can continue now.
1364:             */
1365:
1366:            private void makeDestructionComplete() {
1367:                if (shutdownState < POAConstants.DESTRUCTION_COMPLETE) {
1368:                    /* do */
1369:                    /* clear up the queue */
1370:                    if (logger.isDebugEnabled()) {
1371:                        logger.debug(logPrefix + "clear up the queue ...");
1372:                    }
1373:
1374:                    requestController
1375:                            .clearUpQueue(new org.omg.CORBA.OBJECT_NOT_EXIST(
1376:                                    "adapter destroyed"));
1377:
1378:                    if (logger.isDebugEnabled()) {
1379:                        logger.debug(logPrefix + "... done");
1380:                    }
1381:
1382:                    /* etherialize all active objects */
1383:                    if (etherealize && isRetain() && useServantManager()) {
1384:                        if (logger.isDebugEnabled()) {
1385:                            logger.debug(logPrefix
1386:                                    + "etherialize all servants ...");
1387:                        }
1388:
1389:                        aom.removeAll((ServantActivator) servantManager, this ,
1390:                                true);
1391:
1392:                        if (logger.isDebugEnabled()) {
1393:                            logger.debug(logPrefix + "... done");
1394:                        }
1395:                    }
1396:
1397:                    if (logger.isDebugEnabled()) {
1398:                        logger.debug(logPrefix
1399:                                + "remove all processors from the pool ...");
1400:                    }
1401:                    requestController.clearUpPool();
1402:
1403:                    if (logger.isDebugEnabled()) {
1404:                        logger.debug(logPrefix + "... done");
1405:                    }
1406:
1407:                    /* stop the request controller */
1408:                    if (logger.isDebugEnabled()) {
1409:                        logger.debug(logPrefix
1410:                                + "stop the request controller ...");
1411:                    }
1412:
1413:                    requestController.end();
1414:
1415:                    if (logger.isDebugEnabled()) {
1416:                        logger.debug(logPrefix + "... done");
1417:                    }
1418:
1419:                    /* set */
1420:                    shutdownState = POAConstants.DESTRUCTION_COMPLETE;
1421:                    if (parent != null) {
1422:                        // I am not the RootPOA
1423:                        // unregister the poa with the parent and
1424:                        // notify a concurrent creation process
1425:                        parent.unregisterChild(name);
1426:                    }
1427:
1428:                    /* annouce */
1429:                    if (logger.isInfoEnabled()) {
1430:                        logger.info(logPrefix + " destroyed");
1431:                    }
1432:
1433:                    monitor.changeState("destroyed");
1434:
1435:                    /* clear tables */
1436:                    createdReferences.clear();
1437:                    all_policies.clear();
1438:                }
1439:            }
1440:
1441:            /**
1442:             * The etherealize_objects parameter  from the destroy method will
1443:             * saved in the  field etherealize because the etherealize_objects
1444:             * parameter  applies only the  first call of  destroy. Subsequent
1445:             * calls use  the field etherealize.  Any calls  to create_POA are
1446:             * impossible now (receives a BAD_INV_ORDER exception).
1447:             */
1448:
1449:            private void makeShutdownInProgress(boolean etherealize_objects) {
1450:                synchronized (poaCreationLog) {
1451:                    if (shutdownState < POAConstants.SHUTDOWN_IN_PROGRESS) {
1452:                        /* do */
1453:                        etherealize = etherealize_objects;
1454:
1455:                        /* set */
1456:                        shutdownState = POAConstants.SHUTDOWN_IN_PROGRESS;
1457:
1458:                        /* annouce */
1459:                        if (logger.isDebugEnabled()) {
1460:                            logger.debug(logPrefix + "shutdown is in progress");
1461:                        }
1462:
1463:                        monitor.changeState("shutdown is in progress ...");
1464:                    }
1465:                }
1466:            }
1467:
1468:            public boolean previouslyGeneratedObjectId(byte[] oid) {
1469:                return IdUtil.equals(watermark, extractWatermark(oid));
1470:            }
1471:
1472:            public boolean previouslyGeneratedObjectKey(byte[] object_key) {
1473:                return IdUtil.equals(object_key, getPOAId(), getPOAId().length);
1474:            }
1475:
1476:            public byte[] reference_to_id(org.omg.CORBA.Object reference)
1477:                    throws WrongAdapter, WrongPolicy {
1478:                checkDestructionApparent();
1479:                checkNotLocal(reference);
1480:
1481:                byte[] objectId = POAUtil.extractOID(reference);
1482:
1483:                /* not spec (isSystemId) */
1484:                if (isSystemId() && !previouslyGeneratedObjectId(objectId)) {
1485:                    if (logger.isWarnEnabled()) {
1486:                        logger
1487:                                .warn(logPrefix
1488:                                        + "oid: "
1489:                                        + POAUtil.convert(objectId)
1490:                                        + "reference_to_id: oid not previously generated!");
1491:                    }
1492:                    throw new WrongAdapter();
1493:                }
1494:
1495:                return objectId;
1496:            }
1497:
1498:            public Servant reference_to_servant(org.omg.CORBA.Object reference)
1499:                    throws ObjectNotActive, WrongAdapter, WrongPolicy {
1500:                checkDestructionApparent();
1501:                checkNotLocal(reference);
1502:
1503:                if (!isRetain() && !isUseDefaultServant()) {
1504:                    throw new WrongPolicy();
1505:                }
1506:
1507:                byte[] objectId = POAUtil.extractOID(reference);
1508:
1509:                /* not spec (isSystemId) */
1510:                if (isSystemId() && !previouslyGeneratedObjectId(objectId)) {
1511:                    if (logger.isWarnEnabled()) {
1512:                        logger
1513:                                .warn(logPrefix
1514:                                        + "oid: "
1515:                                        + POAUtil.convert(objectId)
1516:                                        + "reference_to_servant: oid not previously generated!");
1517:                    }
1518:                    throw new WrongAdapter();
1519:                }
1520:
1521:                ByteArrayKey oid = new ByteArrayKey(objectId);
1522:
1523:                if ((aom != null && aom.isDeactivating(oid))
1524:                        || requestController.isDeactivating(oid)) {
1525:                    if (logger.isWarnEnabled()) {
1526:                        logger
1527:                                .warn(logPrefix
1528:                                        + "oid: "
1529:                                        + POAUtil.convert(objectId)
1530:                                        + "cannot process request, because object is already in the deactivation process");
1531:                    }
1532:
1533:                    throw new org.omg.CORBA.OBJECT_NOT_EXIST();
1534:                }
1535:
1536:                Servant servant = null;
1537:
1538:                /* is active servant */
1539:                if (isRetain() && (servant = aom.getServant(objectId)) != null) {
1540:                    return servant;
1541:                } else if (useDefaultServant()) {
1542:                    return defaultServant;
1543:                }
1544:
1545:                throw new ObjectNotActive();
1546:            }
1547:
1548:            protected synchronized void removePOAListener(POAListener listener) {
1549:                poaListener = EventMulticaster.remove(poaListener, listener);
1550:            }
1551:
1552:            public byte[] servant_to_id(Servant servant)
1553:                    throws ServantNotActive, WrongPolicy {
1554:                checkDestructionApparent();
1555:
1556:                if ((!isUseDefaultServant()) && (!isRetain() || !isUniqueId())
1557:                        && (!isRetain() || !isImplicitActivation())) {
1558:                    throw new WrongPolicy();
1559:                }
1560:
1561:                byte[] objectId = null;
1562:
1563:                if (isRetain()) {
1564:                    if (isUniqueId()) {
1565:                        objectId = aom.getObjectId(servant);
1566:                        if (objectId != null) {
1567:                            return objectId;
1568:                        }
1569:                    }
1570:
1571:                    if (isImplicitActivation()
1572:                            && (isMultipleId() || !aom.contains(servant))) {
1573:                        objectId = generateObjectId();
1574:                        /* activate the servant using the generated objectId and the
1575:                           intfRepId associated with the servant */
1576:                        try {
1577:                            aom.add(objectId, servant);
1578:                        } catch (ObjectAlreadyActive e) {
1579:                            throw new POAInternalError(
1580:                                    "error: object already active (servant_to_id)");
1581:                        } catch (ServantAlreadyActive e) {
1582:                            /*  it's   ok,  a  nother  one   was  faster  with
1583:                                activation (only occurs if unique_id is set) */
1584:                            objectId = aom.getObjectId(servant);
1585:                        }
1586:
1587:                        orb.set_delegate(servant);
1588:
1589:                        return objectId;
1590:                    }
1591:                }
1592:                if (isUseDefaultServant() && servant == defaultServant
1593:                        && isInInvocationContext(servant)) {
1594:                    /* objectId associated with the current invocation */
1595:                    try {
1596:                        objectId = orb.getPOACurrent().get_object_id();
1597:                    } catch (org.omg.PortableServer.CurrentPackage.NoContext e) {
1598:                        throw new POAInternalError(
1599:                                "error: not in invocation context (servant_to_id)");
1600:                    }
1601:                    return objectId;
1602:                }
1603:
1604:                throw new ServantNotActive();
1605:            }
1606:
1607:            /**
1608:             */
1609:
1610:            public org.omg.CORBA.Object servant_to_reference(Servant servant)
1611:                    throws ServantNotActive, WrongPolicy {
1612:                checkDestructionApparent();
1613:
1614:                boolean isInInvocationContext = isInInvocationContext(servant);
1615:
1616:                if ((!isRetain() || !isUniqueId())
1617:                        && (!isRetain() || !isImplicitActivation())
1618:                        && !isInInvocationContext) {
1619:                    throw new WrongPolicy();
1620:                }
1621:
1622:                byte[] objectId = null;
1623:
1624:                if (isInInvocationContext) {
1625:                    /* reference = Reference associated with the current invocation */
1626:                    try {
1627:                        objectId = orb.getPOACurrent().get_object_id();
1628:                    } catch (org.omg.PortableServer.CurrentPackage.NoContext e) {
1629:                        throw new POAInternalError(
1630:                                "error: not in invocation context (servant_to_reference)");
1631:                    }
1632:                    return getReference(objectId, servant._all_interfaces(this ,
1633:                            objectId)[0], true);
1634:                }
1635:
1636:                if (isRetain()) {
1637:                    if (isUniqueId()) {
1638:                        /* the object reference encapsulating the information
1639:                           used to activate the servant is returned */
1640:
1641:                        objectId = aom.getObjectId(servant);
1642:                        if (objectId != null) {
1643:                            return getReference(objectId, servant
1644:                                    ._all_interfaces(this , objectId)[0], true);
1645:                        }
1646:                    }
1647:
1648:                    if (isImplicitActivation()
1649:                            && (isMultipleId() || !aom.contains(servant))) {
1650:                        objectId = generateObjectId();
1651:
1652:                        /* activate the servant using a generated objectId and
1653:                           the intfRepId associated with the servant
1654:                           and a corresponding object reference is returned */
1655:
1656:                        try {
1657:                            aom.add(objectId, servant);
1658:                        } catch (ObjectAlreadyActive e) {
1659:                            throw new POAInternalError(
1660:                                    "error: object already active (servant_to_reference)");
1661:                        } catch (ServantAlreadyActive e) {
1662:                            /* it's ok, another one was faster with activation
1663:                               (only occurs if unique_id is set) */
1664:                            objectId = aom.getObjectId(servant);
1665:                        }
1666:
1667:                        orb.set_delegate(servant);
1668:
1669:                        return getReference(objectId, servant._all_interfaces(
1670:                                this , objectId)[0], true);
1671:                    }
1672:                }
1673:                throw new ServantNotActive();
1674:            }
1675:
1676:            public void set_servant(Servant _defaultServant) throws WrongPolicy {
1677:                checkDestructionApparent();
1678:
1679:                if (!isUseDefaultServant()) {
1680:                    throw new WrongPolicy();
1681:                }
1682:
1683:                defaultServant = _defaultServant;
1684:
1685:                if (defaultServant != null) {
1686:                    orb.set_delegate(defaultServant); // set the orb
1687:                }
1688:            }
1689:
1690:            /**
1691:             * this method makes a additional check: if the POA has the RETAIN
1692:             *   policy   and   _servantManager   is   not   a   instance   of
1693:             * ServantActivator  or if the  POA has the NON_RETAIN  policy and
1694:             * _servantManager is not a instance of ServantLocator this method
1695:             * raises also the WrongPolicy Exception (not spec.)
1696:             */
1697:
1698:            public void set_servant_manager(
1699:                    org.omg.PortableServer.ServantManager servant_manager)
1700:                    throws WrongPolicy {
1701:                checkDestructionApparent();
1702:
1703:                if (!isUseServantManager()) {
1704:                    throw new WrongPolicy();
1705:                }
1706:
1707:                if (servantManager != null) {
1708:                    throw new org.omg.CORBA.BAD_INV_ORDER();
1709:                }
1710:
1711:                /* not spec. */
1712:                if (isRetain()
1713:                        && !(servant_manager instanceof  org.omg.PortableServer.ServantActivator)) {
1714:                    throw new WrongPolicy();
1715:                }
1716:
1717:                if (!isRetain()
1718:                        && !(servant_manager instanceof  org.omg.PortableServer.ServantLocator)) {
1719:                    throw new WrongPolicy();
1720:                }
1721:
1722:                servantManager = servant_manager;
1723:            }
1724:
1725:            protected void setMonitor(POAMonitor _monitor) {
1726:                monitor = _monitor;
1727:            }
1728:
1729:            /**
1730:             * it is system-dependent whether the root POA initially has an adapter
1731:             * activator. a newly created POA has not an adapter activator (null)
1732:             */
1733:
1734:            public org.omg.PortableServer.AdapterActivator the_activator() {
1735:                checkDestructionApparent();
1736:                return adapterActivator;
1737:            }
1738:
1739:            public void the_activator(
1740:                    org.omg.PortableServer.AdapterActivator adapter_activator) {
1741:                checkDestructionApparent();
1742:                adapterActivator = adapter_activator;
1743:            }
1744:
1745:            public String the_name() {
1746:                checkDestructionApparent();
1747:                return POAUtil.unmaskStr(name);
1748:            }
1749:
1750:            public org.omg.PortableServer.POA the_parent() {
1751:                checkDestructionApparent();
1752:                return parent;
1753:            }
1754:
1755:            public org.omg.PortableServer.POA[] the_children() {
1756:                checkDestructionApparent();
1757:
1758:                int i = 0;
1759:                Enumeration enumeration;
1760:                org.omg.PortableServer.POA[] children;
1761:
1762:                synchronized (poaCreationLog) {
1763:                    children = new org.omg.PortableServer.POA[childs.size()];
1764:                    enumeration = childs.elements();
1765:                    while (enumeration.hasMoreElements()) {
1766:                        children[i] = (org.omg.PortableServer.POA) enumeration
1767:                                .nextElement();
1768:                        i++;
1769:                    }
1770:                }
1771:
1772:                return children;
1773:            }
1774:
1775:            public org.omg.PortableServer.POAManager the_POAManager() {
1776:                checkDestructionApparent();
1777:                return poaManager;
1778:            }
1779:
1780:            /**
1781:             * notified the completion of a child destruction
1782:             */
1783:
1784:            protected void unregisterChild(String name) {
1785:                synchronized (poaCreationLog) {
1786:                    childs.remove(name);
1787:                    poaCreationLog.notifyAll();
1788:                }
1789:            }
1790:
1791:            /**
1792:             * called from Delegate
1793:             */
1794:
1795:            public boolean useDefaultServant() {
1796:                return isUseDefaultServant() && defaultServant != null;
1797:            }
1798:
1799:            protected boolean useServantManager() {
1800:                return isUseServantManager() && servantManager != null;
1801:            }
1802:
1803:            /**
1804:             * If any of the policies specified are not valid, or if conflicting
1805:             * policies are specified, or if any of the specified policies require
1806:             * prior administrative action that has not been performed, or if the
1807:             * policy type is unknown, this method returns the index in the policy list
1808:             * of the first offending policy object. By the creation of a new POA object
1809:             * this lead to an InvalidPolicy exception being raised containing this index.
1810:             *
1811:             * If everything's fine, this method returns -1;
1812:             */
1813:
1814:            private short verifyPolicyList(org.omg.CORBA.Policy[] policies) {
1815:                org.omg.CORBA.Policy policy;
1816:                org.omg.CORBA.Policy policy2;
1817:
1818:                for (short i = 0; i < policies.length; i++) {
1819:                    switch (policies[i].policy_type()) {
1820:                    case THREAD_POLICY_ID.value:
1821:                        /* no dependencies */
1822:                        break;
1823:                    case LIFESPAN_POLICY_ID.value:
1824:                        // PERSISTENT -> ImplName is set
1825:                        if (((LifespanPolicy) policies[i]).value() == LifespanPolicyValue.PERSISTENT) {
1826:                            if (implName == null) {
1827:                                logger
1828:                                        .fatalError("Cannot create a persistent poa. The implname property has not been set.");
1829:                                return i;
1830:                            }
1831:                        }
1832:
1833:                        /* no dependencies */
1834:                        break;
1835:                    case ID_UNIQUENESS_POLICY_ID.value:
1836:                        /* no dependencies */
1837:                        /* if you set NON_RETAIN the poa doesn't take any
1838:                           notice of the IdUniquenesPolicyValue */
1839:                        break;
1840:                    case ID_ASSIGNMENT_POLICY_ID.value:
1841:                        //   SYSTEM_ID   ->   no   dependencies   USER_ID   ->
1842:                        // NO_IMPLICIT_ACTIVATION, but  an error will detected
1843:                        //  if  we  have  considered  the  IMPLICIT_ACTIVATION
1844:                        // policy
1845:                        break;
1846:
1847:                    case SERVANT_RETENTION_POLICY_ID.value:
1848:                        // RETAIN -> no dependencies
1849:                        // NON_RETAIN -> (USE_DEFAULT_SERVANT || USE_SERVANT_MANAGER)
1850:                        if (((ServantRetentionPolicy) policies[i]).value() == ServantRetentionPolicyValue.NON_RETAIN) {
1851:
1852:                            policy = POAUtil.getPolicy(policies,
1853:                                    REQUEST_PROCESSING_POLICY_ID.value);
1854:                            if (policy == null) {
1855:                                return i; // default (USE_ACTIVE_OBJECT_MAP_ONLY) is forbidden
1856:                            }
1857:
1858:                            if (((RequestProcessingPolicy) policy).value() != RequestProcessingPolicyValue.USE_DEFAULT_SERVANT
1859:                                    && ((RequestProcessingPolicy) policy)
1860:                                            .value() != RequestProcessingPolicyValue.USE_SERVANT_MANAGER) {
1861:                                return i;
1862:                            }
1863:                            // NON_RETAIN -> NO_IMPLICIT_ACTIVATION, but an error will
1864:                            // be detected if we have considered the IMPLICIT_ACTIVATION policy
1865:                        }
1866:                        break;
1867:
1868:                    case REQUEST_PROCESSING_POLICY_ID.value:
1869:                        // USE_SERVANT_MANAGER -> no dependencies
1870:                        // USE_ACTIVE_OBJECT_MAP_ONLY -> RETAIN
1871:                        if (((RequestProcessingPolicy) policies[i]).value() == RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY) {
1872:
1873:                            policy = POAUtil.getPolicy(policies,
1874:                                    SERVANT_RETENTION_POLICY_ID.value);
1875:                            if (policy != null) {
1876:                                if (((ServantRetentionPolicy) policy).value() != ServantRetentionPolicyValue.RETAIN) {
1877:                                    return i;
1878:                                }
1879:                            }
1880:                            // else: do nothing, because default (RETAIN) is ok
1881:                            // USE_DEFAULT_SERVANT -> (MULTIPLE_ID || NON_RETAIN)  /* not spec. (NON_RETAIN) */
1882:                        } else if (((RequestProcessingPolicy) policies[i])
1883:                                .value() == RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) {
1884:                            policy = POAUtil.getPolicy(policies,
1885:                                    ID_UNIQUENESS_POLICY_ID.value);
1886:                            policy2 = POAUtil.getPolicy(policies,
1887:                                    SERVANT_RETENTION_POLICY_ID.value);
1888:                            if (policy == null && policy2 == null) {
1889:                                return i; // default (UNIQUE_ID && RETAIN) is forbidden
1890:                            } else if (policy != null && policy2 == null) {
1891:                                if (((IdUniquenessPolicy) policy).value() != IdUniquenessPolicyValue.MULTIPLE_ID) {
1892:                                    return i;
1893:                                }
1894:                            } else if (policy == null && policy2 != null) {
1895:                                if (((ServantRetentionPolicy) policy2).value() != ServantRetentionPolicyValue.NON_RETAIN) {
1896:                                    return i;
1897:                                }
1898:                            } else if (policy != null && policy2 != null) {
1899:                                if (((IdUniquenessPolicy) policy).value() != IdUniquenessPolicyValue.MULTIPLE_ID
1900:                                        && ((ServantRetentionPolicy) policy2)
1901:                                                .value() != ServantRetentionPolicyValue.NON_RETAIN) {
1902:                                    return i;
1903:                                }
1904:                            }
1905:                        }
1906:                        break;
1907:
1908:                    case IMPLICIT_ACTIVATION_POLICY_ID.value: {
1909:                        // NO_IMPLICIT_ACTIVATION -> no dependencies
1910:                        // IMPLICIT_ACTIVATION -> (SYSTEM_ID && RETAIN)
1911:                        if (((ImplicitActivationPolicy) policies[i]).value() == ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) {
1912:                            policy = POAUtil.getPolicy(policies,
1913:                                    SERVANT_RETENTION_POLICY_ID.value);
1914:                            if (policy != null) {
1915:                                if (((ServantRetentionPolicy) policy).value() != ServantRetentionPolicyValue.RETAIN) {
1916:                                    return i;
1917:                                }
1918:                            }
1919:                            // else: do nothing, because default (RETAIN) is ok
1920:
1921:                            policy = POAUtil.getPolicy(policies,
1922:                                    ID_ASSIGNMENT_POLICY_ID.value);
1923:                            if (policy != null) {
1924:                                if (((IdAssignmentPolicy) policy).value() != IdAssignmentPolicyValue.SYSTEM_ID) {
1925:                                    return i;
1926:                                }
1927:                            }
1928:                            // else: do nothing, because default (SYSTEM_ID) is ok
1929:                        }
1930:                        break;
1931:                    }
1932:                    case BIDIRECTIONAL_POLICY_TYPE.value:
1933:                        // nothing to do
1934:                        break;
1935:                    //ignore unknown policies
1936:
1937:                    //              // unknown policy type -> return i
1938:                    //          default :
1939:                    //              return i;
1940:                    }
1941:                }
1942:                return -1;
1943:            }
1944:
1945:            public org.omg.CORBA.Policy getPolicy(int type) {
1946:                return (org.omg.CORBA.Policy) all_policies.get(ObjectUtil
1947:                        .newInteger(type));
1948:            }
1949:
1950:            public void addLocalRequest() {
1951:                requestController.addLocalRequest();
1952:            }
1953:
1954:            public void removeLocalRequest() {
1955:                requestController.removeLocalRequest();
1956:            }
1957:
1958:            public int getNumberOfObjects() {
1959:                return aom.size();
1960:            }
1961:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.