Source Code Cross Referenced for ElementInfoBuilder.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003:         * Distributed under the terms of either:
0004:         * - the common development and distribution license (CDDL), v1.0; or
0005:         * - the GNU Lesser General Public License, v2.1 or later
0006:         * $Id: ElementInfoBuilder.java 3701 2007-03-18 12:24:23Z gbevin $
0007:         */
0008:        package com.uwyn.rife.engine;
0009:
0010:        import com.uwyn.rife.engine.exceptions.*;
0011:        import java.util.*;
0012:
0013:        import com.uwyn.rife.ioc.PropertyValue;
0014:        import com.uwyn.rife.ioc.PropertyValueObject;
0015:        import com.uwyn.rife.resources.ResourceFinder;
0016:        import com.uwyn.rife.site.Constrained;
0017:        import com.uwyn.rife.site.ConstrainedUtils;
0018:        import com.uwyn.rife.site.ValidatedConstrained;
0019:        import com.uwyn.rife.site.ValidationGroup;
0020:        import com.uwyn.rife.tools.BeanUtils;
0021:        import com.uwyn.rife.tools.JavaSpecificationUtils;
0022:        import com.uwyn.rife.tools.Localization;
0023:        import com.uwyn.rife.tools.exceptions.BeanUtilsException;
0024:
0025:        public class ElementInfoBuilder {
0026:            private SiteBuilder mSiteBuilder = null;
0027:            private ResourceFinder mResourceFinder = null;
0028:
0029:            private ElementDeclaration mDeclaration = null;
0030:
0031:            private String mProcessorIdentifier = null;
0032:            private String mExtendsFrom = null;
0033:            private String mContentType = null;
0034:            private String mImplementation = null;
0035:            private Element mImplementationBlueprint = null;
0036:            private String mInherits = null;
0037:            private String mPre = null;
0038:            private ArrayList<DataLinkDeclaration> mDataLinks = null;
0039:            private ArrayList<FlowLinkDeclaration> mFlowLinks = null;
0040:            private ArrayList<AutoLinkDeclaration> mAutoLinks = null;
0041:            private LinkedHashMap<BeanDeclaration, String> mInbeans = null;
0042:            private LinkedHashMap<BeanDeclaration, String> mOutbeans = null;
0043:            private LinkedHashMap<String, PropertyValue> mStaticProperties = null;
0044:            private LinkedHashMap<String, String[]> mInputs = null;
0045:            private LinkedHashMap<String, String[]> mOutputs = null;
0046:            private LinkedHashMap<String, String> mIncookies = null;
0047:            private LinkedHashMap<String, String> mOutcookies = null;
0048:            private ArrayList<String> mExits = null;
0049:            private ArrayList<String> mChildTriggers = null;
0050:            private ArrayList<SubmissionBuilder> mSubmissionBuilders = null;
0051:            private PathInfoMode mPathInfoMode = null;
0052:            private List<PathInfoMapping> mPathInfoMappings = null;
0053:
0054:            ElementInfoBuilder(SiteBuilder siteBuilder,
0055:                    ResourceFinder resourceFinder,
0056:                    ElementDeclaration declaration) {
0057:                assert siteBuilder != null;
0058:                assert resourceFinder != null;
0059:
0060:                mSiteBuilder = siteBuilder;
0061:                mResourceFinder = resourceFinder;
0062:                mDeclaration = declaration;
0063:
0064:                return;
0065:            }
0066:
0067:            void process() {
0068:                if (JavaSpecificationUtils.isAtLeastJdk15()
0069:                        && null == mExtendsFrom) {
0070:                    // handle auto declaration generation for annotation element info processors
0071:                    if (null == mDeclaration.getDeclarationName()) {
0072:                        if (AnnotationsElementDetector
0073:                                .hasElementAnnotation(mImplementation)) {
0074:                            mDeclaration
0075:                                    .setDeclarationName(ElementInfoProcessorFactory.ANNOTATIONS_IDENTIFIER
0076:                                            + ":" + mImplementation);
0077:                        }
0078:                    }
0079:                    // handle auto implementation generation for annotation element info processors
0080:                    else if (null == mImplementation
0081:                            && mDeclaration.getDeclarationName() != null) {
0082:                        String declaration = mDeclaration.getDeclarationName();
0083:                        int identifier_index = declaration.indexOf(":");
0084:                        if (identifier_index != -1) {
0085:                            mImplementation = declaration
0086:                                    .substring(identifier_index + 1);
0087:                        }
0088:                    }
0089:                }
0090:
0091:                process(mDeclaration.getDeclarationName());
0092:            }
0093:
0094:            void process(String declarationName) {
0095:                if (null == declarationName) {
0096:                    throw new ElementDeclarationNameMissingException(
0097:                            mSiteBuilder.getDeclarationName(), mDeclaration
0098:                                    .getId(), mDeclaration.getUrl(),
0099:                            mImplementation, null);
0100:                }
0101:
0102:                String declaration_name_part = declarationName;
0103:                ElementInfoProcessorFactory processor_factory = null;
0104:
0105:                String identifier = ElementInfoProcessorFactory.MANUAL_IDENTIFIER;
0106:                int identifier_index = declarationName.indexOf(":");
0107:                int extension_index = declarationName.lastIndexOf(".");
0108:                if (identifier_index != -1) {
0109:                    identifier = declarationName.substring(0, identifier_index);
0110:                    declaration_name_part = declarationName
0111:                            .substring(identifier_index + 1);
0112:
0113:                    processor_factory = ElementInfoProcessorFactory
0114:                            .getElementInfoProcessorFactory(identifier);
0115:                } else if (extension_index != -1) {
0116:                    String extension = declarationName
0117:                            .substring(extension_index + 1);
0118:                    Collection<ElementInfoProcessorFactory> factories = ElementInfoProcessorFactory
0119:                            .getElementInfoProcessorFactories();
0120:                    for (ElementInfoProcessorFactory factory : factories) {
0121:                        if (factory.getExtension() != null
0122:                                && factory.getExtension().equals(extension)) {
0123:                            processor_factory = factory;
0124:                            break;
0125:                        }
0126:                    }
0127:
0128:                    if (null == processor_factory) {
0129:                        throw new ElementInfoProcessorExtensionUnsupportedException(
0130:                                declarationName, extension);
0131:                    }
0132:                } else {
0133:                    processor_factory = ElementInfoProcessorFactory
0134:                            .getElementInfoProcessorFactory(identifier);
0135:                }
0136:
0137:                if (null == processor_factory) {
0138:                    throw new ElementInfoProcessorIdentifierUnsupportedException(
0139:                            declarationName, identifier);
0140:                }
0141:
0142:                mProcessorIdentifier = processor_factory.getIdentifier();
0143:
0144:                // process the element definition
0145:                ElementInfoProcessor processor = processor_factory
0146:                        .getProcessor();
0147:                if (processor != null) {
0148:                    processor.processElementInfo(this , declaration_name_part,
0149:                            mResourceFinder);
0150:                }
0151:            }
0152:
0153:            ElementInfo createElementInfo(
0154:                    LinkedHashMap<String, GlobalExit> globalExits,
0155:                    LinkedHashMap<String, GlobalVar> globalVars,
0156:                    LinkedHashMap<String, String> globalCookies,
0157:                    LinkedHashMap<String, BeanDeclaration> namedGlobalBeans) {
0158:                ElementInfo element_info = new ElementInfo();
0159:
0160:                element_info.setProcessorIdentifier(mProcessorIdentifier);
0161:
0162:                if (mDeclaration != null) {
0163:                    element_info.setDeclarationName(mDeclaration
0164:                            .getDeclarationName());
0165:                }
0166:
0167:                element_info.setGlobalExits(globalExits);
0168:                element_info.setGlobalVars(globalVars);
0169:                element_info.setGlobalCookies(globalCookies);
0170:                element_info.setNamedGlobalBeans(namedGlobalBeans);
0171:
0172:                if (mExtendsFrom != null) {
0173:                    ElementInfoBuilder builder = new ElementInfoBuilder(
0174:                            mSiteBuilder, mResourceFinder, null);
0175:                    builder.process(mExtendsFrom);
0176:                    ElementInfo extended_element_info = builder
0177:                            .createElementInfo(globalExits, globalVars,
0178:                                    globalCookies, namedGlobalBeans);
0179:                    extended_element_info.getDeclarationName();
0180:
0181:                    // instantiate the current element info by taking all the properties from the class it extends from
0182:                    element_info.extendFrom(extended_element_info);
0183:                }
0184:
0185:                element_info.setContentType(mContentType);
0186:
0187:                if (mImplementation != null) {
0188:                    element_info.setImplementation(mImplementation,
0189:                            mImplementationBlueprint);
0190:                }
0191:
0192:                if (mInherits != null) {
0193:                    mInherits = mSiteBuilder.makeAbsoluteElementId(mInherits);
0194:                    mInherits = Site.getCanonicalId(mInherits);
0195:
0196:                    mDeclaration.setInherits(mInherits);
0197:                }
0198:
0199:                if (mPre != null) {
0200:                    mPre = mSiteBuilder.makeAbsoluteElementId(mPre);
0201:                    mPre = Site.getCanonicalId(mPre);
0202:
0203:                    mDeclaration.setPre(mPre);
0204:                }
0205:
0206:                registerFlowAndDataLinksInSite(null);
0207:
0208:                if (mAutoLinks != null) {
0209:                    for (AutoLinkDeclaration autolink : mAutoLinks) {
0210:                        autolink.makeAbsoluteDestId(mSiteBuilder);
0211:                        mSiteBuilder
0212:                                .addAutoLink(mDeclaration.getId(), autolink);
0213:                    }
0214:                }
0215:
0216:                if (mInbeans != null) {
0217:                    String name = null;
0218:                    BeanDeclaration declaration = null;
0219:                    for (Map.Entry<BeanDeclaration, String> inbean : mInbeans
0220:                            .entrySet()) {
0221:                        name = inbean.getValue();
0222:                        declaration = inbean.getKey();
0223:                        try {
0224:                            Class bean_class = declaration.getBeanClass();
0225:
0226:                            if (name != null) {
0227:                                element_info.addNamedInbean(name, declaration);
0228:                            }
0229:
0230:                            try {
0231:                                Object instance = bean_class.newInstance();
0232:                                Constrained constrained = ConstrainedUtils
0233:                                        .makeConstrainedInstance(instance);
0234:                                Set<String> properties;
0235:                                if (declaration.getGroupName() != null) {
0236:                                    if (!(instance instanceof  ValidatedConstrained)) {
0237:                                        throw new InbeanGroupRequiresValidatedConstrainedException(
0238:                                                mDeclaration
0239:                                                        .getDeclarationName(),
0240:                                                declaration.getClassname(),
0241:                                                declaration.getGroupName());
0242:                                    }
0243:
0244:                                    ValidatedConstrained validation = (ValidatedConstrained) instance;
0245:                                    ValidationGroup group = validation
0246:                                            .getGroup(declaration
0247:                                                    .getGroupName());
0248:                                    if (null == group) {
0249:                                        throw new InbeanGroupNotFoundException(
0250:                                                mDeclaration
0251:                                                        .getDeclarationName(),
0252:                                                declaration.getClassname(),
0253:                                                declaration.getGroupName());
0254:                                    }
0255:                                    properties = new TreeSet<String>();
0256:                                    if (null == declaration.getPrefix()) {
0257:                                        properties.addAll(group
0258:                                                .getPropertyNames());
0259:                                    } else {
0260:                                        for (String property_name : (List<String>) group
0261:                                                .getPropertyNames()) {
0262:                                            properties.add(declaration
0263:                                                    .getPrefix()
0264:                                                    + property_name);
0265:                                        }
0266:                                    }
0267:                                } else {
0268:                                    properties = BeanUtils.getPropertyNames(
0269:                                            bean_class, null, null, declaration
0270:                                                    .getPrefix());
0271:                                }
0272:
0273:                                for (String property : properties) {
0274:                                    if (ConstrainedUtils
0275:                                            .editConstrainedProperty(
0276:                                                    constrained, property,
0277:                                                    declaration.getPrefix())
0278:                                            && !element_info
0279:                                                    .containsInput(property)) {
0280:                                        element_info.addInput(property, null);
0281:                                    }
0282:                                }
0283:                            } catch (IllegalAccessException e) {
0284:                                throw new InbeanPropertiesCouldntBeRetrievedException(
0285:                                        mDeclaration.getDeclarationName(),
0286:                                        declaration.getClassname(), e);
0287:                            } catch (InstantiationException e) {
0288:                                throw new InbeanPropertiesCouldntBeRetrievedException(
0289:                                        mDeclaration.getDeclarationName(),
0290:                                        declaration.getClassname(), e);
0291:                            } catch (BeanUtilsException e) {
0292:                                throw new InbeanPropertiesCouldntBeRetrievedException(
0293:                                        mDeclaration.getDeclarationName(),
0294:                                        declaration.getClassname(), e);
0295:                            }
0296:                        } catch (ClassNotFoundException e) {
0297:                            throw new InbeanClassNotFoundException(mDeclaration
0298:                                    .getDeclarationName(), declaration
0299:                                    .getClassname());
0300:                        }
0301:                    }
0302:                }
0303:
0304:                if (mOutbeans != null) {
0305:                    String name = null;
0306:                    BeanDeclaration declaration = null;
0307:                    for (Map.Entry<BeanDeclaration, String> outbean : mOutbeans
0308:                            .entrySet()) {
0309:                        name = outbean.getValue();
0310:                        declaration = outbean.getKey();
0311:                        try {
0312:                            Class bean_class = declaration.getBeanClass();
0313:
0314:                            if (name != null) {
0315:                                element_info.addNamedOutbean(name, declaration);
0316:                            }
0317:
0318:                            try {
0319:                                Object instance = bean_class.newInstance();
0320:                                Constrained constrained = ConstrainedUtils
0321:                                        .makeConstrainedInstance(instance);
0322:                                Set<String> properties;
0323:                                if (declaration.getGroupName() != null) {
0324:                                    if (!(instance instanceof  ValidatedConstrained)) {
0325:                                        throw new OutbeanGroupRequiresValidatedConstrainedException(
0326:                                                mDeclaration
0327:                                                        .getDeclarationName(),
0328:                                                declaration.getClassname(),
0329:                                                declaration.getGroupName());
0330:                                    }
0331:
0332:                                    ValidatedConstrained validation = (ValidatedConstrained) instance;
0333:                                    ValidationGroup group = validation
0334:                                            .getGroup(declaration
0335:                                                    .getGroupName());
0336:                                    if (null == group) {
0337:                                        throw new OutbeanGroupNotFoundException(
0338:                                                mDeclaration
0339:                                                        .getDeclarationName(),
0340:                                                declaration.getClassname(),
0341:                                                declaration.getGroupName());
0342:                                    }
0343:                                    properties = new TreeSet<String>();
0344:                                    if (null == declaration.getPrefix()) {
0345:                                        properties.addAll(group
0346:                                                .getPropertyNames());
0347:                                    } else {
0348:                                        for (String property_name : (List<String>) group
0349:                                                .getPropertyNames()) {
0350:                                            properties.add(declaration
0351:                                                    .getPrefix()
0352:                                                    + property_name);
0353:                                        }
0354:                                    }
0355:                                } else {
0356:                                    properties = BeanUtils.getPropertyNames(
0357:                                            bean_class, null, null, declaration
0358:                                                    .getPrefix());
0359:                                }
0360:
0361:                                for (String property : properties) {
0362:                                    if (ConstrainedUtils
0363:                                            .editConstrainedProperty(
0364:                                                    constrained, property,
0365:                                                    declaration.getPrefix())
0366:                                            && !element_info
0367:                                                    .containsOutput(property)) {
0368:                                        element_info.addOutput(property, null);
0369:                                    }
0370:                                }
0371:                            } catch (IllegalAccessException e) {
0372:                                throw new OutbeanPropertiesCouldntBeRetrievedException(
0373:                                        mDeclaration.getDeclarationName(),
0374:                                        declaration.getClassname(), e);
0375:                            } catch (InstantiationException e) {
0376:                                throw new OutbeanPropertiesCouldntBeRetrievedException(
0377:                                        mDeclaration.getDeclarationName(),
0378:                                        declaration.getClassname(), e);
0379:                            } catch (BeanUtilsException e) {
0380:                                throw new OutbeanPropertiesCouldntBeRetrievedException(
0381:                                        mDeclaration.getDeclarationName(),
0382:                                        declaration.getClassname(), e);
0383:                            }
0384:                        } catch (ClassNotFoundException e) {
0385:                            throw new OutbeanClassNotFoundException(
0386:                                    mDeclaration.getDeclarationName(),
0387:                                    declaration.getClassname());
0388:                        }
0389:                    }
0390:                }
0391:
0392:                if (mStaticProperties != null) {
0393:                    for (Map.Entry<String, PropertyValue> property : mStaticProperties
0394:                            .entrySet()) {
0395:                        element_info.addStaticProperty(property.getKey(),
0396:                                property.getValue());
0397:                    }
0398:                }
0399:
0400:                if (mInputs != null) {
0401:                    for (Map.Entry<String, String[]> input : mInputs.entrySet()) {
0402:                        element_info.addInput(input.getKey(), input.getValue());
0403:                    }
0404:                }
0405:
0406:                if (mOutputs != null) {
0407:                    for (Map.Entry<String, String[]> output : mOutputs
0408:                            .entrySet()) {
0409:                        element_info.addOutput(output.getKey(), output
0410:                                .getValue());
0411:                    }
0412:                }
0413:
0414:                if (mIncookies != null) {
0415:                    for (Map.Entry<String, String> incookie : mIncookies
0416:                            .entrySet()) {
0417:                        element_info.addIncookie(incookie.getKey(), incookie
0418:                                .getValue());
0419:                    }
0420:                }
0421:
0422:                if (mOutcookies != null) {
0423:                    for (Map.Entry<String, String> outcookie : mOutcookies
0424:                            .entrySet()) {
0425:                        element_info.addOutcookie(outcookie.getKey(), outcookie
0426:                                .getValue());
0427:                    }
0428:                }
0429:
0430:                if (mExits != null) {
0431:                    for (String exit : mExits) {
0432:                        element_info.addExit(exit);
0433:                    }
0434:                }
0435:
0436:                if (mChildTriggers != null) {
0437:                    for (String name : mChildTriggers) {
0438:                        element_info.addChildTrigger(name);
0439:                    }
0440:                }
0441:
0442:                if (mSubmissionBuilders != null) {
0443:                    for (SubmissionBuilder builder : mSubmissionBuilders) {
0444:                        builder.getSubmission(element_info);
0445:                    }
0446:                }
0447:
0448:                element_info.setPathInfoMode(mPathInfoMode);
0449:                if (mPathInfoMappings != null) {
0450:                    element_info.setPathInfoMappings(mPathInfoMappings);
0451:
0452:                    for (PathInfoMapping mapping : mPathInfoMappings) {
0453:                        for (String input : mapping.getInputs()) {
0454:                            if (!element_info.containsInputPossibility(input)) {
0455:                                element_info.addInput(input, null);
0456:                            }
0457:                        }
0458:                    }
0459:                }
0460:
0461:                return element_info;
0462:            }
0463:
0464:            void registerFlowAndDataLinksInSite(
0465:                    FlowLinkDeclaration focusedFlowlinkDeclaration) {
0466:                if (mDataLinks != null) {
0467:                    for (DataLinkDeclaration datalink_declaration : mDataLinks) {
0468:                        if (focusedFlowlinkDeclaration != null
0469:                                && datalink_declaration
0470:                                        .getFlowLinkDeclaration() != focusedFlowlinkDeclaration) {
0471:                            continue;
0472:                        }
0473:
0474:                        datalink_declaration.makeAbsoluteDestId(mSiteBuilder);
0475:                        mSiteBuilder.addDataLink(mDeclaration.getId(),
0476:                                datalink_declaration, true);
0477:                    }
0478:                }
0479:
0480:                if (mFlowLinks != null) {
0481:                    for (FlowLinkDeclaration flowlink_declaration : mFlowLinks) {
0482:                        if (focusedFlowlinkDeclaration != null
0483:                                && flowlink_declaration != focusedFlowlinkDeclaration) {
0484:                            continue;
0485:                        }
0486:                        flowlink_declaration.makeAbsoluteDestId(mSiteBuilder);
0487:                        mSiteBuilder.addFlowLink(mDeclaration.getId(),
0488:                                flowlink_declaration);
0489:                    }
0490:                }
0491:            }
0492:
0493:            public ElementInfoBuilder setId(String id) throws EngineException {
0494:                if (id != null && 0 == id.length()) {
0495:                    throw new ElementIdInvalidException(id);
0496:                }
0497:
0498:                mDeclaration.setId(id);
0499:
0500:                return this ;
0501:            }
0502:
0503:            public ElementInfoBuilder extendsFrom(String extendsFrom) {
0504:                mExtendsFrom = extendsFrom;
0505:
0506:                return this ;
0507:            }
0508:
0509:            public ElementInfoBuilder setContentType(String contentType) {
0510:                if (null == contentType) {
0511:                    return this ;
0512:                }
0513:
0514:                mContentType = contentType;
0515:
0516:                return this ;
0517:            }
0518:
0519:            public ElementInfoBuilder setImplementation(Class klass) {
0520:                if (null == klass) {
0521:                    return setImplementation((String) null);
0522:                }
0523:
0524:                return setImplementation(klass.getName());
0525:            }
0526:
0527:            public ElementInfoBuilder setImplementation(String implementation) {
0528:                mImplementation = implementation;
0529:
0530:                return this ;
0531:            }
0532:
0533:            public ElementInfoBuilder setImplementation(Element blueprint) {
0534:                if (null == blueprint) {
0535:                    mImplementation = null;
0536:                    mImplementationBlueprint = null;
0537:                } else {
0538:                    mImplementation = blueprint.getClass().getName();
0539:                    mImplementationBlueprint = blueprint;
0540:                }
0541:
0542:                return this ;
0543:            }
0544:
0545:            public String getImplementation() {
0546:                return mImplementation;
0547:            }
0548:
0549:            public ElementInfoBuilder setUrl(String url) {
0550:                if (url != null) {
0551:                    mDeclaration.setUrl(Localization.extractLocalizedUrl(url));
0552:                }
0553:
0554:                return this ;
0555:            }
0556:
0557:            public ElementInfoBuilder setInherits(String inherits) {
0558:                mInherits = inherits;
0559:
0560:                return this ;
0561:            }
0562:
0563:            public ElementInfoBuilder setPre(String pre) {
0564:                mPre = pre;
0565:
0566:                return this ;
0567:            }
0568:
0569:            public ElementInfoBuilder addProperty(String name,
0570:                    PropertyValue value) throws EngineException {
0571:                mDeclaration.addProperty(name, value);
0572:
0573:                return this ;
0574:            }
0575:
0576:            public ElementInfoBuilder addProperty(String name, Object value)
0577:                    throws EngineException {
0578:                mDeclaration.addProperty(name, new PropertyValueObject(value));
0579:
0580:                return this ;
0581:            }
0582:
0583:            public ElementInfoBuilder addDataLink(String srcOutput,
0584:                    String destId, String destInput) throws EngineException {
0585:                addDataLink(srcOutput, null, destId, false, destInput, null);
0586:
0587:                return this ;
0588:            }
0589:
0590:            public ElementInfoBuilder addSnapbackDataLink(String srcOutput,
0591:                    String destInput) throws EngineException {
0592:                addDataLink(srcOutput, null, null, true, destInput, null);
0593:
0594:                return this ;
0595:            }
0596:
0597:            public ElementInfoBuilder addDataLinkBean(String srcOutbean,
0598:                    String destId, String destInbean) throws EngineException {
0599:                addDataLink(null, srcOutbean, destId, false, null, destInbean);
0600:
0601:                return this ;
0602:            }
0603:
0604:            public ElementInfoBuilder addSnapbackDataLinkBean(
0605:                    String srcOutbean, String destInbean)
0606:                    throws EngineException {
0607:                addDataLink(null, srcOutbean, null, true, null, destInbean);
0608:
0609:                return this ;
0610:            }
0611:
0612:            public ElementInfoBuilder addDataLink(String srcOutput,
0613:                    String srcOutbean, String destId, boolean snapback,
0614:                    String destInput, String destInbean) throws EngineException {
0615:                addDataLink(srcOutput, srcOutbean, destId, snapback, destInput,
0616:                        destInbean, null);
0617:
0618:                return this ;
0619:            }
0620:
0621:            void addDataLink(String srcOutput, String srcOutbean,
0622:                    String destId, boolean snapback, String destInput,
0623:                    String destInbean, FlowLinkBuilder flowlink)
0624:                    throws EngineException {
0625:                if (srcOutput != null && 0 == srcOutput.length())
0626:                    srcOutput = null;
0627:                if (srcOutbean != null && 0 == srcOutbean.length())
0628:                    srcOutbean = null;
0629:                if (destId != null && 0 == destId.length())
0630:                    destId = null;
0631:                if (destInput != null && 0 == destInput.length())
0632:                    destInput = null;
0633:                if (destInbean != null && 0 == destInbean.length())
0634:                    destInbean = null;
0635:
0636:                if (null == srcOutput && null == srcOutbean) {
0637:                    throw new DataLinkOutputRequiredException(mSiteBuilder
0638:                            .getDeclarationName(), mDeclaration.getId());
0639:                }
0640:                if (srcOutput != null && srcOutbean != null) {
0641:                    throw new DataLinkAmbiguousOutputException(mSiteBuilder
0642:                            .getDeclarationName(), mDeclaration.getId());
0643:                }
0644:
0645:                if (null == destId && !snapback) {
0646:                    throw new DataLinkTargetRequiredException(mSiteBuilder
0647:                            .getDeclarationName(), mDeclaration.getId(),
0648:                            srcOutput, srcOutbean, destInput, destInbean);
0649:                }
0650:                if (destId != null && snapback) {
0651:                    throw new DataLinkAmbiguousTargetException(mSiteBuilder
0652:                            .getDeclarationName(), mDeclaration.getId(),
0653:                            srcOutput, srcOutbean, destInput, destInbean);
0654:                }
0655:
0656:                if (null == destInput && null == destInbean) {
0657:                    throw new DataLinkInputRequiredException(mSiteBuilder
0658:                            .getDeclarationName(), mDeclaration.getId(),
0659:                            destId, snapback);
0660:                }
0661:                if (destInput != null && destInbean != null) {
0662:                    throw new DataLinkAmbiguousInputException(mSiteBuilder
0663:                            .getDeclarationName(), mDeclaration.getId(),
0664:                            destId, snapback);
0665:                }
0666:
0667:                if ((srcOutput != null && destInbean != null)
0668:                        || (srcOutbean != null && destInput != null)) {
0669:                    throw new DataLinkIncompatibleInputOutputException(
0670:                            mSiteBuilder.getDeclarationName(), mDeclaration
0671:                                    .getId(), destId, snapback);
0672:                }
0673:
0674:                if (null == mDataLinks) {
0675:                    mDataLinks = new ArrayList<DataLinkDeclaration>();
0676:                }
0677:                mDataLinks.add(new DataLinkDeclaration(srcOutput, srcOutbean,
0678:                        destId, snapback, destInput, destInbean, flowlink));
0679:            }
0680:
0681:            public FlowLinkBuilder enterFlowLink(String srcExit)
0682:                    throws EngineException {
0683:                FlowLinkBuilder builder = new FlowLinkBuilder(this , srcExit);
0684:
0685:                return builder;
0686:            }
0687:
0688:            public ElementInfoBuilder addFlowLink(String srcExit, String destId)
0689:                    throws EngineException {
0690:                addFlowLink(srcExit, destId, false, false, false, false);
0691:
0692:                return this ;
0693:            }
0694:
0695:            public ElementInfoBuilder addFlowLink(String srcExit,
0696:                    String destId, boolean cancelInheritance)
0697:                    throws EngineException {
0698:                addFlowLink(srcExit, destId, false, cancelInheritance, false,
0699:                        false);
0700:
0701:                return this ;
0702:            }
0703:
0704:            public ElementInfoBuilder addFlowLink(String srcExit,
0705:                    String destId, boolean cancelInheritance,
0706:                    boolean cancelEmbedding) throws EngineException {
0707:                addFlowLink(srcExit, destId, false, cancelInheritance,
0708:                        cancelEmbedding, false);
0709:
0710:                return this ;
0711:            }
0712:
0713:            public ElementInfoBuilder addSnapbackFlowLink(String srcExit,
0714:                    boolean cancelInheritance) throws EngineException {
0715:                addFlowLink(srcExit, null, true, cancelInheritance, false,
0716:                        false);
0717:
0718:                return this ;
0719:            }
0720:
0721:            public ElementInfoBuilder addRedirectFlowLink(String srcExit,
0722:                    String destId) throws EngineException {
0723:                addFlowLink(srcExit, destId, false, false, false, true);
0724:
0725:                return this ;
0726:            }
0727:
0728:            public ElementInfoBuilder addFlowLink(String srcExit,
0729:                    String destId, boolean snapback, boolean cancelInheritance,
0730:                    boolean cancelEmbedding, boolean redirect)
0731:                    throws EngineException {
0732:                return enterFlowLink(srcExit).destId(destId).snapback(snapback)
0733:                        .cancelInheritance(cancelInheritance).cancelEmbedding(
0734:                                cancelEmbedding).redirect(redirect)
0735:                        .leaveFlowLink();
0736:            }
0737:
0738:            public ElementInfoBuilder addAutoLink(String srcExit)
0739:                    throws EngineException {
0740:                addAutoLink(srcExit, null, false, false, false, false);
0741:
0742:                return this ;
0743:            }
0744:
0745:            public ElementInfoBuilder addAutoLink(String srcExit, String destId)
0746:                    throws EngineException {
0747:                addAutoLink(srcExit, destId, false, false, false, false);
0748:
0749:                return this ;
0750:            }
0751:
0752:            public ElementInfoBuilder addRedirectAutoLink(String srcExit)
0753:                    throws EngineException {
0754:                addAutoLink(srcExit, null, false, false, true, false);
0755:
0756:                return this ;
0757:            }
0758:
0759:            public ElementInfoBuilder addRedirectAutoLink(String srcExit,
0760:                    String destId) throws EngineException {
0761:                addAutoLink(srcExit, destId, false, false, true, false);
0762:
0763:                return this ;
0764:            }
0765:
0766:            public ElementInfoBuilder addAutoLink(String srcExit,
0767:                    String destId, boolean cancelInheritance,
0768:                    boolean cancelEmbedding, boolean redirect,
0769:                    boolean cancelContinuations) throws EngineException {
0770:                addAutoLinkDeclaration(new AutoLinkDeclaration(this , srcExit,
0771:                        destId, cancelInheritance, cancelEmbedding, redirect,
0772:                        cancelContinuations));
0773:                return this ;
0774:            }
0775:
0776:            void addFlowLinkDeclaration(FlowLinkDeclaration declaration) {
0777:                if (null == mFlowLinks) {
0778:                    mFlowLinks = new ArrayList<FlowLinkDeclaration>();
0779:                }
0780:                mFlowLinks.add(declaration);
0781:            }
0782:
0783:            void addAutoLinkDeclaration(AutoLinkDeclaration declaration) {
0784:                if (null == mAutoLinks) {
0785:                    mAutoLinks = new ArrayList<AutoLinkDeclaration>();
0786:                }
0787:                mAutoLinks.add(declaration);
0788:            }
0789:
0790:            public ElementInfoBuilder addInBean(String classname) {
0791:                return addInBean(classname, null, null, null);
0792:            }
0793:
0794:            public ElementInfoBuilder addInBean(String classname, String prefix) {
0795:                return addInBean(classname, prefix, null, null);
0796:            }
0797:
0798:            public ElementInfoBuilder addInBean(String classname,
0799:                    String prefix, String name) {
0800:                return addInBean(classname, prefix, name, null);
0801:            }
0802:
0803:            public ElementInfoBuilder addInBean(String classname,
0804:                    String prefix, String name, String groupName) {
0805:                BeanDeclaration bean_declaration = new BeanDeclaration(
0806:                        classname, prefix, groupName);
0807:
0808:                return addInBean(bean_declaration, name);
0809:            }
0810:
0811:            public ElementInfoBuilder addInBean(Class klass) {
0812:                return addInBean(klass, null, null, null);
0813:            }
0814:
0815:            public ElementInfoBuilder addInBean(Class klass, String prefix) {
0816:                return addInBean(klass, prefix, null, null);
0817:            }
0818:
0819:            public ElementInfoBuilder addInBean(Class klass, String prefix,
0820:                    String name) {
0821:                return addInBean(klass, prefix, name, null);
0822:            }
0823:
0824:            public ElementInfoBuilder addInBean(Class klass, String prefix,
0825:                    String name, String groupName) {
0826:                if (prefix != null && 0 == prefix.length())
0827:                    prefix = null;
0828:                if (name != null && 0 == name.length())
0829:                    name = null;
0830:                if (groupName != null && 0 == groupName.length())
0831:                    groupName = null;
0832:
0833:                BeanDeclaration bean_declaration = new BeanDeclaration(klass,
0834:                        prefix, groupName);
0835:
0836:                return addInBean(bean_declaration, name);
0837:            }
0838:
0839:            private ElementInfoBuilder addInBean(
0840:                    BeanDeclaration beanDeclaration, String name) {
0841:                if (null == mInbeans) {
0842:                    mInbeans = new LinkedHashMap<BeanDeclaration, String>();
0843:                }
0844:
0845:                mInbeans.put(beanDeclaration, name);
0846:
0847:                return this ;
0848:            }
0849:
0850:            public ElementInfoBuilder addOutBean(String classname) {
0851:                return addOutBean(classname, null, null, null);
0852:            }
0853:
0854:            public ElementInfoBuilder addOutBean(String classname, String prefix) {
0855:                return addOutBean(classname, prefix, null, null);
0856:            }
0857:
0858:            public ElementInfoBuilder addOutBean(String classname,
0859:                    String prefix, String name) {
0860:                return addOutBean(classname, prefix, name, null);
0861:            }
0862:
0863:            public ElementInfoBuilder addOutBean(String classname,
0864:                    String prefix, String name, String groupName) {
0865:                BeanDeclaration bean_declaration = new BeanDeclaration(
0866:                        classname, prefix, groupName);
0867:
0868:                return addOutBean(bean_declaration, name);
0869:            }
0870:
0871:            public ElementInfoBuilder addOutBean(Class klass) {
0872:                return addOutBean(klass, null, null, null);
0873:            }
0874:
0875:            public ElementInfoBuilder addOutBean(Class klass, String prefix) {
0876:                return addOutBean(klass, prefix, null, null);
0877:            }
0878:
0879:            public ElementInfoBuilder addOutBean(Class klass, String prefix,
0880:                    String name) {
0881:                return addOutBean(klass, prefix, name, null);
0882:            }
0883:
0884:            public ElementInfoBuilder addOutBean(Class klass, String prefix,
0885:                    String name, String groupName) {
0886:                if (prefix != null && 0 == prefix.length())
0887:                    prefix = null;
0888:                if (name != null && 0 == name.length())
0889:                    name = null;
0890:                if (groupName != null && 0 == groupName.length())
0891:                    groupName = null;
0892:
0893:                BeanDeclaration bean_declaration = new BeanDeclaration(klass,
0894:                        prefix, groupName);
0895:
0896:                return addOutBean(bean_declaration, name);
0897:            }
0898:
0899:            private ElementInfoBuilder addOutBean(
0900:                    BeanDeclaration beanDeclaration, String name) {
0901:                if (null == mOutbeans) {
0902:                    mOutbeans = new LinkedHashMap<BeanDeclaration, String>();
0903:                }
0904:
0905:                mOutbeans.put(beanDeclaration, name);
0906:
0907:                return this ;
0908:            }
0909:
0910:            public ElementInfoBuilder addStaticProperty(String name,
0911:                    Object value) throws EngineException {
0912:                return addStaticProperty(name, new PropertyValueObject(value));
0913:            }
0914:
0915:            public ElementInfoBuilder addStaticProperty(String name,
0916:                    PropertyValue value) {
0917:                if (null == mStaticProperties) {
0918:                    mStaticProperties = new LinkedHashMap<String, PropertyValue>();
0919:                }
0920:
0921:                mStaticProperties.put(name, value);
0922:
0923:                return this ;
0924:            }
0925:
0926:            public ElementInfoBuilder addInput(String name) {
0927:                return addInput(name, null);
0928:            }
0929:
0930:            public ElementInfoBuilder addInput(String name,
0931:                    String[] defaultValues) {
0932:                if (null == mInputs) {
0933:                    mInputs = new LinkedHashMap<String, String[]>();
0934:                }
0935:
0936:                mInputs.put(name, defaultValues);
0937:
0938:                return this ;
0939:            }
0940:
0941:            public ElementInfoBuilder addOutput(String name) {
0942:                return addOutput(name, null);
0943:            }
0944:
0945:            public ElementInfoBuilder addOutput(String name,
0946:                    String[] defaultValues) {
0947:                if (null == mOutputs) {
0948:                    mOutputs = new LinkedHashMap<String, String[]>();
0949:                }
0950:
0951:                mOutputs.put(name, defaultValues);
0952:
0953:                return this ;
0954:            }
0955:
0956:            public ElementInfoBuilder addIncookie(String name) {
0957:                return addIncookie(name, null);
0958:            }
0959:
0960:            public ElementInfoBuilder addIncookie(String name,
0961:                    String defaultValue) {
0962:                if (null == mIncookies) {
0963:                    mIncookies = new LinkedHashMap<String, String>();
0964:                }
0965:
0966:                mIncookies.put(name, defaultValue);
0967:
0968:                return this ;
0969:            }
0970:
0971:            public ElementInfoBuilder addOutcookie(String name) {
0972:                return addOutcookie(name, null);
0973:            }
0974:
0975:            public ElementInfoBuilder addOutcookie(String name,
0976:                    String defaultValue) {
0977:                if (null == mOutcookies) {
0978:                    mOutcookies = new LinkedHashMap<String, String>();
0979:                }
0980:
0981:                mOutcookies.put(name, defaultValue);
0982:
0983:                return this ;
0984:            }
0985:
0986:            public ElementInfoBuilder addExit(String name) {
0987:                if (null == mExits) {
0988:                    mExits = new ArrayList<String>();
0989:                }
0990:
0991:                mExits.add(name);
0992:
0993:                return this ;
0994:            }
0995:
0996:            public ElementInfoBuilder addChildTrigger(String name) {
0997:                if (null == mChildTriggers) {
0998:                    mChildTriggers = new ArrayList<String>();
0999:                }
1000:
1001:                mChildTriggers.add(name);
1002:
1003:                return this ;
1004:            }
1005:
1006:            public SubmissionBuilder enterSubmission(String name) {
1007:                if (null == mSubmissionBuilders) {
1008:                    mSubmissionBuilders = new ArrayList<SubmissionBuilder>();
1009:                }
1010:
1011:                SubmissionBuilder builder = new SubmissionBuilder(this , name);
1012:                mSubmissionBuilders.add(builder);
1013:
1014:                return builder;
1015:            }
1016:
1017:            public ElementInfoBuilder addResourceModificationTime(
1018:                    UrlResource resource, long modificationTime) {
1019:                mSiteBuilder.addResourceModificationTime(resource,
1020:                        modificationTime);
1021:
1022:                return this ;
1023:            }
1024:
1025:            public SiteBuilder leaveElement() {
1026:                return mSiteBuilder;
1027:            }
1028:
1029:            public ElementInfoBuilder setPathInfoMode(PathInfoMode mode) {
1030:                mPathInfoMode = mode;
1031:
1032:                return this ;
1033:            }
1034:
1035:            public ElementInfoBuilder addPathInfoMapping(String specification) {
1036:                PathInfoMapping mapping = PathInfoMapping.create(specification);
1037:                if (null == mapping) {
1038:                    return this ;
1039:                }
1040:
1041:                if (null == mPathInfoMappings) {
1042:                    mPathInfoMappings = new ArrayList<PathInfoMapping>();
1043:                }
1044:
1045:                mPathInfoMappings.add(mapping);
1046:
1047:                return this ;
1048:            }
1049:
1050:            SiteBuilder getSiteBuilder() {
1051:                return mSiteBuilder;
1052:            }
1053:
1054:            ElementDeclaration getElementDeclaration() {
1055:                return mDeclaration;
1056:            }
1057:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.