Source Code Cross Referenced for KeRegisteredObject.java in  » J2EE » WiSerFramework » de » ug2t » kernel » 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 » J2EE » WiSerFramework » de.ug2t.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // @@
0002:        // @@
0003:        /*
0004:         * Wi.Ser Framework
0005:         *
0006:         * Version: 1.8.1, 20-September-2007  
0007:         * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
0008:         *
0009:         * This library is free software; you can redistribute it and/or
0010:         * modify it under the terms of the GNU Lesser General Public
0011:         * License as published by the Free Software Foundation; either
0012:         * version 2 of the License, or (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful,
0015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017:         * Lesser General Public License for more details.
0018:         *
0019:         * You should have received a copy of the GNU Lesser General Public
0020:         * License along with this library located in LGPL.txt in the 
0021:         * license directory; if not, write to the 
0022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0023:         * Boston, MA  02111-1307, USA.
0024:         * 
0025:         * If this agreement does not cover your requirements, please contact us
0026:         * via email to get detailed information about the commercial license 
0027:         * or our service offerings!
0028:         *
0029:         */
0030:        // @@
0031:        package de.ug2t.kernel;
0032:
0033:        import java.lang.ref.*;
0034:        import java.util.*;
0035:
0036:        import de.ug2t.kernel.id.*;
0037:        import de.ug2t.kernel.interfaces.*;
0038:
0039:        /**
0040:         * @author Dirk
0041:         * 
0042:         * date: 02.01.2004 project: WiSer-Framework
0043:         * 
0044:         * <p>
0045:         * This class is responsible for the access to registered objects. A registered
0046:         * object is identified by its name. This name has to be unique either in the
0047:         * namespace of a thread (only accessable from this thread) or in a global
0048:         * namespace (accessable from all threads).
0049:         * </p>
0050:         */
0051:        public class KeRegisteredObject implements  Runnable, IKeExecutable,
0052:                IKeValueContainer, IKeRegisteredObject {
0053:            // Debug
0054:            // public static Map pcm_map = Collections.synchronizedMap(new HashMap());
0055:            //  
0056:            // public void pcmf_incInst()
0057:            // {
0058:            // Integer l_cnt = (Integer)pcm_map.get(this.getClass());
0059:            // if (l_cnt == null)
0060:            // l_cnt = new Integer(0);
0061:            //    
0062:            // l_cnt = new Integer (l_cnt.intValue()+1);
0063:            // pcm_map.put(this.getClass(), l_cnt);
0064:            // }
0065:            //  
0066:            // public void pcmf_decInst()
0067:            // {
0068:            // Integer l_cnt = (Integer)pcm_map.get(this.getClass());
0069:            // if (l_cnt == null)
0070:            // l_cnt = new Integer(0);
0071:            //    
0072:            // l_cnt = new Integer (l_cnt.intValue()-1);
0073:            // pcm_map.put(this.getClass(), l_cnt);
0074:            // }
0075:            //  
0076:            // public static String pcmf_getInstStats()
0077:            // {
0078:            // String l_ret = "";
0079:            // l_ret += "InstStatsBegin\n------------------------";
0080:            // Iterator l_it = pcm_map.keySet().iterator();
0081:            // while (l_it.hasNext())
0082:            // {
0083:            // Object l_obj = l_it.next();
0084:            // l_ret +="\n" + pcm_map.get(l_obj).toString() + " " + l_obj.toString();
0085:            // }
0086:            // l_ret += "InstStatsEnd\n------------------------";
0087:            //    
0088:            // return (l_ret);
0089:            // }
0090:
0091:            private static final String NAMESEP = "@";
0092:            public static final int AUTO_DELETE_DISABLED = 0;
0093:            public static final int AUTO_DELETE_EARLY = 1;
0094:            public static final int AUTO_DELETE_LATE = 2;
0095:
0096:            private static final Map pem_allObj = Collections
0097:                    .synchronizedMap(new HashMap());
0098:            private static final Map pem_context = Collections
0099:                    .synchronizedMap(new HashMap());
0100:
0101:            private static IKeIDGenerator pem_idGen = new KeStdIDGenerator();
0102:
0103:            private static String pem_prefix = null;
0104:            private String pem_objName = null;
0105:            private String pem_objShortName = null;
0106:            private String pem_objRemName = null;
0107:            private Object pem_addInfo = null;
0108:            private KeObjectStorage pem_myThread = null;
0109:            protected volatile boolean pdm_deleted = false;
0110:
0111:            // @@
0112:
0113:            /**
0114:             * For internal use only
0115:             */
0116:            public static synchronized void pcmf_setIDGenerator(
0117:                    IKeIDGenerator xGen) {
0118:                KeRegisteredObject.pem_idGen = xGen;
0119:            }
0120:
0121:            /**
0122:             * For internal use only
0123:             */
0124:            public static synchronized IKeIDGenerator pcmf_getIDGenerator() {
0125:                return (KeRegisteredObject.pem_idGen);
0126:            }
0127:
0128:            /**
0129:             * For internal use only
0130:             */
0131:            protected void pdmf_resetThread() {
0132:                this .pem_myThread = null;
0133:            }
0134:
0135:            private static final String GLOBAL = Thread.currentThread()
0136:                    .getName()
0137:                    + "_GLOBAL";
0138:
0139:            static {
0140:                try {
0141:                    // Server Centric
0142:                    pem_prefix = "UG2T" + KeRegisteredObject.NAMESEP;
0143:
0144:                    // Distributed
0145:                    // Hier muß noch eine PID geholt werden, ggf. eine virtuelle per
0146:                    // Filezugriff erzeugte !
0147:
0148:                    // pem_prefix = java.net.InetAddress.getLocalHost().getHostName();
0149:                    // pem_prefix = pem_prefix + Runtime.getRuntime().hashCode() +
0150:                    // KeRegisteredObject.NAMESEP;
0151:
0152:                    KeLog.pcmf_log("ug2t", "registry startup", null,
0153:                            KeLog.MESSAGE);
0154:
0155:                    String l_out = "\n----------------------------------------------------\n"
0156:                            + "  WidgetServer Framework, open source (LGPL) release\n"
0157:                            + "       (C) 2005-2007, Dirk von der Weiden\n"
0158:                            + "----------------------------------------------------\n\n";
0159:
0160:                    // @@
0161:                    System.out.println(l_out);
0162:                } catch (Exception e) {
0163:                    KeLog.pcmf_logException("ug2t", null, e);
0164:                }
0165:                ;
0166:            };
0167:
0168:            /**
0169:             * For internal use only
0170:             */
0171:            protected boolean isDeleted() {
0172:                return (this .pdm_deleted);
0173:            }
0174:
0175:            /**
0176:             * For internal use only
0177:             */
0178:            public final void pcmf_setAdditionalInfo(Object xObj) {
0179:                this .pem_addInfo = xObj;
0180:            };
0181:
0182:            /**
0183:             * For internal use only
0184:             * 
0185:             * @deprecated
0186:             */
0187:            public final Object pcmf_getAdditionalnfo() {
0188:                return (this .pem_addInfo);
0189:            };
0190:
0191:            public final Object pcmf_getAdditionalInfo() {
0192:                return (this .pem_addInfo);
0193:            };
0194:
0195:            /**
0196:             * For internal use only
0197:             */
0198:            public void run() {
0199:                pcmf_execObj(this .pem_addInfo);
0200:            };
0201:
0202:            /**
0203:             * For internal use only
0204:             */
0205:            public Object pcmf_execObj(Object xObj) {
0206:                throw (new UnsupportedOperationException());
0207:            };
0208:
0209:            /**
0210:             * For internal use only
0211:             */
0212:            public void pcmf_setValue(Object xValue) {
0213:                throw (new UnsupportedOperationException());
0214:            };
0215:
0216:            /**
0217:             * For internal use only
0218:             */
0219:            public Object pcmf_setValueValidate(Object xValue) {
0220:                this .pcmf_setValue(xValue);
0221:                return (xValue);
0222:            };
0223:
0224:            /**
0225:             * For internal use only
0226:             */
0227:            public Object pcmf_getValue() {
0228:                throw (new UnsupportedOperationException());
0229:            };
0230:
0231:            /*
0232:             * (non-Javadoc)
0233:             * 
0234:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_delete()
0235:             */
0236:            public void pcmf_delete() throws Exception {
0237:                if (this .pdm_deleted == true)
0238:                    return;
0239:
0240:                KeObjectStorage actx = null;
0241:
0242:                if (this .pem_objName != null) {
0243:                    actx = this .pem_myThread;
0244:
0245:                    if (actx == null) {
0246:                        this .pem_objRemName = null;
0247:                        this .pdm_deleted = true;
0248:
0249:                        return;
0250:                    }
0251:
0252:                    if (this .pem_objRemName != null) {
0253:                        actx.pcmf_removeRemName(this .pem_objRemName);
0254:                        this .pem_objRemName = null;
0255:                    }
0256:                    ;
0257:
0258:                    this .pem_myThread = null;
0259:                    actx.pcmf_removeByName(this .pem_objName);
0260:                }
0261:                // KeLog.pcmf_log("ug2t", "delete obj: " + this.pcmf_getObjName(),
0262:                // this, KeLog.DEBUG);
0263:                this .pdm_deleted = true;
0264:
0265:                // @@
0266:
0267:                if (actx != null)
0268:                    actx.pdmf_execDeletedListeners(this );
0269:
0270:                return;
0271:            };
0272:
0273:            /**
0274:             * <p>
0275:             * Creates a registred object with a unique name in the currently running
0276:             * threads namespace
0277:             * </p>
0278:             * <p>
0279:             * 
0280:             * </p>
0281:             * <p>
0282:             * </p>
0283:             */
0284:            public KeRegisteredObject() {
0285:                // pcmf_incInst();
0286:                pem_objName = pem_idGen.pcmf_getId();
0287:                pemf_register(pem_objName);
0288:
0289:                // KeLog.pcmf_log("ug2t", "constructed registred object: " +
0290:                // pem_objName, this, KeLog.DEBUG);
0291:                return;
0292:            };
0293:
0294:            /**
0295:             * <p>
0296:             * Creates a registrable object
0297:             * </p>
0298:             * <p>
0299:             * 
0300:             * </p>
0301:             * <p>
0302:             * 
0303:             * @param xRegister
0304:             *          true registers the object, false does not register the object
0305:             *          </p>
0306:             */
0307:            protected KeRegisteredObject(boolean xRegister) {
0308:                // pcmf_incInst();
0309:                if (!xRegister) {
0310:                    KeRegisteredObject.pemf_createThreadContext();
0311:                    return;
0312:                }
0313:
0314:                pem_objName = pem_idGen.pcmf_getId();
0315:                pemf_register(pem_objName);
0316:
0317:                // KeLog.pcmf_log("ug2t", "constructed registred object: " +
0318:                // pem_objName, this, KeLog.DEBUG);
0319:                return;
0320:            };
0321:
0322:            private static synchronized KeObjectStorage pemf_createThreadContext() {
0323:                String tname = Thread.currentThread().getName();
0324:
0325:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
0326:                if (actx == null) {
0327:                    actx = new KeObjectStorage();
0328:                    KeRegisteredObject.pem_context.put(tname, actx);
0329:                }
0330:                ;
0331:
0332:                return (actx);
0333:            }
0334:
0335:            /**
0336:             * For internal use only
0337:             */
0338:            private static synchronized KeObjectStorage pemf_createThreadContext(
0339:                    String xCtx) {
0340:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0341:                if (actx == null) {
0342:                    actx = new KeObjectStorage();
0343:                    KeRegisteredObject.pem_context.put(xCtx, actx);
0344:                }
0345:                ;
0346:
0347:                return (actx);
0348:            }
0349:
0350:            /**
0351:             * <p>
0352:             * Adds a registration listener to a given context
0353:             * </p>
0354:             * <p>
0355:             * 
0356:             * </p>
0357:             * <p>
0358:             * 
0359:             * @param xCtx
0360:             *          context name
0361:             * @param xListen
0362:             *          registration listener
0363:             *          </p>
0364:             */
0365:            public static synchronized void pcmf_addRegListener(String xCtx,
0366:                    IKeRegistrationListener xListen) {
0367:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0368:                if (actx == null) {
0369:                    actx = new KeObjectStorage();
0370:                    KeRegisteredObject.pem_context.put(xCtx, actx);
0371:                }
0372:                ;
0373:                actx.pdmf_addRegListener(xListen);
0374:
0375:                return;
0376:            }
0377:
0378:            /**
0379:             * <p>
0380:             * Removes a registration listener from a given context
0381:             * </p>
0382:             * <p>
0383:             * 
0384:             * </p>
0385:             * <p>
0386:             * 
0387:             * @param xCtx
0388:             *          context name
0389:             * @param xListen
0390:             *          registration listener
0391:             *          </p>
0392:             */
0393:            public static synchronized void pcmf_removeRegListener(String xCtx,
0394:                    IKeRegistrationListener xListen) {
0395:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0396:                if (actx == null)
0397:                    return;
0398:
0399:                actx.pdmf_removeRegListener(xListen);
0400:
0401:                return;
0402:            }
0403:
0404:            /**
0405:             * <p>
0406:             * Adds a registration listener to this context
0407:             * </p>
0408:             * <p>
0409:             * 
0410:             * </p>
0411:             * <p>
0412:             * 
0413:             * @param xCtx
0414:             *          context name
0415:             * @param xListen
0416:             *          registration listener
0417:             *          </p>
0418:             */
0419:            public static void pcmf_addRegListener(
0420:                    IKeRegistrationListener xListen) {
0421:                String tname = Thread.currentThread().getName();
0422:                KeRegisteredObject.pcmf_addRegListener(tname, xListen);
0423:
0424:                return;
0425:            }
0426:
0427:            /**
0428:             * <p>
0429:             * Removes a registration listener from this context
0430:             * </p>
0431:             * <p>
0432:             * 
0433:             * </p>
0434:             * <p>
0435:             * 
0436:             * @param xCtx
0437:             *          context name
0438:             * @param xListen
0439:             *          registration listener
0440:             *          </p>
0441:             */
0442:            public static void pcmf_removeRegListener(
0443:                    IKeRegistrationListener xListen) {
0444:                String tname = Thread.currentThread().getName();
0445:                KeRegisteredObject.pcmf_removeRegListener(tname, xListen);
0446:
0447:                return;
0448:            }
0449:
0450:            /**
0451:             * <p>
0452:             * Returns the list with all registration listeners of this context
0453:             * </p>
0454:             * <p>
0455:             * 
0456:             * @return list
0457:             *         </p>
0458:             */
0459:            public static ArrayList pcmf_getRegListeners() {
0460:                String tname = Thread.currentThread().getName();
0461:                return (KeRegisteredObject.pcmf_getRegListeners());
0462:            };
0463:
0464:            /**
0465:             * <p>
0466:             * Returns the list with all registration listeners of the given context
0467:             * </p>
0468:             * <p>
0469:             * 
0470:             * @return list
0471:             *         </p>
0472:             */
0473:            public static ArrayList pcmf_getRegListeners(String xCtx) {
0474:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0475:                if (actx == null)
0476:                    return (null);
0477:
0478:                return (actx.pcmf_getRegListeners());
0479:            };
0480:
0481:            /**
0482:             * <p>
0483:             * Registers an object in the currently running threads namespace which is not
0484:             * derived from KeRegisteredObject
0485:             * </p>
0486:             * <p>
0487:             * 
0488:             * </p>
0489:             * <p>
0490:             * 
0491:             * @param xName
0492:             *          unique name of the object
0493:             * @param xObj
0494:             *          object to register
0495:             *          </p>
0496:             */
0497:            public final static int pcmf_register(String xName, Object xObj) {
0498:                if (xObj instanceof  KeRegisteredObject)
0499:                    return (((KeRegisteredObject) xObj).pcmf_register(xName));
0500:
0501:                xName = KeRegisteredObject.pem_prefix + xName;
0502:                KeObjectStorage actx = KeRegisteredObject
0503:                        .pemf_createThreadContext();
0504:
0505:                if (actx.pcmf_getRegister() == false) {
0506:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0507:                        KeLog.pcmf_log("ug2t",
0508:                                "registration disabled, object: " + xName
0509:                                        + " not has not been registered", null,
0510:                                KeLog.DEBUG);
0511:
0512:                    return (0);
0513:                }
0514:
0515:                if (actx.pcmf_getByName(xName) != null) {
0516:                    KeLog.pcmf_log("ug2t",
0517:                            "duplicate registration class@object@thread: "
0518:                                    + xObj.getClass() + "@" + xName + "@"
0519:                                    + Thread.currentThread().getName(), null,
0520:                            KeLog.ERROR);
0521:                    return (-1);
0522:                }
0523:                ;
0524:
0525:                actx.pcmf_put(xName, xObj);
0526:                pem_allObj.put(xObj, actx);
0527:
0528:                actx.pdmf_execRegListeners(xObj);
0529:
0530:                return (0);
0531:            };
0532:
0533:            /**
0534:             * <p>
0535:             * Reregisters an object in the currently running threads namespace which is
0536:             * not derived from KeRegisteredObject
0537:             * </p>
0538:             * <p>
0539:             * 
0540:             * </p>
0541:             * <p>
0542:             * 
0543:             * @param xName
0544:             *          unique name of the object
0545:             * @param xObj
0546:             *          object to register
0547:             *          </p>
0548:             */
0549:            public final static void pcmf_reRegister(String xName, Object xObj) {
0550:                if (xObj instanceof  KeRegisteredObject)
0551:                    ((KeRegisteredObject) xObj).pcmf_reRegister(xName);
0552:                else {
0553:                    KeRegisteredObject.pcmf_unRegister(xObj);
0554:                    KeRegisteredObject.pcmf_register(xName, xObj);
0555:                }
0556:            };
0557:
0558:            /*
0559:             * (non-Javadoc)
0560:             * 
0561:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_register(java.lang.String)
0562:             */
0563:            public int pcmf_register(String xName) {
0564:                if (this .pem_myThread != null) {
0565:                    this .pcmf_reRegister(xName);
0566:                    return (0);
0567:                }
0568:                ;
0569:
0570:                String l_sname = xName;
0571:                xName = KeRegisteredObject.pem_prefix + xName;
0572:
0573:                KeObjectStorage actx = KeRegisteredObject
0574:                        .pemf_createThreadContext();
0575:
0576:                if (actx.pcmf_getRegister() == false) {
0577:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0578:                        KeLog.pcmf_log("ug2t",
0579:                                "registration disabled, object: " + xName
0580:                                        + " not has not been registered", this ,
0581:                                KeLog.DEBUG);
0582:
0583:                    return (0);
0584:                }
0585:
0586:                if (actx.pcmf_getByName(xName) != null) {
0587:                    KeLog.pcmf_log("ug2t",
0588:                            "duplicate registration class@object@thread: "
0589:                                    + this .getClass() + "@" + xName + "@"
0590:                                    + Thread.currentThread().getName(), null,
0591:                            KeLog.ERROR);
0592:
0593:                    return (-1);
0594:                }
0595:                ;
0596:
0597:                this .pem_myThread = actx;
0598:                pem_objName = xName;
0599:                this .pem_objShortName = l_sname;
0600:                if (this .pem_objRemName == null)
0601:                    pem_objRemName = pem_objName;
0602:
0603:                actx.pcmf_putRemName(pem_objRemName, l_sname);
0604:
0605:                switch (actx.pcmf_getAutoDelete()) {
0606:                case KeRegisteredObject.AUTO_DELETE_EARLY:
0607:                    this .pcmf_setEarlyAutoDelete(true);
0608:                    break;
0609:                case KeRegisteredObject.AUTO_DELETE_LATE:
0610:                    this .pcmf_setLateAutoDelete(true);
0611:                    break;
0612:                default:
0613:                    actx.pcmf_putToName(xName, this );
0614:                }
0615:
0616:                actx.pdmf_execRegListeners(this );
0617:
0618:                return (0);
0619:            };
0620:
0621:            /**
0622:             * For internal use only
0623:             */
0624:            private int pemf_register(String xName) {
0625:                String l_sname = xName;
0626:                xName = KeRegisteredObject.pem_prefix + xName;
0627:
0628:                KeObjectStorage actx = KeRegisteredObject
0629:                        .pemf_createThreadContext();
0630:
0631:                if (actx.pcmf_getRegister() == false) {
0632:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0633:                        KeLog.pcmf_log("ug2t",
0634:                                "registration disabled, object: " + xName
0635:                                        + " not has not been registered", this ,
0636:                                KeLog.DEBUG);
0637:
0638:                    return (0);
0639:                }
0640:                this .pem_myThread = actx;
0641:                pem_objName = xName;
0642:                this .pem_objShortName = l_sname;
0643:                if (this .pem_objRemName == null)
0644:                    pem_objRemName = pem_objName;
0645:
0646:                actx.pcmf_putRemName(pem_objRemName, l_sname);
0647:                this .pcmf_setEarlyAutoDelete(true);
0648:                actx.pdmf_execRegListeners(this );
0649:
0650:                return (0);
0651:            };
0652:
0653:            /**
0654:             * <p>
0655:             * Registers an object in the given threads namespace which is not derived
0656:             * from KeRegisteredObject
0657:             * </p>
0658:             * <p>
0659:             * 
0660:             * </p>
0661:             * <p>
0662:             * 
0663:             * @param xName
0664:             *          unique name of the object
0665:             * @param xObj
0666:             *          object to register
0667:             * @param xCtx
0668:             *          Thread name
0669:             *          </p>
0670:             */
0671:            public final static int pcmf_registerInContext(String xName,
0672:                    Object xObj, String xCtx) {
0673:                if (xObj instanceof  KeRegisteredObject)
0674:                    return (((KeRegisteredObject) xObj).pcmf_registerInContext(
0675:                            xName, xCtx));
0676:
0677:                xName = KeRegisteredObject.pem_prefix + xName;
0678:                KeObjectStorage actx = KeRegisteredObject
0679:                        .pemf_createThreadContext(xCtx);
0680:
0681:                if (actx.pcmf_getByName(xName) != null) {
0682:                    KeLog.pcmf_log("ug2t",
0683:                            "duplicate registration class@object@thread: "
0684:                                    + xObj.getClass() + "@" + xName + "@"
0685:                                    + Thread.currentThread().getName(), null,
0686:                            KeLog.ERROR);
0687:                    return (-1);
0688:                }
0689:                ;
0690:
0691:                actx.pcmf_put(xName, xObj);
0692:                pem_allObj.put(xObj, actx);
0693:
0694:                actx.pdmf_execRegListeners(xObj);
0695:
0696:                return (0);
0697:            };
0698:
0699:            /**
0700:             * For internal use only
0701:             */
0702:            public static void pcmf_setRegister(boolean xReg) {
0703:                KeObjectStorage actx = KeRegisteredObject
0704:                        .pemf_createThreadContext();
0705:                actx.pcmf_setRegister(xReg);
0706:            }
0707:
0708:            /**
0709:             * For internal use only
0710:             */
0711:            public static void pcmf_setRegister(String xCtx, boolean xReg) {
0712:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0713:                actx.pcmf_setRegister(xReg);
0714:            }
0715:
0716:            /**
0717:             * For internal use only
0718:             */
0719:            public static boolean pcmf_getRegister() {
0720:                KeObjectStorage actx = KeRegisteredObject
0721:                        .pemf_createThreadContext();
0722:                return (actx.pcmf_getRegister());
0723:            }
0724:
0725:            /**
0726:             * For internal use only
0727:             */
0728:            public static boolean pcmf_getRegister(String xCtx) {
0729:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
0730:                return (actx.pcmf_getRegister());
0731:            }
0732:
0733:            /**
0734:             * <p>
0735:             * Registers an object in the given threads namespace which is derived from
0736:             * KeRegisteredObject
0737:             * </p>
0738:             * <p>
0739:             * 
0740:             * </p>
0741:             * <p>
0742:             * 
0743:             * @param xName
0744:             *          unique name of the object and must not be null
0745:             * @param xCtx
0746:             *          Thread name
0747:             *          </p>
0748:             */
0749:            public int pcmf_registerInContext(String xName, String xCtx) {
0750:                if (this .pem_myThread != null) {
0751:                    this .pcmf_reRegister(xName);
0752:                    return (0);
0753:                }
0754:                ;
0755:
0756:                String l_sname = xName;
0757:                xName = KeRegisteredObject.pem_prefix + xName;
0758:
0759:                KeObjectStorage actx = KeRegisteredObject
0760:                        .pemf_createThreadContext(xCtx);
0761:
0762:                if (actx.pcmf_getRegister() == false) {
0763:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0764:                        KeLog.pcmf_log("ug2t",
0765:                                "registration disabled, object: " + xName
0766:                                        + " not has not been registered", this ,
0767:                                KeLog.DEBUG);
0768:
0769:                    return (0);
0770:                }
0771:
0772:                if (actx.pcmf_getByName(xName) != null) {
0773:                    KeLog.pcmf_log("ug2t",
0774:                            "duplicate registration class@object@thread: "
0775:                                    + this .getClass() + "@" + xName + "@"
0776:                                    + Thread.currentThread().getName(), null,
0777:                            KeLog.ERROR);
0778:                    return (-1);
0779:                }
0780:                ;
0781:
0782:                this .pem_myThread = actx;
0783:                pem_objName = xName;
0784:                this .pem_objShortName = l_sname;
0785:                if (this .pem_objRemName == null)
0786:                    pem_objRemName = pem_objName;
0787:
0788:                actx.pcmf_putRemName(pem_objRemName, l_sname);
0789:
0790:                switch (actx.pcmf_getAutoDelete()) {
0791:                case KeRegisteredObject.AUTO_DELETE_EARLY:
0792:                    this .pcmf_setEarlyAutoDelete(true);
0793:                    break;
0794:                case KeRegisteredObject.AUTO_DELETE_LATE:
0795:                    this .pcmf_setLateAutoDelete(true);
0796:                    break;
0797:                default:
0798:                    actx.pcmf_putToName(xName, this );
0799:                }
0800:
0801:                actx.pdmf_execRegListeners(this );
0802:
0803:                return (0);
0804:            };
0805:
0806:            /*
0807:             * (non-Javadoc)
0808:             * 
0809:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_isRegistered()
0810:             */
0811:            public final boolean pcmf_isRegistered() {
0812:                if (this  == KeRegisteredObject.pcmf_getObjByName(this 
0813:                        .pcmf_getObjName())
0814:                        || this .pcmf_isGlobal())
0815:                    return (true);
0816:                else
0817:                    return (false);
0818:            }
0819:
0820:            /**
0821:             * <p>
0822:             * Returns whether this object is registered or not
0823:             * </p>
0824:             */
0825:            public static final boolean pcmf_isRegistered(Object xObj) {
0826:                if (xObj instanceof  KeRegisteredObject)
0827:                    return (((KeRegisteredObject) xObj).pcmf_isRegistered());
0828:
0829:                KeObjectStorage actx = (KeObjectStorage) pem_allObj.get(xObj);
0830:                if (actx == null)
0831:                    return (false);
0832:
0833:                return (actx.pcmf_testObj(xObj));
0834:            }
0835:
0836:            // =====================
0837:            // Globals
0838:            // ====================
0839:
0840:            /*
0841:             * (non-Javadoc)
0842:             * 
0843:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_isGlobal()
0844:             */
0845:            public final boolean pcmf_isGlobal() {
0846:                String tname = KeRegisteredObject.GLOBAL;
0847:
0848:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
0849:                if (actx == null)
0850:                    return (false);
0851:
0852:                if (this  == KeRegisteredObject.pcmf_getGlobalObjByName(this 
0853:                        .pcmf_getObjName()))
0854:                    return (true);
0855:                else
0856:                    return (false);
0857:            }
0858:
0859:            /*
0860:             * (non-Javadoc)
0861:             * 
0862:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_isLocal()
0863:             */
0864:            public final boolean pcmf_isLocal() {
0865:                if (KeRegisteredObject
0866:                        .pcmf_getObjByName(this .pcmf_getObjName(), this 
0867:                                .pcmf_getCurrentContextID()) == null)
0868:                    return (false);
0869:                else
0870:                    return (true);
0871:            }
0872:
0873:            /**
0874:             * <p>
0875:             * Returns whether this object is registered locally or not
0876:             * </p>
0877:             */
0878:            public static final boolean pcmf_isLocal(Object xObj) {
0879:                if (xObj instanceof  KeRegisteredObject)
0880:                    return (((KeRegisteredObject) xObj).pcmf_isLocal());
0881:
0882:                String tname = Thread.currentThread().getName();
0883:
0884:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
0885:                if (actx == null)
0886:                    return (false);
0887:
0888:                return (actx.pcmf_testObj(xObj));
0889:            }
0890:
0891:            /**
0892:             * <p>
0893:             * Returns whether this object is registered globaly or not
0894:             * </p>
0895:             */
0896:            public static final boolean pcmf_isGlobal(Object xObj) {
0897:                if (xObj instanceof  KeRegisteredObject)
0898:                    return (((KeRegisteredObject) xObj).pcmf_isGlobal());
0899:
0900:                String tname = KeRegisteredObject.GLOBAL;
0901:
0902:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
0903:                if (actx == null)
0904:                    return (false);
0905:
0906:                return (actx.pcmf_testObj(xObj));
0907:            }
0908:
0909:            /**
0910:             * <p>
0911:             * Registers an object in the global namespace which is not derived from
0912:             * KeRegisteredObject
0913:             * </p>
0914:             * <p>
0915:             * 
0916:             * </p>
0917:             * <p>
0918:             * 
0919:             * @param xName
0920:             *          unique name of the object
0921:             * @param xObj
0922:             *          object to register
0923:             *          </p>
0924:             */
0925:            public final static int pcmf_registerGlobal(String xName,
0926:                    Object xObj) {
0927:                if (xObj instanceof  KeRegisteredObject)
0928:                    return (((KeRegisteredObject) xObj)
0929:                            .pcmf_registerGlobal(xName));
0930:
0931:                xName = KeRegisteredObject.pem_prefix + xName;
0932:                String tname = KeRegisteredObject.GLOBAL;
0933:
0934:                KeObjectStorage actx = null;
0935:                synchronized (KeRegisteredObject.class) {
0936:                    actx = (KeObjectStorage) pem_context.get(tname);
0937:                    if (actx == null) {
0938:                        actx = new KeObjectStorage();
0939:                        pem_context.put(tname, actx);
0940:                    }
0941:                    ;
0942:                }
0943:
0944:                if (actx.pcmf_getRegister() == false) {
0945:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0946:                        KeLog.pcmf_log("ug2t",
0947:                                "registration disabled, object: " + xName
0948:                                        + " not has not been registered", null,
0949:                                KeLog.DEBUG);
0950:
0951:                    return (0);
0952:                }
0953:
0954:                if (actx.pcmf_getByName(xName) != null) {
0955:                    KeLog.pcmf_log("ug2t",
0956:                            "duplicate global registration class@object@thread: "
0957:                                    + xObj.getClass() + "@" + xName + "@"
0958:                                    + tname, null, KeLog.ERROR);
0959:                    return (-1);
0960:                }
0961:                ;
0962:
0963:                actx.pcmf_put(xName, xObj);
0964:                pem_allObj.put(xObj, actx);
0965:
0966:                actx.pdmf_execRegListeners(xObj);
0967:
0968:                return (0);
0969:            };
0970:
0971:            /*
0972:             * (non-Javadoc)
0973:             * 
0974:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_registerGlobal(java.lang.String)
0975:             */
0976:            public final int pcmf_registerGlobal(String xName) {
0977:                String l_sname = xName;
0978:                xName = KeRegisteredObject.pem_prefix + xName;
0979:                String tname = KeRegisteredObject.GLOBAL;
0980:
0981:                KeObjectStorage actx = null;
0982:                synchronized (KeRegisteredObject.class) {
0983:                    actx = (KeObjectStorage) pem_context.get(tname);
0984:                    if (actx == null) {
0985:                        actx = new KeObjectStorage();
0986:                        KeRegisteredObject.pem_context.put(tname, actx);
0987:                    }
0988:                    ;
0989:                }
0990:
0991:                if (actx.pcmf_getRegister() == false) {
0992:                    if (KeLog.pcmf_testLog(KeLog.DEBUG))
0993:                        KeLog.pcmf_log("ug2t",
0994:                                "registration disabled, object: " + xName
0995:                                        + " not has not been registered", this ,
0996:                                KeLog.DEBUG);
0997:
0998:                    return (0);
0999:                }
1000:
1001:                if (actx.pcmf_getByName(xName) != null) {
1002:                    KeLog.pcmf_log("ug2t",
1003:                            "duplicate global registration class@object@thread: "
1004:                                    + this .getClass() + "@" + xName + "@"
1005:                                    + tname, null, KeLog.ERROR);
1006:                    return (-1);
1007:                }
1008:                ;
1009:
1010:                this .pem_myThread = actx;
1011:                pem_objName = xName;
1012:                this .pem_objShortName = l_sname;
1013:                if (this .pem_objRemName == null)
1014:                    pem_objRemName = pem_objName;
1015:
1016:                actx.pcmf_putRemName(pem_objRemName, l_sname);
1017:
1018:                switch (actx.pcmf_getAutoDelete()) {
1019:                case KeRegisteredObject.AUTO_DELETE_EARLY:
1020:                    this .pcmf_setEarlyAutoDelete(true);
1021:                    break;
1022:                case KeRegisteredObject.AUTO_DELETE_LATE:
1023:                    this .pcmf_setLateAutoDelete(true);
1024:                    break;
1025:                default:
1026:                    actx.pcmf_putToName(xName, this );
1027:                }
1028:
1029:                actx.pdmf_execRegListeners(this );
1030:
1031:                return (0);
1032:            };
1033:
1034:            // =================================
1035:
1036:            /**
1037:             * <p>
1038:             * Gets the unique name of an object
1039:             * </p>
1040:             * <p>
1041:             * 
1042:             * </p>
1043:             * <p>
1044:             * 
1045:             * @param xObj
1046:             *          object to get the unique name from
1047:             * @return objects name
1048:             *         </p>
1049:             */
1050:            public static final String pcmf_getObjName(Object xObj) {
1051:                String tname = Thread.currentThread().getName();
1052:                String l_name = null;
1053:
1054:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1055:                if (actx != null)
1056:                    l_name = actx.pcmf_getName(xObj);
1057:
1058:                if (l_name != null)
1059:                    l_name = KeRegisteredObject.pcmf_filterShortName(l_name);
1060:                else
1061:                    l_name = KeRegisteredObject.pcmf_getGlobalObjName(xObj);
1062:
1063:                return (l_name);
1064:            };
1065:
1066:            /**
1067:             * <p>
1068:             * Gets the unique name of an object from the global namespace
1069:             * </p>
1070:             * <p>
1071:             * 
1072:             * </p>
1073:             * <p>
1074:             * 
1075:             * @param xObj
1076:             *          object to get the unique name from
1077:             * @return objects name
1078:             *         </p>
1079:             */
1080:            public static final String pcmf_getGlobalObjName(Object xObj) {
1081:                String tname = KeRegisteredObject.GLOBAL;
1082:                String l_name = null;
1083:
1084:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1085:                if (actx != null)
1086:                    l_name = actx.pcmf_getName(xObj);
1087:
1088:                if (l_name != null)
1089:                    l_name = KeRegisteredObject.pcmf_filterShortName(l_name);
1090:
1091:                return (l_name);
1092:            };
1093:
1094:            /**
1095:             * <p>
1096:             * Gets the unique name of this object
1097:             * </p>
1098:             * <p>
1099:             * 
1100:             * </p>
1101:             * <p>
1102:             * 
1103:             * @return objects name
1104:             *         </p>
1105:             */
1106:            public final String pcmf_getObjName() {
1107:                return (pem_objShortName);
1108:            };
1109:
1110:            /**
1111:             * For internal use only
1112:             */
1113:            public final String pcmf_getObjLongName() {
1114:                return (pem_objName);
1115:            };
1116:
1117:            // unREgister entfernt den registrierungsnamen, lässt die Remote identität
1118:            // aber bestehen.
1119:            /**
1120:             * For internal use only
1121:             */
1122:            public final static Object pcmf_unRegister(String xName) {
1123:                xName = KeRegisteredObject.pem_prefix + xName;
1124:                String tname = Thread.currentThread().getName();
1125:
1126:                // KeLog.pcmf_log("ug2t", "remove obj from thread: " + tname + ":"
1127:                // + xName, null, KeLog.DEBUG);
1128:
1129:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1130:                if (actx == null)
1131:                    return (null);
1132:
1133:                Object l_obj = actx.pcmf_removeByName(xName);
1134:                if (l_obj instanceof  Reference)
1135:                    l_obj = ((Reference) l_obj).get();
1136:
1137:                pem_allObj.remove(l_obj);
1138:
1139:                if (l_obj instanceof  KeRegisteredObject)
1140:                    ((KeRegisteredObject) l_obj).pdmf_resetThread();
1141:
1142:                return (l_obj);
1143:            };
1144:
1145:            /*
1146:             * (non-Javadoc)
1147:             * 
1148:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_unRegister()
1149:             */
1150:            public final Object pcmf_unRegister() {
1151:                if (this .pem_objName == null)
1152:                    return (null);
1153:
1154:                KeObjectStorage actx = this .pem_myThread;
1155:                if (actx == null) {
1156:                    actx = (KeObjectStorage) pem_context.get(Thread
1157:                            .currentThread().getName());
1158:                    if (actx == null)
1159:                        return (null);
1160:                }
1161:                ;
1162:
1163:                // KeLog.pcmf_log("ug2t", "remove obj: " + this.pcmf_getObjName(),
1164:                // this, KeLog.DEBUG);
1165:
1166:                this .pem_myThread = null;
1167:                return (actx.pcmf_removeByName(this .pem_objName));
1168:            };
1169:
1170:            /**
1171:             * For internal use only
1172:             */
1173:            public static final Object pcmf_unRegister(Object xObj) {
1174:                if (xObj instanceof  KeRegisteredObject)
1175:                    return (((KeRegisteredObject) xObj).pcmf_unRegister());
1176:
1177:                KeObjectStorage actx = (KeObjectStorage) pem_allObj.get(xObj);
1178:                // Ist nicht mehr vorhanden
1179:                if (actx == null)
1180:                    return (null);
1181:
1182:                // KeLog.pcmf_log("ug2t", "remove obj: " + xObj, null,
1183:                // KeLog.DEBUG);
1184:
1185:                pem_allObj.remove(xObj);
1186:                actx.pcmf_removeByObj(xObj);
1187:
1188:                actx.pdmf_execUnRegListeners(xObj);
1189:
1190:                return (xObj);
1191:            };
1192:
1193:            /**
1194:             * For internal use only
1195:             */
1196:            public final void pcmf_registerGlobal2NewName(String xName) {
1197:                this .pcmf_unRegister();
1198:                this .pcmf_registerGlobal(xName);
1199:
1200:                return;
1201:            };
1202:
1203:            /**
1204:             * For internal use only
1205:             */
1206:            public final void pcmf_register2NewName(String xName) {
1207:                this .pcmf_unRegister();
1208:                this .pcmf_register(xName);
1209:
1210:                return;
1211:            };
1212:
1213:            public final static void pcmf_removeContext(String xName) {
1214:                if (xName == null)
1215:                    xName = Thread.currentThread().getName();
1216:
1217:                KeObjectStorage actx = (KeObjectStorage) pem_context
1218:                        .remove(xName);
1219:                if (actx == null)
1220:                    KeLog.pcmf_log("ug2t", "cannot remove thread context: "
1221:                            + xName, null, KeLog.ERROR);
1222:            }
1223:
1224:            /**
1225:             * For internal use only
1226:             */
1227:            public final static void pcmf_deleteContext(String xName) {
1228:                if (xName == null)
1229:                    xName = Thread.currentThread().getName();
1230:
1231:                KeLog.pcmf_log("ug2t",
1232:                        "try to remove thread context: " + xName, null,
1233:                        KeLog.MESSAGE);
1234:
1235:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xName);
1236:                if (actx == null) {
1237:                    KeLog.pcmf_log("ug2t", "cannot remove thread context: "
1238:                            + xName, null, KeLog.ERROR);
1239:                    return;
1240:                }
1241:                Iterator l_it = actx.pcmf_getNameValues().iterator();
1242:                Object l_obj = null;
1243:                int i_cnt = 0;
1244:                ArrayList l_nDel = new ArrayList(1000);
1245:
1246:                // @@
1247:
1248:                {
1249:                    while (l_it.hasNext()) {
1250:                        i_cnt++;
1251:                        l_obj = l_it.next();
1252:                        if (l_obj instanceof  KeRegisteredObject) {
1253:                            try {
1254:                                KeRegisteredObject l_robj = (KeRegisteredObject) l_obj;
1255:                                l_robj.pcmf_delete();
1256:
1257:                                if (l_robj.pdm_deleted == false) {
1258:                                    // Hier zuerst mal wegspeichen und nach komplettem lauf prüfen!!
1259:                                    l_nDel.add(l_obj);
1260:                                }
1261:                            } catch (Exception e) {
1262:                                KeLog.pcmf_log("ug2t",
1263:                                        "error during session clenaup", null,
1264:                                        KeLog.ERROR);
1265:                                KeLog.pcmf_logException("ug2t", null, e);
1266:                            }
1267:                        } else
1268:                            KeRegisteredObject.pcmf_unRegister(l_obj);
1269:                    }
1270:                    ;
1271:
1272:                    l_it = l_nDel.iterator();
1273:                    KeRegisteredObject l_att = null;
1274:
1275:                    while (l_it.hasNext()) {
1276:                        l_att = (KeRegisteredObject) l_it.next();
1277:
1278:                        if (l_att.pdm_deleted == false) {
1279:                            if (l_att instanceof  IKeAttachable)
1280:                                ((IKeAttachable) l_att).pcmf_forceDetach();
1281:
1282:                            try {
1283:                                l_att.pcmf_delete();
1284:                            } catch (Exception e) {
1285:                                KeLog
1286:                                        .pcmf_log(
1287:                                                "ug2t",
1288:                                                "error during session clenaup (forced remove of attached object)",
1289:                                                null, KeLog.ERROR);
1290:                                KeLog.pcmf_logException("ug2t", null, e);
1291:                            }
1292:
1293:                            if (l_att.pdm_deleted == false) {
1294:                                KeLog
1295:                                        .pcmf_log(
1296:                                                "ug2t",
1297:                                                "attached object: ["
1298:                                                        + l_att
1299:                                                                .pcmf_getObjName()
1300:                                                        + ":"
1301:                                                        + l_att.getClass()
1302:                                                                .toString()
1303:                                                        + "] could not be removed during session cleanup, termination forced on server side - maybe memory leak on client side.",
1304:                                                null, KeLog.FATAL);
1305:                                l_att.pcmf_unRegister();
1306:                                l_att.pdm_deleted = true;
1307:                            }
1308:                        }
1309:                    }
1310:                }
1311:                pem_context.remove(xName);
1312:                KeLog.pcmf_log("ug2t", "removed " + Integer.toString(i_cnt)
1313:                        + " objects from thread context: " + xName, null,
1314:                        KeLog.MESSAGE);
1315:
1316:                // Debug
1317:                // @@
1318:
1319:            };
1320:
1321:            /**
1322:             * For internal use only
1323:             */
1324:            public final static Object pcmf_getLocalOrRemoteObjByName(
1325:                    String xName) {
1326:                Object l_ret = null;
1327:                String l_shortName = xName;
1328:
1329:                xName = KeRegisteredObject.pem_prefix + xName;
1330:                String tname = Thread.currentThread().getName();
1331:
1332:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1333:                if (actx == null)
1334:                    return (null);
1335:
1336:                l_ret = actx.pcmf_getByName(xName);
1337:
1338:                if (l_ret == null) {
1339:                    String xTName = (String) actx.pcmf_getRemName(l_shortName);
1340:                    if (xTName != null)
1341:                        l_ret = actx
1342:                                .pcmf_getByName(KeRegisteredObject.pem_prefix
1343:                                        + xTName);
1344:                }
1345:                ;
1346:
1347:                return (l_ret);
1348:            }
1349:
1350:            /**
1351:             * For internal use only
1352:             */
1353:            public final static Object pcmf_getLocalObjByName(String xName) {
1354:                Object l_ret = null;
1355:
1356:                xName = KeRegisteredObject.pem_prefix + xName;
1357:                String tname = Thread.currentThread().getName();
1358:
1359:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1360:                if (actx == null)
1361:                    return (null);
1362:
1363:                l_ret = actx.pcmf_getByName(xName);
1364:
1365:                return (l_ret);
1366:            }
1367:
1368:            /**
1369:             * <p>
1370:             * Gets an object which is identified by its unique name. The namespace of the
1371:             * currently running thread is searched through first. If the name does not
1372:             * exist there the sub threads and the global namespace is scanned as well.
1373:             * </p>
1374:             * <p>
1375:             * 
1376:             * </p>
1377:             * <p>
1378:             * 
1379:             * @param xName
1380:             *          unique name
1381:             * @return object
1382:             *         </p>
1383:             */
1384:            public final static Object pcmf_getObjByName(String xName) {
1385:                Object l_ret = null;
1386:                String l_shortName = xName;
1387:
1388:                xName = KeRegisteredObject.pem_prefix + xName;
1389:                String tname = Thread.currentThread().getName();
1390:
1391:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1392:                if (actx != null) {
1393:                    l_ret = actx.pcmf_getByName(xName);
1394:
1395:                    if (l_ret == null) {
1396:                        String xTName = (String) actx
1397:                                .pcmf_getRemName(l_shortName);
1398:                        if (xTName != null)
1399:                            l_ret = actx
1400:                                    .pcmf_getByName(KeRegisteredObject.pem_prefix
1401:                                            + xTName);
1402:                    }
1403:                    ;
1404:
1405:                    if (l_ret == null
1406:                            && Thread.currentThread() instanceof  KeNameSpaceThread
1407:                            && ((KeNameSpaceThread) Thread.currentThread())
1408:                                    .pcmf_getSubThreadCount() != 0) {
1409:                        Iterator l_it = ((KeNameSpaceThread) Thread
1410:                                .currentThread()).pcmf_getSubThreadIt();
1411:                        KeObjectStorage actx2;
1412:                        while (l_it.hasNext()) {
1413:                            actx2 = (KeObjectStorage) pem_context
1414:                                    .get(((Thread) l_it.next()).getName());
1415:                            if (actx2 == null)
1416:                                continue;
1417:
1418:                            l_ret = actx2.pcmf_getByName(xName);
1419:
1420:                            if (l_ret == null) {
1421:                                String xTName = (String) actx2
1422:                                        .pcmf_getRemName(l_shortName);
1423:                                if (xTName != null)
1424:                                    l_ret = actx2
1425:                                            .pcmf_getByName(KeRegisteredObject.pem_prefix
1426:                                                    + xTName);
1427:                            }
1428:                            ;
1429:                            if (l_ret != null)
1430:                                return (l_ret);
1431:                        }
1432:                    }
1433:                }
1434:                if (l_ret == null)
1435:                    l_ret = KeRegisteredObject
1436:                            .pcmf_getGlobalObjByName(l_shortName);
1437:
1438:                return (l_ret);
1439:            };
1440:
1441:            /**
1442:             * <p>
1443:             * Broadcasts a message to all contexts and returns a list which contains the
1444:             * context IDs
1445:             * </p>
1446:             * <p>
1447:             * 
1448:             * </p>
1449:             * <p>
1450:             * 
1451:             * @param xMess
1452:             *          message to send
1453:             * @return list of receiving contexts
1454:             *         </p>
1455:             */
1456:            public static ArrayList pcmf_broadcastMessage(KeIPCMessage xMess) {
1457:                String tname = Thread.currentThread().getName();
1458:                xMess.pdm_senderCtxID = tname;
1459:
1460:                ArrayList l_list = new ArrayList();
1461:                Iterator l_it = new ArrayList(KeRegisteredObject.pem_context
1462:                        .keySet()).iterator();
1463:                while (l_it.hasNext()) {
1464:                    String l_ctxn = (String) l_it.next();
1465:                    KeObjectStorage l_ctx = (KeObjectStorage) KeRegisteredObject.pem_context
1466:                            .get(l_ctxn);
1467:                    if (l_ctx != null) {
1468:                        l_list.add(l_ctxn);
1469:                        l_ctx.pdmf_pushMessage(xMess);
1470:                    }
1471:                }
1472:                return (l_list);
1473:            }
1474:
1475:            /**
1476:             * <p>
1477:             * Clears all messageboxes
1478:             * </p>
1479:             */
1480:            public static void pcmf_clearAllMessages() {
1481:                String tname = Thread.currentThread().getName();
1482:
1483:                Iterator l_it = new ArrayList(KeRegisteredObject.pem_context
1484:                        .keySet()).iterator();
1485:                while (l_it.hasNext()) {
1486:                    String l_ctxn = (String) l_it.next();
1487:                    KeObjectStorage l_ctx = (KeObjectStorage) KeRegisteredObject.pem_context
1488:                            .get(l_ctxn);
1489:                    if (l_ctx != null)
1490:                        l_ctx.pdmf_clearMessages();
1491:                }
1492:                return;
1493:            }
1494:
1495:            /**
1496:             * <p>
1497:             * Pushs a message to one singe context
1498:             * </p>
1499:             * <p>
1500:             * 
1501:             * </p>
1502:             * <p>
1503:             * 
1504:             * @param xCtx
1505:             *          context ID
1506:             * @param xMess
1507:             *          message to send
1508:             *          </p>
1509:             */
1510:            public static void pcmf_pushMessage(String xCtx, KeIPCMessage xMess) {
1511:                String tname = Thread.currentThread().getName();
1512:                xMess.pdm_senderCtxID = tname;
1513:
1514:                KeObjectStorage l_ctx = (KeObjectStorage) KeRegisteredObject.pem_context
1515:                        .get(xCtx);
1516:                if (l_ctx != null)
1517:                    l_ctx.pdmf_pushMessage(xMess);
1518:            }
1519:
1520:            /**
1521:             * <p>
1522:             * Clears a specific message box
1523:             * </p>
1524:             * <p>
1525:             * 
1526:             * </p>
1527:             * <p>
1528:             * 
1529:             * @param xCtx
1530:             *          context ID
1531:             *          </p>
1532:             */
1533:            public static void pcmf_clearMessages(String xCtx) {
1534:                KeObjectStorage l_ctx = (KeObjectStorage) KeRegisteredObject.pem_context
1535:                        .get(xCtx);
1536:                if (l_ctx != null)
1537:                    l_ctx.pdmf_clearMessages();
1538:            }
1539:
1540:            /**
1541:             * <p>
1542:             * Clears message box
1543:             * </p>
1544:             * <p>
1545:             * 
1546:             * </p>
1547:             * <p>
1548:             * 
1549:             * @param xCtx
1550:             *          context ID
1551:             *          </p>
1552:             */
1553:            public static void pcmf_clearMessages() {
1554:                String tname = Thread.currentThread().getName();
1555:
1556:                KeObjectStorage l_ctx = (KeObjectStorage) KeRegisteredObject.pem_context
1557:                        .get(tname);
1558:                if (l_ctx != null)
1559:                    l_ctx.pdmf_clearMessages();
1560:            }
1561:
1562:            /**
1563:             * <p>
1564:             * Gets a message from the current context's message list
1565:             * </p>
1566:             * <p>
1567:             * 
1568:             * </p>
1569:             * <p>
1570:             * 
1571:             * @return message or null if list is empty
1572:             *         </p>
1573:             */
1574:            public static KeIPCMessage pcmf_getMessage() {
1575:                String tname = Thread.currentThread().getName();
1576:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1577:                return (actx.pdmf_getMessage());
1578:            }
1579:
1580:            /**
1581:             * <p>
1582:             * Gets an object which is identified by its unique name from the given
1583:             * context.
1584:             * </p>
1585:             * <p>
1586:             * 
1587:             * </p>
1588:             * <p>
1589:             * 
1590:             * @param xName
1591:             *          unique name
1592:             * @param xCtx
1593:             *          contect ID
1594:             * @return object
1595:             *         </p>
1596:             */
1597:            public final static Object pcmf_getObjByName(String xName,
1598:                    String xCtx) {
1599:                Object l_ret = null;
1600:                String l_shortName = xName;
1601:
1602:                xName = KeRegisteredObject.pem_prefix + xName;
1603:
1604:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(xCtx);
1605:                if (actx != null) {
1606:                    l_ret = actx.pcmf_getByName(xName);
1607:
1608:                    if (l_ret == null) {
1609:                        String xTName = (String) actx
1610:                                .pcmf_getRemName(l_shortName);
1611:                        if (xTName != null)
1612:                            l_ret = actx
1613:                                    .pcmf_getByName(KeRegisteredObject.pem_prefix
1614:                                            + xTName);
1615:                    }
1616:                    ;
1617:                }
1618:                return (l_ret);
1619:            };
1620:
1621:            /**
1622:             * <p>
1623:             * Gets hte ID of the current context
1624:             * </p>
1625:             * <p>
1626:             * 
1627:             * </p>
1628:             * <p>
1629:             * 
1630:             * @return contect ID
1631:             *         </p>
1632:             */
1633:            public static String pcmf_getCurrentContextID() {
1634:                return (Thread.currentThread().getName());
1635:            }
1636:
1637:            /**
1638:             * For internal use only
1639:             */
1640:            public static synchronized ArrayList pcmf_getAllContextIDs() {
1641:                return (new ArrayList(pem_context.keySet()));
1642:            }
1643:
1644:            /**
1645:             * For internal use only
1646:             */
1647:            public final static Object pcmf_getGlobalObjByName(String xName) {
1648:                xName = KeRegisteredObject.pem_prefix + xName;
1649:                String tname = KeRegisteredObject.GLOBAL;
1650:                Object l_ret = null;
1651:
1652:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1653:                if (actx == null)
1654:                    return (null);
1655:
1656:                l_ret = actx.pcmf_getByName(xName);
1657:
1658:                if (l_ret == null) {
1659:                    xName = (String) actx.pcmf_getRemName(xName);
1660:                    if (xName != null)
1661:                        l_ret = actx
1662:                                .pcmf_getByName(KeRegisteredObject.pem_prefix
1663:                                        + xName);
1664:                }
1665:                ;
1666:
1667:                return (l_ret);
1668:            };
1669:
1670:            /**
1671:             * For internal use only
1672:             */
1673:            public final static Object pcmf_getObjByLongName(String xName) {
1674:                String tname = Thread.currentThread().getName();
1675:
1676:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1677:                if (actx == null)
1678:                    return (null);
1679:
1680:                Object l_ret = actx.pcmf_getByName(xName);
1681:
1682:                if (l_ret == null
1683:                        && Thread.currentThread() instanceof  KeNameSpaceThread) {
1684:                    Iterator l_it = ((KeNameSpaceThread) Thread.currentThread())
1685:                            .pcmf_getSubThreadIt();
1686:                    KeObjectStorage actx2;
1687:                    while (l_it.hasNext()) {
1688:                        actx2 = (KeObjectStorage) pem_context
1689:                                .get(((Thread) l_it.next()).getName());
1690:                        if (actx2 == null)
1691:                            continue;
1692:
1693:                        l_ret = actx2.pcmf_getByName(xName);
1694:                        if (l_ret != null)
1695:                            return (l_ret);
1696:                    }
1697:                }
1698:                return (l_ret);
1699:            };
1700:
1701:            /**
1702:             * For internal use only
1703:             */
1704:            public final static Object pcmf_getGlobalObjByLongName(String xName) {
1705:                String tname = KeRegisteredObject.GLOBAL;
1706:
1707:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(tname);
1708:                if (actx == null)
1709:                    return (null);
1710:
1711:                return (actx.pcmf_getByName(xName));
1712:            };
1713:
1714:            /**
1715:             * For internal use only
1716:             */
1717:            public final void pcmf_setRemName(String xRemName) {
1718:                this .pem_objRemName = xRemName;
1719:
1720:                return;
1721:            };
1722:
1723:            /**
1724:             * For internal use only
1725:             */
1726:            public final String pcmf_getRemName() {
1727:                return (this .pem_objRemName);
1728:            };
1729:
1730:            /**
1731:             * For internal use only
1732:             */
1733:            public static String pcmf_filterShortName(String xName) {
1734:                KeStringWrapper l_str = new KeStringWrapper(xName);
1735:                return (KeTools.pcmf_stringCutParam(l_str,
1736:                        KeRegisteredObject.NAMESEP));
1737:            };
1738:
1739:            // Finalize kann nur nach unregister bzw delete kommen !!
1740:            // public void finalize()
1741:            // {
1742:            // KeLog.pcmf_log("ug2t", "finalize object: " + pem_objName, this,
1743:            // KeLog.DEBUG);
1744:            //
1745:            // if (this.pem_objRemName != null)
1746:            // {
1747:            // pem_myThread.pcmf_getRemNames().remove(this.pem_objRemName);
1748:            // this.pem_objRemName = null;
1749:            // };
1750:            //
1751:            // return;
1752:            // };
1753:
1754:            /**
1755:             * For internal use only
1756:             */
1757:            public final void pcmf_resetRemoteName() {
1758:                if (this .pem_objRemName == null)
1759:                    return;
1760:
1761:                String tname = Thread.currentThread().getName();
1762:
1763:                KeObjectStorage actx = this .pem_myThread;
1764:                if (actx == null) {
1765:                    actx = (KeObjectStorage) pem_context.get(tname);
1766:                    if (actx == null) {
1767:                        KeLog.pcmf_log("ug2t", "can not remove remote name "
1768:                                + this .pem_objRemName, this , KeLog.ERROR);
1769:                        return;
1770:                    }
1771:                    ;
1772:                }
1773:                ;
1774:
1775:                actx.pcmf_removeRemName(this .pem_objRemName);
1776:                this .pem_objRemName = null;
1777:            };
1778:
1779:            /**
1780:             * For internal use only
1781:             */
1782:            public void pcmf_reRegister(String xName) {
1783:                this .pcmf_unRegister();
1784:                this .pcmf_register(xName);
1785:
1786:                return;
1787:            };
1788:
1789:            // @@
1790:
1791:            /**
1792:             * For internal use only
1793:             */
1794:            public String pcmf_getUniqueName() {
1795:                return (Thread.currentThread().getName() + this 
1796:                        .pcmf_getObjLongName());
1797:            };
1798:
1799:            /**
1800:             * For internal use only
1801:             */
1802:            public static synchronized String pcmf_getRegistryStatisticString(
1803:                    boolean xSeparateClasses) {
1804:                String l_ret = "";
1805:
1806:                l_ret += "\n==================================================================";
1807:                l_ret += "\nSystem Information";
1808:                l_ret += "\n==================================================================";
1809:                l_ret += "\nProcessors:  "
1810:                        + Runtime.getRuntime().availableProcessors();
1811:                Runtime.getRuntime().gc();
1812:                l_ret += "\nTotal Memory: "
1813:                        + Runtime.getRuntime().totalMemory();
1814:                l_ret += "\nMax. Memory:  " + Runtime.getRuntime().maxMemory();
1815:                l_ret += "\nFree Memory:  " + Runtime.getRuntime().freeMemory();
1816:                l_ret += "\nUsed Memory:  "
1817:                        + (Runtime.getRuntime().totalMemory() - Runtime
1818:                                .getRuntime().freeMemory());
1819:                l_ret += "\n==================================================================";
1820:                l_ret += "\nRegistry Statictics";
1821:                l_ret += "\n==================================================================";
1822:                l_ret += "\ntotal fw obj count:     "
1823:                        + KeRegisteredObject.pcmf_getTotalObjectCount();
1824:                l_ret += "\ntotal non fw obj count: "
1825:                        + KeRegisteredObject.pem_allObj.size();
1826:                l_ret += "\nthread count:           "
1827:                        + KeRegisteredObject.pem_context.size();
1828:                l_ret += "\n------------------------------------------------------------------";
1829:
1830:                Iterator l_it = pem_context.keySet().iterator();
1831:                String l_tname = null;
1832:                while (l_it.hasNext()) {
1833:                    l_tname = (String) l_it.next();
1834:                    l_ret += "\n+ thread: "
1835:                            + l_tname
1836:                            + ",\n"
1837:                            + "   - "
1838:                            + ((KeObjectStorage) pem_context.get(l_tname))
1839:                                    .pcmf_getStorageStaticticString();
1840:                    if (xSeparateClasses)
1841:                        l_ret += ((KeObjectStorage) pem_context.get(l_tname))
1842:                                .pcmf_getStorageStaticByClassString();
1843:
1844:                }
1845:
1846:                l_ret += "\n==================================================================";
1847:
1848:                // l_it = KeRegisteredObject.pem_allObj.keySet().iterator();
1849:                // while (l_it.hasNext())
1850:                // System.out.println(l_it.next().getClass());
1851:
1852:                return (l_ret);
1853:            }
1854:
1855:            /**
1856:             * For internal use only
1857:             */
1858:            public static synchronized int pcmf_getTotalObjectCount() {
1859:                Iterator l_it = pem_context.values().iterator();
1860:                KeObjectStorage l_st = null;
1861:                int l_ret = 0;
1862:
1863:                while (l_it.hasNext()) {
1864:                    l_st = (KeObjectStorage) l_it.next();
1865:                    l_ret = l_ret + l_st.pcmf_getObjectCount();
1866:                }
1867:                l_ret += KeRegisteredObject.pem_allObj.size();
1868:                return (l_ret);
1869:            }
1870:
1871:            /**
1872:             * For internal use only
1873:             */
1874:            public boolean pcmf_isRemoted() {
1875:                return (this .pem_objRemName == null ? false : true);
1876:            };
1877:
1878:            /*
1879:             * (non-Javadoc)
1880:             * 
1881:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_isDeleted()
1882:             */
1883:            public boolean pcmf_isDeleted() {
1884:                return (this .pdm_deleted);
1885:            };
1886:
1887:            /**
1888:             * Returns the current version
1889:             */
1890:            public static String pcmf_getVersion() {
1891:                String l_ret = "WidgetServer LGPL Release " + "1.8.1";
1892:                // @@
1893:                return (l_ret);
1894:            }
1895:
1896:            /**
1897:             * Returns true for the commercial release
1898:             */
1899:            public static boolean pcmf_getEnhanced() {
1900:                boolean l_ret = false;
1901:                // @@
1902:                return (l_ret);
1903:            }
1904:
1905:            /*
1906:             * (non-Javadoc)
1907:             * 
1908:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_setEarlyAutoDelete(boolean)
1909:             */
1910:            public void pcmf_setEarlyAutoDelete(boolean xWR) {
1911:                if (this .pem_myThread == null)
1912:                    return;
1913:
1914:                if (xWR)
1915:                    this .pem_myThread.pcmf_putToName(this .pem_objName,
1916:                            new WeakReference(this ));
1917:                else
1918:                    this .pem_myThread.pcmf_putToName(this .pem_objName, this );
1919:            }
1920:
1921:            /*
1922:             * (non-Javadoc)
1923:             * 
1924:             * @see de.ug2t.kernel.IKeRegisteredObject#pcmf_setLateAutoDelete(boolean)
1925:             */
1926:            public void pcmf_setLateAutoDelete(boolean xWR) {
1927:                if (this .pem_myThread == null)
1928:                    return;
1929:
1930:                if (xWR)
1931:                    this .pem_myThread.pcmf_putToName(this .pem_objName,
1932:                            new SoftReference(this ));
1933:                else
1934:                    this .pem_myThread.pcmf_putToName(this .pem_objName, this );
1935:            }
1936:
1937:            /**
1938:             * For internal use only
1939:             */
1940:            public static ArrayList pcmf_getAllAutoDeletes() {
1941:                KeObjectStorage actx = (KeObjectStorage) pem_context.get(Thread
1942:                        .currentThread().getName());
1943:                return (actx.pcmf_getAllAutoDeletes());
1944:            }
1945:
1946:            /**
1947:             * <p>
1948:             * Sets a context to AUTO_DELETE_DISABLED, AUTO_DELETE_EARLY or
1949:             * AUTO_DELETE_LATE. That means that the objects createtd in this context are
1950:             * either removed by the garbage collector as soon as they are not referenced,
1951:             * removed by the garbage collector when memory is low or not removed by the
1952:             * garbage collector.
1953:             * </p>
1954:             * <p>
1955:             * 
1956:             * </p>
1957:             * <p>
1958:             * 
1959:             * @param xAutoDelete
1960:             *          delete behaviour
1961:             *          </p>
1962:             */
1963:            public static void pcmf_setContextAutoDelete(int xAutoDelete) {
1964:                KeObjectStorage actx = KeRegisteredObject
1965:                        .pemf_createThreadContext();
1966:                actx.pcmf_setAutoDelete(xAutoDelete);
1967:            }
1968:
1969:            /**
1970:             * For internal use only
1971:             */
1972:            public static KeObjectStorage pcmf_getCurrentContext() {
1973:                return (KeObjectStorage) pem_context.get(Thread.currentThread()
1974:                        .getName());
1975:            }
1976:
1977:            /**
1978:             * For internal use only
1979:             */
1980:            public static String pcmf_setCurrentContextID(String xName) {
1981:                String l_ret = Thread.currentThread().getName();
1982:                Thread.currentThread().setName(xName);
1983:                return (l_ret);
1984:            }
1985:
1986:            // @@
1987:
1988:            public void finalize() throws Throwable {
1989:                // pcmf_decInst();
1990:                if (!this.pdm_deleted)
1991:                    this.pcmf_delete();
1992:
1993:                super.finalize();
1994:            }
1995:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.